Index: cc/raster/one_copy_tile_task_worker_pool.h |
diff --git a/cc/raster/one_copy_tile_task_worker_pool.h b/cc/raster/one_copy_tile_task_worker_pool.h |
index 4e050b4c2023a6bba1ca0d706e404bd6fba5706b..851f1b45e1de24e09e96605a10e448305a5fc274 100644 |
--- a/cc/raster/one_copy_tile_task_worker_pool.h |
+++ b/cc/raster/one_copy_tile_task_worker_pool.h |
@@ -5,8 +5,12 @@ |
#ifndef CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ |
#define CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ |
+#include <set> |
+ |
#include "base/memory/weak_ptr.h" |
#include "base/synchronization/lock.h" |
+#include "base/time/time.h" |
+#include "base/trace_event/memory_dump_provider.h" |
#include "base/values.h" |
#include "cc/base/scoped_ptr_deque.h" |
#include "cc/output/context_provider.h" |
@@ -21,15 +25,20 @@ class TracedValue; |
} |
} |
+namespace gpu { |
+namespace gles2 { |
+class GLES2Interface; |
+} |
+} |
+ |
namespace cc { |
class ResourcePool; |
-class ScopedResource; |
- |
-typedef int64 CopySequenceNumber; |
-class CC_EXPORT OneCopyTileTaskWorkerPool : public TileTaskWorkerPool, |
- public TileTaskRunner, |
- public TileTaskClient { |
+class CC_EXPORT OneCopyTileTaskWorkerPool |
+ : public TileTaskWorkerPool, |
+ public TileTaskRunner, |
+ public TileTaskClient, |
+ public base::trace_event::MemoryDumpProvider { |
public: |
~OneCopyTileTaskWorkerPool() override; |
@@ -38,9 +47,9 @@ class CC_EXPORT OneCopyTileTaskWorkerPool : public TileTaskWorkerPool, |
TaskGraphRunner* task_graph_runner, |
ContextProvider* context_provider, |
ResourceProvider* resource_provider, |
- ResourcePool* resource_pool, |
int max_copy_texture_chromium_size, |
- bool have_persistent_gpu_memory_buffers); |
+ bool use_persistent_gpu_memory_buffers, |
+ int max_staging_buffers); |
// Overridden from TileTaskWorkerPool: |
TileTaskRunner* AsTileTaskRunner() override; |
@@ -60,61 +69,57 @@ class CC_EXPORT OneCopyTileTaskWorkerPool : public TileTaskWorkerPool, |
uint64_t previous_content_id) override; |
void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override; |
- // Playback raster source and schedule copy of |raster_resource| resource to |
- // |output_resource|. Returns a non-zero sequence number for this copy |
- // operation. |
- CopySequenceNumber PlaybackAndScheduleCopyOnWorkerThread( |
- bool reusing_raster_resource, |
- scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> |
- raster_resource_write_lock, |
- const Resource* raster_resource, |
- const Resource* output_resource, |
+ // Overridden from base::trace_event::MemoryDumpProvider: |
+ bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
+ base::trace_event::ProcessMemoryDump* pmd) override; |
+ |
+ // Playback raster source and copy result into |resource|. |
+ void PlaybackAndCopyOnWorkerThread( |
+ const Resource* resource, |
+ const ResourceProvider::ScopedWriteLockGL* resource_lock, |
const RasterSource* raster_source, |
const gfx::Rect& raster_full_rect, |
const gfx::Rect& raster_dirty_rect, |
float scale, |
- bool include_images); |
- |
- // Issues copy operations until |sequence| has been processed. This will |
- // return immediately if |sequence| has already been processed. |
- void AdvanceLastIssuedCopyTo(CopySequenceNumber sequence); |
- |
- bool have_persistent_gpu_memory_buffers() const { |
- return have_persistent_gpu_memory_buffers_; |
- } |
+ bool include_images, |
+ uint64_t resource_content_id, |
+ uint64_t previous_content_id); |
protected: |
OneCopyTileTaskWorkerPool(base::SequencedTaskRunner* task_runner, |
TaskGraphRunner* task_graph_runner, |
- ContextProvider* context_provider, |
ResourceProvider* resource_provider, |
- ResourcePool* resource_pool, |
int max_copy_texture_chromium_size, |
- bool have_persistent_gpu_memory_buffers); |
+ bool use_persistent_gpu_memory_buffers, |
+ int max_staging_buffers); |
private: |
- struct CopyOperation { |
- typedef ScopedPtrDeque<CopyOperation> Deque; |
- |
- CopyOperation(scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> |
- src_write_lock, |
- const Resource* src, |
- const Resource* dst, |
- const gfx::Rect& rect); |
- ~CopyOperation(); |
- |
- scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> src_write_lock; |
- const Resource* src; |
- const Resource* dst; |
- const gfx::Rect rect; |
+ struct StagingBuffer { |
+ explicit StagingBuffer(const gfx::Size& size); |
+ ~StagingBuffer(); |
+ |
+ void DestroyGLResources(gpu::gles2::GLES2Interface* gl); |
+ void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
+ ResourceFormat format, |
+ bool is_free) const; |
+ |
+ const gfx::Size size; |
+ scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer; |
+ base::TimeTicks last_usage; |
+ unsigned texture_id; |
+ unsigned image_id; |
+ unsigned query_id; |
+ uint64_t content_id; |
}; |
+ scoped_ptr<StagingBuffer> AcquireStagingBuffer(const Resource* resource, |
+ uint64_t previous_content_id); |
+ base::TimeTicks GetUsageTimeForLRUBuffer(); |
+ void ScheduleReduceMemoryUsage(); |
+ void ReduceMemoryUsage(); |
+ void ReleaseBuffersNotUsedSince(base::TimeTicks time); |
+ |
void OnTaskSetFinished(TaskSet task_set); |
- void AdvanceLastFlushedCopyTo(CopySequenceNumber sequence); |
- void IssueCopyOperations(int64 count); |
- void ScheduleCheckForCompletedCopyOperationsWithLockAcquired( |
- bool wait_if_needed); |
- void CheckForCompletedCopyOperations(bool wait_if_needed); |
scoped_refptr<base::trace_event::ConvertableToTraceFormat> StateAsValue() |
const; |
void StagingStateAsValueInto( |
@@ -124,31 +129,29 @@ class CC_EXPORT OneCopyTileTaskWorkerPool : public TileTaskWorkerPool, |
TaskGraphRunner* task_graph_runner_; |
const NamespaceToken namespace_token_; |
TileTaskRunnerClient* client_; |
- ContextProvider* context_provider_; |
- ResourceProvider* resource_provider_; |
- ResourcePool* resource_pool_; |
+ ResourceProvider* const resource_provider_; |
const int max_bytes_per_copy_operation_; |
- const bool have_persistent_gpu_memory_buffers_; |
+ const bool use_persistent_gpu_memory_buffers_; |
TaskSetCollection tasks_pending_; |
scoped_refptr<TileTask> task_set_finished_tasks_[kNumberOfTaskSets]; |
- CopySequenceNumber last_issued_copy_operation_; |
- CopySequenceNumber last_flushed_copy_operation_; |
// Task graph used when scheduling tasks and vector used to gather |
// completed tasks. |
TaskGraph graph_; |
Task::Vector completed_tasks_; |
- base::Lock lock_; |
+ mutable base::Lock lock_; |
// |lock_| must be acquired when accessing the following members. |
- base::ConditionVariable copy_operation_count_cv_; |
+ using StagingBufferSet = std::set<StagingBuffer*>; |
+ StagingBufferSet buffers_; |
+ using StagingBufferDeque = ScopedPtrDeque<StagingBuffer>; |
+ StagingBufferDeque free_buffers_; |
+ StagingBufferDeque busy_buffers_; |
int bytes_scheduled_since_last_flush_; |
- size_t issued_copy_operation_count_; |
- CopyOperation::Deque pending_copy_operations_; |
- CopySequenceNumber next_copy_operation_sequence_; |
- bool check_for_completed_copy_operations_pending_; |
- base::TimeTicks last_check_for_completed_copy_operations_time_; |
- bool shutdown_; |
+ size_t max_staging_buffers_; |
+ const base::TimeDelta staging_buffer_expiration_delay_; |
+ bool reduce_memory_usage_pending_; |
+ base::Closure reduce_memory_usage_callback_; |
base::WeakPtrFactory<OneCopyTileTaskWorkerPool> weak_ptr_factory_; |
// "raster finished" tasks need their own factory as they need to be |