diff options
Diffstat (limited to 'src/gpu/GrProcessor.h')
-rw-r--r-- | src/gpu/GrProcessor.h | 122 |
1 files changed, 0 insertions, 122 deletions
diff --git a/src/gpu/GrProcessor.h b/src/gpu/GrProcessor.h index f4a1e1682b..1c0161a811 100644 --- a/src/gpu/GrProcessor.h +++ b/src/gpu/GrProcessor.h @@ -196,126 +196,4 @@ private: ClassID fClassID; }; -/** A GrProcessor with the ability to access textures, buffers, and image storages. */ -class GrResourceIOProcessor : public GrProcessor { -public: - class TextureSampler; - - int numTextureSamplers() const { return fNumTextureSamplers; } - - /** Gets a TextureSampler which is a combination of a GrTextureProxy and how it is sampled. - * index must be valid according to numTextureSamplers(). */ - const TextureSampler& textureSampler(int index) const { - SkASSERT(index >= 0 && index < fNumTextureSamplers); - return this->onTextureSampler(index); - } - - bool instantiate(GrResourceProvider* resourceProvider) const; - -protected: - template <typename... Args> - static const TextureSampler& IthTextureSampler(int i, const TextureSampler& samp0, - const Args&... samps) { - return (0 == i) ? samp0 : IthTextureSampler(i - 1, samps...); - } - inline static const TextureSampler& IthTextureSampler(int i); - - GrResourceIOProcessor(ClassID classID) : INHERITED(classID) {} - - void setTextureSamplerCnt(int numTextureSamplers) { - SkASSERT(numTextureSamplers >= 0); - fNumTextureSamplers = numTextureSamplers; - } - - bool hasSameSamplers(const GrResourceIOProcessor&) const; - - // These methods can be used by derived classes that also derive from GrProgramElement. - void addPendingIOs() const; - void removeRefs() const; - void pendingIOComplete() const; - -private: - virtual const TextureSampler& onTextureSampler(int index) const { return IthTextureSampler(0); } - - int fNumTextureSamplers = 0; - typedef GrProcessor INHERITED; -}; - -/** - * Used to represent a texture that is required by a GrResourceIOProcessor. It holds a GrTexture - * along with an associated GrSamplerState. TextureSamplers don't perform any coord manipulation to - * account for texture origin. - */ -class GrResourceIOProcessor::TextureSampler { -public: - /** - * Must be initialized before adding to a GrProcessor's texture access list. - */ - TextureSampler(); - /** - * This copy constructor is used by GrFragmentProcessor::clone() implementations. The copy - * always takes a new ref on the texture proxy as the new fragment processor will not yet be - * in pending execution state. - */ - explicit TextureSampler(const TextureSampler& that) - : fProxyRef(sk_ref_sp(that.fProxyRef.get()), that.fProxyRef.ioType()) - , fSamplerState(that.fSamplerState) - , fVisibility(that.fVisibility) {} - - TextureSampler(sk_sp<GrTextureProxy>, const GrSamplerState&); - - explicit TextureSampler(sk_sp<GrTextureProxy>, - GrSamplerState::Filter = GrSamplerState::Filter::kNearest, - GrSamplerState::WrapMode wrapXAndY = GrSamplerState::WrapMode::kClamp, - GrShaderFlags visibility = kFragment_GrShaderFlag); - - TextureSampler& operator=(const TextureSampler&) = delete; - - void reset(sk_sp<GrTextureProxy>, const GrSamplerState&, - GrShaderFlags visibility = kFragment_GrShaderFlag); - void reset(sk_sp<GrTextureProxy>, - GrSamplerState::Filter = GrSamplerState::Filter::kNearest, - GrSamplerState::WrapMode wrapXAndY = GrSamplerState::WrapMode::kClamp, - GrShaderFlags visibility = kFragment_GrShaderFlag); - - bool operator==(const TextureSampler& that) const { - return this->proxy()->underlyingUniqueID() == that.proxy()->underlyingUniqueID() && - fSamplerState == that.fSamplerState && fVisibility == that.fVisibility; - } - - bool operator!=(const TextureSampler& other) const { return !(*this == other); } - - // 'instantiate' should only ever be called at flush time. - bool instantiate(GrResourceProvider* resourceProvider) const { - return SkToBool(fProxyRef.get()->instantiate(resourceProvider)); - } - - // 'peekTexture' should only ever be called after a successful 'instantiate' call - GrTexture* peekTexture() const { - SkASSERT(fProxyRef.get()->priv().peekTexture()); - return fProxyRef.get()->priv().peekTexture(); - } - - GrTextureProxy* proxy() const { return fProxyRef.get()->asTextureProxy(); } - GrShaderFlags visibility() const { return fVisibility; } - const GrSamplerState& samplerState() const { return fSamplerState; } - - bool isInitialized() const { return SkToBool(fProxyRef.get()); } - /** - * For internal use by GrProcessor. - */ - const GrSurfaceProxyRef* programProxy() const { return &fProxyRef; } - -private: - GrSurfaceProxyRef fProxyRef; - GrSamplerState fSamplerState; - GrShaderFlags fVisibility; -}; - -const GrResourceIOProcessor::TextureSampler& GrResourceIOProcessor::IthTextureSampler(int i) { - SK_ABORT("Illegal texture sampler index"); - static const TextureSampler kBogus; - return kBogus; -} - #endif |