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

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

Issue 1379783002: Allow one-copy task tile worker pool to use compressed textures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove needs_conversion, fix tile size unit test and move modulo 4 DCHECK (for tests) Created 5 years 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 <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/atomic_sequence_num.h" 10 #include "base/atomic_sequence_num.h"
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 itr != resources_.end(); ++itr) { 361 itr != resources_.end(); ++itr) {
362 DCHECK(!IsGpuResourceType(itr->second.type)); 362 DCHECK(!IsGpuResourceType(itr->second.type));
363 } 363 }
364 #endif // DCHECK_IS_ON() 364 #endif // DCHECK_IS_ON()
365 365
366 texture_id_allocator_ = nullptr; 366 texture_id_allocator_ = nullptr;
367 buffer_id_allocator_ = nullptr; 367 buffer_id_allocator_ = nullptr;
368 gl->Finish(); 368 gl->Finish();
369 } 369 }
370 370
371 bool ResourceProvider::IsResourceFormatSupported(ResourceFormat format) const {
372 const ContextProvider::Capabilities& caps =
373 output_surface_->context_provider()->ContextCapabilities();
374
375 switch (format) {
376 case ALPHA_8:
377 case RGBA_4444:
378 case RGBA_8888:
379 case RGB_565:
380 case LUMINANCE_8:
381 return true;
382 case BGRA_8888:
383 return caps.gpu.texture_format_bgra8888;
384 case ETC1:
385 return caps.gpu.texture_format_etc1;
386 case RED_8:
387 return caps.gpu.texture_rg;
388 }
389
390 NOTREACHED();
391 return false;
392 }
393
371 bool ResourceProvider::InUseByConsumer(ResourceId id) { 394 bool ResourceProvider::InUseByConsumer(ResourceId id) {
372 Resource* resource = GetResource(id); 395 Resource* resource = GetResource(id);
373 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || 396 return resource->lock_for_read_count > 0 || resource->exported_count > 0 ||
374 resource->lost; 397 resource->lost;
375 } 398 }
376 399
377 bool ResourceProvider::IsLost(ResourceId id) { 400 bool ResourceProvider::IsLost(ResourceId id) {
378 Resource* resource = GetResource(id); 401 Resource* resource = GetResource(id);
379 return resource->lost; 402 return resource->lost;
380 } 403 }
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 use_texture_storage_ext_ = caps.gpu.texture_storage; 1083 use_texture_storage_ext_ = caps.gpu.texture_storage;
1061 use_texture_format_bgra_ = caps.gpu.texture_format_bgra8888; 1084 use_texture_format_bgra_ = caps.gpu.texture_format_bgra8888;
1062 use_texture_usage_hint_ = caps.gpu.texture_usage; 1085 use_texture_usage_hint_ = caps.gpu.texture_usage;
1063 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1; 1086 use_compressed_texture_etc1_ = caps.gpu.texture_format_etc1;
1064 yuv_resource_format_ = caps.gpu.texture_rg ? RED_8 : LUMINANCE_8; 1087 yuv_resource_format_ = caps.gpu.texture_rg ? RED_8 : LUMINANCE_8;
1065 use_sync_query_ = caps.gpu.sync_query; 1088 use_sync_query_ = caps.gpu.sync_query;
1066 1089
1067 max_texture_size_ = 0; // Context expects cleared value. 1090 max_texture_size_ = 0; // Context expects cleared value.
1068 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); 1091 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_);
1069 best_texture_format_ = 1092 best_texture_format_ =
1070 PlatformColor::BestTextureFormat(use_texture_format_bgra_); 1093 PlatformColor::BestSupportedTextureFormat(use_texture_format_bgra_);
1071 1094
1072 best_render_buffer_format_ = 1095 best_render_buffer_format_ = PlatformColor::BestSupportedTextureFormat(
1073 PlatformColor::BestTextureFormat(caps.gpu.render_buffer_format_bgra8888); 1096 caps.gpu.render_buffer_format_bgra8888);
1074 1097
1075 texture_id_allocator_.reset( 1098 texture_id_allocator_.reset(
1076 new TextureIdAllocator(gl, id_allocation_chunk_size_)); 1099 new TextureIdAllocator(gl, id_allocation_chunk_size_));
1077 buffer_id_allocator_.reset( 1100 buffer_id_allocator_.reset(
1078 new BufferIdAllocator(gl, id_allocation_chunk_size_)); 1101 new BufferIdAllocator(gl, id_allocation_chunk_size_));
1079 } 1102 }
1080 1103
1081 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) { 1104 int ResourceProvider::CreateChild(const ReturnCallback& return_callback) {
1082 DCHECK(thread_checker_.CalledOnValidThread()); 1105 DCHECK(thread_checker_.CalledOnValidThread());
1083 1106
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 const int kImportance = 2; 1684 const int kImportance = 2;
1662 pmd->CreateSharedGlobalAllocatorDump(guid); 1685 pmd->CreateSharedGlobalAllocatorDump(guid);
1663 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 1686 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
1664 } 1687 }
1665 } 1688 }
1666 1689
1667 return true; 1690 return true;
1668 } 1691 }
1669 1692
1670 } // namespace cc 1693 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698