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/khronos/GLES2/gl2.h"
9 #include "third_party/khronos/GLES2/gl2ext.h"
10 #include "third_party/skia/include/core/SkTypes.h"
11 #include <public/WebGraphicsContext3D.h>
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
;
29 case SourceFormatRGBA8
:
31 case SourceFormatBGRA8
:
33 textureFormat
= GL_BGRA_EXT
;
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
)
47 case SourceFormatRGBA8
:
48 return textureFormat
== GL_RGBA
;
49 case SourceFormatBGRA8
:
50 return textureFormat
== GL_BGRA_EXT
;
60 #endif // CC_PLATFORM_COLOR_H_