aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-17 17:23:21 +0000
committerGravatar bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-09-17 17:23:21 +0000
commit7534747e631c49680f7199ccf9e71a359cfa647d (patch)
tree1b51964a307b5449217c78e426b2c3c06175ddbb /include
parent0729b623730983821ef53fad9c988bad030509ed (diff)
Add GrColor to RGBA float helper func
Review URL: https://codereview.appspot.com/6518044/ git-svn-id: http://skia.googlecode.com/svn/trunk@5572 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrColor.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/gpu/GrColor.h b/include/gpu/GrColor.h
index ed666dee26..4318f141dd 100644
--- a/include/gpu/GrColor.h
+++ b/include/gpu/GrColor.h
@@ -58,5 +58,14 @@ static inline GrColor GrColorPackRGBA(unsigned r, unsigned g,
*/
#define GrColor_ILLEGAL (~(0xFF << GrColor_SHIFT_A))
+/** 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;
+ rgba[0] = GrColorUnpackR(color) * ONE_OVER_255;
+ rgba[1] = GrColorUnpackG(color) * ONE_OVER_255;
+ rgba[2] = GrColorUnpackB(color) * ONE_OVER_255;
+ rgba[3] = GrColorUnpackA(color) * ONE_OVER_255;
+}
+
#endif