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

Unified Diff: cc/resources/image_copy_raster_worker_pool.h

Issue 562833004: cc: Move RasterBuffer implementations from ResourceProvider to RasterWorkerPool implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: build fix 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/image_copy_raster_worker_pool.h
diff --git a/cc/resources/image_copy_raster_worker_pool.h b/cc/resources/image_copy_raster_worker_pool.h
index faa3f1aa7dff4490100a69c753edca0ce7998c33..4111e814e8547ad8d8321e4416ecba2c877aa2cc 100644
--- a/cc/resources/image_copy_raster_worker_pool.h
+++ b/cc/resources/image_copy_raster_worker_pool.h
@@ -5,13 +5,14 @@
#ifndef CC_RESOURCES_IMAGE_COPY_RASTER_WORKER_POOL_H_
#define CC_RESOURCES_IMAGE_COPY_RASTER_WORKER_POOL_H_
-#include <vector>
-
#include "base/memory/weak_ptr.h"
+#include "base/synchronization/lock.h"
#include "base/values.h"
+#include "cc/base/scoped_ptr_deque.h"
#include "cc/output/context_provider.h"
#include "cc/resources/raster_worker_pool.h"
#include "cc/resources/rasterizer.h"
+#include "cc/resources/resource_provider.h"
namespace base {
namespace debug {
@@ -48,8 +49,18 @@ class CC_EXPORT ImageCopyRasterWorkerPool : public RasterWorkerPool,
virtual void CheckForCompletedTasks() OVERRIDE;
// Overridden from RasterizerTaskClient:
- virtual RasterBuffer* AcquireBufferForRaster(RasterTask* task) OVERRIDE;
- virtual void ReleaseBufferForRaster(RasterTask* task) OVERRIDE;
+ virtual scoped_ptr<RasterBuffer> AcquireBufferForRaster(
+ const Resource* resource) OVERRIDE;
+ virtual void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) OVERRIDE;
+
+ // Schedule copying from |src| to |dst|. Returns the number of currently
+ // pending copy operations.
+ // Note: this can be called from a worker thread.
+ size_t ScheduleCopy(scoped_ptr<ScopedResource> src, const Resource* dst);
+
+ base::SequencedTaskRunner* task_runner() { return task_runner_.get(); }
+ ResourceProvider* resource_provider() { return resource_provider_; }
+ ResourcePool* resource_pool() { return resource_pool_; }
protected:
ImageCopyRasterWorkerPool(base::SequencedTaskRunner* task_runner,
@@ -59,31 +70,19 @@ class CC_EXPORT ImageCopyRasterWorkerPool : public RasterWorkerPool,
ResourcePool* resource_pool);
private:
- struct RasterTaskState {
- class TaskComparator {
- public:
- explicit TaskComparator(const RasterTask* task) : task_(task) {}
-
- bool operator()(const RasterTaskState& state) const {
- return state.task == task_;
- }
-
- private:
- const RasterTask* task_;
- };
-
- typedef std::vector<RasterTaskState> Vector;
+ struct ResourceCopyOperation {
+ typedef ScopedPtrDeque<ResourceCopyOperation> Deque;
- RasterTaskState(const RasterTask* task, ScopedResource* resource)
- : task(task), resource(resource) {}
+ ResourceCopyOperation(scoped_ptr<ScopedResource> src, const Resource* dst);
+ ~ResourceCopyOperation();
- const RasterTask* task;
- ScopedResource* resource;
+ scoped_ptr<ScopedResource> src;
+ const Resource* dst;
};
void OnRasterFinished();
void OnRasterRequiredForActivationFinished();
- void FlushCopies();
+ void CopyResources(size_t count);
scoped_refptr<base::debug::ConvertableToTraceFormat> StateAsValue() const;
void StagingStateAsValueInto(base::debug::TracedValue* staging_state) const;
@@ -95,23 +94,29 @@ class CC_EXPORT ImageCopyRasterWorkerPool : public RasterWorkerPool,
ResourceProvider* resource_provider_;
ResourcePool* resource_pool_;
- RasterTaskState::Vector raster_task_states_;
-
- bool has_performed_copy_since_last_flush_;
-
bool raster_tasks_pending_;
bool raster_tasks_required_for_activation_pending_;
scoped_refptr<RasterizerTask> raster_finished_task_;
scoped_refptr<RasterizerTask> raster_required_for_activation_finished_task_;
- // Task graph used when scheduling tasks and vector used to gather
- // completed tasks.
+ // |pending_resource_copy_operations_lock_| must be acquired when accessing
+ // |pending_resource_copy_operations_|.
+ base::Lock pending_resource_copy_operations_lock_;
+ ResourceCopyOperation::Deque pending_resource_copy_operations_;
+
+ // Callback used to copy a batch of resources.
+ base::Closure copy_batch_of_resources_callback_;
+
+ // Task graph used when scheduling tasks, vector used to gather completed
+ // tasks and vector used to gather resource copy operations.
TaskGraph graph_;
Task::Vector completed_tasks_;
base::WeakPtrFactory<ImageCopyRasterWorkerPool>
raster_finished_weak_ptr_factory_;
+ base::WeakPtrFactory<ImageCopyRasterWorkerPool>
+ copy_batch_of_resources_weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(ImageCopyRasterWorkerPool);
};

Powered by Google App Engine
This is Rietveld 408576698