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.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tests/Test.h"
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "include/gpu/GrBackendSurface.h"
|
|
|
|
#include "include/gpu/GrContextOptions.h"
|
|
|
|
#include "src/gpu/GrContextPriv.h"
|
|
|
|
#include "src/gpu/GrGpu.h"
|
|
|
|
#include "src/gpu/GrProxyProvider.h"
|
|
|
|
#include "src/gpu/GrXferProcessor.h"
|
|
|
|
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
|
|
|
|
#include "src/gpu/gl/GrGLCaps.h"
|
|
|
|
#include "src/gpu/ops/GrMeshDrawOp.h"
|
|
|
|
#include "tools/gpu/GrContextFactory.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
|
|
|
|
2019-03-26 15:31:16 +00:00
|
|
|
DEF_GPUTEST(GrPorterDuff, reporter, /*ctxInfo*/) {
|
|
|
|
GrMockOptions mockOptions;
|
|
|
|
mockOptions.fDualSourceBlendingSupport = true;
|
|
|
|
auto context = GrContext::MakeMock(&mockOptions, GrContextOptions());
|
|
|
|
const GrCaps& caps = *context->priv().getGpu()->caps();
|
|
|
|
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!caps.shaderCaps()->dualSourceBlendingSupport()) {
|
2017-08-16 14:53:04 +00:00
|
|
|
SK_ABORT("Null context does not support dual source blending.");
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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-05-22 19:56:22 +00:00
|
|
|
static const int kInvalid_OutputType = -1;
|
2015-05-27 22:08:33 +00:00
|
|
|
|
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));
|
2019-06-24 00:07:38 +00:00
|
|
|
bool hasMixedSampledCoverage = false;
|
2018-10-31 18:04:39 +00:00
|
|
|
SkPMColor4f overrideColor;
|
2019-03-05 17:11:58 +00:00
|
|
|
GrProcessorSet::Analysis analysis = procs.finalize(
|
2019-06-24 00:07:38 +00:00
|
|
|
colorInput, coverageInput, nullptr, &GrUserStencilSettings::kUnused,
|
|
|
|
hasMixedSampledCoverage, caps, GrClampType::kAuto, &overrideColor);
|
2017-04-08 11:38:53 +00:00
|
|
|
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
|
|
|
|
2017-05-22 19:56:22 +00:00
|
|
|
bool isLCD = GrProcessorAnalysisCoverage::kLCD == inputCoverage;
|
|
|
|
|
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();
|
2017-04-08 11:38:53 +00:00
|
|
|
fIgnoresInputColor = analysis.inputColorIsIgnored();
|
2017-04-10 14:54:25 +00:00
|
|
|
sk_sp<const GrXferProcessor> xp(
|
2019-03-15 14:15:29 +00:00
|
|
|
GrXPFactory::MakeXferProcessor(xpf, inputColor, inputCoverage, false, caps,
|
|
|
|
GrClampType::kAuto));
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(!analysis.requiresDstTexture() ||
|
|
|
|
(isLCD &&
|
|
|
|
!caps.shaderCaps()->dstReadInShaderSupport() &&
|
|
|
|
(SkBlendMode::kSrcOver != xfermode ||
|
|
|
|
!inputColor.isOpaque())));
|
2019-01-23 16:10:36 +00:00
|
|
|
// Porter Duff modes currently only use fixed-function or shader blending, and Ganesh
|
|
|
|
// doesn't yet make use of framebuffer fetches that require a barrier
|
|
|
|
// (e.g., QCOM_shader_framebuffer_fetch_noncoherent). So dst textures and xfer barriers
|
|
|
|
// should always go hand in hand for Porter Duff modes.
|
|
|
|
TEST_ASSERT(analysis.requiresDstTexture() == analysis.requiresNonOverlappingDraws());
|
2016-11-04 15:49:42 +00:00
|
|
|
GetXPOutputTypes(xp.get(), &fPrimaryOutputType, &fSecondaryOutputType);
|
2019-07-24 16:25:08 +00:00
|
|
|
fBlendInfo = xp->getBlendInfo();
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(!xp->willReadDstColor() ||
|
|
|
|
(isLCD && (SkBlendMode::kSrcOver != xfermode ||
|
|
|
|
!inputColor.isOpaque())));
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendInfo.fDstBlend));
|
|
|
|
}
|
|
|
|
|
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-05-19 14:56:46 +00:00
|
|
|
GrProcessorAnalysisColor inputColor = GrProcessorAnalysisColor::Opaque::kYes;
|
2017-03-30 12:21:32 +00:00
|
|
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrc:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDst:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
2015-09-15 16:31:40 +00:00
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOver:
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcIn:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstIn:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcOut:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOut:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kSrcATop:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstATop:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kXor:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kPlus:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kModulate:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kScreen:
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
|
|
|
TEST_ASSERT(!xpi.fCompatibleWithCoverageAsAlpha);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kInvalid_OutputType == xpi.fSecondaryOutputType);
|
2015-09-15 16:31:40 +00:00
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
2017-05-22 19:56:22 +00:00
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
2015-09-15 16:31:40 +00:00
|
|
|
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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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) {
|
2018-10-31 18:04:39 +00:00
|
|
|
GrProcessorAnalysisColor inputColor(
|
|
|
|
SkPMColor4f::FromBytes_RGBA(GrColorPackRGBA(229, 0, 154, 240)));
|
2017-03-30 12:21:32 +00:00
|
|
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-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-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-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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-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-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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-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-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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-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-06-05 16:25:13 +00:00
|
|
|
// We don't specialize opaque src-over. See note in GrPorterDuffXferProcessor.cpp
|
2017-03-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2017-06-05 16:25:13 +00:00
|
|
|
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);
|
2020-01-08 18:39:16 +00:00
|
|
|
if (caps.shouldCollapseSrcOverToSrcWhenAble()) {
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
} else {
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
}
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
2016-10-28 19:42:34 +00:00
|
|
|
case SkBlendMode::kDstOver:
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-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-28 20:32:05 +00:00
|
|
|
TEST_ASSERT(!xpi.fIgnoresInputColor);
|
2020-02-28 18:06:02 +00:00
|
|
|
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-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) {
|
2019-03-15 14:15:29 +00:00
|
|
|
constexpr GrClampType autoClamp = GrClampType::kAuto;
|
2017-03-28 20:32:05 +00:00
|
|
|
const GrXPFactory* xpf = GrPorterDuffXPFactory::Get(SkBlendMode::kSrcOver);
|
2018-10-31 18:04:39 +00:00
|
|
|
GrProcessorAnalysisColor color = SkPMColor4f::FromBytes_RGBA(GrColorPackRGBA(123, 45, 67, 255));
|
2017-03-30 12:21:32 +00:00
|
|
|
GrProcessorAnalysisCoverage coverage = GrProcessorAnalysisCoverage::kLCD;
|
2019-03-15 14:15:29 +00:00
|
|
|
TEST_ASSERT(!(GrXPFactory::GetAnalysisProperties(xpf, color, coverage, caps, autoClamp) &
|
2017-05-19 14:56:46 +00:00
|
|
|
GrXPFactory::AnalysisProperties::kRequiresDstTexture));
|
|
|
|
sk_sp<const GrXferProcessor> xp_opaque(
|
2019-03-15 14:15:29 +00:00
|
|
|
GrXPFactory::MakeXferProcessor(xpf, color, coverage, false, caps, autoClamp));
|
2017-05-19 14:56:46 +00:00
|
|
|
if (!xp_opaque) {
|
|
|
|
ERRORF(reporter, "Failed to create an XP with LCD coverage.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-24 16:25:08 +00:00
|
|
|
GrXferProcessor::BlendInfo blendInfo = xp_opaque->getBlendInfo();
|
2017-05-19 14:56:46 +00:00
|
|
|
TEST_ASSERT(blendInfo.fWriteColor);
|
|
|
|
|
|
|
|
// Test with non-opaque alpha
|
2018-10-31 18:04:39 +00:00
|
|
|
color = SkPMColor4f::FromBytes_RGBA(GrColorPackRGBA(123, 45, 67, 221));
|
2017-05-19 14:56:46 +00:00
|
|
|
coverage = GrProcessorAnalysisCoverage::kLCD;
|
2019-03-15 14:15:29 +00:00
|
|
|
TEST_ASSERT(!(GrXPFactory::GetAnalysisProperties(xpf, color, coverage, caps, autoClamp) &
|
2017-06-14 17:37:12 +00:00
|
|
|
GrXPFactory::AnalysisProperties::kRequiresDstTexture));
|
2017-04-10 14:54:25 +00:00
|
|
|
sk_sp<const GrXferProcessor> xp(
|
2019-03-15 14:15:29 +00:00
|
|
|
GrXPFactory::MakeXferProcessor(xpf, color, coverage, false, caps, autoClamp));
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!xp) {
|
|
|
|
ERRORF(reporter, "Failed to create an XP with LCD coverage.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-07-24 16:25:08 +00:00
|
|
|
blendInfo = xp->getBlendInfo();
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(blendInfo.fWriteColor);
|
|
|
|
}
|
|
|
|
|
2017-11-15 20:48:03 +00:00
|
|
|
DEF_GPUTEST(PorterDuffNoDualSourceBlending, reporter, options) {
|
|
|
|
GrContextOptions opts = options;
|
2015-05-27 22:08:33 +00:00
|
|
|
opts.fSuppressDualSourceBlending = true;
|
2016-03-31 01:56:19 +00:00
|
|
|
sk_gpu_test::GrContextFactory mockFactory(opts);
|
2019-03-26 15:10:11 +00:00
|
|
|
GrContext* ctx = mockFactory.get(sk_gpu_test::GrContextFactory::kMock_ContextType);
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!ctx) {
|
2019-03-26 15:10:11 +00:00
|
|
|
SK_ABORT("Failed to create mock context without ARB_blend_func_extended.");
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|
|
|
|
|
2019-02-04 18:26:26 +00:00
|
|
|
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
|
|
|
|
const GrCaps& caps = *ctx->priv().caps();
|
2015-05-27 22:08:33 +00:00
|
|
|
if (caps.shaderCaps()->dualSourceBlendingSupport()) {
|
2019-03-26 15:10:11 +00:00
|
|
|
SK_ABORT("Mock context failed to honor request for no ARB_blend_func_extended.");
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|
|
|
|
|
2017-12-12 18:01:25 +00:00
|
|
|
GrBackendTexture backendTex =
|
2019-06-04 15:03:06 +00:00
|
|
|
ctx->createBackendTexture(100, 100, kRGBA_8888_SkColorType, SkColors::kTransparent,
|
2019-07-01 19:04:06 +00:00
|
|
|
GrMipMapped::kNo, GrRenderable::kNo, GrProtected::kNo);
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
|
2019-11-01 15:48:53 +00:00
|
|
|
GrXferProcessor::DstProxyView fakeDstProxyView;
|
2017-05-29 19:05:15 +00:00
|
|
|
{
|
2018-12-06 15:00:03 +00:00
|
|
|
sk_sp<GrTextureProxy> proxy = proxyProvider->wrapBackendTexture(
|
2020-03-27 14:42:15 +00:00
|
|
|
backendTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRead_GrIOType);
|
2019-12-17 21:18:06 +00:00
|
|
|
GrSwizzle swizzle = caps.getReadSwizzle(backendTex.getBackendFormat(),
|
2019-11-01 15:48:53 +00:00
|
|
|
GrColorType::kRGBA_8888);
|
|
|
|
fakeDstProxyView.setProxyView({std::move(proxy), kTopLeft_GrSurfaceOrigin, swizzle});
|
2017-05-29 19:05:15 +00:00
|
|
|
}
|
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,
|
2018-10-31 18:04:39 +00:00
|
|
|
GrProcessorAnalysisColor(SkPMColor4f::FromBytes_RGBA(GrColorPackRGBA(0, 82, 17, 100))),
|
|
|
|
GrProcessorAnalysisColor(SkPMColor4f::FromBytes_RGBA(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(
|
2019-03-15 14:15:29 +00:00
|
|
|
GrXPFactory::MakeXferProcessor(xpf, colorInput, coverageType, false, caps,
|
|
|
|
GrClampType::kAuto));
|
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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-05-20 12:38:07 +00:00
|
|
|
ctx->deleteBackendTexture(backendTex);
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|