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

Unified Diff: cc/resources/pixel_buffer_raster_worker_pool.cc

Issue 562833004: cc: Move RasterBuffer implementations from ResourceProvider to RasterWorkerPool implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and fix gpu raster issue 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
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.h ('k') | cc/resources/raster_buffer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/pixel_buffer_raster_worker_pool.cc
diff --git a/cc/resources/pixel_buffer_raster_worker_pool.cc b/cc/resources/pixel_buffer_raster_worker_pool.cc
index 2ae94b577575de7103e6e25350da5d274600c779..b1011fcf0ac77f92e25ef211e7541755b9274886 100644
--- a/cc/resources/pixel_buffer_raster_worker_pool.cc
+++ b/cc/resources/pixel_buffer_raster_worker_pool.cc
@@ -11,12 +11,57 @@
#include "base/debug/trace_event_argument.h"
#include "base/strings/stringprintf.h"
#include "cc/debug/traced_value.h"
+#include "cc/resources/raster_buffer.h"
#include "cc/resources/resource.h"
#include "gpu/command_buffer/client/gles2_interface.h"
+#include "third_party/skia/include/utils/SkNullCanvas.h"
namespace cc {
namespace {
+class RasterBufferImpl : public RasterBuffer {
+ public:
+ RasterBufferImpl(ResourceProvider* resource_provider,
+ const Resource* resource)
+ : resource_provider_(resource_provider),
+ resource_(resource),
+ buffer_(NULL),
+ stride_(0) {
+ resource_provider_->AcquirePixelBuffer(resource_->id());
+ buffer_ = resource_provider_->MapPixelBuffer(resource_->id(), &stride_);
+ }
+
+ virtual ~RasterBufferImpl() {
+ resource_provider_->ReleasePixelBuffer(resource_->id());
+ }
+
+ // Overridden from RasterBuffer:
+ virtual skia::RefPtr<SkCanvas> AcquireSkCanvas() OVERRIDE {
+ if (!buffer_)
+ return skia::AdoptRef(SkCreateNullCanvas());
+
+ RasterWorkerPool::AcquireBitmapForBuffer(
+ &bitmap_, buffer_, resource_->format(), resource_->size(), stride_);
+ return skia::AdoptRef(new SkCanvas(bitmap_));
+ }
+ virtual void ReleaseSkCanvas(const skia::RefPtr<SkCanvas>& canvas) OVERRIDE {
+ if (!buffer_)
+ return;
+
+ RasterWorkerPool::ReleaseBitmapForBuffer(
+ &bitmap_, buffer_, resource_->format());
+ }
+
+ private:
+ ResourceProvider* resource_provider_;
+ const Resource* resource_;
+ uint8_t* buffer_;
+ int stride_;
+ SkBitmap bitmap_;
+
+ DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl);
+};
+
const int kCheckForCompletedRasterTasksDelayMs = 6;
const size_t kMaxScheduledRasterTasks = 48;
@@ -278,21 +323,15 @@ void PixelBufferRasterWorkerPool::CheckForCompletedTasks() {
completed_raster_tasks_.clear();
}
-RasterBuffer* PixelBufferRasterWorkerPool::AcquireBufferForRaster(
- RasterTask* task) {
- DCHECK(std::find_if(raster_task_states_.begin(),
- raster_task_states_.end(),
- RasterTaskState::TaskComparator(task)) !=
- raster_task_states_.end());
- return resource_provider_->AcquirePixelRasterBuffer(task->resource()->id());
+scoped_ptr<RasterBuffer> PixelBufferRasterWorkerPool::AcquireBufferForRaster(
+ const Resource* resource) {
+ return make_scoped_ptr<RasterBuffer>(
+ new RasterBufferImpl(resource_provider_, resource));
}
-void PixelBufferRasterWorkerPool::ReleaseBufferForRaster(RasterTask* task) {
- DCHECK(std::find_if(raster_task_states_.begin(),
- raster_task_states_.end(),
- RasterTaskState::TaskComparator(task)) !=
- raster_task_states_.end());
- resource_provider_->ReleasePixelRasterBuffer(task->resource()->id());
+void PixelBufferRasterWorkerPool::ReleaseBufferForRaster(
+ scoped_ptr<RasterBuffer> buffer) {
+ // Nothing to do here. RasterBufferImpl destructor cleans up after itself.
}
void PixelBufferRasterWorkerPool::OnRasterFinished(TaskSet task_set) {
@@ -652,6 +691,8 @@ void PixelBufferRasterWorkerPool::CheckForCompletedRasterizerTasks() {
RasterTaskState& state = *state_it;
DCHECK_EQ(RasterTaskState::SCHEDULED, state.type);
+ resource_provider_->UnmapPixelBuffer(raster_task->resource()->id());
+
if (!raster_task->HasFinishedRunning()) {
// When priorites change, a raster task can be canceled as a result of
// no longer being of high enough priority to fit in our throttled
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.h ('k') | cc/resources/raster_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698