2019-01-23 16:10:36 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
#include "GrContextPriv.h"
|
|
|
|
#include "GrPaint.h"
|
|
|
|
#include "GrProcessorSet.h"
|
|
|
|
#include "effects/GrCustomXfermode.h"
|
|
|
|
|
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(AdvancedBlendTest, reporter, ctxInfo) {
|
|
|
|
static constexpr auto opaque = GrProcessorAnalysisColor::Opaque::kYes;
|
|
|
|
static constexpr auto coverage = GrProcessorAnalysisCoverage::kSingleChannel;
|
2019-02-04 18:26:26 +00:00
|
|
|
const GrCaps& caps = *ctxInfo.grContext()->priv().caps();
|
2019-01-23 16:10:36 +00:00
|
|
|
|
|
|
|
for (int mode = (int)SkBlendMode::kLastMode; mode > (int)SkBlendMode::kLastCoeffMode; --mode) {
|
|
|
|
const SkBlendMode blendMode = (SkBlendMode)mode;
|
|
|
|
const GrBlendEquation blendEquation =
|
|
|
|
(GrBlendEquation)(mode + (kOverlay_GrBlendEquation - (int)SkBlendMode::kOverlay));
|
|
|
|
const GrXPFactory* xpf = GrCustomXfermode::Get(blendMode);
|
|
|
|
|
|
|
|
GrXPFactory::AnalysisProperties xpfAnalysis =
|
2019-03-15 14:15:29 +00:00
|
|
|
GrXPFactory::GetAnalysisProperties(xpf, opaque, coverage, caps, GrClampType::kAuto);
|
2019-01-23 16:10:36 +00:00
|
|
|
|
|
|
|
GrPaint paint;
|
|
|
|
paint.setXPFactory(xpf);
|
|
|
|
GrProcessorSet procs(std::move(paint));
|
|
|
|
SkPMColor4f overrideColor;
|
|
|
|
GrProcessorSet::Analysis processorAnalysis =
|
2019-03-05 17:11:58 +00:00
|
|
|
procs.finalize(
|
|
|
|
opaque, coverage, nullptr, &GrUserStencilSettings::kUnused,
|
2019-03-15 14:15:29 +00:00
|
|
|
GrFSAAType::kNone, caps, GrClampType::kAuto, &overrideColor);
|
2019-01-23 16:10:36 +00:00
|
|
|
|
|
|
|
if (caps.advancedBlendEquationSupport() &&
|
|
|
|
!caps.isAdvancedBlendEquationBlacklisted(blendEquation)) {
|
|
|
|
REPORTER_ASSERT(reporter,
|
|
|
|
!(xpfAnalysis & GrXPFactory::AnalysisProperties::kReadsDstInShader));
|
|
|
|
if (GrCaps::kAdvancedCoherent_BlendEquationSupport == caps.blendEquationSupport()) {
|
|
|
|
REPORTER_ASSERT(reporter, !processorAnalysis.requiresNonOverlappingDraws());
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter,
|
|
|
|
GrCaps::kAdvanced_BlendEquationSupport
|
|
|
|
== caps.blendEquationSupport());
|
|
|
|
REPORTER_ASSERT(reporter, processorAnalysis.requiresNonOverlappingDraws());
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter,
|
|
|
|
(xpfAnalysis & GrXPFactory::AnalysisProperties::kReadsDstInShader));
|
|
|
|
if (xpfAnalysis & GrXPFactory::AnalysisProperties::kRequiresDstTexture) {
|
|
|
|
REPORTER_ASSERT(reporter, processorAnalysis.requiresNonOverlappingDraws());
|
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, !processorAnalysis.requiresNonOverlappingDraws());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|