Revert "Converted texture and runtime effects to use GrMatrixEffect"
This reverts commit 4ab84eda53
.
Reason for revert: Breaking some GMs.
Original change's description:
> Converted texture and runtime effects to use GrMatrixEffect
>
> Change-Id: I6e769d52291dd29c2d06983dae5013b6058864cb
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/283780
> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
> Reviewed-by: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
TBR=bsalomon@google.com,brianosman@google.com,ethannicholas@google.com
Change-Id: Idb2c782ae619689744e868bf38111cc4eaf0b40a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/284233
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
This commit is contained in:
parent
4e7ee6e0af
commit
36a3e014e1
@ -19,11 +19,8 @@ class SampleMatrixVariableEffect : public GrFragmentProcessor {
|
||||
public:
|
||||
static constexpr GrProcessor::ClassID CLASS_ID = (GrProcessor::ClassID) 2;
|
||||
|
||||
SampleMatrixVariableEffect(std::unique_ptr<GrFragmentProcessor> child, float xOffset,
|
||||
float yOffset)
|
||||
: INHERITED(CLASS_ID, kNone_OptimizationFlags)
|
||||
, fXOffset(xOffset)
|
||||
, fYOffset(yOffset) {
|
||||
SampleMatrixVariableEffect(std::unique_ptr<GrFragmentProcessor> child)
|
||||
: INHERITED(CLASS_ID, kNone_OptimizationFlags) {
|
||||
child->setSampleMatrix(SkSL::SampleMatrix(SkSL::SampleMatrix::Kind::kVariable));
|
||||
this->registerChildProcessor(std::move(child));
|
||||
}
|
||||
@ -44,25 +41,15 @@ public:
|
||||
|
||||
private:
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
||||
float fXOffset;
|
||||
float fYOffset;
|
||||
|
||||
typedef GrFragmentProcessor INHERITED;
|
||||
|
||||
friend class GLSLSampleMatrixVariableEffect;
|
||||
};
|
||||
|
||||
class GLSLSampleMatrixVariableEffect : public GrGLSLFragmentProcessor {
|
||||
void emitCode(EmitArgs& args) override {
|
||||
auto& smve = args.fFp.cast<SampleMatrixVariableEffect>();
|
||||
GrGLSLFPFragmentBuilder* fragBuilder = args.fFragBuilder;
|
||||
SkString sample1 = this->invokeChildWithMatrix(0, args, "float3x3(1)");
|
||||
SkString sample2 = this->invokeChildWithMatrix(0, args,
|
||||
SkStringPrintf("float3x3(1, -1, 0, 1, 0, 0, "
|
||||
"%g, %g, 1)",
|
||||
smve.fXOffset,
|
||||
smve.fYOffset).c_str());
|
||||
SkString sample2 = this->invokeChildWithMatrix(0, args, "float3x3(1, -1, 0, 1, 0, 0, "
|
||||
"-0.5, 1, 1)");
|
||||
fragBuilder->codeAppendf("%s = (%s + %s) / 2;\n", args.fOutputColor, sample1.c_str(),
|
||||
sample2.c_str());
|
||||
}
|
||||
@ -83,7 +70,7 @@ DEF_SIMPLE_GPU_GM(sample_matrix_variable, ctx, rtCtx, canvas, 512, 256) {
|
||||
GrTextureEffect::Make(std::move(view), bmp.alphaType(), SkMatrix());
|
||||
imgFP->setSampleMatrix(SkSL::SampleMatrix::Kind::kVariable);
|
||||
auto fp = std::unique_ptr<GrFragmentProcessor>(
|
||||
new SampleMatrixVariableEffect(std::move(imgFP), -128, 256));
|
||||
new SampleMatrixVariableEffect(std::move(imgFP)));
|
||||
|
||||
GrPaint paint;
|
||||
paint.addCoverageFragmentProcessor(std::move(fp));
|
||||
@ -106,7 +93,7 @@ DEF_SIMPLE_GPU_GM(sample_matrix_variable, ctx, rtCtx, canvas, 512, 256) {
|
||||
std::unique_ptr<GrFragmentProcessor> gradientFP = as_SB(shader)->asFragmentProcessor(args);
|
||||
gradientFP->setSampleMatrix(SkSL::SampleMatrix::Kind::kVariable);
|
||||
auto fp = std::unique_ptr<GrFragmentProcessor>(
|
||||
new SampleMatrixVariableEffect(std::move(gradientFP), -0.5, 1));
|
||||
new SampleMatrixVariableEffect(std::move(gradientFP)));
|
||||
paint.addCoverageFragmentProcessor(std::move(fp));
|
||||
rtCtx->drawRect(GrNoClip(), std::move(paint), GrAA::kNo, SkMatrix::I(), bounds);
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "src/gpu/GrColorInfo.h"
|
||||
#include "src/gpu/GrFPArgs.h"
|
||||
#include "src/gpu/effects/GrSkSLFP.h"
|
||||
#include "src/gpu/effects/generated/GrMatrixEffect.h"
|
||||
#endif
|
||||
|
||||
namespace SkSL {
|
||||
@ -649,7 +648,7 @@ public:
|
||||
if (!this->totalLocalMatrix(args.fPreLocalMatrix)->invert(&matrix)) {
|
||||
return nullptr;
|
||||
}
|
||||
auto fp = GrSkSLFP::Make(args.fContext, fEffect, "runtime_shader", fInputs);
|
||||
auto fp = GrSkSLFP::Make(args.fContext, fEffect, "runtime_shader", fInputs, &matrix);
|
||||
for (const auto& child : fChildren) {
|
||||
auto childFP = child ? as_SB(child)->asFragmentProcessor(args) : nullptr;
|
||||
if (!childFP) {
|
||||
@ -658,14 +657,10 @@ public:
|
||||
}
|
||||
fp->addChild(std::move(childFP));
|
||||
}
|
||||
std::unique_ptr<GrFragmentProcessor> result = std::move(fp);
|
||||
if (!matrix.isIdentity()) {
|
||||
result = GrMatrixEffect::Make(matrix, std::move(result));
|
||||
}
|
||||
if (GrColorTypeClampType(args.fDstColorInfo->colorType()) != GrClampType::kNone) {
|
||||
return GrFragmentProcessor::ClampPremulOutput(std::move(result));
|
||||
return GrFragmentProcessor::ClampPremulOutput(std::move(fp));
|
||||
} else {
|
||||
return result;
|
||||
return std::move(fp);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -64,6 +64,7 @@ public:
|
||||
for (int i = 0; *transformHandler; ++*transformHandler, ++i) {
|
||||
auto [coordTransform, fp] = transformHandler->get();
|
||||
|
||||
SkString matrix;
|
||||
GrShaderVar fragmentVar;
|
||||
GrShaderVar transformVar;
|
||||
if (fp.isSampledWithExplicitCoords()) {
|
||||
@ -88,6 +89,7 @@ public:
|
||||
&name)
|
||||
.toIndex();
|
||||
transformVar = uniformHandler->getUniformVariable(uni.fHandle);
|
||||
matrix = name;
|
||||
}
|
||||
} else {
|
||||
SkString strVaryingName;
|
||||
@ -102,9 +104,10 @@ public:
|
||||
.toIndex();
|
||||
#endif
|
||||
fVaryingTransform.back().fType = varyingType;
|
||||
matrix = matrix_to_sksl(coordTransform.matrix());
|
||||
fragmentVar = {SkString(v.fsIn()), varyingType};
|
||||
}
|
||||
transformHandler->specifyCoordsForCurrCoordTransform(transformVar, fragmentVar);
|
||||
transformHandler->specifyCoordsForCurrCoordTransform(matrix, transformVar, fragmentVar);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -163,23 +163,28 @@ public:
|
||||
};
|
||||
|
||||
std::unique_ptr<GrSkSLFP> GrSkSLFP::Make(GrContext_Base* context, sk_sp<SkRuntimeEffect> effect,
|
||||
const char* name, sk_sp<SkData> inputs) {
|
||||
const char* name, sk_sp<SkData> inputs,
|
||||
const SkMatrix* matrix) {
|
||||
if (inputs->size() != effect->inputSize()) {
|
||||
return nullptr;
|
||||
}
|
||||
return std::unique_ptr<GrSkSLFP>(new GrSkSLFP(
|
||||
context->priv().caps()->refShaderCaps(), context->priv().getShaderErrorHandler(),
|
||||
std::move(effect), name, std::move(inputs)));
|
||||
std::move(effect), name, std::move(inputs), matrix));
|
||||
}
|
||||
|
||||
GrSkSLFP::GrSkSLFP(sk_sp<const GrShaderCaps> shaderCaps, ShaderErrorHandler* shaderErrorHandler,
|
||||
sk_sp<SkRuntimeEffect> effect, const char* name, sk_sp<SkData> inputs)
|
||||
sk_sp<SkRuntimeEffect> effect, const char* name, sk_sp<SkData> inputs,
|
||||
const SkMatrix* matrix)
|
||||
: INHERITED(kGrSkSLFP_ClassID, kNone_OptimizationFlags)
|
||||
, fShaderCaps(std::move(shaderCaps))
|
||||
, fShaderErrorHandler(shaderErrorHandler)
|
||||
, fEffect(std::move(effect))
|
||||
, fName(name)
|
||||
, fInputs(std::move(inputs)) {
|
||||
if (matrix) {
|
||||
fCoordTransform = GrCoordTransform(*matrix);
|
||||
}
|
||||
this->addCoordTransform(&fCoordTransform);
|
||||
}
|
||||
|
||||
@ -190,6 +195,8 @@ GrSkSLFP::GrSkSLFP(const GrSkSLFP& other)
|
||||
, fEffect(other.fEffect)
|
||||
, fName(other.fName)
|
||||
, fInputs(other.fInputs) {
|
||||
SkASSERT(other.numCoordTransforms() == 1);
|
||||
fCoordTransform = other.fCoordTransform;
|
||||
this->addCoordTransform(&fCoordTransform);
|
||||
}
|
||||
|
||||
@ -284,7 +291,7 @@ std::unique_ptr<GrFragmentProcessor> GrSkSLFP::TestCreate(GrProcessorTestData* d
|
||||
auto result = GrSkSLFP::Make(d->context(), effect, "Arithmetic",
|
||||
SkData::MakeWithCopy(&inputs, sizeof(inputs)));
|
||||
result->addChild(GrConstColorProcessor::Make(
|
||||
SK_PMColor4fWHITE, GrConstColorProcessor::InputMode::kIgnore));
|
||||
SK_PMColor4fWHITE, GrConstColorProcessor::InputMode::kIgnore));
|
||||
return std::unique_ptr<GrFragmentProcessor>(result.release());
|
||||
}
|
||||
case 2: {
|
||||
|
@ -69,7 +69,8 @@ public:
|
||||
static std::unique_ptr<GrSkSLFP> Make(GrContext_Base* context,
|
||||
sk_sp<SkRuntimeEffect> effect,
|
||||
const char* name,
|
||||
sk_sp<SkData> inputs);
|
||||
sk_sp<SkData> inputs,
|
||||
const SkMatrix* matrix = nullptr);
|
||||
|
||||
const char* name() const override;
|
||||
|
||||
@ -81,7 +82,8 @@ private:
|
||||
using ShaderErrorHandler = GrContextOptions::ShaderErrorHandler;
|
||||
|
||||
GrSkSLFP(sk_sp<const GrShaderCaps> shaderCaps, ShaderErrorHandler* shaderErrorHandler,
|
||||
sk_sp<SkRuntimeEffect> effect, const char* name, sk_sp<SkData> inputs);
|
||||
sk_sp<SkRuntimeEffect> effect, const char* name, sk_sp<SkData> inputs,
|
||||
const SkMatrix* matrix);
|
||||
|
||||
GrSkSLFP(const GrSkSLFP& other);
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "src/gpu/GrTexture.h"
|
||||
#include "src/gpu/GrTexturePriv.h"
|
||||
#include "src/gpu/effects/generated/GrMatrixEffect.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentProcessor.h"
|
||||
#include "src/gpu/glsl/GrGLSLFragmentShaderBuilder.h"
|
||||
#include "src/gpu/glsl/GrGLSLProgramBuilder.h"
|
||||
@ -149,58 +148,12 @@ bool GrTextureEffect::Sampling::hasBorderAlpha() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void get_matrix(const SkMatrix& preMatrix, const GrSurfaceProxyView& view,
|
||||
SkMatrix* outMatrix, bool* outLazyProxyNormalization) {
|
||||
SkMatrix combined = preMatrix;
|
||||
bool normalize = view.proxy()->backendFormat().textureType() != GrTextureType::kRectangle;
|
||||
if (normalize) {
|
||||
if (view.proxy()->isFullyLazy()) {
|
||||
*outLazyProxyNormalization = true;
|
||||
} else {
|
||||
SkMatrixPriv::PostIDiv(&combined, view.proxy()->backingStoreDimensions().fWidth,
|
||||
view.proxy()->backingStoreDimensions().fHeight);
|
||||
*outLazyProxyNormalization = false;
|
||||
}
|
||||
} else {
|
||||
*outLazyProxyNormalization = false;
|
||||
}
|
||||
if (view.origin() == kBottomLeft_GrSurfaceOrigin) {
|
||||
if (normalize) {
|
||||
// combined.postScale(1,-1);
|
||||
// combined.postTranslate(0,1);
|
||||
combined.set(SkMatrix::kMSkewY,
|
||||
combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]);
|
||||
combined.set(SkMatrix::kMScaleY,
|
||||
combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]);
|
||||
combined.set(SkMatrix::kMTransY,
|
||||
combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]);
|
||||
} else {
|
||||
// combined.postScale(1, -1);
|
||||
// combined.postTranslate(0,1);
|
||||
SkScalar h = view.proxy()->backingStoreDimensions().fHeight;
|
||||
combined.set(SkMatrix::kMSkewY,
|
||||
h * combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]);
|
||||
combined.set(SkMatrix::kMScaleY,
|
||||
h * combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]);
|
||||
combined.set(SkMatrix::kMTransY,
|
||||
h * combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]);
|
||||
}
|
||||
}
|
||||
*outMatrix = combined;
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(GrSurfaceProxyView view,
|
||||
SkAlphaType alphaType,
|
||||
const SkMatrix& matrix,
|
||||
Filter filter) {
|
||||
SkMatrix final;
|
||||
bool lazyProxyNormalization;
|
||||
get_matrix(matrix, view, &final, &lazyProxyNormalization);
|
||||
return GrMatrixEffect::Apply(final, std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrTextureEffect(std::move(view),
|
||||
alphaType,
|
||||
Sampling(filter),
|
||||
lazyProxyNormalization)));
|
||||
return std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrTextureEffect(std::move(view), alphaType, matrix, Sampling(filter)));
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(GrSurfaceProxyView view,
|
||||
@ -211,14 +164,8 @@ std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(GrSurfaceProxyView vi
|
||||
const float border[4]) {
|
||||
Sampling sampling(*view.proxy(), sampler, SkRect::Make(view.proxy()->dimensions()), nullptr,
|
||||
border, caps);
|
||||
SkMatrix final;
|
||||
bool lazyProxyNormalization;
|
||||
get_matrix(matrix, view, &final, &lazyProxyNormalization);
|
||||
return GrMatrixEffect::Apply(final, std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrTextureEffect(std::move(view),
|
||||
alphaType,
|
||||
sampling,
|
||||
lazyProxyNormalization)));
|
||||
return std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrTextureEffect(std::move(view), alphaType, matrix, sampling));
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeSubset(GrSurfaceProxyView view,
|
||||
@ -229,14 +176,8 @@ std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeSubset(GrSurfaceProxyV
|
||||
const GrCaps& caps,
|
||||
const float border[4]) {
|
||||
Sampling sampling(*view.proxy(), sampler, subset, nullptr, border, caps);
|
||||
SkMatrix final;
|
||||
bool lazyProxyNormalization;
|
||||
get_matrix(matrix, view, &final, &lazyProxyNormalization);
|
||||
return GrMatrixEffect::Apply(final, std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrTextureEffect(std::move(view),
|
||||
alphaType,
|
||||
sampling,
|
||||
lazyProxyNormalization)));
|
||||
return std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrTextureEffect(std::move(view), alphaType, matrix, sampling));
|
||||
}
|
||||
|
||||
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeSubset(GrSurfaceProxyView view,
|
||||
@ -248,14 +189,8 @@ std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeSubset(GrSurfaceProxyV
|
||||
const GrCaps& caps,
|
||||
const float border[4]) {
|
||||
Sampling sampling(*view.proxy(), sampler, subset, &domain, border, caps);
|
||||
SkMatrix final;
|
||||
bool lazyProxyNormalization;
|
||||
get_matrix(matrix, view, &final, &lazyProxyNormalization);
|
||||
return GrMatrixEffect::Apply(final, std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrTextureEffect(std::move(view),
|
||||
alphaType,
|
||||
sampling,
|
||||
lazyProxyNormalization)));
|
||||
return std::unique_ptr<GrFragmentProcessor>(
|
||||
new GrTextureEffect(std::move(view), alphaType, matrix, sampling));
|
||||
}
|
||||
|
||||
GrTextureEffect::FilterLogic GrTextureEffect::GetFilterLogic(ShaderMode mode,
|
||||
@ -292,41 +227,28 @@ GrGLSLFragmentProcessor* GrTextureEffect::onCreateGLSLInstance() const {
|
||||
public:
|
||||
void emitCode(EmitArgs& args) override {
|
||||
auto& te = args.fFp.cast<GrTextureEffect>();
|
||||
SkString coords;
|
||||
if (args.fFp.isSampledWithExplicitCoords()) {
|
||||
coords = "_coords";
|
||||
} else {
|
||||
coords = args.fTransformedCoords[0].fVaryingPoint.c_str();
|
||||
}
|
||||
auto* fb = args.fFragBuilder;
|
||||
if (te.sampleMatrix().fKind == SkSL::SampleMatrix::Kind::kMixed) {
|
||||
args.fUniformHandler->writeUniformMappings(te.sampleMatrix().fOwner, fb);
|
||||
coords = SkStringPrintf("(%s * _matrix * float3(%s, 1)).xy",
|
||||
te.sampleMatrix().fExpression.c_str(),
|
||||
coords.c_str());
|
||||
}
|
||||
if (te.fShaderModes[0] == ShaderMode::kNone &&
|
||||
te.fShaderModes[1] == ShaderMode::kNone) {
|
||||
fb->codeAppendf("%s = ", args.fOutputColor);
|
||||
if (te.fLazyProxyNormalization) {
|
||||
const char* norm = nullptr;
|
||||
fNormUni = args.fUniformHandler->addUniform(&te, kFragment_GrShaderFlag,
|
||||
kFloat4_GrSLType, "norm", &norm);
|
||||
fb->appendTextureLookupAndBlend(args.fInputColor, SkBlendMode::kModulate,
|
||||
args.fTexSamplers[0],
|
||||
SkStringPrintf("%s * %s.zw", coords.c_str(),
|
||||
norm).c_str());
|
||||
SkString coords;
|
||||
if (args.fFp.isSampledWithExplicitCoords()) {
|
||||
coords = "_coords";
|
||||
} else {
|
||||
fb->appendTextureLookupAndBlend(args.fInputColor, SkBlendMode::kModulate,
|
||||
args.fTexSamplers[0], coords.c_str());
|
||||
coords = args.fTransformedCoords[0].fVaryingPoint.c_str();
|
||||
}
|
||||
switch (te.sampleMatrix().fKind) {
|
||||
case SkSL::SampleMatrix::Kind::kMixed:
|
||||
case SkSL::SampleMatrix::Kind::kVariable:
|
||||
coords = SkStringPrintf("(_matrix * float3(%s, 1)).xy", coords.c_str());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
fb->codeAppendf("%s = ", args.fOutputColor);
|
||||
fb->appendTextureLookupAndBlend(args.fInputColor, SkBlendMode::kModulate,
|
||||
args.fTexSamplers[0], coords.c_str());
|
||||
fb->codeAppendf(";");
|
||||
} else {
|
||||
// Tripping this assert means we have a normalized fully lazy proxy with a
|
||||
// non-default ShaderMode. There's nothing fundamentally wrong with doing that, but
|
||||
// it hasn't been tested and this code path probably won't handle normalization
|
||||
// properly in that case.
|
||||
SkASSERT(!te.fLazyProxyNormalization);
|
||||
// Here is the basic flow of the various ShaderModes are implemented in a series of
|
||||
// steps. Not all the steps apply to all the modes. We try to emit only the steps
|
||||
// that are necessary for the given x/y shader modes.
|
||||
@ -731,15 +653,14 @@ bool GrTextureEffect::onIsEqual(const GrFragmentProcessor& other) const {
|
||||
}
|
||||
|
||||
GrTextureEffect::GrTextureEffect(GrSurfaceProxyView view, SkAlphaType alphaType,
|
||||
const Sampling& sampling, bool lazyProxyNormalization)
|
||||
const SkMatrix& matrix, const Sampling& sampling)
|
||||
: GrFragmentProcessor(kGrTextureEffect_ClassID,
|
||||
ModulateForSamplerOptFlags(alphaType, sampling.hasBorderAlpha()))
|
||||
, fCoordTransform(SkMatrix::I())
|
||||
, fCoordTransform(matrix, view.proxy(), view.origin())
|
||||
, fSampler(std::move(view), sampling.fHWSampler)
|
||||
, fSubset(sampling.fShaderSubset)
|
||||
, fClamp(sampling.fShaderClamp)
|
||||
, fShaderModes{sampling.fShaderModes[0], sampling.fShaderModes[1]}
|
||||
, fLazyProxyNormalization(lazyProxyNormalization) {
|
||||
, fShaderModes{sampling.fShaderModes[0], sampling.fShaderModes[1]} {
|
||||
// We always compare the range even when it isn't used so assert we have canonical don't care
|
||||
// values.
|
||||
SkASSERT(fShaderModes[0] != ShaderMode::kNone || (fSubset.fLeft == 0 && fSubset.fRight == 0));
|
||||
@ -755,8 +676,7 @@ GrTextureEffect::GrTextureEffect(const GrTextureEffect& src)
|
||||
, fSampler(src.fSampler)
|
||||
, fSubset(src.fSubset)
|
||||
, fClamp(src.fClamp)
|
||||
, fShaderModes{src.fShaderModes[0], src.fShaderModes[1]}
|
||||
, fLazyProxyNormalization(src.fLazyProxyNormalization) {
|
||||
, fShaderModes{src.fShaderModes[0], src.fShaderModes[1]} {
|
||||
std::copy_n(src.fBorder, 4, fBorder);
|
||||
this->setTextureSamplerCnt(1);
|
||||
this->addCoordTransform(&fCoordTransform);
|
||||
|
@ -100,10 +100,8 @@ private:
|
||||
SkRect fSubset;
|
||||
SkRect fClamp;
|
||||
ShaderMode fShaderModes[2];
|
||||
// true if we are dealing with a fully lazy proxy which can't be normalized until runtime
|
||||
bool fLazyProxyNormalization;
|
||||
|
||||
inline GrTextureEffect(GrSurfaceProxyView, SkAlphaType, const Sampling&, bool);
|
||||
inline GrTextureEffect(GrSurfaceProxyView, SkAlphaType, const SkMatrix&, const Sampling&);
|
||||
|
||||
explicit GrTextureEffect(const GrTextureEffect& src);
|
||||
|
||||
|
@ -41,8 +41,6 @@ private:
|
||||
: INHERITED(kGrMatrixEffect_ClassID, kNone_OptimizationFlags), matrix(matrix) {
|
||||
SkASSERT(child);
|
||||
child_index = this->numChildProcessors();
|
||||
child->setSampleMatrix(
|
||||
SkSL::SampleMatrix(SkSL::SampleMatrix::Kind::kConstantOrUniform, this, "matrix"));
|
||||
this->registerChildProcessor(std::move(child));
|
||||
}
|
||||
GrGLSLFragmentProcessor* onCreateGLSLInstance() const override;
|
||||
|
@ -131,9 +131,14 @@ void GrGLSLGeometryProcessor::emitTransforms(GrGLSLVertexBuilder* vb,
|
||||
vb->codeAppendf("%s = %s * %s;", v.vsOut(), matrix.c_str(), localCoordsStr.c_str());
|
||||
}
|
||||
fsVar = GrShaderVar(SkString(v.fsIn()), v.type(), GrShaderVar::TypeModifier::In);
|
||||
fTransformInfos.push_back({ v.vsOut(), v.type(), matrix, localCoordsStr, &fp });
|
||||
fTransformInfos.push_back({ v.vsOut(), v.type(), matrix.c_str(), localCoordsStr, &fp });
|
||||
} else {
|
||||
SkASSERT(fp.sampleMatrix().fKind != SkSL::SampleMatrix::Kind::kVariable);
|
||||
if (fp.sampleMatrix().fKind == SkSL::SampleMatrix::Kind::kConstantOrUniform) {
|
||||
matrix += " * " + fp.sampleMatrix().fExpression;
|
||||
}
|
||||
}
|
||||
handler->specifyCoordsForCurrCoordTransform(transformVar, fsVar);
|
||||
handler->specifyCoordsForCurrCoordTransform(matrix, transformVar, fsVar);
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,12 +151,12 @@ void GrGLSLGeometryProcessor::emitTransformCode(GrGLSLVertexBuilder* vb,
|
||||
uniformHandler->writeUniformMappings(tr.fFP->sampleMatrix().fOwner, vb);
|
||||
if (tr.fType == kFloat2_GrSLType) {
|
||||
vb->codeAppendf("%s = (%s * %s * %s).xy", tr.fName,
|
||||
tr.fFP->sampleMatrix().fExpression.c_str(), tr.fMatrix.c_str(),
|
||||
tr.fFP->sampleMatrix().fExpression.c_str(), tr.fMatrix,
|
||||
tr.fLocalCoords.c_str());
|
||||
} else {
|
||||
SkASSERT(tr.fType == kFloat3_GrSLType);
|
||||
vb->codeAppendf("%s = %s * %s * %s", tr.fName,
|
||||
tr.fFP->sampleMatrix().fExpression.c_str(), tr.fMatrix.c_str(),
|
||||
tr.fFP->sampleMatrix().fExpression.c_str(), tr.fMatrix,
|
||||
tr.fName);
|
||||
}
|
||||
vb->codeAppend(";\n");
|
||||
|
@ -97,7 +97,7 @@ private:
|
||||
struct TransformInfo {
|
||||
const char* fName;
|
||||
GrSLType fType;
|
||||
SkString fMatrix;
|
||||
const char* fMatrix;
|
||||
SkString fLocalCoords;
|
||||
const GrFragmentProcessor* fFP;
|
||||
};
|
||||
|
@ -60,7 +60,8 @@ public:
|
||||
FPCoordTransformHandler& operator++();
|
||||
|
||||
// 'args' are constructor params to GrShaderVar.
|
||||
void specifyCoordsForCurrCoordTransform(GrShaderVar transformVar, GrShaderVar varyingVar) {
|
||||
void specifyCoordsForCurrCoordTransform(/* FIXME name and doc this properly */const SkString& name, GrShaderVar transformVar,
|
||||
GrShaderVar varyingVar) {
|
||||
SkASSERT(!fAddedCoord);
|
||||
fTransformedCoordVars->push_back({transformVar, varyingVar});
|
||||
SkDEBUGCODE(fAddedCoord = true;)
|
||||
|
@ -287,28 +287,6 @@ void HCodeGenerator::writeConstructor() {
|
||||
this->writef(" %s->setSampledWithExplicitCoords();",
|
||||
String(param->fName).c_str());
|
||||
}
|
||||
SampleMatrix matrix = fSectionAndParameterHelper.getMatrix(*param);
|
||||
switch (matrix.fKind) {
|
||||
case SampleMatrix::Kind::kVariable:
|
||||
this->writef(" %s->setSampleMatrix(this, "
|
||||
"SkSL::SampleMatrix::Kind::kVariable);",
|
||||
String(param->fName).c_str());
|
||||
break;
|
||||
case SampleMatrix::Kind::kConstantOrUniform:
|
||||
this->writef(" %s->setSampleMatrix(SkSL::SampleMatrix("
|
||||
"SkSL::SampleMatrix::Kind::kConstantOrUniform, this, \"%s\"));",
|
||||
String(param->fName).c_str(),
|
||||
matrix.fExpression.c_str());
|
||||
break;
|
||||
case SampleMatrix::Kind::kMixed:
|
||||
this->writef(" %s->setSampleMatrix(SkSL::SampleMatrix("
|
||||
"SkSL::SampleMatrix::Kind::kMixed, this, \"%s\"));",
|
||||
String(param->fName).c_str(),
|
||||
matrix.fExpression.c_str());
|
||||
break;
|
||||
case SampleMatrix::Kind::kNone:
|
||||
break;
|
||||
}
|
||||
this->writef(" this->registerChildProcessor(std::move(%s));",
|
||||
String(param->fName).c_str());
|
||||
if (param->fType.kind() == Type::kNullable_Kind) {
|
||||
|
@ -59,6 +59,7 @@ void PipelineStageCodeGenerator::writeFunctionCall(const FunctionCall& c) {
|
||||
SkASSERT(c.fArguments.size() == 2);
|
||||
SkASSERT("fragmentProcessor" == c.fArguments[0]->fType.name() ||
|
||||
"fragmentProcessor?" == c.fArguments[0]->fType.name());
|
||||
SkASSERT("float2" == c.fArguments[1]->fType.name());
|
||||
SkASSERT(Expression::kVariableReference_Kind == c.fArguments[0]->fKind);
|
||||
int index = 0;
|
||||
bool found = false;
|
||||
|
Loading…
Reference in New Issue
Block a user