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.
|
|
|
|
*/
|
|
|
|
|
2019-05-06 21:17:19 +00:00
|
|
|
#include "include/core/SkBlendMode.h"
|
2020-07-06 14:56:46 +00:00
|
|
|
#include "include/gpu/GrDirectContext.h"
|
2019-05-06 21:17:19 +00:00
|
|
|
#include "include/private/GrTypesPriv.h"
|
|
|
|
#include "include/private/SkColorData.h"
|
2019-08-14 20:56:13 +00:00
|
|
|
#include "src/gpu/GrBlend.h"
|
2019-05-06 21:17:19 +00:00
|
|
|
#include "src/gpu/GrCaps.h"
|
2020-10-14 15:23:11 +00:00
|
|
|
#include "src/gpu/GrDirectContextPriv.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrPaint.h"
|
2019-05-06 21:17:19 +00:00
|
|
|
#include "src/gpu/GrProcessorAnalysis.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrProcessorSet.h"
|
2019-05-06 21:17:19 +00:00
|
|
|
#include "src/gpu/GrUserStencilSettings.h"
|
|
|
|
#include "src/gpu/GrXferProcessor.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/effects/GrCustomXfermode.h"
|
2019-05-06 21:17:19 +00:00
|
|
|
#include "tests/Test.h"
|
|
|
|
#include "tools/gpu/GrContextFactory.h"
|
|
|
|
|
|
|
|
#include <utility>
|
2019-01-23 16:10:36 +00:00
|
|
|
|
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(AdvancedBlendTest, reporter, ctxInfo) {
|
|
|
|
static constexpr auto opaque = GrProcessorAnalysisColor::Opaque::kYes;
|
|
|
|
static constexpr auto coverage = GrProcessorAnalysisCoverage::kSingleChannel;
|
2020-07-06 14:56:46 +00:00
|
|
|
const GrCaps& caps = *ctxInfo.directContext()->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 =
|
2020-12-03 08:43:08 +00:00
|
|
|
GrXPFactory::GetAnalysisProperties(xpf, opaque, coverage, false, caps,
|
|
|
|
GrClampType::kAuto);
|
2019-01-23 16:10:36 +00:00
|
|
|
|
|
|
|
GrPaint paint;
|
|
|
|
paint.setXPFactory(xpf);
|
|
|
|
GrProcessorSet procs(std::move(paint));
|
2019-06-24 00:07:38 +00:00
|
|
|
bool hasMixedSampledCoverage = false;
|
2019-01-23 16:10:36 +00:00
|
|
|
SkPMColor4f overrideColor;
|
2019-06-24 00:07:38 +00:00
|
|
|
GrProcessorSet::Analysis processorAnalysis = procs.finalize(
|
|
|
|
opaque, coverage, nullptr, &GrUserStencilSettings::kUnused, hasMixedSampledCoverage,
|
|
|
|
caps, GrClampType::kAuto, &overrideColor);
|
2019-01-23 16:10:36 +00:00
|
|
|
|
|
|
|
if (caps.advancedBlendEquationSupport() &&
|
2020-07-09 12:09:13 +00:00
|
|
|
!caps.isAdvancedBlendEquationDisabled(blendEquation)) {
|
2019-01-23 16:10:36 +00:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|