Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 #include "cc/base/histograms.h" | 16 #include "cc/base/histograms.h" |
| 17 #include "cc/base/math_util.h" | 17 #include "cc/base/math_util.h" |
| 18 #include "cc/resources/platform_color.h" | 18 #include "cc/resources/platform_color.h" |
| 19 #include "cc/resources/resource_format.h" | 19 #include "cc/resources/resource_format.h" |
| 20 #include "cc/resources/resource_util.h" | 20 #include "cc/resources/resource_util.h" |
| 21 #include "cc/resources/scoped_resource.h" | 21 #include "cc/resources/scoped_resource.h" |
| 22 #include "gpu/GLES2/gl2extchromium.h" | 22 #include "gpu/GLES2/gl2extchromium.h" |
| 23 #include "gpu/command_buffer/client/context_support.h" | |
| 23 #include "gpu/command_buffer/client/gles2_interface.h" | 24 #include "gpu/command_buffer/client/gles2_interface.h" |
| 24 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" | 25 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" |
| 25 #include "ui/gfx/buffer_format_util.h" | 26 #include "ui/gfx/buffer_format_util.h" |
| 26 | 27 |
| 27 namespace cc { | 28 namespace cc { |
| 28 namespace { | 29 namespace { |
| 29 | 30 |
| 30 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good | 31 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good |
| 31 // default batch size for copy operations. | 32 // default batch size for copy operations. |
| 32 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4; | 33 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); | 155 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); |
| 155 } | 156 } |
| 156 | 157 |
| 157 bool OneCopyRasterBufferProvider::CanPartialRasterIntoProvidedResource() const { | 158 bool OneCopyRasterBufferProvider::CanPartialRasterIntoProvidedResource() const { |
| 158 // While OneCopyRasterBufferProvider has an internal partial raster | 159 // While OneCopyRasterBufferProvider has an internal partial raster |
| 159 // implementation, it cannot directly partial raster into the externally | 160 // implementation, it cannot directly partial raster into the externally |
| 160 // owned resource provided in AcquireBufferForRaster. | 161 // owned resource provided in AcquireBufferForRaster. |
| 161 return false; | 162 return false; |
| 162 } | 163 } |
| 163 | 164 |
| 165 uint64_t OneCopyRasterBufferProvider::SetReadyToDrawCallback( | |
| 166 const ResourceProvider::ResourceIdArray& resource_ids, | |
| 167 const base::Callback<void(uint64_t)>& callback, | |
| 168 uint64_t pending_callback_id) const { | |
| 169 if (!async_worker_context_enabled_) | |
| 170 return 0; | |
| 171 | |
| 172 gpu::SyncToken sync_token = | |
| 173 resource_provider_->GetSyncTokenForResources(resource_ids); | |
| 174 uint64_t callback_id = sync_token.release_count(); | |
| 175 DCHECK_NE(callback_id, 0u); | |
| 176 | |
| 177 if (callback_id != pending_callback_id) { | |
|
vmpstr
2016/12/07 21:00:25
Can you add a comment explaining what's going on h
| |
| 178 compositor_context_provider_->ContextSupport()->SignalSyncToken( | |
| 179 sync_token, base::Bind(callback, callback_id)); | |
| 180 } | |
| 181 | |
| 182 return callback_id; | |
| 183 } | |
| 184 | |
| 164 void OneCopyRasterBufferProvider::Shutdown() { | 185 void OneCopyRasterBufferProvider::Shutdown() { |
| 165 staging_pool_.Shutdown(); | 186 staging_pool_.Shutdown(); |
| 166 pending_raster_buffers_.clear(); | 187 pending_raster_buffers_.clear(); |
| 167 } | 188 } |
| 168 | 189 |
| 169 void OneCopyRasterBufferProvider::PlaybackAndCopyOnWorkerThread( | 190 void OneCopyRasterBufferProvider::PlaybackAndCopyOnWorkerThread( |
| 170 const Resource* resource, | 191 const Resource* resource, |
| 171 ResourceProvider::ScopedWriteLockGL* resource_lock, | 192 ResourceProvider::ScopedWriteLockGL* resource_lock, |
| 172 const gpu::SyncToken& sync_token, | 193 const gpu::SyncToken& sync_token, |
| 173 const RasterSource* raster_source, | 194 const RasterSource* raster_source, |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 385 resource_lock->set_synchronized(!async_worker_context_enabled_); | 406 resource_lock->set_synchronized(!async_worker_context_enabled_); |
| 386 } | 407 } |
| 387 | 408 |
| 388 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { | 409 gfx::BufferUsage OneCopyRasterBufferProvider::StagingBufferUsage() const { |
| 389 return use_partial_raster_ | 410 return use_partial_raster_ |
| 390 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT | 411 ? gfx::BufferUsage::GPU_READ_CPU_READ_WRITE_PERSISTENT |
| 391 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; | 412 : gfx::BufferUsage::GPU_READ_CPU_READ_WRITE; |
| 392 } | 413 } |
| 393 | 414 |
| 394 } // namespace cc | 415 } // namespace cc |
| OLD | NEW |