Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Unified Diff: cc/resources/gpu_raster_worker_pool.cc

Issue 659563002: cc: Replace RasterBuffer::Acquire/ReleaseCanvas with Playback function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: cc/resources/gpu_raster_worker_pool.cc
diff --git a/cc/resources/gpu_raster_worker_pool.cc b/cc/resources/gpu_raster_worker_pool.cc
index 229a3f768dcdaf999111c8ae1011eb00029a8206..faffb3515f90b1d1ba4bcca9fa4904a3ed34ce4c 100644
--- a/cc/resources/gpu_raster_worker_pool.cc
+++ b/cc/resources/gpu_raster_worker_pool.cc
@@ -8,6 +8,7 @@
#include "base/debug/trace_event.h"
#include "cc/output/context_provider.h"
+#include "cc/resources/picture_pile_impl.h"
#include "cc/resources/raster_buffer.h"
#include "cc/resources/resource.h"
#include "cc/resources/resource_provider.h"
@@ -17,7 +18,6 @@
#include "third_party/skia/include/core/SkPictureRecorder.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "third_party/skia/include/gpu/GrContext.h"
-#include "third_party/skia/include/utils/SkNullCanvas.h"
namespace cc {
namespace {
@@ -32,27 +32,23 @@ class RasterBufferImpl : public RasterBuffer {
multi_picture_draw_(multi_picture_draw) {}
// Overridden from RasterBuffer:
- virtual skia::RefPtr<SkCanvas> AcquireSkCanvas() override {
+ virtual void Playback(const PicturePileImpl* picture_pile,
+ const gfx::Rect& rect,
+ float scale,
+ RenderingStatsInstrumentation* stats) override {
if (!lock_.sk_surface())
- return skia::AdoptRef(SkCreateNullCanvas());
+ return;
- skia::RefPtr<SkCanvas> canvas = skia::SharePtr(recorder_.beginRecording(
+ SkPictureRecorder recorder;
+ skia::RefPtr<SkCanvas> canvas = skia::SharePtr(recorder.beginRecording(
resource_->size().width(), resource_->size().height()));
vmpstr 2014/10/15 00:09:30 nit: Can you make size a variable above?
reveman 2014/10/15 01:24:06 Done.
- // Balanced with restore() call in ReleaseSkCanvas. save()/restore() calls
- // are needed to ensure that canvas returns to its previous state after use.
canvas->save();
- return canvas;
- }
- virtual void ReleaseSkCanvas(const skia::RefPtr<SkCanvas>& canvas) override {
- if (!lock_.sk_surface())
- return;
-
- // Balanced with save() call in AcquireSkCanvas.
+ picture_pile->RasterToBitmap(canvas.get(), rect, scale, stats);
canvas->restore();
// Add the canvas and recorded picture to |multi_picture_draw_|.
- skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder_.endRecording());
+ skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder.endRecording());
multi_picture_draw_->add(lock_.sk_surface()->getCanvas(), picture.get());
}
@@ -60,7 +56,6 @@ class RasterBufferImpl : public RasterBuffer {
ResourceProvider::ScopedWriteLockGr lock_;
const Resource* resource_;
SkMultiPictureDraw* multi_picture_draw_;
- SkPictureRecorder recorder_;
DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl);
};

Powered by Google App Engine
This is Rietveld 408576698