Remove root_surface_transformation from PaintContext (#6213)

It should be sufficient to provide the matrix to preroll.
This commit is contained in:
liyuqian
2018-09-11 15:29:08 -07:00
committed by GitHub
parent 565a19489a
commit 7ac3345c65
6 changed files with 18 additions and 30 deletions
-1
View File
@@ -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;
+12 -14
View File
@@ -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<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);
+1 -2
View File
@@ -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());
}
+2 -6
View File
@@ -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);
}
+1 -2
View File
@@ -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_;
+2 -5
View File
@@ -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);