aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Scroggo <Scroggo@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-11 18:05:38 +0000
committerGravatar Scroggo <Scroggo@2bbb7eff-a529-9590-31e7-b0007b416f81>2011-05-11 18:05:38 +0000
commit01b87ec6a69ae032164105ae5f9e17b87cb5f52c (patch)
treeaa235d580def4b47001a71f736959550273a8627
parentf475a331463de6ba2a27dee5c58f523902d7e4c6 (diff)
Store 1/255 as a constant to reduce number of divides.
git-svn-id: http://skia.googlecode.com/svn/trunk@1301 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--gpu/src/GrGpuGLShaders.cpp30
1 files changed, 12 insertions, 18 deletions
diff --git a/gpu/src/GrGpuGLShaders.cpp b/gpu/src/GrGpuGLShaders.cpp
index 5057791c51..937c8ed422 100644
--- a/gpu/src/GrGpuGLShaders.cpp
+++ b/gpu/src/GrGpuGLShaders.cpp
@@ -396,6 +396,15 @@ void GrGpuGLShaders::flushTexelSize(int s) {
}
}
+static const float ONE_OVER_255 = 1.f / 255.f;
+
+#define GR_COLOR_TO_VEC4(color) {\
+ GrColorUnpackR(color) * ONE_OVER_255,\
+ GrColorUnpackG(color) * ONE_OVER_255,\
+ GrColorUnpackB(color) * ONE_OVER_255,\
+ GrColorUnpackA(color) * ONE_OVER_255 \
+}
+
void GrGpuGLShaders::flushColor() {
const GrGLProgram::ProgramDesc& desc = fCurrentProgram.getDesc();
if (fGeometrySrc.fVertexLayout & kColor_VertexLayoutBit) {
@@ -407,12 +416,7 @@ void GrGpuGLShaders::flushColor() {
case GrGLProgram::ProgramDesc::kAttribute_ColorType:
if (fHWDrawState.fColor != fCurrDrawState.fColor) {
// OpenGL ES only supports the float varities of glVertexAttrib
- float c[] = {
- GrColorUnpackR(fCurrDrawState.fColor) / 255.f,
- GrColorUnpackG(fCurrDrawState.fColor) / 255.f,
- GrColorUnpackB(fCurrDrawState.fColor) / 255.f,
- GrColorUnpackA(fCurrDrawState.fColor) / 255.f
- };
+ float c[] = GR_COLOR_TO_VEC4(fCurrDrawState.fColor);
GR_GL(VertexAttrib4fv(GrGLProgram::ColorAttributeIdx(), c));
fHWDrawState.fColor = fCurrDrawState.fColor;
}
@@ -420,12 +424,7 @@ void GrGpuGLShaders::flushColor() {
case GrGLProgram::ProgramDesc::kUniform_ColorType:
if (fProgramData->fColor != fCurrDrawState.fColor) {
// OpenGL ES only supports the float varities of glVertexAttrib
- float c[] = {
- GrColorUnpackR(fCurrDrawState.fColor) / 255.f,
- GrColorUnpackG(fCurrDrawState.fColor) / 255.f,
- GrColorUnpackB(fCurrDrawState.fColor) / 255.f,
- GrColorUnpackA(fCurrDrawState.fColor) / 255.f
- };
+ float c[] = GR_COLOR_TO_VEC4(fCurrDrawState.fColor);
GrAssert(GrGLProgram::kUnusedUniform !=
fProgramData->fUniLocations.fColorUni);
GR_GL(Uniform4fv(fProgramData->fUniLocations.fColorUni, 1, c));
@@ -443,12 +442,7 @@ void GrGpuGLShaders::flushColor() {
!= GrGLProgram::kUnusedUniform
&& fProgramData->fColorFilterColor
!= fCurrDrawState.fColorFilterColor) {
- float c[] = {
- GrColorUnpackR(fCurrDrawState.fColorFilterColor) / 255.f,
- GrColorUnpackG(fCurrDrawState.fColorFilterColor) / 255.f,
- GrColorUnpackB(fCurrDrawState.fColorFilterColor) / 255.f,
- GrColorUnpackA(fCurrDrawState.fColorFilterColor) / 255.f
- };
+ float c[] = GR_COLOR_TO_VEC4(fCurrDrawState.fColorFilterColor);
GR_GL(Uniform4fv(fProgramData->fUniLocations.fColorFilterUni, 1, c));
fProgramData->fColorFilterColor = fCurrDrawState.fColorFilterColor;
}