Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(867)

Side by Side Diff: cc/resources/platform_color.h

Issue 21159007: cc: Adding support for RGBA_4444 tile textures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed a signed vs. unsigned comparison in video_resource_updater.cc Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.cc ('k') | cc/resources/prioritized_resource.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "third_party/khronos/GLES2/gl2.h" 11 #include "third_party/khronos/GLES2/gl2.h"
11 #include "third_party/khronos/GLES2/gl2ext.h" 12 #include "third_party/khronos/GLES2/gl2ext.h"
12 #include "third_party/skia/include/core/SkTypes.h" 13 #include "third_party/skia/include/core/SkTypes.h"
13 14
14 namespace cc { 15 namespace cc {
15 16
16 class PlatformColor { 17 class PlatformColor {
17 public: 18 public:
18 enum SourceDataFormat { 19 enum SourceDataFormat {
19 SOURCE_FORMAT_RGBA8, 20 SOURCE_FORMAT_RGBA8,
20 SOURCE_FORMAT_BGRA8 21 SOURCE_FORMAT_BGRA8
21 }; 22 };
22 23
23 static SourceDataFormat Format() { 24 static SourceDataFormat Format() {
24 return SK_B32_SHIFT ? SOURCE_FORMAT_RGBA8 : SOURCE_FORMAT_BGRA8; 25 return SK_B32_SHIFT ? SOURCE_FORMAT_RGBA8 : SOURCE_FORMAT_BGRA8;
25 } 26 }
26 27
27 // Returns the most efficient texture format for this platform. 28 // Returns the most efficient texture format for this platform.
28 static GLenum BestTextureFormat(bool supports_bgra8888) { 29 static ResourceFormat BestTextureFormat(bool supports_bgra8888) {
29 switch (Format()) { 30 switch (Format()) {
30 case SOURCE_FORMAT_BGRA8: 31 case SOURCE_FORMAT_BGRA8:
31 if (supports_bgra8888) 32 return (supports_bgra8888) ? BGRA_8888 : RGBA_8888;
32 return GL_BGRA_EXT;
33 return GL_RGBA;
34 case SOURCE_FORMAT_RGBA8: 33 case SOURCE_FORMAT_RGBA8:
35 return GL_RGBA; 34 return RGBA_8888;
36 } 35 }
37 NOTREACHED(); 36 NOTREACHED();
38 return GL_RGBA; 37 return RGBA_8888;
39 } 38 }
40 39
41 // Return true if the given texture format has the same component order 40 // Return true if the given texture format has the same component order
42 // as the color on this platform. 41 // as the color on this platform.
43 static bool SameComponentOrder(GLenum texture_format) { 42 static bool SameComponentOrder(ResourceFormat format) {
44 switch (Format()) { 43 switch (Format()) {
45 case SOURCE_FORMAT_RGBA8: 44 case SOURCE_FORMAT_RGBA8:
46 return texture_format == GL_RGBA; 45 return format == RGBA_8888 || format == RGBA_4444;
47 case SOURCE_FORMAT_BGRA8: 46 case SOURCE_FORMAT_BGRA8:
48 return texture_format == GL_BGRA_EXT; 47 return format == BGRA_8888;
49 } 48 }
50 NOTREACHED(); 49 NOTREACHED();
51 return false; 50 return false;
52 } 51 }
53 52
54 private: 53 private:
55 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformColor); 54 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformColor);
56 }; 55 };
57 56
58 } // namespace cc 57 } // namespace cc
59 58
60 #endif // CC_RESOURCES_PLATFORM_COLOR_H_ 59 #endif // CC_RESOURCES_PLATFORM_COLOR_H_
OLDNEW
« no previous file with comments | « cc/resources/pixel_buffer_raster_worker_pool.cc ('k') | cc/resources/prioritized_resource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698