diff options
author | Brian Salomon <bsalomon@google.com> | 2017-02-14 10:28:22 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-02-14 16:06:13 +0000 |
commit | 9a51498720e234b413e5a3c46d38ab40bda131de (patch) | |
tree | d9eab53b0bc23e4d5b3f575552fdac5e83c588e5 | |
parent | 8a8937c3d18e42f5d878885b40f3c1f8140627b7 (diff) |
Remove component flags from GrXPFactory output analysis.
Change-Id: Ieb8dab564e6e593dca2e092d352756052dadfd90
Reviewed-on: https://skia-review.googlesource.com/8354
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
-rw-r--r-- | include/gpu/GrXferProcessor.h | 41 | ||||
-rw-r--r-- | include/gpu/effects/GrCoverageSetOpXP.h | 15 | ||||
-rw-r--r-- | include/gpu/effects/GrPorterDuffXferProcessor.h | 15 | ||||
-rw-r--r-- | src/gpu/GrPaint.cpp | 13 | ||||
-rw-r--r-- | src/gpu/GrPipeline.cpp | 12 | ||||
-rw-r--r-- | src/gpu/GrPrimitiveProcessor.h | 14 | ||||
-rw-r--r-- | src/gpu/GrXferProcessor.cpp | 26 | ||||
-rw-r--r-- | src/gpu/effects/GrCoverageSetOpXP.cpp | 6 | ||||
-rw-r--r-- | src/gpu/effects/GrCustomXfermode.cpp | 22 | ||||
-rw-r--r-- | src/gpu/effects/GrDisableColorXP.h | 17 | ||||
-rw-r--r-- | src/gpu/effects/GrPorterDuffXferProcessor.cpp | 65 | ||||
-rw-r--r-- | src/gpu/ops/GrDrawPathOp.cpp | 5 | ||||
-rw-r--r-- | src/gpu/ops/GrDrawPathOp.h | 6 | ||||
-rw-r--r-- | tests/GrPorterDuffTest.cpp | 343 |
14 files changed, 298 insertions, 302 deletions
diff --git a/include/gpu/GrXferProcessor.h b/include/gpu/GrXferProcessor.h index 353c682f96..5aff17ff44 100644 --- a/include/gpu/GrXferProcessor.h +++ b/include/gpu/GrXferProcessor.h @@ -321,24 +321,27 @@ public: bool hasMixedSamples, const DstTexture*, const GrCaps& caps) const; + /** - * Known color information after blending, but before accounting for any coverage. + * Is the destination color required either in the shader or fixed function blending. */ - struct InvariantBlendedColor { - bool fWillBlendWithDst; - GrColor fKnownColor; - GrColorComponentFlags fKnownColorFlags; - }; + static bool WillReadDst(const GrXPFactory*, const GrProcOptInfo& colorInput, + const GrProcOptInfo& coverageInput); - /** - * Returns information about the output color, produced by XPs from this factory, that will be - * known after blending. Note that we can conflate coverage and color, so the actual values - * written to pixels with partial coverage may not always seem consistent with the invariant - * information returned by this function. + /** + * Most of the time GrXferProcessor performs a blend of the src and dst colors and then applies + * the coverage using c*b + (1-c)*d where c is coverage, b=F(s,d) is the blended color, s is the + * source color, and d is the destination color. This query answers the question "is b a + * constant and if so what is its value?" If the XP ignores the source color or applies the + * coverage in some other fashion then this returns false. */ - virtual void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, - InvariantBlendedColor*) const = 0; + static bool IsPreCoverageBlendedColorConstant(const GrXPFactory*, + const GrProcOptInfo& colorInput, GrColor* color); + /** + * This will return true if the xfer processor needs the dst color in the shader and the way + * that the color will be made available to the xfer processor is by sampling a texture. + */ bool willNeedDstTexture(const GrCaps& caps, const GrPipelineAnalysis& analysis) const; protected: @@ -353,19 +356,27 @@ protected: } private: + /** Subclass-specific implementation of IsPreCoverageBlendedColorConstant(). */ + virtual bool isPreCoverageBlendedColorConstant(const GrProcOptInfo& colorInput, + GrColor* color) const = 0; + + /** Subclass-specific implementation of WillReadDst(). */ + virtual bool willReadsDst(const GrProcOptInfo& colorInput, + const GrProcOptInfo& coverageInput) const = 0; + virtual GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, const GrPipelineAnalysis&, bool hasMixedSamples, const DstTexture*) const = 0; - bool willReadDstColor(const GrCaps& caps, const GrPipelineAnalysis& analysis) const; + bool willReadDstInShader(const GrCaps& caps, const GrPipelineAnalysis& analysis) const; /** * Returns true if the XP generated by this factory will explicitly read dst in the fragment * shader. This will not be called for draws that read from PLS since the dst color is always * available in such draws. */ - virtual bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const = 0; + virtual bool willReadDstInShader(const GrCaps&, ColorType, CoverageType) const = 0; }; #if defined(__GNUC__) || defined(__clang) #pragma GCC diagnostic pop diff --git a/include/gpu/effects/GrCoverageSetOpXP.h b/include/gpu/effects/GrCoverageSetOpXP.h index 385cad865e..7781b848bc 100644 --- a/include/gpu/effects/GrCoverageSetOpXP.h +++ b/include/gpu/effects/GrCoverageSetOpXP.h @@ -29,18 +29,25 @@ class GrCoverageSetOpXPFactory : public GrXPFactory { public: static const GrXPFactory* Get(SkRegion::Op regionOp, bool invertCoverage = false); - void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, - GrXPFactory::InvariantBlendedColor*) const override; - private: constexpr GrCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage); + bool isPreCoverageBlendedColorConstant(const GrProcOptInfo&, GrColor*) const override { + return false; + } + + bool willReadsDst(const GrProcOptInfo&, const GrProcOptInfo&) const override { + return fRegionOp != SkRegion::kReplace_Op; + } + GrXferProcessor* onCreateXferProcessor(const GrCaps&, const GrPipelineAnalysis&, bool hasMixedSamples, const DstTexture*) const override; - bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const override { return false; } + bool willReadDstInShader(const GrCaps&, ColorType, CoverageType) const override { + return false; + } GR_DECLARE_XP_FACTORY_TEST; diff --git a/include/gpu/effects/GrPorterDuffXferProcessor.h b/include/gpu/effects/GrPorterDuffXferProcessor.h index dd68c656cb..3a404f4975 100644 --- a/include/gpu/effects/GrPorterDuffXferProcessor.h +++ b/include/gpu/effects/GrPorterDuffXferProcessor.h @@ -23,10 +23,6 @@ class GrPorterDuffXPFactory : public GrXPFactory { public: static const GrXPFactory* Get(SkBlendMode blendMode); - void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, - GrXPFactory::InvariantBlendedColor*) const override; - - /** Because src-over is so common we special case it for performance reasons. If this returns null then the SimpleSrcOverXP() below should be used. */ static GrXferProcessor* CreateSrcOverXferProcessor(const GrCaps& caps, @@ -41,20 +37,25 @@ public: by reference because it is global and its ref-cnting methods are not thread safe. */ static const GrXferProcessor& SimpleSrcOverXP(); - static void SrcOverInvariantBlendedColor(const GrProcOptInfo&, - GrXPFactory::InvariantBlendedColor*); + static bool WillSrcOverReadDst(const GrProcOptInfo& colorInput, + const GrProcOptInfo& coverageInput); + static bool IsSrcOverPreCoverageBlendedColorConstant(const GrProcOptInfo& colorInput, + GrColor* color); static bool SrcOverWillNeedDstTexture(const GrCaps&, const GrPipelineAnalysis&); private: constexpr GrPorterDuffXPFactory(SkBlendMode); + bool isPreCoverageBlendedColorConstant(const GrProcOptInfo&, GrColor*) const override; + bool willReadsDst(const GrProcOptInfo&, const GrProcOptInfo&) const override; + GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, const GrPipelineAnalysis&, bool hasMixedSamples, const DstTexture*) const override; - bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const override; + bool willReadDstInShader(const GrCaps&, ColorType, CoverageType) const override; GR_DECLARE_XP_FACTORY_TEST; static void TestGetXPOutputTypes(const GrXferProcessor*, int* outPrimary, int* outSecondary); diff --git a/src/gpu/GrPaint.cpp b/src/gpu/GrPaint.cpp index 19bfef3360..26dbf3d2df 100644 --- a/src/gpu/GrPaint.cpp +++ b/src/gpu/GrPaint.cpp @@ -81,16 +81,5 @@ bool GrPaint::internalIsConstantBlendedColor(GrColor paintColor, GrColor* color) sk_sp_address_as_pointer_address(fColorFragmentProcessors.begin()), this->numColorFragmentProcessors()); - GrXPFactory::InvariantBlendedColor blendedColor; - if (fXPFactory) { - fXPFactory->getInvariantBlendedColor(colorProcInfo, &blendedColor); - } else { - GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(colorProcInfo, &blendedColor); - } - - if (kRGBA_GrColorComponentFlags == blendedColor.fKnownColorFlags) { - *color = blendedColor.fKnownColor; - return true; - } - return false; + return GrXPFactory::IsPreCoverageBlendedColorConstant(fXPFactory, colorProcInfo, color); } diff --git a/src/gpu/GrPipeline.cpp b/src/gpu/GrPipeline.cpp index 94f11e93ac..e2b76f8ab4 100644 --- a/src/gpu/GrPipeline.cpp +++ b/src/gpu/GrPipeline.cpp @@ -144,15 +144,9 @@ GrPipeline* GrPipeline::CreateAt(void* memory, const CreateArgs& args, optimizations->fFlags |= GrPipelineOptimizations::kCanTweakAlphaForCoverage_Flag; } - GrXPFactory::InvariantBlendedColor blendedColor; - if (xpFactory) { - xpFactory->getInvariantBlendedColor(args.fAnalysis.fColorPOI, &blendedColor); - } else { - GrPorterDuffXPFactory::SrcOverInvariantBlendedColor(args.fAnalysis.fColorPOI, - &blendedColor); - } - if (blendedColor.fWillBlendWithDst) { - optimizations->fFlags |= GrPipelineOptimizations::kWillColorBlendWithDst_Flag; + if (GrXPFactory::WillReadDst(xpFactory, args.fAnalysis.fColorPOI, + args.fAnalysis.fCoveragePOI)) { + optimizations->fFlags |= GrPipelineOptimizations::kXPReadsDst_Flag; } return pipeline; diff --git a/src/gpu/GrPrimitiveProcessor.h b/src/gpu/GrPrimitiveProcessor.h index 9f726d242b..47564d9862 100644 --- a/src/gpu/GrPrimitiveProcessor.h +++ b/src/gpu/GrPrimitiveProcessor.h @@ -80,17 +80,9 @@ public: } /** - * Returns true if the pipeline's color output will be affected by the existing render target - * destination pixel values (meaning we need to be careful with overlapping draws). Note that we - * can conflate coverage and color, so the destination color may still bleed into pixels that - * have partial coverage, even if this function returns false. - * - * The above comment seems incorrect for the use case. This function is used to turn two - * overlapping draws into a single draw (really to stencil multiple paths and do a single - * cover). It seems that what really matters is whether the dst is read for color OR for - * coverage. + * Returns true if the color written to the output pixel depends on the pixels previous value. */ - bool willColorBlendWithDst() const { return SkToBool(kWillColorBlendWithDst_Flag & fFlags); } + bool xpReadsDst() const { return SkToBool(kXPReadsDst_Flag & fFlags); } private: enum { @@ -105,7 +97,7 @@ private: // output color. If not set fOverrideColor is to be ignored. kUseOverrideColor_Flag = 0x4, - kWillColorBlendWithDst_Flag = 0x8, + kXPReadsDst_Flag = 0x8, }; uint32_t fFlags; diff --git a/src/gpu/GrXferProcessor.cpp b/src/gpu/GrXferProcessor.cpp index bc90f99ec7..e6a1817aba 100644 --- a/src/gpu/GrXferProcessor.cpp +++ b/src/gpu/GrXferProcessor.cpp @@ -203,13 +203,31 @@ CoverageType analysis_coverage_type(const GrPipelineAnalysis& analysis) { return CoverageType::kSingleChannel; } -bool GrXPFactory::willReadDstColor(const GrCaps& caps, const GrPipelineAnalysis& analysis) const { +bool GrXPFactory::WillReadDst(const GrXPFactory* factory, const GrProcOptInfo& colorInput, + const GrProcOptInfo& coverageInput) { + if (factory) { + return factory->willReadsDst(colorInput, coverageInput); + } + return GrPorterDuffXPFactory::WillSrcOverReadDst(colorInput, coverageInput); +} + +bool GrXPFactory::IsPreCoverageBlendedColorConstant(const GrXPFactory* factory, + const GrProcOptInfo& colorInput, + GrColor* color) { + if (factory) { + return factory->isPreCoverageBlendedColorConstant(colorInput, color); + } + return GrPorterDuffXPFactory::IsSrcOverPreCoverageBlendedColorConstant(colorInput, color); +} + +bool GrXPFactory::willReadDstInShader(const GrCaps& caps, + const GrPipelineAnalysis& analysis) const { if (analysis.fUsesPLSDstRead) { return true; } ColorType colorType = analysis_color_type(analysis); CoverageType coverageType = analysis_coverage_type(analysis); - return this->willReadDstColor(caps, colorType, coverageType); + return this->willReadDstInShader(caps, colorType, coverageType); } GrXferProcessor* GrXPFactory::createXferProcessor(const GrPipelineAnalysis& analysis, @@ -217,7 +235,7 @@ GrXferProcessor* GrXPFactory::createXferProcessor(const GrPipelineAnalysis& anal const DstTexture* dstTexture, const GrCaps& caps) const { #ifdef SK_DEBUG - if (this->willReadDstColor(caps, analysis)) { + if (this->willReadDstInShader(caps, analysis)) { if (!caps.shaderCaps()->dstReadInShaderSupport()) { SkASSERT(dstTexture && dstTexture->texture()); } else { @@ -233,5 +251,5 @@ GrXferProcessor* GrXPFactory::createXferProcessor(const GrPipelineAnalysis& anal bool GrXPFactory::willNeedDstTexture(const GrCaps& caps, const GrPipelineAnalysis& analysis) const { return !analysis.fUsesPLSDstRead && !caps.shaderCaps()->dstReadInShaderSupport() && - this->willReadDstColor(caps, analysis); + this->willReadDstInShader(caps, analysis); } diff --git a/src/gpu/effects/GrCoverageSetOpXP.cpp b/src/gpu/effects/GrCoverageSetOpXP.cpp index b8902de58c..9cf994f07a 100644 --- a/src/gpu/effects/GrCoverageSetOpXP.cpp +++ b/src/gpu/effects/GrCoverageSetOpXP.cpp @@ -339,12 +339,6 @@ GrXferProcessor* GrCoverageSetOpXPFactory::onCreateXferProcessor(const GrCaps& c return CoverageSetOpXP::Create(fRegionOp, fInvertCoverage); } -void GrCoverageSetOpXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, - InvariantBlendedColor* blendedColor) const { - blendedColor->fWillBlendWithDst = SkRegion::kReplace_Op != fRegionOp; - blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; -} - GR_DEFINE_XP_FACTORY_TEST(GrCoverageSetOpXPFactory); #if GR_TEST_UTILS diff --git a/src/gpu/effects/GrCustomXfermode.cpp b/src/gpu/effects/GrCustomXfermode.cpp index 4a4cb60b4e..bc11d7e533 100644 --- a/src/gpu/effects/GrCustomXfermode.cpp +++ b/src/gpu/effects/GrCustomXfermode.cpp @@ -331,16 +331,20 @@ public: constexpr CustomXPFactory(SkBlendMode mode) : fMode(mode), fHWBlendEquation(hw_blend_equation(mode)) {} - void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, - GrXPFactory::InvariantBlendedColor*) const override; - private: GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, const GrPipelineAnalysis&, bool hasMixedSamples, const DstTexture*) const override; - bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const override; + bool isPreCoverageBlendedColorConstant(const GrProcOptInfo& colorInput, + GrColor* color) const override { + return false; + } + + bool willReadsDst(const GrProcOptInfo&, const GrProcOptInfo&) const override { return true; } + + bool willReadDstInShader(const GrCaps&, ColorType, CoverageType) const override; GR_DECLARE_XP_FACTORY_TEST; @@ -366,20 +370,14 @@ GrXferProcessor* CustomXPFactory::onCreateXferProcessor(const GrCaps& caps, return new CustomXP(dstTexture, hasMixedSamples, fMode); } -bool CustomXPFactory::willReadDstColor(const GrCaps& caps, ColorType colorType, - CoverageType coverageType) const { +bool CustomXPFactory::willReadDstInShader(const GrCaps& caps, ColorType colorType, + CoverageType coverageType) const { // This should not be called if we're using PLS dst read. static constexpr bool kUsesPLSRead = false; return !can_use_hw_blend_equation(fHWBlendEquation, kUsesPLSRead, CoverageType::kLCD == coverageType, caps); } -void CustomXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, - InvariantBlendedColor* blendedColor) const { - blendedColor->fWillBlendWithDst = true; - blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; -} - GR_DEFINE_XP_FACTORY_TEST(CustomXPFactory); #if GR_TEST_UTILS const GrXPFactory* CustomXPFactory::TestGet(GrProcessorTestData* d) { diff --git a/src/gpu/effects/GrDisableColorXP.h b/src/gpu/effects/GrDisableColorXP.h index f027e3c3bb..e98e71e069 100644 --- a/src/gpu/effects/GrDisableColorXP.h +++ b/src/gpu/effects/GrDisableColorXP.h @@ -23,16 +23,21 @@ class GrDisableColorXPFactory : public GrXPFactory { public: static const GrXPFactory* Get(); - void getInvariantBlendedColor(const GrProcOptInfo& colorPOI, - GrXPFactory::InvariantBlendedColor* blendedColor) const override { - blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; - blendedColor->fWillBlendWithDst = false; +private: + bool isPreCoverageBlendedColorConstant(const GrProcOptInfo&, GrColor*) const override { + return false; + } + + bool willReadsDst(const GrProcOptInfo& colorInput, + const GrProcOptInfo& coverageInput) const override { + return false; } -private: constexpr GrDisableColorXPFactory() {} - bool willReadDstColor(const GrCaps&, ColorType, CoverageType) const override { return false; } + bool willReadDstInShader(const GrCaps&, ColorType, CoverageType) const override { + return false; + } GrXferProcessor* onCreateXferProcessor(const GrCaps& caps, const GrPipelineAnalysis&, diff --git a/src/gpu/effects/GrPorterDuffXferProcessor.cpp b/src/gpu/effects/GrPorterDuffXferProcessor.cpp index 5f44c7a108..a04bb5b512 100644 --- a/src/gpu/effects/GrPorterDuffXferProcessor.cpp +++ b/src/gpu/effects/GrPorterDuffXferProcessor.cpp @@ -764,40 +764,33 @@ GrXferProcessor* GrPorterDuffXPFactory::onCreateXferProcessor(const GrCaps& caps SkASSERT(!dstTexture || !dstTexture->texture()); return new PorterDuffXferProcessor(blendFormula); } - -void GrPorterDuffXPFactory::getInvariantBlendedColor(const GrProcOptInfo& colorPOI, - InvariantBlendedColor* blendedColor) const { - // Find the blended color info based on the formula that does not have coverage. - BlendFormula colorFormula = gBlendTable[colorPOI.isOpaque()][0][(int)fBlendMode]; +bool GrPorterDuffXPFactory::isPreCoverageBlendedColorConstant(const GrProcOptInfo& colorInput, + GrColor* color) const { + BlendFormula colorFormula = gBlendTable[colorInput.isOpaque()][0][(int)fBlendMode]; + SkASSERT(kAdd_GrBlendEquation == colorFormula.fBlendEquation); if (colorFormula.usesDstColor()) { - blendedColor->fWillBlendWithDst = true; - blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; - return; + return false; } - - blendedColor->fWillBlendWithDst = false; - - SkASSERT(kAdd_GrBlendEquation == colorFormula.fBlendEquation); - switch (colorFormula.fSrcCoeff) { case kZero_GrBlendCoeff: - blendedColor->fKnownColor = 0; - blendedColor->fKnownColorFlags = kRGBA_GrColorComponentFlags; - return; + *color = GrColor_TRANSPARENT_BLACK; + return true; case kOne_GrBlendCoeff: - blendedColor->fKnownColorFlags = - colorPOI.hasKnownOutputColor(&blendedColor->fKnownColor) - ? kRGBA_GrColorComponentFlags - : kNone_GrColorComponentFlags; - return; + return colorInput.hasKnownOutputColor(color); default: - blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; - return; + return false; } } -bool GrPorterDuffXPFactory::willReadDstColor(const GrCaps& caps, ColorType colorType, - CoverageType coverageType) const { +bool GrPorterDuffXPFactory::willReadsDst(const GrProcOptInfo& colorInput, + const GrProcOptInfo& coverageInput) const { + BlendFormula colorFormula = gBlendTable[colorInput.isOpaque()][0][(int)fBlendMode]; + SkASSERT(kAdd_GrBlendEquation == colorFormula.fBlendEquation); + return (colorFormula.usesDstColor() || !coverageInput.isSolidWhite()); +} + +bool GrPorterDuffXPFactory::willReadDstInShader(const GrCaps& caps, ColorType colorType, + CoverageType coverageType) const { if (caps.shaderCaps()->dualSourceBlendingSupport()) { return false; } @@ -900,19 +893,17 @@ sk_sp<GrXferProcessor> GrPorterDuffXPFactory::CreateNoCoverageXP(SkBlendMode ble return sk_make_sp<PorterDuffXferProcessor>(formula); } -void GrPorterDuffXPFactory::SrcOverInvariantBlendedColor( - const GrProcOptInfo& colorPOI, GrXPFactory::InvariantBlendedColor* blendedColor) { - if (!colorPOI.isOpaque()) { - blendedColor->fWillBlendWithDst = true; - blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; - return; - } - blendedColor->fWillBlendWithDst = false; - if (colorPOI.hasKnownOutputColor(&blendedColor->fKnownColor)) { - blendedColor->fKnownColorFlags = kRGBA_GrColorComponentFlags; - } else { - blendedColor->fKnownColorFlags = kNone_GrColorComponentFlags; +bool GrPorterDuffXPFactory::WillSrcOverReadDst(const GrProcOptInfo& colorInput, + const GrProcOptInfo& coverageInput) { + return !coverageInput.isSolidWhite() || !colorInput.isOpaque(); +} + +bool GrPorterDuffXPFactory::IsSrcOverPreCoverageBlendedColorConstant( + const GrProcOptInfo& colorInput, GrColor* color) { + if (!colorInput.isOpaque()) { + return false; } + return colorInput.hasKnownOutputColor(color); } bool GrPorterDuffXPFactory::SrcOverWillNeedDstTexture(const GrCaps& caps, diff --git a/src/gpu/ops/GrDrawPathOp.cpp b/src/gpu/ops/GrDrawPathOp.cpp index a32d7080e0..c2b4fdb4bc 100644 --- a/src/gpu/ops/GrDrawPathOp.cpp +++ b/src/gpu/ops/GrDrawPathOp.cpp @@ -99,11 +99,10 @@ bool GrDrawPathRangeOp::onCombineIfPossible(GrOp* t, const GrCaps& caps) { // numbers, and we only partially account for this by not allowing even/odd paths to be // combined. (Glyphs in the same font tend to wind the same direction so it works out OK.) if (GrPathRendering::kWinding_FillType != this->fillType() || - GrPathRendering::kWinding_FillType != that->fillType() || - this->blendsWithDst()) { + GrPathRendering::kWinding_FillType != that->fillType() || this->xpReadsDst()) { return false; } - SkASSERT(!that->blendsWithDst()); + SkASSERT(!that->xpReadsDst()); fTotalPathCount += that->fTotalPathCount; while (Draw* head = that->fDraws.head()) { Draw* draw = fDraws.addToTail(); diff --git a/src/gpu/ops/GrDrawPathOp.h b/src/gpu/ops/GrDrawPathOp.h index a18a351162..e82ff22845 100644 --- a/src/gpu/ops/GrDrawPathOp.h +++ b/src/gpu/ops/GrDrawPathOp.h @@ -33,7 +33,7 @@ protected: const SkMatrix& viewMatrix() const { return fViewMatrix; } GrColor color() const { return fColor; } GrPathRendering::FillType fillType() const { return fFillType; } - bool blendsWithDst() const { return fBlendsWithDst; } + bool xpReadsDst() const { return fXPReadsDst; } private: void getPipelineAnalysisInput(GrPipelineAnalysisDrawOpInput* input) const override { @@ -43,7 +43,7 @@ private: void applyPipelineOptimizations(const GrPipelineOptimizations& optimizations) override { optimizations.getOverrideColorIfSet(&fColor); - fBlendsWithDst = optimizations.willColorBlendWithDst(); + fXPReadsDst = optimizations.xpReadsDst(); } void onPrepare(GrOpFlushState*) override; // Initializes fStencilPassSettings. @@ -52,7 +52,7 @@ private: GrColor fColor; GrPathRendering::FillType fFillType; GrStencilSettings fStencilPassSettings; - bool fBlendsWithDst; + bool fXPReadsDst; typedef GrDrawOp INHERITED; }; diff --git a/tests/GrPorterDuffTest.cpp b/tests/GrPorterDuffTest.cpp index f4bf85160f..133d2b7e72 100644 --- a/tests/GrPorterDuffTest.cpp +++ b/tests/GrPorterDuffTest.cpp @@ -68,9 +68,11 @@ public: XPInfo(skiatest::Reporter* reporter, SkBlendMode xfermode, const GrCaps& caps, const GrPipelineAnalysis& analysis) { const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(xfermode); + fReadsDst = GrXPFactory::WillReadDst(xpf, analysis.fColorPOI, analysis.fCoveragePOI); + fHasConstantPreCoverageBlendedColor = GrXPFactory::IsPreCoverageBlendedColorConstant( + xpf, analysis.fColorPOI, &fPreCoverageBlendedColor); sk_sp<GrXferProcessor> xp(xpf->createXferProcessor(analysis, false, nullptr, caps)); TEST_ASSERT(!xpf->willNeedDstTexture(caps, analysis)); - xpf->getInvariantBlendedColor(analysis.fColorPOI, &fBlendedColor); GrColor ignoredOverrideColor; fOptFlags = xp->getOptimizations(analysis, false, &ignoredOverrideColor, caps); GetXPOutputTypes(xp.get(), &fPrimaryOutputType, &fSecondaryOutputType); @@ -79,7 +81,9 @@ public: TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendInfo.fDstBlend)); } - GrXPFactory::InvariantBlendedColor fBlendedColor; + bool fReadsDst; + bool fHasConstantPreCoverageBlendedColor; + GrColor fPreCoverageBlendedColor; int fOptFlags; int fPrimaryOutputType; int fSecondaryOutputType; @@ -105,12 +109,11 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { SkBlendMode xfermode = static_cast<SkBlendMode>(m); const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, analysis); - switch (xfermode) { case SkBlendMode::kClear: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); - TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(xpi.fHasConstantPreCoverageBlendedColor); + TEST_ASSERT(GrColor_TRANSPARENT_BLACK == xpi.fPreCoverageBlendedColor); TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -120,8 +123,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrc: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); @@ -131,8 +134,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDst: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kSkipDraw_OptFlag | kIgnoreColor_OptFlag | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); @@ -144,8 +147,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOver: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); @@ -155,8 +158,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOver: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -166,8 +169,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); @@ -177,8 +180,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -188,8 +191,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOut: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); @@ -199,8 +202,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOut: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kSAModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -210,8 +213,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); @@ -221,8 +224,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType); @@ -232,8 +235,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kXor: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType); @@ -243,8 +246,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kPlus: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -254,8 +257,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kModulate: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -265,8 +268,8 @@ static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kScreen: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -294,12 +297,11 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { SkBlendMode xfermode = static_cast<SkBlendMode>(m); const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, analysis); - switch (xfermode) { case SkBlendMode::kClear: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); - TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(xpi.fHasConstantPreCoverageBlendedColor); + TEST_ASSERT(GrColor_TRANSPARENT_BLACK == xpi.fPreCoverageBlendedColor); TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -309,8 +311,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrc: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); @@ -320,8 +322,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDst: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kSkipDraw_OptFlag | kIgnoreColor_OptFlag | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); @@ -333,8 +335,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOver: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -344,8 +346,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOver: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -355,8 +357,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); @@ -366,8 +368,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -377,8 +379,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOut: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType); @@ -388,8 +390,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOut: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -399,8 +401,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -410,8 +412,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType); @@ -421,8 +423,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kXor: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -432,8 +434,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kPlus: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -443,8 +445,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kModulate: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -454,8 +456,8 @@ static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kScreen: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -484,12 +486,11 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { SkBlendMode xfermode = static_cast<SkBlendMode>(m); const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, analysis); - switch (xfermode) { case SkBlendMode::kClear: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); - TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(!xpi.fReadsDst); + TEST_ASSERT(xpi.fHasConstantPreCoverageBlendedColor); + TEST_ASSERT(GrColor_TRANSPARENT_BLACK == xpi.fPreCoverageBlendedColor); TEST_ASSERT(kIgnoreColor_OptFlag == xpi.fOptFlags); TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -499,12 +500,12 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrc: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(229 == GrColorUnpackR(xpi.fBlendedColor.fKnownColor)); - TEST_ASSERT(0 == GrColorUnpackG(xpi.fBlendedColor.fKnownColor)); - TEST_ASSERT(154 == GrColorUnpackB(xpi.fBlendedColor.fKnownColor)); - TEST_ASSERT(240 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor)); - TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(!xpi.fReadsDst); + TEST_ASSERT(xpi.fHasConstantPreCoverageBlendedColor); + TEST_ASSERT(229 == GrColorUnpackR(xpi.fPreCoverageBlendedColor)); + TEST_ASSERT(0 == GrColorUnpackG(xpi.fPreCoverageBlendedColor)); + TEST_ASSERT(154 == GrColorUnpackB(xpi.fPreCoverageBlendedColor)); + TEST_ASSERT(240 == GrColorUnpackA(xpi.fPreCoverageBlendedColor)); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -514,8 +515,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDst: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kSkipDraw_OptFlag | kIgnoreColor_OptFlag | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); @@ -527,8 +528,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOver: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -538,8 +539,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOver: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -549,8 +550,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -560,8 +561,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -571,8 +572,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOut: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -582,8 +583,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOut: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -593,8 +594,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -604,8 +605,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -615,8 +616,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kXor: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -626,8 +627,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kPlus: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -637,8 +638,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kModulate: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -648,8 +649,8 @@ static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const G TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kScreen: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -678,12 +679,11 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) { SkBlendMode xfermode = static_cast<SkBlendMode>(m); const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, analysis); - switch (xfermode) { case SkBlendMode::kClear: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); - TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(xpi.fHasConstantPreCoverageBlendedColor); + TEST_ASSERT(GrColor_TRANSPARENT_BLACK == xpi.fPreCoverageBlendedColor); TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -693,9 +693,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrc: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - // We don't really track per-component blended output anymore. - TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -705,8 +704,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDst: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kSkipDraw_OptFlag | kIgnoreColor_OptFlag | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); @@ -718,9 +717,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOver: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - // We don't really track per-component blended output anymore. - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -730,8 +728,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOver: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -741,8 +739,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -752,8 +750,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kSkipDraw_OptFlag | kIgnoreColor_OptFlag | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); @@ -765,8 +763,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOut: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -776,9 +774,9 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOut: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); - TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(xpi.fHasConstantPreCoverageBlendedColor); + TEST_ASSERT(GrColor_TRANSPARENT_BLACK == xpi.fPreCoverageBlendedColor); TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -788,8 +786,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -799,8 +797,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -810,8 +808,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kXor: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -821,8 +819,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kPlus: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -832,8 +830,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kModulate: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags); TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -843,8 +841,8 @@ static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kScreen: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -877,9 +875,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr switch (xfermode) { case SkBlendMode::kClear: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); - TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(!xpi.fReadsDst); + TEST_ASSERT(xpi.fHasConstantPreCoverageBlendedColor); + TEST_ASSERT(GrColor_TRANSPARENT_BLACK == xpi.fPreCoverageBlendedColor); TEST_ASSERT(kIgnoreColor_OptFlag == xpi.fOptFlags); TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -889,9 +887,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrc: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); + TEST_ASSERT(!xpi.fReadsDst); // We don't really track per-component blended output anymore. - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -901,8 +899,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDst: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kSkipDraw_OptFlag | kIgnoreColor_OptFlag | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); @@ -914,9 +912,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOver: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); + TEST_ASSERT(!xpi.fReadsDst); // We don't really track per-component blended output anymore. - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -926,8 +924,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOver: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -937,8 +935,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -948,8 +946,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstIn: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT((kSkipDraw_OptFlag | kIgnoreColor_OptFlag | kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags); @@ -961,8 +959,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(!xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcOut: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -972,9 +970,9 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstOut: - TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor); - TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(!xpi.fReadsDst); + TEST_ASSERT(xpi.fHasConstantPreCoverageBlendedColor); + TEST_ASSERT(GrColor_TRANSPARENT_BLACK == xpi.fPreCoverageBlendedColor); TEST_ASSERT(kIgnoreColor_OptFlag == xpi.fOptFlags); TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -984,8 +982,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kSrcATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -995,8 +993,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kDstATop: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -1006,8 +1004,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kXor: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -1017,8 +1015,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kPlus: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -1028,8 +1026,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kModulate: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kNone_OptFlags == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -1039,8 +1037,8 @@ static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const Gr TEST_ASSERT(xpi.fBlendInfo.fWriteColor); break; case SkBlendMode::kScreen: - TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags); + TEST_ASSERT(xpi.fReadsDst); + TEST_ASSERT(!xpi.fHasConstantPreCoverageBlendedColor); TEST_ASSERT(kCanTweakAlphaForCoverage_OptFlag == xpi.fOptFlags); TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType); TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType); @@ -1099,10 +1097,9 @@ static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const return; } - GrXPFactory::InvariantBlendedColor blendedColor; - xpf->getInvariantBlendedColor(colorPOI, &blendedColor); - TEST_ASSERT(blendedColor.fWillBlendWithDst); - TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags); + GrColor color; + TEST_ASSERT(GrXPFactory::WillReadDst(xpf, colorPOI, covPOI)); + TEST_ASSERT(!GrXPFactory::IsPreCoverageBlendedColorConstant(xpf, colorPOI, &color)); GrColor overrideColor; xp->getOptimizations(analysis, false, &overrideColor, caps); |