| 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_tile_task_worker_pool.h" | 5 #include "cc/raster/one_copy_tile_task_worker_pool.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> |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); | 62 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good | 65 // 4MiB is the size of 4 512x512 tiles, which has proven to be a good |
| 66 // default batch size for copy operations. | 66 // default batch size for copy operations. |
| 67 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4; | 67 const int kMaxBytesPerCopyOperation = 1024 * 1024 * 4; |
| 68 | 68 |
| 69 } // namespace | 69 } // namespace |
| 70 | 70 |
| 71 // static | 71 // static |
| 72 scoped_ptr<TileTaskWorkerPool> OneCopyTileTaskWorkerPool::Create( | 72 std::unique_ptr<TileTaskWorkerPool> OneCopyTileTaskWorkerPool::Create( |
| 73 base::SequencedTaskRunner* task_runner, | 73 base::SequencedTaskRunner* task_runner, |
| 74 TaskGraphRunner* task_graph_runner, | 74 TaskGraphRunner* task_graph_runner, |
| 75 ContextProvider* context_provider, | 75 ContextProvider* context_provider, |
| 76 ResourceProvider* resource_provider, | 76 ResourceProvider* resource_provider, |
| 77 int max_copy_texture_chromium_size, | 77 int max_copy_texture_chromium_size, |
| 78 bool use_partial_raster, | 78 bool use_partial_raster, |
| 79 int max_staging_buffer_usage_in_bytes, | 79 int max_staging_buffer_usage_in_bytes, |
| 80 ResourceFormat preferred_tile_format) { | 80 ResourceFormat preferred_tile_format) { |
| 81 return make_scoped_ptr<TileTaskWorkerPool>(new OneCopyTileTaskWorkerPool( | 81 return base::WrapUnique<TileTaskWorkerPool>(new OneCopyTileTaskWorkerPool( |
| 82 task_runner, task_graph_runner, resource_provider, | 82 task_runner, task_graph_runner, resource_provider, |
| 83 max_copy_texture_chromium_size, use_partial_raster, | 83 max_copy_texture_chromium_size, use_partial_raster, |
| 84 max_staging_buffer_usage_in_bytes, preferred_tile_format)); | 84 max_staging_buffer_usage_in_bytes, preferred_tile_format)); |
| 85 } | 85 } |
| 86 | 86 |
| 87 OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool( | 87 OneCopyTileTaskWorkerPool::OneCopyTileTaskWorkerPool( |
| 88 base::SequencedTaskRunner* task_runner, | 88 base::SequencedTaskRunner* task_runner, |
| 89 TaskGraphRunner* task_graph_runner, | 89 TaskGraphRunner* task_graph_runner, |
| 90 ResourceProvider* resource_provider, | 90 ResourceProvider* resource_provider, |
| 91 int max_copy_texture_chromium_size, | 91 int max_copy_texture_chromium_size, |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 return resource_provider_->best_texture_format(); | 167 return resource_provider_->best_texture_format(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle( | 170 bool OneCopyTileTaskWorkerPool::GetResourceRequiresSwizzle( |
| 171 bool must_support_alpha) const { | 171 bool must_support_alpha) const { |
| 172 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); | 172 return ResourceFormatRequiresSwizzle(GetResourceFormat(must_support_alpha)); |
| 173 } | 173 } |
| 174 | 174 |
| 175 scoped_ptr<RasterBuffer> OneCopyTileTaskWorkerPool::AcquireBufferForRaster( | 175 std::unique_ptr<RasterBuffer> OneCopyTileTaskWorkerPool::AcquireBufferForRaster( |
| 176 const Resource* resource, | 176 const Resource* resource, |
| 177 uint64_t resource_content_id, | 177 uint64_t resource_content_id, |
| 178 uint64_t previous_content_id) { | 178 uint64_t previous_content_id) { |
| 179 // TODO(danakj): If resource_content_id != 0, we only need to copy/upload | 179 // TODO(danakj): If resource_content_id != 0, we only need to copy/upload |
| 180 // the dirty rect. | 180 // the dirty rect. |
| 181 return make_scoped_ptr<RasterBuffer>( | 181 return base::WrapUnique<RasterBuffer>( |
| 182 new RasterBufferImpl(this, resource_provider_, resource->format(), | 182 new RasterBufferImpl(this, resource_provider_, resource->format(), |
| 183 resource, previous_content_id)); | 183 resource, previous_content_id)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void OneCopyTileTaskWorkerPool::ReleaseBufferForRaster( | 186 void OneCopyTileTaskWorkerPool::ReleaseBufferForRaster( |
| 187 scoped_ptr<RasterBuffer> buffer) { | 187 std::unique_ptr<RasterBuffer> buffer) { |
| 188 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. | 188 // Nothing to do here. RasterBufferImpl destructor cleans up after itself. |
| 189 } | 189 } |
| 190 | 190 |
| 191 void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread( | 191 void OneCopyTileTaskWorkerPool::PlaybackAndCopyOnWorkerThread( |
| 192 const Resource* resource, | 192 const Resource* resource, |
| 193 ResourceProvider::ScopedWriteLockGL* resource_lock, | 193 ResourceProvider::ScopedWriteLockGL* resource_lock, |
| 194 const RasterSource* raster_source, | 194 const RasterSource* raster_source, |
| 195 const gfx::Rect& raster_full_rect, | 195 const gfx::Rect& raster_full_rect, |
| 196 const gfx::Rect& raster_dirty_rect, | 196 const gfx::Rect& raster_dirty_rect, |
| 197 float scale, | 197 float scale, |
| 198 const RasterSource::PlaybackSettings& playback_settings, | 198 const RasterSource::PlaybackSettings& playback_settings, |
| 199 uint64_t previous_content_id, | 199 uint64_t previous_content_id, |
| 200 uint64_t new_content_id) { | 200 uint64_t new_content_id) { |
| 201 scoped_ptr<StagingBuffer> staging_buffer = | 201 std::unique_ptr<StagingBuffer> staging_buffer = |
| 202 staging_pool_->AcquireStagingBuffer(resource, previous_content_id); | 202 staging_pool_->AcquireStagingBuffer(resource, previous_content_id); |
| 203 | 203 |
| 204 PlaybackToStagingBuffer(staging_buffer.get(), resource, raster_source, | 204 PlaybackToStagingBuffer(staging_buffer.get(), resource, raster_source, |
| 205 raster_full_rect, raster_dirty_rect, scale, | 205 raster_full_rect, raster_dirty_rect, scale, |
| 206 playback_settings, previous_content_id, | 206 playback_settings, previous_content_id, |
| 207 new_content_id); | 207 new_content_id); |
| 208 | 208 |
| 209 CopyOnWorkerThread(staging_buffer.get(), resource, resource_lock, | 209 CopyOnWorkerThread(staging_buffer.get(), resource, resource_lock, |
| 210 raster_source, previous_content_id, new_content_id); | 210 raster_source, previous_content_id, new_content_id); |
| 211 | 211 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 gl->OrderingBarrierCHROMIUM(); | 376 gl->OrderingBarrierCHROMIUM(); |
| 377 | 377 |
| 378 // Generate sync token after the barrier for cross context synchronization. | 378 // Generate sync token after the barrier for cross context synchronization. |
| 379 gpu::SyncToken sync_token; | 379 gpu::SyncToken sync_token; |
| 380 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); | 380 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, sync_token.GetData()); |
| 381 resource_lock->UpdateResourceSyncToken(sync_token); | 381 resource_lock->UpdateResourceSyncToken(sync_token); |
| 382 } | 382 } |
| 383 } | 383 } |
| 384 | 384 |
| 385 } // namespace cc | 385 } // namespace cc |
| OLD | NEW |