Revert "Mark wrapped textures imported into SkImages as "read only"."
This reverts commit 796693af3cda0e24a76a89a092ed8de0e46ccb18.
Reason for revert: texture flags assertion in DDL config
Original change's description:
> Mark wrapped textures imported into SkImages as "read only".
>
> Read only textures and proxies fail writePixels, as copy dsts, and mip
> regeneration.
>
> Bug: skia:8509
>
> Change-Id: Iaa0b473cc9a9930fde3ef0e91373d5040650de35
> Reviewed-on: https://skia-review.googlesource.com/c/174316
> Commit-Queue: Brian Salomon <bsalomon@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: If5cb36e83795656185ff8d26e4ef2c52a2695a09
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:8509
Reviewed-on: https://skia-review.googlesource.com/c/174846
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index 8b86721..b6cc28d 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -574,8 +574,8 @@
const bool isProtectedContent = fIsProtectedContent;
sk_sp<GrTextureProxy> texProxy = proxyProvider->createLazyProxy(
- [context, hardwareBuffer, width, height, pixelConfig, isProtectedContent,
- backendFormat](GrResourceProvider* resourceProvider) {
+ [context, hardwareBuffer, width, height, pixelConfig, isProtectedContent, backendFormat]
+ (GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
AHardwareBuffer_release(hardwareBuffer);
return sk_sp<GrTexture>();
@@ -596,8 +596,7 @@
SkASSERT(deleteImageProc && deleteImageCtx);
backendTex.fConfig = pixelConfig;
- sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture(
- backendTex, kBorrow_GrWrapOwnership, kRead_GrIOType);
+ sk_sp<GrTexture> tex = resourceProvider->wrapBackendTexture(backendTex);
if (!tex) {
deleteImageProc(deleteImageCtx);
return sk_sp<GrTexture>();
@@ -611,8 +610,8 @@
return tex;
},
- backendFormat, desc, fSurfaceOrigin, GrMipMapped::kNo,
- GrInternalSurfaceFlags::kReadOnly, SkBackingFit::kExact, SkBudgeted::kNo);
+ backendFormat, desc, fSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact,
+ SkBudgeted::kNo);
if (!texProxy) {
AHardwareBuffer_release(hardwareBuffer);
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 1785823..4f887f2 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -138,8 +138,8 @@
SkASSERT(format.isValid());
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
- [refHelper, releaseProcHelper, semaphore,
- backendTexture](GrResourceProvider* resourceProvider) {
+ [refHelper, releaseProcHelper, semaphore, backendTexture]
+ (GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
return sk_sp<GrTexture>();
}
@@ -163,8 +163,9 @@
// informs us that the context is done with it. This is unfortunate - we'll have
// two texture objects referencing the same GPU object. However, no client can
// ever see the original texture, so this should be safe.
- tex = resourceProvider->wrapBackendTexture(
- backendTexture, kBorrow_GrWrapOwnership, kRead_GrIOType, true);
+ tex = resourceProvider->wrapBackendTexture(backendTexture,
+ kBorrow_GrWrapOwnership,
+ true);
if (!tex) {
return sk_sp<GrTexture>();
}
@@ -175,8 +176,7 @@
return tex;
},
- format, desc, fSurfaceOrigin, mipMapped, GrInternalSurfaceFlags::kReadOnly,
- SkBackingFit::kExact, SkBudgeted::kNo);
+ format, desc, fSurfaceOrigin, mipMapped, SkBackingFit::kExact, SkBudgeted::kNo);
if (!proxy) {
return nullptr;
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 562a7fc..64625d9 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -6,10 +6,9 @@
*/
#include "GrCaps.h"
+
#include "GrBackendSurface.h"
#include "GrContextOptions.h"
-#include "GrSurface.h"
-#include "GrSurfaceProxy.h"
#include "GrTypesPriv.h"
#include "GrWindowRectangles.h"
#include "SkJSONWriter.h"
@@ -243,15 +242,6 @@
void GrCaps::dumpJSON(SkJSONWriter* writer) const { }
#endif
-bool GrCaps::surfaceSupportsWritePixels(const GrSurface* surface) const {
- return surface->readOnly() ? false : this->onSurfaceSupportsWritePixels(surface);
-}
-
-bool GrCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const {
- return dst->readOnly() ? false : this->onCanCopySurface(dst, src, srcRect, dstPoint);
-}
-
bool GrCaps::validateSurfaceDesc(const GrSurfaceDesc& desc, GrMipMapped mipped) const {
if (!this->isConfigTexturable(desc.fConfig)) {
return false;
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index 7a9285d..c695ebe 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -192,7 +192,7 @@
* If this returns false then the caller should implement a fallback where a temporary texture
* is created, pixels are written to it, and then that is copied or drawn into the the surface.
*/
- bool surfaceSupportsWritePixels(const GrSurface*) const;
+ virtual bool surfaceSupportsWritePixels(const GrSurface*) const = 0;
/**
* Backends may have restrictions on what types of surfaces support GrGpu::readPixels().
@@ -246,8 +246,8 @@
/**
* Returns whether or not we will be able to do a copy given the passed in params
*/
- bool canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const;
+ virtual bool canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) const = 0;
bool dynamicStateArrayGeometryProcessorTextureSupport() const {
return fDynamicStateArrayGeometryProcessorTextureSupport;
@@ -389,9 +389,6 @@
private:
virtual void onApplyOptionsOverrides(const GrContextOptions&) {}
virtual void onDumpJSON(SkJSONWriter*) const {}
- virtual bool onSurfaceSupportsWritePixels(const GrSurface*) const = 0;
- virtual bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const = 0;
// Backends should implement this if they have any extra requirements for use of window
// rectangles for a specific GrBackendRenderTarget outside of basic support.
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 1b2d13c..06eb6c4 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -928,8 +928,7 @@
sk_sp<SkColorSpace> colorSpace) {
ASSERT_SINGLE_OWNER_PRIV
- sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendTexture(
- tex, origin, kBorrow_GrWrapOwnership, kRW_GrIOType);
+ sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendTexture(tex, origin);
if (!proxy) {
return nullptr;
}
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 7b7ff2e..8e18fb8 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -145,9 +145,7 @@
sk_sp<GrTexture> GrGpu::wrapBackendTexture(const GrBackendTexture& backendTex,
GrWrapOwnership ownership,
- GrIOType ioType,
bool purgeImmediately) {
- SkASSERT(ioType != kWrite_GrIOType);
this->handleDirtyContext();
if (!this->caps()->isConfigTexturable(backendTex.config())) {
return nullptr;
@@ -156,7 +154,7 @@
backendTex.height() > this->caps()->maxTextureSize()) {
return nullptr;
}
- return this->onWrapBackendTexture(backendTex, ownership, ioType, purgeImmediately);
+ return this->onWrapBackendTexture(backendTex, ownership, purgeImmediately);
}
sk_sp<GrTexture> GrGpu::wrapRenderableBackendTexture(const GrBackendTexture& backendTex,
@@ -216,13 +214,7 @@
bool canDiscardOutsideDstRect) {
GR_CREATE_TRACE_MARKER_CONTEXT("GrGpu", "copySurface", fContext);
SkASSERT(dst && src);
-
- if (dst->readOnly()) {
- return false;
- }
-
this->handleDirtyContext();
-
return this->onCopySurface(dst, dstOrigin, src, srcOrigin, srcRect, dstPoint,
canDiscardOutsideDstRect);
}
@@ -247,11 +239,6 @@
bool GrGpu::writePixels(GrSurface* surface, int left, int top, int width, int height,
GrColorType srcColorType, const GrMipLevel texels[], int mipLevelCount) {
SkASSERT(surface);
-
- if (surface->readOnly()) {
- return false;
- }
-
if (1 == mipLevelCount) {
// We require that if we are not mipped, then the write region is contained in the surface
SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height);
@@ -284,13 +271,8 @@
bool GrGpu::transferPixels(GrTexture* texture, int left, int top, int width, int height,
GrColorType bufferColorType, GrBuffer* transferBuffer, size_t offset,
size_t rowBytes) {
- SkASSERT(texture);
SkASSERT(transferBuffer);
- if (texture->readOnly()) {
- return false;
- }
-
// We require that the write region is contained in the texture
SkIRect subRect = SkIRect::MakeXYWH(left, top, width, height);
SkIRect bounds = SkIRect::MakeWH(texture->width(), texture->height());
@@ -316,9 +298,6 @@
SkASSERT(texture->texturePriv().mipMapped() == GrMipMapped::kYes);
SkASSERT(texture->texturePriv().mipMapsAreDirty());
SkASSERT(!texture->asRenderTarget() || !texture->asRenderTarget()->needsResolve());
- if (texture->readOnly()) {
- return false;
- }
if (this->onRegenerateMipMapLevels(texture)) {
texture->texturePriv().markMipMapsClean();
return true;
@@ -335,7 +314,6 @@
void GrGpu::didWriteToSurface(GrSurface* surface, GrSurfaceOrigin origin, const SkIRect* bounds,
uint32_t mipLevels) const {
SkASSERT(surface);
- SkASSERT(!surface->readOnly());
// Mark any MIP chain and resolve buffer as dirty if and only if there is a non-empty bounds.
if (nullptr == bounds || !bounds->isEmpty()) {
if (GrRenderTarget* target = surface->asRenderTarget()) {
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 99985f1..cb8b2e9 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -104,7 +104,7 @@
/**
* Implements GrResourceProvider::wrapBackendTexture
*/
- sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrIOType,
+ sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture&, GrWrapOwnership,
bool purgeImmediately);
/**
@@ -445,7 +445,7 @@
const GrMipLevel texels[], int mipLevelCount) = 0;
virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership,
- GrIOType, bool purgeImmediately) = 0;
+ bool purgeImmediately) = 0;
virtual sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
int sampleCnt,
GrWrapOwnership) = 0;
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index dcf642b..3259f28 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -415,10 +415,8 @@
sk_sp<GrTextureProxy> GrProxyProvider::wrapBackendTexture(const GrBackendTexture& backendTex,
GrSurfaceOrigin origin,
GrWrapOwnership ownership,
- GrIOType ioType,
ReleaseProc releaseProc,
ReleaseContext releaseCtx) {
- SkASSERT(ioType != kWrite_GrIOType);
if (this->isAbandoned()) {
return nullptr;
}
@@ -428,7 +426,7 @@
return nullptr;
}
- sk_sp<GrTexture> tex = fResourceProvider->wrapBackendTexture(backendTex, ownership, ioType);
+ sk_sp<GrTexture> tex = fResourceProvider->wrapBackendTexture(backendTex, ownership);
if (!tex) {
return nullptr;
}
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index 1aec328..1e26f51 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -104,12 +104,11 @@
typedef void (*ReleaseProc)(ReleaseContext);
/*
- * Create a texture proxy that wraps a (non-renderable) backend texture. GrIOType must be
- * kRead or kRW.
+ * Create a texture proxy that wraps a (non-renderable) backend texture.
*/
sk_sp<GrTextureProxy> wrapBackendTexture(const GrBackendTexture&, GrSurfaceOrigin,
- GrWrapOwnership, GrIOType, ReleaseProc = nullptr,
- ReleaseContext = nullptr);
+ GrWrapOwnership = kBorrow_GrWrapOwnership,
+ ReleaseProc = nullptr, ReleaseContext = nullptr);
/*
* Create a texture proxy that wraps a backend texture and is both texture-able and renderable
@@ -120,7 +119,7 @@
GrWrapOwnership = kBorrow_GrWrapOwnership);
/*
- * Create a render target proxy that wraps a backend render target
+ * Create a render target proxy that wraps a backend rendertarget
*/
sk_sp<GrSurfaceProxy> wrapBackendRenderTarget(const GrBackendRenderTarget&, GrSurfaceOrigin);
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 1193246..78bd97b 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -226,13 +226,12 @@
sk_sp<GrTexture> GrResourceProvider::wrapBackendTexture(const GrBackendTexture& tex,
GrWrapOwnership ownership,
- GrIOType ioType,
bool purgeImmediately) {
ASSERT_SINGLE_OWNER
if (this->isAbandoned()) {
return nullptr;
}
- return fGpu->wrapBackendTexture(tex, ownership, ioType, purgeImmediately);
+ return fGpu->wrapBackendTexture(tex, ownership, purgeImmediately);
}
sk_sp<GrTexture> GrResourceProvider::wrapRenderableBackendTexture(const GrBackendTexture& tex,
diff --git a/src/gpu/GrResourceProvider.h b/src/gpu/GrResourceProvider.h
index c86136f..74e1dce 100644
--- a/src/gpu/GrResourceProvider.h
+++ b/src/gpu/GrResourceProvider.h
@@ -98,17 +98,13 @@
/**
* Wraps an existing texture with a GrTexture object.
*
- * GrIOType must either be kRead or kRW. kRead blocks any operations that would modify the
- * pixels (e.g. dst for a copy, regenerating MIP levels, write pixels).
- *
* OpenGL: if the object is a texture Gr may change its GL texture params
* when it is drawn.
*
* @return GrTexture object or NULL on failure.
*/
sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture& tex,
- GrWrapOwnership /* = kBorrow_GrWrapOwnership*/,
- GrIOType,
+ GrWrapOwnership = kBorrow_GrWrapOwnership,
bool purgeImmediately = false);
/**
diff --git a/src/gpu/GrTextureOpList.cpp b/src/gpu/GrTextureOpList.cpp
index ae51807..4b93803 100644
--- a/src/gpu/GrTextureOpList.cpp
+++ b/src/gpu/GrTextureOpList.cpp
@@ -25,7 +25,6 @@
GrAuditTrail* auditTrail)
: INHERITED(resourceProvider, std::move(opMemoryPool), proxy, auditTrail) {
SkASSERT(fOpMemoryPool);
- SkASSERT(!proxy->readOnly());
}
void GrTextureOpList::deleteOp(int index) {
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index b732818..854ed17 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -173,14 +173,7 @@
SkASSERT(surface->asTexture());
SkASSERT(GrMipMapped::kNo == this->proxyMipMapped() ||
GrMipMapped::kYes == surface->asTexture()->texturePriv().mipMapped());
-
SkASSERT(surface->asTexture()->texturePriv().textureType() == this->textureType());
-
- GrInternalSurfaceFlags proxyFlags = fSurfaceFlags;
- GrInternalSurfaceFlags surfaceFlags = surface->surfacePriv().flags();
- SkASSERT((proxyFlags & GrInternalSurfaceFlags::kTextureMask) ==
- (surfaceFlags & GrInternalSurfaceFlags::kTextureMask));
}
-
#endif
diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp
index 3e52b2c..a665270 100644
--- a/src/gpu/GrTextureRenderTargetProxy.cpp
+++ b/src/gpu/GrTextureRenderTargetProxy.cpp
@@ -124,19 +124,11 @@
SkASSERT(surface->asRenderTarget());
SkASSERT(surface->asRenderTarget()->numStencilSamples() == this->numStencilSamples());
- SkASSERT(surface->asTexture()->texturePriv().textureType() == this->textureType());
-
GrInternalSurfaceFlags proxyFlags = fSurfaceFlags;
GrInternalSurfaceFlags surfaceFlags = surface->surfacePriv().flags();
-
- // Only non-RT textures can be read only.
- SkASSERT(!(proxyFlags & GrInternalSurfaceFlags::kReadOnly));
- SkASSERT(!(surfaceFlags & GrInternalSurfaceFlags::kReadOnly));
-
SkASSERT((proxyFlags & GrInternalSurfaceFlags::kRenderTargetMask) ==
(surfaceFlags & GrInternalSurfaceFlags::kRenderTargetMask));
- SkASSERT((proxyFlags & GrInternalSurfaceFlags::kTextureMask) ==
- (surfaceFlags & GrInternalSurfaceFlags::kTextureMask));
+ SkASSERT(surface->asTexture()->texturePriv().textureType() == this->textureType());
}
#endif
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index f90a1b0..9f26a7c 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -2172,8 +2172,8 @@
!rt->rtPriv().glRTFBOIDIs0();
}
-bool GrGLCaps::onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const {
+bool GrGLCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) const {
GrSurfaceOrigin dstOrigin = dst->origin();
GrSurfaceOrigin srcOrigin = src->origin();
@@ -2756,7 +2756,7 @@
}
}
-bool GrGLCaps::onSurfaceSupportsWritePixels(const GrSurface* surface) const {
+bool GrGLCaps::surfaceSupportsWritePixels(const GrSurface* surface) const {
if (fDisallowTexSubImageForUnormConfigTexturesEverBoundToFBO) {
if (auto tex = static_cast<const GrGLTexture*>(surface->asTexture())) {
if (tex->hasBaseLevelBeenBoundToFBO()) {
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 54dc126..4cdd316 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -311,6 +311,7 @@
/// Use indices or vertices in CPU arrays rather than VBOs for dynamic content.
bool useNonVBOVertexAndIndexDynamicData() const { return fUseNonVBOVertexAndIndexDynamicData; }
+ bool surfaceSupportsWritePixels(const GrSurface*) const override;
bool surfaceSupportsReadPixels(const GrSurface*) const override;
GrColorType supportedReadPixelsColorType(GrPixelConfig, GrColorType) const override;
@@ -418,6 +419,9 @@
const SkIRect& srcRect, const SkIPoint& dstPoint) const;
bool canCopyAsDraw(GrPixelConfig dstConfig, bool srcIsTextureable) const;
+ bool canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
+
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, GrSurfaceOrigin*,
bool* rectsMustMatch, bool* disallowSubrect) const override;
@@ -476,9 +480,6 @@
// This must be called after initFSAASupport().
void initConfigTable(const GrContextOptions&, const GrGLContextInfo&, const GrGLInterface*,
GrShaderCaps*);
- bool onSurfaceSupportsWritePixels(const GrSurface*) const override;
- bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
GrGLStandard fStandard;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index d344c3b..63bf032 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -652,8 +652,7 @@
}
sk_sp<GrTexture> GrGLGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
- GrWrapOwnership ownership, GrIOType ioType,
- bool purgeImmediately) {
+ GrWrapOwnership ownership, bool purgeImmediately) {
GrGLTexture::IDDesc idDesc;
if (!check_backend_texture(backendTex, this->glCaps(), &idDesc)) {
return nullptr;
@@ -677,7 +676,7 @@
GrMipMapsStatus mipMapsStatus = backendTex.hasMipMaps() ? GrMipMapsStatus::kValid
: GrMipMapsStatus::kNotAllocated;
- auto texture = GrGLTexture::MakeWrapped(this, surfDesc, mipMapsStatus, idDesc, ioType,
+ auto texture = GrGLTexture::MakeWrapped(this, surfDesc, mipMapsStatus, idDesc,
purgeImmediately);
// We don't know what parameters are already set on wrapped textures.
texture->textureParamsModified();
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index f74b98e..eb920db 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -189,7 +189,7 @@
GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrAccessPattern,
const void* data) override;
- sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrIOType,
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership,
bool purgeImmediately) override;
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
int sampleCnt,
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index 06bf662..2d432fe 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -51,15 +51,12 @@
}
GrGLTexture::GrGLTexture(GrGLGpu* gpu, Wrapped, const GrSurfaceDesc& desc,
- GrMipMapsStatus mipMapsStatus, const IDDesc& idDesc, GrIOType ioType,
+ GrMipMapsStatus mipMapsStatus, const IDDesc& idDesc,
bool purgeImmediately)
: GrSurface(gpu, desc)
, INHERITED(gpu, desc, TextureTypeFromTarget(idDesc.fInfo.fTarget), mipMapsStatus) {
this->init(desc, idDesc);
this->registerWithCacheWrapped(purgeImmediately);
- if (ioType == kRead_GrIOType) {
- this->setReadOnly();
- }
}
GrGLTexture::GrGLTexture(GrGLGpu* gpu, const GrSurfaceDesc& desc, const IDDesc& idDesc,
@@ -114,9 +111,9 @@
sk_sp<GrGLTexture> GrGLTexture::MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
GrMipMapsStatus mipMapsStatus, const IDDesc& idDesc,
- GrIOType ioType, bool purgeImmediately) {
- return sk_sp<GrGLTexture>(
- new GrGLTexture(gpu, kWrapped, desc, mipMapsStatus, idDesc, ioType, purgeImmediately));
+ bool purgeImmediately) {
+ return sk_sp<GrGLTexture>(new GrGLTexture(gpu, kWrapped, desc, mipMapsStatus, idDesc,
+ purgeImmediately));
}
bool GrGLTexture::onStealBackendTexture(GrBackendTexture* backendTexture,
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index 290729b..a9d7a38 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -100,7 +100,7 @@
void baseLevelWasBoundToFBO() { fBaseLevelHasBeenBoundToFBO = true; }
static sk_sp<GrGLTexture> MakeWrapped(GrGLGpu*, const GrSurfaceDesc&, GrMipMapsStatus,
- const IDDesc&, GrIOType, bool purgeImmediately);
+ const IDDesc&, bool purgeImmediately);
void dumpMemoryStatistics(SkTraceMemoryDump* traceMemoryDump) const override;
@@ -110,7 +110,7 @@
enum Wrapped { kWrapped };
// Constructor for instances wrapping backend objects.
- GrGLTexture(GrGLGpu*, Wrapped, const GrSurfaceDesc&, GrMipMapsStatus, const IDDesc&, GrIOType,
+ GrGLTexture(GrGLGpu*, Wrapped, const GrSurfaceDesc&, GrMipMapsStatus, const IDDesc&,
bool purgeImmediately);
void init(const GrSurfaceDesc&, const IDDesc&);
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index e940423..d24afa5 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -66,8 +66,14 @@
return 0;
}
+ bool surfaceSupportsWritePixels(const GrSurface*) const override { return true; }
bool surfaceSupportsReadPixels(const GrSurface*) const override { return true; }
+ bool canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) const override {
+ return true;
+ }
+
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, GrSurfaceOrigin*,
bool* rectsMustMatch, bool* disallowSubrect) const override {
return false;
@@ -136,11 +142,6 @@
SkAssertResult(backendTex.getMockTextureInfo(&mockInfo));
return GrBackendFormat::MakeMock(mockInfo.fConfig);
}
- bool onSurfaceSupportsWritePixels(const GrSurface*) const override { return true; }
- bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const override {
- return true;
- }
static const int kMaxSampleCnt = 16;
diff --git a/src/gpu/mock/GrMockGpu.cpp b/src/gpu/mock/GrMockGpu.cpp
index 4f2c4cd..2de25ef 100644
--- a/src/gpu/mock/GrMockGpu.cpp
+++ b/src/gpu/mock/GrMockGpu.cpp
@@ -103,8 +103,7 @@
}
sk_sp<GrTexture> GrMockGpu::onWrapBackendTexture(const GrBackendTexture& tex,
- GrWrapOwnership ownership, GrIOType ioType,
- bool purgeImmediately) {
+ GrWrapOwnership ownership, bool purgeImmediately) {
GrSurfaceDesc desc;
desc.fWidth = tex.width();
desc.fHeight = tex.height();
@@ -117,7 +116,7 @@
: GrMipMapsStatus::kNotAllocated;
return sk_sp<GrTexture>(new GrMockTexture(this, GrMockTexture::kWrapped, desc, mipMapsStatus,
- info, ioType, purgeImmediately));
+ info, purgeImmediately));
}
sk_sp<GrTexture> GrMockGpu::onWrapRenderableBackendTexture(const GrBackendTexture& tex,
diff --git a/src/gpu/mock/GrMockGpu.h b/src/gpu/mock/GrMockGpu.h
index 832877a..a39a82b 100644
--- a/src/gpu/mock/GrMockGpu.h
+++ b/src/gpu/mock/GrMockGpu.h
@@ -59,7 +59,7 @@
sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&, SkBudgeted, const GrMipLevel[],
int mipLevelCount) override;
- sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrIOType,
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership,
bool purgeImmediately) override;
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h
index ee8780d..0565f81 100644
--- a/src/gpu/mock/GrMockTexture.h
+++ b/src/gpu/mock/GrMockTexture.h
@@ -23,12 +23,10 @@
}
enum Wrapped { kWrapped };
- GrMockTexture(GrMockGpu* gpu, Wrapped, const GrSurfaceDesc& desc, GrMipMapsStatus mipMapsStatus,
- const GrMockTextureInfo& info, GrIOType ioType, bool purgeImmediately)
+ GrMockTexture(GrMockGpu* gpu, Wrapped, const GrSurfaceDesc& desc,
+ GrMipMapsStatus mipMapsStatus, const GrMockTextureInfo& info,
+ bool purgeImmediately)
: GrMockTexture(gpu, desc, mipMapsStatus, info) {
- if (ioType == kRead_GrIOType) {
- this->setReadOnly();
- }
this->registerWithCacheWrapped(purgeImmediately);
}
diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h
index 9d7b86f..7edfa79 100644
--- a/src/gpu/mtl/GrMtlCaps.h
+++ b/src/gpu/mtl/GrMtlCaps.h
@@ -33,6 +33,7 @@
int getRenderTargetSampleCount(int requestedCount, GrPixelConfig) const override;
int maxRenderTargetSampleCount(GrPixelConfig) const override;
+ bool surfaceSupportsWritePixels(const GrSurface*) const override { return true; }
bool surfaceSupportsReadPixels(const GrSurface*) const override { return true; }
bool isConfigCopyable(GrPixelConfig config) const override {
@@ -57,6 +58,9 @@
bool canCopyAsDrawThenBlit(GrPixelConfig dstConfig, GrPixelConfig srcConfig,
bool srcIsTextureable) const;
+ bool canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
+
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, GrSurfaceOrigin*,
bool* rectsMustMatch, bool* disallowSubrect) const override {
return false;
@@ -105,10 +109,6 @@
void initConfigTable();
- bool onSurfaceSupportsWritePixels(const GrSurface*) const override { return true; }
- bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
-
struct ConfigInfo {
ConfigInfo() : fFlags(0) {}
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index 880b0fa..ca3779b 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -166,8 +166,8 @@
return true;
}
-bool GrMtlCaps::onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const {
+bool GrMtlCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) const {
GrSurfaceOrigin dstOrigin = dst->origin();
GrSurfaceOrigin srcOrigin = src->origin();
diff --git a/src/gpu/mtl/GrMtlGpu.h b/src/gpu/mtl/GrMtlGpu.h
index 607f704..a727784 100644
--- a/src/gpu/mtl/GrMtlGpu.h
+++ b/src/gpu/mtl/GrMtlGpu.h
@@ -132,7 +132,7 @@
sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted,
const GrMipLevel texels[], int mipLevelCount) override;
- sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrIOType,
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership,
bool purgeImmediately) override;
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
diff --git a/src/gpu/mtl/GrMtlGpu.mm b/src/gpu/mtl/GrMtlGpu.mm
index 132f455..0661648 100644
--- a/src/gpu/mtl/GrMtlGpu.mm
+++ b/src/gpu/mtl/GrMtlGpu.mm
@@ -338,8 +338,7 @@
}
sk_sp<GrTexture> GrMtlGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
- GrWrapOwnership ownership, GrIOType ioType,
- bool purgeImmediately) {
+ GrWrapOwnership ownership, bool purgeImmediately) {
id<MTLTexture> mtlTexture = get_texture_from_backend(backendTex, ownership);
if (!mtlTexture) {
return nullptr;
@@ -348,7 +347,7 @@
GrSurfaceDesc surfDesc;
init_surface_desc(&surfDesc, mtlTexture, false, backendTex.config());
- return GrMtlTexture::MakeWrappedTexture(this, surfDesc, mtlTexture, ioType, purgeImmediately);
+ return GrMtlTexture::MakeWrappedTexture(this, surfDesc, mtlTexture, purgeImmediately);
}
sk_sp<GrTexture> GrMtlGpu::onWrapRenderableBackendTexture(const GrBackendTexture& backendTex,
diff --git a/src/gpu/mtl/GrMtlTexture.h b/src/gpu/mtl/GrMtlTexture.h
index 7564f94..5f6234e 100644
--- a/src/gpu/mtl/GrMtlTexture.h
+++ b/src/gpu/mtl/GrMtlTexture.h
@@ -21,8 +21,8 @@
MTLTextureDescriptor*,
GrMipMapsStatus);
- static sk_sp<GrMtlTexture> MakeWrappedTexture(GrMtlGpu*, const GrSurfaceDesc&, id<MTLTexture>,
- GrIOType, bool purgeImmediately);
+ static sk_sp<GrMtlTexture> MakeWrappedTexture(GrMtlGpu*, const GrSurfaceDesc&,
+ id<MTLTexture>, bool purgeImmediately);
~GrMtlTexture() override;
@@ -65,7 +65,7 @@
GrMipMapsStatus);
GrMtlTexture(GrMtlGpu*, Wrapped, const GrSurfaceDesc&, id<MTLTexture>, GrMipMapsStatus,
- GrIOType, bool purgeImmediately);
+ bool purgeImmediately);
id<MTLTexture> fTexture;
diff --git a/src/gpu/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm
index 5e91746..711d5ae 100644
--- a/src/gpu/mtl/GrMtlTexture.mm
+++ b/src/gpu/mtl/GrMtlTexture.mm
@@ -28,15 +28,11 @@
const GrSurfaceDesc& desc,
id<MTLTexture> texture,
GrMipMapsStatus mipMapsStatus,
- GrIOType ioType,
bool purgeImmediately)
: GrSurface(gpu, desc)
, INHERITED(gpu, desc, GrTextureType::k2D, mipMapsStatus)
, fTexture(texture) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == texture.mipmapLevelCount));
- if (ioType == kRead_GrIOType) {
- this->setReadOnly();
- }
this->registerWithCacheWrapped(purgeImmediately);
}
@@ -67,7 +63,6 @@
sk_sp<GrMtlTexture> GrMtlTexture::MakeWrappedTexture(GrMtlGpu* gpu,
const GrSurfaceDesc& desc,
id<MTLTexture> texture,
- GrIOType ioType,
bool purgeImmediately) {
if (desc.fSampleCnt > 1) {
SkASSERT(false); // Currently we don't support msaa
@@ -77,7 +72,7 @@
SkASSERT(MTLTextureUsageShaderRead & texture.usage);
GrMipMapsStatus mipMapsStatus = texture.mipmapLevelCount > 1 ? GrMipMapsStatus::kValid
: GrMipMapsStatus::kNotAllocated;
- return sk_sp<GrMtlTexture>(new GrMtlTexture(gpu, kWrapped, desc, texture, mipMapsStatus, ioType,
+ return sk_sp<GrMtlTexture>(new GrMtlTexture(gpu, kWrapped, desc, texture, mipMapsStatus,
purgeImmediately));
}
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 75911b6..fbd381f 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -158,8 +158,8 @@
return true;
}
-bool GrVkCaps::onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const {
+bool GrVkCaps::canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) const {
GrSurfaceOrigin dstOrigin = dst->origin();
GrSurfaceOrigin srcOrigin = src->origin();
@@ -698,7 +698,7 @@
return table[table.count() - 1];
}
-bool GrVkCaps::onSurfaceSupportsWritePixels(const GrSurface* surface) const {
+bool GrVkCaps::surfaceSupportsWritePixels(const GrSurface* surface) const {
if (auto rt = surface->asRenderTarget()) {
return rt->numColorSamples() <= 1 && SkToBool(surface->asTexture());
}
diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h
index 9514d41..a20a104 100644
--- a/src/gpu/vk/GrVkCaps.h
+++ b/src/gpu/vk/GrVkCaps.h
@@ -43,6 +43,7 @@
int getRenderTargetSampleCount(int requestedCount, GrPixelConfig config) const override;
int maxRenderTargetSampleCount(GrPixelConfig config) const override;
+ bool surfaceSupportsWritePixels(const GrSurface*) const override;
bool surfaceSupportsReadPixels(const GrSurface*) const override { return true; }
bool isConfigTexturableLinearly(GrPixelConfig config) const {
@@ -150,6 +151,9 @@
bool canCopyAsDraw(GrPixelConfig dstConfig, bool dstIsRenderable,
GrPixelConfig srcConfig, bool srcIsTextureable) const;
+ bool canCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
+ const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
+
bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc, GrSurfaceOrigin*,
bool* rectsMustMatch, bool* disallowSubrect) const override;
@@ -197,10 +201,6 @@
void applyDriverCorrectnessWorkarounds(const VkPhysicalDeviceProperties&);
- bool onSurfaceSupportsWritePixels(const GrSurface*) const override;
- bool onCanCopySurface(const GrSurfaceProxy* dst, const GrSurfaceProxy* src,
- const SkIRect& srcRect, const SkIPoint& dstPoint) const override;
-
struct ConfigInfo {
ConfigInfo() : fOptimalFlags(0), fLinearFlags(0) {}
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 1c02e33..ca48271 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -888,8 +888,7 @@
}
sk_sp<GrTexture> GrVkGpu::onWrapBackendTexture(const GrBackendTexture& backendTex,
- GrWrapOwnership ownership, GrIOType ioType,
- bool purgeImmediately) {
+ GrWrapOwnership ownership, bool purgeImmediately) {
GrVkImageInfo imageInfo;
if (!backendTex.getVkImageInfo(&imageInfo)) {
return nullptr;
@@ -908,7 +907,7 @@
sk_sp<GrVkImageLayout> layout = backendTex.getGrVkImageLayout();
SkASSERT(layout);
- return GrVkTexture::MakeWrappedTexture(this, surfDesc, ownership, ioType, purgeImmediately,
+ return GrVkTexture::MakeWrappedTexture(this, surfDesc, ownership, purgeImmediately,
imageInfo, std::move(layout));
}
diff --git a/src/gpu/vk/GrVkGpu.h b/src/gpu/vk/GrVkGpu.h
index 32a7c89..c195d3b 100644
--- a/src/gpu/vk/GrVkGpu.h
+++ b/src/gpu/vk/GrVkGpu.h
@@ -170,7 +170,7 @@
sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&, SkBudgeted, const GrMipLevel[],
int mipLevelCount) override;
- sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrIOType,
+ sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership,
bool purgeImmediately) override;
sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&,
int sampleCnt,
diff --git a/src/gpu/vk/GrVkTexture.cpp b/src/gpu/vk/GrVkTexture.cpp
index a295c04..8157433 100644
--- a/src/gpu/vk/GrVkTexture.cpp
+++ b/src/gpu/vk/GrVkTexture.cpp
@@ -41,16 +41,12 @@
const GrVkImageView* view,
GrMipMapsStatus mipMapsStatus,
GrBackendObjectOwnership ownership,
- GrIOType ioType,
bool purgeImmediately)
: GrSurface(gpu, desc)
, GrVkImage(info, std::move(layout), ownership)
, INHERITED(gpu, desc, GrTextureType::k2D, mipMapsStatus)
, fTextureView(view) {
SkASSERT((GrMipMapsStatus::kNotAllocated == mipMapsStatus) == (1 == info.fLevelCount));
- if (ioType == kRead_GrIOType) {
- this->setReadOnly();
- }
this->registerWithCacheWrapped(purgeImmediately);
}
@@ -96,7 +92,6 @@
sk_sp<GrVkTexture> GrVkTexture::MakeWrappedTexture(GrVkGpu* gpu,
const GrSurfaceDesc& desc,
GrWrapOwnership wrapOwnership,
- GrIOType ioType,
bool purgeImmediately,
const GrVkImageInfo& info,
sk_sp<GrVkImageLayout> layout) {
@@ -116,7 +111,7 @@
GrBackendObjectOwnership ownership = kBorrow_GrWrapOwnership == wrapOwnership
? GrBackendObjectOwnership::kBorrowed : GrBackendObjectOwnership::kOwned;
return sk_sp<GrVkTexture>(new GrVkTexture(gpu, kWrapped, desc, info, std::move(layout),
- imageView, mipMapsStatus, ownership, ioType,
+ imageView, mipMapsStatus, ownership,
purgeImmediately));
}
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index b85dee0..d841bf3 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -25,8 +25,8 @@
const GrVkImage::ImageDesc&,
GrMipMapsStatus);
- static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&, GrWrapOwnership,
- GrIOType, bool purgeImmediately,
+ static sk_sp<GrVkTexture> MakeWrappedTexture(GrVkGpu*, const GrSurfaceDesc&,
+ GrWrapOwnership, bool purgeImmediatley,
const GrVkImageInfo&, sk_sp<GrVkImageLayout>);
~GrVkTexture() override;
@@ -66,7 +66,7 @@
GrMipMapsStatus);
GrVkTexture(GrVkGpu*, Wrapped, const GrSurfaceDesc&, const GrVkImageInfo&,
sk_sp<GrVkImageLayout> layout, const GrVkImageView* imageView, GrMipMapsStatus,
- GrBackendObjectOwnership, GrIOType ioType, bool purgeImmediately);
+ GrBackendObjectOwnership, bool purgeImmediately);
const GrVkImageView* fTextureView;