| OLD | NEW |
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CC_RESOURCES_PLATFORM_COLOR_H_ | 5 #ifndef CC_RESOURCES_PLATFORM_COLOR_H_ |
| 6 #define CC_RESOURCES_PLATFORM_COLOR_H_ | 6 #define CC_RESOURCES_PLATFORM_COLOR_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "cc/resources/resource_format.h" | 10 #include "cc/resources/resource_format.h" |
| 11 #include "third_party/skia/include/core/SkTypes.h" | 11 #include "third_party/skia/include/core/SkTypes.h" |
| 12 | 12 |
| 13 namespace cc { | 13 namespace cc { |
| 14 | 14 |
| 15 class PlatformColor { | 15 class PlatformColor { |
| 16 public: | 16 public: |
| 17 enum SourceDataFormat { | 17 enum SourceDataFormat { |
| 18 SOURCE_FORMAT_RGBA8, | 18 SOURCE_FORMAT_RGBA8, |
| 19 SOURCE_FORMAT_BGRA8 | 19 SOURCE_FORMAT_BGRA8 |
| 20 }; | 20 }; |
| 21 | 21 |
| 22 static SourceDataFormat Format() { | 22 static SourceDataFormat Format() { |
| 23 return SK_B32_SHIFT ? SOURCE_FORMAT_RGBA8 : SOURCE_FORMAT_BGRA8; | 23 return SK_B32_SHIFT ? SOURCE_FORMAT_RGBA8 : SOURCE_FORMAT_BGRA8; |
| 24 } | 24 } |
| 25 | 25 |
| 26 // Returns the most efficient texture format for this platform. | 26 // Returns the most efficient texture format for this platform. |
| 27 static ResourceFormat BestTextureFormat() { | 27 static ResourceFormat BestTextureFormat(bool supports_bgra8888) { |
| 28 switch (Format()) { | |
| 29 case SOURCE_FORMAT_BGRA8: | |
| 30 return BGRA_8888; | |
| 31 case SOURCE_FORMAT_RGBA8: | |
| 32 return RGBA_8888; | |
| 33 } | |
| 34 NOTREACHED(); | |
| 35 return RGBA_8888; | |
| 36 } | |
| 37 | |
| 38 // Returns the most efficient supported texture format for this platform. | |
| 39 static ResourceFormat BestSupportedTextureFormat(bool supports_bgra8888) { | |
| 40 switch (Format()) { | 28 switch (Format()) { |
| 41 case SOURCE_FORMAT_BGRA8: | 29 case SOURCE_FORMAT_BGRA8: |
| 42 return (supports_bgra8888) ? BGRA_8888 : RGBA_8888; | 30 return (supports_bgra8888) ? BGRA_8888 : RGBA_8888; |
| 43 case SOURCE_FORMAT_RGBA8: | 31 case SOURCE_FORMAT_RGBA8: |
| 44 return RGBA_8888; | 32 return RGBA_8888; |
| 45 } | 33 } |
| 46 NOTREACHED(); | 34 NOTREACHED(); |
| 47 return RGBA_8888; | 35 return RGBA_8888; |
| 48 } | 36 } |
| 49 | 37 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 60 return false; | 48 return false; |
| 61 } | 49 } |
| 62 | 50 |
| 63 private: | 51 private: |
| 64 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformColor); | 52 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformColor); |
| 65 }; | 53 }; |
| 66 | 54 |
| 67 } // namespace cc | 55 } // namespace cc |
| 68 | 56 |
| 69 #endif // CC_RESOURCES_PLATFORM_COLOR_H_ | 57 #endif // CC_RESOURCES_PLATFORM_COLOR_H_ |
| OLD | NEW |