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

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: Tests: cc, skcanvas_video_renderer, wrtcrecorder... Fake capture supports Y16. Created 4 years, 2 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 DCHECK(!buffer_id_allocator_); 441 DCHECK(!buffer_id_allocator_);
440 442
441 const auto& caps = compositor_context_provider_->ContextCapabilities(); 443 const auto& caps = compositor_context_provider_->ContextCapabilities();
442 444
443 DCHECK(IsGpuResourceType(default_resource_type_)); 445 DCHECK(IsGpuResourceType(default_resource_type_));
444 use_texture_storage_ext_ = caps.texture_storage; 446 use_texture_storage_ext_ = caps.texture_storage;
445 use_texture_format_bgra_ = caps.texture_format_bgra8888; 447 use_texture_format_bgra_ = caps.texture_format_bgra8888;
446 use_texture_usage_hint_ = caps.texture_usage; 448 use_texture_usage_hint_ = caps.texture_usage;
447 use_compressed_texture_etc1_ = caps.texture_format_etc1; 449 use_compressed_texture_etc1_ = caps.texture_format_etc1;
448 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8; 450 yuv_resource_format_ = caps.texture_rg ? RED_8 : LUMINANCE_8;
451 y16_resource_format_ =
452 caps.texture_rg
453 ? RG_88
454 : RGBA_8888;
449 yuv_highbit_resource_format_ = yuv_resource_format_; 455 yuv_highbit_resource_format_ = yuv_resource_format_;
450 if (caps.texture_half_float_linear) 456 if (caps.texture_half_float_linear)
451 yuv_highbit_resource_format_ = LUMINANCE_F16; 457 yuv_highbit_resource_format_ = LUMINANCE_F16;
452 use_sync_query_ = caps.sync_query; 458 use_sync_query_ = caps.sync_query;
453 459
454 GLES2Interface* gl = ContextGL(); 460 GLES2Interface* gl = ContextGL();
455 461
456 max_texture_size_ = 0; // Context expects cleared value. 462 max_texture_size_ = 0; // Context expects cleared value.
457 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_); 463 gl->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size_);
458 best_texture_format_ = 464 best_texture_format_ =
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 case RGBA_4444: 513 case RGBA_4444:
508 case RGBA_8888: 514 case RGBA_8888:
509 case RGB_565: 515 case RGB_565:
510 case LUMINANCE_8: 516 case LUMINANCE_8:
511 return true; 517 return true;
512 case BGRA_8888: 518 case BGRA_8888:
513 return caps.texture_format_bgra8888; 519 return caps.texture_format_bgra8888;
514 case ETC1: 520 case ETC1:
515 return caps.texture_format_etc1; 521 return caps.texture_format_etc1;
516 case RED_8: 522 case RED_8:
523 case RG_88:
517 return caps.texture_rg; 524 return caps.texture_rg;
518 case LUMINANCE_F16: 525 case LUMINANCE_F16:
519 return caps.texture_half_float_linear; 526 return caps.texture_half_float_linear;
520 } 527 }
521 528
522 NOTREACHED(); 529 NOTREACHED();
523 return false; 530 return false;
524 } 531 }
525 532
526 bool ResourceProvider::InUseByConsumer(ResourceId id) { 533 bool ResourceProvider::InUseByConsumer(ResourceId id) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 577
571 case RESOURCE_TYPE_BITMAP: 578 case RESOURCE_TYPE_BITMAP:
572 DCHECK_EQ(RGBA_8888, format); 579 DCHECK_EQ(RGBA_8888, format);
573 return CreateBitmap(size, color_space); 580 return CreateBitmap(size, color_space);
574 } 581 }
575 582
576 LOG(FATAL) << "Invalid default resource type."; 583 LOG(FATAL) << "Invalid default resource type.";
577 return 0; 584 return 0;
578 } 585 }
579 586
587 ResourceFormat ResourceProvider::Y16ResourceFormat() const {
588 return y16_resource_format_;
589 }
590
580 ResourceId ResourceProvider::CreateGpuMemoryBufferResource( 591 ResourceId ResourceProvider::CreateGpuMemoryBufferResource(
581 const gfx::Size& size, 592 const gfx::Size& size,
582 TextureHint hint, 593 TextureHint hint,
583 ResourceFormat format, 594 ResourceFormat format,
584 gfx::BufferUsage usage, 595 gfx::BufferUsage usage,
585 const gfx::ColorSpace& color_space) { 596 const gfx::ColorSpace& color_space) {
586 DCHECK(!size.IsEmpty()); 597 DCHECK(!size.IsEmpty());
587 switch (default_resource_type_) { 598 switch (default_resource_type_) {
588 case RESOURCE_TYPE_GPU_MEMORY_BUFFER: 599 case RESOURCE_TYPE_GPU_MEMORY_BUFFER:
589 case RESOURCE_TYPE_GL_TEXTURE: { 600 case RESOURCE_TYPE_GL_TEXTURE: {
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 resource->read_lock_fences_enabled = true; 1044 resource->read_lock_fences_enabled = true;
1034 } 1045 }
1035 1046
1036 ResourceProvider::ScopedReadLockGL::ScopedReadLockGL( 1047 ResourceProvider::ScopedReadLockGL::ScopedReadLockGL(
1037 ResourceProvider* resource_provider, 1048 ResourceProvider* resource_provider,
1038 ResourceId resource_id) 1049 ResourceId resource_id)
1039 : resource_provider_(resource_provider), resource_id_(resource_id) { 1050 : resource_provider_(resource_provider), resource_id_(resource_id) {
1040 const Resource* resource = resource_provider->LockForRead(resource_id); 1051 const Resource* resource = resource_provider->LockForRead(resource_id);
1041 texture_id_ = resource->gl_id; 1052 texture_id_ = resource->gl_id;
1042 target_ = resource->target; 1053 target_ = resource->target;
1054 format_ = resource->format;
1043 size_ = resource->size; 1055 size_ = resource->size;
1044 color_space_ = resource->color_space; 1056 color_space_ = resource->color_space;
1045 } 1057 }
1046 1058
1047 ResourceProvider::ScopedReadLockGL::~ScopedReadLockGL() { 1059 ResourceProvider::ScopedReadLockGL::~ScopedReadLockGL() {
1048 resource_provider_->UnlockForRead(resource_id_); 1060 resource_provider_->UnlockForRead(resource_id_);
1049 } 1061 }
1050 1062
1051 ResourceProvider::ScopedSamplerGL::ScopedSamplerGL( 1063 ResourceProvider::ScopedSamplerGL::ScopedSamplerGL(
1052 ResourceProvider* resource_provider, 1064 ResourceProvider* resource_provider,
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after
2015 2027
2016 const int kImportance = 2; 2028 const int kImportance = 2;
2017 pmd->CreateSharedGlobalAllocatorDump(guid); 2029 pmd->CreateSharedGlobalAllocatorDump(guid);
2018 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance); 2030 pmd->AddOwnershipEdge(dump->guid(), guid, kImportance);
2019 } 2031 }
2020 2032
2021 return true; 2033 return true;
2022 } 2034 }
2023 2035
2024 } // namespace cc 2036 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698