aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-03-21 12:13:37 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-03-21 17:04:18 +0000
commitabf7b763e2c1ba069942dedec914494817fd27a8 (patch)
treec956480efd2273f0371823d3ebf0a3af46c09cab /src
parente65a5cd3fc34ab90743056ace2ef0a3a01bf6346 (diff)
Add texture-specific flags for External & Rectangle textures
For DDLs, Ganesh needs to know about External & Rectangle textures prior to instantiation (or PromiseImage fulfillment). These new flags allow the client to provide this information when the lazyProxy is created. The new texture flags work analogously to the render target flags: GrSurface and GrSurfaceProxy get a new set of accessors for the new flags The new flags are set appropriately on a GrGLTexture when it is created For wrapped texture proxies the flags are just copied off of the GrSurface For lazy-proxies/promise-images the flags are computed up front and passed to the proxy The GrSurfaceProxy/GrSurface flags equivalence is verified in GrSurfaceProxy::assign Change-Id: Ia8e1998aa0a36ce4481bfd9e56be21f990e83148 Reviewed-on: https://skia-review.googlesource.com/114985 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/core/SkDeferredDisplayListRecorder.cpp10
-rw-r--r--src/gpu/GrGpu.cpp17
-rw-r--r--src/gpu/GrGpu.h26
-rw-r--r--src/gpu/GrSurfacePriv.h3
-rw-r--r--src/gpu/GrSurfaceProxy.cpp9
-rw-r--r--src/gpu/GrTextureAdjuster.cpp10
-rw-r--r--src/gpu/GrTextureMaker.cpp9
-rw-r--r--src/gpu/GrTextureProxyPriv.h3
-rw-r--r--src/gpu/gl/GrGLGpu.cpp24
-rw-r--r--src/gpu/gl/GrGLGpu.h4
-rw-r--r--src/gpu/gl/GrGLTexture.cpp5
-rw-r--r--src/image/SkImage_Gpu.cpp16
12 files changed, 67 insertions, 69 deletions
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index 1114a26751..8a89068f4f 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -93,6 +93,14 @@ bool SkDeferredDisplayListRecorder::init() {
// proxy, when instantiated, will use the GrRenderTarget that backs the SkSurface that the
// DDL is being replayed into.
+ GrInternalSurfaceFlags surfaceFlags = GrInternalSurfaceFlags::kNone;
+ if (fContext->caps()->usesMixedSamples() && desc.fSampleCnt > 1) {
+ surfaceFlags |= GrInternalSurfaceFlags::kMixedSampled;
+ }
+ if (fContext->caps()->maxWindowRectangles() > 0) {
+ surfaceFlags |= GrInternalSurfaceFlags::kWindowRectsSupport;
+ }
+
sk_sp<GrRenderTargetProxy> proxy = proxyProvider->createLazyRenderTargetProxy(
[lazyProxyData](GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
@@ -106,7 +114,7 @@ bool SkDeferredDisplayListRecorder::init() {
},
desc,
fCharacterization.origin(),
- GrInternalSurfaceFlags::kNone,
+ surfaceFlags,
GrProxyProvider::Textureable(fCharacterization.isTextureable()),
GrMipMapped::kNo,
SkBackingFit::kExact,
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 18a13de991..fafce10f57 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -26,6 +26,7 @@
#include "GrStencilSettings.h"
#include "GrSurfacePriv.h"
#include "GrTexturePriv.h"
+#include "GrTextureProxyPriv.h"
#include "GrTracing.h"
#include "SkJSONWriter.h"
#include "SkMathPriv.h"
@@ -44,11 +45,25 @@ void GrGpu::disconnect(DisconnectType) {}
////////////////////////////////////////////////////////////////////////////////
-bool GrGpu::IsACopyNeededForTextureParams(const GrCaps* caps,
+bool GrGpu::IsACopyNeededForTextureParams(const GrCaps* caps, GrTextureProxy* texProxy,
int width, int height,
const GrSamplerState& textureParams,
GrTextureProducer::CopyParams* copyParams,
SkScalar scaleAdjust[2]) {
+
+ if (texProxy) {
+ // If the texture format itself doesn't support repeat wrap mode or mipmapping (and
+ // those capabilities are required) force a copy.
+ if ((textureParams.isRepeated() && texProxy->texPriv().isClampOnly()) ||
+ (GrSamplerState::Filter::kMipMap == textureParams.filter() &&
+ texProxy->texPriv().doesNotSupportMipMaps())) {
+ copyParams->fFilter = GrSamplerState::Filter::kNearest;
+ copyParams->fWidth = texProxy->width();
+ copyParams->fHeight = texProxy->height();
+ return true;
+ }
+ }
+
if (textureParams.isRepeated() && !caps->npotTextureTileSupport() &&
(!SkIsPow2(width) || !SkIsPow2(height))) {
SkASSERT(scaleAdjust);
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 95c5117799..78b6fd4654 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -506,26 +506,12 @@ public:
virtual void clearStencil(GrRenderTarget* target, int clearValue) = 0;
// Determines whether a texture will need to be rescaled in order to be used with the
- // GrSamplerState. This variation is called when the caller will create a new texture using the
- // resource provider from a non-texture src (cpu-backed image, ...).
- static bool IsACopyNeededForTextureParams(const GrCaps*, int width, int height,
+ // GrSamplerState.
+ static bool IsACopyNeededForTextureParams(const GrCaps*, GrTextureProxy* texProxy,
+ int width, int height,
const GrSamplerState&, GrTextureProducer::CopyParams*,
SkScalar scaleAdjust[2]);
- // Like the above but this variation should be called when the caller is not creating the
- // original texture but rather was handed the original texture. It adds additional checks
- // relevant to original textures that were created external to Skia via
- // GrResourceProvider::wrap methods.
- bool isACopyNeededForTextureParams(GrTextureProxy* proxy, const GrSamplerState& params,
- GrTextureProducer::CopyParams* copyParams,
- SkScalar scaleAdjust[2]) const {
- if (IsACopyNeededForTextureParams(this->caps(), proxy->width(), proxy->height(), params,
- copyParams, scaleAdjust)) {
- return true;
- }
- return this->onIsACopyNeededForTextureParams(proxy, params, copyParams, scaleAdjust);
- }
-
void handleDirtyContext() {
if (fResetBits) {
this->resetContext();
@@ -578,12 +564,6 @@ private:
virtual GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrAccessPattern,
const void* data) = 0;
- virtual bool onIsACopyNeededForTextureParams(GrTextureProxy* proxy, const GrSamplerState&,
- GrTextureProducer::CopyParams*,
- SkScalar scaleAdjust[2]) const {
- return false;
- }
-
virtual bool onGetReadPixelsInfo(GrSurface*, GrSurfaceOrigin, int width, int height,
size_t rowBytes, GrColorType, DrawPreference*,
ReadPixelTempDrawInfo*) = 0;
diff --git a/src/gpu/GrSurfacePriv.h b/src/gpu/GrSurfacePriv.h
index 4d61dca5ee..98d8fc52d8 100644
--- a/src/gpu/GrSurfacePriv.h
+++ b/src/gpu/GrSurfacePriv.h
@@ -40,6 +40,9 @@ public:
GrInternalSurfaceFlags flags() const { return fSurface->fSurfaceFlags; }
+ bool doesNotSupportMipMaps() const { return fSurface->doesNotSupportMipMaps(); }
+ bool isClampOnly() const { return fSurface->isClampOnly(); }
+
private:
explicit GrSurfacePriv(GrSurface* surface) : fSurface(surface) {}
GrSurfacePriv(const GrSurfacePriv&); // unimpl
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index a49251f337..2aa13c89aa 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -179,6 +179,11 @@ sk_sp<GrSurface> GrSurfaceProxy::createSurfaceImpl(
void GrSurfaceProxy::assign(sk_sp<GrSurface> surface) {
SkASSERT(!fTarget && surface);
+
+ // Check that our a priori computation matched the ultimate reality
+ SkASSERT((fSurfaceFlags & ~GrInternalSurfaceFlags::kNoPendingIO) ==
+ surface->surfacePriv().flags());
+
fTarget = surface.release();
this->INHERITED::transferRefs();
@@ -222,10 +227,6 @@ bool GrSurfaceProxy::instantiateImpl(GrResourceProvider* resourceProvider, int s
this->assign(std::move(surface));
- // Check that our a priori computation matched the ultimate reality
- SkASSERT((fSurfaceFlags & ~GrInternalSurfaceFlags::kNoPendingIO) ==
- fTarget->surfacePriv().flags());
-
return true;
}
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index cc7a899839..306ec59220 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -75,13 +75,9 @@ sk_sp<GrTextureProxy> GrTextureAdjuster::refTextureProxySafeForParams(const GrSa
return nullptr;
}
- // DDL TODO: remove the need for the GrGpu in this method
- GrGpu* gpu = fContext->contextPriv().getGpu();
- if (!gpu) {
- return proxy;
- }
-
- if (!gpu->isACopyNeededForTextureParams(proxy.get(), params, &copyParams, scaleAdjust)) {
+ if (!GrGpu::IsACopyNeededForTextureParams(fContext->caps(),
+ proxy.get(), proxy->width(), proxy->height(),
+ params, &copyParams, scaleAdjust)) {
return proxy;
}
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index 720f357a68..5db0b481b7 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -31,13 +31,14 @@ sk_sp<GrTextureProxy> GrTextureMaker::refTextureProxyForParams(const GrSamplerSt
sk_sp<GrTextureProxy> original(this->refOriginalTextureProxy(willBeMipped, dstColorSpace,
AllowedTexGenType::kCheap));
if (original) {
- GrGpu* gpu = fContext->contextPriv().getGpu();
-
- if (!gpu->isACopyNeededForTextureParams(original.get(), params, &copyParams, scaleAdjust)) {
+ if (!GrGpu::IsACopyNeededForTextureParams(fContext->caps(), original.get(),
+ original->width(), original->height(),
+ params, &copyParams, scaleAdjust)) {
return original;
}
} else {
- if (!GrGpu::IsACopyNeededForTextureParams(fContext->caps(), this->width(), this->height(),
+ if (!GrGpu::IsACopyNeededForTextureParams(fContext->caps(), nullptr,
+ this->width(), this->height(),
params, &copyParams, scaleAdjust)) {
return this->refOriginalTextureProxy(willBeMipped, dstColorSpace,
AllowedTexGenType::kAny);
diff --git a/src/gpu/GrTextureProxyPriv.h b/src/gpu/GrTextureProxyPriv.h
index 3b68374d49..c7582d3ee9 100644
--- a/src/gpu/GrTextureProxyPriv.h
+++ b/src/gpu/GrTextureProxyPriv.h
@@ -31,6 +31,9 @@ public:
// been instantiated or not.
GrMipMapped proxyMipMapped() const { return fTextureProxy->fMipMapped; }
+ bool doesNotSupportMipMaps() const { return fTextureProxy->doesNotSupportMipMaps(); }
+ bool isClampOnly() const { return fTextureProxy->isClampOnly(); }
+
private:
explicit GrTextureProxyPriv(GrTextureProxy* textureProxy) : fTextureProxy(textureProxy) {}
GrTextureProxyPriv(const GrTextureProxyPriv&) {} // unimpl
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index 4e1e64b21e..ce81adf95f 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -4553,30 +4553,6 @@ GrGLAttribArrayState* GrGLGpu::HWVertexArrayState::bindInternalVertexArray(GrGLG
return attribState;
}
-bool GrGLGpu::onIsACopyNeededForTextureParams(GrTextureProxy* proxy,
- const GrSamplerState& textureParams,
- GrTextureProducer::CopyParams* copyParams,
- SkScalar scaleAdjust[2]) const {
- const GrTexture* texture = proxy->priv().peekTexture();
- if (!texture) {
- // The only way to get and EXTERNAL or RECTANGLE texture in Ganesh is to wrap them.
- // In that case the proxy should already be instantiated.
- return false;
- }
-
- if (textureParams.isRepeated() || GrSamplerState::Filter::kMipMap == textureParams.filter()) {
- const GrGLTexture* glTexture = static_cast<const GrGLTexture*>(texture);
- if (GR_GL_TEXTURE_EXTERNAL == glTexture->target() ||
- GR_GL_TEXTURE_RECTANGLE == glTexture->target()) {
- copyParams->fFilter = GrSamplerState::Filter::kNearest;
- copyParams->fWidth = texture->width();
- copyParams->fHeight = texture->height();
- return true;
- }
- }
- return false;
-}
-
void GrGLGpu::onFinishFlush(bool insertedSemaphore) {
// If we inserted semaphores during the flush, we need to call GLFlush.
if (insertedSemaphore) {
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index c09cac64fc..9a03d97126 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -215,10 +215,6 @@ private:
GrGLTexture::TexParams* initialTexParams, const GrMipLevel texels[],
int mipLevelCount, GrMipMapsStatus* mipMapsStatus);
- bool onIsACopyNeededForTextureParams(GrTextureProxy*, const GrSamplerState&,
- GrTextureProducer::CopyParams*,
- SkScalar scaleAdjust[2]) const override;
-
// Checks whether glReadPixels can be called to get pixel values in readConfig from the
// render target.
bool readPixelsSupported(GrRenderTarget* target, GrPixelConfig readConfig);
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index 5175ea88e7..8fe992794f 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -69,6 +69,11 @@ 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->setDoesNotSupportMipMaps();
+ this->setIsClampOnly();
+ }
fTexParams.invalidate();
fTexParamsTimestamp = GrGpu::kExpiredTimestamp;
fInfo = idDesc.fInfo;
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 9c62c349c8..6342512837 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -28,6 +28,7 @@
#include "GrTexture.h"
#include "GrTexturePriv.h"
#include "GrTextureProxy.h"
+#include "gl/GrGLDefines.h"
#include "effects/GrNonlinearColorSpaceXformEffect.h"
#include "effects/GrYUVtoRGBEffect.h"
#include "SkCanvas.h"
@@ -617,6 +618,17 @@ private:
sk_sp<GrReleaseProcHelper> fDoneHelper;
};
+static GrInternalSurfaceFlags get_flags_from_format(const GrBackendFormat& backendFormat) {
+ if (const GrGLenum* target = backendFormat.getGLTarget()) {
+ if (GR_GL_TEXTURE_RECTANGLE == *target || GR_GL_TEXTURE_EXTERNAL == *target) {
+ return GrInternalSurfaceFlags::kDoesNotSupportMipMaps |
+ GrInternalSurfaceFlags::kIsClampOnly;
+ }
+ }
+
+ return GrInternalSurfaceFlags::kNone;
+}
+
sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
const GrBackendFormat& backendFormat,
int width,
@@ -661,6 +673,8 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
PromiseImageHelper promiseHelper(textureFulfillProc, textureReleaseProc, promiseDoneProc,
textureContext);
+ GrInternalSurfaceFlags formatFlags = get_flags_from_format(backendFormat);
+
sk_sp<GrTextureProxy> proxy = proxyProvider->createLazyProxy(
[promiseHelper, config] (GrResourceProvider* resourceProvider) mutable {
if (!resourceProvider) {
@@ -669,7 +683,7 @@ sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
}
return promiseHelper.getTexture(resourceProvider, config);
- }, desc, origin, mipMapped, GrInternalSurfaceFlags::kNone, SkBackingFit::kExact,
+ }, desc, origin, mipMapped, formatFlags, SkBackingFit::kExact,
SkBudgeted::kNo, GrSurfaceProxy::LazyInstantiationType::kUninstantiate);
if (!proxy) {