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

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

Issue 22875045: cc: Remove unnecessary "default" cases from switch statements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove changes to enums that require arraysize Created 7 years, 4 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 | Annotate | Revision Log
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 "third_party/khronos/GLES2/gl2.h" 10 #include "third_party/khronos/GLES2/gl2.h"
11 #include "third_party/khronos/GLES2/gl2ext.h" 11 #include "third_party/khronos/GLES2/gl2ext.h"
12 #include "third_party/skia/include/core/SkTypes.h" 12 #include "third_party/skia/include/core/SkTypes.h"
13 13
14 namespace cc { 14 namespace cc {
15 15
16 class PlatformColor { 16 class PlatformColor {
17 public: 17 public:
18 enum SourceDataFormat { 18 enum SourceDataFormat {
19 SOURCE_FORMAT_RGBA8, 19 SOURCE_FORMAT_RGBA8,
20 SOURCE_FORMAT_BGRA8 20 SOURCE_FORMAT_BGRA8
21 }; 21 };
22 22
23 static SourceDataFormat Format() { 23 static SourceDataFormat Format() {
24 return SK_B32_SHIFT ? SOURCE_FORMAT_RGBA8 : SOURCE_FORMAT_BGRA8; 24 return SK_B32_SHIFT ? SOURCE_FORMAT_RGBA8 : SOURCE_FORMAT_BGRA8;
25 } 25 }
26 26
27 // Returns the most efficient texture format for this platform. 27 // Returns the most efficient texture format for this platform.
28 static GLenum BestTextureFormat(bool supports_bgra8888) { 28 static GLenum BestTextureFormat(bool supports_bgra8888) {
29 GLenum texture_format = GL_RGBA;
30 switch (Format()) { 29 switch (Format()) {
31 case SOURCE_FORMAT_RGBA8:
32 break;
33 case SOURCE_FORMAT_BGRA8: 30 case SOURCE_FORMAT_BGRA8:
34 if (supports_bgra8888) 31 if (supports_bgra8888)
35 texture_format = GL_BGRA_EXT; 32 return GL_BGRA_EXT;
36 break; 33 // fall-through
danakj 2013/08/26 15:55:39 how about just return GL_RGBA here?
vmpstr 2013/08/26 16:04:26 +1 :)
reveman 2013/08/26 17:16:57 Done.
37 default: 34 case SOURCE_FORMAT_RGBA8:
38 NOTREACHED(); 35 return GL_RGBA;
39 break;
40 } 36 }
41 return texture_format; 37 NOTREACHED();
38 return GL_RGBA;
42 } 39 }
43 40
44 // Return true if the given texture format has the same component order 41 // Return true if the given texture format has the same component order
45 // as the color on this platform. 42 // as the color on this platform.
46 static bool SameComponentOrder(GLenum texture_format) { 43 static bool SameComponentOrder(GLenum texture_format) {
47 switch (Format()) { 44 switch (Format()) {
48 case SOURCE_FORMAT_RGBA8: 45 case SOURCE_FORMAT_RGBA8:
49 return texture_format == GL_RGBA; 46 return texture_format == GL_RGBA;
50 case SOURCE_FORMAT_BGRA8: 47 case SOURCE_FORMAT_BGRA8:
51 return texture_format == GL_BGRA_EXT; 48 return texture_format == GL_BGRA_EXT;
52 default:
53 NOTREACHED();
54 return false;
55 } 49 }
50 NOTREACHED();
51 return false;
56 } 52 }
57 53
58 private: 54 private:
59 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformColor); 55 DISALLOW_IMPLICIT_CONSTRUCTORS(PlatformColor);
60 }; 56 };
61 57
62 } // namespace cc 58 } // namespace cc
63 59
64 #endif // CC_RESOURCES_PLATFORM_COLOR_H_ 60 #endif // CC_RESOURCES_PLATFORM_COLOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698