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/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 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 raster_full_rect, raster_dirty_rect, | 113 raster_full_rect, raster_dirty_rect, |
| 114 new_content_id, scale, playback_settings); | 114 new_content_id, scale, playback_settings); |
| 115 } | 115 } |
| 116 | 116 |
| 117 GpuRasterBufferProvider::GpuRasterBufferProvider( | 117 GpuRasterBufferProvider::GpuRasterBufferProvider( |
| 118 ContextProvider* compositor_context_provider, | 118 ContextProvider* compositor_context_provider, |
| 119 ContextProvider* worker_context_provider, | 119 ContextProvider* worker_context_provider, |
| 120 ResourceProvider* resource_provider, | 120 ResourceProvider* resource_provider, |
| 121 bool use_distance_field_text, | 121 bool use_distance_field_text, |
| 122 int gpu_rasterization_msaa_sample_count, | 122 int gpu_rasterization_msaa_sample_count, |
| 123 ResourceFormat preferred_tile_format, | |
| 123 bool async_worker_context_enabled) | 124 bool async_worker_context_enabled) |
| 124 : compositor_context_provider_(compositor_context_provider), | 125 : compositor_context_provider_(compositor_context_provider), |
| 125 worker_context_provider_(worker_context_provider), | 126 worker_context_provider_(worker_context_provider), |
| 126 resource_provider_(resource_provider), | 127 resource_provider_(resource_provider), |
| 127 use_distance_field_text_(use_distance_field_text), | 128 use_distance_field_text_(use_distance_field_text), |
| 128 msaa_sample_count_(gpu_rasterization_msaa_sample_count), | 129 msaa_sample_count_(gpu_rasterization_msaa_sample_count), |
| 130 preferred_tile_format_(preferred_tile_format), | |
| 129 async_worker_context_enabled_(async_worker_context_enabled) { | 131 async_worker_context_enabled_(async_worker_context_enabled) { |
| 130 DCHECK(compositor_context_provider); | 132 DCHECK(compositor_context_provider); |
| 131 DCHECK(worker_context_provider); | 133 DCHECK(worker_context_provider); |
| 132 } | 134 } |
| 133 | 135 |
| 134 GpuRasterBufferProvider::~GpuRasterBufferProvider() { | 136 GpuRasterBufferProvider::~GpuRasterBufferProvider() { |
| 135 DCHECK(pending_raster_buffers_.empty()); | 137 DCHECK(pending_raster_buffers_.empty()); |
| 136 } | 138 } |
| 137 | 139 |
| 138 std::unique_ptr<RasterBuffer> GpuRasterBufferProvider::AcquireBufferForRaster( | 140 std::unique_ptr<RasterBuffer> GpuRasterBufferProvider::AcquireBufferForRaster( |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 167 | 169 |
| 168 for (RasterBufferImpl* buffer : pending_raster_buffers_) | 170 for (RasterBufferImpl* buffer : pending_raster_buffers_) |
| 169 buffer->set_sync_token(sync_token); | 171 buffer->set_sync_token(sync_token); |
| 170 } else { | 172 } else { |
| 171 gl->OrderingBarrierCHROMIUM(); | 173 gl->OrderingBarrierCHROMIUM(); |
| 172 } | 174 } |
| 173 pending_raster_buffers_.clear(); | 175 pending_raster_buffers_.clear(); |
| 174 } | 176 } |
| 175 | 177 |
| 176 ResourceFormat GpuRasterBufferProvider::GetResourceFormat( | 178 ResourceFormat GpuRasterBufferProvider::GetResourceFormat( |
| 177 bool must_support_alpha) const { | 179 bool must_support_alpha) const { |
|
ccameron
2017/03/23 22:20:14
It feels wrong that we now have 3 copy-paste insta
ericrk
2017/03/24 01:46:32
I think I'd prefer to keep the base pure virtual.
| |
| 180 if (resource_provider_->IsRenderBufferFormatSupported( | |
| 181 preferred_tile_format_) && | |
| 182 (DoesResourceFormatSupportAlpha(preferred_tile_format_) || | |
| 183 !must_support_alpha)) { | |
| 184 return preferred_tile_format_; | |
| 185 } | |
| 186 | |
| 178 return resource_provider_->best_render_buffer_format(); | 187 return resource_provider_->best_render_buffer_format(); |
| 179 } | 188 } |
| 180 | 189 |
| 181 bool GpuRasterBufferProvider::IsResourceSwizzleRequired( | 190 bool GpuRasterBufferProvider::IsResourceSwizzleRequired( |
| 182 bool must_support_alpha) const { | 191 bool must_support_alpha) const { |
| 183 // This doesn't require a swizzle because we rasterize to the correct format. | 192 // This doesn't require a swizzle because we rasterize to the correct format. |
| 184 return false; | 193 return false; |
| 185 } | 194 } |
| 186 | 195 |
| 187 bool GpuRasterBufferProvider::CanPartialRasterIntoProvidedResource() const { | 196 bool GpuRasterBufferProvider::CanPartialRasterIntoProvidedResource() const { |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 gl->OrderingBarrierCHROMIUM(); | 279 gl->OrderingBarrierCHROMIUM(); |
| 271 | 280 |
| 272 // Generate sync token after the barrier for cross context synchronization. | 281 // Generate sync token after the barrier for cross context synchronization. |
| 273 gpu::SyncToken resource_sync_token; | 282 gpu::SyncToken resource_sync_token; |
| 274 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); | 283 gl->GenUnverifiedSyncTokenCHROMIUM(fence_sync, resource_sync_token.GetData()); |
| 275 resource_lock->set_sync_token(resource_sync_token); | 284 resource_lock->set_sync_token(resource_sync_token); |
| 276 resource_lock->set_synchronized(!async_worker_context_enabled_); | 285 resource_lock->set_synchronized(!async_worker_context_enabled_); |
| 277 } | 286 } |
| 278 | 287 |
| 279 } // namespace cc | 288 } // namespace cc |
| OLD | NEW |