aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar bsalomon <bsalomon@google.com>2014-11-19 12:36:22 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2014-11-19 12:36:22 -0800
commit04ddf89627077ea8f2b447e7cd5e902956341a32 (patch)
tree3fabea710800da027b76866671d3cb58fb7aa437 /src
parent158fcaa031d105dc999d9813fee8927db56a871c (diff)
Small cleanups after GrDrawState/GrOptDrawState base class elimination.
Diffstat (limited to 'src')
-rw-r--r--src/gpu/GrDrawState.cpp28
-rw-r--r--src/gpu/GrDrawState.h76
-rw-r--r--src/gpu/GrGpu.h1
-rw-r--r--src/gpu/GrOptDrawState.cpp70
-rw-r--r--src/gpu/GrOptDrawState.h115
-rw-r--r--src/gpu/gl/GrGpuGL.cpp2
-rw-r--r--src/gpu/gl/GrGpuGL.h2
-rw-r--r--src/gpu/gl/builders/GrGLProgramBuilder.h1
8 files changed, 94 insertions, 201 deletions
diff --git a/src/gpu/GrDrawState.cpp b/src/gpu/GrDrawState.cpp
index fef549463a..7538cdb340 100644
--- a/src/gpu/GrDrawState.cpp
+++ b/src/gpu/GrDrawState.cpp
@@ -194,7 +194,7 @@ void GrDrawState::setFromPaint(const GrPaint& paint, const SkMatrix& vm, GrRende
fBlendConstant = 0x0;
fDrawFace = kBoth_DrawFace;
fStencilSettings.setDisabled();
- this->resetStateFlags();
+ fFlagBits = 0;
fHints = 0;
// Enable the clip bit
@@ -341,8 +341,8 @@ bool GrDrawState::couldApplyCoverage(const GrDrawTargetCaps& caps) const {
// or c) the src, dst blend coeffs are 1,0 and we will read Dst Color
GrBlendCoeff srcCoeff;
GrBlendCoeff dstCoeff;
- BlendOptFlags flag = this->getBlendOpts(true, &srcCoeff, &dstCoeff);
- return GrDrawState::kNone_BlendOpt != flag ||
+ BlendOpt opt = this->getBlendOpt(true, &srcCoeff, &dstCoeff);
+ return GrDrawState::kNone_BlendOpt != opt ||
(this->willEffectReadDstColor() &&
kOne_GrBlendCoeff == srcCoeff && kZero_GrBlendCoeff == dstCoeff);
}
@@ -538,9 +538,9 @@ GrDrawState::~GrDrawState() {
////////////////////////////////////////////////////////////////////////////////
-GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage,
- GrBlendCoeff* srcCoeff,
- GrBlendCoeff* dstCoeff) const {
+GrDrawState::BlendOpt GrDrawState::getBlendOpt(bool forceCoverage,
+ GrBlendCoeff* srcCoeff,
+ GrBlendCoeff* dstCoeff) const {
GrBlendCoeff bogusSrcCoeff, bogusDstCoeff;
if (NULL == srcCoeff) {
srcCoeff = &bogusSrcCoeff;
@@ -568,10 +568,10 @@ GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage,
// (0,1).
if ((kZero_GrBlendCoeff == *srcCoeff && dstCoeffIsOne)) {
if (this->getStencil().doesWrite()) {
- return kEmitCoverage_BlendOptFlag;
+ return kEmitCoverage_BlendOpt;
} else {
*dstCoeff = kOne_GrBlendCoeff;
- return kSkipDraw_BlendOptFlag;
+ return kSkipDraw_BlendOpt;
}
}
@@ -591,17 +591,17 @@ GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage,
// or blend, just write transparent black into the dst.
*srcCoeff = kOne_GrBlendCoeff;
*dstCoeff = kZero_GrBlendCoeff;
- return kEmitTransBlack_BlendOptFlag;
+ return kEmitTransBlack_BlendOpt;
}
}
} else if (this->isCoverageDrawing()) {
// we have coverage but we aren't distinguishing it from alpha by request.
- return kCoverageAsAlpha_BlendOptFlag;
+ return kCoverageAsAlpha_BlendOpt;
} else {
// check whether coverage can be safely rolled into alpha
// of if we can skip color computation and just emit coverage
if (this->canTweakAlphaForCoverage()) {
- return kCoverageAsAlpha_BlendOptFlag;
+ return kCoverageAsAlpha_BlendOpt;
}
if (dstCoeffIsZero) {
if (kZero_GrBlendCoeff == *srcCoeff) {
@@ -609,20 +609,20 @@ GrDrawState::BlendOptFlags GrDrawState::getBlendOpts(bool forceCoverage,
// the dst coeff is effectively zero so blend works out to:
// (c)(0)D + (1-c)D = (1-c)D.
*dstCoeff = kISA_GrBlendCoeff;
- return kEmitCoverage_BlendOptFlag;
+ return kEmitCoverage_BlendOpt;
} else if (srcAIsOne) {
// the dst coeff is effectively zero so blend works out to:
// cS + (c)(0)D + (1-c)D = cS + (1-c)D.
// If Sa is 1 then we can replace Sa with c
// and set dst coeff to 1-Sa.
*dstCoeff = kISA_GrBlendCoeff;
- return kCoverageAsAlpha_BlendOptFlag;
+ return kCoverageAsAlpha_BlendOpt;
}
} else if (dstCoeffIsOne) {
// the dst coeff is effectively one so blend works out to:
// cS + (c)(1)D + (1-c)D = cS + D.
*dstCoeff = kOne_GrBlendCoeff;
- return kCoverageAsAlpha_BlendOptFlag;
+ return kCoverageAsAlpha_BlendOpt;
}
}
diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
index 4b1016001a..a049f1d807 100644
--- a/src/gpu/GrDrawState.h
+++ b/src/gpu/GrDrawState.h
@@ -21,7 +21,6 @@
#include "effects/GrSimpleTextureEffect.h"
class GrDrawTargetCaps;
-class GrOptDrawState;
class GrPaint;
class GrTexture;
@@ -417,10 +416,8 @@ public:
* @param dstCoef coefficient applied to the dst color.
*/
void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
- if (srcCoeff != fSrcBlend || dstCoeff != fDstBlend) {
- fSrcBlend = srcCoeff;
- fDstBlend = dstCoeff;
- }
+ fSrcBlend = srcCoeff;
+ fDstBlend = dstCoeff;
#ifdef SK_DEBUG
if (GrBlendCoeffRefsDst(dstCoeff)) {
SkDebugf("Unexpected dst blend coeff. Won't work correctly with coverage stages.\n");
@@ -441,11 +438,7 @@ public:
*
* @param constant the constant to set
*/
- void setBlendConstant(GrColor constant) {
- if (constant != fBlendConstant) {
- fBlendConstant = constant;
- }
- }
+ void setBlendConstant(GrColor constant) { fBlendConstant = constant; }
/// @}
@@ -557,20 +550,12 @@ public:
* using stencil should not change the clip between passes.
* @param settings the stencil settings to use.
*/
- void setStencil(const GrStencilSettings& settings) {
- if (settings != fStencilSettings) {
- fStencilSettings = settings;
- }
- }
+ void setStencil(const GrStencilSettings& settings) { fStencilSettings = settings; }
/**
* Shortcut to disable stencil testing and ops.
*/
- void disableStencil() {
- if (!fStencilSettings.isDisabled()) {
- fStencilSettings.setDisabled();
- }
- }
+ void disableStencil() { fStencilSettings.setDisabled(); }
GrStencilSettings* stencil() { return &fStencilSettings; }
@@ -617,41 +602,25 @@ public:
kLast_StateBit = kCoverageDrawing_StateBit,
};
- uint32_t getFlagBits() const { return fFlagBits; }
-
- bool isStateFlagEnabled(uint32_t stateBit) const { return 0 != (stateBit & fFlagBits); }
-
bool isClipState() const { return 0 != (fFlagBits & kClip_StateBit); }
bool isColorWriteDisabled() const { return 0 != (fFlagBits & kNoColorWrites_StateBit); }
bool isCoverageDrawing() const { return 0 != (fFlagBits & kCoverageDrawing_StateBit); }
-
- void resetStateFlags() {
- if (0 != fFlagBits) {
- fFlagBits = 0;
- }
- }
+ bool isDither() const { return 0 != (fFlagBits & kDither_StateBit); }
+ bool isHWAntialias() const { return 0 != (fFlagBits & kHWAntialias_StateBit); }
/**
* Enable render state settings.
*
* @param stateBits bitfield of StateBits specifying the states to enable
*/
- void enableState(uint32_t stateBits) {
- if (stateBits & ~fFlagBits) {
- fFlagBits |= stateBits;
- }
- }
+ void enableState(uint32_t stateBits) { fFlagBits |= stateBits; }
/**
* Disable render state settings.
*
* @param stateBits bitfield of StateBits specifying the states to disable
*/
- void disableState(uint32_t stateBits) {
- if (stateBits & fFlagBits) {
- fFlagBits &= ~(stateBits);
- }
- }
+ void disableState(uint32_t stateBits) { fFlagBits &= ~(stateBits); }
/**
* Enable or disable stateBits based on a boolean.
@@ -725,31 +694,30 @@ private:
/**
* Optimizations for blending / coverage to that can be applied based on the current state.
*/
- enum BlendOptFlags {
+ enum BlendOpt {
/**
* No optimization
*/
- kNone_BlendOpt = 0,
+ kNone_BlendOpt,
/**
* Don't draw at all
*/
- kSkipDraw_BlendOptFlag = 0x1,
+ kSkipDraw_BlendOpt,
/**
* The coverage value does not have to be computed separately from alpha, the the output
* color can be the modulation of the two.
*/
- kCoverageAsAlpha_BlendOptFlag = 0x2,
+ kCoverageAsAlpha_BlendOpt,
/**
* Instead of emitting a src color, emit coverage in the alpha channel and r,g,b are
* "don't cares".
*/
- kEmitCoverage_BlendOptFlag = 0x4,
+ kEmitCoverage_BlendOpt,
/**
* Emit transparent black instead of the src color, no need to compute coverage.
*/
- kEmitTransBlack_BlendOptFlag = 0x8,
+ kEmitTransBlack_BlendOpt
};
- GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags);
/**
* Determines what optimizations can be applied based on the blend. The coefficients may have
@@ -758,15 +726,11 @@ private:
* state to see if coverage is enabled. By setting forceCoverage the caller can speculatively
* determine the blend optimizations that would be used if there was partial pixel coverage.
*
- * Subclasses of GrDrawTarget that actually draw (as opposed to those that just buffer for
- * playback) must call this function and respect the flags that replace the output color.
- *
- * If the cached BlendOptFlags does not have the invalidate bit set, then getBlendOpts will
- * simply returned the cached flags and coefficients. Otherwise it will calculate the values.
+ * This is used internally and when constructing a GrOptDrawState.
*/
- BlendOptFlags getBlendOpts(bool forceCoverage = false,
- GrBlendCoeff* srcCoeff = NULL,
- GrBlendCoeff* dstCoeff = NULL) const;
+ BlendOpt getBlendOpt(bool forceCoverage = false,
+ GrBlendCoeff* srcCoeff = NULL,
+ GrBlendCoeff* dstCoeff = NULL) const;
const GrProcOptInfo& colorProcInfo() const {
this->calcColorInvariantOutput();
@@ -835,6 +799,4 @@ private:
friend class GrOptDrawState;
};
-GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags);
-
#endif
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 94a0914843..987e06724b 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -15,6 +15,7 @@
class GrContext;
class GrIndexBufferAllocPool;
+class GrOptDrawState;
class GrPath;
class GrPathRange;
class GrPathRenderer;
diff --git a/src/gpu/GrOptDrawState.cpp b/src/gpu/GrOptDrawState.cpp
index 2435e5fc33..93cc04798b 100644
--- a/src/gpu/GrOptDrawState.cpp
+++ b/src/gpu/GrOptDrawState.cpp
@@ -14,7 +14,7 @@
#include "GrProcOptInfo.h"
GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
- BlendOptFlags blendOptFlags,
+ GrDrawState::BlendOpt blendOpt,
GrBlendCoeff optSrcCoeff,
GrBlendCoeff optDstCoeff,
GrGpu* gpu,
@@ -25,17 +25,26 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
fScissorState = scissorState;
fViewMatrix = drawState.getViewMatrix();
fBlendConstant = drawState.getBlendConstant();
- fFlagBits = drawState.getFlagBits();
fVAPtr = drawState.getVertexAttribs();
fVACount = drawState.getVertexAttribCount();
fVAStride = drawState.getVertexStride();
fStencilSettings = drawState.getStencil();
- fDrawFace = (DrawFace)drawState.getDrawFace();
- fBlendOptFlags = blendOptFlags;
+ fDrawFace = drawState.getDrawFace();
fSrcBlend = optSrcCoeff;
fDstBlend = optDstCoeff;
GrProgramDesc::DescInfo descInfo;
+ fFlags = 0;
+ if (drawState.isHWAntialias()) {
+ fFlags |= kHWAA_Flag;
+ }
+ if (drawState.isColorWriteDisabled()) {
+ fFlags |= kDisableColorWrite_Flag;
+ }
+ if (drawState.isDither()) {
+ fFlags |= kDither_Flag;
+ }
+
memcpy(descInfo.fFixedFunctionVertexAttribIndices,
drawState.getFixedFunctionVertexAttribIndices(),
sizeof(descInfo.fFixedFunctionVertexAttribIndices));
@@ -56,8 +65,8 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
descInfo.fInputCoverageIsUsed = true;
fCoverage = drawState.getCoverage();
- this->adjustFromBlendOpts(drawState, &descInfo, &firstColorStageIdx, &firstCoverageStageIdx,
- &fixedFunctionVAToRemove);
+ this->adjustProgramForBlendOpt(drawState, blendOpt, &descInfo, &firstColorStageIdx,
+ &firstCoverageStageIdx, &fixedFunctionVAToRemove);
// Should not be setting any more FFVA to be removed at this point
if (0 != fixedFunctionVAToRemove) {
this->removeFixedFunctionVertexAttribs(fixedFunctionVAToRemove, &descInfo);
@@ -85,7 +94,7 @@ GrOptDrawState::GrOptDrawState(const GrDrawState& drawState,
(drawState.fCoverageStages[i], explicitLocalCoords));
}
- this->setOutputStateInfo(drawState, *gpu->caps(), &descInfo);
+ this->setOutputStateInfo(drawState, blendOpt, *gpu->caps(), &descInfo);
// now create a key
gpu->buildProgramDesc(*this, descInfo, drawType, dstCopy, &fDesc);
@@ -98,9 +107,7 @@ GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState,
GrGpu::DrawType drawType) {
GrBlendCoeff srcCoeff;
GrBlendCoeff dstCoeff;
- BlendOptFlags blendFlags = (BlendOptFlags) drawState.getBlendOpts(false,
- &srcCoeff,
- &dstCoeff);
+ GrDrawState::BlendOpt blendOpt = drawState.getBlendOpt(false, &srcCoeff, &dstCoeff);
// If our blend coeffs are set to 0,1 we know we will not end up drawing unless we are
// stenciling. When path rendering the stencil settings are not always set on the draw state
@@ -111,23 +118,23 @@ GrOptDrawState* GrOptDrawState::Create(const GrDrawState& drawState,
return NULL;
}
- return SkNEW_ARGS(GrOptDrawState, (drawState, blendFlags, srcCoeff,
+ return SkNEW_ARGS(GrOptDrawState, (drawState, blendOpt, srcCoeff,
dstCoeff, gpu, scissorState, dstCopy, drawType));
}
void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
+ GrDrawState::BlendOpt blendOpt,
const GrDrawTargetCaps& caps,
GrProgramDesc::DescInfo* descInfo) {
// Set this default and then possibly change our mind if there is coverage.
descInfo->fPrimaryOutputType = GrProgramDesc::kModulate_PrimaryOutputType;
descInfo->fSecondaryOutputType = GrProgramDesc::kNone_SecondaryOutputType;
- // If we do have coverage determine whether it matters. Dual source blending is expensive so
- // we don't do it if we are doing coverage drawing. If we aren't then We always do dual source
- // blending if we have any effective coverage stages OR the geometry processor doesn't emits
- // solid coverage.
- // TODO move the gp logic into the GP base class
- if (!this->isCoverageDrawing() && !ds.hasSolidCoverage()) {
+ // Determine whether we should use dual source blending or shader code to keep coverage
+ // separate from color.
+ bool keepCoverageSeparate = !(GrDrawState::kCoverageAsAlpha_BlendOpt == blendOpt ||
+ GrDrawState::kEmitCoverage_BlendOpt == blendOpt);
+ if (keepCoverageSeparate && !ds.hasSolidCoverage()) {
if (caps.dualSourceBlendingSupport()) {
if (kZero_GrBlendCoeff == fDstBlend) {
// write the coverage value to second color
@@ -150,25 +157,24 @@ void GrOptDrawState::setOutputStateInfo(const GrDrawState& ds,
}
}
-void GrOptDrawState::adjustFromBlendOpts(const GrDrawState& ds,
- GrProgramDesc::DescInfo* descInfo,
- int* firstColorStageIdx,
- int* firstCoverageStageIdx,
- uint8_t* fixedFunctionVAToRemove) {
- switch (fBlendOptFlags) {
- case kNone_BlendOpt:
- case kSkipDraw_BlendOptFlag:
- break;
- case kCoverageAsAlpha_BlendOptFlag:
- fFlagBits |= kCoverageDrawing_StateBit;
+void GrOptDrawState::adjustProgramForBlendOpt(const GrDrawState& ds,
+ GrDrawState::BlendOpt blendOpt,
+ GrProgramDesc::DescInfo* descInfo,
+ int* firstColorStageIdx,
+ int* firstCoverageStageIdx,
+ uint8_t* fixedFunctionVAToRemove) {
+ switch (blendOpt) {
+ case GrDrawState::kNone_BlendOpt:
+ case GrDrawState::kSkipDraw_BlendOpt:
+ case GrDrawState::kCoverageAsAlpha_BlendOpt:
break;
- case kEmitCoverage_BlendOptFlag:
+ case GrDrawState::kEmitCoverage_BlendOpt:
fColor = 0xffffffff;
descInfo->fInputColorIsUsed = true;
*firstColorStageIdx = ds.numColorStages();
*fixedFunctionVAToRemove |= 0x1 << kColor_GrVertexAttribBinding;
break;
- case kEmitTransBlack_BlendOptFlag:
+ case GrDrawState::kEmitTransBlack_BlendOpt:
fColor = 0;
fCoverage = 0xff;
descInfo->fInputColorIsUsed = true;
@@ -178,8 +184,6 @@ void GrOptDrawState::adjustFromBlendOpts(const GrDrawState& ds,
*fixedFunctionVAToRemove |= (0x1 << kColor_GrVertexAttribBinding |
0x1 << kCoverage_GrVertexAttribBinding);
break;
- default:
- SkFAIL("Unknown BlendOptFlag");
}
}
@@ -269,7 +273,7 @@ bool GrOptDrawState::operator== (const GrOptDrawState& that) const {
this->fSrcBlend != that.fSrcBlend ||
this->fDstBlend != that.fDstBlend ||
this->fBlendConstant != that.fBlendConstant ||
- this->fFlagBits != that.fFlagBits ||
+ this->fFlags != that.fFlags ||
this->fVACount != that.fVACount ||
this->fVAStride != that.fVAStride ||
memcmp(this->fVAPtr, that.fVAPtr, this->fVACount * sizeof(GrVertexAttrib)) ||
diff --git a/src/gpu/GrOptDrawState.h b/src/gpu/GrOptDrawState.h
index 903b227891..0bb3d07f89 100644
--- a/src/gpu/GrOptDrawState.h
+++ b/src/gpu/GrOptDrawState.h
@@ -176,34 +176,21 @@ public:
///////////////////////////////////////////////////////////////////////////
- /// @name State Flags
+ /// @name Boolean Queries
////
- bool isDitherState() const { return 0 != (fFlagBits & kDither_StateBit); }
- bool isHWAntialiasState() const { return 0 != (fFlagBits & kHWAntialias_StateBit); }
- bool isColorWriteDisabled() const { return 0 != (fFlagBits & kNoColorWrites_StateBit); }
- bool isCoverageDrawing() const { return 0 != (fFlagBits & kCoverageDrawing_StateBit); }
+ bool isDitherState() const { return SkToBool(fFlags & kDither_Flag); }
+ bool isHWAntialiasState() const { return SkToBool(fFlags & kHWAA_Flag); }
+ bool isColorWriteDisabled() const { return SkToBool(fFlags & kDisableColorWrite_Flag); }
/// @}
- ///////////////////////////////////////////////////////////////////////////
- /// @name Face Culling
- ////
-
- enum DrawFace {
- kInvalid_DrawFace = -1,
-
- kBoth_DrawFace,
- kCCW_DrawFace,
- kCW_DrawFace,
- };
-
/**
* Gets whether the target is drawing clockwise, counterclockwise,
* or both faces.
* @return the current draw face(s).
*/
- DrawFace getDrawFace() const { return fDrawFace; }
+ GrDrawState::DrawFace getDrawFace() const { return fDrawFace; }
/// @}
@@ -213,72 +200,10 @@ public:
const GrProgramDesc& programDesc() const { return fDesc; }
private:
- // This is lifted from GrDrawState. This should be revised and made specific to this class/
- enum StateBits {
- /**
- * Perform dithering. TODO: Re-evaluate whether we need this bit
- */
- kDither_StateBit = 0x01,
- /**
- * Perform HW anti-aliasing. This means either HW FSAA, if supported by the render target,
- * or smooth-line rendering if a line primitive is drawn and line smoothing is supported by
- * the 3D API.
- */
- kHWAntialias_StateBit = 0x02,
- /**
- * Draws will respect the clip, otherwise the clip is ignored.
- */
- kClip_StateBit = 0x04,
- /**
- * Disables writing to the color buffer. Useful when performing stencil
- * operations.
- */
- kNoColorWrites_StateBit = 0x08,
-
- /**
- * Usually coverage is applied after color blending. The color is blended using the coeffs
- * specified by setBlendFunc(). The blended color is then combined with dst using coeffs
- * of src_coverage, 1-src_coverage. Sometimes we are explicitly drawing a coverage mask. In
- * this case there is no distinction between coverage and color and the caller needs direct
- * control over the blend coeffs. When set, there will be a single blend step controlled by
- * setBlendFunc() which will use coverage*color as the src color.
- */
- kCoverageDrawing_StateBit = 0x10
- };
-
- /**
- * Optimizations for blending / coverage to that can be applied based on the current state.
- */
- enum BlendOptFlags {
- /**
- * No optimization
- */
- kNone_BlendOpt = 0,
- /**
- * Don't draw at all
- */
- kSkipDraw_BlendOptFlag = 0x1,
- /**
- * The coverage value does not have to be computed separately from alpha, the the output
- * color can be the modulation of the two.
- */
- kCoverageAsAlpha_BlendOptFlag = 0x2,
- /**
- * Instead of emitting a src color, emit coverage in the alpha channel and r,g,b are
- * "don't cares".
- */
- kEmitCoverage_BlendOptFlag = 0x4,
- /**
- * Emit transparent black instead of the src color, no need to compute coverage.
- */
- kEmitTransBlack_BlendOptFlag = 0x8,
- };
- GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags);
-
/**
* Constructs and optimized drawState out of a GrRODrawState.
*/
- GrOptDrawState(const GrDrawState& drawState, BlendOptFlags blendOptFlags,
+ GrOptDrawState(const GrDrawState& drawState, GrDrawState::BlendOpt,
GrBlendCoeff optSrcCoeff, GrBlendCoeff optDstCoeff,
GrGpu*, const ScissorState&, const GrDeviceCoordTexture* dstCopy,
GrGpu::DrawType);
@@ -308,12 +233,12 @@ private:
void removeFixedFunctionVertexAttribs(uint8_t removeVAFlags, GrProgramDesc::DescInfo*);
/**
- * Alter the OptDrawState (adjusting stages, vertex attribs, flags, etc.) based on the
- * BlendOptFlags.
+ * Alter the program desc and inputs (attribs and processors) based on the blend optimization.
*/
- void adjustFromBlendOpts(const GrDrawState& ds, GrProgramDesc::DescInfo*,
- int* firstColorStageIdx, int* firstCoverageStageIdx,
- uint8_t* fixedFunctionVAToRemove);
+ void adjustProgramForBlendOpt(const GrDrawState& ds, GrDrawState::BlendOpt,
+ GrProgramDesc::DescInfo*,
+ int* firstColorStageIdx, int* firstCoverageStageIdx,
+ uint8_t* fixedFunctionVAToRemove);
/**
* Loop over the effect stages to determine various info like what data they will read and what
@@ -327,9 +252,15 @@ private:
* the function may adjust the blend coefficients. After this function is called the src and dst
* blend coeffs will represent those used by backend API.
*/
- void setOutputStateInfo(const GrDrawState& ds, const GrDrawTargetCaps&,
+ void setOutputStateInfo(const GrDrawState& ds, GrDrawState::BlendOpt, const GrDrawTargetCaps&,
GrProgramDesc::DescInfo*);
+ enum Flags {
+ kDither_Flag = 0x1,
+ kHWAA_Flag = 0x2,
+ kDisableColorWrite_Flag = 0x4,
+ };
+
typedef GrPendingIOResource<GrRenderTarget, kWrite_GrIOType> RenderTarget;
typedef SkSTArray<8, GrPendingFragmentStage> FragmentStageArray;
typedef GrPendingProgramElement<const GrGeometryProcessor> ProgramGeometryProcessor;
@@ -338,16 +269,15 @@ private:
GrColor fColor;
SkMatrix fViewMatrix;
GrColor fBlendConstant;
- uint32_t fFlagBits;
const GrVertexAttrib* fVAPtr;
int fVACount;
size_t fVAStride;
GrStencilSettings fStencilSettings;
uint8_t fCoverage;
- DrawFace fDrawFace;
+ GrDrawState::DrawFace fDrawFace;
GrBlendCoeff fSrcBlend;
GrBlendCoeff fDstBlend;
-
+ uint32_t fFlags;
ProgramGeometryProcessor fGeometryProcessor;
FragmentStageArray fFragmentStages;
@@ -356,14 +286,9 @@ private:
SkAutoSTArray<4, GrVertexAttrib> fOptVA;
- BlendOptFlags fBlendOptFlags;
-
GrProgramDesc fDesc;
typedef SkRefCnt INHERITED;
};
-GR_MAKE_BITFIELD_OPS(GrOptDrawState::BlendOptFlags);
-
#endif
-
diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp
index a17329f69f..9e1f754a82 100644
--- a/src/gpu/gl/GrGpuGL.cpp
+++ b/src/gpu/gl/GrGpuGL.cpp
@@ -241,7 +241,7 @@ void GrGpuGL::onResetContext(uint32_t resetBits) {
GL_CALL(Disable(GR_GL_DEPTH_TEST));
GL_CALL(DepthMask(GR_GL_FALSE));
- fHWDrawFace = GrOptDrawState::kInvalid_DrawFace;
+ fHWDrawFace = GrDrawState::kInvalid_DrawFace;
fHWDitherEnabled = kUnknown_TriState;
if (kGL_GrGLStandard == this->glStandard()) {
diff --git a/src/gpu/gl/GrGpuGL.h b/src/gpu/gl/GrGpuGL.h
index 059a08e52d..8212f9e617 100644
--- a/src/gpu/gl/GrGpuGL.h
+++ b/src/gpu/gl/GrGpuGL.h
@@ -442,7 +442,7 @@ private:
TriState fHWStencilTestEnabled;
- GrOptDrawState::DrawFace fHWDrawFace;
+ GrDrawState::DrawFace fHWDrawFace;
TriState fHWWriteToColor;
TriState fHWDitherEnabled;
uint32_t fHWBoundRenderTargetUniqueID;
diff --git a/src/gpu/gl/builders/GrGLProgramBuilder.h b/src/gpu/gl/builders/GrGLProgramBuilder.h
index 1b6c904036..e6180cc36d 100644
--- a/src/gpu/gl/builders/GrGLProgramBuilder.h
+++ b/src/gpu/gl/builders/GrGLProgramBuilder.h
@@ -14,6 +14,7 @@
#include "../GrGLProgramDataManager.h"
#include "../GrGLUniformHandle.h"
#include "../GrGLGeometryProcessor.h"
+#include "../../GrOptDrawState.h"
#include "../../GrPendingFragmentStage.h"
/*