diff --git a/flow/layers/layer.h b/flow/layers/layer.h index 53e32941e8d1d..173c2890b6ae8 100644 --- a/flow/layers/layer.h +++ b/flow/layers/layer.h @@ -57,7 +57,6 @@ class Layer { struct PaintContext { SkCanvas& canvas; - const SkMatrix& root_surface_transformation; const Stopwatch& frame_time; const Stopwatch& engine_time; TextureRegistry& texture_registry; diff --git a/flow/layers/layer_tree.cc b/flow/layers/layer_tree.cc index 007bd0fbd9530..29f9c93b52c19 100644 --- a/flow/layers/layer_tree.cc +++ b/flow/layers/layer_tree.cc @@ -32,7 +32,7 @@ void LayerTree::Preroll(CompositorContext::ScopedFrame& frame, SkRect::MakeEmpty(), }; - root_layer_->Preroll(&context, SkMatrix::I()); + root_layer_->Preroll(&context, frame.root_surface_transformation()); } #if defined(OS_FUCHSIA) @@ -63,12 +63,11 @@ void LayerTree::UpdateScene(SceneUpdateContext& context, void LayerTree::Paint(CompositorContext::ScopedFrame& frame) const { TRACE_EVENT0("flutter", "LayerTree::Paint"); Layer::PaintContext context = { - *frame.canvas(), // - frame.root_surface_transformation(), // - frame.context().frame_time(), // - frame.context().engine_time(), // - frame.context().texture_registry(), // - checkerboard_offscreen_layers_ // + *frame.canvas(), // + frame.context().frame_time(), // + frame.context().engine_time(), // + frame.context().texture_registry(), // + checkerboard_offscreen_layers_ // }; if (root_layer_->needs_painting()) @@ -99,18 +98,17 @@ sk_sp LayerTree::Flatten(const SkRect& bounds) { root_surface_transformation.reset(); Layer::PaintContext paint_context = { - *canvas, // canvas - root_surface_transformation, // root surface transformation - unused_stopwatch, // frame time (dont care) - unused_stopwatch, // engine time (dont care) - unused_texture_registry, // texture registry (not supported) - false // checkerboard offscreen layers + *canvas, // canvas + unused_stopwatch, // frame time (dont care) + unused_stopwatch, // engine time (dont care) + unused_texture_registry, // texture registry (not supported) + false // checkerboard offscreen layers }; // Even if we don't have a root layer, we still need to create an empty // picture. if (root_layer_) { - root_layer_->Preroll(&preroll_context, SkMatrix::I()); + root_layer_->Preroll(&preroll_context, root_surface_transformation); // The needs painting flag may be set after the preroll. So check it after. if (root_layer_->needs_painting()) { root_layer_->Paint(paint_context); diff --git a/flow/layers/picture_layer.cc b/flow/layers/picture_layer.cc index 9389e0862c398..3cbf15a609ad1 100644 --- a/flow/layers/picture_layer.cc +++ b/flow/layers/picture_layer.cc @@ -45,8 +45,7 @@ void PictureLayer::Paint(PaintContext& context) const { #endif if (raster_cache_result_.is_valid()) { - raster_cache_result_.draw(context.canvas, - context.root_surface_transformation); + raster_cache_result_.draw(context.canvas); } else { context.canvas.drawPicture(picture()); } diff --git a/flow/raster_cache.cc b/flow/raster_cache.cc index aadebb72d039e..a3aef6e3d1410 100644 --- a/flow/raster_cache.cc +++ b/flow/raster_cache.cc @@ -17,16 +17,12 @@ namespace flow { -void RasterCacheResult::draw( - SkCanvas& canvas, - const SkMatrix& root_surface_transformation) const { +void RasterCacheResult::draw(SkCanvas& canvas) const { SkAutoCanvasRestore auto_restore(&canvas, true); SkIRect bounds = RasterCache::GetDeviceBounds(logical_rect_, canvas.getTotalMatrix()); FML_DCHECK(bounds.size() == image_->dimensions()); - // Clear all transformations on the canvas except the root surface - // transormation. - canvas.setMatrix(root_surface_transformation); + canvas.resetMatrix(); canvas.drawImage(image_, bounds.fLeft, bounds.fTop); } diff --git a/flow/raster_cache.h b/flow/raster_cache.h index b2084d3bf1c74..348ab8000da39 100644 --- a/flow/raster_cache.h +++ b/flow/raster_cache.h @@ -28,8 +28,7 @@ class RasterCacheResult { bool is_valid() const { return static_cast(image_); }; - void draw(SkCanvas& canvas, - const SkMatrix& root_surface_transformation) const; + void draw(SkCanvas& canvas) const; private: sk_sp image_; diff --git a/flow/scene_update_context.cc b/flow/scene_update_context.cc index 1da575bf56f12..576bde7fa1aff 100644 --- a/flow/scene_update_context.cc +++ b/flow/scene_update_context.cc @@ -187,12 +187,9 @@ SceneUpdateContext::ExecutePaintTasks(CompositorContext::ScopedFrame& frame) { for (auto& task : paint_tasks_) { FML_DCHECK(task.surface); SkCanvas* canvas = task.surface->GetSkiaSurface()->getCanvas(); - Layer::PaintContext context = {*canvas, - frame.root_surface_transformation(), - frame.context().frame_time(), + Layer::PaintContext context = {*canvas, frame.context().frame_time(), frame.context().engine_time(), - frame.context().texture_registry(), - false}; + frame.context().texture_registry(), false}; canvas->restoreToCount(1); canvas->save(); canvas->clear(task.background_color);