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 15 matching lines...) Expand all Loading... |
26 #include <stddef.h> | 26 #include <stddef.h> |
27 | 27 |
28 using gfx::BufferFormat; | 28 using gfx::BufferFormat; |
29 | 29 |
30 namespace gl { | 30 namespace gl { |
31 namespace { | 31 namespace { |
32 | 32 |
33 bool ValidInternalFormat(unsigned internalformat) { | 33 bool ValidInternalFormat(unsigned internalformat) { |
34 switch (internalformat) { | 34 switch (internalformat) { |
35 case GL_RED: | 35 case GL_RED: |
| 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::UYVY_422: | 54 case gfx::BufferFormat::UYVY_422: |
54 case gfx::BufferFormat::YUV_420_BIPLANAR: | 55 case gfx::BufferFormat::YUV_420_BIPLANAR: |
55 return true; | 56 return true; |
| 57 case gfx::BufferFormat::RG_88: |
56 case gfx::BufferFormat::ATC: | 58 case gfx::BufferFormat::ATC: |
57 case gfx::BufferFormat::ATCIA: | 59 case gfx::BufferFormat::ATCIA: |
58 case gfx::BufferFormat::DXT1: | 60 case gfx::BufferFormat::DXT1: |
59 case gfx::BufferFormat::DXT5: | 61 case gfx::BufferFormat::DXT5: |
60 case gfx::BufferFormat::ETC1: | 62 case gfx::BufferFormat::ETC1: |
61 case gfx::BufferFormat::BGR_565: | 63 case gfx::BufferFormat::BGR_565: |
62 case gfx::BufferFormat::RGBA_4444: | 64 case gfx::BufferFormat::RGBA_4444: |
63 case gfx::BufferFormat::RGBX_8888: | 65 case gfx::BufferFormat::RGBX_8888: |
64 case gfx::BufferFormat::YVU_420: | 66 case gfx::BufferFormat::YVU_420: |
65 return false; | 67 return false; |
66 } | 68 } |
67 | 69 |
68 NOTREACHED(); | 70 NOTREACHED(); |
69 return false; | 71 return false; |
70 } | 72 } |
71 | 73 |
72 GLenum TextureFormat(gfx::BufferFormat format) { | 74 GLenum TextureFormat(gfx::BufferFormat format) { |
73 switch (format) { | 75 switch (format) { |
74 case gfx::BufferFormat::R_8: | 76 case gfx::BufferFormat::R_8: |
75 return GL_RED; | 77 return GL_RED; |
| 78 case gfx::BufferFormat::RG_88: |
| 79 return GL_RG; |
76 case gfx::BufferFormat::BGRA_8888: | 80 case gfx::BufferFormat::BGRA_8888: |
77 case gfx::BufferFormat::BGRX_8888: | 81 case gfx::BufferFormat::BGRX_8888: |
78 case gfx::BufferFormat::RGBA_8888: | 82 case gfx::BufferFormat::RGBA_8888: |
79 return GL_RGBA; | 83 return GL_RGBA; |
80 case gfx::BufferFormat::UYVY_422: | 84 case gfx::BufferFormat::UYVY_422: |
81 return GL_RGB; | 85 return GL_RGB; |
82 case gfx::BufferFormat::YUV_420_BIPLANAR: | 86 case gfx::BufferFormat::YUV_420_BIPLANAR: |
83 return GL_RGB_YCBCR_420V_CHROMIUM; | 87 return GL_RGB_YCBCR_420V_CHROMIUM; |
84 case gfx::BufferFormat::ATC: | 88 case gfx::BufferFormat::ATC: |
85 case gfx::BufferFormat::ATCIA: | 89 case gfx::BufferFormat::ATCIA: |
86 case gfx::BufferFormat::DXT1: | 90 case gfx::BufferFormat::DXT1: |
87 case gfx::BufferFormat::DXT5: | 91 case gfx::BufferFormat::DXT5: |
88 case gfx::BufferFormat::ETC1: | 92 case gfx::BufferFormat::ETC1: |
89 case gfx::BufferFormat::BGR_565: | 93 case gfx::BufferFormat::BGR_565: |
90 case gfx::BufferFormat::RGBA_4444: | 94 case gfx::BufferFormat::RGBA_4444: |
91 case gfx::BufferFormat::RGBX_8888: | 95 case gfx::BufferFormat::RGBX_8888: |
92 case gfx::BufferFormat::YVU_420: | 96 case gfx::BufferFormat::YVU_420: |
93 NOTREACHED(); | 97 NOTREACHED(); |
94 return 0; | 98 return 0; |
95 } | 99 } |
96 | 100 |
97 NOTREACHED(); | 101 NOTREACHED(); |
98 return 0; | 102 return 0; |
99 } | 103 } |
100 | 104 |
101 GLenum DataFormat(gfx::BufferFormat format) { | 105 GLenum DataFormat(gfx::BufferFormat format) { |
102 switch (format) { | 106 switch (format) { |
103 case gfx::BufferFormat::R_8: | 107 case gfx::BufferFormat::R_8: |
104 return GL_RED; | 108 return GL_RED; |
| 109 case gfx::BufferFormat::RG_88: |
| 110 return GL_RG; |
105 case gfx::BufferFormat::BGRA_8888: | 111 case gfx::BufferFormat::BGRA_8888: |
106 case gfx::BufferFormat::BGRX_8888: | 112 case gfx::BufferFormat::BGRX_8888: |
107 case gfx::BufferFormat::RGBA_8888: | 113 case gfx::BufferFormat::RGBA_8888: |
108 return GL_BGRA; | 114 return GL_BGRA; |
109 case gfx::BufferFormat::UYVY_422: | 115 case gfx::BufferFormat::UYVY_422: |
110 return GL_YCBCR_422_APPLE; | 116 return GL_YCBCR_422_APPLE; |
111 case gfx::BufferFormat::ATC: | 117 case gfx::BufferFormat::ATC: |
112 case gfx::BufferFormat::ATCIA: | 118 case gfx::BufferFormat::ATCIA: |
113 case gfx::BufferFormat::DXT1: | 119 case gfx::BufferFormat::DXT1: |
114 case gfx::BufferFormat::DXT5: | 120 case gfx::BufferFormat::DXT5: |
115 case gfx::BufferFormat::ETC1: | 121 case gfx::BufferFormat::ETC1: |
116 case gfx::BufferFormat::BGR_565: | 122 case gfx::BufferFormat::BGR_565: |
117 case gfx::BufferFormat::RGBA_4444: | 123 case gfx::BufferFormat::RGBA_4444: |
118 case gfx::BufferFormat::RGBX_8888: | 124 case gfx::BufferFormat::RGBX_8888: |
119 case gfx::BufferFormat::YVU_420: | 125 case gfx::BufferFormat::YVU_420: |
120 case gfx::BufferFormat::YUV_420_BIPLANAR: | 126 case gfx::BufferFormat::YUV_420_BIPLANAR: |
121 NOTREACHED(); | 127 NOTREACHED(); |
122 return 0; | 128 return 0; |
123 } | 129 } |
124 | 130 |
125 NOTREACHED(); | 131 NOTREACHED(); |
126 return 0; | 132 return 0; |
127 } | 133 } |
128 | 134 |
129 GLenum DataType(gfx::BufferFormat format) { | 135 GLenum DataType(gfx::BufferFormat format) { |
130 switch (format) { | 136 switch (format) { |
131 case gfx::BufferFormat::R_8: | 137 case gfx::BufferFormat::R_8: |
| 138 case gfx::BufferFormat::RG_88: |
132 return GL_UNSIGNED_BYTE; | 139 return GL_UNSIGNED_BYTE; |
133 case gfx::BufferFormat::BGRA_8888: | 140 case gfx::BufferFormat::BGRA_8888: |
134 case gfx::BufferFormat::BGRX_8888: | 141 case gfx::BufferFormat::BGRX_8888: |
135 case gfx::BufferFormat::RGBA_8888: | 142 case gfx::BufferFormat::RGBA_8888: |
136 return GL_UNSIGNED_INT_8_8_8_8_REV; | 143 return GL_UNSIGNED_INT_8_8_8_8_REV; |
137 case gfx::BufferFormat::UYVY_422: | 144 case gfx::BufferFormat::UYVY_422: |
138 return GL_UNSIGNED_SHORT_8_8_APPLE; | 145 return GL_UNSIGNED_SHORT_8_8_APPLE; |
139 break; | 146 break; |
140 case gfx::BufferFormat::ATC: | 147 case gfx::BufferFormat::ATC: |
141 case gfx::BufferFormat::ATCIA: | 148 case gfx::BufferFormat::ATCIA: |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 } | 405 } |
399 | 406 |
400 // static | 407 // static |
401 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { | 408 GLImageIOSurface* GLImageIOSurface::FromGLImage(GLImage* image) { |
402 if (!image || image->GetType() != Type::IOSURFACE) | 409 if (!image || image->GetType() != Type::IOSURFACE) |
403 return nullptr; | 410 return nullptr; |
404 return static_cast<GLImageIOSurface*>(image); | 411 return static_cast<GLImageIOSurface*>(image); |
405 } | 412 } |
406 | 413 |
407 } // namespace gl | 414 } // namespace gl |
OLD | NEW |