From e2a449a519e78814b4c2700940829994fd451a57 Mon Sep 17 00:00:00 2001 From: liyuqian Date: Fri, 22 Feb 2019 12:48:04 -0800 Subject: [PATCH] Move canvas clear after preroll (#7923) This will reduce 1 render target switch when preroll paints some raster cache. --- flow/compositor_context.cc | 5 +++++ shell/common/rasterizer.cc | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/flow/compositor_context.cc b/flow/compositor_context.cc index 8dc6883597999..30f1132818b2c 100644 --- a/flow/compositor_context.cc +++ b/flow/compositor_context.cc @@ -63,6 +63,11 @@ CompositorContext::ScopedFrame::~ScopedFrame() { bool CompositorContext::ScopedFrame::Raster(flow::LayerTree& layer_tree, bool ignore_raster_cache) { layer_tree.Preroll(*this, ignore_raster_cache); + // Clearing canvas after preroll reduces one render target switch when preroll + // paints some raster cache. + if (canvas()) { + canvas()->clear(SK_ColorTRANSPARENT); + } layer_tree.Paint(*this, ignore_raster_cache); return true; } diff --git a/shell/common/rasterizer.cc b/shell/common/rasterizer.cc index 48e8ea41aff00..39766a5877c99 100644 --- a/shell/common/rasterizer.cc +++ b/shell/common/rasterizer.cc @@ -181,10 +181,6 @@ bool Rasterizer::DrawToSurface(flow::LayerTree& layer_tree) { surface_->GetContext(), canvas, external_view_embedder, surface_->GetRootTransformation(), true); - if (canvas) { - canvas->clear(SK_ColorTRANSPARENT); - } - if (compositor_frame && compositor_frame->Raster(layer_tree, false)) { frame->Submit(); if (external_view_embedder != nullptr) {