2015-05-27 22:08:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
|
|
|
|
#include "GrContextFactory.h"
|
|
|
|
#include "GrContextOptions.h"
|
|
|
|
#include "GrGpu.h"
|
|
|
|
#include "GrResourceProvider.h"
|
|
|
|
#include "GrXferProcessor.h"
|
2016-12-01 21:40:24 +00:00
|
|
|
#include "batches/GrMeshDrawOp.h"
|
2015-05-27 22:08:33 +00:00
|
|
|
#include "effects/GrPorterDuffXferProcessor.h"
|
|
|
|
#include "gl/GrGLCaps.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
|
|
|
static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
|
|
|
static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
|
|
|
static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
|
|
|
static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
2015-09-15 16:31:40 +00:00
|
|
|
static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2016-04-06 21:02:39 +00:00
|
|
|
DEF_GPUTEST_FOR_NULLGL_CONTEXT(GrPorterDuff, reporter, ctxInfo) {
|
2016-05-11 13:33:06 +00:00
|
|
|
const GrCaps& caps = *ctxInfo.grContext()->getGpu()->caps();
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!caps.shaderCaps()->dualSourceBlendingSupport()) {
|
|
|
|
SkFAIL("Null context does not support dual source blending.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
test_color_unknown_with_coverage(reporter, caps);
|
|
|
|
test_color_unknown_no_coverage(reporter, caps);
|
|
|
|
test_color_opaque_with_coverage(reporter, caps);
|
|
|
|
test_color_opaque_no_coverage(reporter, caps);
|
|
|
|
test_lcd_coverage(reporter, caps);
|
2015-09-15 16:31:40 +00:00
|
|
|
test_lcd_coverage_fallback_case(reporter, caps);
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__)
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kNone_OutputType,
|
|
|
|
kCoverage_OutputType,
|
|
|
|
kModulate_OutputType,
|
2015-09-15 16:31:40 +00:00
|
|
|
kSAModulate_OutputType,
|
2015-05-27 22:08:33 +00:00
|
|
|
kISAModulate_OutputType,
|
|
|
|
kISCModulate_OutputType
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2015-07-08 18:26:37 +00:00
|
|
|
kNone_OptFlags = GrXferProcessor::kNone_OptFlags,
|
2015-05-27 22:08:33 +00:00
|
|
|
kSkipDraw_OptFlag = GrXferProcessor::kSkipDraw_OptFlag,
|
|
|
|
kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag,
|
|
|
|
kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag,
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag
|
|
|
|
};
|
|
|
|
|
|
|
|
class GrPorterDuffTest {
|
|
|
|
public:
|
|
|
|
struct XPInfo {
|
2016-10-28 19:42:34 +00:00
|
|
|
XPInfo(skiatest::Reporter* reporter, SkBlendMode xfermode, const GrCaps& caps,
|
2015-11-30 16:57:38 +00:00
|
|
|
const GrPipelineOptimizations& optimizations) {
|
2016-06-09 15:01:03 +00:00
|
|
|
sk_sp<GrXPFactory> xpf(GrPorterDuffXPFactory::Make(xfermode));
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<GrXferProcessor> xp(
|
2015-11-30 16:57:38 +00:00
|
|
|
xpf->createXferProcessor(optimizations, false, nullptr, caps));
|
2016-05-06 16:41:16 +00:00
|
|
|
TEST_ASSERT(!xpf->willNeedDstTexture(caps, optimizations));
|
2015-11-30 16:57:38 +00:00
|
|
|
xpf->getInvariantBlendedColor(optimizations.fColorPOI, &fBlendedColor);
|
|
|
|
fOptFlags = xp->getOptimizations(optimizations, false, nullptr, caps);
|
2016-11-04 15:49:42 +00:00
|
|
|
GetXPOutputTypes(xp.get(), &fPrimaryOutputType, &fSecondaryOutputType);
|
2015-05-27 22:08:33 +00:00
|
|
|
xp->getBlendInfo(&fBlendInfo);
|
|
|
|
TEST_ASSERT(!xp->willReadDstColor());
|
|
|
|
TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendInfo.fDstBlend));
|
|
|
|
}
|
|
|
|
|
2015-06-02 17:43:39 +00:00
|
|
|
GrXPFactory::InvariantBlendedColor fBlendedColor;
|
2015-05-27 22:08:33 +00:00
|
|
|
int fOptFlags;
|
|
|
|
int fPrimaryOutputType;
|
|
|
|
int fSecondaryOutputType;
|
|
|
|
GrXferProcessor::BlendInfo fBlendInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int* outSecondary) {
|
2015-11-20 23:12:59 +00:00
|
|
|
GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary);
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-09-15 16:31:40 +00:00
|
|
|
static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
2015-11-30 16:57:38 +00:00
|
|
|
GrPipelineOptimizations opt;
|
|
|
|
opt.fColorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false);
|
2015-09-15 16:31:40 +00:00
|
|
|
// Setting 2nd to last value to false and last to true will force covPOI to LCD coverage.
|
2015-11-30 16:57:38 +00:00
|
|
|
opt.fCoveragePOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false, true);
|
2015-09-15 16:31:40 +00:00
|
|
|
|
2015-11-30 16:57:38 +00:00
|
|
|
SkASSERT(!opt.fColorPOI.isOpaque());
|
|
|
|
SkASSERT(!opt.fColorPOI.isSolidWhite());
|
|
|
|
SkASSERT(!opt.fCoveragePOI.isSolidWhite());
|
|
|
|
SkASSERT(opt.fCoveragePOI.isFourChannelOutput());
|
2015-09-15 16:31:40 +00:00
|
|
|
|
2016-10-28 19:42:34 +00:00
|
|
|
for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) {
|
|
|
|
SkBlendMode xfermode = static_cast<SkBlendMode>(m);
|
2015-11-30 16:57:38 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, opt);
|
2015-09-15 16:31:40 +00:00
|
|
|
|
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrc:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDst:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOver:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOver:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcIn:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstIn:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOut:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOut:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kSAModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcATop:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstATop:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kXor:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kPlus:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kModulate:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kScreen:
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-27 22:08:33 +00:00
|
|
|
static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
2015-11-30 16:57:38 +00:00
|
|
|
GrPipelineOptimizations optimizations;
|
2016-03-29 16:03:52 +00:00
|
|
|
optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
|
2015-11-30 16:57:38 +00:00
|
|
|
false);
|
2016-03-29 16:03:52 +00:00
|
|
|
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
|
2015-11-30 16:57:38 +00:00
|
|
|
true);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2015-11-30 16:57:38 +00:00
|
|
|
SkASSERT(!optimizations.fColorPOI.isOpaque());
|
|
|
|
SkASSERT(!optimizations.fColorPOI.isSolidWhite());
|
|
|
|
SkASSERT(!optimizations.fCoveragePOI.isSolidWhite());
|
|
|
|
SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput());
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2016-10-28 19:42:34 +00:00
|
|
|
for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) {
|
|
|
|
SkBlendMode xfermode = static_cast<SkBlendMode>(m);
|
2015-11-30 16:57:38 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizations);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2015-09-15 16:31:40 +00:00
|
|
|
|
2015-05-27 22:08:33 +00:00
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrc:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDst:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOver:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOver:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcIn:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstIn:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOut:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOut:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcATop:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstATop:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kXor:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kPlus:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kModulate:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kScreen:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
2015-11-30 16:57:38 +00:00
|
|
|
GrPipelineOptimizations optimizations;
|
|
|
|
optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(229, 0, 154, 0),
|
2015-05-27 22:08:33 +00:00
|
|
|
kR_GrColorComponentFlag | kB_GrColorComponentFlag, false);
|
2016-03-29 16:03:52 +00:00
|
|
|
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
|
2015-11-30 16:57:38 +00:00
|
|
|
kRGBA_GrColorComponentFlags, true);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2015-11-30 16:57:38 +00:00
|
|
|
SkASSERT(!optimizations.fColorPOI.isOpaque());
|
|
|
|
SkASSERT(!optimizations.fColorPOI.isSolidWhite());
|
|
|
|
SkASSERT(optimizations.fCoveragePOI.isSolidWhite());
|
|
|
|
SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput());
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2016-10-28 19:42:34 +00:00
|
|
|
for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) {
|
|
|
|
SkBlendMode xfermode = static_cast<SkBlendMode>(m);
|
2015-11-30 16:57:38 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizations);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrc:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(229 == GrColorUnpackR(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(154 == GrColorUnpackB(xpi.fBlendedColor.fKnownColor));
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kR_GrColorComponentFlag |
|
2015-06-02 17:43:39 +00:00
|
|
|
kB_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDst:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOver:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOver:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcIn:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstIn:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOut:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOut:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcATop:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstATop:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kXor:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kPlus:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kModulate:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kScreen:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
2015-11-30 16:57:38 +00:00
|
|
|
GrPipelineOptimizations optimizations;
|
2016-03-29 16:03:52 +00:00
|
|
|
optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
|
2015-11-30 16:57:38 +00:00
|
|
|
kA_GrColorComponentFlag, false);
|
2016-03-29 16:03:52 +00:00
|
|
|
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags,
|
2015-11-30 16:57:38 +00:00
|
|
|
true);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2015-11-30 16:57:38 +00:00
|
|
|
SkASSERT(optimizations.fColorPOI.isOpaque());
|
|
|
|
SkASSERT(!optimizations.fColorPOI.isSolidWhite());
|
|
|
|
SkASSERT(!optimizations.fCoveragePOI.isSolidWhite());
|
|
|
|
SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput());
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2016-10-28 19:42:34 +00:00
|
|
|
for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) {
|
|
|
|
SkBlendMode xfermode = static_cast<SkBlendMode>(m);
|
2015-11-30 16:57:38 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizations);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrc:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(kA_GrColorComponentFlag == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDst:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOver:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(kA_GrColorComponentFlag == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOver:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcIn:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstIn:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOut:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOut:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcATop:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstATop:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kXor:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kPlus:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kModulate:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kScreen:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
2015-11-30 16:57:38 +00:00
|
|
|
GrPipelineOptimizations optimizations;
|
|
|
|
optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0, 82, 0, 255),
|
2015-05-27 22:08:33 +00:00
|
|
|
kG_GrColorComponentFlag | kA_GrColorComponentFlag, false);
|
2016-03-29 16:03:52 +00:00
|
|
|
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
|
2015-11-30 16:57:38 +00:00
|
|
|
kRGBA_GrColorComponentFlags, true);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2015-11-30 16:57:38 +00:00
|
|
|
SkASSERT(optimizations.fColorPOI.isOpaque());
|
|
|
|
SkASSERT(!optimizations.fColorPOI.isSolidWhite());
|
|
|
|
SkASSERT(optimizations.fCoveragePOI.isSolidWhite());
|
|
|
|
SkASSERT(!optimizations.fCoveragePOI.isFourChannelOutput());
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2016-10-28 19:42:34 +00:00
|
|
|
for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) {
|
|
|
|
SkBlendMode xfermode = static_cast<SkBlendMode>(m);
|
2015-11-30 16:57:38 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, optimizations);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrc:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(82 == GrColorUnpackG(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor));
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kG_GrColorComponentFlag |
|
2015-06-02 17:43:39 +00:00
|
|
|
kA_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDst:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOver:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(82 == GrColorUnpackG(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor));
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kG_GrColorComponentFlag |
|
2015-06-02 17:43:39 +00:00
|
|
|
kA_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOver:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcIn:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstIn:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOut:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOut:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcATop:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstATop:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kXor:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kPlus:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kModulate:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kScreen:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-15 16:31:40 +00:00
|
|
|
static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps) {
|
2016-12-01 21:40:24 +00:00
|
|
|
class TestLCDCoverageBatch : public GrMeshDrawOp {
|
2015-09-18 03:16:13 +00:00
|
|
|
public:
|
2016-12-01 14:36:50 +00:00
|
|
|
DEFINE_OP_CLASS_ID
|
2015-09-18 03:16:13 +00:00
|
|
|
|
|
|
|
TestLCDCoverageBatch() : INHERITED(ClassID()) {}
|
|
|
|
|
|
|
|
private:
|
2016-03-29 16:03:52 +00:00
|
|
|
void computePipelineOptimizations(GrInitInvariantOutput* color,
|
2015-11-24 20:10:10 +00:00
|
|
|
GrInitInvariantOutput* coverage,
|
|
|
|
GrBatchToXPOverrides* overrides) const override {
|
|
|
|
color->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221));
|
|
|
|
coverage->setUnknownFourComponents();
|
2016-01-30 17:59:10 +00:00
|
|
|
coverage->setUsingLCDCoverage(); }
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
const char* name() const override { return "Test LCD Text Batch"; }
|
2015-11-24 20:10:10 +00:00
|
|
|
void initBatchTracker(const GrXPOverridesForBatch&) override {}
|
2016-12-01 14:36:50 +00:00
|
|
|
bool onCombineIfPossible(GrOp*, const GrCaps&) override { return false; }
|
2016-09-27 13:34:10 +00:00
|
|
|
void onPrepareDraws(Target*) const override {}
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2016-12-01 21:40:24 +00:00
|
|
|
typedef GrMeshDrawOp INHERITED;
|
2015-05-27 22:08:33 +00:00
|
|
|
} testLCDCoverageBatch;
|
|
|
|
|
2015-11-24 20:10:10 +00:00
|
|
|
GrPipelineOptimizations opts;
|
|
|
|
testLCDCoverageBatch.getPipelineOptimizations(&opts);
|
|
|
|
GrProcOptInfo colorPOI = opts.fColorPOI;
|
|
|
|
GrProcOptInfo covPOI = opts.fCoveragePOI;
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags());
|
|
|
|
SkASSERT(covPOI.isFourChannelOutput());
|
|
|
|
|
2016-10-28 19:42:34 +00:00
|
|
|
sk_sp<GrXPFactory> xpf(GrPorterDuffXPFactory::Make(SkBlendMode::kSrcOver));
|
2016-05-06 16:41:16 +00:00
|
|
|
TEST_ASSERT(!xpf->willNeedDstTexture(caps, opts));
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<GrXferProcessor> xp(xpf->createXferProcessor(opts, false, nullptr, caps));
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!xp) {
|
|
|
|
ERRORF(reporter, "Failed to create an XP with LCD coverage.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-02 17:43:39 +00:00
|
|
|
GrXPFactory::InvariantBlendedColor blendedColor;
|
|
|
|
xpf->getInvariantBlendedColor(colorPOI, &blendedColor);
|
|
|
|
TEST_ASSERT(blendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
GrColor overrideColor;
|
2015-11-30 16:57:38 +00:00
|
|
|
xp->getOptimizations(opts, false, &overrideColor, caps);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
GrXferProcessor::BlendInfo blendInfo;
|
|
|
|
xp->getBlendInfo(&blendInfo);
|
|
|
|
TEST_ASSERT(blendInfo.fWriteColor);
|
|
|
|
}
|
|
|
|
|
2015-12-01 12:35:26 +00:00
|
|
|
DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, /*factory*/) {
|
2015-05-27 22:08:33 +00:00
|
|
|
GrContextOptions opts;
|
|
|
|
opts.fSuppressDualSourceBlending = true;
|
2016-03-31 01:56:19 +00:00
|
|
|
sk_gpu_test::GrContextFactory mockFactory(opts);
|
2016-04-05 18:06:27 +00:00
|
|
|
GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kNullGL_ContextType);
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!ctx) {
|
|
|
|
SkFAIL("Failed to create null context without ARB_blend_func_extended.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-29 15:02:10 +00:00
|
|
|
const GrCaps& caps = *ctx->caps();
|
2015-05-27 22:08:33 +00:00
|
|
|
if (caps.shaderCaps()->dualSourceBlendingSupport()) {
|
|
|
|
SkFAIL("Null context failed to honor request for no ARB_blend_func_extended.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-10 19:54:56 +00:00
|
|
|
GrBackendObject backendTex =
|
2016-10-27 16:30:08 +00:00
|
|
|
ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_8888_GrPixelConfig);
|
2015-05-27 22:08:33 +00:00
|
|
|
GrBackendTextureDesc fakeDesc;
|
|
|
|
fakeDesc.fConfig = kRGBA_8888_GrPixelConfig;
|
|
|
|
fakeDesc.fWidth = fakeDesc.fHeight = 100;
|
2015-11-10 19:54:56 +00:00
|
|
|
fakeDesc.fTextureHandle = backendTex;
|
2015-05-27 22:08:33 +00:00
|
|
|
GrXferProcessor::DstTexture fakeDstTexture;
|
2016-10-27 16:30:08 +00:00
|
|
|
fakeDstTexture.setTexture(
|
|
|
|
ctx->textureProvider()->wrapBackendTexture(fakeDesc, kBorrow_GrWrapOwnership));
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
static const GrColor testColors[] = {
|
|
|
|
0,
|
|
|
|
GrColorPackRGBA(0, 82, 0, 255),
|
|
|
|
GrColorPackA4(255)
|
|
|
|
};
|
|
|
|
static const GrColorComponentFlags testColorFlags[] = {
|
|
|
|
kNone_GrColorComponentFlags,
|
|
|
|
kG_GrColorComponentFlag | kA_GrColorComponentFlag,
|
|
|
|
kRGBA_GrColorComponentFlags
|
|
|
|
};
|
|
|
|
GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags));
|
|
|
|
|
|
|
|
for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) {
|
2015-11-30 16:57:38 +00:00
|
|
|
GrPipelineOptimizations optimizations;
|
2016-03-29 16:03:52 +00:00
|
|
|
optimizations.fColorPOI.calcWithInitialValues(nullptr, 0, testColors[c], testColorFlags[c],
|
2015-11-30 16:57:38 +00:00
|
|
|
false);
|
2015-05-27 22:08:33 +00:00
|
|
|
for (int f = 0; f <= 1; f++) {
|
|
|
|
if (!f) {
|
2016-03-29 16:03:52 +00:00
|
|
|
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, 0,
|
2015-11-30 16:57:38 +00:00
|
|
|
kNone_GrColorComponentFlags, true);
|
2015-05-27 22:08:33 +00:00
|
|
|
} else {
|
2015-11-30 16:57:38 +00:00
|
|
|
optimizations.fCoveragePOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
|
|
|
|
kRGBA_GrColorComponentFlags, true);
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|
2016-10-28 19:42:34 +00:00
|
|
|
for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) {
|
|
|
|
SkBlendMode xfermode = static_cast<SkBlendMode>(m);
|
2016-06-09 15:01:03 +00:00
|
|
|
sk_sp<GrXPFactory> xpf(GrPorterDuffXPFactory::Make(xfermode));
|
2015-06-08 22:11:04 +00:00
|
|
|
GrXferProcessor::DstTexture* dstTexture =
|
2016-05-06 16:41:16 +00:00
|
|
|
xpf->willNeedDstTexture(caps, optimizations) ? &fakeDstTexture : 0;
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<GrXferProcessor> xp(
|
2015-11-30 16:57:38 +00:00
|
|
|
xpf->createXferProcessor(optimizations, false, dstTexture, caps));
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!xp) {
|
|
|
|
ERRORF(reporter, "Failed to create an XP without dual source blending.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TEST_ASSERT(!xp->hasSecondaryOutput());
|
2015-11-30 16:57:38 +00:00
|
|
|
xp->getOptimizations(optimizations, false, 0, caps);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(!xp->hasSecondaryOutput());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-10 19:54:56 +00:00
|
|
|
ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|