From 84a812061f1d16aa6d349ca065bf67d06767bbc2 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Fri, 4 Nov 2016 11:59:10 -0400 Subject: Add GrTextureRenderTargetProxy and support switching between RT & Tex Proxies GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=4427 Change-Id: Ie7662299953592f564bb27a4df4ea101f743403e Reviewed-on: https://skia-review.googlesource.com/4427 Reviewed-by: Brian Salomon Commit-Queue: Robert Phillips --- include/private/GrRenderTargetProxy.h | 5 +-- include/private/GrTextureProxy.h | 8 +++-- include/private/GrTextureRenderTargetProxy.h | 46 ++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 include/private/GrTextureRenderTargetProxy.h (limited to 'include') diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h index c124dddd79..3bad9df9e4 100644 --- a/include/private/GrRenderTargetProxy.h +++ b/include/private/GrRenderTargetProxy.h @@ -18,7 +18,7 @@ class GrTextureProvider; // required // Beware: the uniqueID of the RenderTargetProxy will usually be different than // the uniqueID of the RenderTarget it represents! -class GrRenderTargetProxy : public GrSurfaceProxy { +class GrRenderTargetProxy : virtual public GrSurfaceProxy { public: /** * The caller gets the creation ref. @@ -65,13 +65,14 @@ public: SkDEBUGCODE(void validate(GrContext*) const;) -private: +protected: // Deferred version GrRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted); // Wrapped version GrRenderTargetProxy(sk_sp rt); +private: size_t onGpuMemorySize() const override; // For wrapped render targets the actual GrRenderTarget is stored in the GrIORefProxy class. diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h index b85302feea..e68ef8896a 100644 --- a/include/private/GrTextureProxy.h +++ b/include/private/GrTextureProxy.h @@ -11,14 +11,15 @@ #include "GrSurfaceProxy.h" #include "GrTexture.h" +class GrCaps; class GrTextureProvider; // This class delays the acquisition of textures until they are actually required -class GrTextureProxy : public GrSurfaceProxy { +class GrTextureProxy : virtual public GrSurfaceProxy { public: // TODO: need to refine ownership semantics of 'srcData' if we're in completely // deferred mode - static sk_sp Make(GrTextureProvider*, const GrSurfaceDesc&, + static sk_sp Make(const GrCaps&, GrTextureProvider*, const GrSurfaceDesc&, SkBackingFit, SkBudgeted, const void* srcData = nullptr, size_t rowBytes = 0); static sk_sp Make(sk_sp); @@ -30,13 +31,14 @@ public: // Actually instantiate the backing texture, if necessary GrTexture* instantiate(GrTextureProvider*); -private: +protected: // Deferred version GrTextureProxy(const GrSurfaceDesc& srcDesc, SkBackingFit, SkBudgeted, const void* srcData, size_t srcRowBytes); // Wrapped version GrTextureProxy(sk_sp tex); +private: size_t onGpuMemorySize() const override; // For wrapped proxies the GrTexture pointer is stored in GrIORefProxy. diff --git a/include/private/GrTextureRenderTargetProxy.h b/include/private/GrTextureRenderTargetProxy.h new file mode 100644 index 0000000000..c4d190f94d --- /dev/null +++ b/include/private/GrTextureRenderTargetProxy.h @@ -0,0 +1,46 @@ +/* + * Copyright 2016 Google Inc. + * + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +#ifndef GrTextureRenderTargetProxy_DEFINED +#define GrTextureRenderTargetProxy_DEFINED + +#include "GrRenderTargetProxy.h" +#include "GrTextureProxy.h" + +#ifdef SK_BUILD_FOR_WIN +// Windows gives warnings about inheriting asTextureProxy/asRenderTargetProxy via dominance. +#pragma warning(push) +#pragma warning(disable: 4250) +#endif + +// This class delays the acquisition of RenderTargets that are also textures until +// they are actually required +// Beware: the uniqueID of the TextureRenderTargetProxy will usually be different than +// the uniqueID of the RenderTarget/Texture it represents! +class GrTextureRenderTargetProxy : public GrTextureProxy, public GrRenderTargetProxy { +public: + static sk_sp Make(const GrCaps&, + const GrSurfaceDesc&, + SkBackingFit, SkBudgeted); + static sk_sp Make(sk_sp); + static sk_sp Make(sk_sp); + +private: + // Deferred version + GrTextureRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted); + + // Wrapped version + GrTextureRenderTargetProxy(sk_sp rt); + + size_t onGpuMemorySize() const override; +}; + +#ifdef SK_BUILD_FOR_WIN +#pragma warning(pop) +#endif + +#endif -- cgit v1.2.3