Add internal grsurface flag to track if using gl rectangle or external texture.

Bug: skia:
Change-Id: I84963833bbc3ae957c919a19f6e78fce2c9de7ef
Reviewed-on: https://skia-review.googlesource.com/125294
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2018-05-02 15:06:47 -04:00 committed by Skia Commit-Bot
parent 90864a21c4
commit b73a9f8b96
9 changed files with 56 additions and 34 deletions

View File

@ -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());

View File

@ -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;

View File

@ -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)

View File

@ -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) {}

View File

@ -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();

View File

@ -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;

View File

@ -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);
}

View File

@ -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());

View File

@ -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());