aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2016-11-04 11:59:10 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2016-11-07 15:56:19 +0000
commit84a812061f1d16aa6d349ca065bf67d06767bbc2 (patch)
tree11f467989d4303a1fc62b8b7805547d0b77013fe /include
parent739c5bf111baf977fe418a24fa00ce260989ee9a (diff)
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 <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/private/GrRenderTargetProxy.h5
-rw-r--r--include/private/GrTextureProxy.h8
-rw-r--r--include/private/GrTextureRenderTargetProxy.h46
3 files changed, 54 insertions, 5 deletions
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<GrRenderTarget> 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<GrTextureProxy> Make(GrTextureProvider*, const GrSurfaceDesc&,
+ static sk_sp<GrTextureProxy> Make(const GrCaps&, GrTextureProvider*, const GrSurfaceDesc&,
SkBackingFit, SkBudgeted,
const void* srcData = nullptr, size_t rowBytes = 0);
static sk_sp<GrTextureProxy> Make(sk_sp<GrTexture>);
@@ -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<GrTexture> 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<GrTextureRenderTargetProxy> Make(const GrCaps&,
+ const GrSurfaceDesc&,
+ SkBackingFit, SkBudgeted);
+ static sk_sp<GrTextureRenderTargetProxy> Make(sk_sp<GrTexture>);
+ static sk_sp<GrTextureRenderTargetProxy> Make(sk_sp<GrRenderTarget>);
+
+private:
+ // Deferred version
+ GrTextureRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, SkBackingFit, SkBudgeted);
+
+ // Wrapped version
+ GrTextureRenderTargetProxy(sk_sp<GrRenderTarget> rt);
+
+ size_t onGpuMemorySize() const override;
+};
+
+#ifdef SK_BUILD_FOR_WIN
+#pragma warning(pop)
+#endif
+
+#endif