summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/skia/include/gpu/GrColor.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/skia/include/gpu/GrColor.h')
-rw-r--r--chromium/third_party/skia/include/gpu/GrColor.h47
1 files changed, 36 insertions, 11 deletions
diff --git a/chromium/third_party/skia/include/gpu/GrColor.h b/chromium/third_party/skia/include/gpu/GrColor.h
index cf7e7df8431..1994cc50107 100644
--- a/chromium/third_party/skia/include/gpu/GrColor.h
+++ b/chromium/third_party/skia/include/gpu/GrColor.h
@@ -14,21 +14,26 @@
#include "GrTypes.h"
/**
- * GrColor is 4 bytes for R, G, B, A, in a compile-time specific order. The
- * components are stored premultiplied.
+ * GrColor is 4 bytes for R, G, B, A, in a specific order defined below. The components are stored
+ * premultiplied.
*/
typedef uint32_t GrColor;
-
// shift amount to assign a component to a GrColor int
// These shift values are chosen for compatibility with GL attrib arrays
// ES doesn't allow BGRA vertex attrib order so if they were not in this order
-// we'd have to swizzle in shaders. Note the assumption that the cpu is little
-// endian.
-#define GrColor_SHIFT_R 0
-#define GrColor_SHIFT_G 8
-#define GrColor_SHIFT_B 16
-#define GrColor_SHIFT_A 24
+// we'd have to swizzle in shaders.
+#ifdef SK_CPU_BENDIAN
+ #define GrColor_SHIFT_R 24
+ #define GrColor_SHIFT_G 16
+ #define GrColor_SHIFT_B 8
+ #define GrColor_SHIFT_A 0
+#else
+ #define GrColor_SHIFT_R 0
+ #define GrColor_SHIFT_G 8
+ #define GrColor_SHIFT_B 16
+ #define GrColor_SHIFT_A 24
+#endif
/**
* Pack 4 components (RGBA) into a GrColor int
@@ -58,6 +63,22 @@ static inline GrColor GrColorPackRGBA(unsigned r, unsigned g,
*/
#define GrColor_ILLEGAL (~(0xFF << GrColor_SHIFT_A))
+/**
+ * Assert in debug builds that a GrColor is premultiplied.
+ */
+static inline void GrColorIsPMAssert(GrColor c) {
+#ifdef SK_DEBUG
+ unsigned a = GrColorUnpackA(c);
+ unsigned r = GrColorUnpackR(c);
+ unsigned g = GrColorUnpackG(c);
+ unsigned b = GrColorUnpackB(c);
+
+ SkASSERT(r <= a);
+ SkASSERT(g <= a);
+ SkASSERT(b <= a);
+#endif
+}
+
/** Converts a GrColor to an rgba array of GrGLfloat */
static inline void GrColorToRGBAFloat(GrColor color, float rgba[4]) {
static const float ONE_OVER_255 = 1.f / 255.f;
@@ -85,7 +106,7 @@ enum GrColorComponentFlags {
};
static inline char GrColorComponentFlagToChar(GrColorComponentFlags component) {
- SkASSERT(GrIsPow2(component));
+ SkASSERT(SkIsPow2(component));
switch (component) {
case kR_GrColorComponentFlag:
return 'r';
@@ -96,7 +117,7 @@ static inline char GrColorComponentFlagToChar(GrColorComponentFlags component) {
case kA_GrColorComponentFlag:
return 'a';
default:
- GrCrash("Invalid color component flag.");
+ SkFAIL("Invalid color component flag.");
return '\0';
}
}
@@ -111,6 +132,8 @@ static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) {
kRGBA_GrColorComponentFlags, // kRGBA_4444_GrPixelConfig
kRGBA_GrColorComponentFlags, // kRGBA_8888_GrPixelConfig
kRGBA_GrColorComponentFlags, // kBGRA_8888_GrPixelConfig
+ kRGB_GrColorComponentFlags, // kETC1_GrPixelConfig
+ kA_GrColorComponentFlag, // kLATC_GrPixelConfig
};
return kFlags[config];
@@ -121,6 +144,8 @@ static inline uint32_t GrPixelConfigComponentMask(GrPixelConfig config) {
GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig);
GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig);
GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig);
+ GR_STATIC_ASSERT(7 == kETC1_GrPixelConfig);
+ GR_STATIC_ASSERT(8 == kLATC_GrPixelConfig);
GR_STATIC_ASSERT(SK_ARRAY_COUNT(kFlags) == kGrPixelConfigCnt);
}