OLD | NEW |
| (Empty) |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CC_PLATFORM_COLOR_H_ | |
6 #define CC_PLATFORM_COLOR_H_ | |
7 | |
8 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3
D.h" | |
9 #include "third_party/khronos/GLES2/gl2.h" | |
10 #include "third_party/khronos/GLES2/gl2ext.h" | |
11 #include "third_party/skia/include/core/SkTypes.h" | |
12 | |
13 namespace cc { | |
14 | |
15 class PlatformColor { | |
16 public: | |
17 enum SourceDataFormat { | |
18 SOURCE_FORMAT_RGBA8, | |
19 SOURCE_FORMAT_BGRA8 | |
20 }; | |
21 | |
22 static SourceDataFormat Format() { | |
23 return SK_B32_SHIFT ? SOURCE_FORMAT_RGBA8 : SOURCE_FORMAT_BGRA8; | |
24 } | |
25 | |
26 // Returns the most efficient texture format for this platform. | |
27 static GLenum BestTextureFormat(WebKit::WebGraphicsContext3D* context, | |
28 bool supports_bgra8888) { | |
29 GLenum texture_format = GL_RGBA; | |
30 switch (Format()) { | |
31 case SOURCE_FORMAT_RGBA8: | |
32 break; | |
33 case SOURCE_FORMAT_BGRA8: | |
34 if (supports_bgra8888) | |
35 texture_format = GL_BGRA_EXT; | |
36 break; | |
37 default: | |
38 NOTREACHED(); | |
39 break; | |
40 } | |
41 return texture_format; | |
42 } | |
43 | |
44 // Return true if the given texture format has the same component order | |
45 // as the color on this platform. | |
46 static bool SameComponentOrder(GLenum texture_format) { | |
47 switch (Format()) { | |
48 case SOURCE_FORMAT_RGBA8: | |
49 return texture_format == GL_RGBA; | |
50 case SOURCE_FORMAT_BGRA8: | |
51 return texture_format == GL_BGRA_EXT; | |
52 default: | |
53 NOTREACHED(); | |
54 return false; | |
55 } | |
56 } | |
57 }; | |
58 | |
59 } // namespace cc | |
60 | |
61 #endif // CC_PLATFORM_COLOR_H_ | |
OLD | NEW |