From 7534747e631c49680f7199ccf9e71a359cfa647d Mon Sep 17 00:00:00 2001 From: "bsalomon@google.com" Date: Mon, 17 Sep 2012 17:23:21 +0000 Subject: 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 --- include/gpu/GrColor.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') 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 -- cgit v1.2.3