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

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

Issue 2555743004: Delay activation/draw on GPU tile work completion (Closed)
Patch Set: rebase Created 3 years, 11 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 "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/metrics/histogram_macros.h" 15 #include "base/metrics/histogram_macros.h"
16 #include "base/trace_event/trace_event.h" 16 #include "base/trace_event/trace_event.h"
17 #include "cc/base/histograms.h" 17 #include "cc/base/histograms.h"
18 #include "cc/base/math_util.h" 18 #include "cc/base/math_util.h"
19 #include "cc/resources/platform_color.h" 19 #include "cc/resources/platform_color.h"
20 #include "cc/resources/resource_format.h" 20 #include "cc/resources/resource_format.h"
21 #include "cc/resources/resource_util.h" 21 #include "cc/resources/resource_util.h"
22 #include "cc/resources/scoped_resource.h" 22 #include "cc/resources/scoped_resource.h"
23 #include "gpu/GLES2/gl2extchromium.h" 23 #include "gpu/GLES2/gl2extchromium.h"
24 #include "gpu/command_buffer/client/context_support.h"
24 #include "gpu/command_buffer/client/gles2_interface.h" 25 #include "gpu/command_buffer/client/gles2_interface.h"
25 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 26 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
26 #include "ui/gfx/buffer_format_util.h" 27 #include "ui/gfx/buffer_format_util.h"
27 28
28 namespace cc { 29 namespace cc {
29 namespace { 30 namespace {
30 31
31 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good 32 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good
32 // default batch size for copy operations. 33 // default batch size for copy operations.
33 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4; 34 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); 156 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha));
156 } 157 }
157 158
158 bool OneCopyRasterBufferProvider::CanPartialRasterIntoProvidedResource() const { 159 bool OneCopyRasterBufferProvider::CanPartialRasterIntoProvidedResource() const {
159 // While OneCopyRasterBufferProvider has an internal partial raster 160 // While OneCopyRasterBufferProvider has an internal partial raster
160 // implementation, it cannot directly partial raster into the externally 161 // implementation, it cannot directly partial raster into the externally
161 // owned resource provided in AcquireBufferForRaster. 162 // owned resource provided in AcquireBufferForRaster.
162 return false; 163 return false;
163 } 164 }
164 165
166 bool OneCopyRasterBufferProvider::IsResourceReadyToDraw(
167 ResourceId resource_id) const {
168 if (!async_worker_context_enabled_)
169 return true;
170
171 gpu::SyncToken sync_token =
172 resource_provider_->GetSyncTokenForResource(resource_id);
173 if (!sync_token.HasData())
174 return true;
175
176 // IsSyncTokenSignalled is threadsafe, no need for worker context lock.
177 return worker_context_provider_->ContextSupport()->IsSyncTokenSignalled(
178 sync_token);
179 }
180
181 uint64_t OneCopyRasterBufferProvider::SetReadyToDrawCallback(
182 const ResourceProvider::ResourceIdArray& resource_ids,
183 const base::Closure& callback,
184 uint64_t pending_callback_id) const {
185 if (!async_worker_context_enabled_)
186 return 0;
187
188 gpu::SyncToken sync_token =
189 resource_provider_->GetSyncTokenForResources(resource_ids);
190 uint64_t callback_id = sync_token.release_count();
191 DCHECK_NE(callback_id, 0u);
192
193 // If the callback we are about to request has the same ID as the one which
vmpstr 2017/01/05 22:00:46 Same here.
ericrk 2017/01/09 23:05:21 Done.
194 // our caller is waiting on, then the request is redundant.
195 if (callback_id != pending_callback_id) {
196 // SignalSyncToken is threadsafe, no need for worker context lock.
197 worker_context_provider_->ContextSupport()->SignalSyncToken(sync_token,
198 callback);
199 }
200
201 return callback_id;
202 }
203
165 void OneCopyRasterBufferProvider::Shutdown() { 204 void OneCopyRasterBufferProvider::Shutdown() {
166 staging_pool_.Shutdown(); 205 staging_pool_.Shutdown();
167 pending_raster_buffers_.clear(); 206 pending_raster_buffers_.clear();
168 } 207 }
169 208
170 void OneCopyRasterBufferProvider::PlaybackAndCopyOnWorkerThread( 209 void OneCopyRasterBufferProvider::PlaybackAndCopyOnWorkerThread(
171 const Resource* resource, 210 const Resource* resource,
172 ResourceProvider::ScopedWriteLockGL* resource_lock, 211 ResourceProvider::ScopedWriteLockGL* resource_lock,
173 const gpu::SyncToken& sync_token, 212 const gpu::SyncToken& sync_token,
174 const RasterSource* raster_source, 213 const RasterSource* raster_source,
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 resource_lock->set_synchronized(!async_worker_context_enabled_); 425 resource_lock->set_synchronized(!async_worker_context_enabled_);
387 } 426 }
388 427
389 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { 428 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const {
390 return use_partial_raster_ 429 return use_partial_raster_
391 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT 430 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT
392 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; 431 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE;
393 } 432 }
394 433
395 } // namespace cc 434 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698