#include "src/gpu/ganesh/effects/GrTextureEffect.h"
#include "include/core/SkSize.h"
#include "include/core/SkString.h"
#include "include/gpu/GpuTypes.h"
#include "include/gpu/ganesh/GrTypes.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkFloatingPoint.h"
#include "include/private/base/SkMath.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/GrSurfaceProxy.h"
#include "src/gpu/ganesh/GrTestUtils.h"
#include "src/gpu/ganesh/GrTexture.h"
#include "src/gpu/ganesh/effects/GrMatrixEffect.h"
#include "src/gpu/ganesh/glsl/GrGLSLFragmentShaderBuilder.h"
#include "src/gpu/ganesh/glsl/GrGLSLProgramDataManager.h"
#include "src/gpu/ganesh/glsl/GrGLSLUniformHandler.h"
#include <algorithm>
#include <cmath>
#include <utility>
enum SkAlphaType : int;
struct GrShaderCaps;
Wrap;
Filter;
MipmapMode;
struct GrTextureEffect::Sampling { … };
GrTextureEffect::Sampling::Sampling(const GrSurfaceProxy& proxy,
GrSamplerState sampler,
const SkRect& subset,
const SkRect* domain,
const float border[4],
bool alwaysUseShaderTileMode,
const GrCaps& caps,
SkVector linearFilterInset) { … }
bool GrTextureEffect::Sampling::hasBorderAlpha() const { … }
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
Filter filter,
MipmapMode mm) { … }
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::Make(GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
GrSamplerState sampler,
const GrCaps& caps,
const float border[4]) { … }
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeSubset(GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
GrSamplerState sampler,
const SkRect& subset,
const GrCaps& caps,
const float border[4],
bool alwaysUseShaderTileMode) { … }
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeSubset(GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
GrSamplerState sampler,
const SkRect& subset,
const SkRect& domain,
const GrCaps& caps,
const float border[4]) { … }
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::MakeCustomLinearFilterInset(
GrSurfaceProxyView view,
SkAlphaType alphaType,
const SkMatrix& matrix,
Wrap wx,
Wrap wy,
const SkRect& subset,
const SkRect* domain,
SkVector inset,
const GrCaps& caps,
const float border[4]) { … }
SkMatrix GrTextureEffect::coordAdjustmentMatrix() const { … }
GrTextureEffect::ShaderMode GrTextureEffect::GetShaderMode(Wrap wrap,
Filter filter,
MipmapMode mm) { … }
inline bool GrTextureEffect::ShaderModeIsClampToBorder(ShaderMode m) { … }
bool GrTextureEffect::ShaderModeRequiresUnormCoord(ShaderMode m) { … }
void GrTextureEffect::Impl::emitCode(EmitArgs& args) { … }
void GrTextureEffect::Impl::onSetData(const GrGLSLProgramDataManager& pdm,
const GrFragmentProcessor& fp) { … }
std::unique_ptr<GrFragmentProcessor::ProgramImpl> GrTextureEffect::onMakeProgramImpl() const { … }
void GrTextureEffect::onAddToKey(const GrShaderCaps&, skgpu::KeyBuilder* b) const { … }
bool GrTextureEffect::onIsEqual(const GrFragmentProcessor& other) const { … }
bool GrTextureEffect::matrixEffectShouldNormalize() const { … }
GrTextureEffect::GrTextureEffect(GrSurfaceProxyView view,
SkAlphaType alphaType,
const Sampling& sampling)
: … { … }
GrTextureEffect::GrTextureEffect(const GrTextureEffect& src)
: … { … }
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::clone() const { … }
GR_DEFINE_FRAGMENT_PROCESSOR_TEST(…)
#if defined(GPU_TEST_UTILS)
std::unique_ptr<GrFragmentProcessor> GrTextureEffect::TestCreate(GrProcessorTestData* testData) {
auto [view, ct, at] = testData->randomView();
Wrap wrapModes[2];
GrTest::TestWrapModes(testData->fRandom, wrapModes);
Filter filter = testData->fRandom->nextBool() ? Filter::kLinear : Filter::kNearest;
MipmapMode mm = MipmapMode::kNone;
if (view.asTextureProxy()->mipmapped() == skgpu::Mipmapped::kYes) {
mm = testData->fRandom->nextBool() ? MipmapMode::kLinear : MipmapMode::kNone;
}
GrSamplerState params(wrapModes, filter, mm);
const SkMatrix& matrix = GrTest::TestMatrix(testData->fRandom);
return GrTextureEffect::Make(std::move(view), at, matrix, params, *testData->caps());
}
#endif