diff options
author | 2012-03-05 17:58:34 +0000 | |
---|---|---|
committer | 2012-03-05 17:58:34 +0000 | |
commit | 9b1517edc7eb3e116902a3b3da447a73aaa56585 (patch) | |
tree | 6104f26229fb1e0ddfd4ce9e819c441a2134338b | |
parent | 8c0a0d36541d8385b3e8bddea802c5542800c9a4 (diff) |
minor improvement, remove some conditionals in GrAAConvexPathRenderer
Review URL: http://codereview.appspot.com/5728060
git-svn-id: http://skia.googlecode.com/svn/trunk@3316 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | include/gpu/GrPaint.h | 1 | ||||
-rw-r--r-- | src/gpu/GrAAConvexPathRenderer.cpp | 15 | ||||
-rw-r--r-- | src/gpu/GrContext.cpp | 2 | ||||
-rw-r--r-- | src/gpu/GrDrawState.h | 13 |
4 files changed, 23 insertions, 8 deletions
diff --git a/include/gpu/GrPaint.h b/include/gpu/GrPaint.h index 9f220e07a8..827b89024f 100644 --- a/include/gpu/GrPaint.h +++ b/include/gpu/GrPaint.h @@ -172,7 +172,6 @@ public: void resetColorFilter() { fColorFilterXfermode = SkXfermode::kDst_Mode; fColorFilterColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff); - memset(fColorMatrix, 0, sizeof(fColorMatrix)); fColorMatrixEnabled = false; } diff --git a/src/gpu/GrAAConvexPathRenderer.cpp b/src/gpu/GrAAConvexPathRenderer.cpp index 60749d81c0..657dfc1ee2 100644 --- a/src/gpu/GrAAConvexPathRenderer.cpp +++ b/src/gpu/GrAAConvexPathRenderer.cpp @@ -22,9 +22,11 @@ namespace { struct Segment { enum { - kLine, - kQuad + // These enum values are assumed in member functions below. + kLine = 0, + kQuad = 1, } fType; + // line uses one pt, quad uses 2 pts GrPoint fPts[2]; // normal to edge ending at each pt @@ -34,13 +36,16 @@ struct Segment { GrVec fMid; int countPoints() { - return (kLine == fType) ? 1 : 2; + GR_STATIC_ASSERT(0 == kLine && 1 == kQuad); + return fType + 1; } const SkPoint& endPt() const { - return (kLine == fType) ? fPts[0] : fPts[1]; + GR_STATIC_ASSERT(0 == kLine && 1 == kQuad); + return fPts[fType]; }; const SkPoint& endNorm() const { - return (kLine == fType) ? fNorms[0] : fNorms[1]; + GR_STATIC_ASSERT(0 == kLine && 1 == kQuad); + return fNorms[fType]; }; }; diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp index 2a12399555..2c4a131b38 100644 --- a/src/gpu/GrContext.cpp +++ b/src/gpu/GrContext.cpp @@ -1839,12 +1839,12 @@ void GrContext::setPaint(const GrPaint& paint, GrDrawTarget* target) { } if (paint.fColorMatrixEnabled) { drawState->enableState(GrDrawState::kColorMatrix_StateBit); + drawState->setColorMatrix(paint.fColorMatrix); } else { drawState->disableState(GrDrawState::kColorMatrix_StateBit); } drawState->setBlendFunc(paint.fSrcBlendCoeff, paint.fDstBlendCoeff); drawState->setColorFilter(paint.fColorFilterColor, paint.fColorFilterXfermode); - drawState->setColorMatrix(paint.fColorMatrix); drawState->setCoverage(paint.fCoverage); if (paint.getActiveMaskStageMask() && !target->canApplyCoverage()) { diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h index 18dd6bf406..7350f0f16f 100644 --- a/src/gpu/GrDrawState.h +++ b/src/gpu/GrDrawState.h @@ -749,6 +749,13 @@ struct GrDrawState { return false; } } + if (kColorMatrix_StateBit & s.fFlagBits) { + if (memcmp(fColorMatrix, + s.fColorMatrix, + sizeof(fColorMatrix))) { + return false; + } + } return true; } @@ -765,6 +772,9 @@ struct GrDrawState { sizeof(GrSamplerState)); } } + if (kColorMatrix_StateBit & s.fFlagBits) { + memcpy(this->fColorMatrix, s.fColorMatrix, sizeof(fColorMatrix)); + } return *this; } @@ -779,7 +789,6 @@ private: DrawFace fDrawFace; VertexEdgeType fVertexEdgeType; GrStencilSettings fStencilSettings; - float fColorMatrix[20]; // 5 x 4 matrix GrRenderTarget* fRenderTarget; // @} @@ -803,6 +812,8 @@ private: // This field must be last; it will not be copied or compared // if the corresponding fTexture[] is NULL. GrSamplerState fSamplerStates[kNumStages]; + // only compared if the color matrix enable flag is set + float fColorMatrix[20]; // 5 x 4 matrix size_t leadingBytes() const { // Can't use offsetof() with non-POD types, so stuck with pointer math. |