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"
|
|
|
|
#include "effects/GrPorterDuffXferProcessor.h"
|
|
|
|
#include "gl/GrGLCaps.h"
|
2016-12-16 14:52:16 +00:00
|
|
|
#include "ops/GrMeshDrawOp.h"
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
2017-03-28 20:32:05 +00:00
|
|
|
static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
2015-05-27 22:08:33 +00:00
|
|
|
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);
|
2017-03-28 20:32:05 +00:00
|
|
|
test_color_not_opaque_no_coverage(reporter, caps);
|
2015-05-27 22:08:33 +00:00
|
|
|
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
|
|
|
|
};
|
|
|
|
|
2017-04-08 11:38:53 +00:00
|
|
|
static GrProcessorSet::Analysis do_analysis(const GrXPFactory* xpf,
|
|
|
|
const GrProcessorAnalysisColor& colorInput,
|
|
|
|
GrProcessorAnalysisCoverage coverageInput,
|
|
|
|
const GrCaps& caps) {
|
|
|
|
GrPaint paint;
|
|
|
|
paint.setXPFactory(xpf);
|
|
|
|
GrProcessorSet procs(std::move(paint));
|
|
|
|
GrColor overrideColor;
|
|
|
|
GrProcessorSet::Analysis analysis =
|
|
|
|
procs.finalize(colorInput, coverageInput, nullptr, false, caps, &overrideColor);
|
|
|
|
return analysis;
|
|
|
|
}
|
|
|
|
|
2015-05-27 22:08:33 +00:00
|
|
|
class GrPorterDuffTest {
|
|
|
|
public:
|
|
|
|
struct XPInfo {
|
2016-10-28 19:42:34 +00:00
|
|
|
XPInfo(skiatest::Reporter* reporter, SkBlendMode xfermode, const GrCaps& caps,
|
2017-03-30 12:21:32 +00:00
|
|
|
GrProcessorAnalysisColor inputColor, GrProcessorAnalysisCoverage inputCoverage) {
|
2017-01-09 16:46:10 +00:00
|
|
|
const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(xfermode);
|
2017-04-08 11:38:53 +00:00
|
|
|
|
|
|
|
GrProcessorSet::Analysis analysis = do_analysis(xpf, inputColor, inputCoverage, caps);
|
2017-03-28 20:32:05 +00:00
|
|
|
fCompatibleWithCoverageAsAlpha = analysis.isCompatibleWithCoverageAsAlpha();
|
|
|
|
fCanCombineOverlappedStencilAndCover = analysis.canCombineOverlappedStencilAndCover();
|
2017-04-08 11:38:53 +00:00
|
|
|
fIgnoresInputColor = analysis.inputColorIsIgnored();
|
2017-04-10 14:54:25 +00:00
|
|
|
sk_sp<const GrXferProcessor> xp(
|
2017-04-04 19:17:03 +00:00
|
|
|
GrXPFactory::MakeXferProcessor(xpf, inputColor, inputCoverage, false, caps));
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!analysis.requiresDstTexture());
|
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));
|
|
|
|
}
|
|
|
|
|
2017-03-21 18:22:38 +00:00
|
|
|
bool fCanCombineOverlappedStencilAndCover;
|
2017-03-28 20:32:05 +00:00
|
|
|
bool fCompatibleWithCoverageAsAlpha;
|
|
|
|
bool fIgnoresInputColor;
|
2015-05-27 22:08:33 +00:00
|
|
|
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) {
|
2017-03-30 12:21:32 +00:00
|
|
|
GrProcessorAnalysisColor inputColor = GrProcessorAnalysisColor::Opaque::kNo;
|
|
|
|
GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kLCD;
|
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);
|
2017-03-28 20:32:05 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage);
|
2015-09-15 16:31:40 +00:00
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +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(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDst:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +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(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstIn:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +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(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOut:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-09-15 16:31:40 +00:00
|
|
|
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) {
|
2017-03-30 12:21:32 +00:00
|
|
|
GrProcessorAnalysisColor inputColor = GrProcessorAnalysisColor::Opaque::kNo;
|
|
|
|
GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kSingleChannel;
|
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);
|
2017-03-28 20:32:05 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage);
|
2015-05-27 22:08:33 +00:00
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-28 20:32:05 +00:00
|
|
|
static void test_color_not_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
2017-03-30 12:21:32 +00:00
|
|
|
GrProcessorAnalysisColor inputColor(GrColorPackRGBA(229, 0, 154, 240));
|
|
|
|
GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kNone;
|
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);
|
2017-03-28 20:32:05 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage);
|
2015-05-27 22:08:33 +00:00
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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) {
|
2017-03-30 12:21:32 +00:00
|
|
|
GrProcessorAnalysisColor inputColor = GrProcessorAnalysisColor::Opaque::kYes;
|
|
|
|
GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kSingleChannel;
|
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);
|
2017-03-28 20:32:05 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage);
|
2015-05-27 22:08:33 +00:00
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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) {
|
2017-03-30 12:21:32 +00:00
|
|
|
GrProcessorAnalysisColor inputColor = GrProcessorAnalysisColor::Opaque::kYes;
|
|
|
|
GrProcessorAnalysisCoverage inputCoverage = GrProcessorAnalysisCoverage::kNone;
|
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);
|
2017-03-28 20:32:05 +00:00
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, inputColor, inputCoverage);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
switch (xfermode) {
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kClear:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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:
|
2017-03-21 18:22:38 +00:00
|
|
|
TEST_ASSERT(!xpi.fCanCombineOverlappedStencilAndCover);
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(xpi.fCompatibleWithCoverageAsAlpha);
|
2015-05-27 22:08:33 +00:00
|
|
|
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) {
|
2017-03-28 20:32:05 +00:00
|
|
|
const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(SkBlendMode::kSrcOver);
|
2017-03-30 12:21:32 +00:00
|
|
|
GrProcessorAnalysisColor color = GrColorPackRGBA(123, 45, 67, 221);
|
|
|
|
GrProcessorAnalysisCoverage coverage = GrProcessorAnalysisCoverage::kLCD;
|
2017-03-29 18:25:04 +00:00
|
|
|
SkASSERT(!(GrXPFactory::GetAnalysisProperties(xpf, color, coverage, caps) &
|
|
|
|
GrXPFactory::AnalysisProperties::kRequiresDstTexture));
|
2017-04-10 14:54:25 +00:00
|
|
|
sk_sp<const GrXferProcessor> xp(
|
|
|
|
GrXPFactory::MakeXferProcessor(xpf, color, coverage, false, caps));
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!xp) {
|
|
|
|
ERRORF(reporter, "Failed to create an XP with LCD coverage.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-04-19 00:23:39 +00:00
|
|
|
GrBackendObject backendTex =
|
2016-10-27 16:30:08 +00:00
|
|
|
ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_8888_GrPixelConfig);
|
2017-04-19 00:23:39 +00:00
|
|
|
GrBackendTextureDesc fakeDesc;
|
|
|
|
fakeDesc.fConfig = kRGBA_8888_GrPixelConfig;
|
|
|
|
fakeDesc.fWidth = fakeDesc.fHeight = 100;
|
|
|
|
fakeDesc.fTextureHandle = backendTex;
|
2015-05-27 22:08:33 +00:00
|
|
|
GrXferProcessor::DstTexture fakeDstTexture;
|
2016-10-27 16:30:08 +00:00
|
|
|
fakeDstTexture.setTexture(
|
2017-04-19 00:23:39 +00:00
|
|
|
ctx->resourceProvider()->wrapBackendTexture(fakeDesc, kBorrow_GrWrapOwnership));
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2017-03-30 12:21:32 +00:00
|
|
|
static const GrProcessorAnalysisColor colorInputs[] = {
|
|
|
|
GrProcessorAnalysisColor::Opaque::kNo, GrProcessorAnalysisColor::Opaque::kYes,
|
|
|
|
GrProcessorAnalysisColor(GrColorPackRGBA(0, 82, 17, 100)),
|
|
|
|
GrProcessorAnalysisColor(GrColorPackRGBA(0, 82, 17, 255))};
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2017-02-14 16:33:01 +00:00
|
|
|
for (const auto& colorInput : colorInputs) {
|
2017-03-30 12:21:32 +00:00
|
|
|
for (GrProcessorAnalysisCoverage coverageType :
|
|
|
|
{GrProcessorAnalysisCoverage::kSingleChannel, GrProcessorAnalysisCoverage::kNone}) {
|
2016-10-28 19:42:34 +00:00
|
|
|
for (int m = 0; m <= (int)SkBlendMode::kLastCoeffMode; m++) {
|
|
|
|
SkBlendMode xfermode = static_cast<SkBlendMode>(m);
|
2017-01-09 16:46:10 +00:00
|
|
|
const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(xfermode);
|
2017-04-10 14:54:25 +00:00
|
|
|
sk_sp<const GrXferProcessor> xp(
|
2017-04-04 19:17:03 +00:00
|
|
|
GrXPFactory::MakeXferProcessor(xpf, colorInput, coverageType, false, 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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-04-19 00:23:39 +00:00
|
|
|
ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|