Make deferred render target context without config or format
config is completely redundant. No caller really cares what the backend
format is.
Change-Id: I93f1feb3ee61db6c21b7915bab3ee3fba5656f92
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/225194
Commit-Queue: Brian Salomon <bsalomon@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/bench/VertexColorSpaceBench.cpp b/bench/VertexColorSpaceBench.cpp
index 8891aed..5b875f0 100644
--- a/bench/VertexColorSpaceBench.cpp
+++ b/bench/VertexColorSpaceBench.cpp
@@ -269,12 +269,9 @@
SkRandom r;
const int kDrawsPerLoop = 32;
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
for (int i = 0; i < loops; ++i) {
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, 100, 100, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, p3));
+ SkBackingFit::kApprox, 100, 100, GrColorType::kRGBA_8888, p3));
SkASSERT(rtc);
for (int j = 0; j < kDrawsPerLoop; ++j) {
diff --git a/gm/clockwise.cpp b/gm/clockwise.cpp
index 5ffd0fc..a9ee63d 100644
--- a/gm/clockwise.cpp
+++ b/gm/clockwise.cpp
@@ -187,8 +187,7 @@
// Draw the test to an off-screen, top-down render target.
if (auto topLeftRTC = ctx->priv().makeDeferredRenderTargetContext(
- rtc->asSurfaceProxy()->backendFormat(), SkBackingFit::kExact, 100, 200,
- rtc->asSurfaceProxy()->config(), rtc->colorSpaceInfo().colorType(), nullptr, 1,
+ SkBackingFit::kExact, 100, 200, rtc->colorSpaceInfo().colorType(), nullptr, 1,
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) {
topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
@@ -204,8 +203,7 @@
// Draw the test to an off-screen, bottom-up render target.
if (auto topLeftRTC = ctx->priv().makeDeferredRenderTargetContext(
- rtc->asSurfaceProxy()->backendFormat(), SkBackingFit::kExact, 100, 200,
- rtc->asSurfaceProxy()->config(), rtc->colorSpaceInfo().colorType(), nullptr, 1,
+ SkBackingFit::kExact, 100, 200, rtc->colorSpaceInfo().colorType(), nullptr, 1,
GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) {
topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
diff --git a/gm/samplelocations.cpp b/gm/samplelocations.cpp
index a209c95..6e6cdae 100644
--- a/gm/samplelocations.cpp
+++ b/gm/samplelocations.cpp
@@ -268,8 +268,7 @@
}
auto offscreenRTC = ctx->priv().makeDeferredRenderTargetContext(
- rtc->asSurfaceProxy()->backendFormat(), SkBackingFit::kExact, 200, 200,
- rtc->asSurfaceProxy()->config(), rtc->colorSpaceInfo().colorType(), nullptr,
+ SkBackingFit::kExact, 200, 200, rtc->colorSpaceInfo().colorType(), nullptr,
rtc->numSamples(), GrMipMapped::kNo, fOrigin);
if (!offscreenRTC) {
*errorMsg = "Failed to create offscreen render target.";
diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp
index e73f474..c9bfecb 100644
--- a/gm/windowrectangles.cpp
+++ b/gm/windowrectangles.cpp
@@ -228,12 +228,9 @@
const GrReducedClip& reducedClip, GrPaint&& paint) {
const int padRight = (kDeviceRect.right() - kCoverRect.right()) / 2;
const int padBottom = (kDeviceRect.bottom() - kCoverRect.bottom()) / 2;
- const GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
sk_sp<GrRenderTargetContext> maskRTC(ctx->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, kCoverRect.width() + padRight,
- kCoverRect.height() + padBottom, kAlpha_8_GrPixelConfig, GrColorType::kAlpha_8,
- nullptr));
+ SkBackingFit::kExact, kCoverRect.width() + padRight, kCoverRect.height() + padBottom,
+ GrColorType::kAlpha_8, nullptr));
if (!maskRTC) {
return;
}
diff --git a/include/private/GrRecordingContext.h b/include/private/GrRecordingContext.h
index 0b8aa13..86e84f8 100644
--- a/include/private/GrRecordingContext.h
+++ b/include/private/GrRecordingContext.h
@@ -79,11 +79,9 @@
* renderTargetContexts created via this entry point.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt = 1,
@@ -100,11 +98,9 @@
* SRGB-ness will be preserved.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt = 1,
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp
index 0171b4a..ee05f38 100644
--- a/samplecode/SampleCCPRGeometry.cpp
+++ b/samplecode/SampleCCPRGeometry.cpp
@@ -187,12 +187,9 @@
GrOpMemoryPool* pool = ctx->priv().opMemoryPool();
- const GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromGrColorType(GrColorType::kAlpha_F16,
- GrSRGBEncoded::kNo);
sk_sp<GrRenderTargetContext> ccbuff = ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, this->width(), this->height(),
- kAlpha_half_GrPixelConfig, GrColorType::kAlpha_8, nullptr);
+ SkBackingFit::kApprox, this->width(), this->height(), GrColorType::kAlpha_F16,
+ nullptr);
SkASSERT(ccbuff);
ccbuff->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index a9e29ec..a0c4210 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -92,16 +92,17 @@
SkRect::Make(dstRect), localMatrix);
}
-static GrPixelConfig get_blur_config(GrTextureProxy* proxy) {
+static GrColorType get_blur_color_type(GrTextureProxy* proxy) {
GrPixelConfig config = proxy->config();
SkASSERT(kBGRA_8888_GrPixelConfig == config || kRGBA_8888_GrPixelConfig == config ||
kRGB_888_GrPixelConfig == config || kRGBA_4444_GrPixelConfig == config ||
kRGB_565_GrPixelConfig == config || kSRGBA_8888_GrPixelConfig == config ||
kRGBA_half_GrPixelConfig == config || kAlpha_8_GrPixelConfig == config ||
+ kAlpha_8_as_Alpha_GrPixelConfig == config || kAlpha_8_as_Red_GrPixelConfig ||
kRGBA_1010102_GrPixelConfig == config || kRGBA_half_Clamped_GrPixelConfig == config);
- return config;
+ return GrPixelConfigToColorType(config);
}
static sk_sp<GrRenderTargetContext> convolve_gaussian_2d(GrRecordingContext* context,
@@ -113,26 +114,20 @@
SkScalar sigmaX,
SkScalar sigmaY,
GrTextureDomain::Mode mode,
- const SkImageInfo& dstII,
+ int finalW,
+ int finalH,
+ sk_sp<SkColorSpace> finalCS,
SkBackingFit dstFit) {
-
- GrPixelConfig config = get_blur_config(proxy.get());
- GrColorType colorType = GrPixelConfigToColorType(config);
-
- GrBackendFormat format = proxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
+ // TODO: Once GrPixelConfig is gone, we need will need the source's color type.
+ GrColorType colorType = get_blur_color_type(proxy.get());
sk_sp<GrRenderTargetContext> renderTargetContext;
renderTargetContext = context->priv().makeDeferredRenderTargetContext(
- format,
dstFit,
- dstII.width(),
- dstII.height(),
- config,
+ finalW,
+ finalH,
colorType,
- dstII.refColorSpace(),
+ std::move(finalCS),
1,
GrMipMapped::kNo,
proxy->origin(),
@@ -152,10 +147,10 @@
kernelOffset, mode, true, sigmaX, sigmaY);
paint.addColorFragmentProcessor(std::move(conv));
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- GrFixedClip clip(dstII.bounds());
+ GrFixedClip clip(SkIRect::MakeWH(finalW, finalH));
renderTargetContext->fillRectWithLocalMatrix(clip, std::move(paint), GrAA::kNo, SkMatrix::I(),
- SkRect::Make(dstII.bounds()), localMatrix);
+ SkRect::MakeWH(finalW, finalH), localMatrix);
return renderTargetContext;
}
@@ -177,27 +172,22 @@
float sigma,
SkIRect* contentRect,
GrTextureDomain::Mode mode,
- const SkImageInfo& dstII,
+ int finalW,
+ int finalH,
+ sk_sp<SkColorSpace> finalCS,
SkBackingFit fit) {
- SkASSERT(srcRect.width() <= dstII.width() && srcRect.height() <= dstII.height());
+ SkASSERT(srcRect.width() <= finalW && srcRect.height() <= finalH);
- GrPixelConfig config = get_blur_config(proxy.get());
- GrColorType colorType = GrPixelConfigToColorType(config);
-
- GrBackendFormat format = proxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
+ // TODO: Once GrPixelConfig is gone we'll need the source's color type here.
+ GrColorType colorType = get_blur_color_type(proxy.get());
sk_sp<GrRenderTargetContext> dstRenderTargetContext;
dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext(
- format,
fit,
srcRect.width(),
srcRect.height(),
- config,
colorType,
- dstII.refColorSpace(),
+ std::move(finalCS),
1,
GrMipMapped::kNo,
proxy->origin(),
@@ -208,7 +198,7 @@
return nullptr;
}
- GrFixedClip clip(dstII.bounds());
+ GrFixedClip clip(SkIRect::MakeWH(finalW, finalH));
int bounds[2] = { 0, 0 };
SkIRect dstRect = SkIRect::MakeWH(srcRect.width(), srcRect.height());
@@ -286,6 +276,7 @@
return dstRenderTargetContext;
}
+// Note: despite its name this function does not kill every tenth legionnaire.
static sk_sp<GrTextureProxy> decimate(GrRecordingContext* context,
sk_sp<GrTextureProxy> src,
const SkIPoint& proxyOffset,
@@ -295,16 +286,18 @@
bool willBeXFiltering, bool willBeYFiltering,
int radiusX, int radiusY,
GrTextureDomain::Mode mode,
- const SkImageInfo& dstII) {
+ int finalW,
+ int finalH,
+ sk_sp<SkColorSpace> finalCS) {
SkASSERT(SkIsPow2(scaleFactorX) && SkIsPow2(scaleFactorY));
SkASSERT(scaleFactorX > 1 || scaleFactorY > 1);
- GrPixelConfig config = get_blur_config(src.get());
- GrColorType colorType = GrPixelConfigToColorType(config);
+ // TODO: Once GrPixelConfig is gone we'll need the source's color type here.
+ GrColorType colorType = get_blur_color_type(src.get());
SkIRect srcRect;
if (GrTextureDomain::kIgnore_Mode == mode) {
- srcRect = dstII.bounds();
+ srcRect = SkIRect::MakeWH(finalW, finalH);
} else {
srcRect = *contentRect;
srcRect.offset(*srcOffset);
@@ -317,23 +310,16 @@
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->priv().makeDeferredRenderTargetContext(
- format,
SkBackingFit::kApprox,
dstRect.fRight,
dstRect.fBottom,
- config,
colorType,
- dstII.refColorSpace(),
+ finalCS,
1,
GrMipMapped::kNo,
src->origin(),
@@ -423,7 +409,9 @@
const SkIRect& localSrcBounds,
int scaleFactorX, int scaleFactorY,
GrTextureDomain::Mode mode,
- const SkImageInfo& dstII,
+ int finalW,
+ int finalH,
+ sk_sp<SkColorSpace> finalCS,
SkBackingFit fit) {
const SkIRect srcRect = SkIRect::MakeWH(srcRenderTargetContext->width(),
srcRenderTargetContext->height());
@@ -443,17 +431,13 @@
srcRenderTargetContext = nullptr; // no longer needed
- GrPixelConfig config = get_blur_config(srcProxy.get());
- GrColorType colorType = GrPixelConfigToColorType(config);
- GrBackendFormat format = srcProxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
+ // TODO: Once GrPixelConfig is gone we'll need the source's color type here.
+ GrColorType colorType = get_blur_color_type(srcProxy.get());
sk_sp<GrRenderTargetContext> dstRenderTargetContext =
- context->priv().makeDeferredRenderTargetContext(
- format, fit, dstII.width(), dstII.height(), config, colorType,
- dstII.refColorSpace(), 1, GrMipMapped::kNo, srcProxy->origin());
+ context->priv().makeDeferredRenderTargetContext(fit, finalW, finalH, colorType,
+ std::move(finalCS), 1, GrMipMapped::kNo,
+ srcProxy->origin());
if (!dstRenderTargetContext) {
return nullptr;
}
@@ -478,7 +462,7 @@
GrSamplerState::ClampBilerp());
}
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- GrFixedClip clip(dstII.bounds());
+ GrFixedClip clip(SkIRect::MakeWH(finalW, finalH));
// TODO: using dstII as dstRect results in some image diffs - why?
SkIRect dstRect(srcRect);
@@ -505,14 +489,8 @@
SkBackingFit fit) {
SkASSERT(context);
- const GrPixelConfig config = get_blur_config(srcProxy.get());
- SkColorType ct;
- if (!GrPixelConfigToColorType(config, &ct)) {
- return nullptr;
- }
-
- const SkImageInfo finalDestII = SkImageInfo::Make(dstBounds.width(), dstBounds.height(),
- ct, at, std::move(colorSpace));
+ int finalW = dstBounds.width();
+ int finalH = dstBounds.height();
int scaleFactorX, radiusX;
int scaleFactorY, radiusY;
@@ -535,7 +513,8 @@
srcOffset -= proxyOffset;
localSrcBounds.offset(proxyOffset);
return convolve_gaussian_2d(context, std::move(srcProxy), localSrcBounds, srcOffset,
- radiusX, radiusY, sigmaX, sigmaY, mode, finalDestII, fit);
+ radiusX, radiusY, sigmaX, sigmaY, mode, finalW, finalH,
+ colorSpace, fit);
}
// Only the last rendered renderTargetContext needs to match the supplied 'fit'
@@ -549,7 +528,7 @@
if (scaleFactorX > 1 || scaleFactorY > 1) {
srcProxy = decimate(context, std::move(srcProxy), localProxyOffset, &srcOffset,
&localSrcBounds, scaleFactorX, scaleFactorY, sigmaX > 0.0f,
- sigmaY > 0.0f, radiusX, radiusY, mode, finalDestII);
+ sigmaY > 0.0f, radiusX, radiusY, mode, finalW, finalH, colorSpace);
localProxyOffset.set(0, 0);
if (!srcProxy) {
return nullptr;
@@ -558,12 +537,12 @@
sk_sp<GrRenderTargetContext> dstRenderTargetContext;
- SkIRect srcRect = finalDestII.bounds();
+ auto srcRect = SkIRect::MakeWH(finalW, finalH);
scale_irect_roundout(&srcRect, 1.0f / scaleFactorX, 1.0f / scaleFactorY);
if (sigmaX > 0.0f) {
dstRenderTargetContext = convolve_gaussian(
context, std::move(srcProxy), localProxyOffset, srcRect, srcOffset, Direction::kX,
- radiusX, sigmaX, &localSrcBounds, mode, finalDestII, xFit);
+ radiusX, sigmaX, &localSrcBounds, mode, finalW, finalH, colorSpace, xFit);
if (!dstRenderTargetContext) {
return nullptr;
}
@@ -589,7 +568,7 @@
if (sigmaY > 0.0f) {
dstRenderTargetContext = convolve_gaussian(
context, std::move(srcProxy), localProxyOffset, srcRect, srcOffset, Direction::kY,
- radiusY, sigmaY, &localSrcBounds, mode, finalDestII, yFit);
+ radiusY, sigmaY, &localSrcBounds, mode, finalW, finalH, colorSpace, yFit);
if (!dstRenderTargetContext) {
return nullptr;
}
@@ -609,9 +588,9 @@
SkASSERT(localProxyOffset.x() == 0 && localProxyOffset.y() == 0);
if (scaleFactorX > 1 || scaleFactorY > 1) {
- dstRenderTargetContext = reexpand(context, std::move(dstRenderTargetContext),
- localSrcBounds, scaleFactorX, scaleFactorY,
- mode, finalDestII, fit);
+ dstRenderTargetContext =
+ reexpand(context, std::move(dstRenderTargetContext), localSrcBounds, scaleFactorX,
+ scaleFactorY, mode, finalW, finalH, colorSpace, fit);
}
SkASSERT(!dstRenderTargetContext || dstRenderTargetContext->origin() == srcProxy->origin());
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index 2eaf04c..ec56a2f 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -252,18 +252,12 @@
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
sk_sp<SkColorSpace> colorSpace = sk_ref_sp(outputProperties.colorSpace());
- GrPixelConfig config = SkColorType2GrPixelConfig(outputProperties.colorType());
GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(
- outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format,
SkBackingFit::kApprox,
bounds.width(),
bounds.height(),
- config,
colorType,
std::move(colorSpace),
1,
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index c17ae24..801b866 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -460,13 +460,9 @@
return nullptr;
}
- GrBackendFormat format =
- fContext->priv().caps()->getBackendFormatFromColorType(outProps.colorType());
-
- return SkSpecialSurface::MakeRenderTarget(
- fContext, format, size.width(), size.height(),
- SkColorType2GrPixelConfig(outProps.colorType()), sk_ref_sp(outProps.colorSpace()),
- props);
+ return SkSpecialSurface::MakeRenderTarget(fContext, size.width(), size.height(),
+ SkColorTypeToGrColorType(outProps.colorType()),
+ sk_ref_sp(outProps.colorSpace()), props);
}
sk_sp<SkSpecialImage> onMakeSubset(const SkIRect& subset) const override {
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 8e894dd..64b3e3b 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -169,21 +169,17 @@
};
sk_sp<SkSpecialSurface> SkSpecialSurface::MakeRenderTarget(GrRecordingContext* context,
- const GrBackendFormat& format,
int width, int height,
- GrPixelConfig config,
+ GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
if (!context) {
return nullptr;
}
-
- GrColorType colorType = GrPixelConfigToColorType(config);
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, width, height, config, colorType,
- std::move(colorSpace), 1, GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin,
- props));
+ SkBackingFit::kApprox, width, height, colorType, 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 75f2392..f890e1e 100644
--- a/src/core/SkSpecialSurface.h
+++ b/src/core/SkSpecialSurface.h
@@ -61,11 +61,8 @@
* Allocate a new GPU-backed SkSpecialSurface. If the requested surface cannot
* be created, nullptr will be returned.
*/
- static sk_sp<SkSpecialSurface> MakeRenderTarget(GrRecordingContext*,
- const GrBackendFormat& format,
- int width, int height,
- GrPixelConfig config,
- sk_sp<SkColorSpace> colorSpace,
+ static sk_sp<SkSpecialSurface> MakeRenderTarget(GrRecordingContext*, int width, int height,
+ GrColorType, sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* = nullptr);
#endif
diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
index ba141a0..456bd33 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -105,12 +105,10 @@
sk_sp<GrTextureProxy> SkAlphaThresholdFilterImpl::createMaskTexture(GrRecordingContext* context,
const SkMatrix& inMatrix,
const SkIRect& bounds) const {
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
sk_sp<GrRenderTargetContext> rtContext(
context->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(),
- kAlpha_8_GrPixelConfig, GrColorType::kAlpha_8, nullptr));
+ SkBackingFit::kApprox, bounds.width(), bounds.height(), GrColorType::kAlpha_8,
+ nullptr));
if (!rtContext) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
index 7da4a98..e9c419b 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -361,18 +361,14 @@
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- SkColorType colorType = outputProperties.colorType();
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(colorType);
+ GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format,
SkBackingFit::kApprox,
bounds.width(),
bounds.height(),
- SkColorType2GrPixelConfig(colorType),
- SkColorTypeToGrColorType(colorType),
+ colorType,
sk_ref_sp(outputProperties.colorSpace()),
1,
GrMipMapped::kNo,
diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
index 416b2d4..9c85288 100644
--- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp
+++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
@@ -301,26 +301,20 @@
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->priv().caps()->getBackendFormatFromColorType(colorType);
+ GrColorType colorType = SkColorTypeToGrColorType(ctx.outputProperties().colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContext(
- format,
- SkBackingFit::kApprox,
- bounds.width(),
- bounds.height(),
- config,
- SkColorTypeToGrColorType(colorType),
- sk_ref_sp(colorSpace),
- 1,
- GrMipMapped::kNo,
- kBottomLeft_GrSurfaceOrigin,
- nullptr,
- SkBudgeted::kYes,
- isProtected));
+ context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
+ bounds.width(),
+ bounds.height(),
+ colorType,
+ sk_ref_sp(colorSpace),
+ 1,
+ GrMipMapped::kNo,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ SkBudgeted::kYes,
+ isProtected));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkLightingImageFilter.cpp b/src/effects/imagefilters/SkLightingImageFilter.cpp
index 04db4c5..d94298c 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -463,18 +463,14 @@
sk_sp<GrTextureProxy> inputProxy(input->asTextureProxyRef(context));
SkASSERT(inputProxy);
- SkColorType colorType = outputProperties.colorType();
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(colorType);
+ GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format,
SkBackingFit::kApprox,
offsetBounds.width(),
offsetBounds.height(),
- SkColorType2GrPixelConfig(colorType),
- SkColorTypeToGrColorType(colorType),
+ colorType,
sk_ref_sp(outputProperties.colorSpace()),
1,
GrMipMapped::kNo,
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index bba4314..a6cb3b5 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -472,10 +472,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->priv().caps()->getBackendFormatFromColorType(colorType);
- GrPixelConfig config = SkColorType2GrPixelConfig(colorType);
+ GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
// setup new clip
const GrFixedClip clip(SkIRect::MakeWH(srcTexture->width(), srcTexture->height()));
@@ -487,12 +484,10 @@
if (radius.fWidth > 0) {
sk_sp<GrRenderTargetContext> dstRTContext(context->priv().makeDeferredRenderTargetContext(
- format,
SkBackingFit::kApprox,
rect.width(),
rect.height(),
- config,
- SkColorTypeToGrColorType(colorType),
+ colorType,
colorSpace,
1,
GrMipMapped::kNo,
@@ -517,12 +512,10 @@
}
if (radius.fHeight > 0) {
sk_sp<GrRenderTargetContext> dstRTContext(context->priv().makeDeferredRenderTargetContext(
- format,
SkBackingFit::kApprox,
rect.width(),
rect.height(),
- config,
- SkColorTypeToGrColorType(colorType),
+ colorType,
colorSpace,
1,
GrMipMapped::kNo,
diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
index b82ad30..8b074ea 100644
--- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp
+++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
@@ -307,14 +307,11 @@
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
- SkColorType colorType = outputProperties.colorType();
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(colorType);
+ GrColorType colorType = SkColorTypeToGrColorType(outputProperties.colorType());
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(),
- SkColorType2GrPixelConfig(colorType), SkColorTypeToGrColorType(colorType),
+ SkBackingFit::kApprox, bounds.width(), bounds.height(), colorType,
sk_ref_sp(outputProperties.colorSpace())));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 0cc44b2..dd6ae3b 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -175,13 +175,11 @@
const SkMatrix& origViewMatrix,
const GrShape& shape,
int sampleCnt) {
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
sk_sp<GrRenderTargetContext> rtContext(
context->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kApprox, maskRect.width(), maskRect.height(),
- kAlpha_8_GrPixelConfig, GrColorType::kAlpha_8, nullptr, sampleCnt,
- GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
+ SkBackingFit::kApprox, maskRect.width(), maskRect.height(),
+ GrColorType::kAlpha_8, nullptr, sampleCnt, GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin));
if (!rtContext) {
return nullptr;
}
diff --git a/src/gpu/GrClipStackClip.cpp b/src/gpu/GrClipStackClip.cpp
index 4bcc4fb..6e455d5 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -356,15 +356,11 @@
return proxy;
}
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
auto isProtected = proxy->isProtected() ? GrProtected::kYes : GrProtected::kNo;
sk_sp<GrRenderTargetContext> rtc(
- context->priv().makeDeferredRenderTargetContextWithFallback(format,
- SkBackingFit::kApprox,
+ context->priv().makeDeferredRenderTargetContextWithFallback(SkBackingFit::kApprox,
reducedClip.width(),
reducedClip.height(),
- kAlpha_8_GrPixelConfig,
GrColorType::kAlpha_8,
nullptr,
1,
diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp
index 5c135d6..e0bb319 100644
--- a/src/gpu/GrContextPriv.cpp
+++ b/src/gpu/GrContextPriv.cpp
@@ -73,11 +73,9 @@
}
sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt,
@@ -86,19 +84,18 @@
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted,
GrProtected isProtected) {
- return fContext->makeDeferredRenderTargetContext(format, fit, width, height, config, colorType,
+ return fContext->makeDeferredRenderTargetContext(fit, width, height, colorType,
std::move(colorSpace), sampleCnt, mipMapped,
origin, surfaceProps, budgeted, isProtected);
}
sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, GrColorType colorType, sk_sp<SkColorSpace> colorSpace, int sampleCnt,
- GrMipMapped mipMapped, GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps,
- SkBudgeted budgeted) {
+ SkBackingFit fit, int width, int height, GrColorType colorType,
+ sk_sp<SkColorSpace> colorSpace, int sampleCnt, GrMipMapped mipMapped,
+ GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps, SkBudgeted budgeted) {
return fContext->makeDeferredRenderTargetContextWithFallback(
- format, fit, width, height, config, colorType, std::move(colorSpace), sampleCnt,
- mipMapped, origin, surfaceProps, budgeted);
+ fit, width, height, colorType, std::move(colorSpace), sampleCnt, mipMapped, origin,
+ surfaceProps, budgeted);
}
sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackendTexture& tex,
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 85402e1..adea6c8 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -96,11 +96,9 @@
* renderTargetContexts created via this entry point.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt = 1,
@@ -117,11 +115,9 @@
* SRGB-ness will be preserved.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt = 1,
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index d596dc6..6cfd49c 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -198,11 +198,9 @@
}
sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt,
@@ -216,6 +214,15 @@
return nullptr;
}
+ auto format = this->caps()->getBackendFormatFromGrColorType(colorType, GrSRGBEncoded::kNo);
+ if (!format.isValid()) {
+ return nullptr;
+ }
+ auto config = this->caps()->getConfigFromBackendFormat(format, colorType);
+ if (config == kUnknown_GrPixelConfig) {
+ return nullptr;
+ }
+
GrSurfaceDesc desc;
desc.fFlags = kRenderTarget_GrSurfaceFlag;
desc.fWidth = width;
@@ -247,85 +254,31 @@
return renderTargetContext;
}
-static inline bool color_type_and_config_fallback(GrColorType* ct, GrPixelConfig* config) {
- switch (*ct) {
+static inline GrColorType color_type_fallback(GrColorType ct) {
+ switch (ct) {
+ // kRGBA_8888 is our default fallback for many color types that may not have renderable
+ // backend formats.
case GrColorType::kAlpha_8:
- if (*config != kAlpha_8_GrPixelConfig && *config != kAlpha_8_as_Red_GrPixelConfig &&
- *config != kAlpha_8_as_Alpha_GrPixelConfig) {
- return false;
- }
- *config = kRGBA_8888_GrPixelConfig;
- *ct = GrColorType::kRGBA_8888;
- return true;
case GrColorType::kBGR_565:
- if (*config != kRGB_565_GrPixelConfig) {
- return false;
- }
- *config = kRGBA_8888_GrPixelConfig;
- *ct = GrColorType::kRGBA_8888;
- return true;
case GrColorType::kABGR_4444:
- if (*config != kRGBA_4444_GrPixelConfig) {
- return false;
- }
- *config = kRGBA_8888_GrPixelConfig;
- *ct = GrColorType::kRGBA_8888;
- return true;
case GrColorType::kBGRA_8888:
- if (*config != kBGRA_8888_GrPixelConfig) {
- return false;
- }
- *config = kRGBA_8888_GrPixelConfig;
- *ct = GrColorType::kRGBA_8888;
- return true;
case GrColorType::kRGBA_1010102:
- if (*config != kRGBA_1010102_GrPixelConfig) {
- return false;
- }
- *config = kRGBA_8888_GrPixelConfig;
- *ct = GrColorType::kRGBA_8888;
- return true;
case GrColorType::kRGBA_F16:
- if (*config != kRGBA_half_GrPixelConfig) {
- return false;
- }
- *config = kRGBA_8888_GrPixelConfig;
- *ct = GrColorType::kRGBA_8888;
- return true;
case GrColorType::kRGBA_F16_Clamped:
- if (*config != kRGBA_half_Clamped_GrPixelConfig) {
- return false;
- }
- *config = kRGBA_8888_GrPixelConfig;
- *ct = GrColorType::kRGBA_8888;
- return true;
+ return GrColorType::kRGBA_8888;
case GrColorType::kAlpha_F16:
- if (*config != kAlpha_half_GrPixelConfig &&
- *config != kAlpha_half_as_Red_GrPixelConfig) {
- return false;
- }
- *config = kRGBA_half_GrPixelConfig;
- *ct = GrColorType::kRGBA_F16;
- return true;
+ return GrColorType::kRGBA_F16;
case GrColorType::kGray_8:
- if (*config != kGray_8_GrPixelConfig && *config != kGray_8_as_Red_GrPixelConfig &&
- *config != kGray_8_as_Lum_GrPixelConfig) {
- return false;
- }
- *config = kRGB_888_GrPixelConfig;
- *ct = GrColorType::kRGB_888x;
- return true;
+ return GrColorType::kRGB_888x;
default:
- return false;
+ return GrColorType::kUnknown;
}
}
sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt,
@@ -334,21 +287,15 @@
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted,
GrProtected isProtected) {
- GrBackendFormat localFormat = format;
SkASSERT(sampleCnt > 0);
- if (0 == this->caps()->getRenderTargetSampleCount(sampleCnt, config)) {
- // TODO: Make the fallback part of GrCaps?
- if (!color_type_and_config_fallback(&colorType, &config)) {
- return nullptr;
- }
- // Figure out what the new backend format should be for the new color type.
- auto srgb = GrPixelConfigIsSRGBEncoded(config);
- localFormat = this->caps()->getBackendFormatFromGrColorType(colorType, srgb);
- }
-
- return this->makeDeferredRenderTargetContext(localFormat, fit, width, height, config, colorType,
- std::move(colorSpace), sampleCnt, mipMapped,
- origin, surfaceProps, budgeted, isProtected);
+ sk_sp<GrRenderTargetContext> rtc;
+ do {
+ rtc = this->makeDeferredRenderTargetContext(fit, width, height, colorType, colorSpace,
+ sampleCnt, mipMapped, origin, surfaceProps,
+ budgeted, isProtected);
+ colorType = color_type_fallback(colorType);
+ } while (!rtc && colorType != GrColorType::kUnknown);
+ return rtc;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -395,11 +342,9 @@
}
sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt,
@@ -408,17 +353,15 @@
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted,
GrProtected isProtected) {
- return fContext->makeDeferredRenderTargetContext(format, fit, width, height, config, colorType,
+ return fContext->makeDeferredRenderTargetContext(fit, width, height, colorType,
std::move(colorSpace), sampleCnt, mipMapped,
origin, surfaceProps, budgeted, isProtected);
}
sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt,
@@ -427,11 +370,9 @@
const SkSurfaceProps* surfaceProps,
SkBudgeted budgeted,
GrProtected isProtected) {
- return fContext->makeDeferredRenderTargetContextWithFallback(format,
- fit,
+ return fContext->makeDeferredRenderTargetContextWithFallback(fit,
width,
height,
- config,
colorType,
std::move(colorSpace),
sampleCnt,
diff --git a/src/gpu/GrRecordingContextPriv.h b/src/gpu/GrRecordingContextPriv.h
index 12206c8..0743ae7 100644
--- a/src/gpu/GrRecordingContextPriv.h
+++ b/src/gpu/GrRecordingContextPriv.h
@@ -80,11 +80,9 @@
* renderTargetContexts created via this entry point.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt = 1,
@@ -101,11 +99,9 @@
* SRGB-ness will be preserved.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format,
SkBackingFit fit,
int width,
int height,
- GrPixelConfig config,
GrColorType,
sk_sp<SkColorSpace> colorSpace,
int sampleCnt = 1,
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index b85de5c..8bdda90 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -1696,15 +1696,13 @@
if (rescaleGamma == SkSurface::RescaleGamma::kLinear && this->colorSpaceInfo().colorSpace() &&
!this->colorSpaceInfo().colorSpace()->gammaIsLinear()) {
auto cs = this->colorSpaceInfo().colorSpace()->makeLinearGamma();
- auto backendFormat = this->caps()->getBackendFormatFromGrColorType(GrColorType::kRGBA_F16,
- GrSRGBEncoded::kNo);
auto xform = GrColorSpaceXform::Make(this->colorSpaceInfo().colorSpace(),
this->colorSpaceInfo().alphaType(),
cs.get(), kPremul_SkAlphaType);
// We'll fall back to kRGBA_8888 if half float not supported.
auto linearRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback(
- backendFormat, SkBackingFit::kExact, srcW, srcH, kRGBA_half_GrPixelConfig,
- GrColorType::kRGBA_F16, cs, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ SkBackingFit::kExact, srcW, srcH, GrColorType::kRGBA_F16, cs, 1, GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin);
if (!linearRTC) {
return nullptr;
}
@@ -1740,16 +1738,12 @@
}
--stepsY;
}
- GrBackendFormat backendFormat = texProxy->backendFormat().makeTexture2D();
- GrPixelConfig config = texProxy->config();
GrColorType colorType = currRTC->colorSpaceInfo().colorType();
auto cs = currRTC->colorSpaceInfo().refColorSpace();
sk_sp<GrColorSpaceXform> xform;
auto prevAlphaType = currRTC->colorSpaceInfo().alphaType();
if (!stepsX && !stepsY) {
// Might as well fold conversion to final info in the last step.
- backendFormat = this->caps()->getBackendFormatFromColorType(info.colorType());
- config = this->caps()->getConfigFromBackendFormat(backendFormat, info.colorType());
cs = info.refColorSpace();
colorType = SkColorTypeToGrColorType(info.colorType());
xform = GrColorSpaceXform::Make(currRTC->colorSpaceInfo().colorSpace(),
@@ -1757,8 +1751,8 @@
cs.get(), info.alphaType());
}
currRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback(
- backendFormat, SkBackingFit::kExact, nextW, nextH, config, colorType, std::move(cs),
- 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ SkBackingFit::kExact, nextW, nextH, colorType, std::move(cs), 1, GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin);
if (!currRTC) {
return nullptr;
}
@@ -1870,7 +1864,6 @@
return;
}
sk_sp<GrTextureProxy> texProxy = sk_ref_sp(fRenderTargetProxy->asTextureProxy());
- const auto backendFormat = fRenderTargetProxy->backendFormat().makeTexture2D();
SkRect srcRectToDraw = SkRect::Make(srcRect);
// If the src is not texturable first try to make a copy to a texture.
if (!texProxy) {
@@ -1884,9 +1877,9 @@
srcRectToDraw = SkRect::MakeWH(srcRect.width(), srcRect.height());
}
rtc = direct->priv().makeDeferredRenderTargetContext(
- backendFormat, SkBackingFit::kApprox, srcRect.width(), srcRect.height(),
- fRenderTargetProxy->config(), this->colorSpaceInfo().colorType(),
- info.refColorSpace(), 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ SkBackingFit::kApprox, srcRect.width(), srcRect.height(),
+ this->colorSpaceInfo().colorType(), info.refColorSpace(), 1, GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin);
if (!rtc) {
callback(context, nullptr, 0);
return;
@@ -2069,13 +2062,10 @@
callback(context, nullptr, nullptr);
return;
}
- const auto backendFormat =
- this->caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
SkRect srcRectToDraw = SkRect::Make(srcRect);
rtc = direct->priv().makeDeferredRenderTargetContext(
- backendFormat, SkBackingFit::kApprox, dstW, dstH, fRenderTargetProxy->config(),
- this->colorSpaceInfo().colorType(), dstColorSpace, 1, GrMipMapped::kNo,
- kTopLeft_GrSurfaceOrigin);
+ SkBackingFit::kApprox, dstW, dstH, this->colorSpaceInfo().colorType(),
+ dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
if (!rtc) {
callback(context, nullptr, nullptr);
return;
@@ -2094,17 +2084,15 @@
callback(context, nullptr, nullptr);
return;
}
- const auto backendFormat = this->caps()->getBackendFormatFromGrColorType(GrColorType::kAlpha_8,
- GrSRGBEncoded::kNo);
- auto yRTC = direct->priv().makeDeferredRenderTargetContext(
- backendFormat, SkBackingFit::kApprox, dstW, dstH, kAlpha_8_GrPixelConfig,
- GrColorType::kAlpha_8, dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
- auto uRTC = direct->priv().makeDeferredRenderTargetContext(
- backendFormat, SkBackingFit::kApprox, dstW / 2, dstH / 2, kAlpha_8_GrPixelConfig,
- GrColorType::kAlpha_8, dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
- auto vRTC = direct->priv().makeDeferredRenderTargetContext(
- backendFormat, SkBackingFit::kApprox, dstW / 2, dstH / 2, kAlpha_8_GrPixelConfig,
- GrColorType::kAlpha_8, dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ auto yRTC = direct->priv().makeDeferredRenderTargetContextWithFallback(
+ SkBackingFit::kApprox, dstW, dstH, GrColorType::kAlpha_8, dstColorSpace, 1,
+ GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ auto uRTC = direct->priv().makeDeferredRenderTargetContextWithFallback(
+ SkBackingFit::kApprox, dstW / 2, dstH / 2, GrColorType::kAlpha_8, dstColorSpace, 1,
+ GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ auto vRTC = direct->priv().makeDeferredRenderTargetContextWithFallback(
+ SkBackingFit::kApprox, dstW / 2, dstH / 2, GrColorType::kAlpha_8, dstColorSpace, 1,
+ GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
if (!yRTC || !uRTC || !vRTC) {
callback(context, nullptr, nullptr);
return;
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index cdaad49..a3dd91a 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -126,27 +126,14 @@
}
if (readFlag == GrCaps::SurfaceReadPixelsSupport::kCopyToTexture2D || canvas2DFastPath) {
- GrBackendFormat format;
- GrPixelConfig config;
- GrColorType colorType;
- if (canvas2DFastPath) {
- config = kRGBA_8888_GrPixelConfig;
- format = caps->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
- colorType = GrColorType::kRGBA_8888;
- } else {
- config = srcProxy->config();
- format = srcProxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return false;
- }
- colorType = this->colorSpaceInfo().colorType();
- }
- sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr : this->colorSpaceInfo().refColorSpace();
+ GrColorType colorType = canvas2DFastPath ? GrColorType::kRGBA_8888
+ : this->colorSpaceInfo().colorType();
+ sk_sp<SkColorSpace> cs = canvas2DFastPath ? nullptr
+ : this->colorSpaceInfo().refColorSpace();
sk_sp<GrRenderTargetContext> tempCtx = direct->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, dstInfo.width(), dstInfo.height(), config, colorType,
- std::move(cs), 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr,
- SkBudgeted::kYes);
+ SkBackingFit::kApprox, dstInfo.width(), dstInfo.height(), colorType, std::move(cs),
+ 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes);
if (!tempCtx) {
return false;
}
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 6c2ecb3..903a74e 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -378,14 +378,9 @@
}
}
if (src->asTextureProxy()) {
- GrBackendFormat format = src->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrRenderTargetContext> dstContext = context->priv().makeDeferredRenderTargetContext(
- format, fit, dstDesc.fWidth, dstDesc.fHeight, dstDesc.fConfig, colorType, nullptr,
- 1, mipMapped, src->origin(), nullptr, budgeted);
+ fit, dstDesc.fWidth, dstDesc.fHeight, colorType, nullptr, 1, mipMapped,
+ src->origin(), nullptr, budgeted);
if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcRect, dstPoint)) {
return dstContext->asTextureProxyRef();
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 87c0633..48bd0df 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -27,8 +27,6 @@
bool dstWillRequireMipMaps) {
SkASSERT(context);
- GrPixelConfig config = GrMakePixelConfigUncompressed(inputProxy->config());
-
const SkRect dstRect = SkRect::MakeIWH(copyParams.fWidth, copyParams.fHeight);
GrMipMapped mipMapped = dstWillRequireMipMaps ? GrMipMapped::kYes : GrMipMapped::kNo;
@@ -50,15 +48,10 @@
}
}
- GrBackendFormat format = inputProxy->backendFormat().makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrRenderTargetContext> copyRTC =
context->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, dstRect.width(), dstRect.height(), config,
- colorType, nullptr, 1, mipMapped, inputProxy->origin());
+ SkBackingFit::kExact, dstRect.width(), dstRect.height(), colorType, nullptr, 1,
+ mipMapped, inputProxy->origin());
if (!copyRTC) {
return nullptr;
}
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 15f99a6..21da8a0 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -104,7 +104,6 @@
}
sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrRecordingContext* ctx,
- const GrBackendFormat& format,
const GrSurfaceDesc& desc,
GrColorType colorType,
SkColorSpace* srcColorSpace,
@@ -164,8 +163,8 @@
// TODO: investigate preallocating mip maps here
sk_sp<GrRenderTargetContext> renderTargetContext(ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, desc.fWidth, desc.fHeight, desc.fConfig, colorType,
- nullptr, desc.fSampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
+ SkBackingFit::kExact, desc.fWidth, desc.fHeight, colorType, nullptr, desc.fSampleCnt,
+ GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/gpu/GrYUVProvider.h b/src/gpu/GrYUVProvider.h
index 04abdb5..c37488d 100644
--- a/src/gpu/GrYUVProvider.h
+++ b/src/gpu/GrYUVProvider.h
@@ -43,7 +43,6 @@
* On failure (e.g. the provider had no data), this returns NULL.
*/
sk_sp<GrTextureProxy> refAsTextureProxy(GrRecordingContext*,
- const GrBackendFormat&,
const GrSurfaceDesc&,
GrColorType colorType,
SkColorSpace* srcColorSpace,
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index aaf2c82..e5eb2d3 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -152,19 +152,10 @@
return nullptr;
}
- GrPixelConfig config = SkImageInfo2GrPixelConfig(origInfo);
- if (kUnknown_GrPixelConfig == config) {
- return nullptr;
- }
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(origInfo.colorType());
- if (!format.isValid()) {
- return nullptr;
- }
// This method is used to create SkGpuDevice's for SkSurface_Gpus. In this case
// they need to be exact.
return context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, origInfo.width(), origInfo.height(), config,
+ SkBackingFit::kExact, origInfo.width(), origInfo.height(),
SkColorTypeToGrColorType(origInfo.colorType()), origInfo.refColorSpace(), sampleCount,
mipMapped, origin, surfaceProps, budgeted);
}
@@ -1665,26 +1656,17 @@
: SkBackingFit::kExact;
GrColorType colorType = fRenderTargetContext->colorSpaceInfo().colorType();
- const GrBackendFormat& origFormat = fRenderTargetContext->asSurfaceProxy()->backendFormat();
- GrBackendFormat format = origFormat.makeTexture2D();
- if (!format.isValid()) {
- return nullptr;
- }
if (colorType == GrColorType::kRGBA_1010102) {
// If the original device is 1010102, fall back to 8888 so that we have a usable alpha
// channel in the layer.
colorType = GrColorType::kRGBA_8888;
- format = fContext->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
}
- auto config = fContext->priv().caps()->getConfigFromBackendFormat(format, colorType);
sk_sp<GrRenderTargetContext> rtc(fContext->priv().makeDeferredRenderTargetContext(
- format,
fit,
cinfo.fInfo.width(),
cinfo.fInfo.height(),
- config,
- fRenderTargetContext->colorSpaceInfo().colorType(),
+ colorType,
fRenderTargetContext->colorSpaceInfo().refColorSpace(),
fRenderTargetContext->numSamples(),
GrMipMapped::kNo,
diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp
index bc1e3a0..58c0201 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -16,10 +16,7 @@
@class {
static bool TestForPreservingPMConversions(GrContext* context) {
static constexpr int kSize = 256;
- static constexpr GrPixelConfig kConfig = kRGBA_8888_GrPixelConfig;
static constexpr GrColorType kColorType = GrColorType::kRGBA_8888;
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromGrColorType(kColorType, GrSRGBEncoded::kNo);
SkAutoTMalloc<uint32_t> data(kSize * kSize * 3);
uint32_t* srcData = data.get();
uint32_t* firstRead = data.get() + kSize * kSize;
@@ -44,13 +41,13 @@
kRGBA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<GrRenderTargetContext> readRTC(
- context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact,
+ context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
kSize, kSize,
- kConfig, kColorType, nullptr));
+ kColorType, nullptr));
sk_sp<GrRenderTargetContext> tempRTC(
- context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact,
+ context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
kSize, kSize,
- kConfig, kColorType, nullptr));
+ kColorType, nullptr));
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
return false;
}
diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp
index 1f57b4e..de614c4 100644
--- a/src/gpu/effects/GrRRectBlurEffect.fp
+++ b/src/gpu/effects/GrRRectBlurEffect.fp
@@ -53,14 +53,11 @@
sk_sp<GrTextureProxy> mask(proxyProvider->findOrCreateProxyByUniqueKey(
key, kBottomLeft_GrSurfaceOrigin));
if (!mask) {
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
// TODO: this could be approx but the texture coords will need to be updated
sk_sp<GrRenderTargetContext> rtc(
context->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, size.fWidth,
- size.fHeight, kAlpha_8_GrPixelConfig,
- GrColorType::kAlpha_8, nullptr));
+ SkBackingFit::kExact, size.fWidth,
+ size.fHeight, GrColorType::kAlpha_8, nullptr));
if (!rtc) {
return nullptr;
}
diff --git a/src/gpu/effects/generated/GrConfigConversionEffect.h b/src/gpu/effects/generated/GrConfigConversionEffect.h
index f855454..1915ba9 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.h
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.h
@@ -24,10 +24,7 @@
public:
static bool TestForPreservingPMConversions(GrContext* context) {
static constexpr int kSize = 256;
- static constexpr GrPixelConfig kConfig = kRGBA_8888_GrPixelConfig;
static constexpr GrColorType kColorType = GrColorType::kRGBA_8888;
- const GrBackendFormat format = context->priv().caps()->getBackendFormatFromGrColorType(
- kColorType, GrSRGBEncoded::kNo);
SkAutoTMalloc<uint32_t> data(kSize * kSize * 3);
uint32_t* srcData = data.get();
uint32_t* firstRead = data.get() + kSize * kSize;
@@ -52,9 +49,9 @@
SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<GrRenderTargetContext> readRTC(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kSize, kSize, kConfig, kColorType, nullptr));
+ SkBackingFit::kExact, kSize, kSize, kColorType, nullptr));
sk_sp<GrRenderTargetContext> tempRTC(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kSize, kSize, kConfig, kColorType, nullptr));
+ SkBackingFit::kExact, kSize, kSize, kColorType, nullptr));
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
return false;
}
diff --git a/src/gpu/effects/generated/GrRRectBlurEffect.h b/src/gpu/effects/generated/GrRRectBlurEffect.h
index c2b216b..aa00554 100644
--- a/src/gpu/effects/generated/GrRRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRRectBlurEffect.h
@@ -54,13 +54,11 @@
sk_sp<GrTextureProxy> mask(
proxyProvider->findOrCreateProxyByUniqueKey(key, kBottomLeft_GrSurfaceOrigin));
if (!mask) {
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
// TODO: this could be approx but the texture coords will need to be updated
sk_sp<GrRenderTargetContext> rtc(
context->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, size.fWidth, size.fHeight,
- kAlpha_8_GrPixelConfig, GrColorType::kAlpha_8, nullptr));
+ SkBackingFit::kExact, size.fWidth, size.fHeight, GrColorType::kAlpha_8,
+ nullptr));
if (!rtc) {
return nullptr;
}
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index 5f1098a..95d8893 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -234,13 +234,9 @@
gTextContext = GrTextContext::Make(GrTextContext::Options());
}
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
// Setup dummy SkPaint / GrPaint / GrRenderTargetContext
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, 1024, 1024, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr));
+ SkBackingFit::kApprox, 1024, 1024, GrColorType::kRGBA_8888, nullptr));
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index c4a5bab..730c9b1 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -86,16 +86,10 @@
sk_sp<GrTextureProxy> proxy = this->asTextureProxyRef(context);
- GrBackendFormat format = context->priv().caps()->getBackendFormatFromColorType(targetCT);
- if (!format.isValid()) {
- return nullptr;
- }
-
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, this->width(), this->height(),
- SkColorType2GrPixelConfig(targetCT), SkColorTypeToGrColorType(targetCT),
- nullptr));
+ SkBackingFit::kExact, this->width(), this->height(),
+ SkColorTypeToGrColorType(targetCT), nullptr));
if (!renderTargetContext) {
return nullptr;
}
@@ -228,13 +222,10 @@
const int width = imageSize.width();
const int height = imageSize.height();
- const GrBackendFormat format =
- ctx->priv().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->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, width, height, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin));
+ SkBackingFit::kExact, width, height, GrColorType::kRGBA_8888,
+ std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index 2a3b6bb..7b938dd 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -140,15 +140,11 @@
return nullptr;
}
- const GrBackendFormat format =
- fContext->priv().caps()->getBackendFormatFromColorType(kAssumedColorType);
-
// Needs to create a render target in order to draw to it for the yuv->rgb conversion.
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, this->width(), this->height(),
- kRGBA_8888_GrPixelConfig, GrColorType::kRGBA_8888, this->refColorSpace(), 1,
- GrMipMapped::kNo, fOrigin));
+ SkBackingFit::kExact, this->width(), this->height(), GrColorType::kRGBA_8888,
+ this->refColorSpace(), 1, GrMipMapped::kNo, fOrigin));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/image/SkImage_Lazy.cpp b/src/image/SkImage_Lazy.cpp
index a05eddd..b31063e 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -431,8 +431,6 @@
const GrSurfaceDesc desc = GrImageInfoToSurfaceDesc(this->imageInfo());
SkColorType colorType = this->colorType();
- GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromColorType(colorType);
ScopedGenerator generator(fSharedGenerator);
Generator_GrYUVProvider provider(generator);
@@ -446,7 +444,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, SkColorTypeToGrColorType(colorType),
+ proxy = provider.refAsTextureProxy(ctx, desc, SkColorTypeToGrColorType(colorType),
generatorColorSpace, thisColorSpace);
if (proxy) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index cb5d3bb..868e259 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -59,10 +59,7 @@
}
sk_sp<GrRenderTargetContext> newRTC(GrContext* context, int w, int h) {
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
- return context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact, w, h,
- kRGBA_8888_GrPixelConfig,
+ return context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, w, h,
GrColorType::kRGBA_8888, nullptr);
}
diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp
index 7cceb71..144e5f99 100644
--- a/tests/DefaultPathRendererTest.cpp
+++ b/tests/DefaultPathRendererTest.cpp
@@ -82,12 +82,10 @@
GrStyle style(SkStrokeRec::kFill_InitStyle);
- GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
{
auto rtc = ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, kBigSize/2 + 1, kBigSize/2 + 1,
- kRGBA_8888_GrPixelConfig, GrColorType::kRGBA_8888, nullptr);
+ SkBackingFit::kApprox, kBigSize/2 + 1, kBigSize/2 + 1,
+ GrColorType::kRGBA_8888, nullptr);
rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
@@ -105,8 +103,7 @@
{
auto rtc = ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kBigSize, kBigSize, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr);
+ SkBackingFit::kExact, kBigSize, kBigSize, GrColorType::kRGBA_8888, nullptr);
rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
diff --git a/tests/DrawOpAtlasTest.cpp b/tests/DrawOpAtlasTest.cpp
index 54ea360..3bc4ac8 100644
--- a/tests/DrawOpAtlasTest.cpp
+++ b/tests/DrawOpAtlasTest.cpp
@@ -191,11 +191,7 @@
auto textContext = drawingManager->getTextContext();
auto opMemoryPool = context->priv().opMemoryPool();
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
- auto rtc = context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kApprox, 32,
- 32, kRGBA_8888_GrPixelConfig,
+ auto rtc = context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 32, 32,
GrColorType::kRGBA_8888, nullptr);
SkPaint paint;
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 13f00de..9f17e20 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -157,11 +157,9 @@
sampleCnt = SkTMax(1, sampleCnt);
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContext(format,
- SkBackingFit::kExact,
+ context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
kRenderTargetWidth,
kRenderTargetHeight,
- kRGBA_8888_GrPixelConfig,
GrColorType::kRGBA_8888,
nullptr,
sampleCnt,
@@ -323,15 +321,11 @@
drawingManager->flush(nullptr, 0, SkSurface::BackendSurfaceAccess::kNoAccess, GrFlushInfo(),
GrPrepareForExternalIORequests());
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
// Validate that GrFPs work correctly without an input.
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContext(format,
- SkBackingFit::kExact,
+ context->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact,
kRenderTargetWidth,
kRenderTargetHeight,
- kRGBA_8888_GrPixelConfig,
GrColorType::kRGBA_8888,
nullptr));
if (!renderTargetContext) {
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index 539180d..927a975 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -63,9 +63,8 @@
: fCtx(ctx)
, fCCPR(fCtx->priv().drawingManager()->getCoverageCountingPathRenderer())
, fRTC(fCtx->priv().makeDeferredRenderTargetContext(
- ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType),
- SkBackingFit::kExact, kCanvasSize, kCanvasSize, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr))
+ SkBackingFit::kExact, kCanvasSize, kCanvasSize, GrColorType::kRGBA_8888,
+ nullptr))
, fDoStroke(doStroke) {
if (!fCCPR) {
ERRORF(reporter, "ccpr not enabled in GrContext for ccpr tests");
diff --git a/tests/GrMeshTest.cpp b/tests/GrMeshTest.cpp
index 5a4ae8d..800c9a9 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -83,12 +83,8 @@
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(GrMeshTest, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kImageWidth, kImageHeight, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr));
+ SkBackingFit::kExact, kImageWidth, kImageHeight, GrColorType::kRGBA_8888, nullptr));
if (!rtc) {
ERRORF(reporter, "could not create render target context.");
return;
diff --git a/tests/GrPipelineDynamicStateTest.cpp b/tests/GrPipelineDynamicStateTest.cpp
index 8331ae3..4e1a297 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -164,12 +164,8 @@
GrContext* context = ctxInfo.grContext();
GrResourceProvider* rp = context->priv().resourceProvider();
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kScreenSize, kScreenSize, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr));
+ SkBackingFit::kExact, kScreenSize, kScreenSize, GrColorType::kRGBA_8888, nullptr));
if (!rtc) {
ERRORF(reporter, "could not create render target context.");
return;
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index b9ef638..e1427b1 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -368,11 +368,8 @@
static sk_sp<SkSpecialSurface> create_empty_special_surface(GrContext* context, int widthHeight) {
if (context) {
- GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
- return SkSpecialSurface::MakeRenderTarget(context, format,
- widthHeight, widthHeight,
- kRGBA_8888_GrPixelConfig, nullptr);
+ return SkSpecialSurface::MakeRenderTarget(context, widthHeight, widthHeight,
+ GrColorType::kRGBA_8888, nullptr);
} else {
const SkImageInfo info = SkImageInfo::MakeN32(widthHeight, widthHeight,
kOpaque_SkAlphaType);
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 30d368d..177d7fc 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -207,18 +207,11 @@
for (bool nullTexture : {false, true}) {
LazyProxyTest test(reporter);
ctx->priv().addOnFlushCallbackObject(&test);
- GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrRenderTargetContext> rtc = ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr);
+ SkBackingFit::kExact, 100, 100, GrColorType::kRGBA_8888, nullptr);
REPORTER_ASSERT(reporter, rtc);
- format =
- ctx->priv().caps()->getBackendFormatFromGrColorType(GrColorType::kAlpha_F16,
- GrSRGBEncoded::kNo);
sk_sp<GrRenderTargetContext> mockAtlas = ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, 10, 10, kAlpha_half_GrPixelConfig,
- GrColorType::kAlpha_F16, nullptr);
+ SkBackingFit::kExact, 10, 10, GrColorType::kAlpha_F16, nullptr);
REPORTER_ASSERT(reporter, mockAtlas);
rtc->priv().testingOnly_addDrawOp(LazyProxyTest::Clip(&test, mockAtlas->asTextureProxy()),
LazyProxyTest::Op::Make(ctx.get(), proxyProvider, &test, nullTexture));
@@ -374,12 +367,9 @@
GrMockOptions mockOptions;
sk_sp<GrContext> ctx = GrContext::MakeMock(&mockOptions, GrContextOptions());
GrProxyProvider* proxyProvider = ctx->priv().proxyProvider();
- GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
for (bool failInstantiation : {false, true}) {
sk_sp<GrRenderTargetContext> rtc = ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr);
+ SkBackingFit::kExact, 100, 100, GrColorType::kRGBA_8888, nullptr);
REPORTER_ASSERT(reporter, rtc);
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad),
@@ -449,8 +439,7 @@
using LazyType = GrSurfaceProxy::LazyInstantiationType;
for (auto lazyType : {LazyType::kSingleUse, LazyType::kMultipleUse, LazyType::kDeinstantiate}) {
sk_sp<GrRenderTargetContext> rtc = ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr);
+ SkBackingFit::kExact, 100, 100, GrColorType::kRGBA_8888, nullptr);
REPORTER_ASSERT(reporter, rtc);
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad),
diff --git a/tests/OnFlushCallbackTest.cpp b/tests/OnFlushCallbackTest.cpp
index 1b6a868..1d45ad8 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -433,15 +433,10 @@
// This creates an off-screen rendertarget whose ops which eventually pull from the atlas.
static sk_sp<GrTextureProxy> make_upstream_image(GrContext* context, AtlasObject* object, int start,
sk_sp<GrTextureProxy> atlasProxy) {
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
sk_sp<GrRenderTargetContext> rtc(
- context->priv().makeDeferredRenderTargetContext(format,
- SkBackingFit::kApprox,
+ context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
3*kDrawnTileSize,
kDrawnTileSize,
- kRGBA_8888_GrPixelConfig,
GrColorType::kRGBA_8888,
nullptr));
@@ -556,15 +551,10 @@
static const int kFinalWidth = 6*kDrawnTileSize;
static const int kFinalHeight = kDrawnTileSize;
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
sk_sp<GrRenderTargetContext> rtc(
- context->priv().makeDeferredRenderTargetContext(format,
- SkBackingFit::kApprox,
+ context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox,
kFinalWidth,
kFinalHeight,
- kRGBA_8888_GrPixelConfig,
GrColorType::kRGBA_8888,
nullptr));
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index 09aa956..6ab7fb0 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -79,12 +79,9 @@
ctx->setResourceCacheLimits(100, 8000000);
GrResourceCache* cache = ctx->priv().getResourceCache();
- const GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
sk_sp<GrRenderTargetContext> rtc(ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
+ SkBackingFit::kApprox, 800, 800, GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin));
if (!rtc) {
return;
}
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 496a522..9e27d72 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -132,12 +132,8 @@
GrGpu* gpu = context->priv().getGpu();
#endif
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kApprox, 1, 1,
- kRGBA_8888_GrPixelConfig,
+ context->priv().makeDeferredRenderTargetContext(SkBackingFit::kApprox, 1, 1,
GrColorType::kRGBA_8888, nullptr));
if (!renderTargetContext) {
ERRORF(reporter, "Could not create render target context.");
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 9503e32..f0faf8c 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -175,8 +175,7 @@
for (int parentCnt = 0; parentCnt < 2; parentCnt++) {
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, 1, 1, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr));
+ SkBackingFit::kApprox, 1, 1, GrColorType::kRGBA_8888, nullptr));
{
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact,
@@ -432,14 +431,10 @@
// use --processorSeed <seed> (without --randomProcessorTest) to reproduce.
SkRandom random(seed);
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
// Make the destination context for the test.
static constexpr int kRenderSize = 256;
sk_sp<GrRenderTargetContext> rtc = context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr);
+ SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
sk_sp<GrTextureProxy> proxies[2];
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
@@ -670,14 +665,10 @@
SkRandom random;
- const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
// Make the destination context for the test.
static constexpr int kRenderSize = 1024;
sk_sp<GrRenderTargetContext> rtc = context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr);
+ SkBackingFit::kExact, kRenderSize, kRenderSize, GrColorType::kRGBA_8888, nullptr);
sk_sp<GrTextureProxy> proxies[2];
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index c794c14..4b8f0f7 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -26,11 +26,8 @@
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
sk_sp<GrTextureProxy> rectProxy, GrColorType colorType,
uint32_t expectedPixelValues[]) {
- GrBackendFormat format = rectProxy->backendFormat().makeTexture2D();
- SkASSERT(format.isValid());
sk_sp<GrRenderTargetContext> rtContext(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, rectProxy->width(), rectProxy->height(),
- rectProxy->config(), colorType, nullptr));
+ SkBackingFit::kExact, rectProxy->width(), rectProxy->height(), colorType, nullptr));
for (auto filter : {GrSamplerState::Filter::kNearest,
GrSamplerState::Filter::kBilerp,
GrSamplerState::Filter::kMipMap}) {
diff --git a/tests/RenderTargetContextTest.cpp b/tests/RenderTargetContextTest.cpp
index 61e6b30..6ad48fc 100644
--- a/tests/RenderTargetContextTest.cpp
+++ b/tests/RenderTargetContextTest.cpp
@@ -16,11 +16,7 @@
static const int kSize = 64;
static sk_sp<GrRenderTargetContext> get_rtc(GrContext* ctx) {
- const GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
-
- return ctx->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact, kSize, kSize,
- kRGBA_8888_GrPixelConfig,
+ return ctx->priv().makeDeferredRenderTargetContext(SkBackingFit::kExact, kSize, kSize,
GrColorType::kRGBA_8888, nullptr);
}
diff --git a/tests/SpecialSurfaceTest.cpp b/tests/SpecialSurfaceTest.cpp
index f94d22b..d98c209 100644
--- a/tests/SpecialSurfaceTest.cpp
+++ b/tests/SpecialSurfaceTest.cpp
@@ -78,19 +78,13 @@
}
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SpecialSurface_Gpu1, reporter, ctxInfo) {
- for (auto config : { kRGBA_8888_GrPixelConfig, kRGBA_1010102_GrPixelConfig }) {
- const GrCaps* caps = ctxInfo.grContext()->priv().caps();
- if (!caps->isConfigRenderable(config)) {
+ for (auto colorType : {GrColorType::kRGBA_8888, GrColorType::kRGBA_1010102}) {
+ if (!ctxInfo.grContext()->colorTypeSupportedAsSurface(
+ GrColorTypeToSkColorType(colorType))) {
continue;
}
- GrSRGBEncoded srgbEncoded = GrSRGBEncoded::kNo;
- GrColorType colorType = GrPixelConfigToColorTypeAndEncoding(config, &srgbEncoded);
- const GrBackendFormat format =
- caps->getBackendFormatFromGrColorType(colorType, srgbEncoded);
- sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(ctxInfo.grContext(),
- format,
- kSmallerSize, kSmallerSize,
- config, nullptr));
+ sk_sp<SkSpecialSurface> surf(SkSpecialSurface::MakeRenderTarget(
+ ctxInfo.grContext(), kSmallerSize, kSmallerSize, colorType, nullptr));
test_surface(surf, reporter, 0);
}
}
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index 9e6ef21..25eece5 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -733,11 +733,9 @@
DEF_GPUTEST_FOR_ALL_CONTEXTS(TessellatingPathRendererTests, reporter, ctxInfo) {
GrContext* ctx = ctxInfo.grContext();
- const GrBackendFormat format =
- ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrRenderTargetContext> rtc(ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig,
- GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
+ SkBackingFit::kApprox, 800, 800, GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin));
if (!rtc) {
return;
}