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

Side by Side Diff: cc/resources/resource_provider.cc

Issue 1900993002: Move SharedMemoryLimits out of WebGraphicsContext3DCommandBufferImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@limits
Patch Set: move-limits: . Created 4 years, 8 months 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
OLDNEW
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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 DCHECK(!IsGpuResourceType(itr->second.type)); 425 DCHECK(!IsGpuResourceType(itr->second.type));
426 } 426 }
427 #endif // DCHECK_IS_ON() 427 #endif // DCHECK_IS_ON()
428 428
429 texture_id_allocator_ = nullptr; 429 texture_id_allocator_ = nullptr;
430 buffer_id_allocator_ = nullptr; 430 buffer_id_allocator_ = nullptr;
431 gl->Finish(); 431 gl->Finish();
432 } 432 }
433 433
434 bool ResourceProvider::IsResourceFormatSupported(ResourceFormat format) const { 434 bool ResourceProvider::IsResourceFormatSupported(ResourceFormat format) const {
435 ContextProvider::Capabilities caps; 435 gpu::Capabilities caps;
436 if (output_surface_->context_provider()) 436 if (output_surface_->context_provider())
437 caps = output_surface_->context_provider()->ContextCapabilities(); 437 caps = output_surface_->context_provider()->ContextCapabilities();
438 438
439 switch (format) { 439 switch (format) {
440 case ALPHA_8: 440 case ALPHA_8:
441 case RGBA_4444: 441 case RGBA_4444:
442 case RGBA_8888: 442 case RGBA_8888:
443 case RGB_565: 443 case RGB_565:
444 case LUMINANCE_8: 444 case LUMINANCE_8:
445 return true; 445 return true;
446 case BGRA_8888: 446 case BGRA_8888:
447 return caps.gpu.texture_format_bgra8888; 447 return caps.texture_format_bgra8888;
448 case ETC1: 448 case ETC1:
449 return caps.gpu.texture_format_etc1; 449 return caps.texture_format_etc1;
450 case RED_8: 450 case RED_8:
451 return caps.gpu.texture_rg; 451 return caps.texture_rg;
452 case LUMINANCE_F16: 452 case LUMINANCE_F16:
453 return caps.gpu.texture_half_float_linear; 453 return caps.texture_half_float_linear;
454 } 454 }
455 455
456 NOTREACHED(); 456 NOTREACHED();
457 return false; 457 return false;
458 } 458 }
459 459
460 bool ResourceProvider::InUseByConsumer(ResourceId id) { 460 bool ResourceProvider::InUseByConsumer(ResourceId id) {
461 Resource* resource = GetResource(id); 461 Resource* resource = GetResource(id);
462 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || 462 return resource->lock_for_read_count > 0 || resource->exported_count > 0 ||
463 resource->lost || 463 resource->lost ||
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 default_resource_type_ = RESOURCE_TYPE_BITMAP; 1230 default_resource_type_ = RESOURCE_TYPE_BITMAP;
1231 // Pick an arbitrary limit here similar to what hardware might. 1231 // Pick an arbitrary limit here similar to what hardware might.
1232 max_texture_size_ = 16 * 1024; 1232 max_texture_size_ = 16 * 1024;
1233 best_texture_format_ = RGBA_8888; 1233 best_texture_format_ = RGBA_8888;
1234 return; 1234 return;
1235 } 1235 }
1236 1236
1237 DCHECK(!texture_id_allocator_); 1237 DCHECK(!texture_id_allocator_);
1238 DCHECK(!buffer_id_allocator_); 1238 DCHECK(!buffer_id_allocator_);
1239 1239
1240 const ContextProvider::Capabilities& caps = 1240 const gpu::Capabilities& caps =
1241 output_surface_->context_provider()->ContextCapabilities(); 1241 output_surface_->context_provider()->ContextCapabilities();
1242 1242
1243 DCHECK(IsGpuResourceType(default_resource_type_)); 1243 DCHECK(IsGpuResourceType(default_resource_type_));
1244 use_texture_storage_ext_ = caps.gpu.texture_storage; 1244 use_texture_storage_ext_ = caps.texture_storage;
1245 use_texture_format_bgra_ = caps.gpu.texture_format_bgra8888; 1245 use_texture_format_bgra_ = caps.texture_format_bgra8888;
1246 use_texture_usage_hint_ = caps.gpu.texture_usage; 1246 use_texture_usage_hint_ = caps.texture_usage;
1247 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; 1247 use_compressed_texture_etc1_ = caps.texture_format_etc1;
1248 yuv_resource_format_ = caps.gpu.texture_rg ? RED_8 : LUMINANCE_8; 1248 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8;
1249 yuv_highbit_resource_format_ = yuv_resource_format_; 1249 yuv_highbit_resource_format_ = yuv_resource_format_;
1250 if (caps.gpu.texture_half_float_linear) 1250 if (caps.texture_half_float_linear)
1251 yuv_highbit_resource_format_ = LUMINANCE_F16; 1251 yuv_highbit_resource_format_ = LUMINANCE_F16;
1252 use_sync_query_ = caps.gpu.sync_query; 1252 use_sync_query_ = caps.sync_query;
1253 1253
1254 max_texture_size_ = 0; // Context expects cleared value. 1254 max_texture_size_ = 0; // Context expects cleared value.
1255 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); 1255 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_);
1256 best_texture_format_ = 1256 best_texture_format_ =
1257 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_); 1257 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_);
1258 1258
1259 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat( 1259 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat(
1260 caps.gpu.render_buffer_format_bgra8888); 1260 caps.render_buffer_format_bgra8888);
1261 1261
1262 texture_id_allocator_.reset( 1262 texture_id_allocator_.reset(
1263 new TextureIdAllocator(gl, id_allocation_chunk_size_)); 1263 new TextureIdAllocator(gl, id_allocation_chunk_size_));
1264 buffer_id_allocator_.reset( 1264 buffer_id_allocator_.reset(
1265 new BufferIdAllocator(gl, id_allocation_chunk_size_)); 1265 new BufferIdAllocator(gl, id_allocation_chunk_size_));
1266 } 1266 }
1267 1267
1268 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { 1268 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) {
1269 DCHECK(thread_checker_.CalledOnValidThread()); 1269 DCHECK(thread_checker_.CalledOnValidThread());
1270 1270
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after
1961 1961
1962 const int kImportance = 2; 1962 const int kImportance = 2;
1963 pmd->CreateSharedGlobalAllocatorDump(guid); 1963 pmd->CreateSharedGlobalAllocatorDump(guid);
1964 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 1964 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
1965 } 1965 }
1966 1966
1967 return true; 1967 return true;
1968 } 1968 }
1969 1969
1970 } // namespace cc 1970 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698