aboutsummaryrefslogtreecommitdiffhomepage
path: root/include
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-03-16 16:47:25 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-19 12:21:05 +0000
commitfe0253f8bb64857df088d5ff54e2b5b66b102b46 (patch)
tree0d540ceaf02a992228dd713ccfee9fef413f7b3b /include
parent4410d7ff757268792dd5f842d585c514cc80a5fb (diff)
Alter GrSurface/GrSurfaceProxy flags to prepare for GrTexture/GrTextureProxy -specific flags
This CL: moves GrRenderTarget::fFlags to GrSurface::fSurfaceFlags adds a GrInternalSurfaceFlags type and uses it for GrSurfaceProxy::fSurfaceFlags The goal of this is to provide a location where GrTexture/GrTextureProxy-specific flags (i.e., isExternal & isRectangle) can be stored. Change-Id: I8df7b79036a6853dd378ff6cf10d4b37c60dd511 Reviewed-on: https://skia-review.googlesource.com/114796 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'include')
-rw-r--r--include/gpu/GrRenderTarget.h10
-rw-r--r--include/gpu/GrSurface.h27
-rw-r--r--include/gpu/GrTypes.h5
-rw-r--r--include/private/GrRenderTargetProxy.h19
-rw-r--r--include/private/GrSurfaceProxy.h71
-rw-r--r--include/private/GrTextureProxy.h10
-rw-r--r--include/private/GrTypesPriv.h19
7 files changed, 98 insertions, 63 deletions
diff --git a/include/gpu/GrRenderTarget.h b/include/gpu/GrRenderTarget.h
index 188e6d1e0f..ebfa4fd77f 100644
--- a/include/gpu/GrRenderTarget.h
+++ b/include/gpu/GrRenderTarget.h
@@ -38,11 +38,10 @@ public:
GrFSAAType fsaaType() const {
SkASSERT(fSampleCnt >= 1);
if (fSampleCnt <= 1) {
- SkASSERT(!(fFlags & GrRenderTargetFlags::kMixedSampled));
+ SkASSERT(!this->hasMixedSamples());
return GrFSAAType::kNone;
}
- return (fFlags & GrRenderTargetFlags::kMixedSampled) ? GrFSAAType::kMixedSamples
- : GrFSAAType::kUnifiedMSAA;
+ return this->hasMixedSamples() ? GrFSAAType::kMixedSamples : GrFSAAType::kUnifiedMSAA;
}
/**
@@ -116,9 +115,7 @@ public:
const GrRenderTargetPriv renderTargetPriv() const;
protected:
- GrRenderTarget(GrGpu*, const GrSurfaceDesc&,
- GrRenderTargetFlags = GrRenderTargetFlags::kNone,
- GrStencilAttachment* = nullptr);
+ GrRenderTarget(GrGpu*, const GrSurfaceDesc&, GrStencilAttachment* = nullptr);
// override of GrResource
void onAbandon() override;
@@ -135,7 +132,6 @@ private:
int fSampleCnt;
GrStencilAttachment* fStencilAttachment;
- GrRenderTargetFlags fFlags;
SkIRect fResolveRect;
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index 1056bdd224..ee17d8a45f 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -5,7 +5,6 @@
* found in the LICENSE file.
*/
-
#ifndef GrSurface_DEFINED
#define GrSurface_DEFINED
@@ -64,6 +63,20 @@ public:
GrMipMapped, bool useNextPow2 = false);
protected:
+ void setHasMixedSamples() {
+ SkASSERT(this->asRenderTarget());
+ fSurfaceFlags |= GrInternalSurfaceFlags::kMixedSampled;
+ }
+ bool hasMixedSamples() const { return fSurfaceFlags & GrInternalSurfaceFlags::kMixedSampled; }
+
+ void setSupportsWindowRects() {
+ SkASSERT(this->asRenderTarget());
+ fSurfaceFlags |= GrInternalSurfaceFlags::kWindowRectsSupport;
+ }
+ bool supportsWindowRects() const {
+ return fSurfaceFlags & GrInternalSurfaceFlags::kWindowRectsSupport;
+ }
+
// Methods made available via GrSurfacePriv
bool hasPendingRead() const;
bool hasPendingWrite() const;
@@ -76,7 +89,10 @@ protected:
: INHERITED(gpu)
, fConfig(desc.fConfig)
, fWidth(desc.fWidth)
- , fHeight(desc.fHeight) {}
+ , fHeight(desc.fHeight)
+ , fSurfaceFlags(GrInternalSurfaceFlags::kNone) {
+ }
+
~GrSurface() override {}
@@ -84,9 +100,10 @@ protected:
void onAbandon() override;
private:
- GrPixelConfig fConfig;
- int fWidth;
- int fHeight;
+ GrPixelConfig fConfig;
+ int fWidth;
+ int fHeight;
+ GrInternalSurfaceFlags fSurfaceFlags;
typedef GrGpuResource INHERITED;
};
diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h
index 97d6210259..3fec742907 100644
--- a/include/gpu/GrTypes.h
+++ b/include/gpu/GrTypes.h
@@ -376,9 +376,10 @@ enum GrSurfaceFlags {
*/
kPerformInitialClear_GrSurfaceFlag = 0x2
};
-
GR_MAKE_BITFIELD_OPS(GrSurfaceFlags)
+typedef GrSurfaceFlags GrSurfaceDescFlags;
+
// opaque type for 3D API object handles
typedef intptr_t GrBackendObject;
@@ -409,7 +410,7 @@ struct GrSurfaceDesc {
, fConfig(kUnknown_GrPixelConfig)
, fSampleCnt(1) {}
- GrSurfaceFlags fFlags; //!< bitfield of TextureFlags
+ GrSurfaceDescFlags fFlags; //!< bitfield of TextureFlags
int fWidth; //!< Width of the texture
int fHeight; //!< Height of the texture
diff --git a/include/private/GrRenderTargetProxy.h b/include/private/GrRenderTargetProxy.h
index 2468df35ad..f1e1b7d9ff 100644
--- a/include/private/GrRenderTargetProxy.h
+++ b/include/private/GrRenderTargetProxy.h
@@ -27,12 +27,10 @@ public:
GrFSAAType fsaaType() const {
if (fSampleCnt <= 1) {
- SkASSERT(!(fRenderTargetFlags & GrRenderTargetFlags::kMixedSampled));
+ SkASSERT(!this->hasMixedSamples());
return GrFSAAType::kNone;
}
- return (fRenderTargetFlags & GrRenderTargetFlags::kMixedSampled)
- ? GrFSAAType::kMixedSamples
- : GrFSAAType::kUnifiedMSAA;
+ return this->hasMixedSamples() ? GrFSAAType::kMixedSamples : GrFSAAType::kUnifiedMSAA;
}
/*
@@ -55,8 +53,6 @@ public:
int maxWindowRectangles(const GrCaps& caps) const;
- GrRenderTargetFlags testingOnly_getFlags() const;
-
// TODO: move this to a priv class!
bool refsWrappedObjects() const;
@@ -65,7 +61,7 @@ protected:
// Deferred version
GrRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, GrSurfaceOrigin, SkBackingFit,
- SkBudgeted, uint32_t flags);
+ SkBudgeted, GrInternalSurfaceFlags);
// Lazy-callback version
// There are two main use cases for lazily-instantiated proxies:
@@ -79,7 +75,7 @@ protected:
// know the final size until flush time.
GrRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType lazyType,
const GrSurfaceDesc&, GrSurfaceOrigin, SkBackingFit, SkBudgeted,
- uint32_t flags, GrRenderTargetFlags renderTargetFlags);
+ GrInternalSurfaceFlags);
// Wrapped version
GrRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
@@ -97,13 +93,6 @@ private:
// For deferred proxies that pointer is filled in when we need to instantiate the
// deferred resource.
- // These don't usually get computed until the render target is instantiated, but the render
- // target proxy may need to answer queries about it before then. And since in the deferred case
- // we know the newly created render target will be internal, we are able to precompute what the
- // flags will ultimately end up being. In the wrapped case we just copy the wrapped
- // rendertarget's info here.
- GrRenderTargetFlags fRenderTargetFlags;
-
typedef GrSurfaceProxy INHERITED;
};
diff --git a/include/private/GrSurfaceProxy.h b/include/private/GrSurfaceProxy.h
index deac90002e..0b1507969e 100644
--- a/include/private/GrSurfaceProxy.h
+++ b/include/private/GrSurfaceProxy.h
@@ -375,24 +375,26 @@ public:
inline GrSurfaceProxyPriv priv();
inline const GrSurfaceProxyPriv priv() const;
+ GrInternalSurfaceFlags testingOnly_getFlags() const;
+
protected:
// Deferred version
GrSurfaceProxy(const GrSurfaceDesc& desc, GrSurfaceOrigin origin, SkBackingFit fit,
- SkBudgeted budgeted, uint32_t flags)
+ SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags)
: GrSurfaceProxy(nullptr, LazyInstantiationType::kSingleUse, desc, origin, fit,
- budgeted, flags) {
+ budgeted, surfaceFlags) {
// Note: this ctor pulls a new uniqueID from the same pool at the GrGpuResources
}
using LazyInstantiateCallback = std::function<sk_sp<GrSurface>(GrResourceProvider*)>;
// Lazy-callback version
- GrSurfaceProxy(LazyInstantiateCallback&& callback, LazyInstantiationType lazyType,
- const GrSurfaceDesc& desc, GrSurfaceOrigin origin, SkBackingFit fit,
- SkBudgeted budgeted, uint32_t flags);
+ GrSurfaceProxy(LazyInstantiateCallback&&, LazyInstantiationType,
+ const GrSurfaceDesc&, GrSurfaceOrigin, SkBackingFit,
+ SkBudgeted, GrInternalSurfaceFlags);
// Wrapped version
- GrSurfaceProxy(sk_sp<GrSurface> surface, GrSurfaceOrigin origin, SkBackingFit fit);
+ GrSurfaceProxy(sk_sp<GrSurface>, GrSurfaceOrigin, SkBackingFit);
virtual ~GrSurfaceProxy();
@@ -413,26 +415,47 @@ protected:
void assign(sk_sp<GrSurface> surface);
sk_sp<GrSurface> createSurfaceImpl(GrResourceProvider*, int sampleCnt, bool needsStencil,
- GrSurfaceFlags flags, GrMipMapped mipMapped) const;
+ GrSurfaceDescFlags descFlags, GrMipMapped) const;
bool instantiateImpl(GrResourceProvider* resourceProvider, int sampleCnt, bool needsStencil,
- GrSurfaceFlags flags, GrMipMapped mipMapped, const GrUniqueKey*);
+ GrSurfaceDescFlags descFlags, GrMipMapped, const GrUniqueKey*);
+
+ void setHasMixedSamples() {
+ SkASSERT(this->asRenderTargetProxy());
+ fSurfaceFlags |= GrInternalSurfaceFlags::kMixedSampled;
+ }
+ bool hasMixedSamples() const { return fSurfaceFlags & GrInternalSurfaceFlags::kMixedSampled; }
+
+ void setSupportsWindowRects() {
+ SkASSERT(this->asRenderTargetProxy());
+ fSurfaceFlags |= GrInternalSurfaceFlags::kWindowRectsSupport;
+ }
+ bool supportsWindowRects() const {
+ return fSurfaceFlags & GrInternalSurfaceFlags::kWindowRectsSupport;
+ }
private:
// For wrapped resources, 'fConfig', 'fWidth', 'fHeight', and 'fOrigin; will always be filled in
// from the wrapped resource.
- GrPixelConfig fConfig;
- int fWidth;
- int fHeight;
- GrSurfaceOrigin fOrigin;
- SkBackingFit fFit; // always kApprox for lazy-callback resources
- // always kExact for wrapped resources
- mutable SkBudgeted fBudgeted; // always kYes for lazy-callback resources
- // set from the backing resource for wrapped resources
- // mutable bc of SkSurface/SkImage wishy-washiness
- const uint32_t fFlags;
-
- const UniqueID fUniqueID; // set from the backing resource for wrapped resources
+ GrPixelConfig fConfig;
+ int fWidth;
+ int fHeight;
+ GrSurfaceOrigin fOrigin;
+ SkBackingFit fFit; // always kApprox for lazy-callback resources
+ // always kExact for wrapped resources
+ mutable SkBudgeted fBudgeted; // always kYes for lazy-callback resources
+ // set from the backing resource for wrapped resources
+ // mutable bc of SkSurface/SkImage wishy-washiness
+
+ // In many cases these flags aren't actually known until the proxy has been instantiated.
+ // However, Ganesh frequently needs to change its behavior based on these settings. For
+ // internally create proxies we will know these properties ahead of time. For wrapped
+ // proxies we will copy the properties off of the GrSurface. For lazy proxies we force the
+ // call sites to provide the required information ahead of time. At instantiation time
+ // we verify that the assumed properties match the actual properties.
+ GrInternalSurfaceFlags fSurfaceFlags;
+
+ const UniqueID fUniqueID; // set from the backing resource for wrapped resources
LazyInstantiateCallback fLazyInstantiateCallback;
// If this is set to kSingleuse, then after one call to fLazyInstantiateCallback we will cleanup
@@ -440,7 +463,7 @@ private:
// by the standard function to be released. This is specifically useful in non-dll cases where
// we make lazy proxies and instantiate them immediately.
// Note: This is ignored if fLazyInstantiateCallback is null.
- LazyInstantiationType fLazyInstantiationType;
+ LazyInstantiationType fLazyInstantiationType;
SkDEBUGCODE(virtual void validateLazySurface(const GrSurface*) = 0;)
static const size_t kInvalidGpuMemorySize = ~static_cast<size_t>(0);
@@ -448,13 +471,13 @@ private:
virtual size_t onUninstantiatedGpuMemorySize() const = 0;
- bool fNeedsClear;
+ bool fNeedsClear;
// This entry is lazily evaluated so, when the proxy wraps a resource, the resource
// will be called but, when the proxy is deferred, it will compute the answer itself.
// If the proxy computes its own answer that answer is checked (in debug mode) in
// the instantiation method.
- mutable size_t fGpuMemorySize;
+ mutable size_t fGpuMemorySize;
// The last opList that wrote to or is currently going to write to this surface
// The opList can be closed (e.g., no surface context is currently bound
@@ -463,7 +486,7 @@ private:
// the opList used to create the current contents of this surface
// and the opList of a destination surface to which this one is being drawn or copied.
// This pointer is unreffed. OpLists own a ref on their surface proxies.
- GrOpList* fLastOpList;
+ GrOpList* fLastOpList;
typedef GrIORefProxy INHERITED;
};
diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h
index e8bb87cb3e..2ded566475 100644
--- a/include/private/GrTextureProxy.h
+++ b/include/private/GrTextureProxy.h
@@ -73,11 +73,11 @@ protected:
// Deferred version - when constructed with data the origin is always kTopLeft.
GrTextureProxy(const GrSurfaceDesc& srcDesc, GrMipMapped, SkBackingFit, SkBudgeted,
- const void* srcData, size_t srcRowBytes, uint32_t flags);
+ const void* srcData, size_t srcRowBytes, GrInternalSurfaceFlags);
// Deferred version - no data.
GrTextureProxy(const GrSurfaceDesc& srcDesc, GrSurfaceOrigin, GrMipMapped, SkBackingFit,
- SkBudgeted, uint32_t flags);
+ SkBudgeted, GrInternalSurfaceFlags);
// Lazy-callback version
// There are two main use cases for lazily-instantiated proxies:
@@ -90,8 +90,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.
GrTextureProxy(LazyInstantiateCallback&&, LazyInstantiationType, const GrSurfaceDesc& desc,
- GrSurfaceOrigin, GrMipMapped, SkBackingFit fit, SkBudgeted budgeted,
- uint32_t flags);
+ GrSurfaceOrigin, GrMipMapped, SkBackingFit, SkBudgeted,
+ GrInternalSurfaceFlags);
// Wrapped version
GrTextureProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
@@ -101,7 +101,7 @@ protected:
sk_sp<GrSurface> createSurface(GrResourceProvider*) const override;
private:
- GrMipMapped fMipMapped;
+ GrMipMapped fMipMapped;
GrUniqueKey fUniqueKey;
GrProxyProvider* fProxyProvider; // only set when fUniqueKey is valid
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index 5c6d1024be..d64c9a328b 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -670,26 +670,35 @@ enum GrAccessPattern {
kLast_GrAccessPattern = kStream_GrAccessPattern
};
-// Flags shared between GrRenderTarget and GrRenderTargetProxy
-enum class GrRenderTargetFlags {
+// Flags shared between the GrSurface & GrSurfaceProxy class hierarchies
+enum class GrInternalSurfaceFlags {
kNone = 0,
+ // Surface-level
+ kNoPendingIO = 1 << 0,
+
+ // Texture-only
+
+ /* coming soon */
+
+ // RT-only
+
// For internal resources:
// this is enabled whenever MSAA is enabled and GrCaps reports mixed samples are supported
// For wrapped resources:
// this is disabled for FBO0
// but, otherwise, is enabled whenever MSAA is enabled and GrCaps reports mixed samples
// are supported
- kMixedSampled = 1 << 0,
+ kMixedSampled = 1 << 3,
// For internal resources:
// this is enabled whenever GrCaps reports window rect support
// For wrapped resources1
// this is disabled for FBO0
// but, otherwise, is enabled whenever GrCaps reports window rect support
- kWindowRectsSupport = 1 << 1
+ kWindowRectsSupport = 1 << 4
};
-GR_MAKE_BITFIELD_CLASS_OPS(GrRenderTargetFlags)
+GR_MAKE_BITFIELD_CLASS_OPS(GrInternalSurfaceFlags)
#ifdef SK_DEBUG
// Takes a pointer to a GrCaps, and will suppress prints if required