| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/resources/resource_provider.h" | 5 #include "cc/resources/resource_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 DCHECK(!IsGpuResourceType(itr->second.type)); | 422 DCHECK(!IsGpuResourceType(itr->second.type)); |
| 423 } | 423 } |
| 424 #endif // DCHECK_IS_ON() | 424 #endif // DCHECK_IS_ON() |
| 425 | 425 |
| 426 texture_id_allocator_ = nullptr; | 426 texture_id_allocator_ = nullptr; |
| 427 buffer_id_allocator_ = nullptr; | 427 buffer_id_allocator_ = nullptr; |
| 428 gl->Finish(); | 428 gl->Finish(); |
| 429 } | 429 } |
| 430 | 430 |
| 431 bool ResourceProvider::IsResourceFormatSupported(ResourceFormat format) const { | 431 bool ResourceProvider::IsResourceFormatSupported(ResourceFormat format) const { |
| 432 ContextProvider::Capabilities caps; | 432 gpu::Capabilities caps; |
| 433 if (output_surface_->context_provider()) | 433 if (output_surface_->context_provider()) |
| 434 caps = output_surface_->context_provider()->ContextCapabilities(); | 434 caps = output_surface_->context_provider()->ContextCapabilities(); |
| 435 | 435 |
| 436 switch (format) { | 436 switch (format) { |
| 437 case ALPHA_8: | 437 case ALPHA_8: |
| 438 case RGBA_4444: | 438 case RGBA_4444: |
| 439 case RGBA_8888: | 439 case RGBA_8888: |
| 440 case RGB_565: | 440 case RGB_565: |
| 441 case LUMINANCE_8: | 441 case LUMINANCE_8: |
| 442 return true; | 442 return true; |
| 443 case BGRA_8888: | 443 case BGRA_8888: |
| 444 return caps.gpu.texture_format_bgra8888; | 444 return caps.texture_format_bgra8888; |
| 445 case ETC1: | 445 case ETC1: |
| 446 return caps.gpu.texture_format_etc1; | 446 return caps.texture_format_etc1; |
| 447 case RED_8: | 447 case RED_8: |
| 448 return caps.gpu.texture_rg; | 448 return caps.texture_rg; |
| 449 case LUMINANCE_F16: | 449 case LUMINANCE_F16: |
| 450 return caps.gpu.texture_half_float_linear; | 450 return caps.texture_half_float_linear; |
| 451 } | 451 } |
| 452 | 452 |
| 453 NOTREACHED(); | 453 NOTREACHED(); |
| 454 return false; | 454 return false; |
| 455 } | 455 } |
| 456 | 456 |
| 457 bool ResourceProvider::InUseByConsumer(ResourceId id) { | 457 bool ResourceProvider::InUseByConsumer(ResourceId id) { |
| 458 Resource* resource = GetResource(id); | 458 Resource* resource = GetResource(id); |
| 459 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || | 459 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || |
| 460 resource->lost || | 460 resource->lost || |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1226 default_resource_type_ = RESOURCE_TYPE_BITMAP; | 1226 default_resource_type_ = RESOURCE_TYPE_BITMAP; |
| 1227 // Pick an arbitrary limit here similar to what hardware might. | 1227 // Pick an arbitrary limit here similar to what hardware might. |
| 1228 max_texture_size_ = 16 * 1024; | 1228 max_texture_size_ = 16 * 1024; |
| 1229 best_texture_format_ = RGBA_8888; | 1229 best_texture_format_ = RGBA_8888; |
| 1230 return; | 1230 return; |
| 1231 } | 1231 } |
| 1232 | 1232 |
| 1233 DCHECK(!texture_id_allocator_); | 1233 DCHECK(!texture_id_allocator_); |
| 1234 DCHECK(!buffer_id_allocator_); | 1234 DCHECK(!buffer_id_allocator_); |
| 1235 | 1235 |
| 1236 const ContextProvider::Capabilities& caps = | 1236 const gpu::Capabilities& caps = |
| 1237 output_surface_->context_provider()->ContextCapabilities(); | 1237 output_surface_->context_provider()->ContextCapabilities(); |
| 1238 | 1238 |
| 1239 DCHECK(IsGpuResourceType(default_resource_type_)); | 1239 DCHECK(IsGpuResourceType(default_resource_type_)); |
| 1240 use_texture_storage_ext_ = caps.gpu.texture_storage; | 1240 use_texture_storage_ext_ = caps.texture_storage; |
| 1241 use_texture_format_bgra_ = caps.gpu.texture_format_bgra8888; | 1241 use_texture_format_bgra_ = caps.texture_format_bgra8888; |
| 1242 use_texture_usage_hint_ = caps.gpu.texture_usage; | 1242 use_texture_usage_hint_ = caps.texture_usage; |
| 1243 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; | 1243 use_compressed_texture_etc1_ = caps.texture_format_etc1; |
| 1244 yuv_resource_format_ = caps.gpu.texture_rg ? RED_8 : LUMINANCE_8; | 1244 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; |
| 1245 yuv_highbit_resource_format_ = yuv_resource_format_; | 1245 yuv_highbit_resource_format_ = yuv_resource_format_; |
| 1246 if (caps.gpu.texture_half_float_linear) | 1246 if (caps.texture_half_float_linear) |
| 1247 yuv_highbit_resource_format_ = LUMINANCE_F16; | 1247 yuv_highbit_resource_format_ = LUMINANCE_F16; |
| 1248 use_sync_query_ = caps.gpu.sync_query; | 1248 use_sync_query_ = caps.sync_query; |
| 1249 | 1249 |
| 1250 max_texture_size_ = 0; // Context expects cleared value. | 1250 max_texture_size_ = 0; // Context expects cleared value. |
| 1251 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); | 1251 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); |
| 1252 best_texture_format_ = | 1252 best_texture_format_ = |
| 1253 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); | 1253 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); |
| 1254 | 1254 |
| 1255 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( | 1255 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( |
| 1256 caps.gpu.render_buffer_format_bgra8888); | 1256 caps.render_buffer_format_bgra8888); |
| 1257 | 1257 |
| 1258 texture_id_allocator_.reset( | 1258 texture_id_allocator_.reset( |
| 1259 new TextureIdAllocator(gl, id_allocation_chunk_size_)); | 1259 new TextureIdAllocator(gl, id_allocation_chunk_size_)); |
| 1260 buffer_id_allocator_.reset( | 1260 buffer_id_allocator_.reset( |
| 1261 new BufferIdAllocator(gl, id_allocation_chunk_size_)); | 1261 new BufferIdAllocator(gl, id_allocation_chunk_size_)); |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { | 1264 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { |
| 1265 DCHECK(thread_checker_.CalledOnValidThread()); | 1265 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1266 | 1266 |
| (...skipping 688 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1955 | 1955 |
| 1956 const int kImportance = 2; | 1956 const int kImportance = 2; |
| 1957 pmd->CreateSharedGlobalAllocatorDump(guid); | 1957 pmd->CreateSharedGlobalAllocatorDump(guid); |
| 1958 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); | 1958 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); |
| 1959 } | 1959 } |
| 1960 | 1960 |
| 1961 return true; | 1961 return true; |
| 1962 } | 1962 } |
| 1963 | 1963 |
| 1964 } // namespace cc | 1964 } // namespace cc |
| OLD | NEW |