When rasterizing to a recorder backed canvas for SKP tracing, don’t attempt to update the raster cache. (flutter/engine#2983)

We could get into a situation where the second time we rasterize a picture for an SKP, the raster cache detects that the same picture is being repeated in subsequent onscreen frames and then proceeds to rasterize the contents to an offscreen texture. This not only causes an unnecessary cache entry, but also shows the cached image in the final SKP trace (which is not what was originally displayed on screen).
This commit is contained in:
Chinmay Garde
2016-08-30 14:52:39 -07:00
committed by GitHub
parent 0df374dd83
commit 332de9c7d2
4 changed files with 14 additions and 10 deletions

View File

@@ -41,7 +41,7 @@ class Layer {
virtual ~Layer();
struct PrerollContext {
RasterCache& raster_cache;
RasterCache* raster_cache;
GrContext* gr_context;
SkRect child_paint_bounds;
};

View File

@@ -13,20 +13,20 @@ LayerTree::LayerTree() : scene_version_(0), rasterizer_tracing_threshold_(0) {}
LayerTree::~LayerTree() {}
void LayerTree::Raster(CompositorContext::ScopedFrame& frame) {
void LayerTree::Raster(CompositorContext::ScopedFrame& frame,
bool ignore_raster_cache) {
{
TRACE_EVENT0("flutter", "LayerTree::Preroll");
Layer::PrerollContext context = {
frame.context().raster_cache(), frame.gr_context(), SkRect::MakeEmpty(),
ignore_raster_cache ? nullptr : &frame.context().raster_cache(),
frame.gr_context(), SkRect::MakeEmpty(),
};
root_layer_->Preroll(&context, SkMatrix());
}
{
Layer::PaintContext context = {
frame.canvas(), frame.context().frame_time(),
frame.context().engine_time(),
};
Layer::PaintContext context = {frame.canvas(), frame.context().frame_time(),
frame.context().engine_time()};
TRACE_EVENT0("flutter", "LayerTree::Paint");
root_layer_->Paint(context);
}

View File

@@ -23,7 +23,8 @@ class LayerTree {
~LayerTree();
void Raster(CompositorContext::ScopedFrame& frame);
void Raster(CompositorContext::ScopedFrame& frame,
bool ignore_raster_cache = false);
// TODO(abarth): Integrate scene updates with the rasterization pass so that
// we can draw on top of child scenes (and so that we can apply clips and

View File

@@ -14,8 +14,11 @@ PictureLayer::PictureLayer() {}
PictureLayer::~PictureLayer() {}
void PictureLayer::Preroll(PrerollContext* context, const SkMatrix& matrix) {
image_ = context->raster_cache.GetPrerolledImage(
context->gr_context, picture_.get(), matrix, is_complex_, will_change_);
if (auto cache = context->raster_cache) {
image_ = cache->GetPrerolledImage(context->gr_context, picture_.get(),
matrix, is_complex_, will_change_);
}
context->child_paint_bounds =
picture_->cullRect().makeOffset(offset_.x(), offset_.y());
}