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

Side by Side Diff: cc/raster/one_copy_tile_task_worker_pool.h

Issue 1861623003: cc: Refactor OneCopyTileTaskWorkerPool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dependency_task
Patch Set: rebase Created 4 years, 8 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 unified diff | Download patch
« no previous file with comments | « cc/cc.gyp ('k') | cc/raster/one_copy_tile_task_worker_pool.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <stdint.h> 8 #include <stdint.h>
9 9
10 #include <deque>
11 #include <set>
12
13 #include "base/macros.h" 10 #include "base/macros.h"
14 #include "base/memory/weak_ptr.h"
15 #include "base/synchronization/lock.h"
16 #include "base/time/time.h"
17 #include "base/trace_event/memory_dump_provider.h"
18 #include "base/values.h"
19 #include "cc/output/context_provider.h" 11 #include "cc/output/context_provider.h"
20 #include "cc/raster/tile_task_runner.h" 12 #include "cc/raster/tile_task_runner.h"
21 #include "cc/raster/tile_task_worker_pool.h" 13 #include "cc/raster/tile_task_worker_pool.h"
22 #include "cc/resources/resource_provider.h" 14 #include "cc/resources/resource_provider.h"
23 15
24 namespace base {
25 namespace trace_event {
26 class ConvertableToTraceFormat;
27 class TracedValue;
28 }
29 }
30
31 namespace gpu {
32 namespace gles2 {
33 class GLES2Interface;
34 }
35 }
36
37 namespace cc { 16 namespace cc {
17 struct StagingBuffer;
18 class StagingBufferPool;
38 class ResourcePool; 19 class ResourcePool;
39 20
40 class CC_EXPORT OneCopyTileTaskWorkerPool 21 class CC_EXPORT OneCopyTileTaskWorkerPool : public TileTaskWorkerPool,
41 : public TileTaskWorkerPool, 22 public TileTaskRunner,
42 public TileTaskRunner, 23 public TileTaskClient {
43 public TileTaskClient,
44 public base::trace_event::MemoryDumpProvider {
45 public: 24 public:
46 ~OneCopyTileTaskWorkerPool() override; 25 ~OneCopyTileTaskWorkerPool() override;
47 26
48 static scoped_ptr<TileTaskWorkerPool> Create( 27 static scoped_ptr<TileTaskWorkerPool> Create(
49 base::SequencedTaskRunner* task_runner, 28 base::SequencedTaskRunner* task_runner,
50 TaskGraphRunner* task_graph_runner, 29 TaskGraphRunner* task_graph_runner,
51 ContextProvider* context_provider, 30 ContextProvider* context_provider,
52 ResourceProvider* resource_provider, 31 ResourceProvider* resource_provider,
53 int max_copy_texture_chromium_size, 32 int max_copy_texture_chromium_size,
54 bool use_partial_raster, 33 bool use_partial_raster,
(...skipping 10 matching lines...) Expand all
65 ResourceFormat GetResourceFormat(bool must_support_alpha) const override; 44 ResourceFormat GetResourceFormat(bool must_support_alpha) const override;
66 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override; 45 bool GetResourceRequiresSwizzle(bool must_support_alpha) const override;
67 46
68 // Overridden from TileTaskClient: 47 // Overridden from TileTaskClient:
69 scoped_ptr<RasterBuffer> AcquireBufferForRaster( 48 scoped_ptr<RasterBuffer> AcquireBufferForRaster(
70 const Resource* resource, 49 const Resource* resource,
71 uint64_t resource_content_id, 50 uint64_t resource_content_id,
72 uint64_t previous_content_id) override; 51 uint64_t previous_content_id) override;
73 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override; 52 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override;
74 53
75 // Overridden from base::trace_event::MemoryDumpProvider:
76 bool OnMemoryDump(const base::trace_event::MemoryDumpArgs& args,
77 base::trace_event::ProcessMemoryDump* pmd) override;
78
79 // Playback raster source and copy result into |resource|. 54 // Playback raster source and copy result into |resource|.
80 void PlaybackAndCopyOnWorkerThread( 55 void PlaybackAndCopyOnWorkerThread(
81 const Resource* resource, 56 const Resource* resource,
82 ResourceProvider::ScopedWriteLockGL* resource_lock, 57 ResourceProvider::ScopedWriteLockGL* resource_lock,
83 const RasterSource* raster_source, 58 const RasterSource* raster_source,
84 const gfx::Rect& raster_full_rect, 59 const gfx::Rect& raster_full_rect,
85 const gfx::Rect& raster_dirty_rect, 60 const gfx::Rect& raster_dirty_rect,
86 float scale, 61 float scale,
87 const RasterSource::PlaybackSettings& playback_settings, 62 const RasterSource::PlaybackSettings& playback_settings,
88 uint64_t resource_content_id, 63 uint64_t previous_content_id,
89 uint64_t previous_content_id); 64 uint64_t new_content_id);
90 65
91 protected: 66 protected:
92 OneCopyTileTaskWorkerPool(base::SequencedTaskRunner* task_runner, 67 OneCopyTileTaskWorkerPool(base::SequencedTaskRunner* task_runner,
93 TaskGraphRunner* task_graph_runner, 68 TaskGraphRunner* task_graph_runner,
94 ResourceProvider* resource_provider, 69 ResourceProvider* resource_provider,
95 int max_copy_texture_chromium_size, 70 int max_copy_texture_chromium_size,
96 bool use_partial_raster, 71 bool use_partial_raster,
97 int max_staging_buffer_usage_in_bytes, 72 int max_staging_buffer_usage_in_bytes,
98 ResourceFormat preferred_tile_format); 73 ResourceFormat preferred_tile_format);
99 74
100 private: 75 private:
101 struct StagingBuffer { 76 void PlaybackToStagingBuffer(
102 StagingBuffer(const gfx::Size& size, ResourceFormat format); 77 StagingBuffer* staging_buffer,
103 ~StagingBuffer(); 78 const Resource* resource,
79 const RasterSource* raster_source,
80 const gfx::Rect& raster_full_rect,
81 const gfx::Rect& raster_dirty_rect,
82 float scale,
83 const RasterSource::PlaybackSettings& playback_settings,
84 uint64_t previous_content_id,
85 uint64_t new_content_id);
86 void CopyOnWorkerThread(StagingBuffer* staging_buffer,
87 const Resource* resource,
88 ResourceProvider::ScopedWriteLockGL* resource_lock,
89 const RasterSource* raster_source,
90 uint64_t previous_content_id,
91 uint64_t new_content_id);
104 92
105 void DestroyGLResources(gpu::gles2::GLES2Interface* gl);
106 void OnMemoryDump(base::trace_event::ProcessMemoryDump* pmd,
107 ResourceFormat format,
108 bool is_free) const;
109
110 const gfx::Size size;
111 const ResourceFormat format;
112 scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer;
113 base::TimeTicks last_usage;
114 unsigned texture_id;
115 unsigned image_id;
116 unsigned query_id;
117 uint64_t content_id;
118 };
119
120 void AddStagingBuffer(const StagingBuffer* staging_buffer,
121 ResourceFormat format);
122 void RemoveStagingBuffer(const StagingBuffer* staging_buffer);
123 void MarkStagingBufferAsFree(const StagingBuffer* staging_buffer);
124 void MarkStagingBufferAsBusy(const StagingBuffer* staging_buffer);
125 scoped_ptr<StagingBuffer> AcquireStagingBuffer(const Resource* resource,
126 uint64_t previous_content_id);
127 base::TimeTicks GetUsageTimeForLRUBuffer();
128 void ScheduleReduceMemoryUsage();
129 void ReduceMemoryUsage();
130 void ReleaseBuffersNotUsedSince(base::TimeTicks time);
131
132 scoped_ptr<base::trace_event::ConvertableToTraceFormat> StateAsValue() const;
133 void StagingStateAsValueInto(
134 base::trace_event::TracedValue* staging_state) const;
135
136 scoped_refptr<base::SequencedTaskRunner> task_runner_;
137 TaskGraphRunner* task_graph_runner_; 93 TaskGraphRunner* task_graph_runner_;
138 const NamespaceToken namespace_token_; 94 const NamespaceToken namespace_token_;
139 ResourceProvider* const resource_provider_; 95 ResourceProvider* const resource_provider_;
140 const int max_bytes_per_copy_operation_; 96 const int max_bytes_per_copy_operation_;
141 const bool use_partial_raster_; 97 bool use_partial_raster_;
98
99 // Context lock must be acquired when accessing this member.
100 int bytes_scheduled_since_last_flush_;
101
102 ResourceFormat preferred_tile_format_;
103 scoped_ptr<StagingBufferPool> staging_pool_;
142 104
143 Task::Vector completed_tasks_; 105 Task::Vector completed_tasks_;
144 106
145 mutable base::Lock lock_;
146 // |lock_| must be acquired when accessing the following members.
147 using StagingBufferSet = std::set<const StagingBuffer*>;
148 StagingBufferSet buffers_;
149 using StagingBufferDeque = std::deque<scoped_ptr<StagingBuffer>>;
150 StagingBufferDeque free_buffers_;
151 StagingBufferDeque busy_buffers_;
152 int bytes_scheduled_since_last_flush_;
153 const int max_staging_buffer_usage_in_bytes_;
154 ResourceFormat preferred_tile_format_;
155 int staging_buffer_usage_in_bytes_;
156 int free_staging_buffer_usage_in_bytes_;
157 const base::TimeDelta staging_buffer_expiration_delay_;
158 bool reduce_memory_usage_pending_;
159 base::Closure reduce_memory_usage_callback_;
160
161 base::WeakPtrFactory<OneCopyTileTaskWorkerPool> weak_ptr_factory_;
162
163 DISALLOW_COPY_AND_ASSIGN(OneCopyTileTaskWorkerPool); 107 DISALLOW_COPY_AND_ASSIGN(OneCopyTileTaskWorkerPool);
164 }; 108 };
165 109
166 } // namespace cc 110 } // namespace cc
167 111
168 #endif // CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ 112 #endif // CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « cc/cc.gyp ('k') | cc/raster/one_copy_tile_task_worker_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698