Add pushOffset to SceneBuilder (flutter/engine#6349)
For https://github.com/flutter/flutter/pull/21619#discussion_r220390088
This commit is contained in:
@@ -64,6 +64,13 @@ class SceneBuilder extends NativeFieldWrapperClass2 {
|
||||
}
|
||||
void _pushTransform(Float64List matrix4) native 'SceneBuilder_pushTransform';
|
||||
|
||||
/// Pushes an offset operation onto the operation stack.
|
||||
///
|
||||
/// This is equivalent to [pushTransform] with a matrix with only translation.
|
||||
///
|
||||
/// See [pop] for details about the operation stack.
|
||||
void pushOffset(double dx, double dy) native 'SceneBuilder_pushOffset';
|
||||
|
||||
/// Pushes a rectangular clip operation onto the operation stack.
|
||||
///
|
||||
/// Rasterization outside the given rectangle is discarded.
|
||||
|
||||
@@ -93,6 +93,13 @@ void SceneBuilder::pushTransform(const tonic::Float64List& matrix4) {
|
||||
PushLayer(std::move(layer), cullRect);
|
||||
}
|
||||
|
||||
void SceneBuilder::pushOffset(double dx, double dy) {
|
||||
SkMatrix sk_matrix = SkMatrix::MakeTrans(dx, dy);
|
||||
auto layer = std::make_unique<flow::TransformLayer>();
|
||||
layer->set_transform(sk_matrix);
|
||||
PushLayer(std::move(layer), cull_rects_.top().makeOffset(-dx, -dy));
|
||||
}
|
||||
|
||||
void SceneBuilder::pushClipRect(double left,
|
||||
double right,
|
||||
double top,
|
||||
|
||||
@@ -33,6 +33,7 @@ class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
|
||||
~SceneBuilder() override;
|
||||
|
||||
void pushTransform(const tonic::Float64List& matrix4);
|
||||
void pushOffset(double dx, double dy);
|
||||
void pushClipRect(double left,
|
||||
double right,
|
||||
double top,
|
||||
|
||||
Reference in New Issue
Block a user