aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Brian Salomon <bsalomon@google.com>2018-07-30 13:13:17 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-30 19:32:13 +0000
commit7226c232d73356a37ec8cfef0ed55147e68dd2fd (patch)
tree47559e4a5994b5cffc5382e9bb230f49b6c04cd7 /src
parent3ebd354730ea9590bf233deccfc24982ffe48a98 (diff)
Make GrTextureProxy store a GrTextureType.
Removes flag indicating rectangle or external as its now redundant. Bug: skia: Change-Id: Ia475b557390e7a6b0f19f6e189cf8c27090e397c Reviewed-on: https://skia-review.googlesource.com/144346 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkDeferredDisplayListRecorder.cpp9
-rw-r--r--src/gpu/GrBackendTextureImageGenerator.cpp11
-rw-r--r--src/gpu/GrGpu.cpp2
-rw-r--r--src/gpu/GrProxyProvider.cpp65
-rw-r--r--src/gpu/GrProxyProvider.h29
-rw-r--r--src/gpu/GrSurfacePriv.h6
-rw-r--r--src/gpu/GrTexturePriv.h3
-rw-r--r--src/gpu/GrTextureProxy.cpp26
-rw-r--r--src/gpu/GrTextureProxyPriv.h10
-rw-r--r--src/gpu/GrTextureRenderTargetProxy.cpp11
-rw-r--r--src/gpu/GrTextureRenderTargetProxy.h4
-rw-r--r--src/gpu/gl/GrGLCaps.cpp4
-rw-r--r--src/gpu/gl/GrGLTexture.cpp12
-rw-r--r--src/gpu/gl/GrGLTexture.h3
-rw-r--r--src/image/SkImage_Gpu.cpp36
15 files changed, 123 insertions, 108 deletions
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index d13fd3915e..b6989846e3 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -113,6 +113,12 @@ bool SkDeferredDisplayListRecorder::init() {
if (usesGLFBO0) {
surfaceFlags |= GrInternalSurfaceFlags::kGLRTFBOIDIs0;
}
+ static constexpr GrProxyProvider::TextureInfo kTextureInfo{GrMipMapped::kNo,
+ GrTextureType::k2D};
+ const GrProxyProvider::TextureInfo* optionalTextureInfo = nullptr;
+ if (fCharacterization.isTextureable()) {
+ optionalTextureInfo = &kTextureInfo;
+ }
sk_sp<GrRenderTargetProxy> proxy = proxyProvider->createLazyRenderTargetProxy(
[lazyProxyData](GrResourceProvider* resourceProvider) {
@@ -128,8 +134,7 @@ bool SkDeferredDisplayListRecorder::init() {
desc,
fCharacterization.origin(),
surfaceFlags,
- GrProxyProvider::Textureable(fCharacterization.isTextureable()),
- GrMipMapped::kNo,
+ optionalTextureInfo,
SkBackingFit::kExact,
SkBudgeted::kYes);
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 466a842f23..74722c66f4 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -6,7 +6,6 @@
*/
#include "GrBackendTextureImageGenerator.h"
-
#include "GrContext.h"
#include "GrContextPriv.h"
#include "GrGpu.h"
@@ -19,9 +18,9 @@
#include "GrTexture.h"
#include "GrTexturePriv.h"
#include "GrTextureProxyPriv.h"
-
#include "SkGr.h"
#include "SkMessageBus.h"
+#include "gl/GrGLTexture.h"
GrBackendTextureImageGenerator::RefHelper::~RefHelper() {
SkASSERT(nullptr == fBorrowedTexture);
@@ -134,6 +133,11 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
GrBackendTexture backendTexture = fBackendTexture;
RefHelper* refHelper = fRefHelper;
+ GrTextureType textureType = GrTextureType::k2D;
+ GrGLTextureInfo glInfo;
+ if (backendTexture.getGLTextureInfo(&glInfo)) {
+ textureType = GrGLTexture::TextureTypeFromTarget(glInfo.fTarget);
+ }
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
[refHelper, releaseProcHelper, semaphore,
backendTexture](GrResourceProvider* resourceProvider) {
@@ -171,9 +175,8 @@ sk_sp<GrTextureProxy> GrBackendTextureImageGenerator::onGenerateTexture(
}
return tex;
-
},
- desc, fSurfaceOrigin, mipMapped, SkBackingFit::kExact, SkBudgeted::kNo);
+ desc, fSurfaceOrigin, mipMapped, textureType, SkBackingFit::kExact, SkBudgeted::kNo);
if (!proxy) {
return nullptr;
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 4b7e786f87..62eef097a0 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -74,7 +74,7 @@ bool GrGpu::IsACopyNeededForRepeatWrapMode(const GrCaps* caps, GrTextureProxy* t
if (texProxy) {
// If the texture format itself doesn't support repeat wrap mode or mipmapping (and
// those capabilities are required) force a copy.
- if (texProxy->texPriv().isClampOnly()) {
+ if (texProxy->texPriv().hasRestrictedSampling()) {
copyParams->fFilter = GrSamplerState::Filter::kNearest;
copyParams->fWidth = texProxy->width();
copyParams->fHeight = texProxy->height();
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index df7b61e700..67643d7931 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -275,7 +275,8 @@ sk_sp<GrTextureProxy> GrProxyProvider::createTextureProxy(sk_sp<SkImage> srcImag
return resourceProvider->createTexture(desc, budgeted, fit, mipLevel);
},
- desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, surfaceFlags, fit, budgeted);
+ desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, GrTextureType::k2D, surfaceFlags, fit,
+ budgeted);
if (!proxy) {
return nullptr;
@@ -373,8 +374,8 @@ sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitma
return resourceProvider->createTexture(desc, SkBudgeted::kYes, texels.get(),
mipLevelCount);
},
- desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kYes, SkBackingFit::kExact,
- SkBudgeted::kYes);
+ desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kYes, GrTextureType::k2D,
+ SkBackingFit::kExact, SkBudgeted::kYes);
if (!proxy) {
return nullptr;
@@ -416,12 +417,13 @@ sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrSurfaceDesc& desc,
if (copyDesc.fFlags & kRenderTarget_GrSurfaceFlag) {
// We know anything we instantiate later from this deferred path will be
// both texturable and renderable
- return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(
- *this->caps(), copyDesc, origin, mipMapped, fit, budgeted, surfaceFlags));
+ return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*this->caps(), copyDesc, origin,
+ mipMapped, GrTextureType::k2D,
+ fit, budgeted, surfaceFlags));
}
- return sk_sp<GrTextureProxy>(
- new GrTextureProxy(copyDesc, origin, mipMapped, fit, budgeted, surfaceFlags));
+ return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, origin, mipMapped, GrTextureType::k2D,
+ fit, budgeted, surfaceFlags));
}
sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture& backendTex,
@@ -537,9 +539,11 @@ sk_sp<GrSurfaceProxy> GrProxyProvider::wrapBackendTextureAsRenderTarget(
sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
- GrMipMapped mipMapped, SkBackingFit fit,
+ GrMipMapped mipMapped,
+ GrTextureType textureType,
+ SkBackingFit fit,
SkBudgeted budgeted) {
- return this->createLazyProxy(std::move(callback), desc, origin, mipMapped,
+ return this->createLazyProxy(std::move(callback), desc, origin, mipMapped, textureType,
GrInternalSurfaceFlags::kNone, fit, budgeted);
}
@@ -547,21 +551,25 @@ sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&&
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
+ GrTextureType textureType,
GrInternalSurfaceFlags surfaceFlags,
- SkBackingFit fit, SkBudgeted budgeted) {
+ SkBackingFit fit,
+ SkBudgeted budgeted) {
// For non-ddl draws always make lazy proxy's single use.
LazyInstantiationType lazyType = fResourceProvider ? LazyInstantiationType::kSingleUse
: LazyInstantiationType::kMultipleUse;
- return this->createLazyProxy(std::move(callback), desc, origin, mipMapped, surfaceFlags,
- fit, budgeted, lazyType);
+ return this->createLazyProxy(std::move(callback), desc, origin, mipMapped, textureType,
+ surfaceFlags, fit, budgeted, lazyType);
}
sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
+ GrTextureType textureType,
GrInternalSurfaceFlags surfaceFlags,
- SkBackingFit fit, SkBudgeted budgeted,
+ SkBackingFit fit,
+ SkBudgeted budgeted,
LazyInstantiationType lazyType) {
SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
(desc.fWidth > 0 && desc.fHeight > 0));
@@ -585,15 +593,16 @@ sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&&
return sk_sp<GrTextureProxy>(
SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags)
? new GrTextureRenderTargetProxy(std::move(callback), lazyType, desc, origin,
- mipMapped, fit, budgeted, surfaceFlags)
+ mipMapped, textureType, fit, budgeted,
+ surfaceFlags)
: new GrTextureProxy(std::move(callback), lazyType, desc, origin, mipMapped,
- fit, budgeted, surfaceFlags));
+ textureType, fit, budgeted, surfaceFlags));
}
sk_sp<GrRenderTargetProxy> GrProxyProvider::createLazyRenderTargetProxy(
LazyInstantiateCallback&& callback, const GrSurfaceDesc& desc, GrSurfaceOrigin origin,
- GrInternalSurfaceFlags surfaceFlags, Textureable textureable, GrMipMapped mipMapped,
- SkBackingFit fit, SkBudgeted budgeted) {
+ GrInternalSurfaceFlags surfaceFlags, const TextureInfo* textureInfo, SkBackingFit fit,
+ SkBudgeted budgeted) {
SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
(desc.fWidth > 0 && desc.fHeight > 0));
@@ -617,10 +626,10 @@ sk_sp<GrRenderTargetProxy> GrProxyProvider::createLazyRenderTargetProxy(
LazyInstantiationType lazyType = fResourceProvider ? LazyInstantiationType::kSingleUse
: LazyInstantiationType::kMultipleUse;
- if (Textureable::kYes == textureable) {
- return sk_sp<GrRenderTargetProxy>(
- new GrTextureRenderTargetProxy(std::move(callback), lazyType, desc, origin,
- mipMapped, fit, budgeted, surfaceFlags));
+ if (textureInfo) {
+ return sk_sp<GrRenderTargetProxy>(new GrTextureRenderTargetProxy(
+ std::move(callback), lazyType, desc, origin, textureInfo->fMipMapped,
+ textureInfo->fTextureType, fit, budgeted, surfaceFlags));
}
return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(
@@ -645,16 +654,16 @@ sk_sp<GrTextureProxy> GrProxyProvider::MakeFullyLazyProxy(LazyInstantiateCallbac
desc.fConfig = config;
desc.fSampleCnt = 1;
+ static constexpr auto kTextureType = GrTextureType::k2D;
return sk_sp<GrTextureProxy>(
(Renderable::kYes == renderable)
- ? new GrTextureRenderTargetProxy(std::move(callback),
- LazyInstantiationType::kSingleUse, desc,
- origin, GrMipMapped::kNo,
- SkBackingFit::kApprox, SkBudgeted::kYes,
- surfaceFlags)
+ ? new GrTextureRenderTargetProxy(
+ std::move(callback), LazyInstantiationType::kSingleUse, desc, origin,
+ GrMipMapped::kNo, kTextureType, SkBackingFit::kApprox,
+ SkBudgeted::kYes, surfaceFlags)
: new GrTextureProxy(std::move(callback), LazyInstantiationType::kSingleUse,
- desc, origin, GrMipMapped::kNo, SkBackingFit::kApprox,
- SkBudgeted::kYes, surfaceFlags));
+ desc, origin, GrMipMapped::kNo, kTextureType,
+ SkBackingFit::kApprox, SkBudgeted::kYes, surfaceFlags));
}
bool GrProxyProvider::IsFunctionallyExact(GrSurfaceProxy* proxy) {
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index 89f9518e46..87d6f27de2 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -148,16 +148,17 @@ public:
int sampleCnt);
using LazyInstantiateCallback = std::function<sk_sp<GrSurface>(GrResourceProvider*)>;
- enum class Textureable : bool {
- kNo = false,
- kYes = true
- };
enum class Renderable : bool {
kNo = false,
kYes = true
};
+ struct TextureInfo {
+ GrMipMapped fMipMapped;
+ GrTextureType fTextureType;
+ };
+
using LazyInstantiationType = GrSurfaceProxy::LazyInstantiationType;
/**
* Creates a texture proxy that will be instantiated by a user-supplied callback during flush.
@@ -170,20 +171,26 @@ public:
* callback should cleanup any resources it captured and return an empty sk_sp<GrTextureProxy>.
*/
sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrSurfaceDesc&,
- GrSurfaceOrigin, GrMipMapped, GrInternalSurfaceFlags,
- SkBackingFit, SkBudgeted, LazyInstantiationType);
+ GrSurfaceOrigin, GrMipMapped, GrTextureType,
+ GrInternalSurfaceFlags, SkBackingFit, SkBudgeted,
+ LazyInstantiationType);
sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrSurfaceDesc&,
- GrSurfaceOrigin, GrMipMapped, GrInternalSurfaceFlags,
- SkBackingFit, SkBudgeted);
+ GrSurfaceOrigin, GrMipMapped, GrTextureType,
+ GrInternalSurfaceFlags, SkBackingFit, SkBudgeted);
sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrSurfaceDesc&,
- GrSurfaceOrigin, GrMipMapped, SkBackingFit, SkBudgeted);
+ GrSurfaceOrigin, GrMipMapped, GrTextureType, SkBackingFit,
+ SkBudgeted);
+
+ /** A null TextureInfo indicates a non-textureable render target. */
sk_sp<GrRenderTargetProxy> createLazyRenderTargetProxy(LazyInstantiateCallback&&,
const GrSurfaceDesc&,
GrSurfaceOrigin origin,
- GrInternalSurfaceFlags, Textureable,
- GrMipMapped, SkBackingFit, SkBudgeted);
+ GrInternalSurfaceFlags,
+ const TextureInfo*,
+ SkBackingFit,
+ SkBudgeted);
/**
* Fully lazy proxies have unspecified width and height. Methods that rely on those values
diff --git a/src/gpu/GrSurfacePriv.h b/src/gpu/GrSurfacePriv.h
index 45a097b780..4d61dca5ee 100644
--- a/src/gpu/GrSurfacePriv.h
+++ b/src/gpu/GrSurfacePriv.h
@@ -40,12 +40,6 @@ public:
GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
- 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) {}
GrSurfacePriv(const GrSurfacePriv&); // unimpl
diff --git a/src/gpu/GrTexturePriv.h b/src/gpu/GrTexturePriv.h
index 316afbc4c4..47556e476a 100644
--- a/src/gpu/GrTexturePriv.h
+++ b/src/gpu/GrTexturePriv.h
@@ -41,6 +41,9 @@ public:
}
GrTextureType textureType() const { return fTexture->fTextureType; }
+ bool hasRestrictedSampling() const {
+ return GrTextureTypeHasRestrictedSampling(this->textureType());
+ }
/** The filter used is clamped to this value in GrProcessor::TextureSampler. */
GrSamplerState::Filter highestFilterMode() const { return fTexture->fHighestFilterMode; }
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index b25efd95f5..fc6a2fae16 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -17,10 +17,12 @@
// Deferred version - with data
GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, GrMipMapped mipMapped,
- SkBackingFit fit, SkBudgeted budgeted, const void* srcData,
- size_t /*rowBytes*/, GrInternalSurfaceFlags surfaceFlags)
+ GrTextureType textureType, SkBackingFit fit, SkBudgeted budgeted,
+ const void* srcData, size_t /*rowBytes*/,
+ GrInternalSurfaceFlags surfaceFlags)
: INHERITED(srcDesc, kTopLeft_GrSurfaceOrigin, fit, budgeted, surfaceFlags)
, fMipMapped(mipMapped)
+ , fTextureType(textureType)
, fProxyProvider(nullptr)
, fDeferredUploader(nullptr) {
SkASSERT(!srcData); // currently handled in Make()
@@ -28,28 +30,30 @@ GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, GrMipMapped mipMapp
// Deferred version - no data
GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, GrSurfaceOrigin origin,
- GrMipMapped mipMapped, SkBackingFit fit, SkBudgeted budgeted,
- GrInternalSurfaceFlags surfaceFlags)
+ GrMipMapped mipMapped, GrTextureType textureType, SkBackingFit fit,
+ SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags)
: INHERITED(srcDesc, origin, fit, budgeted, surfaceFlags)
, fMipMapped(mipMapped)
+ , fTextureType(textureType)
, fProxyProvider(nullptr)
, fDeferredUploader(nullptr) {}
// Lazy-callback version
GrTextureProxy::GrTextureProxy(LazyInstantiateCallback&& callback, LazyInstantiationType lazyType,
const GrSurfaceDesc& desc, GrSurfaceOrigin origin,
- GrMipMapped mipMapped, SkBackingFit fit, SkBudgeted budgeted,
- GrInternalSurfaceFlags surfaceFlags)
+ GrMipMapped mipMapped, GrTextureType textureType, SkBackingFit fit,
+ SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags)
: INHERITED(std::move(callback), lazyType, desc, origin, fit, budgeted, surfaceFlags)
, fMipMapped(mipMapped)
+ , fTextureType(textureType)
, fProxyProvider(nullptr)
- , fDeferredUploader(nullptr) {
-}
+ , fDeferredUploader(nullptr) {}
// Wrapped version
GrTextureProxy::GrTextureProxy(sk_sp<GrSurface> surf, GrSurfaceOrigin origin)
: INHERITED(std::move(surf), origin, SkBackingFit::kExact)
, fMipMapped(fTarget->asTexture()->texturePriv().mipMapped())
+ , fTextureType(fTarget->asTexture()->texturePriv().textureType())
, fProxyProvider(nullptr)
, fDeferredUploader(nullptr) {
if (fTarget->getUniqueKey().isValid()) {
@@ -167,11 +171,7 @@ void GrTextureProxy::onValidateSurface(const GrSurface* surface) {
SkASSERT(surface->asTexture());
SkASSERT(GrMipMapped::kNo == this->texPriv().proxyMipMapped() ||
GrMipMapped::kYes == surface->asTexture()->texturePriv().mipMapped());
-
- GrInternalSurfaceFlags proxyFlags = fSurfaceFlags;
- GrInternalSurfaceFlags surfaceFlags = surface->surfacePriv().flags();
- SkASSERT((proxyFlags & GrInternalSurfaceFlags::kTextureMask) ==
- (surfaceFlags & GrInternalSurfaceFlags::kTextureMask));
+ SkASSERT(surface->asTexture()->texturePriv().textureType() == fTextureType);
}
#endif
diff --git a/src/gpu/GrTextureProxyPriv.h b/src/gpu/GrTextureProxyPriv.h
index 358369d516..519e96b497 100644
--- a/src/gpu/GrTextureProxyPriv.h
+++ b/src/gpu/GrTextureProxyPriv.h
@@ -31,14 +31,10 @@ public:
// been instantiated or not.
GrMipMapped proxyMipMapped() const { return fTextureProxy->fMipMapped; }
- bool isGLTextureRectangleOrExternal() const {
- return fTextureProxy->isGLTextureRectangleOrExternal();
+ GrTextureType textureType() const { return fTextureProxy->fTextureType; }
+ bool hasRestrictedSampling() const {
+ return GrTextureTypeHasRestrictedSampling(this->textureType());
}
- // We assume that if a texture is not a GL_TEXTURE_RECTANGLE or GL_TEXTURE_EXTERNAL then it is a
- // GL_TEXTURE_2D
- bool isGLTexture2D() const { return !fTextureProxy->isGLTextureRectangleOrExternal(); }
- // We only support the clamp wrap mode with gl rectangle or external textures.
- bool isClampOnly() const { return fTextureProxy->isGLTextureRectangleOrExternal(); }
private:
explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp
index 95d5543bbf..5b87399daa 100644
--- a/src/gpu/GrTextureRenderTargetProxy.cpp
+++ b/src/gpu/GrTextureRenderTargetProxy.cpp
@@ -22,12 +22,13 @@ GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
+ GrTextureType textureType,
SkBackingFit fit,
SkBudgeted budgeted,
GrInternalSurfaceFlags surfaceFlags)
: GrSurfaceProxy(desc, origin, fit, budgeted, surfaceFlags)
// for now textures w/ data are always wrapped
- , GrTextureProxy(desc, origin, mipMapped, fit, budgeted, surfaceFlags)
+ , GrTextureProxy(desc, origin, mipMapped, textureType, fit, budgeted, surfaceFlags)
, GrRenderTargetProxy(caps, desc, origin, fit, budgeted, surfaceFlags) {}
// Lazy-callback version
@@ -36,14 +37,15 @@ GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(LazyInstantiateCallback&&
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
+ GrTextureType textureType,
SkBackingFit fit,
SkBudgeted budgeted,
GrInternalSurfaceFlags surfaceFlags)
: GrSurfaceProxy(std::move(callback), lazyType, desc, origin, fit, budgeted, surfaceFlags)
// Since we have virtual inheritance, we initialize GrSurfaceProxy directly. Send null
// callbacks to the texture and RT proxies simply to route to the appropriate constructors.
- , GrTextureProxy(LazyInstantiateCallback(), lazyType, desc, origin, mipMapped, fit,
- budgeted, surfaceFlags)
+ , GrTextureProxy(LazyInstantiateCallback(), lazyType, desc, origin, mipMapped, textureType,
+ fit, budgeted, surfaceFlags)
, GrRenderTargetProxy(LazyInstantiateCallback(), lazyType, desc, origin, fit, budgeted,
surfaceFlags) {}
@@ -123,10 +125,9 @@ void GrTextureRenderTargetProxy::onValidateSurface(const GrSurface* surface) {
GrInternalSurfaceFlags proxyFlags = fSurfaceFlags;
GrInternalSurfaceFlags surfaceFlags = surface->surfacePriv().flags();
- SkASSERT((proxyFlags & GrInternalSurfaceFlags::kTextureMask) ==
- (surfaceFlags & GrInternalSurfaceFlags::kTextureMask));
SkASSERT((proxyFlags & GrInternalSurfaceFlags::kRenderTargetMask) ==
(surfaceFlags & GrInternalSurfaceFlags::kRenderTargetMask));
+ SkASSERT(surface->asTexture()->texturePriv().textureType() == this->texPriv().textureType());
}
#endif
diff --git a/src/gpu/GrTextureRenderTargetProxy.h b/src/gpu/GrTextureRenderTargetProxy.h
index 141597ec76..f2f3edb41a 100644
--- a/src/gpu/GrTextureRenderTargetProxy.h
+++ b/src/gpu/GrTextureRenderTargetProxy.h
@@ -29,12 +29,12 @@ private:
// Deferred version
GrTextureRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, GrSurfaceOrigin, GrMipMapped,
- SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
+ GrTextureType, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
// Lazy-callback version
GrTextureRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType,
const GrSurfaceDesc& desc, GrSurfaceOrigin, GrMipMapped,
- SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
+ GrTextureType, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
// Wrapped version
GrTextureRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 5532e36bd0..0fc88437b0 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -2185,8 +2185,8 @@ bool GrGLCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* s
const GrTextureProxy* dstTex = dst->asTextureProxy();
const GrTextureProxy* srcTex = src->asTextureProxy();
- bool dstIsTex2D = dstTex ? dstTex->texPriv().isGLTexture2D() : false;
- bool srcIsTex2D = srcTex ? srcTex->texPriv().isGLTexture2D() : false;
+ bool dstIsTex2D = dstTex ? (dstTex->texPriv().textureType() == GrTextureType::k2D) : false;
+ bool srcIsTex2D = srcTex ? (srcTex->texPriv().textureType() == GrTextureType::k2D) : false;
// One of the possible requirements for copy as blit is that the srcRect must match the bounds
// of the src surface. If we have a approx fit surface we can't know for sure what the src
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index f0fafabcba..200c8d22e8 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -15,7 +15,7 @@
#define GPUGL static_cast<GrGLGpu*>(this->getGpu())
#define GL_CALL(X) GR_GL_CALL(GPUGL->glInterface(), X)
-static inline GrTextureType texture_type_from_target(GrGLenum target) {
+GrTextureType GrGLTexture::TextureTypeFromTarget(GrGLenum target) {
switch (target) {
case GR_GL_TEXTURE_2D:
return GrTextureType::k2D;
@@ -55,7 +55,7 @@ static inline GrSamplerState::Filter highest_filter_mode(const GrGLTexture::IDDe
GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc& desc,
const IDDesc& idDesc, GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, texture_type_from_target(idDesc.fInfo.fTarget),
+ , INHERITED(gpu, desc, TextureTypeFromTarget(idDesc.fInfo.fTarget),
highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) {
this->init(desc, idDesc);
this->registerWithCache(budgeted);
@@ -64,7 +64,7 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, SkBudgeted budgeted, const GrSurfaceDesc&
GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc,
GrMipMapsStatus mipMapsStatus, const IDDesc& idDesc)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, texture_type_from_target(idDesc.fInfo.fTarget),
+ , INHERITED(gpu, desc, TextureTypeFromTarget(idDesc.fInfo.fTarget),
highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) {
this->init(desc, idDesc);
this->registerWithCacheWrapped();
@@ -73,7 +73,7 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc,
GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, desc)
- , INHERITED(gpu, desc, texture_type_from_target(idDesc.fInfo.fTarget),
+ , INHERITED(gpu, desc, TextureTypeFromTarget(idDesc.fInfo.fTarget),
highest_filter_mode(idDesc, desc.fConfig), mipMapsStatus) {
this->init(desc, idDesc);
}
@@ -81,10 +81,6 @@ GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc&
void GrGLTexture::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
SkASSERT(0 != idDesc.fInfo.fID);
SkASSERT(0 != idDesc.fInfo.fFormat);
- if (idDesc.fInfo.fTarget == GR_GL_TEXTURE_RECTANGLE ||
- idDesc.fInfo.fTarget == GR_GL_TEXTURE_EXTERNAL) {
- this->setIsGLTextureRectangleOrExternal();
- }
fTexParams.invalidate();
fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
fID = idDesc.fInfo.fID;
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 298f1faf11..cb029cca81 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -31,6 +31,9 @@ public:
GrGLTextureInfo fInfo;
GrBackendObjectOwnership fOwnership;
};
+
+ static GrTextureType TextureTypeFromTarget(GrGLenum textureTarget);
+
GrGLTexture(GrGLGpu*, SkBudgeted, const GrSurfaceDesc&, const IDDesc&, GrMipMapsStatus);
~GrGLTexture() override {
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 1dea80659a..58aa1bc86a 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -9,10 +9,9 @@
#include <cstring>
#include <type_traits>
-#include "SkAutoPixmapStorage.h"
+#include "GrAHardwareBufferImageGenerator.h"
#include "GrBackendSurface.h"
#include "GrBackendTextureImageGenerator.h"
-#include "GrAHardwareBufferImageGenerator.h"
#include "GrBitmapTextureMaker.h"
#include "GrCaps.h"
#include "GrColorSpaceXform.h"
@@ -25,23 +24,24 @@
#include "GrResourceProvider.h"
#include "GrSemaphore.h"
#include "GrSurfacePriv.h"
-#include "GrTextureAdjuster.h"
#include "GrTexture.h"
+#include "GrTextureAdjuster.h"
#include "GrTexturePriv.h"
#include "GrTextureProxy.h"
#include "GrTextureProxyPriv.h"
-#include "gl/GrGLDefines.h"
-#include "effects/GrYUVtoRGBEffect.h"
-#include "SkCanvas.h"
+#include "SkAutoPixmapStorage.h"
#include "SkBitmapCache.h"
+#include "SkCanvas.h"
#include "SkGr.h"
-#include "SkImage_Gpu.h"
#include "SkImageCacherator.h"
#include "SkImageInfoPriv.h"
+#include "SkImage_Gpu.h"
#include "SkMipMap.h"
#include "SkPixelRef.h"
#include "SkReadPixelsRec.h"
#include "SkTraceEvent.h"
+#include "effects/GrYUVtoRGBEffect.h"
+#include "gl/GrGLTexture.h"
SkImage_Gpu::SkImage_Gpu(sk_sp<GrContext> context, uint32_t uniqueID, SkAlphaType at,
sk_sp<GrTextureProxy> proxy, sk_sp<SkColorSpace> colorSpace,
@@ -651,14 +651,11 @@ private:
sk_sp<GrReleaseProcHelper> fDoneHelper;
};
-static GrInternalSurfaceFlags get_flags_from_format(const GrBackendFormat& backendFormat) {
+static GrTextureType TextureTypeFromBackendFormat(const GrBackendFormat& backendFormat) {
if (const GrGLenum* target = backendFormat.getGLTarget()) {
- if (GR_GL_TEXTURE_RECTANGLE == *target || GR_GL_TEXTURE_EXTERNAL == *target) {
- return GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal;
- }
+ return GrGLTexture::TextureTypeFromTarget(*target);
}
-
- return GrInternalSurfaceFlags::kNone;
+ return GrTextureType::k2D;
}
sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
@@ -696,10 +693,9 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
return nullptr;
}
- GrInternalSurfaceFlags formatFlags = get_flags_from_format(backendFormat);
+ GrTextureType textureType = TextureTypeFromBackendFormat(backendFormat);
- if (mipMapped == GrMipMapped::kYes &&
- SkToBool(formatFlags & GrInternalSurfaceFlags::kIsGLTextureRectangleOrExternal)) {
+ if (mipMapped == GrMipMapped::kYes && GrTextureTypeHasRestrictedSampling(textureType)) {
// It is invalid to have a GL_TEXTURE_EXTERNAL or GL_TEXTURE_RECTANGLE and have mips as
// well.
return nullptr;
@@ -716,15 +712,17 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
textureContext);
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
- [promiseHelper, config] (GrResourceProvider* resourceProvider) mutable {
+ [promiseHelper, config](GrResourceProvider* resourceProvider) mutable {
if (!resourceProvider) {
promiseHelper.reset();
return sk_sp<GrTexture>();
}
return promiseHelper.getTexture(resourceProvider, config);
- }, desc, origin, mipMapped, formatFlags, SkBackingFit::kExact,
- SkBudgeted::kNo, GrSurfaceProxy::LazyInstantiationType::kUninstantiate);
+ },
+ desc, origin, mipMapped, textureType, GrInternalSurfaceFlags::kNone,
+ SkBackingFit::kExact, SkBudgeted::kNo,
+ GrSurfaceProxy::LazyInstantiationType::kUninstantiate);
if (!proxy) {
return nullptr;