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

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

Issue 2775723002: Enable RGBA_4444 in GpuRasterBufferProvider (Closed)
Patch Set: comment Created 3 years, 9 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
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/test/layer_tree_pixel_resource_test.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 for (ResourceMap::const_iterator itr = resources_.begin(); 479 for (ResourceMap::const_iterator itr = resources_.begin();
480 itr != resources_.end(); ++itr) { 480 itr != resources_.end(); ++itr) {
481 DCHECK(!IsGpuResourceType(itr->second.type)); 481 DCHECK(!IsGpuResourceType(itr->second.type));
482 } 482 }
483 #endif // DCHECK_IS_ON() 483 #endif // DCHECK_IS_ON()
484 484
485 texture_id_allocator_ = nullptr; 485 texture_id_allocator_ = nullptr;
486 gl->Finish(); 486 gl->Finish();
487 } 487 }
488 488
489 bool ResourceProvider::IsResourceFormatSupported(ResourceFormat format) const { 489 bool ResourceProvider::IsTextureFormatSupported(ResourceFormat format) const {
490 gpu::Capabilities caps; 490 gpu::Capabilities caps;
491 if (compositor_context_provider_) 491 if (compositor_context_provider_)
492 caps = compositor_context_provider_->ContextCapabilities(); 492 caps = compositor_context_provider_->ContextCapabilities();
493 493
494 switch (format) { 494 switch (format) {
495 case ALPHA_8: 495 case ALPHA_8:
496 case RGBA_4444: 496 case RGBA_4444:
497 case RGBA_8888: 497 case RGBA_8888:
498 case RGB_565: 498 case RGB_565:
499 case LUMINANCE_8: 499 case LUMINANCE_8:
500 return true; 500 return true;
501 case BGRA_8888: 501 case BGRA_8888:
502 return caps.texture_format_bgra8888; 502 return caps.texture_format_bgra8888;
503 case ETC1: 503 case ETC1:
504 return caps.texture_format_etc1; 504 return caps.texture_format_etc1;
505 case RED_8: 505 case RED_8:
506 return caps.texture_rg; 506 return caps.texture_rg;
507 case LUMINANCE_F16: 507 case LUMINANCE_F16:
508 case RGBA_F16:
508 return caps.texture_half_float_linear; 509 return caps.texture_half_float_linear;
510 }
511
512 NOTREACHED();
513 return false;
514 }
515
516 bool ResourceProvider::IsRenderBufferFormatSupported(
517 ResourceFormat format) const {
518 gpu::Capabilities caps;
519 if (compositor_context_provider_)
520 caps = compositor_context_provider_->ContextCapabilities();
521
522 switch (format) {
523 case RGBA_4444:
524 case RGBA_8888:
525 case RGB_565:
526 return true;
527 case BGRA_8888:
528 return caps.render_buffer_format_bgra8888;
509 case RGBA_F16: 529 case RGBA_F16:
510 // TODO(ccameron): This will always return false on pixel tests, which 530 // TODO(ccameron): This will always return false on pixel tests, which
511 // makes it un-test-able until we upgrade Mesa. 531 // makes it un-test-able until we upgrade Mesa.
512 // https://crbug.com/687720 532 // https://crbug.com/687720
513 return caps.texture_half_float_linear && 533 return caps.texture_half_float_linear &&
514 caps.color_buffer_half_float_rgba; 534 caps.color_buffer_half_float_rgba;
535 case LUMINANCE_8:
536 case ALPHA_8:
537 case RED_8:
538 case ETC1:
539 case LUMINANCE_F16:
540 // We don't currently render into these formats. If we need to render into
541 // these eventually, we should expand this logic.
542 return false;
515 } 543 }
516 544
517 NOTREACHED(); 545 NOTREACHED();
518 return false; 546 return false;
519 } 547 }
520 548
521 bool ResourceProvider::InUseByConsumer(ResourceId id) { 549 bool ResourceProvider::InUseByConsumer(ResourceId id) {
522 Resource* resource = GetResource(id); 550 Resource* resource = GetResource(id);
523 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || 551 return resource->lock_for_read_count > 0 || resource->exported_count > 0 ||
524 resource->lost; 552 resource->lost;
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 2170
2143 const int kImportance = 2; 2171 const int kImportance = 2;
2144 pmd->CreateSharedGlobalAllocatorDump(guid); 2172 pmd->CreateSharedGlobalAllocatorDump(guid);
2145 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2173 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2146 } 2174 }
2147 2175
2148 return true; 2176 return true;
2149 } 2177 }
2150 2178
2151 } // namespace cc 2179 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_provider.h ('k') | cc/test/layer_tree_pixel_resource_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698