diff options
author | Brian Salomon <bsalomon@google.com> | 2017-07-28 13:41:51 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-07-28 18:02:52 +0000 |
commit | b17e63938fdd466e43c8f15ae19b051f3f2679bf (patch) | |
tree | 96493177e23b4ef6736063b3668fe4d7f63a1804 /src | |
parent | eee5183a322dd902de743ac02f33a5fd3181b0b6 (diff) |
Add clone methods to unit test GrFragmentProcessor classes
Also adds testing of copying ImageStorageAccess and ref counts of proxies held by cloned FPs.
Change-Id: Ia23220bf65b4df83d1c874b46d8525cc3540f716
Reviewed-on: https://skia-review.googlesource.com/28004
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/GrProcessor.h | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/src/gpu/GrProcessor.h b/src/gpu/GrProcessor.h index 2afebb72b1..e4bf5919ff 100644 --- a/src/gpu/GrProcessor.h +++ b/src/gpu/GrProcessor.h @@ -229,10 +229,14 @@ public: , fVisibility(that.fVisibility) {} TextureSampler(sk_sp<GrTextureProxy>, const GrSamplerParams&); + explicit TextureSampler(sk_sp<GrTextureProxy>, GrSamplerParams::FilterMode = GrSamplerParams::kNone_FilterMode, SkShader::TileMode tileXAndY = SkShader::kClamp_TileMode, GrShaderFlags visibility = kFragment_GrShaderFlag); + + TextureSampler& operator=(const TextureSampler&) = delete; + void reset(sk_sp<GrTextureProxy>, const GrSamplerParams&, GrShaderFlags visibility = kFragment_GrShaderFlag); void reset(sk_sp<GrTextureProxy>, @@ -279,7 +283,7 @@ private: * Used to represent a texel buffer that will be read in a GrResourceIOProcessor. It holds a * GrBuffer along with an associated offset and texel config. */ -class GrResourceIOProcessor::BufferAccess : public SkNoncopyable { +class GrResourceIOProcessor::BufferAccess { public: BufferAccess() = default; BufferAccess(GrPixelConfig texelConfig, GrBuffer* buffer, @@ -287,6 +291,17 @@ public: this->reset(texelConfig, buffer, visibility); } /** + * This copy constructor is used by GrFragmentProcessor::clone() implementations. The copy + * always takes a new ref on the buffer proxy as the new fragment processor will not yet be + * in pending execution state. + */ + explicit BufferAccess(const BufferAccess& that) { + this->reset(that.fTexelConfig, that.fBuffer.get(), that.fVisibility); + } + + BufferAccess& operator=(const BufferAccess&) = delete; + + /** * Must be initialized before adding to a GrProcessor's buffer access list. */ void reset(GrPixelConfig texelConfig, GrBuffer* buffer, @@ -327,10 +342,23 @@ private: * Currently the format of the load/store data in the shader is inferred from the texture config, * though it could be made explicit. */ -class GrResourceIOProcessor::ImageStorageAccess : public SkNoncopyable { +class GrResourceIOProcessor::ImageStorageAccess { public: ImageStorageAccess(sk_sp<GrTextureProxy>, GrIOType, GrSLMemoryModel, GrSLRestrict, GrShaderFlags visibility = kFragment_GrShaderFlag); + /** + * This copy constructor is used by GrFragmentProcessor::clone() implementations. The copy + * always takes a new ref on the surface proxy as the new fragment processor will not yet be + * in pending execution state. + */ + explicit ImageStorageAccess(const ImageStorageAccess& that) + : fProxyRef(sk_ref_sp(that.fProxyRef.get()), that.fProxyRef.ioType()) + , fVisibility(that.fVisibility) + , fFormat(that.fFormat) + , fMemoryModel(that.fMemoryModel) + , fRestrict(that.fRestrict) {} + + ImageStorageAccess& operator=(const ImageStorageAccess&) = delete; bool operator==(const ImageStorageAccess& that) const { return this->proxy() == that.proxy() && fVisibility == that.fVisibility; |