Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7ac3345

Browse files
authored
Remove root_surface_transformation from PaintContext (#6213)
It should be sufficient to provide the matrix to preroll.
1 parent 565a194 commit 7ac3345

File tree

6 files changed

+18
-30
lines changed

6 files changed

+18
-30
lines changed

flow/layers/layer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class Layer {
5757

5858
struct PaintContext {
5959
SkCanvas& canvas;
60-
const SkMatrix& root_surface_transformation;
6160
const Stopwatch& frame_time;
6261
const Stopwatch& engine_time;
6362
TextureRegistry& texture_registry;

flow/layers/layer_tree.cc

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ void LayerTree::Preroll(CompositorContext::ScopedFrame& frame,
3232
SkRect::MakeEmpty(),
3333
};
3434

35-
root_layer_->Preroll(&context, SkMatrix::I());
35+
root_layer_->Preroll(&context, frame.root_surface_transformation());
3636
}
3737

3838
#if defined(OS_FUCHSIA)
@@ -63,12 +63,11 @@ void LayerTree::UpdateScene(SceneUpdateContext& context,
6363
void LayerTree::Paint(CompositorContext::ScopedFrame& frame) const {
6464
TRACE_EVENT0("flutter", "LayerTree::Paint");
6565
Layer::PaintContext context = {
66-
*frame.canvas(), //
67-
frame.root_surface_transformation(), //
68-
frame.context().frame_time(), //
69-
frame.context().engine_time(), //
70-
frame.context().texture_registry(), //
71-
checkerboard_offscreen_layers_ //
66+
*frame.canvas(), //
67+
frame.context().frame_time(), //
68+
frame.context().engine_time(), //
69+
frame.context().texture_registry(), //
70+
checkerboard_offscreen_layers_ //
7271
};
7372

7473
if (root_layer_->needs_painting())
@@ -99,18 +98,17 @@ sk_sp<SkPicture> LayerTree::Flatten(const SkRect& bounds) {
9998
root_surface_transformation.reset();
10099

101100
Layer::PaintContext paint_context = {
102-
*canvas, // canvas
103-
root_surface_transformation, // root surface transformation
104-
unused_stopwatch, // frame time (dont care)
105-
unused_stopwatch, // engine time (dont care)
106-
unused_texture_registry, // texture registry (not supported)
107-
false // checkerboard offscreen layers
101+
*canvas, // canvas
102+
unused_stopwatch, // frame time (dont care)
103+
unused_stopwatch, // engine time (dont care)
104+
unused_texture_registry, // texture registry (not supported)
105+
false // checkerboard offscreen layers
108106
};
109107

110108
// Even if we don't have a root layer, we still need to create an empty
111109
// picture.
112110
if (root_layer_) {
113-
root_layer_->Preroll(&preroll_context, SkMatrix::I());
111+
root_layer_->Preroll(&preroll_context, root_surface_transformation);
114112
// The needs painting flag may be set after the preroll. So check it after.
115113
if (root_layer_->needs_painting()) {
116114
root_layer_->Paint(paint_context);

flow/layers/picture_layer.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ void PictureLayer::Paint(PaintContext& context) const {
4545
#endif
4646

4747
if (raster_cache_result_.is_valid()) {
48-
raster_cache_result_.draw(context.canvas,
49-
context.root_surface_transformation);
48+
raster_cache_result_.draw(context.canvas);
5049
} else {
5150
context.canvas.drawPicture(picture());
5251
}

flow/raster_cache.cc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,12 @@
1717

1818
namespace flow {
1919

20-
void RasterCacheResult::draw(
21-
SkCanvas& canvas,
22-
const SkMatrix& root_surface_transformation) const {
20+
void RasterCacheResult::draw(SkCanvas& canvas) const {
2321
SkAutoCanvasRestore auto_restore(&canvas, true);
2422
SkIRect bounds =
2523
RasterCache::GetDeviceBounds(logical_rect_, canvas.getTotalMatrix());
2624
FML_DCHECK(bounds.size() == image_->dimensions());
27-
// Clear all transformations on the canvas except the root surface
28-
// transormation.
29-
canvas.setMatrix(root_surface_transformation);
25+
canvas.resetMatrix();
3026
canvas.drawImage(image_, bounds.fLeft, bounds.fTop);
3127
}
3228

flow/raster_cache.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ class RasterCacheResult {
2828

2929
bool is_valid() const { return static_cast<bool>(image_); };
3030

31-
void draw(SkCanvas& canvas,
32-
const SkMatrix& root_surface_transformation) const;
31+
void draw(SkCanvas& canvas) const;
3332

3433
private:
3534
sk_sp<SkImage> image_;

flow/scene_update_context.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,12 +187,9 @@ SceneUpdateContext::ExecutePaintTasks(CompositorContext::ScopedFrame& frame) {
187187
for (auto& task : paint_tasks_) {
188188
FML_DCHECK(task.surface);
189189
SkCanvas* canvas = task.surface->GetSkiaSurface()->getCanvas();
190-
Layer::PaintContext context = {*canvas,
191-
frame.root_surface_transformation(),
192-
frame.context().frame_time(),
190+
Layer::PaintContext context = {*canvas, frame.context().frame_time(),
193191
frame.context().engine_time(),
194-
frame.context().texture_registry(),
195-
false};
192+
frame.context().texture_registry(), false};
196193
canvas->restoreToCount(1);
197194
canvas->save();
198195
canvas->clear(task.background_color);

0 commit comments

Comments
 (0)