Revert "Reland "Have a GrBackendFormat be stored on gpu proxies.""
This reverts commit 2f9a5ea639925f38785f4d3a0af237822007cfd6.
Reason for revert: breaking fuchsia
Original change's description:
> Reland "Have a GrBackendFormat be stored on gpu proxies."
>
> This reverts commit 919c9e77c3492af766ff5982acda76ee49da3168.
>
> Reason for revert: Flutter change has landed and fixed memory issue.
>
> Original change's description:
> > Revert "Have a GrBackendFormat be stored on gpu proxies."
> >
> > This reverts commit 51b1c12bbc2fa3f8d4faa29ad19c6f3cb34837ce.
> >
> > Reason for revert: reverting till flutter gets to 1.1 to fix build issues.
> >
> > Original change's description:
> > > Have a GrBackendFormat be stored on gpu proxies.
> > >
> > > Bug: skia:
> > > Change-Id: Iaf1fb24ab29a61d44e5fa59a5e0867ed02dcda90
> > > Reviewed-on: https://skia-review.googlesource.com/c/168021
> > > Reviewed-by: Brian Osman <brianosman@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com
> >
> > Change-Id: I574fdc084ef5994596c51fb0d60423b5dc01b885
> > No-Presubmit: true
> > No-Tree-Checks: true
> > No-Try: true
> > Bug: chromium:903701 chromium:903756
> > Reviewed-on: https://skia-review.googlesource.com/c/169835
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com
>
> Change-Id: Ifd9b6b8e194af9fb9258fa626644e76e6ecf090d
> Bug: chromium:903701 chromium:903756
> Reviewed-on: https://skia-review.googlesource.com/c/170104
> Commit-Queue: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Reviewed-by: Brian Osman <brianosman@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,brianosman@google.com
Change-Id: Ia0556355e5775b2100901b7bfa37f97bb6ccd90f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:903701 chromium:903756
Reviewed-on: https://skia-review.googlesource.com/c/171002
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index 6cb7126..9d5f17a 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -145,9 +145,6 @@
optionalTextureInfo = &kTextureInfo;
}
- const GrBackendFormat format = fContext->contextPriv().caps()->getBackendFormatFromColorType(
- fCharacterization.colorType());
-
sk_sp<GrRenderTargetProxy> proxy = proxyProvider->createLazyRenderTargetProxy(
[lazyProxyData](GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
@@ -159,7 +156,6 @@
SkASSERT(lazyProxyData->fReplayDest->peekSurface());
return sk_ref_sp<GrSurface>(lazyProxyData->fReplayDest->peekSurface());
},
- format,
desc,
fCharacterization.origin(),
surfaceFlags,
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index 54f1bc7..f9aee1c 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -117,14 +117,8 @@
GrPixelConfig config = get_blur_config(proxy.get());
- GrBackendFormat format = proxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrRenderTargetContext> renderTargetContext;
renderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
- format,
dstFit, dstII.width(), dstII.height(),
config, dstII.refColorSpace(),
1, GrMipMapped::kNo,
@@ -165,14 +159,8 @@
GrPixelConfig config = get_blur_config(proxy.get());
- GrBackendFormat format = proxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrRenderTargetContext> dstRenderTargetContext;
dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
- format,
fit, srcRect.width(),
srcRect.height(),
config,
@@ -288,17 +276,11 @@
sk_sp<GrRenderTargetContext> dstRenderTargetContext;
- GrBackendFormat format = src->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
for (int i = 1; i < scaleFactorX || i < scaleFactorY; i *= 2) {
shrink_irect_by_2(&dstRect, i < scaleFactorX, i < scaleFactorY);
// We know this will not be the final draw so we are free to make it an approx match.
dstRenderTargetContext = context->contextPriv().makeDeferredRenderTargetContext(
- format,
SkBackingFit::kApprox,
dstRect.fRight,
dstRect.fBottom,
@@ -400,14 +382,8 @@
GrPixelConfig config = get_blur_config(srcProxy.get());
- GrBackendFormat format = srcProxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrRenderTargetContext> dstRenderTargetContext =
- context->contextPriv().makeDeferredRenderTargetContext(format,
- fit, dstII.width(), dstII.height(),
+ context->contextPriv().makeDeferredRenderTargetContext(fit, dstII.width(), dstII.height(),
config, dstII.refColorSpace(),
1, GrMipMapped::kNo,
srcProxy->origin());
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 710e1ff..b6ed9b3 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -248,12 +248,9 @@
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
GrPixelConfig config = SkColorType2GrPixelConfig(outputProperties.colorType());
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(
- outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(),
+ SkBackingFit::kApprox, bounds.width(), bounds.height(),
config, std::move(colorSpace)));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index a1db765..4309b80 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -436,11 +436,8 @@
return nullptr;
}
- GrBackendFormat format =
- fContext->contextPriv().caps()->getBackendFormatFromColorType(outProps.colorType());
-
return SkSpecialSurface::MakeRenderTarget(
- fContext, format, size.width(), size.height(),
+ fContext, size.width(), size.height(),
SkColorType2GrPixelConfig(outProps.colorType()), sk_ref_sp(outProps.colorSpace()),
props);
}
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index a1d76f1..a45b40b 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -117,7 +117,6 @@
#if SK_SUPPORT_GPU
///////////////////////////////////////////////////////////////////////////////
-#include "GrBackendSurface.h"
#include "GrContext.h"
#include "SkGpuDevice.h"
@@ -165,7 +164,6 @@
};
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrContext* context,
- const GrBackendFormat& format,
int width, int height,
GrPixelConfig config,
sk_sp<SkColorSpace> colorSpace,
@@ -176,7 +174,7 @@
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, width, height, config, std::move(colorSpace), 1,
+ SkBackingFit::kApprox, width, height, config, std::move(colorSpace), 1,
GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, props));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/core/SkSpecialSurface.h b/src/core/SkSpecialSurface.h
index 1b7aada..b04b28d 100644
--- a/src/core/SkSpecialSurface.h
+++ b/src/core/SkSpecialSurface.h
@@ -16,7 +16,6 @@
#include "GrTypesPriv.h"
#endif
-class GrBackendFormat;
class GrContext;
class SkBitmap;
class SkCanvas;
@@ -61,7 +60,6 @@
* be created, nullptr will be returned.
*/
static sk_sp<SkSpecialSurface> MakeRenderTarget(GrContext*,
- const GrBackendFormat& format,
int width, int height,
GrPixelConfig config,
sk_sp<SkColorSpace> colorSpace,
diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
index 29d5cc5..8cc485f 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -105,11 +105,10 @@
sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrContext* context,
const SkMatrix& inMatrix,
const SkIRect& bounds) const {
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
+
sk_sp<GrRenderTargetContext> rtContext(
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(), kAlpha_8_GrPixelConfig,
+ SkBackingFit::kApprox, bounds.width(), bounds.height(), kAlpha_8_GrPixelConfig,
nullptr));
if (!rtContext) {
return nullptr;
diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
index 88a7c80..14fd17d 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -356,14 +356,10 @@
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- SkColorType colorType = outputProperties.colorType();
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(colorType);
-
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(),
- SkColorType2GrPixelConfig(colorType),
+ SkBackingFit::kApprox, bounds.width(), bounds.height(),
+ SkColorType2GrPixelConfig(outputProperties.colorType()),
sk_ref_sp(outputProperties.colorSpace())));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
index 0427cff..c5403cb 100644
--- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp
+++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
@@ -300,15 +300,12 @@
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
SkMatrix matrix;
matrix.setTranslate(-SkIntToScalar(colorBounds.x()), -SkIntToScalar(colorBounds.y()));
- SkColorType colorType = ctx.outputProperties().colorType();
- GrPixelConfig config = SkColorType2GrPixelConfig(colorType);
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(colorType);
+ GrPixelConfig config = SkColorType2GrPixelConfig(ctx.outputProperties().colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(), config,
- sk_ref_sp(colorSpace)));
+ context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+ bounds.width(), bounds.height(),
+ config, sk_ref_sp(colorSpace)));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index d89233f..dbe30c6 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -464,14 +464,11 @@
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy);
- SkColorType colorType = outputProperties.colorType();
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(colorType);
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, offsetBounds.width(),
- offsetBounds.height(), SkColorType2GrPixelConfig(colorType),
+ SkBackingFit::kApprox, offsetBounds.width(), offsetBounds.height(),
+ SkColorType2GrPixelConfig(outputProperties.colorType()),
sk_ref_sp(outputProperties.colorSpace())));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index 662343b..ae07ffb 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -466,10 +466,7 @@
sk_sp<GrTextureProxy> srcTexture(input->asTextureProxyRef(context));
SkASSERT(srcTexture);
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
- SkColorType colorType = outputProperties.colorType();
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(colorType);
- GrPixelConfig config = SkColorType2GrPixelConfig(colorType);
+ GrPixelConfig config = SkColorType2GrPixelConfig(outputProperties.colorType());
// setup new clip
const GrFixedClip clip(SkIRect::MakeWH(srcTexture->width(), srcTexture->height()));
@@ -482,7 +479,7 @@
if (radius.fWidth > 0) {
sk_sp<GrRenderTargetContext> dstRTContext(
context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
+ SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
if (!dstRTContext) {
return nullptr;
}
@@ -501,7 +498,7 @@
if (radius.fHeight > 0) {
sk_sp<GrRenderTargetContext> dstRTContext(
context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
+ SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace));
if (!dstRTContext) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
index a56817f..9dad6c2 100644
--- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp
+++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
@@ -315,14 +315,10 @@
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- SkColorType colorType = outputProperties.colorType();
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(colorType);
-
sk_sp<GrRenderTargetContext> renderTargetContext(
context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(),
- SkColorType2GrPixelConfig(colorType),
+ SkBackingFit::kApprox, bounds.width(), bounds.height(),
+ SkColorType2GrPixelConfig(outputProperties.colorType()),
sk_ref_sp(outputProperties.colorSpace())));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index 8a3d5c8..76918de 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -548,7 +548,7 @@
return tex;
},
- backendFormat, desc, fSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact,
+ desc, fSurfaceOrigin, GrMipMapped::kNo, textureType, SkBackingFit::kExact,
SkBudgeted::kNo);
if (!texProxy) {
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index 55f11c6..8198d52 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -20,43 +20,21 @@
GrBackendFormat::GrBackendFormat(GrGLenum format, GrGLenum target)
: fBackend(GrBackendApi::kOpenGL)
- , fValid(true)
- , fGLFormat(format) {
- switch (target) {
- case GR_GL_TEXTURE_2D:
- fTextureType = GrTextureType::k2D;
- break;
- case GR_GL_TEXTURE_RECTANGLE:
- fTextureType = GrTextureType::kRectangle;
- break;
- case GR_GL_TEXTURE_EXTERNAL:
- fTextureType = GrTextureType::kExternal;
- break;
- default:
- SK_ABORT("Unexpected texture target");
- }
+ , fValid(true) {
+ fGL.fTarget = target;
+ fGL.fFormat = format;
}
const GrGLenum* GrBackendFormat::getGLFormat() const {
if (this->isValid() && GrBackendApi::kOpenGL == fBackend) {
- return &fGLFormat;
+ return &fGL.fFormat;
}
return nullptr;
}
const GrGLenum* GrBackendFormat::getGLTarget() const {
if (this->isValid() && GrBackendApi::kOpenGL == fBackend) {
- static constexpr GrGLenum k2D = GR_GL_TEXTURE_2D;
- static constexpr GrGLenum kRect = GR_GL_TEXTURE_RECTANGLE;
- static constexpr GrGLenum kExternal = GR_GL_TEXTURE_EXTERNAL;
- switch (fTextureType) {
- case GrTextureType::k2D:
- return &k2D;
- case GrTextureType::kRectangle:
- return &kRect;
- case GrTextureType::kExternal:
- return &kExternal;
- }
+ return &fGL.fTarget;
}
return nullptr;
}
@@ -66,10 +44,9 @@
#ifdef SK_VULKAN
, fValid(true)
#else
- , fValid(false)
+ ,fValid(false)
#endif
- , fVkFormat(vkFormat)
- , fTextureType(GrTextureType::k2D) {
+ , fVkFormat(vkFormat) {
}
const VkFormat* GrBackendFormat::getVkFormat() const {
@@ -83,8 +60,7 @@
GrBackendFormat::GrBackendFormat(GrMTLPixelFormat mtlFormat)
: fBackend(GrBackendApi::kMetal)
, fValid(true)
- , fMtlFormat(mtlFormat)
- , fTextureType(GrTextureType::k2D) {
+ , fMtlFormat(mtlFormat) {
}
const GrMTLPixelFormat* GrBackendFormat::getMtlFormat() const {
@@ -98,8 +74,7 @@
GrBackendFormat::GrBackendFormat(GrPixelConfig config)
: fBackend(GrBackendApi::kMock)
, fValid(true)
- , fMockFormat(config)
- , fTextureType(GrTextureType::k2D) {
+ , fMockFormat(config) {
}
const GrPixelConfig* GrBackendFormat::getMockFormat() const {
@@ -109,14 +84,6 @@
return nullptr;
}
-GrBackendFormat GrBackendFormat::makeTexture2D() const {
- // TODO: once we support ycbcr conversions in Vulkan we need to check if we are using an
- // external format since they will not be able to be made into a Texture2D.
- GrBackendFormat copy = *this;
- copy.fTextureType = GrTextureType::k2D;
- return copy;
-}
-
GrBackendTexture::GrBackendTexture(int width,
int height,
const GrVkImageInfo& vkInfo)
diff --git a/src/gpu/GrBackendTextureImageGenerator.cpp b/src/gpu/GrBackendTextureImageGenerator.cpp
index 2aa6544..212aded 100644
--- a/src/gpu/GrBackendTextureImageGenerator.cpp
+++ b/src/gpu/GrBackendTextureImageGenerator.cpp
@@ -133,10 +133,11 @@
GrBackendTexture backendTexture = fBackendTexture;
RefHelper* refHelper = fRefHelper;
- GrBackendFormat format =
- context->contextPriv().caps()->createFormatFromBackendTexture(backendTexture);
- SkASSERT(format.isValid());
-
+ 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) {
@@ -175,7 +176,7 @@
return tex;
},
- format, desc, fSurfaceOrigin, mipMapped, SkBackingFit::kExact, SkBudgeted::kNo);
+ desc, fSurfaceOrigin, mipMapped, textureType, SkBackingFit::kExact, SkBudgeted::kNo);
if (!proxy) {
return nullptr;
@@ -192,16 +193,10 @@
// layout change in Vulkan and we do not change the layout of borrowed images.
GrMipMapped mipMapped = willNeedMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
- GrBackendFormat format = proxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrRenderTargetContext> rtContext(
context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, info.width(), info.height(),
- proxy->config(), nullptr, 1, mipMapped, proxy->origin(), nullptr,
- SkBudgeted::kYes));
+ SkBackingFit::kExact, info.width(), info.height(), proxy->config(), nullptr, 1,
+ mipMapped, proxy->origin(), nullptr, SkBudgeted::kYes));
if (!rtContext) {
return nullptr;
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 4e29461..b4b93f4 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -175,13 +175,10 @@
const SkMatrix& origViewMatrix,
const GrShape& shape,
int sampleCnt) {
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
sk_sp<GrRenderTargetContext> rtContext(
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kApprox, maskRect.width(), maskRect.height(),
- kAlpha_8_GrPixelConfig, nullptr, sampleCnt, GrMipMapped::kNo,
- kTopLeft_GrSurfaceOrigin));
+ SkBackingFit::kApprox, maskRect.width(), maskRect.height(), kAlpha_8_GrPixelConfig,
+ nullptr, sampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!rtContext) {
return nullptr;
}
diff --git a/src/gpu/GrCaps.cpp b/src/gpu/GrCaps.cpp
index 64625d9..c2a5a91 100644
--- a/src/gpu/GrCaps.cpp
+++ b/src/gpu/GrCaps.cpp
@@ -9,7 +9,6 @@
#include "GrBackendSurface.h"
#include "GrContextOptions.h"
-#include "GrTypesPriv.h"
#include "GrWindowRectangles.h"
#include "SkJSONWriter.h"
@@ -277,14 +276,9 @@
return true;
}
-GrBackendFormat GrCaps::getBackendFormatFromColorType(SkColorType ct) const {
- return this->getBackendFormatFromGrColorType(SkColorTypeToGrColorType(ct), GrSRGBEncoded::kNo);
-}
-
GrBackendFormat GrCaps::createFormatFromBackendTexture(const GrBackendTexture& backendTex) const {
if (!backendTex.isValid()) {
return GrBackendFormat();
}
return this->onCreateFormatFromBackendTexture(backendTex);
}
-
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index c695ebe..98eaa41 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -303,15 +303,13 @@
virtual bool getYUVAConfigFromBackendFormat(const GrBackendFormat& format,
GrPixelConfig*) const = 0;
- virtual GrBackendFormat getBackendFormatFromGrColorType(GrColorType ct,
- GrSRGBEncoded srgbEncoded) const = 0;
- GrBackendFormat getBackendFormatFromColorType(SkColorType ct) const;
-
+#ifdef GR_TEST_UTILS
/**
* Creates a GrBackendFormat which matches the backend texture. If the backend texture is
* invalid, the function will return the default GrBackendFormat.
*/
GrBackendFormat createFormatFromBackendTexture(const GrBackendTexture&) const;
+#endif
const GrDriverBugWorkarounds& workarounds() const { return fDriverBugWorkarounds; }
@@ -321,11 +319,13 @@
expand them. */
void applyOptionsOverrides(const GrContextOptions& options);
+#ifdef GR_TEST_UTILS
/**
* Subclasses implement this to actually create a GrBackendFormat to match backend texture. At
* this point, the backend texture has already been validated.
*/
virtual GrBackendFormat onCreateFormatFromBackendTexture(const GrBackendTexture&) const = 0;
+#endif
sk_sp<GrShaderCaps> fShaderCaps;
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index ca5043d..92af020 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -344,11 +344,8 @@
return proxy;
}
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
sk_sp<GrRenderTargetContext> rtc(
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
- format,
SkBackingFit::kApprox,
reducedClip.width(),
reducedClip.height(),
@@ -476,15 +473,10 @@
desc.fWidth = maskSpaceIBounds.width();
desc.fHeight = maskSpaceIBounds.height();
desc.fConfig = kAlpha_8_GrPixelConfig;
-
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
-
// MDB TODO: We're going to fill this proxy with an ASAP upload (which is out of order wrt
// to ops), so it can't have any pending IO.
- proxy = proxyProvider->createProxy(format, desc, kTopLeft_GrSurfaceOrigin,
- SkBackingFit::kApprox, SkBudgeted::kYes,
- GrInternalSurfaceFlags::kNoPendingIO);
+ proxy = proxyProvider->createProxy(desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox,
+ SkBudgeted::kYes, GrInternalSurfaceFlags::kNoPendingIO);
auto uploader = skstd::make_unique<GrTDeferredProxyUploader<ClipMaskData>>(reducedClip);
GrTDeferredProxyUploader<ClipMaskData>* uploaderRaw = uploader.get();
diff --git a/src/gpu/GrContext.cpp b/src/gpu/GrContext.cpp
index 46c7607..a941b50 100644
--- a/src/gpu/GrContext.cpp
+++ b/src/gpu/GrContext.cpp
@@ -496,8 +496,7 @@
fContext->contextPriv().caps()->isConfigTexturable(kRGBA_8888_GrPixelConfig) &&
fContext->validPMUPMConversionExists();
- const GrCaps* caps = this->caps();
- if (!caps->surfaceSupportsWritePixels(dstSurface) ||
+ if (!fContext->contextPriv().caps()->surfaceSupportsWritePixels(dstSurface) ||
canvas2DFastPath) {
// We don't expect callers that are skipping flushes to require an intermediate draw.
SkASSERT(!(pixelOpsFlags & kDontFlush_PixelOpsFlag));
@@ -506,25 +505,12 @@
}
GrSurfaceDesc desc;
+ desc.fConfig = canvas2DFastPath ? kRGBA_8888_GrPixelConfig : dstProxy->config();
desc.fWidth = width;
desc.fHeight = height;
desc.fSampleCnt = 1;
-
- GrBackendFormat format;
- if (canvas2DFastPath) {
- desc.fConfig = kRGBA_8888_GrPixelConfig;
- format =
- fContext->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
- } else {
- desc.fConfig = dstProxy->config();
- format = dstProxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return false;
- }
- }
-
auto tempProxy = this->proxyProvider()->createProxy(
- format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
+ desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
if (!tempProxy) {
return false;
}
@@ -697,23 +683,8 @@
desc.fWidth = width;
desc.fHeight = height;
desc.fSampleCnt = 1;
-
- GrBackendFormat format;
- if (canvas2DFastPath) {
- desc.fFlags = kRenderTarget_GrSurfaceFlag;
- desc.fConfig = kRGBA_8888_GrPixelConfig;
- format = this->caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
- } else {
- desc.fFlags = kNone_GrSurfaceFlags;
- desc.fConfig = srcProxy->config();
- format = srcProxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return false;
- }
- }
-
auto tempProxy = this->proxyProvider()->createProxy(
- format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
+ desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kApprox, SkBudgeted::kYes);
if (!tempProxy) {
return false;
}
@@ -893,8 +864,7 @@
}
}
-sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrBackendFormat& format,
- const GrSurfaceDesc& dstDesc,
+sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrSurfaceDesc& dstDesc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
SkBackingFit fit,
@@ -903,10 +873,10 @@
const SkSurfaceProps* props) {
sk_sp<GrTextureProxy> proxy;
if (GrMipMapped::kNo == mipMapped) {
- proxy = this->proxyProvider()->createProxy(format, dstDesc, origin, fit, isDstBudgeted);
+ proxy = this->proxyProvider()->createProxy(dstDesc, origin, fit, isDstBudgeted);
} else {
SkASSERT(SkBackingFit::kExact == fit);
- proxy = this->proxyProvider()->createMipMapProxy(format, dstDesc, origin, isDstBudgeted);
+ proxy = this->proxyProvider()->createMipMapProxy(dstDesc, origin, isDstBudgeted);
}
if (!proxy) {
return nullptr;
@@ -1029,7 +999,6 @@
}
sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format,
SkBackingFit fit,
int width, int height,
GrPixelConfig config,
@@ -1039,28 +1008,17 @@
GrSurfaceOrigin origin,
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted) {
- GrBackendFormat localFormat = format;
SkASSERT(sampleCnt > 0);
if (0 == fContext->contextPriv().caps()->getRenderTargetSampleCount(sampleCnt, config)) {
config = GrPixelConfigFallback(config);
- // TODO: First we should be checking the getRenderTargetSampleCount from the GrBackendFormat
- // and not GrPixelConfig. Besides that, we should implement the fallback in the caps, but
- // for now we just convert the fallback pixel config to an SkColorType and then get the
- // GrBackendFormat from that.
- SkColorType colorType;
- if (!GrPixelConfigToColorType(config, &colorType)) {
- return nullptr;
- }
- localFormat = fContext->fCaps->getBackendFormatFromColorType(colorType);
}
- return this->makeDeferredRenderTargetContext(localFormat, fit, width, height, config,
- std::move(colorSpace), sampleCnt, mipMapped,
- origin, surfaceProps, budgeted);
+ return this->makeDeferredRenderTargetContext(fit, width, height, config, std::move(colorSpace),
+ sampleCnt, mipMapped, origin, surfaceProps,
+ budgeted);
}
sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
- const GrBackendFormat& format,
SkBackingFit fit,
int width, int height,
GrPixelConfig config,
@@ -1084,9 +1042,9 @@
sk_sp<GrTextureProxy> rtp;
if (GrMipMapped::kNo == mipMapped) {
- rtp = fContext->fProxyProvider->createProxy(format, desc, origin, fit, budgeted);
+ rtp = fContext->fProxyProvider->createProxy(desc, origin, fit, budgeted);
} else {
- rtp = fContext->fProxyProvider->createMipMapProxy(format, desc, origin, budgeted);
+ rtp = fContext->fProxyProvider->createMipMapProxy(desc, origin, budgeted);
}
if (!rtp) {
return nullptr;
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index f62979a..ba7b0cf 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -12,7 +12,6 @@
#include "GrSurfaceContext.h"
#include "text/GrAtlasManager.h"
-class GrBackendFormat;
class GrBackendRenderTarget;
class GrOpMemoryPool;
class GrOnFlushCallbackObject;
@@ -44,8 +43,7 @@
sk_sp<SkColorSpace> = nullptr,
const SkSurfaceProps* = nullptr);
- sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrBackendFormat&,
- const GrSurfaceDesc&,
+ sk_sp<GrSurfaceContext> makeDeferredSurfaceContext(const GrSurfaceDesc&,
GrSurfaceOrigin,
GrMipMapped,
SkBackingFit,
@@ -219,7 +217,6 @@
* renderTargetContexts created via this entry point.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
- const GrBackendFormat& format,
SkBackingFit fit,
int width, int height,
GrPixelConfig config,
@@ -236,7 +233,6 @@
* SRGB-ness will be preserved.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format,
SkBackingFit fit,
int width, int height,
GrPixelConfig config,
diff --git a/src/gpu/GrDrawOpAtlas.cpp b/src/gpu/GrDrawOpAtlas.cpp
index 6918123..88308e4 100644
--- a/src/gpu/GrDrawOpAtlas.cpp
+++ b/src/gpu/GrDrawOpAtlas.cpp
@@ -34,13 +34,12 @@
}
std::unique_ptr<GrDrawOpAtlas> GrDrawOpAtlas::Make(GrProxyProvider* proxyProvider,
- const GrBackendFormat& format,
GrPixelConfig config, int width,
int height, int numPlotsX, int numPlotsY,
AllowMultitexturing allowMultitexturing,
GrDrawOpAtlas::EvictionFunc func, void* data) {
- std::unique_ptr<GrDrawOpAtlas> atlas(new GrDrawOpAtlas(proxyProvider, format, config, width,
- height, numPlotsX, numPlotsY,
+ std::unique_ptr<GrDrawOpAtlas> atlas(new GrDrawOpAtlas(proxyProvider, config, width, height,
+ numPlotsX, numPlotsY,
allowMultitexturing));
if (!atlas->getProxies()[0]) {
return nullptr;
@@ -179,11 +178,10 @@
///////////////////////////////////////////////////////////////////////////////
-GrDrawOpAtlas::GrDrawOpAtlas(GrProxyProvider* proxyProvider, const GrBackendFormat& format,
+GrDrawOpAtlas::GrDrawOpAtlas(GrProxyProvider* proxyProvider,
GrPixelConfig config, int width, int height,
int numPlotsX, int numPlotsY, AllowMultitexturing allowMultitexturing)
- : fFormat(format)
- , fPixelConfig(config)
+ : fPixelConfig(config)
, fTextureWidth(width)
, fTextureHeight(height)
, fAtlasGeneration(kInvalidAtlasGeneration + 1)
@@ -523,7 +521,7 @@
int numPlotsY = fTextureHeight/fPlotHeight;
for (uint32_t i = 0; i < this->maxPages(); ++i) {
- fProxies[i] = proxyProvider->createProxy(fFormat, desc, kTopLeft_GrSurfaceOrigin,
+ fProxies[i] = proxyProvider->createProxy(desc, kTopLeft_GrSurfaceOrigin,
SkBackingFit::kExact, SkBudgeted::kYes, GrInternalSurfaceFlags::kNoPendingIO);
if (!fProxies[i]) {
return false;
@@ -649,3 +647,4 @@
constexpr int GrDrawOpAtlasConfig::kMaxDistanceFieldDim;
constexpr int GrDrawOpAtlasConfig::kPlotSize;
+
diff --git a/src/gpu/GrDrawOpAtlas.h b/src/gpu/GrDrawOpAtlas.h
index c9d5546..2e8f3e7 100644
--- a/src/gpu/GrDrawOpAtlas.h
+++ b/src/gpu/GrDrawOpAtlas.h
@@ -90,9 +90,7 @@
* eviction occurs
* @return An initialized GrDrawOpAtlas, or nullptr if creation fails
*/
- static std::unique_ptr<GrDrawOpAtlas> Make(GrProxyProvider*,
- const GrBackendFormat& format,
- GrPixelConfig,
+ static std::unique_ptr<GrDrawOpAtlas> Make(GrProxyProvider*, GrPixelConfig,
int width, int height,
int numPlotsX, int numPlotsY,
AllowMultitexturing allowMultitexturing,
@@ -242,9 +240,8 @@
void setMaxPages_TestingOnly(uint32_t maxPages);
private:
- GrDrawOpAtlas(GrProxyProvider*, const GrBackendFormat& format, GrPixelConfig, int width,
- int height, int numPlotsX, int numPlotsY,
- AllowMultitexturing allowMultitexturing);
+ GrDrawOpAtlas(GrProxyProvider*, GrPixelConfig, int width, int height, int numPlotsX,
+ int numPlotsY, AllowMultitexturing allowMultitexturing);
/**
* The backing GrTexture for a GrDrawOpAtlas is broken into a spatial grid of Plots. The Plots
@@ -380,7 +377,6 @@
plot->resetRects();
}
- GrBackendFormat fFormat;
GrPixelConfig fPixelConfig;
int fTextureWidth;
int fTextureHeight;
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index 33d116c..d63c5ac 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -14,6 +14,48 @@
#include "GrSurfaceProxy.h"
sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
+ const GrSurfaceDesc& desc,
+ GrSurfaceOrigin origin,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props) {
+ GrSurfaceDesc tmpDesc = desc;
+ tmpDesc.fFlags |= kRenderTarget_GrSurfaceFlag;
+
+ auto proxyProvider = fDrawingMgr->getContext()->contextPriv().proxyProvider();
+ auto resourceProvider = fDrawingMgr->getContext()->contextPriv().resourceProvider();
+
+ // Because this is being allocated at the start of a flush we must ensure the proxy
+ // will, when instantiated, have no pending IO.
+ // TODO: fold the kNoPendingIO_Flag into GrSurfaceFlags?
+ sk_sp<GrSurfaceProxy> proxy =
+ proxyProvider->createProxy(tmpDesc, origin, SkBackingFit::kExact, SkBudgeted::kYes,
+ GrInternalSurfaceFlags::kNoPendingIO);
+ if (!proxy || !proxy->asRenderTargetProxy()) {
+ return nullptr;
+ }
+
+ sk_sp<GrRenderTargetContext> renderTargetContext(
+ fDrawingMgr->makeRenderTargetContext(std::move(proxy),
+ std::move(colorSpace),
+ props, false));
+
+ if (!renderTargetContext) {
+ return nullptr;
+ }
+
+ // Since this is at flush time and these won't be allocated for us by the GrResourceAllocator
+ // we have to manually ensure it is allocated here. The proxy had best have been created
+ // with the kNoPendingIO flag!
+ if (!renderTargetContext->asSurfaceProxy()->instantiate(resourceProvider)) {
+ return nullptr;
+ }
+
+ renderTargetContext->discard();
+
+ return renderTargetContext;
+}
+
+sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
sk_sp<GrSurfaceProxy> proxy,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
diff --git a/src/gpu/GrOnFlushResourceProvider.h b/src/gpu/GrOnFlushResourceProvider.h
index 9ff2384..c30ec61 100644
--- a/src/gpu/GrOnFlushResourceProvider.h
+++ b/src/gpu/GrOnFlushResourceProvider.h
@@ -66,12 +66,10 @@
public:
explicit GrOnFlushResourceProvider(GrDrawingManager* drawingMgr) : fDrawingMgr(drawingMgr) {}
-#if 0
sk_sp<GrRenderTargetContext> makeRenderTargetContext(const GrSurfaceDesc&,
GrSurfaceOrigin,
sk_sp<SkColorSpace>,
const SkSurfaceProps*);
-#endif
sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
sk_sp<SkColorSpace>,
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 3259f28..c1f8fad 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -194,11 +194,6 @@
return nullptr;
}
- GrBackendFormat format = fCaps->getBackendFormatFromColorType(info.colorType());
- if (!format.isValid()) {
- return nullptr;
- }
-
if (!this->caps()->isConfigTexturable(config)) {
SkBitmap copy8888;
if (!copy8888.tryAllocPixels(info.makeColorType(kRGBA_8888_SkColorType)) ||
@@ -251,7 +246,8 @@
return resourceProvider->createTexture(desc, budgeted, fit, mipLevel,
resourceProviderFlags);
},
- format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, surfaceFlags, fit, budgeted);
+ desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, GrTextureType::k2D, surfaceFlags, fit,
+ budgeted);
if (!proxy) {
return nullptr;
@@ -270,8 +266,7 @@
return proxy;
}
-sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxy(const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
SkBudgeted budgeted) {
ASSERT_SINGLE_OWNER
@@ -280,8 +275,8 @@
return nullptr;
}
- return this->createProxy(format, desc, origin, GrMipMapped::kYes, SkBackingFit::kExact,
- budgeted, GrInternalSurfaceFlags::kNone);
+ return this->createProxy(desc, origin, GrMipMapped::kYes, SkBackingFit::kExact, budgeted,
+ GrInternalSurfaceFlags::kNone);
}
sk_sp<GrTextureProxy> GrProxyProvider::createMipMapProxyFromBitmap(const SkBitmap& bitmap) {
@@ -307,11 +302,6 @@
SkBackingFit::kExact);
}
- const GrBackendFormat format = fCaps->getBackendFormatFromColorType(bitmap.info().colorType());
- if (!format.isValid()) {
- return nullptr;
- }
-
GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(bitmap.info());
if (!this->caps()->isConfigTexturable(desc.fConfig)) {
SkBitmap copy8888;
@@ -359,8 +349,8 @@
return resourceProvider->createTexture(desc, SkBudgeted::kYes, texels.get(),
mipLevelCount);
},
- format, desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kYes, SkBackingFit::kExact,
- SkBudgeted::kYes);
+ desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kYes, GrTextureType::k2D,
+ SkBackingFit::kExact, SkBudgeted::kYes);
if (!proxy) {
return nullptr;
@@ -376,8 +366,7 @@
return proxy;
}
-sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+sk_sp<GrTextureProxy> GrProxyProvider::createProxy(const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
SkBackingFit fit,
@@ -403,12 +392,12 @@
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(), format, copyDesc,
- origin, mipMapped,
+ return sk_sp<GrTextureProxy>(new GrTextureRenderTargetProxy(*this->caps(), copyDesc, origin,
+ mipMapped, GrTextureType::k2D,
fit, budgeted, surfaceFlags));
}
- return sk_sp<GrTextureProxy>(new GrTextureProxy(format, copyDesc, origin, mipMapped,
+ return sk_sp<GrTextureProxy>(new GrTextureProxy(copyDesc, origin, mipMapped, GrTextureType::k2D,
fit, budgeted, surfaceFlags));
}
@@ -523,36 +512,36 @@
}
sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
- const GrBackendFormat& format,
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
+ GrTextureType textureType,
SkBackingFit fit,
SkBudgeted budgeted) {
- return this->createLazyProxy(std::move(callback), format, desc, origin, mipMapped,
+ return this->createLazyProxy(std::move(callback), desc, origin, mipMapped, textureType,
GrInternalSurfaceFlags::kNone, fit, budgeted);
}
sk_sp<GrTextureProxy> GrProxyProvider::createLazyProxy(LazyInstantiateCallback&& callback,
- const GrBackendFormat& format,
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
+ GrTextureType textureType,
GrInternalSurfaceFlags surfaceFlags,
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), format, 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 GrBackendFormat& format,
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
+ GrTextureType textureType,
GrInternalSurfaceFlags surfaceFlags,
SkBackingFit fit,
SkBudgeted budgeted,
@@ -578,16 +567,17 @@
return sk_sp<GrTextureProxy>(
SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags)
- ? new GrTextureRenderTargetProxy(std::move(callback), lazyType, format, desc,
- origin, mipMapped, fit, budgeted, surfaceFlags)
- : new GrTextureProxy(std::move(callback), lazyType, format, desc, origin,
- mipMapped, fit, budgeted, surfaceFlags));
+ ? new GrTextureRenderTargetProxy(std::move(callback), lazyType, desc, origin,
+ mipMapped, textureType, fit, budgeted,
+ surfaceFlags)
+ : new GrTextureProxy(std::move(callback), lazyType, desc, origin, mipMapped,
+ textureType, fit, budgeted, surfaceFlags));
}
sk_sp<GrRenderTargetProxy> GrProxyProvider::createLazyRenderTargetProxy(
- LazyInstantiateCallback&& callback, const GrBackendFormat& format,
- const GrSurfaceDesc& desc, GrSurfaceOrigin origin, GrInternalSurfaceFlags surfaceFlags,
- const TextureInfo* textureInfo, SkBackingFit fit, SkBudgeted budgeted) {
+ LazyInstantiateCallback&& callback, const GrSurfaceDesc& desc, GrSurfaceOrigin origin,
+ GrInternalSurfaceFlags surfaceFlags, const TextureInfo* textureInfo, SkBackingFit fit,
+ SkBudgeted budgeted) {
SkASSERT((desc.fWidth <= 0 && desc.fHeight <= 0) ||
(desc.fWidth > 0 && desc.fHeight > 0));
@@ -613,16 +603,15 @@
if (textureInfo) {
return sk_sp<GrRenderTargetProxy>(new GrTextureRenderTargetProxy(
- std::move(callback), lazyType, format, desc, origin, textureInfo->fMipMapped,
- fit, budgeted, surfaceFlags));
+ std::move(callback), lazyType, desc, origin, textureInfo->fMipMapped,
+ textureInfo->fTextureType, fit, budgeted, surfaceFlags));
}
return sk_sp<GrRenderTargetProxy>(new GrRenderTargetProxy(
- std::move(callback), lazyType, format, desc, origin, fit, budgeted, surfaceFlags));
+ std::move(callback), lazyType, desc, origin, fit, budgeted, surfaceFlags));
}
sk_sp<GrTextureProxy> GrProxyProvider::MakeFullyLazyProxy(LazyInstantiateCallback&& callback,
- const GrBackendFormat& format,
Renderable renderable,
GrSurfaceOrigin origin,
GrPixelConfig config,
@@ -640,14 +629,15 @@
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, format, desc,
- origin, GrMipMapped::kNo, SkBackingFit::kApprox, SkBudgeted::kYes,
- surfaceFlags)
+ std::move(callback), LazyInstantiationType::kSingleUse, desc, origin,
+ GrMipMapped::kNo, kTextureType, SkBackingFit::kApprox,
+ SkBudgeted::kYes, surfaceFlags)
: new GrTextureProxy(std::move(callback), LazyInstantiationType::kSingleUse,
- format, desc, origin, GrMipMapped::kNo,
+ desc, origin, GrMipMapped::kNo, kTextureType,
SkBackingFit::kApprox, SkBudgeted::kYes, surfaceFlags));
}
diff --git a/src/gpu/GrProxyProvider.h b/src/gpu/GrProxyProvider.h
index 1e26f51..26dc6e9 100644
--- a/src/gpu/GrProxyProvider.h
+++ b/src/gpu/GrProxyProvider.h
@@ -76,8 +76,7 @@
* simply has space allocated for the mips. We will allocated the full amount of mip levels
* based on the width and height in the GrSurfaceDesc.
*/
- sk_sp<GrTextureProxy> createMipMapProxy(const GrBackendFormat&, const GrSurfaceDesc&,
- GrSurfaceOrigin, SkBudgeted);
+ sk_sp<GrTextureProxy> createMipMapProxy(const GrSurfaceDesc&, GrSurfaceOrigin, SkBudgeted);
/*
* Creates a new mipmapped texture proxy for the bitmap with mip levels generated by the cpu.
@@ -87,16 +86,14 @@
/*
* Create a GrSurfaceProxy without any data.
*/
- sk_sp<GrTextureProxy> createProxy(const GrBackendFormat&, const GrSurfaceDesc&, GrSurfaceOrigin,
- GrMipMapped, SkBackingFit, SkBudgeted,
- GrInternalSurfaceFlags);
+ sk_sp<GrTextureProxy> createProxy(const GrSurfaceDesc&, GrSurfaceOrigin, GrMipMapped,
+ SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
sk_sp<GrTextureProxy> createProxy(
- const GrBackendFormat& format, const GrSurfaceDesc& desc,
- GrSurfaceOrigin origin, SkBackingFit fit, SkBudgeted budgeted,
+ const GrSurfaceDesc& desc, GrSurfaceOrigin origin,
+ SkBackingFit fit, SkBudgeted budgeted,
GrInternalSurfaceFlags surfaceFlags = GrInternalSurfaceFlags::kNone) {
- return this->createProxy(format, desc, origin, GrMipMapped::kNo, fit, budgeted,
- surfaceFlags);
+ return this->createProxy(desc, origin, GrMipMapped::kNo, fit, budgeted, surfaceFlags);
}
// These match the definitions in SkImage & GrTexture.h, for whence they came
@@ -153,22 +150,21 @@
* It also must support being passed in a null GrResourceProvider. When this happens, the
* callback should cleanup any resources it captured and return an empty sk_sp<GrTextureProxy>.
*/
- sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrBackendFormat&,
- const GrSurfaceDesc&, GrSurfaceOrigin, GrMipMapped,
+ sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrSurfaceDesc&,
+ GrSurfaceOrigin, GrMipMapped, GrTextureType,
GrInternalSurfaceFlags, SkBackingFit, SkBudgeted,
LazyInstantiationType);
- sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrBackendFormat&,
- const GrSurfaceDesc&, GrSurfaceOrigin, GrMipMapped,
+ sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrSurfaceDesc&,
+ GrSurfaceOrigin, GrMipMapped, GrTextureType,
GrInternalSurfaceFlags, SkBackingFit, SkBudgeted);
- sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrBackendFormat&,
- const GrSurfaceDesc&, GrSurfaceOrigin, GrMipMapped,
- SkBackingFit, SkBudgeted);
+ sk_sp<GrTextureProxy> createLazyProxy(LazyInstantiateCallback&&, const GrSurfaceDesc&,
+ GrSurfaceOrigin, GrMipMapped, GrTextureType, SkBackingFit,
+ SkBudgeted);
/** A null TextureInfo indicates a non-textureable render target. */
sk_sp<GrRenderTargetProxy> createLazyRenderTargetProxy(LazyInstantiateCallback&&,
- const GrBackendFormat&,
const GrSurfaceDesc&,
GrSurfaceOrigin origin,
GrInternalSurfaceFlags,
@@ -180,8 +176,7 @@
* Fully lazy proxies have unspecified width and height. Methods that rely on those values
* (e.g., width, height, getBoundsRect) should be avoided.
*/
- static sk_sp<GrTextureProxy> MakeFullyLazyProxy(LazyInstantiateCallback&&,
- const GrBackendFormat&, Renderable,
+ static sk_sp<GrTextureProxy> MakeFullyLazyProxy(LazyInstantiateCallback&&, Renderable,
GrSurfaceOrigin, GrPixelConfig, const GrCaps&);
// 'proxy' is about to be used as a texture src or drawn to. This query can be used to
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 7920cf1..fc446bf 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1865,10 +1865,8 @@
fit = SkBackingFit::kApprox;
}
- SkASSERT(rtProxy->backendFormat().textureType() == GrTextureType::k2D);
- const GrBackendFormat& format = rtProxy->backendFormat();
sk_sp<GrSurfaceContext> sContext = fContext->contextPriv().makeDeferredSurfaceContext(
- format, desc, origin, GrMipMapped::kNo, fit, SkBudgeted::kYes,
+ desc, origin, GrMipMapped::kNo, fit, SkBudgeted::kYes,
sk_ref_sp(this->colorSpaceInfo().colorSpace()));
if (!sContext) {
SkDebugf("setupDstTexture: surfaceContext creation failed.\n");
diff --git a/src/gpu/GrRenderTargetProxy.cpp b/src/gpu/GrRenderTargetProxy.cpp
index 39fdee3..5488625 100644
--- a/src/gpu/GrRenderTargetProxy.cpp
+++ b/src/gpu/GrRenderTargetProxy.cpp
@@ -19,11 +19,10 @@
// Deferred version
// TODO: we can probably munge the 'desc' in both the wrapped and deferred
// cases to make the sampleConfig/numSamples stuff more rational.
-GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrBackendFormat& format,
- const GrSurfaceDesc& desc, GrSurfaceOrigin origin,
- SkBackingFit fit, SkBudgeted budgeted,
- GrInternalSurfaceFlags surfaceFlags)
- : INHERITED(format, desc, origin, fit, budgeted, surfaceFlags)
+GrRenderTargetProxy::GrRenderTargetProxy(const GrCaps& caps, const GrSurfaceDesc& desc,
+ GrSurfaceOrigin origin, SkBackingFit fit,
+ SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags)
+ : INHERITED(desc, origin, fit, budgeted, surfaceFlags)
, fSampleCnt(desc.fSampleCnt)
, fNeedsStencil(false) {
// Since we know the newly created render target will be internal, we are able to precompute
@@ -38,12 +37,10 @@
// Lazy-callback version
GrRenderTargetProxy::GrRenderTargetProxy(LazyInstantiateCallback&& callback,
- LazyInstantiationType lazyType,
- const GrBackendFormat& format, const GrSurfaceDesc& desc,
- GrSurfaceOrigin origin, SkBackingFit fit,
+ LazyInstantiationType lazyType, const GrSurfaceDesc& desc,
+ GrSurfaceOrigin origin, SkBackingFit fit,
SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags)
- : INHERITED(std::move(callback), lazyType, format, desc, origin, fit, budgeted,
- surfaceFlags)
+ : INHERITED(std::move(callback), lazyType, desc, origin, fit, budgeted, surfaceFlags)
, fSampleCnt(desc.fSampleCnt)
, fNeedsStencil(false) {
SkASSERT(SkToBool(kRenderTarget_GrSurfaceFlag & desc.fFlags));
diff --git a/src/gpu/GrSoftwarePathRenderer.cpp b/src/gpu/GrSoftwarePathRenderer.cpp
index 68e51c9..05b2795 100644
--- a/src/gpu/GrSoftwarePathRenderer.cpp
+++ b/src/gpu/GrSoftwarePathRenderer.cpp
@@ -181,12 +181,9 @@
desc.fHeight = height;
desc.fConfig = kAlpha_8_GrPixelConfig;
- const GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
-
// MDB TODO: We're going to fill this proxy with an ASAP upload (which is out of order wrt to
// ops), so it can't have any pending IO.
- return proxyProvider->createProxy(format, desc, kTopLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes,
+ return proxyProvider->createProxy(desc, kTopLeft_GrSurfaceOrigin, fit, SkBudgeted::kYes,
GrInternalSurfaceFlags::kNoPendingIO);
}
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index ac650af..c0e65c0 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -49,11 +49,9 @@
// Lazy-callback version
GrSurfaceProxy::GrSurfaceProxy(LazyInstantiateCallback&& callback, LazyInstantiationType lazyType,
- const GrBackendFormat& format, const GrSurfaceDesc& desc,
- GrSurfaceOrigin origin, SkBackingFit fit,
+ const GrSurfaceDesc& desc, GrSurfaceOrigin origin, SkBackingFit fit,
SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags)
: fSurfaceFlags(surfaceFlags)
- , fFormat(format)
, fConfig(desc.fConfig)
, fWidth(desc.fWidth)
, fHeight(desc.fHeight)
@@ -65,7 +63,6 @@
, fNeedsClear(SkToBool(desc.fFlags & kPerformInitialClear_GrSurfaceFlag))
, fGpuMemorySize(kInvalidGpuMemorySize)
, fLastOpList(nullptr) {
- SkASSERT(fFormat.isValid());
// NOTE: the default fUniqueID ctor pulls a value from the same pool as the GrGpuResources.
if (fLazyInstantiateCallback) {
SkASSERT(is_valid_fully_lazy(desc, fit) || is_valid_partially_lazy(desc));
@@ -78,7 +75,6 @@
GrSurfaceProxy::GrSurfaceProxy(sk_sp<GrSurface> surface, GrSurfaceOrigin origin, SkBackingFit fit)
: INHERITED(std::move(surface))
, fSurfaceFlags(fTarget->surfacePriv().flags())
- , fFormat(fTarget->backendFormat())
, fConfig(fTarget->config())
, fWidth(fTarget->width())
, fHeight(fTarget->height())
@@ -89,7 +85,6 @@
, fNeedsClear(false)
, fGpuMemorySize(kInvalidGpuMemorySize)
, fLastOpList(nullptr) {
- SkASSERT(fFormat.isValid());
}
GrSurfaceProxy::~GrSurfaceProxy() {
@@ -341,13 +336,8 @@
dstDesc.fHeight = srcRect.height();
dstDesc.fConfig = src->config();
- GrBackendFormat format = src->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrSurfaceContext> dstContext(context->contextPriv().makeDeferredSurfaceContext(
- format, dstDesc, src->origin(), mipMapped, SkBackingFit::kExact, budgeted));
+ dstDesc, src->origin(), mipMapped, SkBackingFit::kExact, budgeted));
if (!dstContext) {
return nullptr;
}
@@ -368,14 +358,8 @@
sk_sp<GrSurfaceContext> GrSurfaceProxy::TestCopy(GrContext* context, const GrSurfaceDesc& dstDesc,
GrSurfaceOrigin origin, GrSurfaceProxy* srcProxy) {
SkASSERT(LazyState::kFully != srcProxy->lazyInstantiationState());
-
- GrBackendFormat format = srcProxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrSurfaceContext> dstContext(context->contextPriv().makeDeferredSurfaceContext(
- format, dstDesc, origin, GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kYes));
+ dstDesc, origin, GrMipMapped::kNo, SkBackingFit::kExact, SkBudgeted::kYes));
if (!dstContext) {
return nullptr;
}
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 97417f9..cbff079 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -44,15 +44,10 @@
}
}
- GrBackendFormat format = inputProxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrRenderTargetContext> copyRTC =
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, dstRect.width(), dstRect.height(),
- inputProxy->config(), nullptr, 1, mipMapped, inputProxy->origin());
+ SkBackingFit::kExact, dstRect.width(), dstRect.height(), inputProxy->config(),
+ nullptr, 1, mipMapped, inputProxy->origin());
if (!copyRTC) {
return nullptr;
}
diff --git a/src/gpu/GrTextureProxy.cpp b/src/gpu/GrTextureProxy.cpp
index 517b832..a65f241 100644
--- a/src/gpu/GrTextureProxy.cpp
+++ b/src/gpu/GrTextureProxy.cpp
@@ -16,35 +16,36 @@
#include "GrTexturePriv.h"
// Deferred version - with data
-GrTextureProxy::GrTextureProxy(const GrBackendFormat& format, const GrSurfaceDesc& srcDesc,
- GrMipMapped mipMapped, SkBackingFit fit, SkBudgeted budgeted,
+GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, GrMipMapped mipMapped,
+ GrTextureType textureType, SkBackingFit fit, SkBudgeted budgeted,
const void* srcData, size_t /*rowBytes*/,
GrInternalSurfaceFlags surfaceFlags)
- : INHERITED(format, srcDesc, kTopLeft_GrSurfaceOrigin, fit, budgeted, surfaceFlags)
+ : INHERITED(srcDesc, kTopLeft_GrSurfaceOrigin, fit, budgeted, surfaceFlags)
, fMipMapped(mipMapped)
+ , fTextureType(textureType)
, fProxyProvider(nullptr)
, fDeferredUploader(nullptr) {
SkASSERT(!srcData); // currently handled in Make()
}
// Deferred version - no data
-GrTextureProxy::GrTextureProxy(const GrBackendFormat& format, const GrSurfaceDesc& srcDesc,
- GrSurfaceOrigin origin, GrMipMapped mipMapped,
- SkBackingFit fit, SkBudgeted budgeted,
- GrInternalSurfaceFlags surfaceFlags)
- : INHERITED(format, srcDesc, origin, fit, budgeted, surfaceFlags)
+GrTextureProxy::GrTextureProxy(const GrSurfaceDesc& srcDesc, GrSurfaceOrigin origin,
+ 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 GrBackendFormat& format, const GrSurfaceDesc& desc,
- GrSurfaceOrigin origin, GrMipMapped mipMapped, SkBackingFit fit,
+ const GrSurfaceDesc& desc, GrSurfaceOrigin origin,
+ GrMipMapped mipMapped, GrTextureType textureType, SkBackingFit fit,
SkBudgeted budgeted, GrInternalSurfaceFlags surfaceFlags)
- : INHERITED(std::move(callback), lazyType, format, desc, origin, fit, budgeted,
- surfaceFlags)
+ : INHERITED(std::move(callback), lazyType, desc, origin, fit, budgeted, surfaceFlags)
, fMipMapped(mipMapped)
+ , fTextureType(textureType)
, fProxyProvider(nullptr)
, fDeferredUploader(nullptr) {}
@@ -52,6 +53,7 @@
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()) {
@@ -166,7 +168,7 @@
SkASSERT(surface->asTexture());
SkASSERT(GrMipMapped::kNo == this->proxyMipMapped() ||
GrMipMapped::kYes == surface->asTexture()->texturePriv().mipMapped());
- SkASSERT(surface->asTexture()->texturePriv().textureType() == this->textureType());
+ SkASSERT(surface->asTexture()->texturePriv().textureType() == fTextureType);
}
#endif
diff --git a/src/gpu/GrTextureRenderTargetProxy.cpp b/src/gpu/GrTextureRenderTargetProxy.cpp
index a665270..fba48e7 100644
--- a/src/gpu/GrTextureRenderTargetProxy.cpp
+++ b/src/gpu/GrTextureRenderTargetProxy.cpp
@@ -19,35 +19,34 @@
// This class is virtually derived from GrSurfaceProxy (via both GrTextureProxy and
// GrRenderTargetProxy) so its constructor must be explicitly called.
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(const GrCaps& caps,
- const GrBackendFormat& format,
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
+ GrTextureType textureType,
SkBackingFit fit,
SkBudgeted budgeted,
GrInternalSurfaceFlags surfaceFlags)
- : GrSurfaceProxy(format, desc, origin, fit, budgeted, surfaceFlags)
+ : GrSurfaceProxy(desc, origin, fit, budgeted, surfaceFlags)
// for now textures w/ data are always wrapped
- , GrRenderTargetProxy(caps, format, desc, origin, fit, budgeted, surfaceFlags)
- , GrTextureProxy(format, desc, origin, mipMapped, fit, budgeted, surfaceFlags) {}
+ , GrRenderTargetProxy(caps, desc, origin, fit, budgeted, surfaceFlags)
+ , GrTextureProxy(desc, origin, mipMapped, textureType, fit, budgeted, surfaceFlags) {}
// Lazy-callback version
GrTextureRenderTargetProxy::GrTextureRenderTargetProxy(LazyInstantiateCallback&& callback,
LazyInstantiationType lazyType,
- const GrBackendFormat& format,
const GrSurfaceDesc& desc,
GrSurfaceOrigin origin,
GrMipMapped mipMapped,
+ GrTextureType textureType,
SkBackingFit fit,
SkBudgeted budgeted,
GrInternalSurfaceFlags surfaceFlags)
- : GrSurfaceProxy(std::move(callback), lazyType, format, desc, origin, fit, budgeted,
- 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.
- , GrRenderTargetProxy(LazyInstantiateCallback(), lazyType, format, desc, origin, fit,
- budgeted, surfaceFlags)
- , GrTextureProxy(LazyInstantiateCallback(), lazyType, format, desc, origin, mipMapped,
+ , GrRenderTargetProxy(LazyInstantiateCallback(), lazyType, desc, origin, fit, budgeted,
+ surfaceFlags)
+ , GrTextureProxy(LazyInstantiateCallback(), lazyType, desc, origin, mipMapped, textureType,
fit, budgeted, surfaceFlags) {}
// Wrapped version
diff --git a/src/gpu/GrTextureRenderTargetProxy.h b/src/gpu/GrTextureRenderTargetProxy.h
index 18c1419..a60c230 100644
--- a/src/gpu/GrTextureRenderTargetProxy.h
+++ b/src/gpu/GrTextureRenderTargetProxy.h
@@ -28,14 +28,13 @@
friend class GrProxyProvider; // for ctors
// Deferred version
- GrTextureRenderTargetProxy(const GrCaps&, const GrBackendFormat&, const GrSurfaceDesc&,
- GrSurfaceOrigin, GrMipMapped, SkBackingFit, SkBudgeted,
- GrInternalSurfaceFlags);
+ GrTextureRenderTargetProxy(const GrCaps&, const GrSurfaceDesc&, GrSurfaceOrigin, GrMipMapped,
+ GrTextureType, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
// Lazy-callback version
GrTextureRenderTargetProxy(LazyInstantiateCallback&&, LazyInstantiationType,
- const GrBackendFormat&, const GrSurfaceDesc& desc, GrSurfaceOrigin,
- GrMipMapped, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
+ const GrSurfaceDesc& desc, GrSurfaceOrigin, GrMipMapped,
+ GrTextureType, SkBackingFit, SkBudgeted, GrInternalSurfaceFlags);
// Wrapped version
GrTextureRenderTargetProxy(sk_sp<GrSurface>, GrSurfaceOrigin);
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 16027df..eedde34 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -101,9 +101,7 @@
cachedData->unref();
}
-sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx,
- const GrBackendFormat& format,
- const GrSurfaceDesc& desc,
+sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrSurfaceDesc& desc,
SkColorSpace* srcColorSpace,
SkColorSpace* dstColorSpace) {
SkYUVASizeInfo yuvSizeInfo;
@@ -158,7 +156,7 @@
// TODO: investigate preallocating mip maps here
sk_sp<GrRenderTargetContext> renderTargetContext(
ctx->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, desc.fWidth, desc.fHeight, desc.fConfig, nullptr,
+ SkBackingFit::kExact, desc.fWidth, desc.fHeight, desc.fConfig, nullptr,
desc.fSampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/gpu/GrYUVProvider.h b/src/gpu/GrYUVProvider.h
index 633ccfb..e62a2ee 100644
--- a/src/gpu/GrYUVProvider.h
+++ b/src/gpu/GrYUVProvider.h
@@ -14,7 +14,6 @@
#include "SkYUVASizeInfo.h"
class GrContext;
-class GrBackendFormat;
struct GrSurfaceDesc;
class GrTexture;
class GrTextureProxy;
@@ -41,9 +40,7 @@
*
* On failure (e.g. the provider had no data), this returns NULL.
*/
- sk_sp<GrTextureProxy> refAsTextureProxy(GrContext*,
- const GrBackendFormat&,
- const GrSurfaceDesc&,
+ sk_sp<GrTextureProxy> refAsTextureProxy(GrContext*, const GrSurfaceDesc&,
SkColorSpace* srcColorSpace,
SkColorSpace* dstColorSpace);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index a29336e..daa86fc 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -164,12 +164,10 @@
if (kUnknown_GrPixelConfig == config) {
return nullptr;
}
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(origInfo.colorType());
// This method is used to create SkGpuDevice's for SkSurface_Gpus. In this case
// they need to be exact.
return context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact,
+ SkBackingFit::kExact,
origInfo.width(), origInfo.height(),
config, origInfo.refColorSpace(), sampleCount,
mipMapped, origin, surfaceProps, budgeted);
@@ -1751,21 +1749,14 @@
: SkBackingFit::kExact;
GrPixelConfig config = fRenderTargetContext->colorSpaceInfo().config();
- const GrBackendFormat& origFormat = fRenderTargetContext->asSurfaceProxy()->backendFormat();
- GrBackendFormat format = origFormat.makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
if (kRGBA_1010102_GrPixelConfig == config) {
// If the original device is 1010102, fall back to 8888 so that we have a usable alpha
// channel in the layer.
config = kRGBA_8888_GrPixelConfig;
- format =
- fContext->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
}
sk_sp<GrRenderTargetContext> rtc(fContext->contextPriv().makeDeferredRenderTargetContext(
- format, fit, cinfo.fInfo.width(), cinfo.fInfo.height(), config,
+ fit, cinfo.fInfo.width(), cinfo.fInfo.height(), config,
fRenderTargetContext->colorSpaceInfo().refColorSpace(),
fRenderTargetContext->numStencilSamples(), GrMipMapped::kNo,
kBottomLeft_GrSurfaceOrigin, &props));
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 0a6033e..168cce6 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -160,13 +160,8 @@
desc.fConfig = baseProxy->config();
desc.fSampleCnt = 1;
- GrBackendFormat format = baseProxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrTextureProxy> proxy =
- proxyProvider->createMipMapProxy(format, desc, baseProxy->origin(), SkBudgeted::kYes);
+ proxyProvider->createMipMapProxy(desc, baseProxy->origin(), SkBudgeted::kYes);
if (!proxy) {
return nullptr;
}
diff --git a/src/gpu/ccpr/GrCCAtlas.cpp b/src/gpu/ccpr/GrCCAtlas.cpp
index 6dc523d..0d1f9d9 100644
--- a/src/gpu/ccpr/GrCCAtlas.cpp
+++ b/src/gpu/ccpr/GrCCAtlas.cpp
@@ -72,13 +72,6 @@
fTopNode = skstd::make_unique<Node>(nullptr, 0, 0, fWidth, fHeight);
- // TODO: don't have this rely on the GrPixelConfig
- GrSRGBEncoded srgbEncoded = GrSRGBEncoded::kNo;
- GrColorType colorType = GrPixelConfigToColorTypeAndEncoding(pixelConfig, &srgbEncoded);
-
- const GrBackendFormat format =
- caps.getBackendFormatFromGrColorType(colorType, srgbEncoded);
-
fTextureProxy = GrProxyProvider::MakeFullyLazyProxy(
[this, pixelConfig](GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
@@ -94,7 +87,7 @@
}
return fBackingTexture;
},
- format, GrProxyProvider::Renderable::kYes, kTextureOrigin, pixelConfig, caps);
+ GrProxyProvider::Renderable::kYes, kTextureOrigin, pixelConfig, caps);
}
GrCCAtlas::~GrCCAtlas() {
diff --git a/src/gpu/ccpr/GrCCClipPath.cpp b/src/gpu/ccpr/GrCCClipPath.cpp
index 8b8d8a6..d70b4f7 100644
--- a/src/gpu/ccpr/GrCCClipPath.cpp
+++ b/src/gpu/ccpr/GrCCClipPath.cpp
@@ -16,9 +16,6 @@
int rtHeight, const GrCaps& caps) {
SkASSERT(!this->isInitialized());
- const GrBackendFormat format = caps.getBackendFormatFromGrColorType(GrColorType::kAlpha_F16,
- GrSRGBEncoded::kNo);
-
fAtlasLazyProxy = GrProxyProvider::MakeFullyLazyProxy(
[this](GrResourceProvider* resourceProvider) {
if (!resourceProvider) {
@@ -43,8 +40,8 @@
return sk_ref_sp(textureProxy->peekTexture());
},
- format, GrProxyProvider::Renderable::kYes, kTopLeft_GrSurfaceOrigin,
- kAlpha_half_GrPixelConfig, caps);
+ GrProxyProvider::Renderable::kYes, kTopLeft_GrSurfaceOrigin, kAlpha_half_GrPixelConfig,
+ caps);
fDeviceSpacePath = deviceSpacePath;
fDeviceSpacePath.getBounds().roundOut(&fPathDevIBounds);
diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp
index 6cee538..f466cc7 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -17,9 +17,6 @@
static bool TestForPreservingPMConversions(GrContext* context) {
static constexpr int kSize = 256;
static constexpr GrPixelConfig kConfig = kRGBA_8888_GrPixelConfig;
- static constexpr SkColorType kColorType = kRGBA_8888_SkColorType;
- const GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kColorType);
SkAutoTMalloc<uint32_t> data(kSize * kSize * 3);
uint32_t* srcData = data.get();
uint32_t* firstRead = data.get() + kSize * kSize;
@@ -44,11 +41,11 @@
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<GrRenderTargetContext> readRTC(
- context->contextPriv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact,
+ context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
kSize, kSize,
kConfig, nullptr));
sk_sp<GrRenderTargetContext> tempRTC(
- context->contextPriv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact,
+ context->contextPriv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
kSize, kSize,
kConfig, nullptr));
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
diff --git a/src/gpu/effects/GrConfigConversionEffect.h b/src/gpu/effects/GrConfigConversionEffect.h
index 301a6f9..4da5b0f 100644
--- a/src/gpu/effects/GrConfigConversionEffect.h
+++ b/src/gpu/effects/GrConfigConversionEffect.h
@@ -24,9 +24,6 @@
static bool TestForPreservingPMConversions(GrContext* context) {
static constexpr int kSize = 256;
static constexpr GrPixelConfig kConfig = kRGBA_8888_GrPixelConfig;
- static constexpr SkColorType kColorType = kRGBA_8888_SkColorType;
- const GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kColorType);
SkAutoTMalloc<uint32_t> data(kSize * kSize * 3);
uint32_t* srcData = data.get();
uint32_t* firstRead = data.get() + kSize * kSize;
@@ -51,9 +48,9 @@
SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<GrRenderTargetContext> readRTC(context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
+ SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
sk_sp<GrRenderTargetContext> tempRTC(context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
+ SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
return false;
}
diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp
index ccaad63..a577d91 100644
--- a/src/gpu/effects/GrRRectBlurEffect.fp
+++ b/src/gpu/effects/GrRRectBlurEffect.fp
@@ -51,13 +51,11 @@
sk_sp<GrTextureProxy> mask(proxyProvider->findOrCreateProxyByUniqueKey(
key, kBottomLeft_GrSurfaceOrigin));
if (!mask) {
- GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
// TODO: this could be approx but the texture coords will need to be updated
sk_sp<GrRenderTargetContext> rtc(
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, size.fWidth,
- size.fHeight, kAlpha_8_GrPixelConfig, nullptr));
+ SkBackingFit::kExact, size.fWidth, size.fHeight,
+ kAlpha_8_GrPixelConfig, nullptr));
if (!rtc) {
return nullptr;
}
diff --git a/src/gpu/effects/GrRRectBlurEffect.h b/src/gpu/effects/GrRRectBlurEffect.h
index a774e2c..e760f60 100644
--- a/src/gpu/effects/GrRRectBlurEffect.h
+++ b/src/gpu/effects/GrRRectBlurEffect.h
@@ -51,13 +51,11 @@
sk_sp<GrTextureProxy> mask(
proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin));
if (!mask) {
- GrBackendFormat format = context->contextPriv().caps()->getBackendFormatFromColorType(
- kAlpha_8_SkColorType);
// TODO: this could be approx but the texture coords will need to be updated
sk_sp<GrRenderTargetContext> rtc(
context->contextPriv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, size.fWidth, size.fHeight,
- kAlpha_8_GrPixelConfig, nullptr));
+ SkBackingFit::kExact, size.fWidth, size.fHeight, kAlpha_8_GrPixelConfig,
+ nullptr));
if (!rtc) {
return nullptr;
}
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 34d9d9e..9dc76b6 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -15,7 +15,6 @@
#include "GrSurfaceProxyPriv.h"
#include "GrTextureProxyPriv.h"
#include "SkJSONWriter.h"
-#include "SkGr.h"
#include "SkTSearch.h"
#include "SkTSort.h"
@@ -2994,19 +2993,12 @@
return get_yuva_config(*glFormat, config);
}
+
+#ifdef GR_TEST_UTILS
GrBackendFormat GrGLCaps::onCreateFormatFromBackendTexture(
const GrBackendTexture& backendTex) const {
GrGLTextureInfo glInfo;
SkAssertResult(backendTex.getGLTextureInfo(&glInfo));
return GrBackendFormat::MakeGL(glInfo.fFormat, glInfo.fTarget);
}
-
-GrBackendFormat GrGLCaps::getBackendFormatFromGrColorType(GrColorType ct,
- GrSRGBEncoded srgbEncoded) const {
- GrPixelConfig config = GrColorTypeToPixelConfig(ct, srgbEncoded);
- if (config == kUnknown_GrPixelConfig) {
- return GrBackendFormat();
- }
- return GrBackendFormat::MakeGL(this->configSizedInternalFormat(config), GR_GL_TEXTURE_2D);
-}
-
+#endif
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index 329618b..fda673e 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -441,9 +441,6 @@
bool getYUVAConfigFromBackendFormat(const GrBackendFormat&,
GrPixelConfig*) const override;
- GrBackendFormat getBackendFormatFromGrColorType(GrColorType ct,
- GrSRGBEncoded srgbEncoded) const override;
-
#if GR_TEST_UTILS
GrGLStandard standard() const { return fStandard; }
#endif
@@ -469,7 +466,9 @@
void onApplyOptionsOverrides(const GrContextOptions& options) override;
+#ifdef GR_TEST_UTILS
GrBackendFormat onCreateFormatFromBackendTexture(const GrBackendTexture&) const override;
+#endif
bool onIsWindowRectanglesSupportedForRT(const GrBackendRenderTarget&) const override;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index a056a8a..5fa589a 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -754,7 +754,7 @@
desc.fSampleCnt =
this->caps()->getRenderTargetSampleCount(backendRT.sampleCnt(), backendRT.config());
- return GrGLRenderTarget::MakeWrapped(this, desc, info.fFormat, idDesc, backendRT.stencilBits());
+ return GrGLRenderTarget::MakeWrapped(this, desc, idDesc, backendRT.stencilBits());
}
sk_sp<GrRenderTarget> GrGLGpu::onWrapBackendTextureAsRenderTarget(const GrBackendTexture& tex,
@@ -783,7 +783,7 @@
if (!this->createRenderTargetObjects(surfDesc, info, &rtIDDesc)) {
return nullptr;
}
- return GrGLRenderTarget::MakeWrapped(this, surfDesc, info.fFormat, rtIDDesc, 0);
+ return GrGLRenderTarget::MakeWrapped(this, surfDesc, rtIDDesc, 0);
}
static bool check_write_and_transfer_input(GrGLTexture* glTex) {
diff --git a/src/gpu/gl/GrGLRenderTarget.cpp b/src/gpu/gl/GrGLRenderTarget.cpp
index 7344dd7..34f8df1 100644
--- a/src/gpu/gl/GrGLRenderTarget.cpp
+++ b/src/gpu/gl/GrGLRenderTarget.cpp
@@ -21,22 +21,21 @@
// Constructor for wrapped render targets.
GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu,
const GrSurfaceDesc& desc,
- GrGLenum format,
const IDDesc& idDesc,
GrGLStencilAttachment* stencil)
: GrSurface(gpu, desc)
, INHERITED(gpu, desc, stencil) {
this->setFlags(gpu->glCaps(), idDesc);
- this->init(desc, format, idDesc);
+ this->init(desc, idDesc);
this->registerWithCacheWrapped();
}
-GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc, GrGLenum format,
+GrGLRenderTarget::GrGLRenderTarget(GrGLGpu* gpu, const GrSurfaceDesc& desc,
const IDDesc& idDesc)
: GrSurface(gpu, desc)
, INHERITED(gpu, desc) {
this->setFlags(gpu->glCaps(), idDesc);
- this->init(desc, format, idDesc);
+ this->init(desc, idDesc);
}
inline void GrGLRenderTarget::setFlags(const GrGLCaps& glCaps, const IDDesc& idDesc) {
@@ -52,14 +51,12 @@
}
}
-void GrGLRenderTarget::init(const GrSurfaceDesc& desc, GrGLenum format, const IDDesc& idDesc) {
+void GrGLRenderTarget::init(const GrSurfaceDesc& desc, const IDDesc& idDesc) {
fRTFBOID = idDesc.fRTFBOID;
fTexFBOID = idDesc.fTexFBOID;
fMSColorRenderbufferID = idDesc.fMSColorRenderbufferID;
fRTFBOOwnership = idDesc.fRTFBOOwnership;
- fRTFormat = format;
-
fViewport.fLeft = 0;
fViewport.fBottom = 0;
fViewport.fWidth = desc.fWidth;
@@ -70,7 +67,6 @@
sk_sp<GrGLRenderTarget> GrGLRenderTarget::MakeWrapped(GrGLGpu* gpu,
const GrSurfaceDesc& desc,
- GrGLenum format,
const IDDesc& idDesc,
int stencilBits) {
GrGLStencilAttachment* sb = nullptr;
@@ -85,7 +81,7 @@
sb = new GrGLStencilAttachment(gpu, sbDesc, desc.fWidth, desc.fHeight,
desc.fSampleCnt, format);
}
- return sk_sp<GrGLRenderTarget>(new GrGLRenderTarget(gpu, desc, format, idDesc, sb));
+ return sk_sp<GrGLRenderTarget>(new GrGLRenderTarget(gpu, desc, idDesc, sb));
}
GrBackendRenderTarget GrGLRenderTarget::getBackendRenderTarget() const {
@@ -101,12 +97,6 @@
numStencilBits, fbi);
}
-GrBackendFormat GrGLRenderTarget::backendFormat() const {
- // We should never have a GrGLRenderTarget (even a textureable one with a target that is not
- // texture 2D.
- return GrBackendFormat::MakeGL(fRTFormat, GR_GL_TEXTURE_2D);
-}
-
size_t GrGLRenderTarget::onGpuMemorySize() const {
return GrSurface::ComputeSize(this->config(), this->width(), this->height(),
fNumSamplesOwnedPerPixel, GrMipMapped::kNo);
diff --git a/src/gpu/gl/GrGLRenderTarget.h b/src/gpu/gl/GrGLRenderTarget.h
index 49f1631..a9ec3c3 100644
--- a/src/gpu/gl/GrGLRenderTarget.h
+++ b/src/gpu/gl/GrGLRenderTarget.h
@@ -36,7 +36,6 @@
static sk_sp<GrGLRenderTarget> MakeWrapped(GrGLGpu*,
const GrSurfaceDesc&,
- GrGLenum format,
const IDDesc&,
int stencilBits);
@@ -64,8 +63,6 @@
GrBackendRenderTarget getBackendRenderTarget() const override;
- GrBackendFormat backendFormat() const override;
-
bool canAttemptStencilAttachment() const override;
// GrGLRenderTarget overrides dumpMemoryStatistics so it can log its texture and renderbuffer
@@ -74,9 +71,9 @@
protected:
// Constructor for subclasses.
- GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, GrGLenum format, const IDDesc&);
+ GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&);
- void init(const GrSurfaceDesc&, GrGLenum format, const IDDesc&);
+ void init(const GrSurfaceDesc&, const IDDesc&);
void onAbandon() override;
void onRelease() override;
@@ -85,8 +82,7 @@
private:
// Constructor for instances wrapping backend objects.
- GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, GrGLenum format, const IDDesc&,
- GrGLStencilAttachment*);
+ GrGLRenderTarget(GrGLGpu*, const GrSurfaceDesc&, const IDDesc&, GrGLStencilAttachment*);
void setFlags(const GrGLCaps&, const IDDesc&);
@@ -102,7 +98,6 @@
GrGLuint fRTFBOID;
GrGLuint fTexFBOID;
GrGLuint fMSColorRenderbufferID;
- GrGLenum fRTFormat;
GrBackendObjectOwnership fRTFBOOwnership;
diff --git a/src/gpu/gl/GrGLTexture.cpp b/src/gpu/gl/GrGLTexture.cpp
index 1f427ca..47878da 100644
--- a/src/gpu/gl/GrGLTexture.cpp
+++ b/src/gpu/gl/GrGLTexture.cpp
@@ -103,11 +103,6 @@
return GrBackendTexture(this->width(), this->height(), this->texturePriv().mipMapped(), info);
}
-GrBackendFormat GrGLTexture::backendFormat() const {
- return GrBackendFormat::MakeGL(fFormat,
- target_from_texture_type(this->texturePriv().textureType()));
-}
-
sk_sp<GrGLTexture> GrGLTexture::MakeWrapped(GrGLGpu* gpu, const GrSurfaceDesc& desc,
GrMipMapsStatus mipMapsStatus, const IDDesc& idDesc) {
return sk_sp<GrGLTexture>(new GrGLTexture(gpu, kWrapped, desc, mipMapsStatus, idDesc));
diff --git a/src/gpu/gl/GrGLTexture.h b/src/gpu/gl/GrGLTexture.h
index e5739fb..5f662e0 100644
--- a/src/gpu/gl/GrGLTexture.h
+++ b/src/gpu/gl/GrGLTexture.h
@@ -66,8 +66,6 @@
GrBackendTexture getBackendTexture() const override;
- GrBackendFormat backendFormat() const override;
-
void textureParamsModified() override {
fSamplerParams.invalidate();
fNonSamplerParams.invalidate();
diff --git a/src/gpu/gl/GrGLTextureRenderTarget.cpp b/src/gpu/gl/GrGLTextureRenderTarget.cpp
index 04f8ffc..a9d7f14 100644
--- a/src/gpu/gl/GrGLTextureRenderTarget.cpp
+++ b/src/gpu/gl/GrGLTextureRenderTarget.cpp
@@ -20,7 +20,7 @@
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, desc)
, GrGLTexture(gpu, desc, texIDDesc, mipMapsStatus)
- , GrGLRenderTarget(gpu, desc, texIDDesc.fInfo.fFormat, rtIDDesc) {
+ , GrGLRenderTarget(gpu, desc, rtIDDesc) {
this->registerWithCache(budgeted);
}
@@ -31,7 +31,7 @@
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, desc)
, GrGLTexture(gpu, desc, texIDDesc, mipMapsStatus)
- , GrGLRenderTarget(gpu, desc, texIDDesc.fInfo.fFormat, rtIDDesc) {
+ , GrGLRenderTarget(gpu, desc, rtIDDesc) {
this->registerWithCacheWrapped();
}
diff --git a/src/gpu/gl/GrGLTextureRenderTarget.h b/src/gpu/gl/GrGLTextureRenderTarget.h
index f33ff28..4a6cae0 100644
--- a/src/gpu/gl/GrGLTextureRenderTarget.h
+++ b/src/gpu/gl/GrGLTextureRenderTarget.h
@@ -39,12 +39,6 @@
const GrGLTexture::IDDesc& texIDDesc,
const GrGLRenderTarget::IDDesc& rtIDDesc,
GrMipMapsStatus);
-
- GrBackendFormat backendFormat() const override {
- // It doesn't matter if we take the texture or render target path, so just pick texture.
- return GrGLTexture::backendFormat();
- }
-
protected:
void onAbandon() override {
GrGLRenderTarget::onAbandon();
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index d24afa5..c5459b2 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -9,7 +9,6 @@
#define GrMockCaps_DEFINED
#include "GrCaps.h"
-#include "SkGr.h"
#include "mock/GrMockTypes.h"
class GrMockCaps : public GrCaps {
@@ -126,22 +125,15 @@
return true;
}
- GrBackendFormat getBackendFormatFromGrColorType(GrColorType ct,
- GrSRGBEncoded srgbEncoded) const override {
- GrPixelConfig config = GrColorTypeToPixelConfig(ct, srgbEncoded);
- if (config == kUnknown_GrPixelConfig) {
- return GrBackendFormat();
- }
- return GrBackendFormat::MakeMock(config);
- }
-
private:
+#ifdef GR_TEST_UTILS
GrBackendFormat onCreateFormatFromBackendTexture(
const GrBackendTexture& backendTex) const override {
GrMockTextureInfo mockInfo;
SkAssertResult(backendTex.getMockTextureInfo(&mockInfo));
return GrBackendFormat::MakeMock(mockInfo.fConfig);
}
+#endif
static const int kMaxSampleCnt = 16;
diff --git a/src/gpu/mock/GrMockTexture.h b/src/gpu/mock/GrMockTexture.h
index ecb25c1..c374dcb 100644
--- a/src/gpu/mock/GrMockTexture.h
+++ b/src/gpu/mock/GrMockTexture.h
@@ -36,10 +36,6 @@
fInfo);
}
- GrBackendFormat backendFormat() const override {
- return GrBackendFormat::MakeMock(fInfo.fConfig);
- }
-
void textureParamsModified() override {}
void setRelease(sk_sp<GrReleaseProcHelper> releaseHelper) override {
fReleaseHelper = std::move(releaseHelper);
@@ -118,10 +114,6 @@
return {this->width(), this->height(), this->numColorSamples(), numStencilBits, fInfo};
}
- GrBackendFormat backendFormat() const override {
- return GrBackendFormat::MakeMock(fInfo.fConfig);
- }
-
protected:
// constructor for subclasses
GrMockRenderTarget(GrMockGpu* gpu, const GrSurfaceDesc& desc,
@@ -161,10 +153,6 @@
const GrTexture* asTexture() const override { return this; }
const GrRenderTarget* asRenderTarget() const override { return this; }
- GrBackendFormat backendFormat() const override {
- return GrMockTexture::backendFormat();
- }
-
private:
void onAbandon() override {
GrRenderTarget::onAbandon();
diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h
index 7edfa79..6eb775c 100644
--- a/src/gpu/mtl/GrMtlCaps.h
+++ b/src/gpu/mtl/GrMtlCaps.h
@@ -90,9 +90,6 @@
return false;
}
- GrBackendFormat getBackendFormatFromGrColorType(GrColorType ct,
- GrSRGBEncoded srgbEncoded) const override;
-
bool performPartialClearsAsDraws() const override {
return true;
}
@@ -105,7 +102,9 @@
void initGrCaps(const id<MTLDevice> device);
void initShaderCaps();
+#ifdef GR_TEST_UTILS
GrBackendFormat onCreateFormatFromBackendTexture(const GrBackendTexture&) const override;
+#endif
void initConfigTable();
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index ca3779b..3085811 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -414,6 +414,7 @@
fPreferredStencilFormat = StencilFormat{ MTLPixelFormatStencil8, 8, 8, true };
}
+#ifdef GR_TEST_UTILS
GrBackendFormat GrMtlCaps::onCreateFormatFromBackendTexture(
const GrBackendTexture& backendTex) const {
GrMtlTextureInfo mtlInfo;
@@ -422,17 +423,5 @@
GrWrapOwnership::kBorrow_GrWrapOwnership);
return GrBackendFormat::MakeMtl(mtlTexture.pixelFormat);
}
-
-GrBackendFormat GrMtlCaps::getBackendFormatFromGrColorType(GrColorType ct,
- GrSRGBEncoded srgbEncoded) const {
- GrPixelConfig config = GrColorTypeToPixelConfig(ct, srgbEncoded);
- if (config == kUnknown_GrPixelConfig) {
- return GrBackendFormat();
- }
- MTLPixelFormat format;
- if (!GrPixelConfigToMTLFormat(config, &format)) {
- return GrBackendFormat();
- }
- return GrBackendFormat::MakeMtl(format);
-}
+#endif
diff --git a/src/gpu/mtl/GrMtlRenderTarget.h b/src/gpu/mtl/GrMtlRenderTarget.h
index 98fa8e0..12f7064 100644
--- a/src/gpu/mtl/GrMtlRenderTarget.h
+++ b/src/gpu/mtl/GrMtlRenderTarget.h
@@ -43,8 +43,6 @@
GrBackendRenderTarget getBackendRenderTarget() const override;
- GrBackendFormat backendFormat() const override;
-
protected:
GrMtlRenderTarget(GrMtlGpu* gpu,
const GrSurfaceDesc& desc,
diff --git a/src/gpu/mtl/GrMtlRenderTarget.mm b/src/gpu/mtl/GrMtlRenderTarget.mm
index 59fd479..d14ff7c 100644
--- a/src/gpu/mtl/GrMtlRenderTarget.mm
+++ b/src/gpu/mtl/GrMtlRenderTarget.mm
@@ -54,10 +54,6 @@
return GrBackendRenderTarget(this->width(), this->height(), fRenderTexture.sampleCount, info);
}
-GrBackendFormat GrMtlRenderTarget::backendFormat() const {
- return GrBackendFormat::MakeMtl(fRenderTexture.pixelFormat);
-}
-
GrMtlGpu* GrMtlRenderTarget::getMtlGpu() const {
SkASSERT(!this->wasDestroyed());
return static_cast<GrMtlGpu*>(this->getGpu());
diff --git a/src/gpu/mtl/GrMtlTexture.h b/src/gpu/mtl/GrMtlTexture.h
index af51092..2265b72 100644
--- a/src/gpu/mtl/GrMtlTexture.h
+++ b/src/gpu/mtl/GrMtlTexture.h
@@ -30,8 +30,6 @@
GrBackendTexture getBackendTexture() const override;
- GrBackendFormat backendFormat() const override;
-
void textureParamsModified() override {}
bool reallocForMipmap(GrMtlGpu* gpu, uint32_t mipLevels);
diff --git a/src/gpu/mtl/GrMtlTexture.mm b/src/gpu/mtl/GrMtlTexture.mm
index abe4faa..7dd6f59 100644
--- a/src/gpu/mtl/GrMtlTexture.mm
+++ b/src/gpu/mtl/GrMtlTexture.mm
@@ -90,7 +90,3 @@
return GrBackendTexture(this->width(), this->height(), mipMapped, info);
}
-GrBackendFormat GrMtlTexture::backendFormat() const {
- return GrBackendFormat::MakeMtl(fTexture.pixelFormat);
-}
-
diff --git a/src/gpu/mtl/GrMtlTextureRenderTarget.h b/src/gpu/mtl/GrMtlTextureRenderTarget.h
index 412af7b..dae3cbc 100644
--- a/src/gpu/mtl/GrMtlTextureRenderTarget.h
+++ b/src/gpu/mtl/GrMtlTextureRenderTarget.h
@@ -22,9 +22,6 @@
static sk_sp<GrMtlTextureRenderTarget> MakeWrappedTextureRenderTarget(GrMtlGpu*,
const GrSurfaceDesc&,
id<MTLTexture>);
- GrBackendFormat backendFormat() const override {
- return GrMtlTexture::backendFormat();
- }
protected:
void onAbandon() override {
diff --git a/src/gpu/ops/GrLatticeOp.cpp b/src/gpu/ops/GrLatticeOp.cpp
index 57d8c14..ff48510 100644
--- a/src/gpu/ops/GrLatticeOp.cpp
+++ b/src/gpu/ops/GrLatticeOp.cpp
@@ -390,10 +390,8 @@
desc.fHeight = random->nextRangeU(1, 1000);
GrSurfaceOrigin origin =
random->nextBool() ? kTopLeft_GrSurfaceOrigin : kBottomLeft_GrSurfaceOrigin;
- const GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
auto proxy = context->contextPriv().proxyProvider()->createProxy(
- format, desc, origin, SkBackingFit::kExact, SkBudgeted::kYes);
+ desc, origin, SkBackingFit::kExact, SkBudgeted::kYes);
do {
if (random->nextBool()) {
diff --git a/src/gpu/ops/GrSmallPathRenderer.cpp b/src/gpu/ops/GrSmallPathRenderer.cpp
index 0c75017..215178c 100644
--- a/src/gpu/ops/GrSmallPathRenderer.cpp
+++ b/src/gpu/ops/GrSmallPathRenderer.cpp
@@ -911,11 +911,7 @@
SkASSERT(!args.fShape->isEmpty());
SkASSERT(args.fShape->hasUnstyledKey());
if (!fAtlas) {
- const GrBackendFormat format =
- args.fContext->contextPriv().caps()->getBackendFormatFromColorType(
- kAlpha_8_SkColorType);
fAtlas = GrDrawOpAtlas::Make(args.fContext->contextPriv().proxyProvider(),
- format,
kAlpha_8_GrPixelConfig,
ATLAS_TEXTURE_WIDTH, ATLAS_TEXTURE_HEIGHT,
NUM_PLOTS_X, NUM_PLOTS_Y,
@@ -1002,10 +998,8 @@
if (context->uniqueID() != gTestStruct.fContextID) {
gTestStruct.fContextID = context->uniqueID();
gTestStruct.reset();
- const GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
gTestStruct.fAtlas = GrDrawOpAtlas::Make(context->contextPriv().proxyProvider(),
- format, kAlpha_8_GrPixelConfig,
+ kAlpha_8_GrPixelConfig,
ATLAS_TEXTURE_WIDTH, ATLAS_TEXTURE_HEIGHT,
NUM_PLOTS_X, NUM_PLOTS_Y,
GrDrawOpAtlas::AllowMultitexturing::kYes,
diff --git a/src/gpu/ops/GrTextureOp.cpp b/src/gpu/ops/GrTextureOp.cpp
index 0622dbc..d0d6c5f 100644
--- a/src/gpu/ops/GrTextureOp.cpp
+++ b/src/gpu/ops/GrTextureOp.cpp
@@ -714,11 +714,8 @@
fit = random->nextBool() ? SkBackingFit::kApprox : SkBackingFit::kExact;
}
- const GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
GrProxyProvider* proxyProvider = context->contextPriv().proxyProvider();
- sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(format, desc, origin, mipMapped, fit,
+ sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(desc, origin, mipMapped, fit,
SkBudgeted::kNo,
GrInternalSurfaceFlags::kNone);
diff --git a/src/gpu/text/GrAtlasManager.cpp b/src/gpu/text/GrAtlasManager.cpp
index 486127d..143f84d 100644
--- a/src/gpu/text/GrAtlasManager.cpp
+++ b/src/gpu/text/GrAtlasManager.cpp
@@ -35,21 +35,6 @@
}
}
-static SkColorType mask_format_to_color_type(GrMaskFormat format) {
- switch (format) {
- case kA8_GrMaskFormat:
- return kAlpha_8_SkColorType;
- case kA565_GrMaskFormat:
- return kRGB_565_SkColorType;
- case kARGB_GrMaskFormat:
- return kRGBA_8888_SkColorType;
- default:
- SkDEBUGFAIL("unsupported GrMaskFormat");
- return kAlpha_8_SkColorType;
- }
-
-}
-
void GrAtlasManager::freeAll() {
for (int i = 0; i < kMaskFormatCount; ++i) {
fAtlases[i] = nullptr;
@@ -176,14 +161,11 @@
int index = MaskFormatToAtlasIndex(format);
if (fAtlases[index] == nullptr) {
GrPixelConfig config = mask_format_to_pixel_config(format);
- SkColorType colorType = mask_format_to_color_type(format);
SkISize atlasDimensions = fAtlasConfigs.atlasDimensions(format);
SkISize numPlots = fAtlasConfigs.numPlots(format);
- const GrBackendFormat format = fCaps->getBackendFormatFromColorType(colorType);
-
fAtlases[index] = GrDrawOpAtlas::Make(
- fProxyProvider, format, config, atlasDimensions.width(), atlasDimensions.height(),
+ fProxyProvider, config, atlasDimensions.width(), atlasDimensions.height(),
numPlots.width(), numPlots.height(), fAllowMultitexturing,
&GrGlyphCache::HandleEviction, fGlyphCache);
if (!fAtlases[index]) {
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index acb01d7..ee8f1d00 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -214,12 +214,9 @@
gTextContext = GrTextContext::Make(GrTextContext::Options());
}
- const GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
// Setup dummy SkPaint / GrPaint / GrRenderTargetContext
sk_sp<GrRenderTargetContext> rtc(context->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, 1024, 1024, kRGBA_8888_GrPixelConfig, nullptr));
+ SkBackingFit::kApprox, 1024, 1024, kRGBA_8888_GrPixelConfig, nullptr));
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 6f4cb8d..01cad06 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -12,7 +12,6 @@
#include "GrShaderCaps.h"
#include "GrVkInterface.h"
#include "GrVkUtil.h"
-#include "SkGr.h"
#include "vk/GrVkBackendContext.h"
#include "vk/GrVkExtensions.h"
@@ -824,23 +823,12 @@
return get_yuva_config(*vkFormat, config);
}
+#ifdef GR_TEST_UTILS
GrBackendFormat GrVkCaps::onCreateFormatFromBackendTexture(
const GrBackendTexture& backendTex) const {
GrVkImageInfo vkInfo;
SkAssertResult(backendTex.getVkImageInfo(&vkInfo));
return GrBackendFormat::MakeVk(vkInfo.fFormat);
}
-
-GrBackendFormat GrVkCaps::getBackendFormatFromGrColorType(GrColorType ct,
- GrSRGBEncoded srgbEncoded) const {
- GrPixelConfig config = GrColorTypeToPixelConfig(ct, srgbEncoded);
- if (config == kUnknown_GrPixelConfig) {
- return GrBackendFormat();
- }
- VkFormat format;
- if (!GrPixelConfigToVkFormat(config, &format)) {
- return GrBackendFormat();
- }
- return GrBackendFormat::MakeVk(format);
-}
+#endif
diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h
index 0b1243a..0154c0b 100644
--- a/src/gpu/vk/GrVkCaps.h
+++ b/src/gpu/vk/GrVkCaps.h
@@ -165,9 +165,6 @@
bool getYUVAConfigFromBackendFormat(const GrBackendFormat&,
GrPixelConfig*) const override;
- GrBackendFormat getBackendFormatFromGrColorType(GrColorType ct,
- GrSRGBEncoded srgbEncoded) const override;
-
private:
enum VkVendor {
kAMD_VkVendor = 4098,
@@ -188,7 +185,9 @@
const GrVkExtensions&);
void initShaderCaps(const VkPhysicalDeviceProperties&, const VkPhysicalDeviceFeatures2&);
+#ifdef GR_TEST_UTILS
GrBackendFormat onCreateFormatFromBackendTexture(const GrBackendTexture&) const override;
+#endif
void initConfigTable(const GrVkInterface*, VkPhysicalDevice, const VkPhysicalDeviceProperties&);
void initStencilFormat(const GrVkInterface* iface, VkPhysicalDevice physDev);
diff --git a/src/gpu/vk/GrVkImage.h b/src/gpu/vk/GrVkImage.h
index 5240250..7381e63 100644
--- a/src/gpu/vk/GrVkImage.h
+++ b/src/gpu/vk/GrVkImage.h
@@ -10,7 +10,6 @@
#include "GrVkResource.h"
-#include "GrBackendSurface.h"
#include "GrTypesPriv.h"
#include "GrVkImageLayout.h"
#include "SkTypes.h"
@@ -43,9 +42,6 @@
VkImage image() const { return fInfo.fImage; }
const GrVkAlloc& alloc() const { return fInfo.fAlloc; }
VkFormat imageFormat() const { return fInfo.fFormat; }
- GrBackendFormat getBackendFormat() const {
- return GrBackendFormat::MakeVk(this->imageFormat());
- }
uint32_t mipLevels() const { return fInfo.fLevelCount; }
const Resource* resource() const { return fResource; }
bool isLinearTiled() const {
diff --git a/src/gpu/vk/GrVkRenderTarget.h b/src/gpu/vk/GrVkRenderTarget.h
index 33f4949..2438a90 100644
--- a/src/gpu/vk/GrVkRenderTarget.h
+++ b/src/gpu/vk/GrVkRenderTarget.h
@@ -37,8 +37,6 @@
~GrVkRenderTarget() override;
- GrBackendFormat backendFormat() const override { return this->getBackendFormat(); }
-
const GrVkFramebuffer* framebuffer() const { return fFramebuffer; }
const GrVkImageView* colorAttachmentView() const { return fColorAttachmentView; }
const GrVkResource* msaaImageResource() const {
diff --git a/src/gpu/vk/GrVkTexture.h b/src/gpu/vk/GrVkTexture.h
index 69e4553..9c6b7b1 100644
--- a/src/gpu/vk/GrVkTexture.h
+++ b/src/gpu/vk/GrVkTexture.h
@@ -31,8 +31,6 @@
GrBackendTexture getBackendTexture() const override;
- GrBackendFormat backendFormat() const override { return this->getBackendFormat(); }
-
void textureParamsModified() override {}
const GrVkImageView* textureView();
diff --git a/src/gpu/vk/GrVkTextureRenderTarget.h b/src/gpu/vk/GrVkTextureRenderTarget.h
index dc4dc92..bd3973c 100644
--- a/src/gpu/vk/GrVkTextureRenderTarget.h
+++ b/src/gpu/vk/GrVkTextureRenderTarget.h
@@ -38,8 +38,6 @@
bool updateForMipmap(GrVkGpu* gpu, const GrVkImageInfo& newInfo);
- GrBackendFormat backendFormat() const override { return this->getBackendFormat(); }
-
protected:
void onAbandon() override {
GrVkRenderTarget::onAbandon();
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 600ba39..b8aa1a5 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -155,13 +155,10 @@
const int width = imageSize.width();
const int height = imageSize.height();
- const GrBackendFormat format =
- ctx->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
// Needs to create a render target in order to draw to it for the yuv->rgb conversion.
sk_sp<GrRenderTargetContext> renderTargetContext(
ctx->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, width, height, kRGBA_8888_GrPixelConfig,
+ SkBackingFit::kExact, width, height, kRGBA_8888_GrPixelConfig,
std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin));
if (!renderTargetContext) {
return nullptr;
@@ -315,6 +312,13 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
+static GrTextureType TextureTypeFromBackendFormat(const GrBackendFormat& backendFormat) {
+ if (const GrGLenum* target = backendFormat.getGLTarget()) {
+ return GrGLTexture::TextureTypeFromTarget(*target);
+ }
+ return GrTextureType::k2D;
+}
+
sk_sp<SkImage> SkImage_Gpu::MakePromiseTexture(GrContext* context,
const GrBackendFormat& backendFormat,
int width,
@@ -359,8 +363,9 @@
return nullptr;
}
- if (mipMapped == GrMipMapped::kYes &&
- GrTextureTypeHasRestrictedSampling(backendFormat.textureType())) {
+ GrTextureType textureType = TextureTypeFromBackendFormat(backendFormat);
+
+ 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;
@@ -382,7 +387,7 @@
return promiseHelper.getTexture(resourceProvider, config);
},
- backendFormat, desc, origin, mipMapped, GrInternalSurfaceFlags::kNone,
+ desc, origin, mipMapped, textureType, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, SkBudgeted::kNo,
GrSurfaceProxy::LazyInstantiationType::kUninstantiate);
@@ -532,8 +537,7 @@
return sk_ref_sp<GrTexture>(tmp->getTexture());
#endif
},
- yuvaFormats[yuvaIndices[SkYUVAIndex::kY_Index].fIndex],
- desc, imageOrigin, GrMipMapped::kNo,
+ desc, imageOrigin, GrMipMapped::kNo, GrTextureType::k2D,
GrInternalSurfaceFlags::kNone, SkBackingFit::kExact, SkBudgeted::kNo,
GrSurfaceProxy::LazyInstantiationType::kUninstantiate);
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 4dfc483..8360361 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -100,13 +100,8 @@
desc.fHeight = subset.height();
desc.fConfig = proxy->config();
- GrBackendFormat format = proxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrSurfaceContext> sContext(fContext->contextPriv().makeDeferredSurfaceContext(
- format, desc, proxy->origin(), GrMipMapped::kNo, SkBackingFit::kExact, fBudgeted));
+ desc, proxy->origin(), GrMipMapped::kNo, SkBackingFit::kExact, fBudgeted));
if (!sContext) {
return nullptr;
}
@@ -258,15 +253,9 @@
sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef();
- GrBackendFormat format = proxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrRenderTargetContext> renderTargetContext(
fContext->contextPriv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, this->width(), this->height(),
- proxy->config(), nullptr));
+ SkBackingFit::kExact, this->width(), this->height(), proxy->config(), nullptr));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index a1d0696..ab13835 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -78,14 +78,11 @@
sk_sp<GrTextureProxy> SkImage_GpuYUVA::asTextureProxyRef() const {
if (!fRGBProxy) {
- const GrBackendFormat format =
- fContext->contextPriv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
// Needs to create a render target in order to draw to it for the yuv->rgb conversion.
sk_sp<GrRenderTargetContext> renderTargetContext(
fContext->contextPriv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, this->width(), this->height(),
- kRGBA_8888_GrPixelConfig, fColorSpace, 1, GrMipMapped::kNo, fOrigin));
+ SkBackingFit::kExact, this->width(), this->height(), kRGBA_8888_GrPixelConfig,
+ fColorSpace, 1, GrMipMapped::kNo, fOrigin));
if (!renderTargetContext) {
return nullptr;
}
@@ -245,8 +242,8 @@
desc.fConfig = params.fConfig;
desc.fSampleCnt = 1;
proxies[texIdx] = proxyProvider->createLazyProxy(
- std::move(lazyInstCallback), yuvaFormats[texIdx], desc, imageOrigin,
- GrMipMapped::kNo, GrInternalSurfaceFlags::kNone,
+ std::move(lazyInstCallback), desc, imageOrigin, GrMipMapped::kNo,
+ GrTextureType::k2D, GrInternalSurfaceFlags::kNone,
SkBackingFit::kExact, SkBudgeted::kNo,
GrSurfaceProxy::LazyInstantiationType::kUninstantiate);
if (!proxies[texIdx]) {
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index fef4bf4..bd219c6 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -418,11 +418,6 @@
// the texture we fall through here and have the CPU generate the mip maps for us.
if (!proxy && !willBeMipped && !ctx->contextPriv().disableGpuYUVConversion()) {
const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(fInfo);
-
- SkColorType colorType = fInfo.colorType();
- GrBackendFormat format =
- ctx->contextPriv().caps()->getBackendFormatFromColorType(colorType);
-
ScopedGenerator generator(fSharedGenerator);
Generator_GrYUVProvider provider(generator);
@@ -434,7 +429,7 @@
// TODO: Update to create the mipped surface in the YUV generator and draw the base
// layer directly into the mipped surface.
- proxy = provider.refAsTextureProxy(ctx, format, desc, generatorColorSpace, thisColorSpace);
+ proxy = provider.refAsTextureProxy(ctx, desc, generatorColorSpace, thisColorSpace);
if (proxy) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
kLockTexturePathCount);
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index af0b564..9c04ac2 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -300,11 +300,8 @@
desc.fConfig = c.config();
desc.fSampleCnt = c.stencilCount();
- const GrBackendFormat format =
- context->contextPriv().caps()->getBackendFormatFromColorType(c.colorType());
-
sk_sp<GrSurfaceContext> sc(
- context->contextPriv().makeDeferredSurfaceContext(format, desc, c.origin(),
+ context->contextPriv().makeDeferredSurfaceContext(desc, c.origin(),
GrMipMapped(c.isMipMapped()),
SkBackingFit::kExact, budgeted,
c.refColorSpace(),