add a use_alsa gyp setting
[chromium-blink-merge.git] / cc / platform_color.h
blob8706114ee895663f64abcde332cab12a7abe2875
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.
5 #ifndef CC_PLATFORM_COLOR_H_
6 #define CC_PLATFORM_COLOR_H_
8 #include "third_party/WebKit/Source/Platform/chromium/public/WebGraphicsContext3D.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"
13 namespace cc {
15 class PlatformColor {
16 public:
17 enum SourceDataFormat { SourceFormatRGBA8, SourceFormatBGRA8 };
19 static SourceDataFormat format()
21 return SK_B32_SHIFT ? SourceFormatRGBA8 : SourceFormatBGRA8;
24 // Returns the most efficient texture format for this platform.
25 static GLenum bestTextureFormat(WebKit::WebGraphicsContext3D* context, bool supportsBGRA8888)
27 GLenum textureFormat = GL_RGBA;
28 switch (format()) {
29 case SourceFormatRGBA8:
30 break;
31 case SourceFormatBGRA8:
32 if (supportsBGRA8888)
33 textureFormat = GL_BGRA_EXT;
34 break;
35 default:
36 NOTREACHED();
37 break;
39 return textureFormat;
42 // Return true if the given texture format has the same component order
43 // as the color on this platform.
44 static bool sameComponentOrder(GLenum textureFormat)
46 switch (format()) {
47 case SourceFormatRGBA8:
48 return textureFormat == GL_RGBA;
49 case SourceFormatBGRA8:
50 return textureFormat == GL_BGRA_EXT;
51 default:
52 NOTREACHED();
53 return false;
58 } // namespace cc
60 #endif // CC_PLATFORM_COLOR_H_