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

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

Issue 2121043002: 16 bpp video stream capture, render and WebGL usage - Realsense R200 & SR300 support. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WebGL video to texture support and readPixels from R16UI for CPU access Created 4 years, 4 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 case BGRA_8888: 84 case BGRA_8888:
85 storage_format = GL_BGRA8_EXT; 85 storage_format = GL_BGRA8_EXT;
86 break; 86 break;
87 case RGBA_4444: 87 case RGBA_4444:
88 case ALPHA_8: 88 case ALPHA_8:
89 case LUMINANCE_8: 89 case LUMINANCE_8:
90 case RGB_565: 90 case RGB_565:
91 case ETC1: 91 case ETC1:
92 case RED_8: 92 case RED_8:
93 case LUMINANCE_F16: 93 case LUMINANCE_F16:
94 case RG_88:
94 NOTREACHED(); 95 NOTREACHED();
95 break; 96 break;
96 } 97 }
97 98
98 return storage_format; 99 return storage_format;
99 } 100 }
100 101
101 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) { 102 bool IsFormatSupportedForStorage(ResourceFormat format, bool use_bgra) {
102 switch (format) { 103 switch (format) {
103 case RGBA_8888: 104 case RGBA_8888:
104 return true; 105 return true;
105 case BGRA_8888: 106 case BGRA_8888:
106 return use_bgra; 107 return use_bgra;
107 case RGBA_4444: 108 case RGBA_4444:
108 case ALPHA_8: 109 case ALPHA_8:
109 case LUMINANCE_8: 110 case LUMINANCE_8:
110 case RGB_565: 111 case RGB_565:
111 case ETC1: 112 case ETC1:
112 case RED_8: 113 case RED_8:
113 case LUMINANCE_F16: 114 case LUMINANCE_F16:
115 case RG_88:
114 return false; 116 return false;
115 } 117 }
116 return false; 118 return false;
117 } 119 }
118 120
119 GrPixelConfig ToGrPixelConfig(ResourceFormat format) { 121 GrPixelConfig ToGrPixelConfig(ResourceFormat format) {
120 switch (format) { 122 switch (format) {
121 case RGBA_8888: 123 case RGBA_8888:
122 return kRGBA_8888_GrPixelConfig; 124 return kRGBA_8888_GrPixelConfig;
123 case BGRA_8888: 125 case BGRA_8888:
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 DCHECK(!buffer_id_allocator_); 440 DCHECK(!buffer_id_allocator_);
439 441
440 const auto& caps = compositor_context_provider_->ContextCapabilities(); 442 const auto& caps = compositor_context_provider_->ContextCapabilities();
441 443
442 DCHECK(IsGpuResourceType(default_resource_type_)); 444 DCHECK(IsGpuResourceType(default_resource_type_));
443 use_texture_storage_ext_ = caps.texture_storage; 445 use_texture_storage_ext_ = caps.texture_storage;
444 use_texture_format_bgra_ = caps.texture_format_bgra8888; 446 use_texture_format_bgra_ = caps.texture_format_bgra8888;
445 use_texture_usage_hint_ = caps.texture_usage; 447 use_texture_usage_hint_ = caps.texture_usage;
446 use_compressed_texture_etc1_ = caps.texture_format_etc1; 448 use_compressed_texture_etc1_ = caps.texture_format_etc1;
447 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; 449 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8;
450 y16_resource_format_ = caps.texture_rg ? RG_88 : LUMINANCE_8;
451 // TODO(astojilj): Temporary code for performance and power consumption
452 // measurement.
453 // Uncomment following lines to use F16 for Y16.
454 // y16_resource_format_ = caps.texture_half_float_linear ? LUMINANCE_F16 :
455 // LUMINANCE_8;
Ken Russell (switch to Gerrit) 2016/08/16 00:22:26 Does this really use a luminance texture containin
aleksandar.stojiljkovic 2016/08/16 12:02:31 It doesn't. I just reused YUV path for the prototy
aleksandar.stojiljkovic 2016/09/20 12:22:54 If software planes (shared memory) are used, the c
448 yuv_highbit_resource_format_ = yuv_resource_format_; 456 yuv_highbit_resource_format_ = yuv_resource_format_;
449 if (caps.texture_half_float_linear) 457 if (caps.texture_half_float_linear)
450 yuv_highbit_resource_format_ = LUMINANCE_F16; 458 yuv_highbit_resource_format_ = LUMINANCE_F16;
451 use_sync_query_ = caps.sync_query; 459 use_sync_query_ = caps.sync_query;
452 460
453 GLES2Interface* gl = ContextGL(); 461 GLES2Interface* gl = ContextGL();
454 462
455 max_texture_size_ = 0; // Context expects cleared value. 463 max_texture_size_ = 0; // Context expects cleared value.
456 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); 464 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_);
457 best_texture_format_ = 465 best_texture_format_ =
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 case LUMINANCE_8: 517 case LUMINANCE_8:
510 return true; 518 return true;
511 case BGRA_8888: 519 case BGRA_8888:
512 return caps.texture_format_bgra8888; 520 return caps.texture_format_bgra8888;
513 case ETC1: 521 case ETC1:
514 return caps.texture_format_etc1; 522 return caps.texture_format_etc1;
515 case RED_8: 523 case RED_8:
516 return caps.texture_rg; 524 return caps.texture_rg;
517 case LUMINANCE_F16: 525 case LUMINANCE_F16:
518 return caps.texture_half_float_linear; 526 return caps.texture_half_float_linear;
527 case RG_88:
528 return caps.texture_rg;
519 } 529 }
520 530
521 NOTREACHED(); 531 NOTREACHED();
522 return false; 532 return false;
523 } 533 }
524 534
525 bool ResourceProvider::InUseByConsumer(ResourceId id) { 535 bool ResourceProvider::InUseByConsumer(ResourceId id) {
526 Resource* resource = GetResource(id); 536 Resource* resource = GetResource(id);
527 return resource->lock_for_read_count > 0 || resource->exported_count > 0 || 537 return resource->lock_for_read_count > 0 || resource->exported_count > 0 ||
528 resource->lost; 538 resource->lost;
(...skipping 11 matching lines...) Expand all
540 } 550 }
541 551
542 ResourceFormat ResourceProvider::YuvResourceFormat(int bits) const { 552 ResourceFormat ResourceProvider::YuvResourceFormat(int bits) const {
543 if (bits > 8) { 553 if (bits > 8) {
544 return yuv_highbit_resource_format_; 554 return yuv_highbit_resource_format_;
545 } else { 555 } else {
546 return yuv_resource_format_; 556 return yuv_resource_format_;
547 } 557 }
548 } 558 }
549 559
560 ResourceFormat ResourceProvider::Y16ResourceFormat(int bits) const {
561 if (bits > 8) {
562 return y16_resource_format_;
563 } else {
564 return yuv_resource_format_;
565 }
566 }
567
550 ResourceId ResourceProvider::CreateResource(const gfx::Size& size, 568 ResourceId ResourceProvider::CreateResource(const gfx::Size& size,
551 TextureHint hint, 569 TextureHint hint,
552 ResourceFormat format) { 570 ResourceFormat format) {
553 DCHECK(!size.IsEmpty()); 571 DCHECK(!size.IsEmpty());
554 switch (default_resource_type_) { 572 switch (default_resource_type_) {
555 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: 573 case RESOURCE_TYPE_GPU_MEMORY_BUFFER:
556 // GPU memory buffers don't support LUMINANCE_F16. 574 // GPU memory buffers don't support LUMINANCE_F16.
557 if (format != LUMINANCE_F16) { 575 if (format != LUMINANCE_F16) {
558 return CreateGLTexture(size, hint, RESOURCE_TYPE_GPU_MEMORY_BUFFER, 576 return CreateGLTexture(size, hint, RESOURCE_TYPE_GPU_MEMORY_BUFFER,
559 format); 577 format);
(...skipping 1427 matching lines...) Expand 10 before | Expand all | Expand 10 after
1987 2005
1988 const int kImportance = 2; 2006 const int kImportance = 2;
1989 pmd->CreateSharedGlobalAllocatorDump(guid); 2007 pmd->CreateSharedGlobalAllocatorDump(guid);
1990 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2008 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
1991 } 2009 }
1992 2010
1993 return true; 2011 return true;
1994 } 2012 }
1995 2013
1996 } // namespace cc 2014 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698