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

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

Issue 2560253003: Delay Activation/Draw in smoothness mode.
Patch Set: more unit tests Created 4 years 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/gpu_raster_buffer_provider.h ('k') | cc/raster/one_copy_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/gpu_raster_buffer_provider.h" 5 #include "cc/raster/gpu_raster_buffer_provider.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
14 #include "base/trace_event/trace_event.h" 14 #include "base/trace_event/trace_event.h"
15 #include "cc/base/histograms.h" 15 #include "cc/base/histograms.h"
16 #include "cc/playback/image_hijack_canvas.h" 16 #include "cc/playback/image_hijack_canvas.h"
17 #include "cc/playback/raster_source.h" 17 #include "cc/playback/raster_source.h"
18 #include "cc/raster/scoped_gpu_raster.h" 18 #include "cc/raster/scoped_gpu_raster.h"
19 #include "cc/resources/resource.h" 19 #include "cc/resources/resource.h"
20 #include "gpu/command_buffer/client/context_support.h"
20 #include "gpu/command_buffer/client/gles2_interface.h" 21 #include "gpu/command_buffer/client/gles2_interface.h"
21 #include "third_party/skia/include/core/SkMultiPictureDraw.h" 22 #include "third_party/skia/include/core/SkMultiPictureDraw.h"
22 #include "third_party/skia/include/core/SkPictureRecorder.h" 23 #include "third_party/skia/include/core/SkPictureRecorder.h"
23 #include "third_party/skia/include/core/SkSurface.h" 24 #include "third_party/skia/include/core/SkSurface.h"
24 #include "third_party/skia/include/gpu/GrContext.h" 25 #include "third_party/skia/include/gpu/GrContext.h"
25 26
26 namespace cc { 27 namespace cc {
27 namespace { 28 namespace {
28 29
29 static void RasterizeSource( 30 static void RasterizeSource(
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 return false; 180 return false;
180 } 181 }
181 182
182 bool GpuRasterBufferProvider::CanPartialRasterIntoProvidedResource() const { 183 bool GpuRasterBufferProvider::CanPartialRasterIntoProvidedResource() const {
183 // Partial raster doesn't support MSAA, as the MSAA resolve is unaware of clip 184 // Partial raster doesn't support MSAA, as the MSAA resolve is unaware of clip
184 // rects. 185 // rects.
185 // TODO(crbug.com/629683): See if we can work around this limitation. 186 // TODO(crbug.com/629683): See if we can work around this limitation.
186 return msaa_sample_count_ == 0; 187 return msaa_sample_count_ == 0;
187 } 188 }
188 189
190 bool GpuRasterBufferProvider::IsResourceReadyToDraw(
191 ResourceId resource_id) const {
192 if (async_worker_context_enabled_) {
193 gpu::SyncToken sync_token =
194 resource_provider_->GetSyncTokenForResource(resource_id);
195 if (sync_token.HasData()) {
196 return compositor_context_provider_->ContextSupport()
197 ->IsFenceSyncReleased(sync_token.release_count());
198 }
199 }
200 return true;
201 }
202
203 uint64_t GpuRasterBufferProvider::SetReadyToDrawCallback(
204 const ResourceProvider::ResourceIdArray& resource_ids,
205 const base::Callback<void(uint64_t)>& callback,
206 uint64_t pending_callback_id) const {
207 if (!async_worker_context_enabled_)
208 return 0;
209
210 gpu::SyncToken sync_token =
211 resource_provider_->GetSyncTokenForResources(resource_ids);
212 uint64_t callback_id = sync_token.release_count();
213 DCHECK_NE(callback_id, 0u);
214
215 if (callback_id != pending_callback_id) {
216 compositor_context_provider_->ContextSupport()->SignalSyncToken(
217 sync_token, base::Bind(callback, callback_id));
218 }
219
220 return callback_id;
221 }
222
189 void GpuRasterBufferProvider::Shutdown() { 223 void GpuRasterBufferProvider::Shutdown() {
190 pending_raster_buffers_.clear(); 224 pending_raster_buffers_.clear();
191 } 225 }
192 226
193 void GpuRasterBufferProvider::PlaybackOnWorkerThread( 227 void GpuRasterBufferProvider::PlaybackOnWorkerThread(
194 ResourceProvider::ScopedWriteLockGL* resource_lock, 228 ResourceProvider::ScopedWriteLockGL* resource_lock,
195 const gpu::SyncToken& sync_token, 229 const gpu::SyncToken& sync_token,
196 bool resource_has_previous_content, 230 bool resource_has_previous_content,
197 const RasterSource* raster_source, 231 const RasterSource* raster_source,
198 const gfx::Rect& raster_full_rect, 232 const gfx::Rect& raster_full_rect,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 gl->OrderingBarrierCHROMIUM(); 264 gl->OrderingBarrierCHROMIUM();
231 265
232 // Generate sync token after the barrier for cross context synchronization. 266 // Generate sync token after the barrier for cross context synchronization.
233 gpu::SyncToken resource_sync_token; 267 gpu::SyncToken resource_sync_token;
234 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); 268 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData());
235 resource_lock->set_sync_token(resource_sync_token); 269 resource_lock->set_sync_token(resource_sync_token);
236 resource_lock->set_synchronized(!async_worker_context_enabled_); 270 resource_lock->set_synchronized(!async_worker_context_enabled_);
237 } 271 }
238 272
239 } // namespace cc 273 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/gpu_raster_buffer_provider.h ('k') | cc/raster/one_copy_raster_buffer_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698