Replace GrConstColorProcessor with a runtime FP
Change-Id: Ie36ea4d5186f6cca341efc6300b813ec8255bdbb Reviewed-on: https://skia-review.googlesource.com/c/skia/+/388457 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
3c1ed9cbe2
commit
354147a23c
@ -34,7 +34,6 @@
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#include "src/gpu/ops/GrDrawOp.h"
|
||||
#include "src/gpu/ops/GrFillRectOp.h"
|
||||
#include "tools/ToolUtils.h"
|
||||
@ -44,7 +43,7 @@
|
||||
|
||||
namespace skiagm {
|
||||
/**
|
||||
* This GM directly exercises GrConstColorProcessor, ModulateRGBA and ModulateAlpha.
|
||||
* This GM directly exercises Color, ModulateRGBA and ModulateAlpha.
|
||||
*/
|
||||
class ColorProcessor : public GpuGM {
|
||||
public:
|
||||
@ -114,7 +113,7 @@ protected:
|
||||
GrFPArgs args(context, SkSimpleMatrixProvider(SkMatrix::I()), &colorInfo);
|
||||
baseFP = as_SB(fShader)->asFragmentProcessor(args);
|
||||
} else {
|
||||
baseFP = GrConstColorProcessor::Make(
|
||||
baseFP = GrFragmentProcessor::MakeColor(
|
||||
SkPMColor4f::FromBytes_RGBA(kPaintColors[paintType]));
|
||||
}
|
||||
|
||||
@ -122,7 +121,7 @@ protected:
|
||||
std::unique_ptr<GrFragmentProcessor> colorFP;
|
||||
switch (fMode) {
|
||||
case TestMode::kConstColor:
|
||||
colorFP = GrConstColorProcessor::Make(
|
||||
colorFP = GrFragmentProcessor::MakeColor(
|
||||
SkPMColor4f::FromBytes_RGBA(kColors[procColor]));
|
||||
break;
|
||||
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "src/gpu/GrSamplerState.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#include "tools/Resources.h"
|
||||
#include "tools/gpu/TestOps.h"
|
||||
|
||||
|
@ -345,8 +345,6 @@ skia_gpu_sources = [
|
||||
"$_src/gpu/effects/generated/GrColorMatrixFragmentProcessor.h",
|
||||
"$_src/gpu/effects/generated/GrConfigConversionEffect.cpp",
|
||||
"$_src/gpu/effects/generated/GrConfigConversionEffect.h",
|
||||
"$_src/gpu/effects/generated/GrConstColorProcessor.cpp",
|
||||
"$_src/gpu/effects/generated/GrConstColorProcessor.h",
|
||||
"$_src/gpu/effects/generated/GrDeviceSpaceEffect.cpp",
|
||||
"$_src/gpu/effects/generated/GrDeviceSpaceEffect.h",
|
||||
"$_src/gpu/effects/generated/GrDitherEffect.cpp",
|
||||
|
@ -208,7 +208,6 @@ skia_gpu_processor_sources = [
|
||||
"$_src/gpu/effects/GrClampFragmentProcessor.fp",
|
||||
"$_src/gpu/effects/GrColorMatrixFragmentProcessor.fp",
|
||||
"$_src/gpu/effects/GrConfigConversionEffect.fp",
|
||||
"$_src/gpu/effects/GrConstColorProcessor.fp",
|
||||
"$_src/gpu/effects/GrDeviceSpaceEffect.fp",
|
||||
"$_src/gpu/effects/GrDitherEffect.fp",
|
||||
"$_src/gpu/effects/GrEllipseEffect.fp",
|
||||
|
@ -84,9 +84,9 @@ skvm::Color SkModeColorFilter::onProgram(skvm::Builder* p, skvm::Color c,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#if SK_SUPPORT_GPU
|
||||
#include "src/gpu/GrBlend.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrBlendFragmentProcessor.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
|
||||
GrFPResult SkModeColorFilter::asFragmentProcessor(std::unique_ptr<GrFragmentProcessor> inputFP,
|
||||
GrRecordingContext*,
|
||||
@ -99,7 +99,7 @@ GrFPResult SkModeColorFilter::asFragmentProcessor(std::unique_ptr<GrFragmentProc
|
||||
|
||||
SkDEBUGCODE(const bool fpHasConstIO = !inputFP || inputFP->hasConstantOutputForConstantInput();)
|
||||
|
||||
auto colorFP = GrConstColorProcessor::Make(SkColorToPMColor4f(fColor, dstColorInfo));
|
||||
auto colorFP = GrFragmentProcessor::MakeColor(SkColorToPMColor4f(fColor, dstColorInfo));
|
||||
auto xferFP = GrBlendFragmentProcessor::Make(
|
||||
std::move(colorFP), std::move(inputFP), fMode,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kSkModeBehavior);
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/generated/GrArithmeticProcessor.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
|
||||
@ -356,7 +355,7 @@ sk_sp<SkSpecialImage> SkArithmeticImageFilter::filterImageGPU(
|
||||
ctx.colorSpace(),
|
||||
kPremul_SkAlphaType);
|
||||
} else {
|
||||
fp = GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT);
|
||||
fp = GrFragmentProcessor::MakeColor(SK_PMColor4fTRANSPARENT);
|
||||
}
|
||||
|
||||
if (foreground) {
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "src/gpu/GrTextureProxy.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#endif
|
||||
#include "src/core/SkClipOpPriv.h"
|
||||
|
||||
@ -268,7 +267,7 @@ sk_sp<SkSpecialImage> SkBlendImageFilter::filterImageGPU(const Context& ctx,
|
||||
background->alphaType(), ctx.colorSpace(),
|
||||
kPremul_SkAlphaType);
|
||||
} else {
|
||||
fp = GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT);
|
||||
fp = GrFragmentProcessor::MakeColor(SK_PMColor4fTRANSPARENT);
|
||||
}
|
||||
|
||||
if (foregroundView.asTextureProxy()) {
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include "src/gpu/GrPipeline.h"
|
||||
#include "src/gpu/GrProcessorAnalysis.h"
|
||||
#include "src/gpu/effects/GrBlendFragmentProcessor.h"
|
||||
#include "src/gpu/effects/GrSkSLFP.h"
|
||||
#include "src/gpu/effects/generated/GrClampFragmentProcessor.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#include "src/gpu/effects/generated/GrOverrideInputFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
@ -216,6 +216,16 @@ void GrFragmentProcessor::cloneAndRegisterAllChildProcessors(const GrFragmentPro
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MakeColor(SkPMColor4f color) {
|
||||
static constexpr char kCode[] = R"(
|
||||
uniform half4 color;
|
||||
half4 main() { return color; }
|
||||
)";
|
||||
auto builder = GrRuntimeFPBuilder::Make<kCode>();
|
||||
builder.uniform("color") = color;
|
||||
return builder.makeFP();
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MulChildByInputAlpha(
|
||||
std::unique_ptr<GrFragmentProcessor> fp) {
|
||||
if (!fp) {
|
||||
@ -234,7 +244,7 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::MulInputByChildAlpha(
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::ModulateAlpha(
|
||||
std::unique_ptr<GrFragmentProcessor> inputFP, const SkPMColor4f& color) {
|
||||
auto colorFP = GrConstColorProcessor::Make(color);
|
||||
auto colorFP = MakeColor(color);
|
||||
return GrBlendFragmentProcessor::Make(
|
||||
std::move(colorFP), std::move(inputFP), SkBlendMode::kSrcIn,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kSkModeBehavior);
|
||||
@ -242,7 +252,7 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::ModulateAlpha(
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::ModulateRGBA(
|
||||
std::unique_ptr<GrFragmentProcessor> inputFP, const SkPMColor4f& color) {
|
||||
auto colorFP = GrConstColorProcessor::Make(color);
|
||||
auto colorFP = MakeColor(color);
|
||||
return GrBlendFragmentProcessor::Make(
|
||||
std::move(colorFP), std::move(inputFP), SkBlendMode::kModulate,
|
||||
GrBlendFragmentProcessor::BlendBehavior::kSkModeBehavior);
|
||||
@ -486,10 +496,10 @@ std::unique_ptr<GrFragmentProcessor> GrFragmentProcessor::Compose(
|
||||
case 1:
|
||||
// Replace the first processor with a constant color.
|
||||
return ComposeProcessor::Make(/*f=*/std::move(series[1]),
|
||||
/*g=*/GrConstColorProcessor::Make(knownColor));
|
||||
/*g=*/MakeColor(knownColor));
|
||||
case 2:
|
||||
// Replace the entire composition with a constant color.
|
||||
return GrConstColorProcessor::Make(knownColor);
|
||||
return MakeColor(knownColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,11 +22,15 @@ class GrShaderCaps;
|
||||
class GrSwizzle;
|
||||
class GrTextureEffect;
|
||||
|
||||
/** Provides custom fragment shader code. Fragment processors receive an input color (half4) and
|
||||
produce an output color. They may reference textures and uniforms.
|
||||
/** Provides custom fragment shader code. Fragment processors receive an input position and
|
||||
produce an output color. They may contain uniforms and may have children fragment processors
|
||||
that are sampled.
|
||||
*/
|
||||
class GrFragmentProcessor : public GrProcessor {
|
||||
public:
|
||||
/** Always returns 'color'. */
|
||||
static std::unique_ptr<GrFragmentProcessor> MakeColor(SkPMColor4f color);
|
||||
|
||||
/**
|
||||
* In many instances (e.g. SkShader::asFragmentProcessor() implementations) it is desirable to
|
||||
* only consider the input color's alpha. However, there is a competing desire to have reusable
|
||||
|
@ -69,7 +69,6 @@ public:
|
||||
kGrColorSpaceXformEffect_ClassID,
|
||||
kGrConfigConversionEffect_ClassID,
|
||||
kGrConicEffect_ClassID,
|
||||
kGrConstColorProcessor_ClassID,
|
||||
kGrConvexPolyEffect_ClassID,
|
||||
kGrDeviceSpaceEffect_ClassID,
|
||||
kGrDiffuseLightingEffect_ClassID,
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/GrRecordingContextPriv.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
|
||||
@ -147,7 +146,7 @@ SkTArray<GrXPFactoryTestFactory*, true>* GrXPFactoryTestFactory::GetFactories()
|
||||
* we verify the count is as expected. If a new factory is added, then these numbers must be
|
||||
* manually adjusted.
|
||||
*/
|
||||
static constexpr int kFPFactoryCount = 35;
|
||||
static constexpr int kFPFactoryCount = 34;
|
||||
static constexpr int kGPFactoryCount = 14;
|
||||
static constexpr int kXPFactoryCount = 4;
|
||||
|
||||
@ -183,7 +182,7 @@ std::unique_ptr<GrFragmentProcessor> GrProcessorUnitTest::MakeChildFP(GrProcesso
|
||||
// We've gone too deep, but we can't necessarily return null without risking an assertion.
|
||||
// Instead, return a known-simple zero-child FP. This limits the recursion, and the
|
||||
// generated FP will be rejected by the numNonNullChildProcessors check below.
|
||||
fp = GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT);
|
||||
fp = GrFragmentProcessor::MakeColor(SK_PMColor4fTRANSPARENT);
|
||||
} else {
|
||||
for (;;) {
|
||||
fp = GrFragmentProcessorTestFactory::Make(data);
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include "src/gpu/effects/GrBlendFragmentProcessor.h"
|
||||
#include "src/gpu/effects/GrPorterDuffXferProcessor.h"
|
||||
#include "src/gpu/effects/generated/GrClampFragmentProcessor.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#include "src/gpu/effects/generated/GrDitherEffect.h"
|
||||
#include "src/image/SkImage_Base.h"
|
||||
#include "src/shaders/SkShaderBase.h"
|
||||
@ -281,7 +280,7 @@ static inline bool skpaint_to_grpaint_impl(GrRecordingContext* context,
|
||||
// There is a blend between the primitive color and the paint color. The blend considers
|
||||
// the opaque paint color. The paint's alpha is applied to the post-blended color.
|
||||
SkPMColor4f opaqueColor = origColor.makeOpaque().premul();
|
||||
paintFP = GrConstColorProcessor::Make(opaqueColor);
|
||||
paintFP = GrFragmentProcessor::MakeColor(opaqueColor);
|
||||
paintFP = GrBlendFragmentProcessor::Make(std::move(paintFP), /*dst=*/nullptr,
|
||||
*primColorMode);
|
||||
grPaint->setColor4f(opaqueColor);
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLBlend.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
@ -328,7 +327,7 @@ std::unique_ptr<GrFragmentProcessor> GrBlendFragmentProcessor::Make(
|
||||
SkBlendMode mode, BlendBehavior behavior) {
|
||||
switch (mode) {
|
||||
case SkBlendMode::kClear:
|
||||
return GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT);
|
||||
return GrFragmentProcessor::MakeColor(SK_PMColor4fTRANSPARENT);
|
||||
case SkBlendMode::kSrc:
|
||||
return GrFragmentProcessor::OverrideInput(std::move(src), SK_PMColor4fWHITE,
|
||||
/*useUniform=*/false);
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
layout(ctype=SkPMColor4f, tracked) in uniform half4 color;
|
||||
|
||||
@optimizationFlags {
|
||||
(kConstantOutputForConstantInput_OptimizationFlag |
|
||||
(color.isOpaque() ? kPreservesOpaqueInput_OptimizationFlag : kNone_OptimizationFlags))
|
||||
}
|
||||
|
||||
half4 main() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@class {
|
||||
SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& inColor) const override {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
||||
@test(d) {
|
||||
SkPMColor4f color;
|
||||
int colorPicker = d->fRandom->nextULessThan(3);
|
||||
switch (colorPicker) {
|
||||
case 0: {
|
||||
uint32_t a = d->fRandom->nextULessThan(0x100);
|
||||
uint32_t r = d->fRandom->nextULessThan(a+1);
|
||||
uint32_t g = d->fRandom->nextULessThan(a+1);
|
||||
uint32_t b = d->fRandom->nextULessThan(a+1);
|
||||
color = SkPMColor4f::FromBytes_RGBA(GrColorPackRGBA(r, g, b, a));
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
color = SK_PMColor4fTRANSPARENT;
|
||||
break;
|
||||
case 2:
|
||||
uint32_t c = d->fRandom->nextULessThan(0x100);
|
||||
color = SkPMColor4f::FromBytes_RGBA(c | (c << 8) | (c << 16) | (c << 24));
|
||||
break;
|
||||
}
|
||||
return GrConstColorProcessor::Make(color);
|
||||
}
|
@ -250,7 +250,6 @@ GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrSkSLFP);
|
||||
|
||||
#include "include/effects/SkOverdrawColorFilter.h"
|
||||
#include "src/core/SkColorFilterBase.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
|
||||
extern const char* SKSL_OVERDRAW_SRC;
|
||||
|
||||
|
@ -1,99 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/**************************************************************************************************
|
||||
*** This file was autogenerated from GrConstColorProcessor.fp; do not modify.
|
||||
**************************************************************************************************/
|
||||
#include "GrConstColorProcessor.h"
|
||||
|
||||
#include "src/core/SkUtils.h"
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
|
||||
#include "src/sksl/SkSLCPP.h"
|
||||
#include "src/sksl/SkSLUtil.h"
|
||||
class GrGLSLConstColorProcessor : public GrGLSLFragmentProcessor {
|
||||
public:
|
||||
GrGLSLConstColorProcessor() {}
|
||||
void emitCode(EmitArgs& args) override {
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
const GrConstColorProcessor& _outer = args.fFp.cast<GrConstColorProcessor>();
|
||||
(void)_outer;
|
||||
auto color = _outer.color;
|
||||
(void)color;
|
||||
colorVar = args.fUniformHandler->addUniform(
|
||||
&_outer, kFragment_GrShaderFlag, kHalf4_GrSLType, "color");
|
||||
fragBuilder->codeAppendf(
|
||||
R"SkSL(return %s;
|
||||
)SkSL",
|
||||
args.fUniformHandler->getUniformCStr(colorVar));
|
||||
}
|
||||
|
||||
private:
|
||||
void onSetData(const GrGLSLProgramDataManager& pdman,
|
||||
const GrFragmentProcessor& _proc) override {
|
||||
const GrConstColorProcessor& _outer = _proc.cast<GrConstColorProcessor>();
|
||||
{
|
||||
const SkPMColor4f& colorValue = _outer.color;
|
||||
if (colorPrev != colorValue) {
|
||||
colorPrev = colorValue;
|
||||
pdman.set4fv(colorVar, 1, colorValue.vec());
|
||||
}
|
||||
}
|
||||
}
|
||||
SkPMColor4f colorPrev = {SK_FloatNaN, SK_FloatNaN, SK_FloatNaN, SK_FloatNaN};
|
||||
UniformHandle colorVar;
|
||||
};
|
||||
std::unique_ptr<GrGLSLFragmentProcessor> GrConstColorProcessor::onMakeProgramImpl() const {
|
||||
return std::make_unique<GrGLSLConstColorProcessor>();
|
||||
}
|
||||
void GrConstColorProcessor::onGetGLSLProcessorKey(const GrShaderCaps& caps,
|
||||
GrProcessorKeyBuilder* b) const {}
|
||||
bool GrConstColorProcessor::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
const GrConstColorProcessor& that = other.cast<GrConstColorProcessor>();
|
||||
(void)that;
|
||||
if (color != that.color) return false;
|
||||
return true;
|
||||
}
|
||||
GrConstColorProcessor::GrConstColorProcessor(const GrConstColorProcessor& src)
|
||||
: INHERITED(kGrConstColorProcessor_ClassID, src.optimizationFlags()), color(src.color) {
|
||||
this->cloneAndRegisterAllChildProcessors(src);
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> GrConstColorProcessor::clone() const {
|
||||
return std::make_unique<GrConstColorProcessor>(*this);
|
||||
}
|
||||
#if GR_TEST_UTILS
|
||||
SkString GrConstColorProcessor::onDumpInfo() const {
|
||||
return SkStringPrintf("(color=half4(%f, %f, %f, %f))", color.fR, color.fG, color.fB, color.fA);
|
||||
}
|
||||
#endif
|
||||
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(GrConstColorProcessor);
|
||||
#if GR_TEST_UTILS
|
||||
std::unique_ptr<GrFragmentProcessor> GrConstColorProcessor::TestCreate(GrProcessorTestData* d) {
|
||||
SkPMColor4f color;
|
||||
int colorPicker = d->fRandom->nextULessThan(3);
|
||||
switch (colorPicker) {
|
||||
case 0: {
|
||||
uint32_t a = d->fRandom->nextULessThan(0x100);
|
||||
uint32_t r = d->fRandom->nextULessThan(a + 1);
|
||||
uint32_t g = d->fRandom->nextULessThan(a + 1);
|
||||
uint32_t b = d->fRandom->nextULessThan(a + 1);
|
||||
color = SkPMColor4f::FromBytes_RGBA(GrColorPackRGBA(r, g, b, a));
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
color = SK_PMColor4fTRANSPARENT;
|
||||
break;
|
||||
case 2:
|
||||
uint32_t c = d->fRandom->nextULessThan(0x100);
|
||||
color = SkPMColor4f::FromBytes_RGBA(c | (c << 8) | (c << 16) | (c << 24));
|
||||
break;
|
||||
}
|
||||
return GrConstColorProcessor::Make(color);
|
||||
}
|
||||
#endif
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
/**************************************************************************************************
|
||||
*** This file was autogenerated from GrConstColorProcessor.fp; do not modify.
|
||||
**************************************************************************************************/
|
||||
#ifndef GrConstColorProcessor_DEFINED
|
||||
#define GrConstColorProcessor_DEFINED
|
||||
|
||||
#include "include/core/SkM44.h"
|
||||
#include "include/core/SkTypes.h"
|
||||
|
||||
#include "src/gpu/GrFragmentProcessor.h"
|
||||
|
||||
class GrConstColorProcessor : public GrFragmentProcessor {
|
||||
public:
|
||||
SkPMColor4f constantOutputForConstantInput(const SkPMColor4f& inColor) const override {
|
||||
return color;
|
||||
}
|
||||
static std::unique_ptr<GrFragmentProcessor> Make(SkPMColor4f color) {
|
||||
return std::unique_ptr<GrFragmentProcessor>(new GrConstColorProcessor(color));
|
||||
}
|
||||
GrConstColorProcessor(const GrConstColorProcessor& src);
|
||||
std::unique_ptr<GrFragmentProcessor> clone() const override;
|
||||
const char* name() const override { return "ConstColorProcessor"; }
|
||||
SkPMColor4f color;
|
||||
|
||||
private:
|
||||
GrConstColorProcessor(SkPMColor4f color)
|
||||
: INHERITED(
|
||||
kGrConstColorProcessor_ClassID,
|
||||
(OptimizationFlags)(kConstantOutputForConstantInput_OptimizationFlag |
|
||||
(color.isOpaque() ? kPreservesOpaqueInput_OptimizationFlag
|
||||
: kNone_OptimizationFlags)))
|
||||
, color(color) {}
|
||||
std::unique_ptr<GrGLSLFragmentProcessor> onMakeProgramImpl() const override;
|
||||
void onGetGLSLProcessorKey(const GrShaderCaps&, GrProcessorKeyBuilder*) const override;
|
||||
bool onIsEqual(const GrFragmentProcessor&) const override;
|
||||
#if GR_TEST_UTILS
|
||||
SkString onDumpInfo() const override;
|
||||
#endif
|
||||
GR_DECLARE_FRAGMENT_PROCESSOR_TEST
|
||||
using INHERITED = GrFragmentProcessor;
|
||||
};
|
||||
#endif
|
@ -202,7 +202,6 @@ skvm::Color SkShader_Lerp::onProgram(skvm::Builder* p,
|
||||
#include "include/gpu/GrRecordingContext.h"
|
||||
#include "src/gpu/effects/GrBlendFragmentProcessor.h"
|
||||
#include "src/gpu/effects/GrSkSLFP.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
|
||||
static std::unique_ptr<GrFragmentProcessor> as_fp(const GrFPArgs& args, SkShader* shader) {
|
||||
return shader ? as_SB(shader)->asFragmentProcessor(args) : nullptr;
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "src/gpu/SkGr.h"
|
||||
#include "src/gpu/effects/GrMatrixEffect.h"
|
||||
#include "src/gpu/effects/GrTextureEffect.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramDataManager.h"
|
||||
@ -973,7 +972,7 @@ std::unique_ptr<GrFragmentProcessor> SkPerlinNoiseShaderImpl::asFragmentProcesso
|
||||
return GrFragmentProcessor::MulChildByInputAlpha(std::move(inner));
|
||||
}
|
||||
// Emit zero.
|
||||
return GrConstColorProcessor::Make(SK_PMColor4fTRANSPARENT);
|
||||
return GrFragmentProcessor::MakeColor(SK_PMColor4fTRANSPARENT);
|
||||
}
|
||||
|
||||
// Need to assert that the textures we'll create are power of 2 so that now copy is needed. We
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "src/gpu/GrProxyProvider.h"
|
||||
#include "src/gpu/GrSurfaceFillContext.h"
|
||||
#include "src/gpu/effects/GrBlendFragmentProcessor.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#include "src/image/SkImage_Base.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tests/TestUtils.h"
|
||||
@ -414,7 +413,7 @@ static void check_mipmaps(GrDirectContext* dContext,
|
||||
// Our swizzles for alpha color types currently produce (a, a, a, a) in the shader. Remove
|
||||
// this once they are correctly (0, 0, 0, a).
|
||||
if (GrColorTypeIsAlphaOnly(colorType)) {
|
||||
auto black = GrConstColorProcessor::Make(SK_PMColor4fBLACK);
|
||||
auto black = GrFragmentProcessor::MakeColor(SK_PMColor4fBLACK);
|
||||
fp = GrBlendFragmentProcessor::Make(std::move(fp),
|
||||
std::move(black),
|
||||
SkBlendMode::kModulate);
|
||||
|
@ -29,7 +29,6 @@
|
||||
#include "src/gpu/GrPaint.h"
|
||||
#include "src/gpu/GrStyle.h"
|
||||
#include "src/gpu/GrSurfaceDrawContext.h"
|
||||
#include "src/gpu/effects/generated/GrConstColorProcessor.h"
|
||||
#include "tests/Test.h"
|
||||
#include "tools/gpu/GrContextFactory.h"
|
||||
|
||||
@ -93,7 +92,7 @@ static void run_test(GrDirectContext* dContext, skiatest::Reporter* reporter) {
|
||||
GrPaint paint;
|
||||
|
||||
const SkPMColor4f color = { 1.0f, 0.0f, 0.0f, 1.0f };
|
||||
auto fp = GrConstColorProcessor::Make(color);
|
||||
auto fp = GrFragmentProcessor::MakeColor(color);
|
||||
paint.setColorFragmentProcessor(std::move(fp));
|
||||
|
||||
rtc->drawPath(nullptr, std::move(paint), GrAA::kNo, SkMatrix::I(), invPath, style);
|
||||
@ -110,7 +109,7 @@ static void run_test(GrDirectContext* dContext, skiatest::Reporter* reporter) {
|
||||
GrPaint paint;
|
||||
|
||||
const SkPMColor4f color = { 0.0f, 1.0f, 0.0f, 1.0f };
|
||||
auto fp = GrConstColorProcessor::Make(color);
|
||||
auto fp = GrFragmentProcessor::MakeColor(color);
|
||||
paint.setColorFragmentProcessor(std::move(fp));
|
||||
|
||||
rtc->drawPath(nullptr, std::move(paint), GrAA::kNo,
|
||||
|
Loading…
Reference in New Issue
Block a user