Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Member Functions | List of all members
GrTextureEffect Class Reference

#include <GrTextureEffect.h>

Inheritance diagram for GrTextureEffect:
GrFragmentProcessor GrProcessor

Classes

class  Impl
 
struct  Sampling
 

Public Member Functions

std::unique_ptr< GrFragmentProcessorclone () const override
 
const char * name () const override
 
GrSamplerState samplerState () const
 
GrTexturetexture () const
 
const GrSurfaceProxyViewview () const
 
SkMatrix coordAdjustmentMatrix () const
 
- Public Member Functions inherited from GrFragmentProcessor
const GrFragmentProcessorparent () const
 
std::unique_ptr< ProgramImplmakeProgramImpl () const
 
void addToKey (const GrShaderCaps &caps, skgpu::KeyBuilder *b) const
 
int numChildProcessors () const
 
int numNonNullChildProcessors () const
 
GrFragmentProcessorchildProcessor (int index)
 
const GrFragmentProcessorchildProcessor (int index) const
 
 SkDEBUGCODE (bool isInstantiated() const ;) bool willReadDstColor() const
 
bool isBlendFunction () const
 
bool usesSampleCoordsDirectly () const
 
bool usesSampleCoords () const
 
const SkSL::SampleUsagesampleUsage () const
 
bool compatibleWithCoverageAsAlpha () const
 
bool preservesOpaqueInput () const
 
bool hasConstantOutputForConstantInput (SkPMColor4f inputColor, SkPMColor4f *outputColor) const
 
bool hasConstantOutputForConstantInput () const
 
void clearConstantOutputForConstantInputFlag ()
 
bool isEqual (const GrFragmentProcessor &that) const
 
void visitProxies (const GrVisitProxyFunc &) const
 
void visitTextureEffects (const std::function< void(const GrTextureEffect &)> &) const
 
void visitWithImpls (const std::function< void(const GrFragmentProcessor &, ProgramImpl &)> &, ProgramImpl &) const
 
GrTextureEffectasTextureEffect ()
 
const GrTextureEffectasTextureEffect () const
 
- Public Member Functions inherited from GrProcessor
virtual ~GrProcessor ()=default
 
void * operator new (size_t size)
 
void * operator new (size_t object_size, size_t footer_size)
 
void operator delete (void *target)
 
void * operator new (size_t size, void *placement)
 
void operator delete (void *target, void *placement)
 
template<typename T >
const Tcast () const
 
ClassID classID () const
 

Static Public Member Functions

static std::unique_ptr< GrFragmentProcessorMake (GrSurfaceProxyView, SkAlphaType, const SkMatrix &=SkMatrix::I(), GrSamplerState::Filter=GrSamplerState::Filter::kNearest, GrSamplerState::MipmapMode mipmapMode=GrSamplerState::MipmapMode::kNone)
 
static std::unique_ptr< GrFragmentProcessorMake (GrSurfaceProxyView, SkAlphaType, const SkMatrix &, GrSamplerState, const GrCaps &caps, const float border[4]=kDefaultBorder)
 
static std::unique_ptr< GrFragmentProcessorMakeSubset (GrSurfaceProxyView, SkAlphaType, const SkMatrix &, GrSamplerState, const SkRect &subset, const GrCaps &caps, const float border[4]=kDefaultBorder, bool alwaysUseShaderTileMode=false)
 
static std::unique_ptr< GrFragmentProcessorMakeSubset (GrSurfaceProxyView, SkAlphaType, const SkMatrix &, GrSamplerState, const SkRect &subset, const SkRect &domain, const GrCaps &caps, const float border[4]=kDefaultBorder)
 
static std::unique_ptr< GrFragmentProcessorMakeCustomLinearFilterInset (GrSurfaceProxyView, SkAlphaType, const SkMatrix &, GrSamplerState::WrapMode wx, GrSamplerState::WrapMode wy, const SkRect &subset, const SkRect *domain, SkVector inset, const GrCaps &caps, const float border[4]=kDefaultBorder)
 
- Static Public Member Functions inherited from GrFragmentProcessor
static std::unique_ptr< GrFragmentProcessorMakeColor (SkPMColor4f color)
 
static std::unique_ptr< GrFragmentProcessorMulInputByChildAlpha (std::unique_ptr< GrFragmentProcessor > child)
 
static std::unique_ptr< GrFragmentProcessorApplyPaintAlpha (std::unique_ptr< GrFragmentProcessor > child)
 
static std::unique_ptr< GrFragmentProcessorModulateRGBA (std::unique_ptr< GrFragmentProcessor > child, const SkPMColor4f &color)
 
static std::unique_ptr< GrFragmentProcessorOverrideInput (std::unique_ptr< GrFragmentProcessor >, const SkPMColor4f &)
 
static std::unique_ptr< GrFragmentProcessorDisableCoverageAsAlpha (std::unique_ptr< GrFragmentProcessor >)
 
static std::unique_ptr< GrFragmentProcessorDestColor ()
 
static std::unique_ptr< GrFragmentProcessorSwizzleOutput (std::unique_ptr< GrFragmentProcessor >, const skgpu::Swizzle &)
 
static std::unique_ptr< GrFragmentProcessorClampOutput (std::unique_ptr< GrFragmentProcessor >)
 
static std::unique_ptr< GrFragmentProcessorCompose (std::unique_ptr< GrFragmentProcessor > f, std::unique_ptr< GrFragmentProcessor > g)
 
static std::unique_ptr< GrFragmentProcessorColorMatrix (std::unique_ptr< GrFragmentProcessor > child, const float matrix[20], bool unpremulInput, bool clampRGBOutput, bool premulOutput)
 
static std::unique_ptr< GrFragmentProcessorSurfaceColor ()
 
static std::unique_ptr< GrFragmentProcessorDeviceSpace (std::unique_ptr< GrFragmentProcessor >)
 
static std::unique_ptr< GrFragmentProcessorRect (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkRect)
 
static GrFPResult Circle (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkPoint center, float radius)
 
static GrFPResult Ellipse (std::unique_ptr< GrFragmentProcessor >, GrClipEdgeType, SkPoint center, SkPoint radii, const GrShaderCaps &)
 
static std::unique_ptr< GrFragmentProcessorHighPrecision (std::unique_ptr< GrFragmentProcessor >)
 

Static Public Attributes

static constexpr float kDefaultBorder [4] = {0}
 
static constexpr float kInsetEpsilon = 0.f
 
static constexpr float kLinearInset = 0.5f + kInsetEpsilon
 

Private Member Functions

std::unique_ptr< ProgramImplonMakeProgramImpl () const override
 
void onAddToKey (const GrShaderCaps &, skgpu::KeyBuilder *) const override
 
bool onIsEqual (const GrFragmentProcessor &) const override
 

Additional Inherited Members

- Public Types inherited from GrProcessor
enum  ClassID {
  kNull_ClassID , kAttributeTestProcessor_ClassID , kBigKeyProcessor_ClassID , kBlendFragmentProcessor_ClassID ,
  kBlockInputFragmentProcessor_ClassID , kButtCapStrokedCircleGeometryProcessor_ClassID , kCircleGeometryProcessor_ClassID , kCircularRRectEffect_ClassID ,
  kClockwiseTestProcessor_ClassID , kColorTableEffect_ClassID , kCoverageSetOpXP_ClassID , kCustomXP_ClassID ,
  kDashingCircleEffect_ClassID , kDashingLineEffect_ClassID , kDefaultGeoProc_ClassID , kDeviceSpace_ClassID ,
  kDIEllipseGeometryProcessor_ClassID , kDisableColorXP_ClassID , kDrawAtlasPathShader_ClassID , kEllipseGeometryProcessor_ClassID ,
  kEllipticalRRectEffect_ClassID , kFwidthSquircleTestProcessor_ClassID , kGP_ClassID , kGrBicubicEffect_ClassID ,
  kGrBitmapTextGeoProc_ClassID , kGrColorSpaceXformEffect_ClassID , kGrConicEffect_ClassID , kGrConvexPolyEffect_ClassID ,
  kGrDiffuseLightingEffect_ClassID , kGrDisplacementMapEffect_ClassID , kGrDistanceFieldA8TextGeoProc_ClassID , kGrDistanceFieldLCDTextGeoProc_ClassID ,
  kGrDistanceFieldPathGeoProc_ClassID , kGrFillRRectOp_Processor_ClassID , kGrGaussianConvolutionFragmentProcessor_ClassID , kGrMatrixConvolutionEffect_ClassID ,
  kGrMatrixEffect_ClassID , kGrMeshTestProcessor_ClassID , kGrMorphologyEffect_ClassID , kGrPerlinNoise2Effect_ClassID ,
  kGrPipelineDynamicStateTestProcessor_ClassID , kGrQuadEffect_ClassID , kGrRRectShadowGeoProc_ClassID , kGrSkSLFP_ClassID ,
  kGrSpecularLightingEffect_ClassID , kGrTextureEffect_ClassID , kGrUnrolledBinaryGradientColorizer_ClassID , kGrYUVtoRGBEffect_ClassID ,
  kHighPrecisionFragmentProcessor_ClassID , kLatticeGP_ClassID , kPDLCDXferProcessor_ClassID , kPorterDuffXferProcessor_ClassID ,
  kPremulFragmentProcessor_ClassID , kQuadEdgeEffect_ClassID , kQuadPerEdgeAAGeometryProcessor_ClassID , kSeriesFragmentProcessor_ClassID ,
  kShaderPDXferProcessor_ClassID , kSurfaceColorProcessor_ClassID , kSwizzleFragmentProcessor_ClassID , kTessellate_BoundingBoxShader_ClassID ,
  kTessellate_GrModulateAtlasCoverageEffect_ClassID , kTessellate_GrStrokeTessellationShader_ClassID , kTessellate_HullShader_ClassID , kTessellate_MiddleOutShader_ClassID ,
  kTessellate_SimpleTriangleShader_ClassID , kTessellationTestTriShader_ClassID , kTestFP_ClassID , kTestRectOp_ClassID ,
  kVertexColorSpaceBenchGP_ClassID , kVerticesGP_ClassID
}
 
- Protected Types inherited from GrFragmentProcessor
enum  OptimizationFlags : uint32_t {
  kNone_OptimizationFlags , kCompatibleWithCoverageAsAlpha_OptimizationFlag = 0x1 , kPreservesOpaqueInput_OptimizationFlag = 0x2 , kConstantOutputForConstantInput_OptimizationFlag = 0x4 ,
  kAll_OptimizationFlags
}
 
- Protected Member Functions inherited from GrFragmentProcessor
 GrFragmentProcessor (ClassID classID, OptimizationFlags optimizationFlags)
 
 GrFragmentProcessor (const GrFragmentProcessor &src)
 
OptimizationFlags optimizationFlags () const
 
void registerChild (std::unique_ptr< GrFragmentProcessor > child, SkSL::SampleUsage sampleUsage=SkSL::SampleUsage::PassThrough())
 
void cloneAndRegisterAllChildProcessors (const GrFragmentProcessor &src)
 
void setUsesSampleCoordsDirectly ()
 
void setWillReadDstColor ()
 
void setIsBlendFunction ()
 
void mergeOptimizationFlags (OptimizationFlags flags)
 
- Protected Member Functions inherited from GrProcessor
 GrProcessor (ClassID classID)
 
 GrProcessor (const GrProcessor &)=delete
 
GrProcessoroperator= (const GrProcessor &)=delete
 
- Static Protected Member Functions inherited from GrFragmentProcessor
static OptimizationFlags ModulateForSamplerOptFlags (SkAlphaType alphaType, bool samplingDecal)
 
static OptimizationFlags ModulateForClampedSamplerOptFlags (SkAlphaType alphaType)
 
static OptimizationFlags ProcessorOptimizationFlags (const GrFragmentProcessor *fp)
 
static SkPMColor4f ConstantOutputForConstantInput (const GrFragmentProcessor *fp, const SkPMColor4f &input)
 
- Protected Attributes inherited from GrProcessor
const ClassID fClassID
 

Detailed Description

Definition at line 32 of file GrTextureEffect.h.

Member Function Documentation

◆ clone()

std::unique_ptr< GrFragmentProcessor > GrTextureEffect::clone ( ) const
overridevirtual

Makes a copy of this fragment processor that draws equivalently to the original. If the processor has child processors they are cloned as well.

Implements GrFragmentProcessor.

Definition at line 850 of file GrTextureEffect.cpp.

850 {
851 return std::unique_ptr<GrFragmentProcessor>(new GrTextureEffect(*this));
852}

◆ coordAdjustmentMatrix()

SkMatrix GrTextureEffect::coordAdjustmentMatrix ( ) const

Definition at line 303 of file GrTextureEffect.cpp.

303 {
304 SkMatrix m;
305 GrTexture* texture = this->texture();
307 if (this->matrixEffectShouldNormalize()) {
308 if (fView.origin() == kBottomLeft_GrSurfaceOrigin) {
309 m.setScaleTranslate(1.f / d.width(), -1.f / d.height(), 0, 1);
310 } else {
311 m.setScale(1.f / d.width(), 1.f / d.height());
312 }
313 } else {
314 if (fView.origin() == kBottomLeft_GrSurfaceOrigin) {
315 m.setScaleTranslate(1.f, -1.f, 0, d.height());
316 }
317 }
318 return m;
319}
@ kBottomLeft_GrSurfaceOrigin
Definition GrTypes.h:149
GrSurfaceOrigin origin() const
SkISize dimensions() const
Definition GrSurface.h:27
GrTexture * texture() const
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE auto & d
Definition main.cc:19

◆ Make() [1/2]

std::unique_ptr< GrFragmentProcessor > GrTextureEffect::Make ( GrSurfaceProxyView  view,
SkAlphaType  alphaType,
const SkMatrix matrix,
GrSamplerState  sampler,
const GrCaps caps,
const float  border[4] = kDefaultBorder 
)
static

Make from a full GrSamplerState. Caps are required to determine support for kClampToBorder. This will be emulated in the shader if there is no hardware support.

Definition at line 229 of file GrTextureEffect.cpp.

234 {
235 Sampling sampling(*view.proxy(),
236 sampler,
238 nullptr,
239 border,
240 false,
241 caps);
242 std::unique_ptr<GrFragmentProcessor> te(new GrTextureEffect(std::move(view),
243 alphaType,
244 sampling));
245 return GrMatrixEffect::Make(matrix, std::move(te));
246}
static std::unique_ptr< GrFragmentProcessor > Make(const SkMatrix &matrix, std::unique_ptr< GrFragmentProcessor > child)
GrSurfaceProxy * proxy() const
SkISize dimensions() const
const GrSurfaceProxyView & view() const
SkSamplingOptions sampling
Definition SkRecords.h:337
static SkRect Make(const SkISize &size)
Definition SkRect.h:669

◆ Make() [2/2]

static std::unique_ptr< GrFragmentProcessor > GrTextureEffect::Make ( GrSurfaceProxyView  ,
SkAlphaType  ,
const SkMatrix = SkMatrix::I(),
GrSamplerState::Filter  = GrSamplerState::Filter::kNearest,
GrSamplerState::MipmapMode  mipmapMode = GrSamplerState::MipmapMode::kNone 
)
static

Make from a filter. The sampler will be configured with clamp mode.

◆ MakeCustomLinearFilterInset()

std::unique_ptr< GrFragmentProcessor > GrTextureEffect::MakeCustomLinearFilterInset ( GrSurfaceProxyView  view,
SkAlphaType  alphaType,
const SkMatrix matrix,
GrSamplerState::WrapMode  wx,
GrSamplerState::WrapMode  wy,
const SkRect subset,
const SkRect domain,
SkVector  inset,
const GrCaps caps,
const float  border[4] = kDefaultBorder 
)
static

Like MakeSubset() but always uses kLinear filtering. MakeSubset() uses the subset rect dimensions to determine the period of the wrap mode (for repeat and mirror). Once it computes the wrapped texture coordinate inside subset rect it further clamps it to a 0.5 inset rect of subset. When subset is an integer rectangle this clamping avoids the hw linear filtering from reading texels just outside the subset rect. This factory allows a custom inset clamping distance rather than 0.5, allowing those neighboring texels to influence the linear filtering sample result. If there is a known restriction on the post-matrix texture coords it can be specified using domain.

Definition at line 284 of file GrTextureEffect.cpp.

294 {
295 GrSamplerState sampler(wx, wy, Filter::kLinear);
296 Sampling sampling(*view.proxy(), sampler, subset, domain, border, false, caps, inset);
297 std::unique_ptr<GrFragmentProcessor> te(new GrTextureEffect(std::move(view),
298 alphaType,
299 sampling));
300 return GrMatrixEffect::Make(matrix, std::move(te));
301}
static SkRect inset(const SkRect &r)

◆ MakeSubset() [1/2]

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] = kDefaultBorder,
bool  alwaysUseShaderTileMode = false 
)
static

Makes a texture effect that samples a subset of a texture. The wrap modes of the GrSampleState are applied to the subset in the shader rather than using HW samplers. The 'subset' parameter specifies the texels in the base level. The shader code will avoid allowing linear filtering to read outside the texel window. However, if MIP filtering is used and a shader invocation reads from a level other than the base then it may read texel values that were computed from in part from base level texels outside the window. More specifically, we treat the MIP map case exactly like the linear case in terms of how the final texture coords are computed. If alwaysUseShaderTileMode is true then MakeSubset won't attempt to use HW wrap modes if the subset contains the entire texture.

Definition at line 248 of file GrTextureEffect.cpp.

255 {
256 Sampling sampling(*view.proxy(),
257 sampler,
258 subset,
259 nullptr,
260 border,
261 alwaysUseShaderTileMode,
262 caps);
263 std::unique_ptr<GrFragmentProcessor> te(new GrTextureEffect(std::move(view),
264 alphaType,
265 sampling));
266 return GrMatrixEffect::Make(matrix, std::move(te));
267}

◆ MakeSubset() [2/2]

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] = kDefaultBorder 
)
static

The same as above but also takes a 'domain' that specifies any known limit on the post- matrix texture coords that will be used to sample the texture. Specifying this requires knowledge of how this effect will be nested into a paint, the local coords used with the draw, etc. It is only used to attempt to optimize away the shader subset calculations.

Definition at line 269 of file GrTextureEffect.cpp.

276 {
277 Sampling sampling(*view.proxy(), sampler, subset, &domain, border, false, caps);
278 std::unique_ptr<GrFragmentProcessor> te(new GrTextureEffect(std::move(view),
279 alphaType,
280 sampling));
281 return GrMatrixEffect::Make(matrix, std::move(te));
282}

◆ name()

const char * GrTextureEffect::name ( ) const
inlineoverridevirtual

Human-meaningful string to identify this processor; may be embedded in generated shader code and must be a legal SkSL identifier prefix.

Implements GrProcessor.

Definition at line 131 of file GrTextureEffect.h.

131{ return "TextureEffect"; }

◆ onAddToKey()

void GrTextureEffect::onAddToKey ( const GrShaderCaps ,
skgpu::KeyBuilder b 
) const
overrideprivatevirtual

Implements GrFragmentProcessor.

Definition at line 787 of file GrTextureEffect.cpp.

787 {
788 auto m0 = static_cast<uint32_t>(fShaderModes[0]);
789 b->addBits(8, m0, "shaderMode0");
790
791 auto m1 = static_cast<uint32_t>(fShaderModes[1]);
792 b->addBits(8, m1, "shaderMode1");
793}
static bool b

◆ onIsEqual()

bool GrTextureEffect::onIsEqual ( const GrFragmentProcessor ) const
overrideprivatevirtual

Subclass implements this to support isEqual(). It will only be called if it is known that the two processors are of the same subclass (i.e. have the same ClassID).

Implements GrFragmentProcessor.

Definition at line 795 of file GrTextureEffect.cpp.

795 {
796 auto& that = other.cast<GrTextureEffect>();
797 if (fView != that.fView) {
798 return false;
799 }
800 if (fSamplerState != that.fSamplerState) {
801 return false;
802 }
803 if (fShaderModes[0] != that.fShaderModes[0] || fShaderModes[1] != that.fShaderModes[1]) {
804 return false;
805 }
806 if (fSubset != that.fSubset) {
807 return false;
808 }
809 if (this->hasClampToBorderShaderMode() && !std::equal(fBorder, fBorder + 4, that.fBorder)) {
810 return false;
811 }
812 return true;
813}

◆ onMakeProgramImpl()

std::unique_ptr< GrFragmentProcessor::ProgramImpl > GrTextureEffect::onMakeProgramImpl ( ) const
overrideprivatevirtual

Returns a new instance of the appropriate ProgramImpl subclass for the given GrFragmentProcessor. It will emit the appropriate code and live with the cached program to setup uniform data for each draw that uses the program.

Implements GrFragmentProcessor.

Definition at line 783 of file GrTextureEffect.cpp.

783 {
784 return std::make_unique<Impl>();
785}

◆ samplerState()

GrSamplerState GrTextureEffect::samplerState ( ) const
inline

Definition at line 133 of file GrTextureEffect.h.

133{ return fSamplerState; }

◆ texture()

GrTexture * GrTextureEffect::texture ( ) const
inline

Definition at line 135 of file GrTextureEffect.h.

135{ return fView.asTextureProxy()->peekTexture(); }
GrTextureProxy * asTextureProxy() const
GrTexture * peekTexture() const

◆ view()

const GrSurfaceProxyView & GrTextureEffect::view ( ) const
inline

Definition at line 137 of file GrTextureEffect.h.

137{ return fView; }

Member Data Documentation

◆ kDefaultBorder

constexpr float GrTextureEffect::kDefaultBorder[4] = {0}
inlinestaticconstexpr

Definition at line 34 of file GrTextureEffect.h.

34{0};

◆ kInsetEpsilon

constexpr float GrTextureEffect::kInsetEpsilon = 0.f
inlinestaticconstexpr

Definition at line 49 of file GrTextureEffect.h.

◆ kLinearInset

constexpr float GrTextureEffect::kLinearInset = 0.5f + kInsetEpsilon
inlinestaticconstexpr

Definition at line 52 of file GrTextureEffect.h.


The documentation for this class was generated from the following files: