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
This commit is contained in:
bsalomon@google.com 2012-03-05 17:58:34 +00:00
Родитель 8c0a0d3654
Коммит 9b1517edc7
4 изменённых файлов: 23 добавлений и 8 удалений

Просмотреть файл

@ -172,7 +172,6 @@ public:
void resetColorFilter() {
fColorFilterXfermode = SkXfermode::kDst_Mode;
fColorFilterColor = GrColorPackRGBA(0xff, 0xff, 0xff, 0xff);
memset(fColorMatrix, 0, sizeof(fColorMatrix));
fColorMatrixEnabled = false;
}

Просмотреть файл

@ -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];
};
};

Просмотреть файл

@ -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()) {

Просмотреть файл

@ -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.