aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGreg Daniel <egdaniel@google.com>2018-11-16 15:43:41 -0500
committerSkia Commit-Bot <skia-commit-bot@chromium.org>2018-11-19 18:51:07 +0000
commit4065d45d2de171a36de60a0d7b094166bfa1a782 (patch)
tree635a095ce5d1b059032fd1261ca6d744d5bb75b0 /include
parent6d9a51a75c52e5857e8c665f2ca8463bdb687cee (diff)
downloadskqp-4065d45d2de171a36de60a0d7b094166bfa1a782.tar.gz
Reland "Reland "Have a GrBackendFormat be stored on gpu proxies.""
This is a reland of 2f9a5ea639925f38785f4d3a0af237822007cfd6 Original change's description: > Reland "Have a GrBackendFormat be stored on gpu proxies." > > This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168. > > Reason for revert: Flutter change has landed and fixed memory issue. > > Original change's description: > > Revert "Have a GrBackendFormat be stored on gpu proxies." > > > > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce. > > > > Reason for revert: reverting till flutter gets to 1.1 to fix build issues. > > > > Original change's description: > > > Have a GrBackendFormat be stored on gpu proxies. > > > > > > Bug: skia: > > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90 > > > Reviewed-on: https://skia-review.googlesource.com/c/168021 > > > Reviewed-by: Brian Osman <brianosman@google.com> > > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > > > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885 > > No-Presubmit: true > > No-Tree-Checks: true > > No-Try: true > > Bug: chromium:903701 chromium:903756 > > Reviewed-on: https://skia-review.googlesource.com/c/169835 > > Commit-Queue: Greg Daniel <egdaniel@google.com> > > Reviewed-by: Greg Daniel <egdaniel@google.com> > > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com > > Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d > Bug: chromium:903701 chromium:903756 > Reviewed-on: https://skia-review.googlesource.com/c/170104 > Commit-Queue: Greg Daniel <egdaniel@google.com> > Reviewed-by: Greg Daniel <egdaniel@google.com> > Reviewed-by: Brian Osman <brianosman@google.com> Bug: chromium:903701 chromium:903756 Change-Id: Id1360067d8e928b0a4e1848dae8bc1e7f1994403 Reviewed-on: https://skia-review.googlesource.com/c/171660 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Greg Daniel <egdaniel@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrBackendSurface.h12
-rw-r--r--include/gpu/GrSurface.h4
-rw-r--r--include/private/GrRenderTargetProxy.h8
-rw-r--r--include/private/GrSurfaceProxy.h20
-rw-r--r--include/private/GrTextureProxy.h18
5 files changed, 36 insertions, 26 deletions
diff --git a/include/gpu/GrBackendSurface.h b/include/gpu/GrBackendSurface.h
index 3f40ce2feb..1de6fb0414 100644
--- a/include/gpu/GrBackendSurface.h
+++ b/include/gpu/GrBackendSurface.h
@@ -61,7 +61,8 @@ public:
return GrBackendFormat(config);
}
- GrBackendApi backend() const {return fBackend; }
+ GrBackendApi backend() const { return fBackend; }
+ GrTextureType textureType() const { return fTextureType; }
// If the backend API is GL, these return a pointer to the format and target. Otherwise
// it returns nullptr.
@@ -82,6 +83,9 @@ public:
// it returns nullptr.
const GrPixelConfig* getMockFormat() const;
+ // If possible, copies the GrBackendFormat and forces the texture type to be Texture2D
+ GrBackendFormat makeTexture2D() const;
+
// Returns true if the backend format has been initialized.
bool isValid() const { return fValid; }
@@ -100,16 +104,14 @@ private:
bool fValid;
union {
- struct {
- GrGLenum fTarget; // GL_TEXTURE_2D, GL_TEXTURE_EXTERNAL or GL_TEXTURE_RECTANGLE
- GrGLenum fFormat; // the sized, internal format of the GL resource
- } fGL;
+ GrGLenum fGLFormat; // the sized, internal format of the GL resource
VkFormat fVkFormat;
#ifdef SK_METAL
GrMTLPixelFormat fMtlFormat;
#endif
GrPixelConfig fMockFormat;
};
+ GrTextureType fTextureType;
};
class SK_API GrBackendTexture {
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index a93cacf501..bcd854f11e 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -9,6 +9,7 @@
#define GrSurface_DEFINED
#include "GrTypes.h"
+#include "GrBackendSurface.h"
#include "GrGpuResource.h"
#include "SkImageInfo.h"
#include "SkRect.h"
@@ -42,6 +43,8 @@ public:
*/
GrPixelConfig config() const { return fConfig; }
+ virtual GrBackendFormat backendFormat() const = 0;
+
/**
* @return the texture associated with the surface, may be null.
*/
@@ -103,7 +106,6 @@ protected:
~GrSurface() override {}
-
void onRelease() override;
void onAbandon() override;
diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h
index d74be14605..1f5b79fdd1 100644
--- a/include/private/GrRenderTargetProxy.h
+++ b/include/private/GrRenderTargetProxy.h
@@ -66,8 +66,8 @@ protected:
friend class GrRenderTargetProxyPriv;
// Deferred version
- GrRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, GrSurfaceOrigin, SkBackingFit,
- SkBudgeted, GrInternalSurfaceFlags);
+ GrRenderTargetProxy(const GrCaps&, const GrBackendFormat&, const GrSurfaceDesc&,
+ GrSurfaceOrigin, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
// Lazy-callback version
// There are two main use cases for lazily-instantiated proxies:
@@ -80,8 +80,8 @@ protected:
// The minimal knowledge version is used for CCPR where we are generating an atlas but we do not
// know the final size until flush time.
GrRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType lazyType,
- const GrSurfaceDesc&, GrSurfaceOrigin, SkBackingFit, SkBudgeted,
- GrInternalSurfaceFlags);
+ const GrBackendFormat&, const GrSurfaceDesc&, GrSurfaceOrigin,
+ SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
// Wrapped version
GrRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index 980f983e83..887400a60c 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -9,12 +9,12 @@
#define GrSurfaceProxy_DEFINED
#include "../private/SkNoncopyable.h"
+#include "GrBackendSurface.h"
#include "GrGpuResource.h"
#include "GrSurface.h"
#include "SkRect.h"
-class GrBackendTexture;
class GrCaps;
class GrOpList;
class GrProxyProvider;
@@ -265,6 +265,10 @@ public:
return fOrigin;
}
+ const GrBackendFormat& backendFormat() const { return fFormat; }
+
+ GrTextureType textureType() const { return fFormat.textureType(); }
+
class UniqueID {
public:
static UniqueID InvalidID() {
@@ -413,9 +417,10 @@ public:
protected:
// Deferred version
- GrSurfaceProxy(const GrSurfaceDesc& desc, GrSurfaceOrigin origin, SkBackingFit fit,
+ GrSurfaceProxy(const GrBackendFormat& format, const GrSurfaceDesc& desc,
+ GrSurfaceOrigin origin, SkBackingFit fit,
SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags)
- : GrSurfaceProxy(nullptr, LazyInstantiationType::kSingleUse, desc, origin, fit,
+ : GrSurfaceProxy(nullptr, LazyInstantiationType::kSingleUse, format, desc, origin, fit,
budgeted, surfaceFlags) {
// Note: this ctor pulls a new uniqueID from the same pool at the GrGpuResources
}
@@ -424,8 +429,8 @@ protected:
// Lazy-callback version
GrSurfaceProxy(LazyInstantiateCallback&&, LazyInstantiationType,
- const GrSurfaceDesc&, GrSurfaceOrigin, SkBackingFit,
- SkBudgeted, GrInternalSurfaceFlags);
+ const GrBackendFormat& format, const GrSurfaceDesc&, GrSurfaceOrigin,
+ SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
// Wrapped version
GrSurfaceProxy(sk_sp<GrSurface>, GrSurfaceOrigin, SkBackingFit);
@@ -467,8 +472,9 @@ protected:
GrInternalSurfaceFlags fSurfaceFlags;
private:
- // For wrapped resources, 'fConfig', 'fWidth', 'fHeight', and 'fOrigin; will always be filled in
- // from the wrapped resource.
+ // For wrapped resources, 'fFormat', 'fConfig', 'fWidth', 'fHeight', and 'fOrigin; will always
+ // be filled in from the wrapped resource.
+ GrBackendFormat fFormat;
GrPixelConfig fConfig;
int fWidth;
int fHeight;
diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h
index 124c5f9010..cdfd07ac56 100644
--- a/include/private/GrTextureProxy.h
+++ b/include/private/GrTextureProxy.h
@@ -40,9 +40,10 @@ public:
// been instantiated or not.
GrMipMapped proxyMipMapped() const { return fMipMapped; }
- GrTextureType textureType() const { return fTextureType; }
/** If true then the texture does not support MIP maps and only supports clamp wrap mode. */
- bool hasRestrictedSampling() const { return GrTextureTypeHasRestrictedSampling(fTextureType); }
+ bool hasRestrictedSampling() const {
+ return GrTextureTypeHasRestrictedSampling(this->textureType());
+ }
/**
* Return the texture proxy's unique key. It will be invalid if the proxy doesn't have one.
*/
@@ -79,12 +80,12 @@ protected:
friend class GrTextureProxyPriv;
// Deferred version - when constructed with data the origin is always kTopLeft.
- GrTextureProxy(const GrSurfaceDesc& srcDesc, GrMipMapped, GrTextureType, SkBackingFit,
+ GrTextureProxy(const GrBackendFormat&, const GrSurfaceDesc& srcDesc, GrMipMapped, SkBackingFit,
SkBudgeted, const void* srcData, size_t srcRowBytes, GrInternalSurfaceFlags);
// Deferred version - no data.
- GrTextureProxy(const GrSurfaceDesc& srcDesc, GrSurfaceOrigin, GrMipMapped, GrTextureType,
- SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
+ GrTextureProxy(const GrBackendFormat&, const GrSurfaceDesc& srcDesc, GrSurfaceOrigin,
+ GrMipMapped, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
// Lazy-callback version
// There are two main use cases for lazily-instantiated proxies:
@@ -96,9 +97,9 @@ protected:
//
// The minimal knowledge version is used for CCPR where we are generating an atlas but we do not
// know the final size until flush time.
- GrTextureProxy(LazyInstantiateCallback&&, LazyInstantiationType, const GrSurfaceDesc& desc,
- GrSurfaceOrigin, GrMipMapped, GrTextureType, SkBackingFit, SkBudgeted,
- GrInternalSurfaceFlags);
+ GrTextureProxy(LazyInstantiateCallback&&, LazyInstantiationType, const GrBackendFormat&,
+ const GrSurfaceDesc& desc, GrSurfaceOrigin, GrMipMapped, SkBackingFit,
+ SkBudgeted, GrInternalSurfaceFlags);
// Wrapped version
GrTextureProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
@@ -117,7 +118,6 @@ private:
// address of other types, leading to this problem.
GrMipMapped fMipMapped;
- GrTextureType fTextureType;
GrUniqueKey fUniqueKey;
GrProxyProvider* fProxyProvider; // only set when fUniqueKey is valid