Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion flow/layers/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
26 changes: 12 additions & 14 deletions flow/layers/layer_tree.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -99,18 +98,17 @@ sk_sp<SkPicture> 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);
Expand Down
3 changes: 1 addition & 2 deletions flow/layers/picture_layer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
8 changes: 2 additions & 6 deletions flow/raster_cache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions flow/raster_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class RasterCacheResult {

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

void draw(SkCanvas& canvas,
const SkMatrix& root_surface_transformation) const;
void draw(SkCanvas& canvas) const;

private:
sk_sp<SkImage> image_;
Expand Down
7 changes: 2 additions & 5 deletions flow/scene_update_context.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down