945ee652d7
Enforces this constraint from one central location, rather than relying on each Op to remember to check if overlap is allowed from its onCombineIfPossible method. Fixes an issue where we need to check the total bounds of both chains for overlap (not the bounds of individual Ops). Bug: skia:8671 Change-Id: I163651c868847884459acfc00d13ffdfca3a27c3 Reviewed-on: https://skia-review.googlesource.com/c/185815 Commit-Queue: Chris Dalton <csmartdalton@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
59 lines
2.5 KiB
C++
59 lines
2.5 KiB
C++
/*
|
|
* 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;
|
|
const GrCaps& caps = *ctxInfo.grContext()->contextPriv().caps();
|
|
|
|
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 =
|
|
GrXPFactory::GetAnalysisProperties(xpf, opaque, coverage, caps);
|
|
|
|
GrPaint paint;
|
|
paint.setXPFactory(xpf);
|
|
GrProcessorSet procs(std::move(paint));
|
|
SkPMColor4f overrideColor;
|
|
GrProcessorSet::Analysis processorAnalysis =
|
|
procs.finalize(opaque, coverage, nullptr, false, caps, &overrideColor);
|
|
|
|
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());
|
|
}
|
|
}
|
|
}
|
|
}
|