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

Side by Side Diff: cc/raster/one_copy_raster_buffer_provider.cc

Issue 1951193002: cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_stream
Patch Set: vmpstr's review Created 4 years, 6 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/raster/one_copy_raster_buffer_provider.h ('k') | cc/raster/raster_buffer_provider.h » ('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 #include "cc/raster/one_copy_raster_buffer_provider.h" 5 #include "cc/raster/one_copy_raster_buffer_provider.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "cc/base/math_util.h" 14 #include "cc/base/math_util.h"
15 #include "cc/resources/platform_color.h" 15 #include "cc/resources/platform_color.h"
16 #include "cc/resources/resource_format.h" 16 #include "cc/resources/resource_format.h"
17 #include "cc/resources/resource_util.h" 17 #include "cc/resources/resource_util.h"
18 #include "cc/resources/scoped_resource.h" 18 #include "cc/resources/scoped_resource.h"
19 #include "gpu/GLES2/gl2extchromium.h" 19 #include "gpu/GLES2/gl2extchromium.h"
20 #include "gpu/command_buffer/client/gles2_interface.h" 20 #include "gpu/command_buffer/client/gles2_interface.h"
21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 21 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
22 #include "ui/gfx/buffer_format_util.h" 22 #include "ui/gfx/buffer_format_util.h"
23 23
24 namespace cc { 24 namespace cc {
25 namespace { 25 namespace {
26 26
27 class RasterBufferImpl : public RasterBuffer {
28 public:
29 RasterBufferImpl(OneCopyRasterBufferProvider* worker_pool,
30 ResourceProvider* resource_provider,
31 ResourceFormat resource_format,
32 const Resource* resource,
33 uint64_t previous_content_id)
34 : worker_pool_(worker_pool),
35 resource_(resource),
36 lock_(resource_provider, resource->id()),
37 previous_content_id_(previous_content_id) {}
38
39 ~RasterBufferImpl() override {}
40
41 // Overridden from RasterBuffer:
42 void Playback(
43 const RasterSource* raster_source,
44 const gfx::Rect& raster_full_rect,
45 const gfx::Rect& raster_dirty_rect,
46 uint64_t new_content_id,
47 float scale,
48 const RasterSource::PlaybackSettings& playback_settings) override {
49 TRACE_EVENT0("cc", "OneCopyRasterBuffer::Playback");
50 worker_pool_->PlaybackAndCopyOnWorkerThread(
51 resource_, &lock_, raster_source, raster_full_rect, raster_dirty_rect,
52 scale, playback_settings, previous_content_id_, new_content_id);
53 }
54
55 private:
56 OneCopyRasterBufferProvider* worker_pool_;
57 const Resource* resource_;
58 ResourceProvider::ScopedWriteLockGL lock_;
59 uint64_t previous_content_id_;
60
61 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl);
62 };
63
64 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good 27 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good
65 // default batch size for copy operations. 28 // default batch size for copy operations.
66 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4; 29 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4;
67 30
68 } // namespace 31 } // namespace
69 32
33 OneCopyRasterBufferProvider::RasterBufferImpl::RasterBufferImpl(
34 OneCopyRasterBufferProvider* client,
35 ResourceProvider* resource_provider,
36 const Resource* resource,
37 uint64_t previous_content_id,
38 bool async_worker_context_enabled)
39 : client_(client),
40 resource_(resource),
41 lock_(resource_provider, resource->id(), async_worker_context_enabled),
42 previous_content_id_(previous_content_id) {
43 client_->pending_raster_buffers_.insert(this);
44 }
45
46 OneCopyRasterBufferProvider::RasterBufferImpl::~RasterBufferImpl() {
47 client_->pending_raster_buffers_.erase(this);
48 }
49
50 void OneCopyRasterBufferProvider::RasterBufferImpl::Playback(
51 const RasterSource* raster_source,
52 const gfx::Rect& raster_full_rect,
53 const gfx::Rect& raster_dirty_rect,
54 uint64_t new_content_id,
55 float scale,
56 const RasterSource::PlaybackSettings& playback_settings) {
57 TRACE_EVENT0("cc", "OneCopyRasterBuffer::Playback");
58 client_->PlaybackAndCopyOnWorkerThread(
59 resource_, &lock_, sync_token_, raster_source, raster_full_rect,
60 raster_dirty_rect, scale, playback_settings, previous_content_id_,
61 new_content_id);
62 }
63
70 OneCopyRasterBufferProvider::OneCopyRasterBufferProvider( 64 OneCopyRasterBufferProvider::OneCopyRasterBufferProvider(
71 base::SequencedTaskRunner* task_runner, 65 base::SequencedTaskRunner* task_runner,
72 ContextProvider* compositor_context_provider, 66 ContextProvider* compositor_context_provider,
73 ContextProvider* worker_context_provider, 67 ContextProvider* worker_context_provider,
74 ResourceProvider* resource_provider, 68 ResourceProvider* resource_provider,
75 int max_copy_texture_chromium_size, 69 int max_copy_texture_chromium_size,
76 bool use_partial_raster, 70 bool use_partial_raster,
77 int max_staging_buffer_usage_in_bytes, 71 int max_staging_buffer_usage_in_bytes,
78 ResourceFormat preferred_tile_format) 72 ResourceFormat preferred_tile_format,
73 bool async_worker_context_enabled)
79 : compositor_context_provider_(compositor_context_provider), 74 : compositor_context_provider_(compositor_context_provider),
80 worker_context_provider_(worker_context_provider), 75 worker_context_provider_(worker_context_provider),
81 resource_provider_(resource_provider), 76 resource_provider_(resource_provider),
82 max_bytes_per_copy_operation_( 77 max_bytes_per_copy_operation_(
83 max_copy_texture_chromium_size 78 max_copy_texture_chromium_size
84 ? std::min(kMaxBytesPerCopyOperation, 79 ? std::min(kMaxBytesPerCopyOperation,
85 max_copy_texture_chromium_size) 80 max_copy_texture_chromium_size)
86 : kMaxBytesPerCopyOperation), 81 : kMaxBytesPerCopyOperation),
87 use_partial_raster_(use_partial_raster), 82 use_partial_raster_(use_partial_raster),
88 bytes_scheduled_since_last_flush_(0), 83 bytes_scheduled_since_last_flush_(0),
89 preferred_tile_format_(preferred_tile_format), 84 preferred_tile_format_(preferred_tile_format),
90 staging_pool_(task_runner, 85 staging_pool_(task_runner,
91 worker_context_provider, 86 worker_context_provider,
92 resource_provider, 87 resource_provider,
93 use_partial_raster, 88 use_partial_raster,
94 max_staging_buffer_usage_in_bytes) { 89 max_staging_buffer_usage_in_bytes),
95 DCHECK(compositor_context_provider_); 90 async_worker_context_enabled_(async_worker_context_enabled) {
91 DCHECK(compositor_context_provider);
96 DCHECK(worker_context_provider); 92 DCHECK(worker_context_provider);
97 } 93 }
98 94
99 OneCopyRasterBufferProvider::~OneCopyRasterBufferProvider() {} 95 OneCopyRasterBufferProvider::~OneCopyRasterBufferProvider() {
96 DCHECK(pending_raster_buffers_.empty());
97 }
100 98
101 std::unique_ptr<RasterBuffer> 99 std::unique_ptr<RasterBuffer>
102 OneCopyRasterBufferProvider::AcquireBufferForRaster( 100 OneCopyRasterBufferProvider::AcquireBufferForRaster(
103 const Resource* resource, 101 const Resource* resource,
104 uint64_t resource_content_id, 102 uint64_t resource_content_id,
105 uint64_t previous_content_id) { 103 uint64_t previous_content_id) {
106 // TODO(danakj): If resource_content_id != 0, we only need to copy/upload 104 // TODO(danakj): If resource_content_id != 0, we only need to copy/upload
107 // the dirty rect. 105 // the dirty rect.
108 return base::WrapUnique<RasterBuffer>( 106 return base::WrapUnique(new RasterBufferImpl(this, resource_provider_,
109 new RasterBufferImpl(this, resource_provider_, resource->format(), 107 resource, previous_content_id,
110 resource, previous_content_id)); 108 async_worker_context_enabled_));
111 } 109 }
112 110
113 void OneCopyRasterBufferProvider::ReleaseBufferForRaster( 111 void OneCopyRasterBufferProvider::ReleaseBufferForRaster(
114 std::unique_ptr<RasterBuffer> buffer) { 112 std::unique_ptr<RasterBuffer> buffer) {
115 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. 113 // Nothing to do here. RasterBufferImpl destructor cleans up after itself.
116 } 114 }
117 115
118 void OneCopyRasterBufferProvider::OrderingBarrier() { 116 bool OneCopyRasterBufferProvider::OrderingBarrier() {
119 TRACE_EVENT0("cc", "OneCopyRasterBufferProvider::OrderingBarrier"); 117 TRACE_EVENT0("cc", "OneCopyRasterBufferProvider::OrderingBarrier");
120 compositor_context_provider_->ContextGL()->OrderingBarrierCHROMIUM(); 118
119 gpu::gles2::GLES2Interface* gl = compositor_context_provider_->ContextGL();
120 GLuint64 fence = gl->InsertFenceSyncCHROMIUM();
121 gl->OrderingBarrierCHROMIUM();
122
123 gpu::SyncToken sync_token;
124 gl->GenUnverifiedSyncTokenCHROMIUM(fence, sync_token.GetData());
125
126 for (RasterBufferImpl* buffer : pending_raster_buffers_)
127 buffer->set_sync_token(sync_token);
128 pending_raster_buffers_.clear();
129
130 DCHECK(sync_token.HasData() ||
131 gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR);
132 // Do not proceed with ScheduleTasks if sync token was invalid.
133 return sync_token.HasData();
121 } 134 }
122 135
123 ResourceFormat OneCopyRasterBufferProvider::GetResourceFormat( 136 ResourceFormat OneCopyRasterBufferProvider::GetResourceFormat(
124 bool must_support_alpha) const { 137 bool must_support_alpha) const {
125 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) && 138 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) &&
126 (DoesResourceFormatSupportAlpha(preferred_tile_format_) || 139 (DoesResourceFormatSupportAlpha(preferred_tile_format_) ||
127 !must_support_alpha)) { 140 !must_support_alpha)) {
128 return preferred_tile_format_; 141 return preferred_tile_format_;
129 } 142 }
130 143
131 return resource_provider_->best_texture_format(); 144 return resource_provider_->best_texture_format();
132 } 145 }
133 146
134 bool OneCopyRasterBufferProvider::GetResourceRequiresSwizzle( 147 bool OneCopyRasterBufferProvider::GetResourceRequiresSwizzle(
135 bool must_support_alpha) const { 148 bool must_support_alpha) const {
136 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); 149 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha));
137 } 150 }
138 151
139 void OneCopyRasterBufferProvider::Shutdown() { 152 void OneCopyRasterBufferProvider::Shutdown() {
140 staging_pool_.Shutdown(); 153 staging_pool_.Shutdown();
154 pending_raster_buffers_.clear();
141 } 155 }
142 156
143 void OneCopyRasterBufferProvider::PlaybackAndCopyOnWorkerThread( 157 void OneCopyRasterBufferProvider::PlaybackAndCopyOnWorkerThread(
144 const Resource* resource, 158 const Resource* resource,
145 ResourceProvider::ScopedWriteLockGL* resource_lock, 159 ResourceProvider::ScopedWriteLockGL* resource_lock,
160 const gpu::SyncToken& sync_token,
146 const RasterSource* raster_source, 161 const RasterSource* raster_source,
147 const gfx::Rect& raster_full_rect, 162 const gfx::Rect& raster_full_rect,
148 const gfx::Rect& raster_dirty_rect, 163 const gfx::Rect& raster_dirty_rect,
149 float scale, 164 float scale,
150 const RasterSource::PlaybackSettings& playback_settings, 165 const RasterSource::PlaybackSettings& playback_settings,
151 uint64_t previous_content_id, 166 uint64_t previous_content_id,
152 uint64_t new_content_id) { 167 uint64_t new_content_id) {
153 std::unique_ptr<StagingBuffer> staging_buffer = 168 std::unique_ptr<StagingBuffer> staging_buffer =
154 staging_pool_.AcquireStagingBuffer(resource, previous_content_id); 169 staging_pool_.AcquireStagingBuffer(resource, previous_content_id);
155 170
156 PlaybackToStagingBuffer(staging_buffer.get(), resource, raster_source, 171 PlaybackToStagingBuffer(staging_buffer.get(), resource, raster_source,
157 raster_full_rect, raster_dirty_rect, scale, 172 raster_full_rect, raster_dirty_rect, scale,
158 playback_settings, previous_content_id, 173 playback_settings, previous_content_id,
159 new_content_id); 174 new_content_id);
160 175
161 CopyOnWorkerThread(staging_buffer.get(), resource, resource_lock, 176 CopyOnWorkerThread(staging_buffer.get(), resource_lock, sync_token,
162 raster_source, previous_content_id, new_content_id); 177 raster_source, previous_content_id, new_content_id);
163 178
164 staging_pool_.ReleaseStagingBuffer(std::move(staging_buffer)); 179 staging_pool_.ReleaseStagingBuffer(std::move(staging_buffer));
165 } 180 }
166 181
167 void OneCopyRasterBufferProvider::PlaybackToStagingBuffer( 182 void OneCopyRasterBufferProvider::PlaybackToStagingBuffer(
168 StagingBuffer* staging_buffer, 183 StagingBuffer* staging_buffer,
169 const Resource* resource, 184 const Resource* resource,
170 const RasterSource* raster_source, 185 const RasterSource* raster_source,
171 const gfx::Rect& raster_full_rect, 186 const gfx::Rect& raster_full_rect,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 buffer->memory(0), resource->format(), staging_buffer->size, 225 buffer->memory(0), resource->format(), staging_buffer->size,
211 buffer->stride(0), raster_source, raster_full_rect, playback_rect, 226 buffer->stride(0), raster_source, raster_full_rect, playback_rect,
212 scale, playback_settings); 227 scale, playback_settings);
213 buffer->Unmap(); 228 buffer->Unmap();
214 staging_buffer->content_id = new_content_id; 229 staging_buffer->content_id = new_content_id;
215 } 230 }
216 } 231 }
217 232
218 void OneCopyRasterBufferProvider::CopyOnWorkerThread( 233 void OneCopyRasterBufferProvider::CopyOnWorkerThread(
219 StagingBuffer* staging_buffer, 234 StagingBuffer* staging_buffer,
220 const Resource* resource,
221 ResourceProvider::ScopedWriteLockGL* resource_lock, 235 ResourceProvider::ScopedWriteLockGL* resource_lock,
236 const gpu::SyncToken& sync_token,
222 const RasterSource* raster_source, 237 const RasterSource* raster_source,
223 uint64_t previous_content_id, 238 uint64_t previous_content_id,
224 uint64_t new_content_id) { 239 uint64_t new_content_id) {
225 { 240 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_);
226 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_);
227 241
228 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL(); 242 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
229 DCHECK(gl); 243 DCHECK(gl);
230 244
231 unsigned image_target = 245 // Synchronize with compositor.
232 resource_provider_->GetImageTextureTarget(resource->format()); 246 DCHECK(sync_token.HasData());
247 gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
233 248
234 // Create and bind staging texture. 249 // Create texture after synchronizing with compositor.
235 if (!staging_buffer->texture_id) { 250 ResourceProvider::ScopedTextureProvider scoped_texture(
236 gl->GenTextures(1, &staging_buffer->texture_id); 251 gl, resource_lock, async_worker_context_enabled_);
237 gl->BindTexture(image_target, staging_buffer->texture_id);
238 gl->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
239 gl->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
240 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
241 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
242 } else {
243 gl->BindTexture(image_target, staging_buffer->texture_id);
244 }
245 252
246 // Create and bind image. 253 unsigned resource_texture_id = scoped_texture.texture_id();
247 if (!staging_buffer->image_id) { 254 unsigned image_target =
248 if (staging_buffer->gpu_memory_buffer) { 255 resource_provider_->GetImageTextureTarget(resource_lock->format());
249 staging_buffer->image_id = gl->CreateImageCHROMIUM( 256
250 staging_buffer->gpu_memory_buffer->AsClientBuffer(), 257 // Create and bind staging texture.
251 staging_buffer->size.width(), staging_buffer->size.height(), 258 if (!staging_buffer->texture_id) {
252 GLInternalFormat(resource->format())); 259 gl->GenTextures(1, &staging_buffer->texture_id);
253 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id); 260 gl->BindTexture(image_target, staging_buffer->texture_id);
254 } 261 gl->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
255 } else { 262 gl->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
256 gl->ReleaseTexImage2DCHROMIUM(image_target, staging_buffer->image_id); 263 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
264 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
265 } else {
266 gl->BindTexture(image_target, staging_buffer->texture_id);
267 }
268
269 // Create and bind image.
270 if (!staging_buffer->image_id) {
271 if (staging_buffer->gpu_memory_buffer) {
272 staging_buffer->image_id = gl->CreateImageCHROMIUM(
273 staging_buffer->gpu_memory_buffer->AsClientBuffer(),
274 staging_buffer->size.width(), staging_buffer->size.height(),
275 GLInternalFormat(resource_lock->format()));
257 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id); 276 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
258 } 277 }
278 } else {
279 gl->ReleaseTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
280 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
281 }
259 282
260 // Unbind staging texture. 283 // Unbind staging texture.
261 gl->BindTexture(image_target, 0); 284 gl->BindTexture(image_target, 0);
262 285
263 if (resource_provider_->use_sync_query()) { 286 if (resource_provider_->use_sync_query()) {
264 if (!staging_buffer->query_id) 287 if (!staging_buffer->query_id)
265 gl->GenQueriesEXT(1, &staging_buffer->query_id); 288 gl->GenQueriesEXT(1, &staging_buffer->query_id);
266 289
267 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 290 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
268 // TODO(reveman): This avoids a performance problem on ARM ChromeOS 291 // TODO(reveman): This avoids a performance problem on ARM ChromeOS
269 // devices. crbug.com/580166 292 // devices. crbug.com/580166
270 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, staging_buffer->query_id); 293 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, staging_buffer->query_id);
271 #else 294 #else
272 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, 295 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, staging_buffer->query_id);
273 staging_buffer->query_id);
274 #endif 296 #endif
275 } 297 }
276 298
277 // Since compressed texture's cannot be pre-allocated we might have an 299 // Since compressed texture's cannot be pre-allocated we might have an
278 // unallocated resource in which case we need to perform a full size copy. 300 // unallocated resource in which case we need to perform a full size copy.
279 if (IsResourceFormatCompressed(resource->format())) { 301 if (IsResourceFormatCompressed(resource_lock->format())) {
280 gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, 302 gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id,
281 resource_lock->texture_id()); 303 resource_texture_id);
282 } else { 304 } else {
283 int bytes_per_row = ResourceUtil::UncheckedWidthInBytes<int>( 305 int bytes_per_row = ResourceUtil::UncheckedWidthInBytes<int>(
284 resource->size().width(), resource->format()); 306 resource_lock->size().width(), resource_lock->format());
285 int chunk_size_in_rows = 307 int chunk_size_in_rows =
286 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row); 308 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row);
287 // Align chunk size to 4. Required to support compressed texture formats. 309 // Align chunk size to 4. Required to support compressed texture formats.
288 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4); 310 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4);
289 int y = 0; 311 int y = 0;
290 int height = resource->size().height(); 312 int height = resource_lock->size().height();
291 while (y < height) { 313 while (y < height) {
292 // Copy at most |chunk_size_in_rows|. 314 // Copy at most |chunk_size_in_rows|.
293 int rows_to_copy = std::min(chunk_size_in_rows, height - y); 315 int rows_to_copy = std::min(chunk_size_in_rows, height - y);
294 DCHECK_GT(rows_to_copy, 0); 316 DCHECK_GT(rows_to_copy, 0);
295 317
296 gl->CopySubTextureCHROMIUM( 318 gl->CopySubTextureCHROMIUM(
297 staging_buffer->texture_id, resource_lock->texture_id(), 0, y, 0, y, 319 staging_buffer->texture_id, resource_texture_id, 0, y, 0, y,
298 resource->size().width(), rows_to_copy, false, false, false); 320 resource_lock->size().width(), rows_to_copy, false, false, false);
299 y += rows_to_copy; 321 y += rows_to_copy;
300 322
301 // Increment |bytes_scheduled_since_last_flush_| by the amount of memory 323 // Increment |bytes_scheduled_since_last_flush_| by the amount of memory
302 // used for this copy operation. 324 // used for this copy operation.
303 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row; 325 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row;
304 326
305 if (bytes_scheduled_since_last_flush_ >= 327 if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) {
306 max_bytes_per_copy_operation_) { 328 gl->ShallowFlushCHROMIUM();
307 gl->ShallowFlushCHROMIUM(); 329 bytes_scheduled_since_last_flush_ = 0;
308 bytes_scheduled_since_last_flush_ = 0;
309 }
310 } 330 }
311 } 331 }
332 }
312 333
313 if (resource_provider_->use_sync_query()) { 334 if (resource_provider_->use_sync_query()) {
314 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 335 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
315 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); 336 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
316 #else 337 #else
317 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); 338 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
318 #endif 339 #endif
319 } 340 }
320 341
321 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); 342 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
322 343
323 // Barrier to sync worker context output to cc context. 344 // Barrier to sync worker context output to cc context.
324 gl->OrderingBarrierCHROMIUM(); 345 gl->OrderingBarrierCHROMIUM();
325 346
326 // Generate sync token after the barrier for cross context synchronization. 347 // Generate sync token after the barrier for cross context synchronization.
327 gpu::SyncToken sync_token; 348 gpu::SyncToken resource_sync_token;
328 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); 349 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData());
329 resource_lock->UpdateResourceSyncToken(sync_token); 350 resource_lock->set_sync_token(resource_sync_token);
330 } 351 resource_lock->set_synchronized(!async_worker_context_enabled_);
331 } 352 }
332 353
333 } // namespace cc 354 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/one_copy_raster_buffer_provider.h ('k') | cc/raster/raster_buffer_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698