aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/gpu/GrSurface.h11
-rw-r--r--include/private/GrTextureProxy.h12
-rw-r--r--include/private/GrTypesPriv.h29
-rw-r--r--src/gpu/GrSurfacePriv.h6
-rw-r--r--src/gpu/GrTextureProxyPriv.h6
-rw-r--r--src/gpu/gl/GrGLTexture.cpp3
-rw-r--r--src/image/SkImage_Gpu.cpp18
-rw-r--r--tests/EGLImageTest.cpp3
-rw-r--r--tests/RectangleTextureTest.cpp2
9 files changed, 56 insertions, 34 deletions
diff --git a/include/gpu/GrSurface.h b/include/gpu/GrSurface.h
index 4ddc5d14cc..f3771a74e2 100644
--- a/include/gpu/GrSurface.h
+++ b/include/gpu/GrSurface.h
@@ -71,11 +71,16 @@ protected:
return fSurfaceFlags & GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
}
- void setIsClampOnly() {
+ void setIsGLTextureRectangleOrExternal() {
SkASSERT(this->asTexture());
- fSurfaceFlags |= GrInternalSurfaceFlags::kIsClampOnly;
+ fSurfaceFlags |= GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
+ // If we are a GL rectangle or external texture, it also means that we do not support
+ // generating mip maps.
+ this->setDoesNotSupportMipMaps();
+ }
+ bool isGLTextureRectangleOrExternal() const {
+ return fSurfaceFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
}
- bool isClampOnly() const { return fSurfaceFlags & GrInternalSurfaceFlags::kIsClampOnly; }
void setHasMixedSamples() {
SkASSERT(this->asRenderTarget());
diff --git a/include/private/GrTextureProxy.h b/include/private/GrTextureProxy.h
index b9373a55f8..8bbdbf2959 100644
--- a/include/private/GrTextureProxy.h
+++ b/include/private/GrTextureProxy.h
@@ -107,11 +107,15 @@ protected:
return fSurfaceFlags & GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
}
- void setIsClampOnly() {
- fSurfaceFlags |= GrInternalSurfaceFlags::kIsClampOnly;
+ void setIsGLTextureRectangleOrExternal() {
+ fSurfaceFlags |= GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
+ // If we are a GL rectangle or external texture, it also means that we do not support
+ // generating mip maps.
+ this->setDoesNotSupportMipMaps();
+ }
+ bool isGLTextureRectangleOrExternal() const {
+ return fSurfaceFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
}
- bool isClampOnly() const { return fSurfaceFlags & GrInternalSurfaceFlags::kIsClampOnly; }
-
private:
GrMipMapped fMipMapped;
diff --git a/include/private/GrTypesPriv.h b/include/private/GrTypesPriv.h
index e0f31fa5f9..84461836f0 100644
--- a/include/private/GrTypesPriv.h
+++ b/include/private/GrTypesPriv.h
@@ -859,12 +859,12 @@ enum GrAccessPattern {
// Flags shared between the GrSurface & GrSurfaceProxy class hierarchies
enum class GrInternalSurfaceFlags {
- kNone = 0,
+ kNone = 0,
// Surface-level
- kNoPendingIO = 1 << 0,
+ kNoPendingIO = 1 << 0,
- kSurfaceMask = kNoPendingIO,
+ kSurfaceMask = kNoPendingIO,
// Texture-only flags
@@ -872,15 +872,16 @@ enum class GrInternalSurfaceFlags {
// external and rectangle textures). Note that Ganesh does not internally
// create resources with this limitation - this flag will only appear on resources passed
// into Ganesh.
- kDoesNotSupportMipMaps = 1 << 1,
+ kDoesNotSupportMipMaps = 1 << 1,
- // This flag is set when the internal texture target only supports the clamp wrap mode (e.g.,
- // external and rectangle textures). Note that Ganesh does not internally
- // create resources with this limitation - this flag will only appear on resources passed
- // into Ganesh.
- kIsClampOnly = 1 << 2,
+ // This flag is for GL only. It says that the GL texture we will use has a target which is
+ // either GL_TEXTURE_RECTANGLE or GL_GL_TEXTURE_EXTERNAL. We use this information to make
+ // decisions about various rendering capabilites (e.g. is clamp the only supported wrap mode).
+ // Note: Ganesh does not internally create these types of textures so they will only occur on
+ // resources passed into Ganesh.
+ kIsGLTextureRectangleOrExternal = 1 << 2,
- kTextureMask = kDoesNotSupportMipMaps | kIsClampOnly,
+ kTextureMask = kDoesNotSupportMipMaps | kIsGLTextureRectangleOrExternal,
// RT-only
@@ -890,19 +891,19 @@ enum class GrInternalSurfaceFlags {
// this is disabled for FBO0
// but, otherwise, is enabled whenever MSAA is enabled and GrCaps reports mixed samples
// are supported
- kMixedSampled = 1 << 3,
+ 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 << 4,
+ kWindowRectsSupport = 1 << 4,
// This flag is for use with GL only. It tells us that the internal render target wraps FBO 0.
- kGLRTFBOIDIs0 = 1 << 5,
+ kGLRTFBOIDIs0 = 1 << 5,
- kRenderTargetMask = kMixedSampled | kWindowRectsSupport | kGLRTFBOIDIs0,
+ kRenderTargetMask = kMixedSampled | kWindowRectsSupport | kGLRTFBOIDIs0,
};
GR_MAKE_BITFIELD_CLASS_OPS(GrInternalSurfaceFlags)
diff --git a/src/gpu/GrSurfacePriv.h b/src/gpu/GrSurfacePriv.h
index 98d8fc52d8..5c98e3f773 100644
--- a/src/gpu/GrSurfacePriv.h
+++ b/src/gpu/GrSurfacePriv.h
@@ -41,7 +41,11 @@ public:
GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
bool doesNotSupportMipMaps() const { return fSurface->doesNotSupportMipMaps(); }
- bool isClampOnly() const { return fSurface->isClampOnly(); }
+ bool isGLTextureRectangleOrExternal() const {
+ return fSurface->isGLTextureRectangleOrExternal();
+ }
+ // We only support the clamp wrap mode with gl rectangle or external textures.
+ bool isClampOnly() const { return fSurface->isGLTextureRectangleOrExternal(); }
private:
explicit GrSurfacePriv(GrSurface* surface) : fSurface(surface) {}
diff --git a/src/gpu/GrTextureProxyPriv.h b/src/gpu/GrTextureProxyPriv.h
index b2b002864e..8f50b90dad 100644
--- a/src/gpu/GrTextureProxyPriv.h
+++ b/src/gpu/GrTextureProxyPriv.h
@@ -32,7 +32,11 @@ public:
GrMipMapped proxyMipMapped() const { return fTextureProxy->fMipMapped; }
bool doesNotSupportMipMaps() const { return fTextureProxy->doesNotSupportMipMaps(); }
- bool isClampOnly() const { return fTextureProxy->isClampOnly(); }
+ bool isGLTextureRectangleOrExternal() const {
+ return fTextureProxy->isGLTextureRectangleOrExternal();
+ }
+ // We only support the clamp wrap mode with gl rectangle or external textures.
+ bool isClampOnly() const { return fTextureProxy->isGLTextureRectangleOrExternal(); }
void setDoesNotSupportMipMaps() {
fTextureProxy->setDoesNotSupportMipMaps();
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index 9a8dbd8f4b..bf22bdb751 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -71,8 +71,7 @@ void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
SkASSERT(0 != idDesc.fInfo.fFormat);
if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE ||
idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) {
- this->setDoesNotSupportMipMaps();
- this->setIsClampOnly();
+ this->setIsGLTextureRectangleOrExternal();
}
fTexParams.invalidate();
fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index bd75c276a2..4786407104 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -661,7 +661,7 @@ static GrInternalSurfaceFlags get_flags_from_format(const GrBackendFormat& backe
if (const GrGLenum* target = backendFormat.getGLTarget()) {
if (GR_GL_TEXTURE_RECTANGLE == *target || GR_GL_TEXTURE_EXTERNAL == *target) {
return GrInternalSurfaceFlags::kDoesNotSupportMipMaps |
- GrInternalSurfaceFlags::kIsClampOnly;
+ GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
}
}
@@ -714,6 +714,14 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
GrInternalSurfaceFlags formatFlags = get_flags_from_format(backendFormat);
+ // Promise images always wrap resources. So if the promise image doesn't have mip maps, we
+ // cannot allocate mips for them and thus will need a copy to use a mipped image. We can't pass
+ // the fact that this creates a wrapped texture into createLazyProxy so we need to manually set
+ // in in the passed in flags.
+ if (GrMipMapped::kNo == mipMapped) {
+ formatFlags |= GrInternalSurfaceFlags::kDoesNotSupportMipMaps;
+ }
+
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
[promiseHelper, config] (GrResourceProvider* resourceProvider) mutable {
if (!resourceProvider) {
@@ -729,14 +737,6 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
return nullptr;
}
- // Promise images always wrap resources. So if the promise image doesn't have mip maps, we
- // cannot allocate mips for them and thus will need a copy to use a mipped image. We can't pass
- // the fact that this creates a wrapped texture into createLazyProxy so we need to manually call
- // setDoesNotSupportMipMaps.
- if (GrMipMapped::kNo == mipMapped) {
- proxy->texPriv().setDoesNotSupportMipMaps();
- }
-
return sk_make_sp<SkImage_Gpu>(context, kNeedNewImageUniqueID, alphaType, std::move(proxy),
std::move(colorSpace), SkBudgeted::kNo);
}
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index d7f3861888..0b54e814c7 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -170,6 +170,9 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(EGLImageTest, reporter, ctxInfo) {
REPORTER_ASSERT(reporter, proxy->texPriv().doesNotSupportMipMaps());
REPORTER_ASSERT(reporter, proxy->priv().peekTexture()->surfacePriv().doesNotSupportMipMaps());
+ REPORTER_ASSERT(reporter, proxy->texPriv().isGLTextureRectangleOrExternal());
+ REPORTER_ASSERT(reporter,
+ proxy->priv().peekTexture()->surfacePriv().isGLTextureRectangleOrExternal());
REPORTER_ASSERT(reporter, proxy->texPriv().isClampOnly());
REPORTER_ASSERT(reporter, proxy->priv().peekTexture()->surfacePriv().isClampOnly());
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 6087aab6f2..04ced776ae 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -140,6 +140,8 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
SkASSERT(rectProxy->texPriv().doesNotSupportMipMaps());
SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().doesNotSupportMipMaps());
+ SkASSERT(rectProxy->texPriv().isGLTextureRectangleOrExternal());
+ SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().isGLTextureRectangleOrExternal());
SkASSERT(rectProxy->texPriv().isClampOnly());
SkASSERT(rectProxy->priv().peekTexture()->surfacePriv().isClampOnly());