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

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

Issue 2081883002: Reland of cc: Add mailbox support to ResourceProvider write locks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@worker_context_sync_tokens_revert
Patch Set: don't cancel tasks on invalid sync token 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
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 void 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 DCHECK(sync_token.HasData() ||
127 gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR);
128
129 for (RasterBufferImpl* buffer : pending_raster_buffers_)
130 buffer->set_sync_token(sync_token);
131 pending_raster_buffers_.clear();
121 } 132 }
122 133
123 ResourceFormat OneCopyRasterBufferProvider::GetResourceFormat( 134 ResourceFormat OneCopyRasterBufferProvider::GetResourceFormat(
124 bool must_support_alpha) const { 135 bool must_support_alpha) const {
125 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) && 136 if (resource_provider_->IsResourceFormatSupported(preferred_tile_format_) &&
126 (DoesResourceFormatSupportAlpha(preferred_tile_format_) || 137 (DoesResourceFormatSupportAlpha(preferred_tile_format_) ||
127 !must_support_alpha)) { 138 !must_support_alpha)) {
128 return preferred_tile_format_; 139 return preferred_tile_format_;
129 } 140 }
130 141
131 return resource_provider_->best_texture_format(); 142 return resource_provider_->best_texture_format();
132 } 143 }
133 144
134 bool OneCopyRasterBufferProvider::GetResourceRequiresSwizzle( 145 bool OneCopyRasterBufferProvider::GetResourceRequiresSwizzle(
135 bool must_support_alpha) const { 146 bool must_support_alpha) const {
136 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); 147 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha));
137 } 148 }
138 149
139 void OneCopyRasterBufferProvider::Shutdown() { 150 void OneCopyRasterBufferProvider::Shutdown() {
140 staging_pool_.Shutdown(); 151 staging_pool_.Shutdown();
152 pending_raster_buffers_.clear();
141 } 153 }
142 154
143 void OneCopyRasterBufferProvider::PlaybackAndCopyOnWorkerThread( 155 void OneCopyRasterBufferProvider::PlaybackAndCopyOnWorkerThread(
144 const Resource* resource, 156 const Resource* resource,
145 ResourceProvider::ScopedWriteLockGL* resource_lock, 157 ResourceProvider::ScopedWriteLockGL* resource_lock,
158 const gpu::SyncToken& sync_token,
146 const RasterSource* raster_source, 159 const RasterSource* raster_source,
147 const gfx::Rect& raster_full_rect, 160 const gfx::Rect& raster_full_rect,
148 const gfx::Rect& raster_dirty_rect, 161 const gfx::Rect& raster_dirty_rect,
149 float scale, 162 float scale,
150 const RasterSource::PlaybackSettings& playback_settings, 163 const RasterSource::PlaybackSettings& playback_settings,
151 uint64_t previous_content_id, 164 uint64_t previous_content_id,
152 uint64_t new_content_id) { 165 uint64_t new_content_id) {
166 // Early out if sync token is invalid. This happens when the context is lost
167 // before ScheduleTasks was called.
168 if (!sync_token.HasData()) {
169 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_);
170 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
171 DCHECK(gl && gl->GetGraphicsResetStatusKHR() != GL_NO_ERROR);
piman 2016/06/21 01:45:35 ditto
sunnyps 2016/06/21 01:57:39 Done.
172 return;
173 }
174
153 std::unique_ptr<StagingBuffer> staging_buffer = 175 std::unique_ptr<StagingBuffer> staging_buffer =
154 staging_pool_.AcquireStagingBuffer(resource, previous_content_id); 176 staging_pool_.AcquireStagingBuffer(resource, previous_content_id);
155 177
156 PlaybackToStagingBuffer(staging_buffer.get(), resource, raster_source, 178 PlaybackToStagingBuffer(staging_buffer.get(), resource, raster_source,
157 raster_full_rect, raster_dirty_rect, scale, 179 raster_full_rect, raster_dirty_rect, scale,
158 playback_settings, previous_content_id, 180 playback_settings, previous_content_id,
159 new_content_id); 181 new_content_id);
160 182
161 CopyOnWorkerThread(staging_buffer.get(), resource, resource_lock, 183 CopyOnWorkerThread(staging_buffer.get(), resource_lock, sync_token,
162 raster_source, previous_content_id, new_content_id); 184 raster_source, previous_content_id, new_content_id);
163 185
164 staging_pool_.ReleaseStagingBuffer(std::move(staging_buffer)); 186 staging_pool_.ReleaseStagingBuffer(std::move(staging_buffer));
165 } 187 }
166 188
167 void OneCopyRasterBufferProvider::PlaybackToStagingBuffer( 189 void OneCopyRasterBufferProvider::PlaybackToStagingBuffer(
168 StagingBuffer* staging_buffer, 190 StagingBuffer* staging_buffer,
169 const Resource* resource, 191 const Resource* resource,
170 const RasterSource* raster_source, 192 const RasterSource* raster_source,
171 const gfx::Rect& raster_full_rect, 193 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, 232 buffer->memory(0), resource->format(), staging_buffer->size,
211 buffer->stride(0), raster_source, raster_full_rect, playback_rect, 233 buffer->stride(0), raster_source, raster_full_rect, playback_rect,
212 scale, playback_settings); 234 scale, playback_settings);
213 buffer->Unmap(); 235 buffer->Unmap();
214 staging_buffer->content_id = new_content_id; 236 staging_buffer->content_id = new_content_id;
215 } 237 }
216 } 238 }
217 239
218 void OneCopyRasterBufferProvider::CopyOnWorkerThread( 240 void OneCopyRasterBufferProvider::CopyOnWorkerThread(
219 StagingBuffer* staging_buffer, 241 StagingBuffer* staging_buffer,
220 const Resource* resource,
221 ResourceProvider::ScopedWriteLockGL* resource_lock, 242 ResourceProvider::ScopedWriteLockGL* resource_lock,
243 const gpu::SyncToken& sync_token,
222 const RasterSource* raster_source, 244 const RasterSource* raster_source,
223 uint64_t previous_content_id, 245 uint64_t previous_content_id,
224 uint64_t new_content_id) { 246 uint64_t new_content_id) {
225 { 247 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_);
226 ContextProvider::ScopedContextLock scoped_context(worker_context_provider_);
227 248
228 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL(); 249 gpu::gles2::GLES2Interface* gl = scoped_context.ContextGL();
229 DCHECK(gl); 250 DCHECK(gl);
230 251
231 unsigned image_target = 252 // Synchronize with compositor.
232 resource_provider_->GetImageTextureTarget(resource->format()); 253 gl->WaitSyncTokenCHROMIUM(sync_token.GetConstData());
233 254
234 // Create and bind staging texture. 255 // Create texture after synchronizing with compositor.
235 if (!staging_buffer->texture_id) { 256 ResourceProvider::ScopedTextureProvider scoped_texture(
236 gl->GenTextures(1, &staging_buffer->texture_id); 257 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 258
246 // Create and bind image. 259 unsigned resource_texture_id = scoped_texture.texture_id();
247 if (!staging_buffer->image_id) { 260 unsigned image_target =
248 if (staging_buffer->gpu_memory_buffer) { 261 resource_provider_->GetImageTextureTarget(resource_lock->format());
249 staging_buffer->image_id = gl->CreateImageCHROMIUM( 262
250 staging_buffer->gpu_memory_buffer->AsClientBuffer(), 263 // Create and bind staging texture.
251 staging_buffer->size.width(), staging_buffer->size.height(), 264 if (!staging_buffer->texture_id) {
252 GLInternalFormat(resource->format())); 265 gl->GenTextures(1, &staging_buffer->texture_id);
253 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id); 266 gl->BindTexture(image_target, staging_buffer->texture_id);
254 } 267 gl->TexParameteri(image_target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
255 } else { 268 gl->TexParameteri(image_target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
256 gl->ReleaseTexImage2DCHROMIUM(image_target, staging_buffer->image_id); 269 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
270 gl->TexParameteri(image_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
271 } else {
272 gl->BindTexture(image_target, staging_buffer->texture_id);
273 }
274
275 // Create and bind image.
276 if (!staging_buffer->image_id) {
277 if (staging_buffer->gpu_memory_buffer) {
278 staging_buffer->image_id = gl->CreateImageCHROMIUM(
279 staging_buffer->gpu_memory_buffer->AsClientBuffer(),
280 staging_buffer->size.width(), staging_buffer->size.height(),
281 GLInternalFormat(resource_lock->format()));
257 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id); 282 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
258 } 283 }
284 } else {
285 gl->ReleaseTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
286 gl->BindTexImage2DCHROMIUM(image_target, staging_buffer->image_id);
287 }
259 288
260 // Unbind staging texture. 289 // Unbind staging texture.
261 gl->BindTexture(image_target, 0); 290 gl->BindTexture(image_target, 0);
262 291
263 if (resource_provider_->use_sync_query()) { 292 if (resource_provider_->use_sync_query()) {
264 if (!staging_buffer->query_id) 293 if (!staging_buffer->query_id)
265 gl->GenQueriesEXT(1, &staging_buffer->query_id); 294 gl->GenQueriesEXT(1, &staging_buffer->query_id);
266 295
267 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 296 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
268 // TODO(reveman): This avoids a performance problem on ARM ChromeOS 297 // TODO(reveman): This avoids a performance problem on ARM ChromeOS
269 // devices. crbug.com/580166 298 // devices. crbug.com/580166
270 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, staging_buffer->query_id); 299 gl->BeginQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM, staging_buffer->query_id);
271 #else 300 #else
272 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, 301 gl->BeginQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM, staging_buffer->query_id);
273 staging_buffer->query_id);
274 #endif 302 #endif
275 } 303 }
276 304
277 // Since compressed texture's cannot be pre-allocated we might have an 305 // 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. 306 // unallocated resource in which case we need to perform a full size copy.
279 if (IsResourceFormatCompressed(resource->format())) { 307 if (IsResourceFormatCompressed(resource_lock->format())) {
280 gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id, 308 gl->CompressedCopyTextureCHROMIUM(staging_buffer->texture_id,
281 resource_lock->texture_id()); 309 resource_texture_id);
282 } else { 310 } else {
283 int bytes_per_row = ResourceUtil::UncheckedWidthInBytes<int>( 311 int bytes_per_row = ResourceUtil::UncheckedWidthInBytes<int>(
284 resource->size().width(), resource->format()); 312 resource_lock->size().width(), resource_lock->format());
285 int chunk_size_in_rows = 313 int chunk_size_in_rows =
286 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row); 314 std::max(1, max_bytes_per_copy_operation_ / bytes_per_row);
287 // Align chunk size to 4. Required to support compressed texture formats. 315 // Align chunk size to 4. Required to support compressed texture formats.
288 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4); 316 chunk_size_in_rows = MathUtil::UncheckedRoundUp(chunk_size_in_rows, 4);
289 int y = 0; 317 int y = 0;
290 int height = resource->size().height(); 318 int height = resource_lock->size().height();
291 while (y < height) { 319 while (y < height) {
292 // Copy at most |chunk_size_in_rows|. 320 // Copy at most |chunk_size_in_rows|.
293 int rows_to_copy = std::min(chunk_size_in_rows, height - y); 321 int rows_to_copy = std::min(chunk_size_in_rows, height - y);
294 DCHECK_GT(rows_to_copy, 0); 322 DCHECK_GT(rows_to_copy, 0);
295 323
296 gl->CopySubTextureCHROMIUM( 324 gl->CopySubTextureCHROMIUM(
297 staging_buffer->texture_id, resource_lock->texture_id(), 0, y, 0, y, 325 staging_buffer->texture_id, resource_texture_id, 0, y, 0, y,
298 resource->size().width(), rows_to_copy, false, false, false); 326 resource_lock->size().width(), rows_to_copy, false, false, false);
299 y += rows_to_copy; 327 y += rows_to_copy;
300 328
301 // Increment |bytes_scheduled_since_last_flush_| by the amount of memory 329 // Increment |bytes_scheduled_since_last_flush_| by the amount of memory
302 // used for this copy operation. 330 // used for this copy operation.
303 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row; 331 bytes_scheduled_since_last_flush_ += rows_to_copy * bytes_per_row;
304 332
305 if (bytes_scheduled_since_last_flush_ >= 333 if (bytes_scheduled_since_last_flush_ >= max_bytes_per_copy_operation_) {
306 max_bytes_per_copy_operation_) { 334 gl->ShallowFlushCHROMIUM();
307 gl->ShallowFlushCHROMIUM(); 335 bytes_scheduled_since_last_flush_ = 0;
308 bytes_scheduled_since_last_flush_ = 0;
309 }
310 } 336 }
311 } 337 }
338 }
312 339
313 if (resource_provider_->use_sync_query()) { 340 if (resource_provider_->use_sync_query()) {
314 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY) 341 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)
315 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM); 342 gl->EndQueryEXT(GL_COMMANDS_ISSUED_CHROMIUM);
316 #else 343 #else
317 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM); 344 gl->EndQueryEXT(GL_COMMANDS_COMPLETED_CHROMIUM);
318 #endif 345 #endif
319 } 346 }
320 347
321 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM(); 348 const uint64_t fence_sync = gl->InsertFenceSyncCHROMIUM();
322 349
323 // Barrier to sync worker context output to cc context. 350 // Barrier to sync worker context output to cc context.
324 gl->OrderingBarrierCHROMIUM(); 351 gl->OrderingBarrierCHROMIUM();
325 352
326 // Generate sync token after the barrier for cross context synchronization. 353 // Generate sync token after the barrier for cross context synchronization.
327 gpu::SyncToken sync_token; 354 gpu::SyncToken resource_sync_token;
328 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); 355 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData());
329 resource_lock->UpdateResourceSyncToken(sync_token); 356 resource_lock->set_sync_token(resource_sync_token);
330 } 357 resource_lock->set_synchronized(!async_worker_context_enabled_);
331 } 358 }
332 359
333 } // namespace cc 360 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698