| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ | 5 #ifndef CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ |
| 6 #define CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ | 6 #define CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 public: | 42 public: |
| 43 ~OneCopyTileTaskWorkerPool() override; | 43 ~OneCopyTileTaskWorkerPool() override; |
| 44 | 44 |
| 45 static scoped_ptr<TileTaskWorkerPool> Create( | 45 static scoped_ptr<TileTaskWorkerPool> Create( |
| 46 base::SequencedTaskRunner* task_runner, | 46 base::SequencedTaskRunner* task_runner, |
| 47 TaskGraphRunner* task_graph_runner, | 47 TaskGraphRunner* task_graph_runner, |
| 48 ContextProvider* context_provider, | 48 ContextProvider* context_provider, |
| 49 ResourceProvider* resource_provider, | 49 ResourceProvider* resource_provider, |
| 50 int max_copy_texture_chromium_size, | 50 int max_copy_texture_chromium_size, |
| 51 bool use_persistent_gpu_memory_buffers, | 51 bool use_persistent_gpu_memory_buffers, |
| 52 int max_staging_buffer_usage_in_bytes); | 52 int max_staging_buffer_usage_in_bytes, |
| 53 bool use_rgba_4444_texture_format); |
| 53 | 54 |
| 54 // Overridden from TileTaskWorkerPool: | 55 // Overridden from TileTaskWorkerPool: |
| 55 TileTaskRunner* AsTileTaskRunner() override; | 56 TileTaskRunner* AsTileTaskRunner() override; |
| 56 | 57 |
| 57 // Overridden from TileTaskRunner: | 58 // Overridden from TileTaskRunner: |
| 58 void SetClient(TileTaskRunnerClient* client) override; | 59 void SetClient(TileTaskRunnerClient* client) override; |
| 59 void Shutdown() override; | 60 void Shutdown() override; |
| 60 void ScheduleTasks(TileTaskQueue* queue) override; | 61 void ScheduleTasks(TileTaskQueue* queue) override; |
| 61 void CheckForCompletedTasks() override; | 62 void CheckForCompletedTasks() override; |
| 62 ResourceFormat GetResourceFormat() const override; | 63 ResourceFormat GetResourceFormat(bool must_support_alpha) const override; |
| 63 bool GetResourceRequiresSwizzle() const override; | 64 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override; |
| 64 | 65 |
| 65 // Overridden from TileTaskClient: | 66 // Overridden from TileTaskClient: |
| 66 scoped_ptr<RasterBuffer> AcquireBufferForRaster( | 67 scoped_ptr<RasterBuffer> AcquireBufferForRaster( |
| 67 const Resource* resource, | 68 const Resource* resource, |
| 68 uint64_t resource_content_id, | 69 uint64_t resource_content_id, |
| 69 uint64_t previous_content_id) override; | 70 uint64_t previous_content_id) override; |
| 70 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override; | 71 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override; |
| 71 | 72 |
| 72 // Overridden from base::trace_event::MemoryDumpProvider: | 73 // Overridden from base::trace_event::MemoryDumpProvider: |
| 73 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, | 74 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 84 bool include_images, | 85 bool include_images, |
| 85 uint64_t resource_content_id, | 86 uint64_t resource_content_id, |
| 86 uint64_t previous_content_id); | 87 uint64_t previous_content_id); |
| 87 | 88 |
| 88 protected: | 89 protected: |
| 89 OneCopyTileTaskWorkerPool(base::SequencedTaskRunner* task_runner, | 90 OneCopyTileTaskWorkerPool(base::SequencedTaskRunner* task_runner, |
| 90 TaskGraphRunner* task_graph_runner, | 91 TaskGraphRunner* task_graph_runner, |
| 91 ResourceProvider* resource_provider, | 92 ResourceProvider* resource_provider, |
| 92 int max_copy_texture_chromium_size, | 93 int max_copy_texture_chromium_size, |
| 93 bool use_persistent_gpu_memory_buffers, | 94 bool use_persistent_gpu_memory_buffers, |
| 94 int max_staging_buffer_usage_in_bytes); | 95 int max_staging_buffer_usage_in_bytes, |
| 96 bool use_rgba_4444_texture_format); |
| 95 | 97 |
| 96 private: | 98 private: |
| 97 struct StagingBuffer { | 99 struct StagingBuffer { |
| 98 explicit StagingBuffer(const gfx::Size& size); | 100 StagingBuffer(const gfx::Size& size, ResourceFormat format); |
| 99 ~StagingBuffer(); | 101 ~StagingBuffer(); |
| 100 | 102 |
| 101 void DestroyGLResources(gpu::gles2::GLES2Interface* gl); | 103 void DestroyGLResources(gpu::gles2::GLES2Interface* gl); |
| 102 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, | 104 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd, |
| 103 ResourceFormat format, | 105 ResourceFormat format, |
| 104 bool is_free) const; | 106 bool is_free) const; |
| 105 | 107 |
| 106 const gfx::Size size; | 108 const gfx::Size size; |
| 109 const ResourceFormat format; |
| 107 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer; | 110 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer; |
| 108 base::TimeTicks last_usage; | 111 base::TimeTicks last_usage; |
| 109 unsigned texture_id; | 112 unsigned texture_id; |
| 110 unsigned image_id; | 113 unsigned image_id; |
| 111 unsigned query_id; | 114 unsigned query_id; |
| 112 uint64_t content_id; | 115 uint64_t content_id; |
| 113 }; | 116 }; |
| 114 | 117 |
| 115 void AddStagingBuffer(const StagingBuffer* staging_buffer); | 118 void AddStagingBuffer(const StagingBuffer* staging_buffer, |
| 119 ResourceFormat format); |
| 116 void RemoveStagingBuffer(const StagingBuffer* staging_buffer); | 120 void RemoveStagingBuffer(const StagingBuffer* staging_buffer); |
| 117 void MarkStagingBufferAsFree(const StagingBuffer* staging_buffer); | 121 void MarkStagingBufferAsFree(const StagingBuffer* staging_buffer); |
| 118 void MarkStagingBufferAsBusy(const StagingBuffer* staging_buffer); | 122 void MarkStagingBufferAsBusy(const StagingBuffer* staging_buffer); |
| 119 scoped_ptr<StagingBuffer> AcquireStagingBuffer(const Resource* resource, | 123 scoped_ptr<StagingBuffer> AcquireStagingBuffer(const Resource* resource, |
| 120 uint64_t previous_content_id); | 124 uint64_t previous_content_id); |
| 121 base::TimeTicks GetUsageTimeForLRUBuffer(); | 125 base::TimeTicks GetUsageTimeForLRUBuffer(); |
| 122 void ScheduleReduceMemoryUsage(); | 126 void ScheduleReduceMemoryUsage(); |
| 123 void ReduceMemoryUsage(); | 127 void ReduceMemoryUsage(); |
| 124 void ReleaseBuffersNotUsedSince(base::TimeTicks time); | 128 void ReleaseBuffersNotUsedSince(base::TimeTicks time); |
| 125 | 129 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 146 | 150 |
| 147 mutable base::Lock lock_; | 151 mutable base::Lock lock_; |
| 148 // |lock_| must be acquired when accessing the following members. | 152 // |lock_| must be acquired when accessing the following members. |
| 149 using StagingBufferSet = std::set<const StagingBuffer*>; | 153 using StagingBufferSet = std::set<const StagingBuffer*>; |
| 150 StagingBufferSet buffers_; | 154 StagingBufferSet buffers_; |
| 151 using StagingBufferDeque = ScopedPtrDeque<StagingBuffer>; | 155 using StagingBufferDeque = ScopedPtrDeque<StagingBuffer>; |
| 152 StagingBufferDeque free_buffers_; | 156 StagingBufferDeque free_buffers_; |
| 153 StagingBufferDeque busy_buffers_; | 157 StagingBufferDeque busy_buffers_; |
| 154 int bytes_scheduled_since_last_flush_; | 158 int bytes_scheduled_since_last_flush_; |
| 155 const int max_staging_buffer_usage_in_bytes_; | 159 const int max_staging_buffer_usage_in_bytes_; |
| 160 bool use_rgba_4444_texture_format_; |
| 156 int staging_buffer_usage_in_bytes_; | 161 int staging_buffer_usage_in_bytes_; |
| 157 int free_staging_buffer_usage_in_bytes_; | 162 int free_staging_buffer_usage_in_bytes_; |
| 158 const base::TimeDelta staging_buffer_expiration_delay_; | 163 const base::TimeDelta staging_buffer_expiration_delay_; |
| 159 bool reduce_memory_usage_pending_; | 164 bool reduce_memory_usage_pending_; |
| 160 base::Closure reduce_memory_usage_callback_; | 165 base::Closure reduce_memory_usage_callback_; |
| 161 | 166 |
| 162 base::WeakPtrFactory<OneCopyTileTaskWorkerPool> weak_ptr_factory_; | 167 base::WeakPtrFactory<OneCopyTileTaskWorkerPool> weak_ptr_factory_; |
| 163 // "raster finished" tasks need their own factory as they need to be | 168 // "raster finished" tasks need their own factory as they need to be |
| 164 // canceled when ScheduleTasks() is called. | 169 // canceled when ScheduleTasks() is called. |
| 165 base::WeakPtrFactory<OneCopyTileTaskWorkerPool> | 170 base::WeakPtrFactory<OneCopyTileTaskWorkerPool> |
| 166 task_set_finished_weak_ptr_factory_; | 171 task_set_finished_weak_ptr_factory_; |
| 167 | 172 |
| 168 DISALLOW_COPY_AND_ASSIGN(OneCopyTileTaskWorkerPool); | 173 DISALLOW_COPY_AND_ASSIGN(OneCopyTileTaskWorkerPool); |
| 169 }; | 174 }; |
| 170 | 175 |
| 171 } // namespace cc | 176 } // namespace cc |
| 172 | 177 |
| 173 #endif // CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ | 178 #endif // CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ |
| OLD | NEW |