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

Side by Side Diff: cc/resources/resource_format.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: rebase 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
« no previous file with comments | « cc/resources/resource_format.h ('k') | cc/resources/resource_format_utils.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_format.h" 5 #include "cc/resources/resource_format.h"
6 6
7 #include "third_party/khronos/GLES2/gl2.h" 7 #include "third_party/khronos/GLES2/gl2.h"
8 #include "third_party/khronos/GLES2/gl2ext.h" 8 #include "third_party/khronos/GLES2/gl2ext.h"
9 #include "ui/gfx/gpu_memory_buffer.h" 9 #include "ui/gfx/gpu_memory_buffer.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 int BitsPerPixel(ResourceFormat format) { 13 int BitsPerPixel(ResourceFormat format) {
14 switch (format) { 14 switch (format) {
15 case BGRA_8888: 15 case BGRA_8888:
16 case RGBA_8888: 16 case RGBA_8888:
17 return 32; 17 return 32;
18 case RGBA_4444: 18 case RGBA_4444:
19 case RGB_565: 19 case RGB_565:
20 case LUMINANCE_F16: 20 case LUMINANCE_F16:
21 case RG_88:
21 return 16; 22 return 16;
22 case ALPHA_8: 23 case ALPHA_8:
23 case LUMINANCE_8: 24 case LUMINANCE_8:
24 case RED_8: 25 case RED_8:
25 return 8; 26 return 8;
26 case ETC1: 27 case ETC1:
27 return 4; 28 return 4;
28 } 29 }
29 NOTREACHED(); 30 NOTREACHED();
30 return 0; 31 return 0;
31 } 32 }
32 33
33 GLenum GLDataType(ResourceFormat format) { 34 GLenum GLDataType(ResourceFormat format) {
34 DCHECK_LE(format, RESOURCE_FORMAT_MAX); 35 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
35 static const GLenum format_gl_data_type[] = { 36 static const GLenum format_gl_data_type[] = {
36 GL_UNSIGNED_BYTE, // RGBA_8888 37 GL_UNSIGNED_BYTE, // RGBA_8888
37 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 38 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444
38 GL_UNSIGNED_BYTE, // BGRA_8888 39 GL_UNSIGNED_BYTE, // BGRA_8888
39 GL_UNSIGNED_BYTE, // ALPHA_8 40 GL_UNSIGNED_BYTE, // ALPHA_8
40 GL_UNSIGNED_BYTE, // LUMINANCE_8 41 GL_UNSIGNED_BYTE, // LUMINANCE_8
41 GL_UNSIGNED_SHORT_5_6_5, // RGB_565, 42 GL_UNSIGNED_SHORT_5_6_5, // RGB_565,
42 GL_UNSIGNED_BYTE, // ETC1 43 GL_UNSIGNED_BYTE, // ETC1
43 GL_UNSIGNED_BYTE, // RED_8 44 GL_UNSIGNED_BYTE, // RED_8
44 GL_HALF_FLOAT_OES, // LUMINANCE_F16 45 GL_HALF_FLOAT_OES, // LUMINANCE_F16
46 GL_UNSIGNED_BYTE, // RG_88
45 }; 47 };
46 static_assert(arraysize(format_gl_data_type) == (RESOURCE_FORMAT_MAX + 1), 48 static_assert(arraysize(format_gl_data_type) == (RESOURCE_FORMAT_MAX + 1),
47 "format_gl_data_type does not handle all cases."); 49 "format_gl_data_type does not handle all cases.");
48 50
49 return format_gl_data_type[format]; 51 return format_gl_data_type[format];
50 } 52 }
51 53
52 GLenum GLDataFormat(ResourceFormat format) { 54 GLenum GLDataFormat(ResourceFormat format) {
53 DCHECK_LE(format, RESOURCE_FORMAT_MAX); 55 DCHECK_LE(format, RESOURCE_FORMAT_MAX);
54 static const GLenum format_gl_data_format[] = { 56 static const GLenum format_gl_data_format[] = {
55 GL_RGBA, // RGBA_8888 57 GL_RGBA, // RGBA_8888
56 GL_RGBA, // RGBA_4444 58 GL_RGBA, // RGBA_4444
57 GL_BGRA_EXT, // BGRA_8888 59 GL_BGRA_EXT, // BGRA_8888
58 GL_ALPHA, // ALPHA_8 60 GL_ALPHA, // ALPHA_8
59 GL_LUMINANCE, // LUMINANCE_8 61 GL_LUMINANCE, // LUMINANCE_8
60 GL_RGB, // RGB_565 62 GL_RGB, // RGB_565
61 GL_ETC1_RGB8_OES, // ETC1 63 GL_ETC1_RGB8_OES, // ETC1
62 GL_RED_EXT, // RED_8 64 GL_RED_EXT, // RED_8
63 GL_LUMINANCE, // LUMINANCE_F16 65 GL_LUMINANCE, // LUMINANCE_F16
66 GL_RG_EXT, // RG_88
64 }; 67 };
65 static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), 68 static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
66 "format_gl_data_format does not handle all cases."); 69 "format_gl_data_format does not handle all cases.");
67 return format_gl_data_format[format]; 70 return format_gl_data_format[format];
68 } 71 }
69 72
70 GLenum GLInternalFormat(ResourceFormat format) { 73 GLenum GLInternalFormat(ResourceFormat format) {
71 // In GLES2, the internal format must match the texture format. (It no longer 74 // In GLES2, the internal format must match the texture format. (It no longer
72 // is true in GLES3, however it still holds for the BGRA extension.) 75 // is true in GLES3, however it still holds for the BGRA extension.)
73 return GLDataFormat(format); 76 return GLDataFormat(format);
(...skipping 10 matching lines...) Expand all
84 static const GLenum format_gl_data_format[] = { 87 static const GLenum format_gl_data_format[] = {
85 GL_RGBA, // RGBA_8888 88 GL_RGBA, // RGBA_8888
86 GL_RGBA, // RGBA_4444 89 GL_RGBA, // RGBA_4444
87 GL_RGBA, // BGRA_8888 90 GL_RGBA, // BGRA_8888
88 GL_ALPHA, // ALPHA_8 91 GL_ALPHA, // ALPHA_8
89 GL_LUMINANCE, // LUMINANCE_8 92 GL_LUMINANCE, // LUMINANCE_8
90 GL_RGB, // RGB_565 93 GL_RGB, // RGB_565
91 GL_RGB, // ETC1 94 GL_RGB, // ETC1
92 GL_LUMINANCE, // RED_8 95 GL_LUMINANCE, // RED_8
93 GL_LUMINANCE, // LUMINANCE_F16 96 GL_LUMINANCE, // LUMINANCE_F16
97 GL_RG8_EXT, // RG_88
94 }; 98 };
95 static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1), 99 static_assert(arraysize(format_gl_data_format) == (RESOURCE_FORMAT_MAX + 1),
96 "format_gl_data_format does not handle all cases."); 100 "format_gl_data_format does not handle all cases.");
97 return format_gl_data_format[format]; 101 return format_gl_data_format[format];
98 } 102 }
99 103
100 gfx::BufferFormat BufferFormat(ResourceFormat format) { 104 gfx::BufferFormat BufferFormat(ResourceFormat format) {
101 switch (format) { 105 switch (format) {
102 case BGRA_8888: 106 case BGRA_8888:
103 return gfx::BufferFormat::BGRA_8888; 107 return gfx::BufferFormat::BGRA_8888;
104 case RED_8: 108 case RED_8:
105 return gfx::BufferFormat::R_8; 109 return gfx::BufferFormat::R_8;
110 case RG_88:
111 return gfx::BufferFormat::RG_88;
106 case RGBA_4444: 112 case RGBA_4444:
107 return gfx::BufferFormat::RGBA_4444; 113 return gfx::BufferFormat::RGBA_4444;
108 case RGBA_8888: 114 case RGBA_8888:
109 return gfx::BufferFormat::RGBA_8888; 115 return gfx::BufferFormat::RGBA_8888;
110 case ETC1: 116 case ETC1:
111 return gfx::BufferFormat::ETC1; 117 return gfx::BufferFormat::ETC1;
112 case ALPHA_8: 118 case ALPHA_8:
113 case LUMINANCE_8: 119 case LUMINANCE_8:
114 case RGB_565: 120 case RGB_565:
115 case LUMINANCE_F16: 121 case LUMINANCE_F16:
(...skipping 12 matching lines...) Expand all
128 case RGBA_4444: 134 case RGBA_4444:
129 case RGBA_8888: 135 case RGBA_8888:
130 case BGRA_8888: 136 case BGRA_8888:
131 case ALPHA_8: 137 case ALPHA_8:
132 return true; 138 return true;
133 case LUMINANCE_8: 139 case LUMINANCE_8:
134 case RGB_565: 140 case RGB_565:
135 case ETC1: 141 case ETC1:
136 case RED_8: 142 case RED_8:
137 case LUMINANCE_F16: 143 case LUMINANCE_F16:
144 case RG_88:
138 return false; 145 return false;
139 } 146 }
140 NOTREACHED(); 147 NOTREACHED();
141 return false; 148 return false;
142 } 149 }
143 150
144 } // namespace cc 151 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/resource_format.h ('k') | cc/resources/resource_format_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698