Update mojo surfaces bindings and mojo/cc/ glue
[chromium-blink-merge.git] / cc / resources / platform_color.h
blob4945dccadc57d01d8a9e03af76eaca13ca9f3d9d
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_RESOURCES_PLATFORM_COLOR_H_
6 #define CC_RESOURCES_PLATFORM_COLOR_H_
8 #include "base/basictypes.h"
9 #include "base/logging.h"
10 #include "cc/resources/resource_format.h"
11 #include "third_party/khronos/GLES2/gl2.h"
12 #include "third_party/khronos/GLES2/gl2ext.h"
13 #include "third_party/skia/include/core/SkTypes.h"
15 namespace cc {
17 class PlatformColor {
18 public:
19 enum SourceDataFormat {
20 SOURCE_FORMAT_RGBA8,
21 SOURCE_FORMAT_BGRA8
24 static SourceDataFormat Format() {
25 return SK_B32_SHIFT ? SOURCE_FORMAT_RGBA8 : SOURCE_FORMAT_BGRA8;
28 // Returns the most efficient texture format for this platform.
29 static ResourceFormat BestTextureFormat(bool supports_bgra8888) {
30 switch (Format()) {
31 case SOURCE_FORMAT_BGRA8:
32 return (supports_bgra8888) ? BGRA_8888 : RGBA_8888;
33 case SOURCE_FORMAT_RGBA8:
34 return RGBA_8888;
36 NOTREACHED();
37 return RGBA_8888;
40 // Return true if the given texture format has the same component order
41 // as the color on this platform.
42 static bool SameComponentOrder(ResourceFormat format) {
43 switch (Format()) {
44 case SOURCE_FORMAT_RGBA8:
45 return format == RGBA_8888 || format == RGBA_4444;
46 case SOURCE_FORMAT_BGRA8:
47 return format == BGRA_8888 || format == RGBA_4444;
49 NOTREACHED();
50 return false;
53 private:
54 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformColor);
57 } // namespace cc
59 #endif // CC_RESOURCES_PLATFORM_COLOR_H_