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

Unified Diff: cc/resources/gpu_raster_worker_pool.cc

Issue 595553002: Use the skmultipicture to perform GPU rasterization (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 d0f97219c713c9039e750972784e9838780cabda..6063a68eb8ab018e6602bd20926e7f93becd0d94 100644
--- a/cc/resources/gpu_raster_worker_pool.cc
+++ b/cc/resources/gpu_raster_worker_pool.cc
@@ -13,6 +13,8 @@
#include "cc/resources/resource_provider.h"
#include "cc/resources/scoped_gpu_raster.h"
#include "gpu/command_buffer/client/gles2_interface.h"
+#include "third_party/skia/include/core/SkMultiPictureDraw.h"
+#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"
@@ -23,19 +25,20 @@ namespace {
class RasterBufferImpl : public RasterBuffer {
public:
RasterBufferImpl(ResourceProvider* resource_provider,
- const Resource* resource)
+ const Resource* resource,
+ SkMultiPictureDraw* multi_picture_draw)
: resource_provider_(resource_provider),
resource_(resource),
- surface_(resource_provider->LockForWriteToSkSurface(resource->id())) {}
+ surface_(resource_provider->LockForWriteToSkSurface(resource->id())),
+ multi_picture_draw_(multi_picture_draw) {}
virtual ~RasterBufferImpl() {
resource_provider_->UnlockForWriteToSkSurface(resource_->id());
}
// Overridden from RasterBuffer:
virtual skia::RefPtr<SkCanvas> AcquireSkCanvas() OVERRIDE {
- skia::RefPtr<SkCanvas> canvas = surface_
- ? skia::SharePtr(surface_->getCanvas())
- : skia::AdoptRef(SkCreateNullCanvas());
+ skia::RefPtr<SkCanvas> canvas = skia::SharePtr(recorder_.beginRecording(
+ resource_->size().width(), resource_->size().height()));
// Balanced with restore() call in ReleaseSkCanvas. save()/restore() calls
// are needed to ensure that canvas returns to its previous state after use.
@@ -45,12 +48,21 @@ class RasterBufferImpl : public RasterBuffer {
virtual void ReleaseSkCanvas(const skia::RefPtr<SkCanvas>& canvas) OVERRIDE {
// Balanced with save() call in AcquireSkCanvas.
canvas->restore();
+
+ // Add the canvas and recorded picture to |multi_picture_draw_|.
+ skia::RefPtr<SkCanvas> real_canvas =
+ surface_ ? skia::SharePtr(surface_->getCanvas())
+ : skia::AdoptRef(SkCreateNullCanvas());
reveman 2014/09/22 21:29:05 it seems a bit silly to add a null canvas. would i
hendrikw 2014/09/22 21:48:39 If we want status quo, I should probably allocate
+ skia::RefPtr<SkPicture> picture = skia::AdoptRef(recorder_.endRecording());
+ multi_picture_draw_->add(real_canvas.get(), picture.get());
}
private:
ResourceProvider* resource_provider_;
const Resource* resource_;
SkSurface* surface_;
+ SkMultiPictureDraw* multi_picture_draw_;
+ SkPictureRecorder recorder_;
DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl);
};
@@ -188,7 +200,7 @@ scoped_ptr<RasterBuffer> GpuRasterWorkerPool::AcquireBufferForRaster(
resource_provider_->AcquireSkSurface(resource->id());
return make_scoped_ptr<RasterBuffer>(
- new RasterBufferImpl(resource_provider_, resource));
+ new RasterBufferImpl(resource_provider_, resource, &multi_picture_draw_));
}
void GpuRasterWorkerPool::ReleaseBufferForRaster(
@@ -224,6 +236,7 @@ void GpuRasterWorkerPool::RunTasksOnOriginThread() {
ScopedGpuRaster gpu_raster(context_provider_);
task_graph_runner_->RunUntilIdle();
+ multi_picture_draw_.draw();
reveman 2014/09/22 21:29:05 Does calling draw() also clear the SkMultiPictureD
hendrikw 2014/09/22 21:48:39 Yes, it clears. I'll add a comment.
}
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698