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

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

Issue 1157943004: cc: [WIP] Use worker context and OrderingBarrierCHROMIUM for one-copy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: keep resource ownership in compositor. Created 5 years, 5 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
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 "base/memory/weak_ptr.h" 8 #include "base/memory/weak_ptr.h"
9 #include "base/synchronization/lock.h" 9 #include "base/synchronization/lock.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // Overridden from TileTaskClient: 56 // Overridden from TileTaskClient:
57 scoped_ptr<RasterBuffer> AcquireBufferForRaster( 57 scoped_ptr<RasterBuffer> AcquireBufferForRaster(
58 const Resource* resource, 58 const Resource* resource,
59 uint64_t resource_content_id, 59 uint64_t resource_content_id,
60 uint64_t previous_content_id) override; 60 uint64_t previous_content_id) override;
61 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override; 61 void ReleaseBufferForRaster(scoped_ptr<RasterBuffer> buffer) override;
62 62
63 // Playback raster source and schedule copy of |raster_resource| resource to 63 // Playback raster source and schedule copy of |raster_resource| resource to
64 // |output_resource|. Returns a non-zero sequence number for this copy 64 // |output_resource|. Returns a non-zero sequence number for this copy
65 // operation. 65 // operation.
66 CopySequenceNumber PlaybackAndScheduleCopyOnWorkerThread( 66 void PlaybackAndCopyOnWorkerThread(
67 bool reusing_raster_resource, 67 bool reusing_raster_resource,
68 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> 68 ResourceProvider::ScopedWriteLockGpuMemoryBufferForThread*
69 raster_resource_write_lock, 69 raster_resource_write_lock,
70 ResourceProvider::ScopedWriteLockGL* output_resource_write_lock,
70 const Resource* raster_resource, 71 const Resource* raster_resource,
71 const Resource* output_resource, 72 const Resource* output_resource,
72 const RasterSource* raster_source, 73 const RasterSource* raster_source,
73 const gfx::Rect& raster_full_rect, 74 const gfx::Rect& raster_full_rect,
74 const gfx::Rect& raster_dirty_rect, 75 const gfx::Rect& raster_dirty_rect,
75 float scale); 76 float scale);
76 77
77 // Issues copy operations until |sequence| has been processed. This will 78 // Issues copy operations until |sequence| has been processed. This will
78 // return immediately if |sequence| has already been processed. 79 // return immediately if |sequence| has already been processed.
79 void AdvanceLastIssuedCopyTo(CopySequenceNumber sequence); 80 void AdvanceLastIssuedCopyTo(CopySequenceNumber sequence);
80 81
81 bool have_persistent_gpu_memory_buffers() const { 82 bool have_persistent_gpu_memory_buffers() const {
82 return have_persistent_gpu_memory_buffers_; 83 return have_persistent_gpu_memory_buffers_;
83 } 84 }
84 85
85 protected: 86 protected:
86 OneCopyTileTaskWorkerPool(base::SequencedTaskRunner* task_runner, 87 OneCopyTileTaskWorkerPool(base::SequencedTaskRunner* task_runner,
87 TaskGraphRunner* task_graph_runner, 88 TaskGraphRunner* task_graph_runner,
88 ContextProvider* context_provider, 89 ContextProvider* context_provider,
89 ResourceProvider* resource_provider, 90 ResourceProvider* resource_provider,
90 ResourcePool* resource_pool, 91 ResourcePool* resource_pool,
91 int max_copy_texture_chromium_size, 92 int max_copy_texture_chromium_size,
92 bool have_persistent_gpu_memory_buffers); 93 bool have_persistent_gpu_memory_buffers);
93 94
94 private: 95 private:
95 struct CopyOperation {
96 typedef ScopedPtrDeque<CopyOperation> Deque;
97
98 CopyOperation(scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer>
99 src_write_lock,
100 const Resource* src,
101 const Resource* dst,
102 const gfx::Rect& rect);
103 ~CopyOperation();
104
105 scoped_ptr<ResourceProvider::ScopedWriteLockGpuMemoryBuffer> src_write_lock;
106 const Resource* src;
107 const Resource* dst;
108 const gfx::Rect rect;
109 };
110
111 void OnTaskSetFinished(TaskSet task_set); 96 void OnTaskSetFinished(TaskSet task_set);
112 void AdvanceLastFlushedCopyTo(CopySequenceNumber sequence);
113 void IssueCopyOperations(int64 count);
114 void ScheduleCheckForCompletedCopyOperationsWithLockAcquired(
115 bool wait_if_needed);
116 void CheckForCompletedCopyOperations(bool wait_if_needed);
117 scoped_refptr<base::trace_event::ConvertableToTraceFormat> StateAsValue() 97 scoped_refptr<base::trace_event::ConvertableToTraceFormat> StateAsValue()
118 const; 98 const;
119 void StagingStateAsValueInto( 99 void StagingStateAsValueInto(
120 base::trace_event::TracedValue* staging_state) const; 100 base::trace_event::TracedValue* staging_state) const;
121 101
122 scoped_refptr<base::SequencedTaskRunner> task_runner_; 102 scoped_refptr<base::SequencedTaskRunner> task_runner_;
123 TaskGraphRunner* task_graph_runner_; 103 TaskGraphRunner* task_graph_runner_;
124 const NamespaceToken namespace_token_; 104 const NamespaceToken namespace_token_;
125 TileTaskRunnerClient* client_; 105 TileTaskRunnerClient* client_;
126 ContextProvider* context_provider_; 106 ContextProvider* context_provider_;
127 ResourceProvider* resource_provider_; 107 ResourceProvider* resource_provider_;
128 ResourcePool* resource_pool_; 108 ResourcePool* resource_pool_;
129 const int max_bytes_per_copy_operation_; 109 const int max_bytes_per_copy_operation_;
130 const bool have_persistent_gpu_memory_buffers_; 110 const bool have_persistent_gpu_memory_buffers_;
131 TaskSetCollection tasks_pending_; 111 TaskSetCollection tasks_pending_;
132 scoped_refptr<TileTask> task_set_finished_tasks_[kNumberOfTaskSets]; 112 scoped_refptr<TileTask> task_set_finished_tasks_[kNumberOfTaskSets];
133 CopySequenceNumber last_issued_copy_operation_;
134 CopySequenceNumber last_flushed_copy_operation_;
135 113
136 // Task graph used when scheduling tasks and vector used to gather 114 // Task graph used when scheduling tasks and vector used to gather
137 // completed tasks. 115 // completed tasks.
138 TaskGraph graph_; 116 TaskGraph graph_;
139 Task::Vector completed_tasks_; 117 Task::Vector completed_tasks_;
140 118
141 base::Lock lock_; 119 base::Lock lock_;
142 // |lock_| must be acquired when accessing the following members.
143 base::ConditionVariable copy_operation_count_cv_;
144 int bytes_scheduled_since_last_flush_;
145 size_t issued_copy_operation_count_;
146 CopyOperation::Deque pending_copy_operations_;
147 CopySequenceNumber next_copy_operation_sequence_;
148 bool check_for_completed_copy_operations_pending_;
149 base::TimeTicks last_check_for_completed_copy_operations_time_;
150 bool shutdown_; 120 bool shutdown_;
151 121
152 base::WeakPtrFactory<OneCopyTileTaskWorkerPool> weak_ptr_factory_; 122 base::WeakPtrFactory<OneCopyTileTaskWorkerPool> weak_ptr_factory_;
153 // "raster finished" tasks need their own factory as they need to be 123 // "raster finished" tasks need their own factory as they need to be
154 // canceled when ScheduleTasks() is called. 124 // canceled when ScheduleTasks() is called.
155 base::WeakPtrFactory<OneCopyTileTaskWorkerPool> 125 base::WeakPtrFactory<OneCopyTileTaskWorkerPool>
156 task_set_finished_weak_ptr_factory_; 126 task_set_finished_weak_ptr_factory_;
157 127
158 DISALLOW_COPY_AND_ASSIGN(OneCopyTileTaskWorkerPool); 128 DISALLOW_COPY_AND_ASSIGN(OneCopyTileTaskWorkerPool);
159 }; 129 };
160 130
161 } // namespace cc 131 } // namespace cc
162 132
163 #endif // CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_ 133 #endif // CC_RASTER_ONE_COPY_TILE_TASK_WORKER_POOL_H_
OLDNEW
« no previous file with comments | « no previous file | cc/raster/one_copy_tile_task_worker_pool.cc » ('j') | cc/resources/resource_provider.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698