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

Unified Diff: include/gpu/GrColor.h

Issue 211683002: Add discard API to SkCanvas, plumb it to glDiscardFramebuffer() (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: move to ToT Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/core/SkCanvas.h ('k') | include/gpu/GrContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrColor.h
diff --git a/include/gpu/GrColor.h b/include/gpu/GrColor.h
index cf7e7df8431b2ee3f09c7eba9bc5d85f96b725eb..b0bce3f9b5f2dff0bdd0c00d3e1114e5c74a76a0 100644
--- a/include/gpu/GrColor.h
+++ b/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;
« no previous file with comments | « include/core/SkCanvas.h ('k') | include/gpu/GrContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698