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 "cc/resources/resource_format.h" | 5 #include "cc/resources/resource_format.h" |
6 | 6 |
7 #include "third_party/khronos/GLES2/gl2.h" | |
8 #include "third_party/khronos/GLES2/gl2ext.h" | |
9 | |
7 namespace cc { | 10 namespace cc { |
8 | 11 |
9 SkColorType ResourceFormatToSkColorType(ResourceFormat format) { | 12 SkColorType ResourceFormatToSkColorType(ResourceFormat format) { |
10 switch (format) { | 13 switch (format) { |
11 case RGBA_4444: | 14 case RGBA_4444: |
12 return kARGB_4444_SkColorType; | 15 return kARGB_4444_SkColorType; |
13 case RGBA_8888: | 16 case RGBA_8888: |
14 case BGRA_8888: | 17 case BGRA_8888: |
15 return kN32_SkColorType; | 18 return kN32_SkColorType; |
16 case ETC1: | 19 case ETC1: |
17 case ALPHA_8: | 20 case ALPHA_8: |
18 case LUMINANCE_8: | 21 case LUMINANCE_8: |
19 case RGB_565: | 22 case RGB_565: |
20 case RED_8: | 23 case RED_8: |
21 NOTREACHED(); | 24 NOTREACHED(); |
22 break; | 25 break; |
23 } | 26 } |
24 NOTREACHED(); | 27 NOTREACHED(); |
25 return kN32_SkColorType; | 28 return kN32_SkColorType; |
26 } | 29 } |
27 | 30 |
31 int BitsPerPixel(ResourceFormat format) { | |
32 switch (format) { | |
33 case BGRA_8888: | |
34 case RGBA_8888: | |
35 return 32; | |
36 case RGBA_4444: | |
37 case RGB_565: | |
38 return 16; | |
39 case ALPHA_8: | |
40 case LUMINANCE_8: | |
41 case RED_8: | |
42 return 8; | |
43 case ETC1: | |
44 return 4; | |
45 } | |
46 NOTREACHED(); | |
47 return 0; | |
48 } | |
49 | |
50 GLenum GLDataType(ResourceFormat format) { | |
51 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | |
52 static const GLenum format_gl_data_type[RESOURCE_FORMAT_MAX + 1] = { | |
ericrk
2015/07/24 20:03:52
There's actually no warning/error generated if you
prashant.n
2015/07/25 07:15:43
Sounds good. I'll incorporate this.
| |
53 GL_UNSIGNED_BYTE, // RGBA_8888 | |
54 GL_UNSIGNED_SHORT_4_4_4_4, // RGBA_4444 | |
55 GL_UNSIGNED_BYTE, // BGRA_8888 | |
56 GL_UNSIGNED_BYTE, // ALPHA_8 | |
57 GL_UNSIGNED_BYTE, // LUMINANCE_8 | |
58 GL_UNSIGNED_SHORT_5_6_5, // RGB_565, | |
59 GL_UNSIGNED_BYTE, // ETC1 | |
60 GL_UNSIGNED_BYTE // RED_8 | |
61 }; | |
62 return format_gl_data_type[format]; | |
63 } | |
64 | |
65 GLenum GLDataFormat(ResourceFormat format) { | |
66 DCHECK_LE(format, RESOURCE_FORMAT_MAX); | |
67 static const GLenum format_gl_data_format[RESOURCE_FORMAT_MAX + 1] = { | |
68 GL_RGBA, // RGBA_8888 | |
69 GL_RGBA, // RGBA_4444 | |
70 GL_BGRA_EXT, // BGRA_8888 | |
71 GL_ALPHA, // ALPHA_8 | |
72 GL_LUMINANCE, // LUMINANCE_8 | |
73 GL_RGB, // RGB_565 | |
74 GL_ETC1_RGB8_OES, // ETC1 | |
75 GL_RED_EXT // RED_8 | |
76 }; | |
77 return format_gl_data_format[format]; | |
78 } | |
79 | |
80 GLenum GLInternalFormat(ResourceFormat format) { | |
81 return GLDataFormat(format); | |
82 } | |
83 | |
28 } // namespace cc | 84 } // namespace cc |
OLD | NEW |