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 "SkXfermode.h"
|
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
|
|
|
|
#include "GrContextFactory.h"
|
|
|
|
#include "GrContextOptions.h"
|
|
|
|
#include "GrGpu.h"
|
|
|
|
#include "GrResourceProvider.h"
|
|
|
|
#include "GrXferProcessor.h"
|
2015-08-13 21:55:50 +00:00
|
|
|
#include "batches/GrVertexBatch.h"
|
2015-05-27 22:08:33 +00:00
|
|
|
#include "effects/GrPorterDuffXferProcessor.h"
|
|
|
|
#include "gl/GrGLCaps.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
|
|
|
static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
|
|
|
static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
|
|
|
static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
|
|
|
static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps);
|
2015-09-15 16:31:40 +00:00
|
|
|
static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps);
|
2015-05-27 22:08:33 +00:00
|
|
|
static void test_no_dual_source_blending(skiatest::Reporter* reporter);
|
|
|
|
|
|
|
|
DEF_GPUTEST(GrPorterDuff, reporter, factory) {
|
|
|
|
GrContext* ctx = factory->get(GrContextFactory::kNull_GLContextType);
|
|
|
|
if (!ctx) {
|
|
|
|
SkFAIL("Failed to create null context.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const GrCaps& caps = *ctx->getGpu()->caps();
|
|
|
|
if (!caps.shaderCaps()->dualSourceBlendingSupport()) {
|
|
|
|
SkFAIL("Null context does not support dual source blending.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
test_color_unknown_with_coverage(reporter, caps);
|
|
|
|
test_color_unknown_no_coverage(reporter, caps);
|
|
|
|
test_color_opaque_with_coverage(reporter, caps);
|
|
|
|
test_color_opaque_no_coverage(reporter, caps);
|
|
|
|
test_lcd_coverage(reporter, caps);
|
2015-09-15 16:31:40 +00:00
|
|
|
test_lcd_coverage_fallback_case(reporter, caps);
|
2015-05-27 22:08:33 +00:00
|
|
|
test_no_dual_source_blending(reporter);
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define TEST_ASSERT(...) REPORTER_ASSERT(reporter, __VA_ARGS__)
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kNone_OutputType,
|
|
|
|
kCoverage_OutputType,
|
|
|
|
kModulate_OutputType,
|
2015-09-15 16:31:40 +00:00
|
|
|
kSAModulate_OutputType,
|
2015-05-27 22:08:33 +00:00
|
|
|
kISAModulate_OutputType,
|
|
|
|
kISCModulate_OutputType
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
2015-07-08 18:26:37 +00:00
|
|
|
kNone_OptFlags = GrXferProcessor::kNone_OptFlags,
|
2015-05-27 22:08:33 +00:00
|
|
|
kSkipDraw_OptFlag = GrXferProcessor::kSkipDraw_OptFlag,
|
|
|
|
kIgnoreColor_OptFlag = GrXferProcessor::kIgnoreColor_OptFlag,
|
|
|
|
kIgnoreCoverage_OptFlag = GrXferProcessor::kIgnoreCoverage_OptFlag,
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag = GrXferProcessor::kCanTweakAlphaForCoverage_OptFlag
|
|
|
|
};
|
|
|
|
|
|
|
|
class GrPorterDuffTest {
|
|
|
|
public:
|
|
|
|
struct XPInfo {
|
|
|
|
XPInfo(skiatest::Reporter* reporter, SkXfermode::Mode xfermode, const GrCaps& caps,
|
|
|
|
const GrProcOptInfo& colorPOI, const GrProcOptInfo& covPOI) {
|
|
|
|
SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode));
|
2015-06-08 22:11:04 +00:00
|
|
|
SkAutoTUnref<GrXferProcessor> xp(
|
2015-08-27 14:41:13 +00:00
|
|
|
xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps));
|
2015-06-08 22:11:04 +00:00
|
|
|
TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false));
|
2015-06-02 17:43:39 +00:00
|
|
|
xpf->getInvariantBlendedColor(colorPOI, &fBlendedColor);
|
2015-08-27 14:41:13 +00:00
|
|
|
fOptFlags = xp->getOptimizations(colorPOI, covPOI, false, nullptr, caps);
|
2015-05-27 22:08:33 +00:00
|
|
|
GetXPOutputTypes(xp, &fPrimaryOutputType, &fSecondaryOutputType);
|
|
|
|
xp->getBlendInfo(&fBlendInfo);
|
|
|
|
TEST_ASSERT(!xp->willReadDstColor());
|
|
|
|
TEST_ASSERT(xp->hasSecondaryOutput() == GrBlendCoeffRefsSrc2(fBlendInfo.fDstBlend));
|
|
|
|
}
|
|
|
|
|
2015-06-02 17:43:39 +00:00
|
|
|
GrXPFactory::InvariantBlendedColor fBlendedColor;
|
2015-05-27 22:08:33 +00:00
|
|
|
int fOptFlags;
|
|
|
|
int fPrimaryOutputType;
|
|
|
|
int fSecondaryOutputType;
|
|
|
|
GrXferProcessor::BlendInfo fBlendInfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void GetXPOutputTypes(const GrXferProcessor* xp, int* outPrimary, int* outSecondary) {
|
|
|
|
GrPorterDuffXPFactory::TestGetXPOutputTypes(xp, outPrimary, outSecondary);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-09-15 16:31:40 +00:00
|
|
|
static void test_lcd_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
|
|
|
GrProcOptInfo colorPOI, covPOI;
|
|
|
|
colorPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false);
|
|
|
|
// Setting 2nd to last value to false and last to true will force covPOI to LCD coverage.
|
|
|
|
covPOI.calcWithInitialValues(NULL, 0, 0, kNone_GrColorComponentFlags, false, true);
|
|
|
|
|
|
|
|
SkASSERT(!colorPOI.isOpaque());
|
|
|
|
SkASSERT(!colorPOI.isSolidWhite());
|
|
|
|
SkASSERT(!covPOI.isSolidWhite());
|
|
|
|
SkASSERT(covPOI.isFourChannelOutput());
|
|
|
|
|
|
|
|
for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
|
|
|
|
SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
|
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI);
|
|
|
|
|
|
|
|
switch (xfermode) {
|
|
|
|
case SkXfermode::kClear_Mode:
|
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrc_Mode:
|
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDst_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOver_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOver_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcIn_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstIn_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOut_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOut_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kSAModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcATop_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstATop_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kXor_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kSAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kPlus_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kModulate_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kScreen_Mode:
|
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-27 22:08:33 +00:00
|
|
|
static void test_color_unknown_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
|
|
|
GrProcOptInfo colorPOI, covPOI;
|
2015-08-27 14:41:13 +00:00
|
|
|
colorPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, false);
|
|
|
|
covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, true);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
SkASSERT(!colorPOI.isOpaque());
|
|
|
|
SkASSERT(!colorPOI.isSolidWhite());
|
|
|
|
SkASSERT(!covPOI.isSolidWhite());
|
|
|
|
SkASSERT(!covPOI.isFourChannelOutput());
|
|
|
|
|
|
|
|
for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
|
|
|
|
SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
|
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI);
|
|
|
|
|
2015-09-15 16:31:40 +00:00
|
|
|
|
2015-05-27 22:08:33 +00:00
|
|
|
switch (xfermode) {
|
|
|
|
case SkXfermode::kClear_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrc_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDst_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOver_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOver_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcIn_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstIn_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kISAModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOut_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2A_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOut_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcATop_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstATop_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kISAModulate_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kIS2C_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kXor_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kPlus_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kModulate_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kScreen_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_color_unknown_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
|
|
|
GrProcOptInfo colorPOI, covPOI;
|
2015-08-27 14:41:13 +00:00
|
|
|
colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(229, 0, 154, 0),
|
2015-05-27 22:08:33 +00:00
|
|
|
kR_GrColorComponentFlag | kB_GrColorComponentFlag, false);
|
2015-08-27 14:41:13 +00:00
|
|
|
covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kRGBA_GrColorComponentFlags, true);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
SkASSERT(!colorPOI.isOpaque());
|
|
|
|
SkASSERT(!colorPOI.isSolidWhite());
|
|
|
|
SkASSERT(covPOI.isSolidWhite());
|
|
|
|
SkASSERT(!covPOI.isFourChannelOutput());
|
|
|
|
|
|
|
|
for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
|
|
|
|
SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
|
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI);
|
|
|
|
|
|
|
|
switch (xfermode) {
|
|
|
|
case SkXfermode::kClear_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrc_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(229 == GrColorUnpackR(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(154 == GrColorUnpackB(xpi.fBlendedColor.fKnownColor));
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kR_GrColorComponentFlag |
|
2015-06-02 17:43:39 +00:00
|
|
|
kB_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDst_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOver_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOver_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcIn_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstIn_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOut_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOut_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcATop_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstATop_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kSA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kXor_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kPlus_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kModulate_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kScreen_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_color_opaque_with_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
|
|
|
GrProcOptInfo colorPOI, covPOI;
|
2015-08-27 14:41:13 +00:00
|
|
|
colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kA_GrColorComponentFlag, false);
|
|
|
|
covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, true);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
SkASSERT(colorPOI.isOpaque());
|
|
|
|
SkASSERT(!colorPOI.isSolidWhite());
|
|
|
|
SkASSERT(!covPOI.isSolidWhite());
|
|
|
|
SkASSERT(!covPOI.isFourChannelOutput());
|
|
|
|
|
|
|
|
for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
|
|
|
|
SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
|
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI);
|
|
|
|
|
|
|
|
switch (xfermode) {
|
|
|
|
case SkXfermode::kClear_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrc_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(kA_GrColorComponentFlag == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDst_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOver_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(kA_GrColorComponentFlag == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOver_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcIn_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstIn_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOut_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOut_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kCoverage_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcATop_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstATop_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kXor_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISA_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kPlus_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kModulate_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-07-08 18:26:37 +00:00
|
|
|
TEST_ASSERT((kNone_OptFlags) == xpi.fOptFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT(kISCModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kReverseSubtract_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDC_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kScreen_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_color_opaque_no_coverage(skiatest::Reporter* reporter, const GrCaps& caps) {
|
|
|
|
GrProcOptInfo colorPOI, covPOI;
|
2015-08-27 14:41:13 +00:00
|
|
|
colorPOI.calcWithInitialValues(nullptr, 0, GrColorPackRGBA(0, 82, 0, 255),
|
2015-05-27 22:08:33 +00:00
|
|
|
kG_GrColorComponentFlag | kA_GrColorComponentFlag, false);
|
2015-08-27 14:41:13 +00:00
|
|
|
covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255), kRGBA_GrColorComponentFlags, true);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
SkASSERT(colorPOI.isOpaque());
|
|
|
|
SkASSERT(!colorPOI.isSolidWhite());
|
|
|
|
SkASSERT(covPOI.isSolidWhite());
|
|
|
|
SkASSERT(!covPOI.isFourChannelOutput());
|
|
|
|
|
|
|
|
for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
|
|
|
|
SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
|
|
|
|
const GrPorterDuffTest::XPInfo xpi(reporter, xfermode, caps, colorPOI, covPOI);
|
|
|
|
|
|
|
|
switch (xfermode) {
|
|
|
|
case SkXfermode::kClear_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrc_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(82 == GrColorUnpackG(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor));
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kG_GrColorComponentFlag |
|
2015-06-02 17:43:39 +00:00
|
|
|
kA_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDst_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOver_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(82 == GrColorUnpackG(xpi.fBlendedColor.fKnownColor));
|
|
|
|
TEST_ASSERT(255 == GrColorUnpackA(xpi.fBlendedColor.fKnownColor));
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kG_GrColorComponentFlag |
|
2015-06-02 17:43:39 +00:00
|
|
|
kA_GrColorComponentFlag) == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOver_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcIn_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstIn_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kSkipDraw_OptFlag |
|
|
|
|
kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(!xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcOut_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstOut_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(!xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(0 == xpi.fBlendedColor.fKnownColor);
|
|
|
|
TEST_ASSERT(kRGBA_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreColor_OptFlag |
|
|
|
|
kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kSrcATop_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kDstATop_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kXor_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kIDA_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kPlus_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kModulate_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kZero_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kSC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
case SkXfermode::kScreen_Mode:
|
2015-06-02 17:43:39 +00:00
|
|
|
TEST_ASSERT(xpi.fBlendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == xpi.fBlendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
TEST_ASSERT((kIgnoreCoverage_OptFlag |
|
|
|
|
kCanTweakAlphaForCoverage_OptFlag) == xpi.fOptFlags);
|
|
|
|
TEST_ASSERT(kModulate_OutputType == xpi.fPrimaryOutputType);
|
|
|
|
TEST_ASSERT(kNone_OutputType == xpi.fSecondaryOutputType);
|
|
|
|
TEST_ASSERT(kAdd_GrBlendEquation == xpi.fBlendInfo.fEquation);
|
|
|
|
TEST_ASSERT(kOne_GrBlendCoeff == xpi.fBlendInfo.fSrcBlend);
|
|
|
|
TEST_ASSERT(kISC_GrBlendCoeff == xpi.fBlendInfo.fDstBlend);
|
|
|
|
TEST_ASSERT(xpi.fBlendInfo.fWriteColor);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERRORF(reporter, "Invalid xfermode.");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-15 16:31:40 +00:00
|
|
|
static void test_lcd_coverage_fallback_case(skiatest::Reporter* reporter, const GrCaps& caps) {
|
2015-09-18 03:16:13 +00:00
|
|
|
class TestLCDCoverageBatch: public GrVertexBatch {
|
|
|
|
public:
|
|
|
|
DEFINE_BATCH_CLASS_ID
|
|
|
|
|
|
|
|
TestLCDCoverageBatch() : INHERITED(ClassID()) {}
|
|
|
|
|
|
|
|
private:
|
2015-05-27 22:08:33 +00:00
|
|
|
void getInvariantOutputColor(GrInitInvariantOutput* out) const override {
|
|
|
|
out->setKnownFourComponents(GrColorPackRGBA(123, 45, 67, 221));
|
|
|
|
}
|
|
|
|
|
|
|
|
void getInvariantOutputCoverage(GrInitInvariantOutput* out) const override {
|
|
|
|
out->setUnknownFourComponents();
|
|
|
|
out->setUsingLCDCoverage();
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* name() const override { return "Test LCD Text Batch"; }
|
2015-08-10 17:47:29 +00:00
|
|
|
void initBatchTracker(const GrPipelineOptimizations&) override {}
|
2015-08-12 18:14:50 +00:00
|
|
|
bool onCombineIfPossible(GrBatch*, const GrCaps&) override { return false; }
|
2015-08-17 19:55:38 +00:00
|
|
|
void onPrepareDraws(Target*) override {};
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2015-09-18 03:16:13 +00:00
|
|
|
typedef GrVertexBatch INHERITED;
|
2015-05-27 22:08:33 +00:00
|
|
|
} testLCDCoverageBatch;
|
|
|
|
|
|
|
|
GrProcOptInfo colorPOI, covPOI;
|
2015-08-27 14:41:13 +00:00
|
|
|
colorPOI.calcColorWithBatch(&testLCDCoverageBatch, nullptr, 0);
|
|
|
|
covPOI.calcCoverageWithBatch(&testLCDCoverageBatch, nullptr, 0);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
SkASSERT(kRGBA_GrColorComponentFlags == colorPOI.validFlags());
|
|
|
|
SkASSERT(covPOI.isFourChannelOutput());
|
|
|
|
|
|
|
|
SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(SkXfermode::kSrcOver_Mode));
|
2015-06-08 22:11:04 +00:00
|
|
|
TEST_ASSERT(!xpf->willNeedDstTexture(caps, colorPOI, covPOI, false));
|
2015-05-27 22:08:33 +00:00
|
|
|
|
2015-06-08 22:11:04 +00:00
|
|
|
SkAutoTUnref<GrXferProcessor> xp(
|
2015-08-27 14:41:13 +00:00
|
|
|
xpf->createXferProcessor(colorPOI, covPOI, false, nullptr, caps));
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!xp) {
|
|
|
|
ERRORF(reporter, "Failed to create an XP with LCD coverage.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-06-02 17:43:39 +00:00
|
|
|
GrXPFactory::InvariantBlendedColor blendedColor;
|
|
|
|
xpf->getInvariantBlendedColor(colorPOI, &blendedColor);
|
|
|
|
TEST_ASSERT(blendedColor.fWillBlendWithDst);
|
|
|
|
TEST_ASSERT(kNone_GrColorComponentFlags == blendedColor.fKnownColorFlags);
|
2015-05-27 22:08:33 +00:00
|
|
|
|
|
|
|
GrColor overrideColor;
|
|
|
|
xp->getOptimizations(colorPOI, covPOI, false, &overrideColor, caps);
|
|
|
|
|
|
|
|
GrXferProcessor::BlendInfo blendInfo;
|
|
|
|
xp->getBlendInfo(&blendInfo);
|
|
|
|
TEST_ASSERT(blendInfo.fWriteColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_no_dual_source_blending(skiatest::Reporter* reporter) {
|
|
|
|
GrContextOptions opts;
|
|
|
|
opts.fSuppressDualSourceBlending = true;
|
|
|
|
GrContextFactory factory(opts);
|
|
|
|
factory.get(GrContextFactory::kNull_GLContextType);
|
|
|
|
GrContext* ctx = factory.get(GrContextFactory::kNull_GLContextType);
|
|
|
|
if (!ctx) {
|
|
|
|
SkFAIL("Failed to create null context without ARB_blend_func_extended.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-05-29 15:02:10 +00:00
|
|
|
const GrCaps& caps = *ctx->caps();
|
2015-05-27 22:08:33 +00:00
|
|
|
if (caps.shaderCaps()->dualSourceBlendingSupport()) {
|
|
|
|
SkFAIL("Null context failed to honor request for no ARB_blend_func_extended.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-10 19:54:56 +00:00
|
|
|
GrBackendObject backendTex =
|
|
|
|
ctx->getGpu()->createTestingOnlyBackendTexture(nullptr, 100, 100, kRGBA_8888_GrPixelConfig);
|
2015-05-27 22:08:33 +00:00
|
|
|
GrBackendTextureDesc fakeDesc;
|
|
|
|
fakeDesc.fConfig = kRGBA_8888_GrPixelConfig;
|
|
|
|
fakeDesc.fWidth = fakeDesc.fHeight = 100;
|
2015-11-10 19:54:56 +00:00
|
|
|
fakeDesc.fTextureHandle = backendTex;
|
2015-07-31 20:59:30 +00:00
|
|
|
SkAutoTUnref<GrTexture> fakeTexture(ctx->textureProvider()->wrapBackendTexture(fakeDesc,
|
2015-06-18 16:12:16 +00:00
|
|
|
kBorrow_GrWrapOwnership));
|
2015-05-27 22:08:33 +00:00
|
|
|
GrXferProcessor::DstTexture fakeDstTexture;
|
|
|
|
fakeDstTexture.setTexture(fakeTexture);
|
|
|
|
|
|
|
|
static const GrColor testColors[] = {
|
|
|
|
0,
|
|
|
|
GrColorPackRGBA(0, 82, 0, 255),
|
|
|
|
GrColorPackA4(255)
|
|
|
|
};
|
|
|
|
static const GrColorComponentFlags testColorFlags[] = {
|
|
|
|
kNone_GrColorComponentFlags,
|
|
|
|
kG_GrColorComponentFlag | kA_GrColorComponentFlag,
|
|
|
|
kRGBA_GrColorComponentFlags
|
|
|
|
};
|
|
|
|
GR_STATIC_ASSERT(SK_ARRAY_COUNT(testColors) == SK_ARRAY_COUNT(testColorFlags));
|
|
|
|
|
|
|
|
for (size_t c = 0; c < SK_ARRAY_COUNT(testColors); c++) {
|
|
|
|
GrProcOptInfo colorPOI;
|
2015-08-27 14:41:13 +00:00
|
|
|
colorPOI.calcWithInitialValues(nullptr, 0, testColors[c], testColorFlags[c], false);
|
2015-05-27 22:08:33 +00:00
|
|
|
for (int f = 0; f <= 1; f++) {
|
|
|
|
GrProcOptInfo covPOI;
|
|
|
|
if (!f) {
|
2015-08-27 14:41:13 +00:00
|
|
|
covPOI.calcWithInitialValues(nullptr, 0, 0, kNone_GrColorComponentFlags, true);
|
2015-05-27 22:08:33 +00:00
|
|
|
} else {
|
2015-08-27 14:41:13 +00:00
|
|
|
covPOI.calcWithInitialValues(nullptr, 0, GrColorPackA4(255),
|
2015-05-27 22:08:33 +00:00
|
|
|
kRGBA_GrColorComponentFlags, true);
|
|
|
|
}
|
|
|
|
for (int m = 0; m <= SkXfermode::kLastCoeffMode; m++) {
|
|
|
|
SkXfermode::Mode xfermode = static_cast<SkXfermode::Mode>(m);
|
|
|
|
SkAutoTUnref<GrXPFactory> xpf(GrPorterDuffXPFactory::Create(xfermode));
|
2015-06-08 22:11:04 +00:00
|
|
|
GrXferProcessor::DstTexture* dstTexture =
|
|
|
|
xpf->willNeedDstTexture(caps, colorPOI, covPOI, false) ? &fakeDstTexture : 0;
|
|
|
|
SkAutoTUnref<GrXferProcessor> xp(
|
|
|
|
xpf->createXferProcessor(colorPOI, covPOI, false, dstTexture, caps));
|
2015-05-27 22:08:33 +00:00
|
|
|
if (!xp) {
|
|
|
|
ERRORF(reporter, "Failed to create an XP without dual source blending.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
TEST_ASSERT(!xp->hasSecondaryOutput());
|
|
|
|
xp->getOptimizations(colorPOI, covPOI, false, 0, caps);
|
|
|
|
TEST_ASSERT(!xp->hasSecondaryOutput());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-10 19:54:56 +00:00
|
|
|
ctx->getGpu()->deleteTestingOnlyBackendTexture(backendTex);
|
2015-05-27 22:08:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|