| Index: cc/raster/gpu_rasterizer.cc
|
| diff --git a/cc/raster/gpu_rasterizer.cc b/cc/raster/gpu_rasterizer.cc
|
| index f8f8b43d35ee0d7a28cfac872f44a8d592d08737..b17be3b1d9b6b033392ab9eb6d689265fbbaaded 100644
|
| --- a/cc/raster/gpu_rasterizer.cc
|
| +++ b/cc/raster/gpu_rasterizer.cc
|
| @@ -12,6 +12,7 @@
|
| #include "cc/debug/devtools_instrumentation.h"
|
| #include "cc/debug/frame_viewer_instrumentation.h"
|
| #include "cc/output/context_provider.h"
|
| +#include "cc/playback/image_hijack_canvas.h"
|
| #include "cc/playback/raster_source.h"
|
| #include "cc/raster/raster_buffer.h"
|
| #include "cc/raster/scoped_gpu_raster.h"
|
| @@ -52,8 +53,17 @@ void GpuRasterizer::RasterizeSource(
|
| sk_sp<SkCanvas> canvas = sk_ref_sp(
|
| recorder.beginRecording(size.width(), size.height(), NULL, flags));
|
| canvas->save();
|
| + // The GPU image decode controller assumes that Skia is done with an image
|
| + // when playback is complete. However, in this case, where we play back to a
|
| + // picture, we don't actually finish with the images until the picture is
|
| + // rasterized later. This can cause lifetime issues in the GPU image decode
|
| + // controller. To avoid this, we disable the image hijack canvas (and image
|
| + // decode controller) for this playback step, instead enabling it for the
|
| + // later picture rasterization.
|
| + RasterSource::PlaybackSettings settings = playback_settings;
|
| + settings.use_image_hijack_canvas = false;
|
| raster_source->PlaybackToCanvas(canvas.get(), raster_full_rect, playback_rect,
|
| - scale, playback_settings);
|
| + scale, settings);
|
| canvas->restore();
|
| sk_sp<SkPicture> picture = recorder.finishRecordingAsPicture();
|
|
|
| @@ -77,8 +87,27 @@ void GpuRasterizer::RasterizeSource(
|
| if (!sk_surface)
|
| return;
|
|
|
| + // As we did not use the image hijack canvas during the initial playback to
|
| + // |picture| (see PlaybackToPicture), we must enable it here if requested.
|
| + SkCanvas* canvas = sk_surface->getCanvas();
|
| + std::unique_ptr<ImageHijackCanvas> hijack_canvas;
|
| + if (playback_settings.use_image_hijack_canvas) {
|
| + const SkImageInfo& info = canvas->imageInfo();
|
| + hijack_canvas.reset(
|
| + new ImageHijackCanvas(info.width(), info.height(),
|
| + raster_source->image_decode_controller()));
|
| + SkIRect raster_bounds;
|
| + canvas->getClipDeviceBounds(&raster_bounds);
|
| + hijack_canvas->clipRect(SkRect::MakeFromIRect(raster_bounds));
|
| + hijack_canvas->setMatrix(canvas->getTotalMatrix());
|
| + hijack_canvas->addCanvas(canvas);
|
| +
|
| + // Replace canvas with our ImageHijackCanvas which is wrapping it.
|
| + canvas = hijack_canvas.get();
|
| + }
|
| +
|
| SkMultiPictureDraw multi_picture_draw;
|
| - multi_picture_draw.add(sk_surface->getCanvas(), picture.get());
|
| + multi_picture_draw.add(canvas, picture.get());
|
| multi_picture_draw.draw(false);
|
| write_lock->ReleaseSkSurface();
|
| }
|
|
|