| Index: src/gpu/GrDrawState.h
|
| diff --git a/src/gpu/GrDrawState.h b/src/gpu/GrDrawState.h
|
| index 6603cc9665832a1068be8a352def570eb83a960b..fa4d5b03f534e108879757e7f5644e86df5c3ca1 100644
|
| --- a/src/gpu/GrDrawState.h
|
| +++ b/src/gpu/GrDrawState.h
|
| @@ -8,21 +8,18 @@
|
| #ifndef GrDrawState_DEFINED
|
| #define GrDrawState_DEFINED
|
|
|
| -#include "GrBackendEffectFactory.h"
|
| #include "GrBlend.h"
|
| #include "GrColor.h"
|
| #include "GrEffectStage.h"
|
| -#include "GrPaint.h"
|
| -#include "GrRenderTarget.h"
|
| #include "GrStencil.h"
|
| -#include "GrTemplates.h"
|
| -#include "GrTexture.h"
|
| -#include "GrTypesPriv.h"
|
| #include "effects/GrSimpleTextureEffect.h"
|
|
|
| #include "SkMatrix.h"
|
| -#include "SkTypes.h"
|
| -#include "SkXfermode.h"
|
| +
|
| +class GrDrawTargetCaps;
|
| +class GrPaint;
|
| +class GrRenderTarget;
|
| +class GrTexture;
|
|
|
| class GrDrawState : public SkRefCnt {
|
| public:
|
| @@ -161,6 +158,18 @@ public:
|
| */
|
| bool hasSolidCoverage() const;
|
|
|
| + /**
|
| + * Depending on features available in the underlying 3D API and the color blend mode requested
|
| + * it may or may not be possible to correctly blend with fractional pixel coverage generated by
|
| + * the fragment shader.
|
| + *
|
| + * This function considers the current draw state and the draw target's capabilities to
|
| + * determine whether coverage can be handled correctly. This function assumes that the caller
|
| + * intends to specify fractional pixel coverage (via setCoverage(), through a coverage vertex
|
| + * attribute, or a coverage effect) but may not have specified it yet.
|
| + */
|
| + bool couldApplyCoverage(const GrDrawTargetCaps& caps) const;
|
| +
|
| /// @}
|
|
|
| ///////////////////////////////////////////////////////////////////////////
|
| @@ -185,9 +194,7 @@ public:
|
| *
|
| * @param alpha The alpha value to set as the color.
|
| */
|
| - void setAlpha(uint8_t a) {
|
| - this->setColor((a << 24) | (a << 16) | (a << 8) | a);
|
| - }
|
| + void setAlpha(uint8_t a) { this->setColor((a << 24) | (a << 16) | (a << 8) | a); }
|
|
|
| /// @}
|
|
|
| @@ -205,13 +212,9 @@ public:
|
| this->invalidateBlendOptFlags();
|
| }
|
|
|
| - uint8_t getCoverage() const {
|
| - return GrColorUnpackR(fCoverage);
|
| - }
|
| + uint8_t getCoverage() const { return GrColorUnpackR(fCoverage); }
|
|
|
| - GrColor getCoverageColor() const {
|
| - return fCoverage;
|
| - }
|
| + GrColor getCoverageColor() const { return fCoverage; }
|
|
|
| /// @}
|
|
|
| @@ -561,9 +564,7 @@ public:
|
| *
|
| * @param target The render target to set.
|
| */
|
| - void setRenderTarget(GrRenderTarget* target) {
|
| - fRenderTarget.reset(SkSafeRef(target));
|
| - }
|
| + void setRenderTarget(GrRenderTarget* target) { fRenderTarget.reset(SkSafeRef(target)); }
|
|
|
| /**
|
| * Retrieves the currently set render-target.
|
| @@ -722,29 +723,13 @@ public:
|
| }
|
| }
|
|
|
| - bool isDitherState() const {
|
| - return 0 != (fFlagBits & kDither_StateBit);
|
| - }
|
| -
|
| - bool isHWAntialiasState() const {
|
| - return 0 != (fFlagBits & kHWAntialias_StateBit);
|
| - }
|
| + 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);
|
| - }
|
| -
|
| - bool isStateFlagEnabled(uint32_t stateBit) const {
|
| - return 0 != (stateBit & fFlagBits);
|
| - }
|
| + bool isDitherState() const { return 0 != (fFlagBits & kDither_StateBit); }
|
| + bool isHWAntialiasState() const { return 0 != (fFlagBits & kHWAntialias_StateBit); }
|
| + bool isClipState() const { return 0 != (fFlagBits & kClip_StateBit); }
|
| + bool isColorWriteDisabled() const { return 0 != (fFlagBits & kNoColorWrites_StateBit); }
|
| + bool isCoverageDrawing() const { return 0 != (fFlagBits & kCoverageDrawing_StateBit); }
|
|
|
| /// @}
|
|
|
| @@ -779,6 +764,17 @@ public:
|
| /// @}
|
|
|
| ///////////////////////////////////////////////////////////////////////////
|
| + /// @name Hints
|
| + /// Hints that when provided can enable optimizations.
|
| + ////
|
| +
|
| + enum Hints { kVertexColorsAreOpaque_Hint = 0x1, };
|
| +
|
| + void setHint(Hints hint, bool value) { fHints = value ? (fHints | hint) : (fHints & ~hint); }
|
| +
|
| + /// @}
|
| +
|
| + ///////////////////////////////////////////////////////////////////////////
|
|
|
| /** Return type for CombineIfPossible. */
|
| enum CombinedState {
|
| @@ -796,7 +792,8 @@ public:
|
| a single GrDrawState. This is used to avoid storing redundant GrDrawStates and to determine
|
| if draws can be batched. The return value indicates whether combining is possible and, if
|
| so, which of the two inputs should be used. */
|
| - static CombinedState CombineIfPossible(const GrDrawState& a, const GrDrawState& b);
|
| + static CombinedState CombineIfPossible(const GrDrawState& a, const GrDrawState& b,
|
| + const GrDrawTargetCaps& caps);
|
|
|
| GrDrawState& operator= (const GrDrawState& that);
|
|
|
| @@ -804,8 +801,8 @@ private:
|
| void onReset(const SkMatrix* initialViewMatrix);
|
|
|
| BlendOptFlags calcBlendOpts(bool forceCoverage = false,
|
| - GrBlendCoeff* srcCoeff = NULL,
|
| - GrBlendCoeff* dstCoeff = NULL) const;
|
| + GrBlendCoeff* srcCoeff = NULL,
|
| + GrBlendCoeff* dstCoeff = NULL) const;
|
|
|
| // These fields are roughly sorted by decreasing likelihood of being different in op==
|
| SkAutoTUnref<GrRenderTarget> fRenderTarget;
|
| @@ -820,10 +817,12 @@ private:
|
| DrawFace fDrawFace;
|
|
|
| State fState;
|
| +
|
| + uint32_t fHints;
|
|
|
| - mutable GrBlendCoeff fOptSrcBlend;
|
| - mutable GrBlendCoeff fOptDstBlend;
|
| - mutable BlendOptFlags fBlendOptFlags;
|
| + mutable GrBlendCoeff fOptSrcBlend;
|
| + mutable GrBlendCoeff fOptDstBlend;
|
| + mutable BlendOptFlags fBlendOptFlags;
|
|
|
| // This is simply a different representation of info in fVertexAttribs and thus does
|
| // not need to be compared in op==.
|
|
|