#include "src/gpu/ganesh/effects/GrBicubicEffect.h"
#include "include/core/SkAlphaType.h"
#include "include/core/SkMatrix.h"
#include "include/core/SkRect.h"
#include "include/core/SkString.h"
#include "include/private/SkSLSampleUsage.h"
#include "include/private/gpu/ganesh/GrTypesPriv.h"
#include "src/base/SkRandom.h"
#include "src/core/SkSLTypeShared.h"
#include "src/gpu/KeyBuilder.h"
#include "src/gpu/ganesh/GrSurfaceProxyView.h"
#include "src/gpu/ganesh/GrTestUtils.h"
#include "src/gpu/ganesh/effects/GrMatrixEffect.h"
#include "src/gpu/ganesh/effects/GrTextureEffect.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/ganesh/glsl/GrGLSLProgramDataManager.h"
#include "src/gpu/ganesh/glsl/GrGLSLUniformHandler.h"
#include "src/shaders/SkImageShader.h"
#include "src/sksl/SkSLString.h"
#include <cmath>
#include <cstdint>
#include <string>
#include <utility>
class GrBicubicEffect::Impl : public ProgramImpl { … };
void GrBicubicEffect::Impl::emitCode(EmitArgs& args) { … }
void GrBicubicEffect::Impl::onSetData(const GrGLSLProgramDataManager& pdm,
const GrFragmentProcessor& fp) { … }
std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::Make(GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
SkCubicResampler kernel,
Direction direction) { … }
std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::Make(GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
const GrSamplerState::WrapMode wrapX,
const GrSamplerState::WrapMode wrapY,
SkCubicResampler kernel,
Direction direction,
const GrCaps& caps) { … }
std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::MakeSubset(
GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
const GrSamplerState::WrapMode wrapX,
const GrSamplerState::WrapMode wrapY,
const SkRect& subset,
SkCubicResampler kernel,
Direction direction,
const GrCaps& caps) { … }
std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::MakeSubset(
GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
const GrSamplerState::WrapMode wrapX,
const GrSamplerState::WrapMode wrapY,
const SkRect& subset,
const SkRect& domain,
SkCubicResampler kernel,
Direction direction,
const GrCaps& caps) { … }
std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::Make(std::unique_ptr<GrFragmentProcessor> fp,
SkAlphaType alphaType,
const SkMatrix& matrix,
SkCubicResampler kernel,
Direction direction) { … }
GrBicubicEffect::GrBicubicEffect(std::unique_ptr<GrFragmentProcessor> fp,
SkCubicResampler kernel,
Direction direction,
Clamp clamp)
: … { … }
GrBicubicEffect::GrBicubicEffect(const GrBicubicEffect& that)
: … { … }
void GrBicubicEffect::onAddToKey(const GrShaderCaps& caps, skgpu::KeyBuilder* b) const { … }
std::unique_ptr<GrFragmentProcessor::ProgramImpl> GrBicubicEffect::onMakeProgramImpl() const { … }
bool GrBicubicEffect::onIsEqual(const GrFragmentProcessor& other) const { … }
SkPMColor4f GrBicubicEffect::constantOutputForConstantInput(const SkPMColor4f& input) const { … }
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(…)
#if defined(GPU_TEST_UTILS)
std::unique_ptr<GrFragmentProcessor> GrBicubicEffect::TestCreate(GrProcessorTestData* d) {
Direction direction = Direction::kX;
switch (d->fRandom->nextULessThan(3)) {
case 0:
direction = Direction::kX;
break;
case 1:
direction = Direction::kY;
break;
case 2:
direction = Direction::kXY;
break;
}
auto kernel = d->fRandom->nextBool() ? GrBicubicEffect::gMitchell
: GrBicubicEffect::gCatmullRom;
auto m = GrTest::TestMatrix(d->fRandom);
switch (d->fRandom->nextULessThan(3)) {
case 0: {
auto [view, ct, at] = d->randomView();
GrSamplerState::WrapMode wm[2];
GrTest::TestWrapModes(d->fRandom, wm);
if (d->fRandom->nextBool()) {
SkRect subset;
subset.fLeft = d->fRandom->nextSScalar1() * view.width();
subset.fTop = d->fRandom->nextSScalar1() * view.height();
subset.fRight = d->fRandom->nextSScalar1() * view.width();
subset.fBottom = d->fRandom->nextSScalar1() * view.height();
subset.sort();
return MakeSubset(std::move(view),
at,
m,
wm[0],
wm[1],
subset,
kernel,
direction,
*d->caps());
}
return Make(std::move(view), at, m, wm[0], wm[1], kernel, direction, *d->caps());
}
case 1: {
auto [view, ct, at] = d->randomView();
return Make(std::move(view), at, m, kernel, direction);
}
default: {
SkAlphaType at;
do {
at = static_cast<SkAlphaType>(d->fRandom->nextULessThan(kLastEnum_SkAlphaType + 1));
} while (at == kUnknown_SkAlphaType);
return Make(GrProcessorUnitTest::MakeChildFP(d), at, m, kernel, direction);
}
}
}
#endif