OLD | NEW |
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 "ui/gl/gl_image_io_surface.h" | 5 #include "ui/gl/gl_image_io_surface.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/mac/bind_objc_block.h" | 10 #include "base/mac/bind_objc_block.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include <stddef.h> | 25 #include <stddef.h> |
26 | 26 |
27 using gfx::BufferFormat; | 27 using gfx::BufferFormat; |
28 | 28 |
29 namespace gl { | 29 namespace gl { |
30 namespace { | 30 namespace { |
31 | 31 |
32 bool ValidInternalFormat(unsigned internalformat) { | 32 bool ValidInternalFormat(unsigned internalformat) { |
33 switch (internalformat) { | 33 switch (internalformat) { |
34 case GL_RED: | 34 case GL_RED: |
| 35 case GL_R16_EXT: |
35 case GL_RG: | 36 case GL_RG: |
36 case GL_BGRA_EXT: | 37 case GL_BGRA_EXT: |
37 case GL_RGB: | 38 case GL_RGB: |
38 case GL_RGB_YCBCR_420V_CHROMIUM: | 39 case GL_RGB_YCBCR_420V_CHROMIUM: |
39 case GL_RGB_YCBCR_422_CHROMIUM: | 40 case GL_RGB_YCBCR_422_CHROMIUM: |
40 case GL_RGBA: | 41 case GL_RGBA: |
41 return true; | 42 return true; |
42 default: | 43 default: |
43 return false; | 44 return false; |
44 } | 45 } |
45 } | 46 } |
46 | 47 |
47 bool ValidFormat(gfx::BufferFormat format) { | 48 bool ValidFormat(gfx::BufferFormat format) { |
48 switch (format) { | 49 switch (format) { |
49 case gfx::BufferFormat::R_8: | 50 case gfx::BufferFormat::R_8: |
50 case gfx::BufferFormat::BGRA_8888: | 51 case gfx::BufferFormat::BGRA_8888: |
51 case gfx::BufferFormat::BGRX_8888: | 52 case gfx::BufferFormat::BGRX_8888: |
52 case gfx::BufferFormat::RGBA_8888: | 53 case gfx::BufferFormat::RGBA_8888: |
53 case gfx::BufferFormat::RGBA_F16: | 54 case gfx::BufferFormat::RGBA_F16: |
54 case gfx::BufferFormat::UYVY_422: | 55 case gfx::BufferFormat::UYVY_422: |
55 case gfx::BufferFormat::YUV_420_BIPLANAR: | 56 case gfx::BufferFormat::YUV_420_BIPLANAR: |
56 return true; | 57 return true; |
| 58 case gfx::BufferFormat::R_16: |
57 case gfx::BufferFormat::RG_88: | 59 case gfx::BufferFormat::RG_88: |
58 case gfx::BufferFormat::ATC: | 60 case gfx::BufferFormat::ATC: |
59 case gfx::BufferFormat::ATCIA: | 61 case gfx::BufferFormat::ATCIA: |
60 case gfx::BufferFormat::DXT1: | 62 case gfx::BufferFormat::DXT1: |
61 case gfx::BufferFormat::DXT5: | 63 case gfx::BufferFormat::DXT5: |
62 case gfx::BufferFormat::ETC1: | 64 case gfx::BufferFormat::ETC1: |
63 case gfx::BufferFormat::BGR_565: | 65 case gfx::BufferFormat::BGR_565: |
64 case gfx::BufferFormat::RGBA_4444: | 66 case gfx::BufferFormat::RGBA_4444: |
65 case gfx::BufferFormat::RGBX_8888: | 67 case gfx::BufferFormat::RGBX_8888: |
66 case gfx::BufferFormat::YVU_420: | 68 case gfx::BufferFormat::YVU_420: |
67 return false; | 69 return false; |
68 } | 70 } |
69 | 71 |
70 NOTREACHED(); | 72 NOTREACHED(); |
71 return false; | 73 return false; |
72 } | 74 } |
73 | 75 |
74 GLenum TextureFormat(gfx::BufferFormat format) { | 76 GLenum TextureFormat(gfx::BufferFormat format) { |
75 switch (format) { | 77 switch (format) { |
76 case gfx::BufferFormat::R_8: | 78 case gfx::BufferFormat::R_8: |
77 return GL_RED; | 79 return GL_RED; |
| 80 case gfx::BufferFormat::R_16: |
| 81 return GL_R16_EXT; |
78 case gfx::BufferFormat::RG_88: | 82 case gfx::BufferFormat::RG_88: |
79 return GL_RG; | 83 return GL_RG; |
80 case gfx::BufferFormat::BGRA_8888: | 84 case gfx::BufferFormat::BGRA_8888: |
81 case gfx::BufferFormat::BGRX_8888: | 85 case gfx::BufferFormat::BGRX_8888: |
82 case gfx::BufferFormat::RGBA_8888: | 86 case gfx::BufferFormat::RGBA_8888: |
83 case gfx::BufferFormat::RGBA_F16: | 87 case gfx::BufferFormat::RGBA_F16: |
84 return GL_RGBA; | 88 return GL_RGBA; |
85 case gfx::BufferFormat::UYVY_422: | 89 case gfx::BufferFormat::UYVY_422: |
86 return GL_RGB; | 90 return GL_RGB; |
87 case gfx::BufferFormat::YUV_420_BIPLANAR: | 91 case gfx::BufferFormat::YUV_420_BIPLANAR: |
(...skipping 12 matching lines...) Expand all Loading... |
100 } | 104 } |
101 | 105 |
102 NOTREACHED(); | 106 NOTREACHED(); |
103 return 0; | 107 return 0; |
104 } | 108 } |
105 | 109 |
106 GLenum DataFormat(gfx::BufferFormat format) { | 110 GLenum DataFormat(gfx::BufferFormat format) { |
107 switch (format) { | 111 switch (format) { |
108 case gfx::BufferFormat::R_8: | 112 case gfx::BufferFormat::R_8: |
109 return GL_RED; | 113 return GL_RED; |
| 114 case gfx::BufferFormat::R_16: |
| 115 return GL_R16_EXT; |
110 case gfx::BufferFormat::RG_88: | 116 case gfx::BufferFormat::RG_88: |
111 return GL_RG; | 117 return GL_RG; |
112 case gfx::BufferFormat::BGRA_8888: | 118 case gfx::BufferFormat::BGRA_8888: |
113 case gfx::BufferFormat::BGRX_8888: | 119 case gfx::BufferFormat::BGRX_8888: |
114 case gfx::BufferFormat::RGBA_8888: | 120 case gfx::BufferFormat::RGBA_8888: |
115 return GL_BGRA; | 121 return GL_BGRA; |
116 case gfx::BufferFormat::RGBA_F16: | 122 case gfx::BufferFormat::RGBA_F16: |
117 return GL_RGBA; | 123 return GL_RGBA; |
118 case gfx::BufferFormat::UYVY_422: | 124 case gfx::BufferFormat::UYVY_422: |
119 return GL_YCBCR_422_APPLE; | 125 return GL_YCBCR_422_APPLE; |
(...skipping 11 matching lines...) Expand all Loading... |
131 return 0; | 137 return 0; |
132 } | 138 } |
133 | 139 |
134 NOTREACHED(); | 140 NOTREACHED(); |
135 return 0; | 141 return 0; |
136 } | 142 } |
137 | 143 |
138 GLenum DataType(gfx::BufferFormat format) { | 144 GLenum DataType(gfx::BufferFormat format) { |
139 switch (format) { | 145 switch (format) { |
140 case gfx::BufferFormat::R_8: | 146 case gfx::BufferFormat::R_8: |
| 147 case gfx::BufferFormat::R_16: |
141 case gfx::BufferFormat::RG_88: | 148 case gfx::BufferFormat::RG_88: |
142 return GL_UNSIGNED_BYTE; | 149 return GL_UNSIGNED_BYTE; |
143 case gfx::BufferFormat::BGRA_8888: | 150 case gfx::BufferFormat::BGRA_8888: |
144 case gfx::BufferFormat::BGRX_8888: | 151 case gfx::BufferFormat::BGRX_8888: |
145 case gfx::BufferFormat::RGBA_8888: | 152 case gfx::BufferFormat::RGBA_8888: |
146 return GL_UNSIGNED_INT_8_8_8_8_REV; | 153 return GL_UNSIGNED_INT_8_8_8_8_REV; |
147 case gfx::BufferFormat::RGBA_F16: | 154 case gfx::BufferFormat::RGBA_F16: |
148 return GL_HALF_APPLE; | 155 return GL_HALF_APPLE; |
149 case gfx::BufferFormat::UYVY_422: | 156 case gfx::BufferFormat::UYVY_422: |
150 return GL_UNSIGNED_SHORT_8_8_APPLE; | 157 return GL_UNSIGNED_SHORT_8_8_APPLE; |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 } | 424 } |
418 | 425 |
419 // static | 426 // static |
420 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { | 427 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { |
421 if (!image || image->GetType() != Type::IOSURFACE) | 428 if (!image || image->GetType() != Type::IOSURFACE) |
422 return nullptr; | 429 return nullptr; |
423 return static_cast<GLImageIOSurface*>(image); | 430 return static_cast<GLImageIOSurface*>(image); |
424 } | 431 } |
425 | 432 |
426 } // namespace gl | 433 } // namespace gl |
OLD | NEW |