Make GrColorSpaceInfo store GrColorType.
This is largely redundant with GrPixelConfig. However, we intend to
remove GrPixelConfig.
Bug: skia:7580
Change-Id: I03d92303be832711f7821f8a97d36387c9b04a9f
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/222883
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Brian Salomon <bsalomon@google.com>
diff --git a/bench/VertexColorSpaceBench.cpp b/bench/VertexColorSpaceBench.cpp
index 0a5a15b..8891aed 100644
--- a/bench/VertexColorSpaceBench.cpp
+++ b/bench/VertexColorSpaceBench.cpp
@@ -272,9 +272,9 @@
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, p3));
+ sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
+ format, SkBackingFit::kApprox, 100, 100, kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, p3));
SkASSERT(rtc);
for (int j = 0; j < kDrawsPerLoop; ++j) {
diff --git a/gm/clockwise.cpp b/gm/clockwise.cpp
index 0fa0935..5ffd0fc 100644
--- a/gm/clockwise.cpp
+++ b/gm/clockwise.cpp
@@ -187,9 +187,9 @@
// 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(), nullptr, 1, GrMipMapped::kNo,
- kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) {
+ rtc->asSurfaceProxy()->backendFormat(), SkBackingFit::kExact, 100, 200,
+ rtc->asSurfaceProxy()->config(), rtc->colorSpaceInfo().colorType(), nullptr, 1,
+ GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) {
topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
@@ -204,9 +204,9 @@
// 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(), nullptr, 1, GrMipMapped::kNo,
- kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) {
+ rtc->asSurfaceProxy()->backendFormat(), SkBackingFit::kExact, 100, 200,
+ rtc->asSurfaceProxy()->config(), rtc->colorSpaceInfo().colorType(), nullptr, 1,
+ GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes)) {
topLeftRTC->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
topLeftRTC->priv().testingOnly_addDrawOp(ClockwiseTestOp::Make(ctx, false, 0));
diff --git a/gm/samplelocations.cpp b/gm/samplelocations.cpp
index d3053a9..8c29acc 100644
--- a/gm/samplelocations.cpp
+++ b/gm/samplelocations.cpp
@@ -279,9 +279,9 @@
);
if (auto offscreenRTC = ctx->priv().makeDeferredRenderTargetContext(
- rtc->asSurfaceProxy()->backendFormat(), SkBackingFit::kExact, 200, 200,
- rtc->asSurfaceProxy()->config(), nullptr, rtc->numSamples(), GrMipMapped::kNo,
- fOrigin)) {
+ rtc->asSurfaceProxy()->backendFormat(), SkBackingFit::kExact, 200, 200,
+ rtc->asSurfaceProxy()->config(), rtc->colorSpaceInfo().colorType(), nullptr,
+ rtc->numSamples(), GrMipMapped::kNo, fOrigin)) {
offscreenRTC->clear(nullptr, {0,1,0,1}, GrRenderTargetContext::CanClearFullscreen::kYes);
// MIXED SAMPLES TODO: Mixed sampled stencil buffer.
diff --git a/gm/windowrectangles.cpp b/gm/windowrectangles.cpp
index a20f3f3..e73f474 100644
--- a/gm/windowrectangles.cpp
+++ b/gm/windowrectangles.cpp
@@ -230,12 +230,10 @@
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, nullptr));
+ sk_sp<GrRenderTargetContext> maskRTC(ctx->priv().makeDeferredRenderTargetContextWithFallback(
+ format, SkBackingFit::kExact, kCoverRect.width() + padRight,
+ kCoverRect.height() + padBottom, kAlpha_8_GrPixelConfig, GrColorType::kAlpha_8,
+ nullptr));
if (!maskRTC) {
return;
}
diff --git a/include/private/GrRecordingContext.h b/include/private/GrRecordingContext.h
index c15bcf6..0b8aa13 100644
--- a/include/private/GrRecordingContext.h
+++ b/include/private/GrRecordingContext.h
@@ -57,6 +57,7 @@
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
+ GrColorType,
SkAlphaType,
sk_sp<SkColorSpace> = nullptr,
const SkSurfaceProps* = nullptr);
@@ -67,6 +68,7 @@
GrMipMapped,
SkBackingFit,
SkBudgeted,
+ GrColorType,
SkAlphaType,
sk_sp<SkColorSpace> colorSpace = nullptr,
const SkSurfaceProps* = nullptr);
@@ -77,10 +79,18 @@
* renderTargetContexts created via this entry point.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, sk_sp<SkColorSpace> colorSpace, int sampleCnt = 1,
- GrMipMapped = GrMipMapped::kNo, GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
- const SkSurfaceProps* surfaceProps = nullptr, SkBudgeted = SkBudgeted::kYes,
+ const GrBackendFormat& format,
+ SkBackingFit fit,
+ int width,
+ int height,
+ GrPixelConfig config,
+ GrColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+ const SkSurfaceProps* surfaceProps = nullptr,
+ SkBudgeted = SkBudgeted::kYes,
GrProtected isProtected = GrProtected::kNo);
/*
@@ -90,10 +100,18 @@
* SRGB-ness will be preserved.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, sk_sp<SkColorSpace> colorSpace, int sampleCnt = 1,
- GrMipMapped = GrMipMapped::kNo, GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
- const SkSurfaceProps* surfaceProps = nullptr, SkBudgeted budgeted = SkBudgeted::kYes,
+ const GrBackendFormat& format,
+ SkBackingFit fit,
+ int width,
+ int height,
+ GrPixelConfig config,
+ GrColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+ const SkSurfaceProps* surfaceProps = nullptr,
+ SkBudgeted budgeted = SkBudgeted::kYes,
GrProtected isProtected = GrProtected::kNo);
GrAuditTrail* auditTrail() { return fAuditTrail.get(); }
diff --git a/samplecode/SampleCCPRGeometry.cpp b/samplecode/SampleCCPRGeometry.cpp
index 7d79369..0171b4a 100644
--- a/samplecode/SampleCCPRGeometry.cpp
+++ b/samplecode/SampleCCPRGeometry.cpp
@@ -190,11 +190,9 @@
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,
- nullptr);
+ sk_sp<GrRenderTargetContext> ccbuff = ctx->priv().makeDeferredRenderTargetContext(
+ format, SkBackingFit::kApprox, this->width(), this->height(),
+ kAlpha_half_GrPixelConfig, GrColorType::kAlpha_8, nullptr);
SkASSERT(ccbuff);
ccbuff->clear(nullptr, SK_PMColor4fTRANSPARENT,
GrRenderTargetContext::CanClearFullscreen::kYes);
diff --git a/src/atlastext/SkAtlasTextTarget.cpp b/src/atlastext/SkAtlasTextTarget.cpp
index bd82a58..468a44f 100644
--- a/src/atlastext/SkAtlasTextTarget.cpp
+++ b/src/atlastext/SkAtlasTextTarget.cpp
@@ -73,7 +73,7 @@
//////////////////////////////////////////////////////////////////////////////
-static const GrColorSpaceInfo kColorSpaceInfo(kPremul_SkAlphaType, nullptr,
+static const GrColorSpaceInfo kColorSpaceInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr,
kRGBA_8888_GrPixelConfig);
static const SkSurfaceProps kProps(
SkSurfaceProps::kUseDistanceFieldFonts_Flag, kUnknown_SkPixelGeometry);
diff --git a/src/core/SkDeferredDisplayListRecorder.cpp b/src/core/SkDeferredDisplayListRecorder.cpp
index 07e344c..3fc07fa 100644
--- a/src/core/SkDeferredDisplayListRecorder.cpp
+++ b/src/core/SkDeferredDisplayListRecorder.cpp
@@ -173,11 +173,12 @@
SkBudgeted::kYes,
fCharacterization.vulkanSecondaryCBCompatible());
- sk_sp<GrSurfaceContext> c =
- fContext->priv().makeWrappedSurfaceContext(std::move(proxy),
- kPremul_SkAlphaType,
- fCharacterization.refColorSpace(),
- &fCharacterization.surfaceProps());
+ sk_sp<GrSurfaceContext> c = fContext->priv().makeWrappedSurfaceContext(
+ std::move(proxy),
+ SkColorTypeToGrColorType(fCharacterization.colorType()),
+ kPremul_SkAlphaType,
+ fCharacterization.refColorSpace(),
+ &fCharacterization.surfaceProps());
fSurface = SkSurface_Gpu::MakeWrappedRenderTarget(fContext.get(),
sk_ref_sp(c->asRenderTargetContext()));
return SkToBool(fSurface.get());
diff --git a/src/core/SkGpuBlurUtils.cpp b/src/core/SkGpuBlurUtils.cpp
index d5cf02c..df592aa 100644
--- a/src/core/SkGpuBlurUtils.cpp
+++ b/src/core/SkGpuBlurUtils.cpp
@@ -118,6 +118,7 @@
SkBackingFit dstFit) {
GrPixelConfig config = get_blur_config(proxy.get());
+ GrColorType colorType = GrPixelConfigToColorType(config);
GrBackendFormat format = proxy->backendFormat().makeTexture2D();
if (!format.isValid()) {
@@ -126,8 +127,18 @@
sk_sp<GrRenderTargetContext> renderTargetContext;
renderTargetContext = context->priv().makeDeferredRenderTargetContext(
- format, dstFit, dstII.width(), dstII.height(), config, dstII.refColorSpace(), 1,
- GrMipMapped::kNo, proxy->origin(), nullptr, SkBudgeted::kYes,
+ format,
+ dstFit,
+ dstII.width(),
+ dstII.height(),
+ config,
+ colorType,
+ dstII.refColorSpace(),
+ 1,
+ GrMipMapped::kNo,
+ proxy->origin(),
+ nullptr,
+ SkBudgeted::kYes,
proxy->isProtected() ? GrProtected::kYes : GrProtected::kNo);
if (!renderTargetContext) {
return nullptr;
@@ -172,6 +183,7 @@
SkASSERT(srcRect.width() <= dstII.width() && srcRect.height() <= dstII.height());
GrPixelConfig config = get_blur_config(proxy.get());
+ GrColorType colorType = GrPixelConfigToColorType(config);
GrBackendFormat format = proxy->backendFormat().makeTexture2D();
if (!format.isValid()) {
@@ -180,8 +192,18 @@
sk_sp<GrRenderTargetContext> dstRenderTargetContext;
dstRenderTargetContext = context->priv().makeDeferredRenderTargetContext(
- format, fit, srcRect.width(), srcRect.height(), config, dstII.refColorSpace(), 1,
- GrMipMapped::kNo, proxy->origin(), nullptr, SkBudgeted::kYes,
+ format,
+ fit,
+ srcRect.width(),
+ srcRect.height(),
+ config,
+ colorType,
+ dstII.refColorSpace(),
+ 1,
+ GrMipMapped::kNo,
+ proxy->origin(),
+ nullptr,
+ SkBudgeted::kYes,
proxy->isProtected() ? GrProtected::kYes : GrProtected::kNo);
if (!dstRenderTargetContext) {
return nullptr;
@@ -279,6 +301,7 @@
SkASSERT(scaleFactorX > 1 || scaleFactorY > 1);
GrPixelConfig config = get_blur_config(src.get());
+ GrColorType colorType = GrPixelConfigToColorType(config);
SkIRect srcRect;
if (GrTextureDomain::kIgnore_Mode == mode) {
@@ -305,9 +328,19 @@
// 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,
- dstII.refColorSpace(), 1, GrMipMapped::kNo, src->origin(), nullptr,
- SkBudgeted::kYes, src->isProtected() ? GrProtected::kYes : GrProtected::kNo);
+ format,
+ SkBackingFit::kApprox,
+ dstRect.fRight,
+ dstRect.fBottom,
+ config,
+ colorType,
+ dstII.refColorSpace(),
+ 1,
+ GrMipMapped::kNo,
+ src->origin(),
+ nullptr,
+ SkBudgeted::kYes,
+ src->isProtected() ? GrProtected::kYes : GrProtected::kNo);
if (!dstRenderTargetContext) {
return nullptr;
}
@@ -412,18 +445,16 @@
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;
}
sk_sp<GrRenderTargetContext> dstRenderTargetContext =
- context->priv().makeDeferredRenderTargetContext(format,
- fit, dstII.width(), dstII.height(),
- config, dstII.refColorSpace(),
- 1, GrMipMapped::kNo,
- srcProxy->origin());
+ context->priv().makeDeferredRenderTargetContext(
+ format, fit, dstII.width(), dstII.height(), config, colorType,
+ dstII.refColorSpace(), 1, GrMipMapped::kNo, srcProxy->origin());
if (!dstRenderTargetContext) {
return nullptr;
}
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index a0f7fc8..2eaf04c 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -243,8 +243,7 @@
#if SK_SUPPORT_GPU
sk_sp<SkSpecialImage> SkImageFilter::DrawWithFP(GrRecordingContext* context,
- std::unique_ptr<GrFragmentProcessor>
- fp,
+ std::unique_ptr<GrFragmentProcessor> fp,
const SkIRect& bounds,
const OutputProperties& outputProperties,
GrProtected isProtected) {
@@ -254,15 +253,25 @@
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, std::move(colorSpace), 1, GrMipMapped::kNo,
- kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes,
- isProtected));
+ context->priv().makeDeferredRenderTargetContext(
+ format,
+ SkBackingFit::kApprox,
+ bounds.width(),
+ bounds.height(),
+ config,
+ colorType,
+ std::move(colorSpace),
+ 1,
+ GrMipMapped::kNo,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ SkBudgeted::kYes,
+ isProtected));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/core/SkSpecialImage.cpp b/src/core/SkSpecialImage.cpp
index a567d96..80f5ff5 100644
--- a/src/core/SkSpecialImage.cpp
+++ b/src/core/SkSpecialImage.cpp
@@ -433,7 +433,8 @@
return false;
}
sk_sp<GrSurfaceContext> sContext = fContext->priv().makeWrappedSurfaceContext(
- fTextureProxy, this->alphaType(), fColorSpace);
+ fTextureProxy, SkColorTypeToGrColorType(info.colorType()), this->alphaType(),
+ fColorSpace);
if (!sContext) {
return false;
}
diff --git a/src/core/SkSpecialSurface.cpp b/src/core/SkSpecialSurface.cpp
index 761a42c..8e894dd 100644
--- a/src/core/SkSpecialSurface.cpp
+++ b/src/core/SkSpecialSurface.cpp
@@ -178,10 +178,12 @@
return nullptr;
}
+ GrColorType colorType = GrPixelConfigToColorType(config);
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, width, height, config, std::move(colorSpace), 1,
- GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, props));
+ context->priv().makeDeferredRenderTargetContext(
+ format, SkBackingFit::kApprox, width, height, config, colorType,
+ std::move(colorSpace), 1, GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin,
+ props));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/effects/SkTableColorFilter.cpp b/src/effects/SkTableColorFilter.cpp
index 881ae12..6fdbcf1 100644
--- a/src/effects/SkTableColorFilter.cpp
+++ b/src/effects/SkTableColorFilter.cpp
@@ -399,8 +399,8 @@
));
sk_sp<SkColorSpace> colorSpace = GrTest::TestColorSpace(d->fRandom);
auto fp = filter->asFragmentProcessor(
- d->context(), GrColorSpaceInfo(kUnknown_SkAlphaType, std::move(colorSpace),
- kRGBA_8888_GrPixelConfig));
+ d->context(), GrColorSpaceInfo(GrColorType::kRGBA_8888, kUnknown_SkAlphaType,
+ std::move(colorSpace), kRGBA_8888_GrPixelConfig));
SkASSERT(fp);
return fp;
}
diff --git a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
index 2d0de7c..ba141a0 100644
--- a/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
+++ b/src/effects/imagefilters/SkAlphaThresholdFilter.cpp
@@ -108,9 +108,9 @@
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,
- nullptr));
+ context->priv().makeDeferredRenderTargetContextWithFallback(
+ format, SkBackingFit::kApprox, bounds.width(), bounds.height(),
+ kAlpha_8_GrPixelConfig, GrColorType::kAlpha_8, nullptr));
if (!rtContext) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkArithmeticImageFilter.cpp b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
index 12d3307..7da4a98 100644
--- a/src/effects/imagefilters/SkArithmeticImageFilter.cpp
+++ b/src/effects/imagefilters/SkArithmeticImageFilter.cpp
@@ -366,11 +366,20 @@
context->priv().caps()->getBackendFormatFromColorType(colorType);
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(),
- SkColorType2GrPixelConfig(colorType),
- sk_ref_sp(outputProperties.colorSpace()), 1, GrMipMapped::kNo,
- kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes, isProtected));
+ context->priv().makeDeferredRenderTargetContext(
+ format,
+ SkBackingFit::kApprox,
+ bounds.width(),
+ bounds.height(),
+ SkColorType2GrPixelConfig(colorType),
+ SkColorTypeToGrColorType(colorType),
+ sk_ref_sp(outputProperties.colorSpace()),
+ 1,
+ GrMipMapped::kNo,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ SkBudgeted::kYes,
+ isProtected));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/effects/imagefilters/SkDisplacementMapEffect.cpp b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
index bfbe526..416b2d4 100644
--- a/src/effects/imagefilters/SkDisplacementMapEffect.cpp
+++ b/src/effects/imagefilters/SkDisplacementMapEffect.cpp
@@ -278,7 +278,7 @@
if (!colorProxy || !displProxy) {
return nullptr;
}
- const auto isProtected = colorProxy->isProtected();
+ const auto isProtected = colorProxy->isProtected() ? GrProtected::kYes : GrProtected::kNo;
SkMatrix offsetMatrix = SkMatrix::MakeTrans(SkIntToScalar(colorOffset.fX - displOffset.fX),
SkIntToScalar(colorOffset.fY - displOffset.fY));
@@ -308,10 +308,19 @@
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(), config,
- sk_ref_sp(colorSpace), 1, GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin,
- nullptr, SkBudgeted::kYes,
- isProtected ? GrProtected::kYes : GrProtected::kNo));
+ format,
+ SkBackingFit::kApprox,
+ bounds.width(),
+ bounds.height(),
+ config,
+ SkColorTypeToGrColorType(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 f3895b0..04db4c5 100644
--- a/src/effects/imagefilters/SkLightingImageFilter.cpp
+++ b/src/effects/imagefilters/SkLightingImageFilter.cpp
@@ -469,9 +469,18 @@
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, offsetBounds.width(), offsetBounds.height(),
- SkColorType2GrPixelConfig(colorType), sk_ref_sp(outputProperties.colorSpace()),
- 1, GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes,
+ format,
+ SkBackingFit::kApprox,
+ offsetBounds.width(),
+ offsetBounds.height(),
+ SkColorType2GrPixelConfig(colorType),
+ SkColorTypeToGrColorType(colorType),
+ sk_ref_sp(outputProperties.colorSpace()),
+ 1,
+ GrMipMapped::kNo,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ SkBudgeted::kYes,
inputProxy->isProtected() ? GrProtected::kYes : GrProtected::kNo));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/effects/imagefilters/SkMorphologyImageFilter.cpp b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
index aa96efc..bba4314 100644
--- a/src/effects/imagefilters/SkMorphologyImageFilter.cpp
+++ b/src/effects/imagefilters/SkMorphologyImageFilter.cpp
@@ -487,8 +487,18 @@
if (radius.fWidth > 0) {
sk_sp<GrRenderTargetContext> dstRTContext(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace, 1,
- GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes,
+ format,
+ SkBackingFit::kApprox,
+ rect.width(),
+ rect.height(),
+ config,
+ SkColorTypeToGrColorType(colorType),
+ colorSpace,
+ 1,
+ GrMipMapped::kNo,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ SkBudgeted::kYes,
srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo));
if (!dstRTContext) {
return nullptr;
@@ -507,8 +517,18 @@
}
if (radius.fHeight > 0) {
sk_sp<GrRenderTargetContext> dstRTContext(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, rect.width(), rect.height(), config, colorSpace, 1,
- GrMipMapped::kNo, kBottomLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes,
+ format,
+ SkBackingFit::kApprox,
+ rect.width(),
+ rect.height(),
+ config,
+ SkColorTypeToGrColorType(colorType),
+ colorSpace,
+ 1,
+ GrMipMapped::kNo,
+ kBottomLeft_GrSurfaceOrigin,
+ nullptr,
+ SkBudgeted::kYes,
srcTexture->isProtected() ? GrProtected::kYes : GrProtected::kNo));
if (!dstRTContext) {
return nullptr;
diff --git a/src/effects/imagefilters/SkXfermodeImageFilter.cpp b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
index ff66985..b82ad30 100644
--- a/src/effects/imagefilters/SkXfermodeImageFilter.cpp
+++ b/src/effects/imagefilters/SkXfermodeImageFilter.cpp
@@ -312,10 +312,10 @@
context->priv().caps()->getBackendFormatFromColorType(colorType);
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, bounds.width(), bounds.height(),
- SkColorType2GrPixelConfig(colorType),
- sk_ref_sp(outputProperties.colorSpace())));
+ context->priv().makeDeferredRenderTargetContext(
+ format, SkBackingFit::kApprox, bounds.width(), bounds.height(),
+ SkColorType2GrPixelConfig(colorType), SkColorTypeToGrColorType(colorType),
+ sk_ref_sp(outputProperties.colorSpace())));
if (!renderTargetContext) {
return nullptr;
}
diff --git a/src/gpu/GrBitmapTextureMaker.cpp b/src/gpu/GrBitmapTextureMaker.cpp
index 8279a30..b114b7c 100644
--- a/src/gpu/GrBitmapTextureMaker.cpp
+++ b/src/gpu/GrBitmapTextureMaker.cpp
@@ -18,8 +18,8 @@
#include "src/gpu/SkGr.h"
static GrColorSpaceInfo make_info(const SkBitmap& bm) {
- return GrColorSpaceInfo(bm.alphaType(), bm.refColorSpace(),
- SkImageInfo2GrPixelConfig(bm.info()));
+ return GrColorSpaceInfo(SkColorTypeToGrColorType(bm.colorType()), bm.alphaType(),
+ bm.refColorSpace(), SkImageInfo2GrPixelConfig(bm.info()));
}
GrBitmapTextureMaker::GrBitmapTextureMaker(GrRecordingContext* context, const SkBitmap& bitmap,
diff --git a/src/gpu/GrBlurUtils.cpp b/src/gpu/GrBlurUtils.cpp
index 1a97888..0cc44b2 100644
--- a/src/gpu/GrBlurUtils.cpp
+++ b/src/gpu/GrBlurUtils.cpp
@@ -178,10 +178,10 @@
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, nullptr, sampleCnt, GrMipMapped::kNo,
- kTopLeft_GrSurfaceOrigin));
+ context->priv().makeDeferredRenderTargetContextWithFallback(
+ format, SkBackingFit::kApprox, maskRect.width(), maskRect.height(),
+ kAlpha_8_GrPixelConfig, 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 b7be58a..2acb5a8 100644
--- a/src/gpu/GrClipStackClip.cpp
+++ b/src/gpu/GrClipStackClip.cpp
@@ -359,10 +359,21 @@
GrBackendFormat format =
context->priv().caps()->getBackendFormatFromColorType(kAlpha_8_SkColorType);
- sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kApprox, reducedClip.width(), reducedClip.height(),
- kAlpha_8_GrPixelConfig, nullptr, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr,
- SkBudgeted::kYes, proxy->isProtected() ? GrProtected::kYes : GrProtected::kNo));
+ auto isProtected = proxy->isProtected() ? GrProtected::kYes : GrProtected::kNo;
+ sk_sp<GrRenderTargetContext> rtc(
+ context->priv().makeDeferredRenderTargetContextWithFallback(format,
+ SkBackingFit::kApprox,
+ reducedClip.width(),
+ reducedClip.height(),
+ kAlpha_8_GrPixelConfig,
+ GrColorType::kAlpha_8,
+ nullptr,
+ 1,
+ GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin,
+ nullptr,
+ SkBudgeted::kYes,
+ isProtected));
if (!rtc) {
return nullptr;
}
diff --git a/src/gpu/GrColorSpaceInfo.cpp b/src/gpu/GrColorSpaceInfo.cpp
index 71cff0e..a560ffd 100644
--- a/src/gpu/GrColorSpaceInfo.cpp
+++ b/src/gpu/GrColorSpaceInfo.cpp
@@ -8,9 +8,12 @@
#include "src/core/SkColorSpacePriv.h"
#include "src/gpu/GrColorSpaceInfo.h"
-GrColorSpaceInfo::GrColorSpaceInfo(SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace,
+GrColorSpaceInfo::GrColorSpaceInfo(GrColorType colorType,
+ SkAlphaType alphaType,
+ sk_sp<SkColorSpace> colorSpace,
GrPixelConfig config)
: fColorSpace(std::move(colorSpace))
+ , fColorType(colorType)
, fAlphaType(alphaType)
, fConfig(config)
, fInitializedColorSpaceXformFromSRGB(false) {}
diff --git a/src/gpu/GrColorSpaceInfo.h b/src/gpu/GrColorSpaceInfo.h
index 4fc80ad..039d108 100644
--- a/src/gpu/GrColorSpaceInfo.h
+++ b/src/gpu/GrColorSpaceInfo.h
@@ -16,27 +16,29 @@
/** Describes the color space properties of a surface context. */
class GrColorSpaceInfo {
public:
- GrColorSpaceInfo(SkAlphaType, sk_sp<SkColorSpace>, GrPixelConfig);
+ GrColorSpaceInfo(GrColorType, SkAlphaType, sk_sp<SkColorSpace>, GrPixelConfig);
bool isLinearlyBlended() const { return fColorSpace && fColorSpace->gammaIsLinear(); }
SkColorSpace* colorSpace() const { return fColorSpace.get(); }
sk_sp<SkColorSpace> refColorSpace() const { return fColorSpace; }
- SkAlphaType alphaType() const { return fAlphaType; }
-
GrColorSpaceXform* colorSpaceXformFromSRGB() const;
sk_sp<GrColorSpaceXform> refColorSpaceXformFromSRGB() const {
return sk_ref_sp(this->colorSpaceXformFromSRGB());
}
- // TODO: Remove or replace with SkColorType
+ GrColorType colorType() const { return fColorType; }
+ SkAlphaType alphaType() const { return fAlphaType; }
+
+ // TODO: Remove.
GrPixelConfig config() const { return fConfig; }
private:
sk_sp<SkColorSpace> fColorSpace;
- SkAlphaType fAlphaType;
mutable sk_sp<GrColorSpaceXform> fColorXformFromSRGB;
+ GrColorType fColorType;
+ SkAlphaType fAlphaType;
GrPixelConfig fConfig;
mutable bool fInitializedColorSpaceXformFromSRGB;
};
diff --git a/src/gpu/GrContextPriv.cpp b/src/gpu/GrContextPriv.cpp
index e387198..14504d5 100644
--- a/src/gpu/GrContextPriv.cpp
+++ b/src/gpu/GrContextPriv.cpp
@@ -49,11 +49,12 @@
}
sk_sp<GrSurfaceContext> GrContextPriv::makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy> proxy,
+ GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
- return fContext->makeWrappedSurfaceContext(std::move(proxy), alphaType, std::move(colorSpace),
- props);
+ return fContext->makeWrappedSurfaceContext(std::move(proxy), colorType, alphaType,
+ std::move(colorSpace), props);
}
sk_sp<GrSurfaceContext> GrContextPriv::makeDeferredSurfaceContext(const GrBackendFormat& format,
@@ -62,43 +63,47 @@
GrMipMapped mipMapped,
SkBackingFit fit,
SkBudgeted isDstBudgeted,
+ GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
return fContext->makeDeferredSurfaceContext(format, dstDesc, origin, mipMapped, fit,
- isDstBudgeted, alphaType, std::move(colorSpace),
- props);
+ isDstBudgeted, colorType, alphaType,
+ std::move(colorSpace), props);
}
sk_sp<GrRenderTargetContext> GrContextPriv::makeDeferredRenderTargetContext(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, sk_sp<SkColorSpace> colorSpace, int sampleCnt, GrMipMapped mipMapped,
- GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps, SkBudgeted budgeted,
+ 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,
GrProtected isProtected) {
- return fContext->makeDeferredRenderTargetContext(format, fit, width, height, config,
+ return fContext->makeDeferredRenderTargetContext(format, fit, width, height, config, 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,
- sk_sp<SkColorSpace> colorSpace,
- int sampleCnt,
- GrMipMapped mipMapped,
- GrSurfaceOrigin origin,
- const SkSurfaceProps* surfaceProps,
- SkBudgeted budgeted) {
- return fContext->makeDeferredRenderTargetContextWithFallback(format, fit, width, height, config,
- std::move(colorSpace), sampleCnt,
- mipMapped, origin, surfaceProps,
- budgeted);
+ 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) {
+ return fContext->makeDeferredRenderTargetContextWithFallback(
+ format, fit, width, height, config, colorType, std::move(colorSpace), sampleCnt,
+ mipMapped, origin, surfaceProps, budgeted);
}
sk_sp<GrTextureContext> GrContextPriv::makeBackendTextureContext(const GrBackendTexture& tex,
GrSurfaceOrigin origin,
+ GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace) {
ASSERT_SINGLE_OWNER
@@ -109,18 +114,19 @@
return nullptr;
}
- return this->drawingManager()->makeTextureContext(std::move(proxy), alphaType,
+ return this->drawingManager()->makeTextureContext(std::move(proxy), colorType, alphaType,
std::move(colorSpace));
}
sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureRenderTargetContext(
- const GrBackendTexture& tex,
- GrSurfaceOrigin origin,
- int sampleCnt,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props,
- ReleaseProc releaseProc,
- ReleaseContext releaseCtx) {
+ const GrBackendTexture& tex,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ GrColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props,
+ ReleaseProc releaseProc,
+ ReleaseContext releaseCtx) {
ASSERT_SINGLE_OWNER
SkASSERT(sampleCnt > 0);
@@ -131,17 +137,18 @@
return nullptr;
}
- return this->drawingManager()->makeRenderTargetContext(std::move(proxy),
+ return this->drawingManager()->makeRenderTargetContext(std::move(proxy), colorType,
std::move(colorSpace), props);
}
sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendRenderTargetRenderTargetContext(
- const GrBackendRenderTarget& backendRT,
- GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps,
- ReleaseProc releaseProc,
- ReleaseContext releaseCtx) {
+ const GrBackendRenderTarget& backendRT,
+ GrSurfaceOrigin origin,
+ GrColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ ReleaseProc releaseProc,
+ ReleaseContext releaseCtx) {
ASSERT_SINGLE_OWNER
sk_sp<GrSurfaceProxy> proxy = this->proxyProvider()->wrapBackendRenderTarget(
@@ -150,17 +157,17 @@
return nullptr;
}
- return this->drawingManager()->makeRenderTargetContext(std::move(proxy),
- std::move(colorSpace),
- surfaceProps);
+ return this->drawingManager()->makeRenderTargetContext(std::move(proxy), colorType,
+ std::move(colorSpace), surfaceProps);
}
sk_sp<GrRenderTargetContext> GrContextPriv::makeBackendTextureAsRenderTargetRenderTargetContext(
- const GrBackendTexture& tex,
- GrSurfaceOrigin origin,
- int sampleCnt,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props) {
+ const GrBackendTexture& tex,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ GrColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props) {
ASSERT_SINGLE_OWNER
SkASSERT(sampleCnt > 0);
sk_sp<GrSurfaceProxy> proxy(
@@ -169,9 +176,8 @@
return nullptr;
}
- return this->drawingManager()->makeRenderTargetContext(std::move(proxy),
- std::move(colorSpace),
- props);
+ return this->drawingManager()->makeRenderTargetContext(std::move(proxy), colorType,
+ std::move(colorSpace), props);
}
sk_sp<GrRenderTargetContext> GrContextPriv::makeVulkanSecondaryCBRenderTargetContext(
@@ -183,9 +189,11 @@
return nullptr;
}
- return this->drawingManager()->makeRenderTargetContext(std::move(proxy),
- imageInfo.refColorSpace(),
- props);
+ return this->drawingManager()->makeRenderTargetContext(
+ std::move(proxy),
+ SkColorTypeToGrColorType(imageInfo.colorType()),
+ imageInfo.refColorSpace(),
+ props);
}
GrSemaphoresSubmitted GrContextPriv::flushSurfaces(GrSurfaceProxy* proxies[], int numProxies,
diff --git a/src/gpu/GrContextPriv.h b/src/gpu/GrContextPriv.h
index 932cd4b..95c9c55 100644
--- a/src/gpu/GrContextPriv.h
+++ b/src/gpu/GrContextPriv.h
@@ -74,6 +74,7 @@
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
+ GrColorType,
SkAlphaType,
sk_sp<SkColorSpace> = nullptr,
const SkSurfaceProps* = nullptr);
@@ -84,6 +85,7 @@
GrMipMapped,
SkBackingFit,
SkBudgeted,
+ GrColorType,
SkAlphaType,
sk_sp<SkColorSpace> colorSpace = nullptr,
const SkSurfaceProps* = nullptr);
@@ -94,10 +96,18 @@
* renderTargetContexts created via this entry point.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, sk_sp<SkColorSpace> colorSpace, int sampleCnt = 1,
- GrMipMapped = GrMipMapped::kNo, GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
- const SkSurfaceProps* surfaceProps = nullptr, SkBudgeted = SkBudgeted::kYes,
+ const GrBackendFormat& format,
+ SkBackingFit fit,
+ int width,
+ int height,
+ GrPixelConfig config,
+ GrColorType,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+ const SkSurfaceProps* surfaceProps = nullptr,
+ SkBudgeted = SkBudgeted::kYes,
GrProtected isProtected = GrProtected::kNo);
/*
@@ -107,16 +117,18 @@
* SRGB-ness will be preserved.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format,
- SkBackingFit fit,
- int width, int height,
- GrPixelConfig config,
- sk_sp<SkColorSpace> colorSpace,
- int sampleCnt = 1,
- GrMipMapped = GrMipMapped::kNo,
- GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
- const SkSurfaceProps* surfaceProps = nullptr,
- SkBudgeted budgeted = SkBudgeted::kYes);
+ const GrBackendFormat& format,
+ SkBackingFit fit,
+ int width,
+ int height,
+ GrPixelConfig config,
+ GrColorType,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+ const SkSurfaceProps* surfaceProps = nullptr,
+ SkBudgeted budgeted = SkBudgeted::kYes);
GrAuditTrail* auditTrail() { return fContext->auditTrail(); }
@@ -127,6 +139,7 @@
sk_sp<GrTextureContext> makeBackendTextureContext(const GrBackendTexture&,
GrSurfaceOrigin,
+ GrColorType,
SkAlphaType,
sk_sp<SkColorSpace>);
@@ -135,28 +148,31 @@
typedef void (*ReleaseProc)(ReleaseContext);
sk_sp<GrRenderTargetContext> makeBackendTextureRenderTargetContext(
- const GrBackendTexture& tex,
- GrSurfaceOrigin origin,
- int sampleCnt,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* = nullptr,
- ReleaseProc = nullptr,
- ReleaseContext = nullptr);
+ const GrBackendTexture& tex,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ GrColorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* = nullptr,
+ ReleaseProc = nullptr,
+ ReleaseContext = nullptr);
sk_sp<GrRenderTargetContext> makeBackendRenderTargetRenderTargetContext(
- const GrBackendRenderTarget&,
- GrSurfaceOrigin origin,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* = nullptr,
- ReleaseProc = nullptr,
- ReleaseContext = nullptr);
+ const GrBackendRenderTarget&,
+ GrSurfaceOrigin origin,
+ GrColorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* = nullptr,
+ ReleaseProc = nullptr,
+ ReleaseContext = nullptr);
sk_sp<GrRenderTargetContext> makeBackendTextureAsRenderTargetRenderTargetContext(
- const GrBackendTexture& tex,
- GrSurfaceOrigin origin,
- int sampleCnt,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* = nullptr);
+ const GrBackendTexture& tex,
+ GrSurfaceOrigin origin,
+ int sampleCnt,
+ GrColorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* = nullptr);
sk_sp<GrRenderTargetContext> makeVulkanSecondaryCBRenderTargetContext(
const SkImageInfo&, const GrVkDrawableInfo&, const SkSurfaceProps* = nullptr);
diff --git a/src/gpu/GrDrawingManager.cpp b/src/gpu/GrDrawingManager.cpp
index e4e8296..724cc15 100644
--- a/src/gpu/GrDrawingManager.cpp
+++ b/src/gpu/GrDrawingManager.cpp
@@ -741,10 +741,11 @@
}
sk_sp<GrRenderTargetContext> GrDrawingManager::makeRenderTargetContext(
- sk_sp<GrSurfaceProxy> sProxy,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* surfaceProps,
- bool managedOpList) {
+ sk_sp<GrSurfaceProxy> sProxy,
+ GrColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* surfaceProps,
+ bool managedOpList) {
if (this->wasAbandoned() || !sProxy->asRenderTargetProxy()) {
return nullptr;
}
@@ -760,12 +761,14 @@
return sk_sp<GrRenderTargetContext>(new GrRenderTargetContext(fContext,
std::move(renderTargetProxy),
+ colorType,
std::move(colorSpace),
surfaceProps,
managedOpList));
}
sk_sp<GrTextureContext> GrDrawingManager::makeTextureContext(sk_sp<GrSurfaceProxy> sProxy,
+ GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace) {
if (this->wasAbandoned() || !sProxy->asTextureProxy()) {
@@ -785,7 +788,8 @@
sk_sp<GrTextureProxy> textureProxy(sk_ref_sp(sProxy->asTextureProxy()));
return sk_sp<GrTextureContext>(new GrTextureContext(fContext,
- alphaType,
std::move(textureProxy),
+ colorType,
+ alphaType,
std::move(colorSpace)));
}
diff --git a/src/gpu/GrDrawingManager.h b/src/gpu/GrDrawingManager.h
index 9a2d216..7a87ffc 100644
--- a/src/gpu/GrDrawingManager.h
+++ b/src/gpu/GrDrawingManager.h
@@ -42,10 +42,12 @@
void freeGpuResources();
sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
+ GrColorType,
sk_sp<SkColorSpace>,
const SkSurfaceProps*,
bool managedOpList = true);
sk_sp<GrTextureContext> makeTextureContext(sk_sp<GrSurfaceProxy>,
+ GrColorType,
SkAlphaType,
sk_sp<SkColorSpace>);
diff --git a/src/gpu/GrImageTextureMaker.cpp b/src/gpu/GrImageTextureMaker.cpp
index 64eeeee..0752e48 100644
--- a/src/gpu/GrImageTextureMaker.cpp
+++ b/src/gpu/GrImageTextureMaker.cpp
@@ -14,7 +14,9 @@
#include "src/image/SkImage_Lazy.h"
static GrColorSpaceInfo make_info(const SkImage*& image) {
- return GrColorSpaceInfo(image->alphaType(), image->refColorSpace(),
+ return GrColorSpaceInfo(SkColorTypeToGrColorType(image->colorType()),
+ image->alphaType(),
+ image->refColorSpace(),
SkImageInfo2GrPixelConfig(image->imageInfo()));
}
diff --git a/src/gpu/GrOnFlushResourceProvider.cpp b/src/gpu/GrOnFlushResourceProvider.cpp
index 0b607aa..ab5dcc9 100644
--- a/src/gpu/GrOnFlushResourceProvider.cpp
+++ b/src/gpu/GrOnFlushResourceProvider.cpp
@@ -16,9 +16,10 @@
#include "src/gpu/GrSurfaceProxy.h"
sk_sp<GrRenderTargetContext> GrOnFlushResourceProvider::makeRenderTargetContext(
- sk_sp<GrSurfaceProxy> proxy,
- sk_sp<SkColorSpace> colorSpace,
- const SkSurfaceProps* props) {
+ sk_sp<GrSurfaceProxy> proxy,
+ GrColorType colorType,
+ sk_sp<SkColorSpace> colorSpace,
+ const SkSurfaceProps* props) {
// 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!
@@ -26,10 +27,8 @@
return nullptr;
}
- sk_sp<GrRenderTargetContext> renderTargetContext(
- fDrawingMgr->makeRenderTargetContext(std::move(proxy),
- std::move(colorSpace),
- props, false));
+ sk_sp<GrRenderTargetContext> renderTargetContext(fDrawingMgr->makeRenderTargetContext(
+ std::move(proxy), colorType, std::move(colorSpace), props, false));
if (!renderTargetContext) {
return nullptr;
diff --git a/src/gpu/GrOnFlushResourceProvider.h b/src/gpu/GrOnFlushResourceProvider.h
index cdc9b7e..6cf0055 100644
--- a/src/gpu/GrOnFlushResourceProvider.h
+++ b/src/gpu/GrOnFlushResourceProvider.h
@@ -67,6 +67,7 @@
explicit GrOnFlushResourceProvider(GrDrawingManager* drawingMgr) : fDrawingMgr(drawingMgr) {}
sk_sp<GrRenderTargetContext> makeRenderTargetContext(sk_sp<GrSurfaceProxy>,
+ GrColorType,
sk_sp<SkColorSpace>,
const SkSurfaceProps*);
diff --git a/src/gpu/GrRecordingContext.cpp b/src/gpu/GrRecordingContext.cpp
index c4438ef..440e730 100644
--- a/src/gpu/GrRecordingContext.cpp
+++ b/src/gpu/GrRecordingContext.cpp
@@ -145,6 +145,7 @@
sk_sp<GrSurfaceContext> GrRecordingContext::makeWrappedSurfaceContext(
sk_sp<GrSurfaceProxy> proxy,
+ GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
@@ -152,12 +153,12 @@
if (proxy->asRenderTargetProxy()) {
SkASSERT(kPremul_SkAlphaType == alphaType || kOpaque_SkAlphaType == alphaType);
- return this->drawingManager()->makeRenderTargetContext(std::move(proxy),
+ return this->drawingManager()->makeRenderTargetContext(std::move(proxy), colorType,
std::move(colorSpace), props);
} else {
SkASSERT(proxy->asTextureProxy());
SkASSERT(!props);
- return this->drawingManager()->makeTextureContext(std::move(proxy), alphaType,
+ return this->drawingManager()->makeTextureContext(std::move(proxy), colorType, alphaType,
std::move(colorSpace));
}
}
@@ -169,6 +170,7 @@
GrMipMapped mipMapped,
SkBackingFit fit,
SkBudgeted isDstBudgeted,
+ GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
@@ -184,6 +186,7 @@
}
sk_sp<GrSurfaceContext> sContext = this->makeWrappedSurfaceContext(std::move(proxy),
+ colorType,
alphaType,
std::move(colorSpace),
props);
@@ -195,9 +198,18 @@
}
sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContext(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, sk_sp<SkColorSpace> colorSpace, int sampleCnt, GrMipMapped mipMapped,
- GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps, SkBudgeted budgeted,
+ 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,
GrProtected isProtected) {
SkASSERT(sampleCnt > 0);
if (this->abandoned()) {
@@ -224,9 +236,8 @@
auto drawingManager = this->drawingManager();
- sk_sp<GrRenderTargetContext> renderTargetContext =
- drawingManager->makeRenderTargetContext(std::move(rtp), std::move(colorSpace),
- surfaceProps);
+ sk_sp<GrRenderTargetContext> renderTargetContext = drawingManager->makeRenderTargetContext(
+ std::move(rtp), colorType, std::move(colorSpace), surfaceProps);
if (!renderTargetContext) {
return nullptr;
}
@@ -236,55 +247,109 @@
return renderTargetContext;
}
-static inline GrPixelConfig GrPixelConfigFallback(GrPixelConfig config) {
- switch (config) {
- case kAlpha_8_GrPixelConfig:
- case kAlpha_8_as_Alpha_GrPixelConfig:
- case kAlpha_8_as_Red_GrPixelConfig:
- case kRGB_565_GrPixelConfig:
- case kRGBA_4444_GrPixelConfig:
- case kBGRA_8888_GrPixelConfig:
- case kRGBA_1010102_GrPixelConfig:
- case kRGBA_half_GrPixelConfig:
- case kRGBA_half_Clamped_GrPixelConfig:
- return kRGBA_8888_GrPixelConfig;
- case kSBGRA_8888_GrPixelConfig:
- return kSRGBA_8888_GrPixelConfig;
- case kAlpha_half_GrPixelConfig:
- case kAlpha_half_as_Red_GrPixelConfig:
- return kRGBA_half_GrPixelConfig;
- case kGray_8_GrPixelConfig:
- case kGray_8_as_Lum_GrPixelConfig:
- case kGray_8_as_Red_GrPixelConfig:
- return kRGB_888_GrPixelConfig;
+static inline bool color_type_and_config_fallback(GrColorType* ct, GrPixelConfig* config) {
+ switch (*ct) {
+ 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 && *config != kSBGRA_8888_GrPixelConfig) {
+ return false;
+ }
+ *config = (*config == kSBGRA_8888_GrPixelConfig) ? kSRGBA_8888_GrPixelConfig
+ : 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;
+ 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;
+ 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;
default:
- return kUnknown_GrPixelConfig;
+ return false;
}
}
sk_sp<GrRenderTargetContext> GrRecordingContext::makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, sk_sp<SkColorSpace> colorSpace, int sampleCnt, GrMipMapped mipMapped,
- GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps, SkBudgeted budgeted,
+ 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,
GrProtected isProtected) {
GrBackendFormat localFormat = format;
SkASSERT(sampleCnt > 0);
if (0 == this->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)) {
+ // TODO: Make the fallback part of GrCaps?
+ if (!color_type_and_config_fallback(&colorType, &config)) {
return nullptr;
}
- localFormat = this->caps()->getBackendFormatFromColorType(colorType);
+ // 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,
+ return this->makeDeferredRenderTargetContext(localFormat, fit, width, height, config, colorType,
std::move(colorSpace), sampleCnt, mipMapped,
- origin, surfaceProps, budgeted);
+ origin, surfaceProps, budgeted, isProtected);
}
///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -306,11 +371,12 @@
sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeWrappedSurfaceContext(
sk_sp<GrSurfaceProxy> proxy,
+ GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
- return fContext->makeWrappedSurfaceContext(std::move(proxy), alphaType, std::move(colorSpace),
- props);
+ return fContext->makeWrappedSurfaceContext(std::move(proxy), colorType, alphaType,
+ std::move(colorSpace), props);
}
sk_sp<GrSurfaceContext> GrRecordingContextPriv::makeDeferredSurfaceContext(
@@ -320,33 +386,61 @@
GrMipMapped mipMapped,
SkBackingFit fit,
SkBudgeted isDstBudgeted,
+ GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* props) {
return fContext->makeDeferredSurfaceContext(format, dstDesc, origin, mipMapped, fit,
- isDstBudgeted, alphaType, std::move(colorSpace),
- props);
+ isDstBudgeted, colorType, alphaType,
+ std::move(colorSpace), props);
}
sk_sp<GrRenderTargetContext> GrRecordingContextPriv::makeDeferredRenderTargetContext(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, sk_sp<SkColorSpace> colorSpace, int sampleCnt, GrMipMapped mipMapped,
- GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps, SkBudgeted budgeted,
+ 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,
GrProtected isProtected) {
- return fContext->makeDeferredRenderTargetContext(format, fit, width, height, config,
+ return fContext->makeDeferredRenderTargetContext(format, fit, width, height, config, 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, sk_sp<SkColorSpace> colorSpace, int sampleCnt, GrMipMapped mipMapped,
- GrSurfaceOrigin origin, const SkSurfaceProps* surfaceProps, SkBudgeted budgeted,
+ 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,
GrProtected isProtected) {
- return fContext->makeDeferredRenderTargetContextWithFallback(format, fit, width, height, config,
- std::move(colorSpace), sampleCnt,
- mipMapped, origin, surfaceProps,
- budgeted, isProtected);
+ return fContext->makeDeferredRenderTargetContextWithFallback(format,
+ fit,
+ width,
+ height,
+ config,
+ colorType,
+ std::move(colorSpace),
+ sampleCnt,
+ mipMapped,
+ origin,
+ surfaceProps,
+ budgeted,
+ isProtected);
}
GrContext* GrRecordingContextPriv::backdoor() {
diff --git a/src/gpu/GrRecordingContextPriv.h b/src/gpu/GrRecordingContextPriv.h
index 9e36751..12206c8 100644
--- a/src/gpu/GrRecordingContextPriv.h
+++ b/src/gpu/GrRecordingContextPriv.h
@@ -58,6 +58,7 @@
void addOnFlushCallbackObject(GrOnFlushCallbackObject*);
sk_sp<GrSurfaceContext> makeWrappedSurfaceContext(sk_sp<GrSurfaceProxy>,
+ GrColorType,
SkAlphaType,
sk_sp<SkColorSpace> = nullptr,
const SkSurfaceProps* = nullptr);
@@ -68,6 +69,7 @@
GrMipMapped,
SkBackingFit,
SkBudgeted,
+ GrColorType,
SkAlphaType,
sk_sp<SkColorSpace> colorSpace = nullptr,
const SkSurfaceProps* = nullptr);
@@ -78,10 +80,18 @@
* renderTargetContexts created via this entry point.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContext(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, sk_sp<SkColorSpace> colorSpace, int sampleCnt = 1,
- GrMipMapped = GrMipMapped::kNo, GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
- const SkSurfaceProps* surfaceProps = nullptr, SkBudgeted = SkBudgeted::kYes,
+ const GrBackendFormat& format,
+ SkBackingFit fit,
+ int width,
+ int height,
+ GrPixelConfig config,
+ GrColorType,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+ const SkSurfaceProps* surfaceProps = nullptr,
+ SkBudgeted = SkBudgeted::kYes,
GrProtected isProtected = GrProtected::kNo);
/*
@@ -91,10 +101,18 @@
* SRGB-ness will be preserved.
*/
sk_sp<GrRenderTargetContext> makeDeferredRenderTargetContextWithFallback(
- const GrBackendFormat& format, SkBackingFit fit, int width, int height,
- GrPixelConfig config, sk_sp<SkColorSpace> colorSpace, int sampleCnt = 1,
- GrMipMapped = GrMipMapped::kNo, GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
- const SkSurfaceProps* surfaceProps = nullptr, SkBudgeted budgeted = SkBudgeted::kYes,
+ const GrBackendFormat& format,
+ SkBackingFit fit,
+ int width,
+ int height,
+ GrPixelConfig config,
+ GrColorType,
+ sk_sp<SkColorSpace> colorSpace,
+ int sampleCnt = 1,
+ GrMipMapped = GrMipMapped::kNo,
+ GrSurfaceOrigin origin = kBottomLeft_GrSurfaceOrigin,
+ const SkSurfaceProps* surfaceProps = nullptr,
+ SkBudgeted budgeted = SkBudgeted::kYes,
GrProtected isProtected = GrProtected::kNo);
GrAuditTrail* auditTrail() { return fContext->auditTrail(); }
diff --git a/src/gpu/GrRenderTargetContext.cpp b/src/gpu/GrRenderTargetContext.cpp
index 43a7086..489fd25 100644
--- a/src/gpu/GrRenderTargetContext.cpp
+++ b/src/gpu/GrRenderTargetContext.cpp
@@ -143,10 +143,12 @@
// when the renderTargetContext attempts to use it (via getOpList).
GrRenderTargetContext::GrRenderTargetContext(GrRecordingContext* context,
sk_sp<GrRenderTargetProxy> rtp,
+ GrColorType colorType,
sk_sp<SkColorSpace> colorSpace,
const SkSurfaceProps* surfaceProps,
bool managedOpList)
- : GrSurfaceContext(context, kPremul_SkAlphaType, std::move(colorSpace), rtp->config())
+ : GrSurfaceContext(context, colorType, kPremul_SkAlphaType, std::move(colorSpace),
+ rtp->config())
, fRenderTargetProxy(std::move(rtp))
, fOpList(sk_ref_sp(fRenderTargetProxy->getLastRenderTargetOpList()))
, fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
@@ -1696,6 +1698,7 @@
}
SkASSERT(stepsX || stepsY);
auto rescaleColorSapce = this->colorSpaceInfo().refColorSpace();
+ auto currRTC = sk_ref_sp(this);
// Assume we should ignore the rescale linear request if the surface has no color space since
// it's unclear how we'd linearize from an unknown color space.
if (rescaleGamma == SkSurface::RescaleGamma::kLinear &&
@@ -1707,8 +1710,8 @@
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, cs, 1,
- GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ backendFormat, SkBackingFit::kExact, srcW, srcH, kRGBA_half_GrPixelConfig,
+ GrColorType::kRGBA_F16, cs, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
if (!linearRTC) {
return nullptr;
}
@@ -1718,12 +1721,12 @@
GrAA::kNo, GrQuadAAFlags::kNone, constraint, SkMatrix::I(),
std::move(xform));
texProxy = linearRTC->asTextureProxyRef();
+ currRTC = std::move(linearRTC);
rescaleColorSapce = std::move(cs);
srcX = 0;
srcY = 0;
constraint = SkCanvas::kFast_SrcRectConstraint;
}
- sk_sp<GrRenderTargetContext> currRTC;
while (stepsX || stepsY) {
int nextW = info.width();
int nextH = info.height();
@@ -1747,6 +1750,7 @@
}
GrBackendFormat backendFormat = texProxy->backendFormat().makeTexture2D();
GrPixelConfig config = texProxy->config();
+ GrColorType colorType = currRTC->colorSpaceInfo().colorType();
auto cs = rescaleColorSapce;
sk_sp<GrColorSpaceXform> xform;
if (!stepsX && !stepsY) {
@@ -1754,12 +1758,13 @@
backendFormat = this->caps()->getBackendFormatFromColorType(info.colorType());
config = this->caps()->getConfigFromBackendFormat(backendFormat, info.colorType());
cs = info.refColorSpace();
+ colorType = SkColorTypeToGrColorType(info.colorType());
xform = GrColorSpaceXform::Make(rescaleColorSapce.get(),
kPremul_SkAlphaType, cs.get(), info.alphaType());
}
currRTC = fContext->priv().makeDeferredRenderTargetContextWithFallback(
- backendFormat, SkBackingFit::kExact, nextW, nextH, config, std::move(cs), 1,
- GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ backendFormat, SkBackingFit::kExact, nextW, nextH, config, colorType, std::move(cs),
+ 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
if (!currRTC) {
return nullptr;
}
@@ -1882,8 +1887,8 @@
}
rtc = direct->priv().makeDeferredRenderTargetContext(
backendFormat, SkBackingFit::kApprox, srcRect.width(), srcRect.height(),
- fRenderTargetProxy->config(), info.refColorSpace(), 1, GrMipMapped::kNo,
- kTopLeft_GrSurfaceOrigin);
+ fRenderTargetProxy->config(), this->colorSpaceInfo().colorType(),
+ info.refColorSpace(), 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
if (!rtc) {
callback(context, nullptr, 0);
return;
@@ -2074,7 +2079,8 @@
SkRect srcRectToDraw = SkRect::Make(srcRect);
rtc = direct->priv().makeDeferredRenderTargetContext(
backendFormat, SkBackingFit::kApprox, dstW, dstH, fRenderTargetProxy->config(),
- dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ this->colorSpaceInfo().colorType(), dstColorSpace, 1, GrMipMapped::kNo,
+ kTopLeft_GrSurfaceOrigin);
if (!rtc) {
callback(context, nullptr, nullptr);
return;
@@ -2096,14 +2102,14 @@
const auto backendFormat = this->caps()->getBackendFormatFromGrColorType(GrColorType::kAlpha_8,
GrSRGBEncoded::kNo);
auto yRTC = direct->priv().makeDeferredRenderTargetContext(
- backendFormat, SkBackingFit::kApprox, dstW, dstH, kAlpha_8_GrPixelConfig, dstColorSpace,
- 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ 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,
- dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ GrColorType::kAlpha_8, dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
auto vRTC = direct->priv().makeDeferredRenderTargetContext(
backendFormat, SkBackingFit::kApprox, dstW / 2, dstH / 2, kAlpha_8_GrPixelConfig,
- dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
+ GrColorType::kAlpha_8, dstColorSpace, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin);
if (!yRTC || !uRTC || !vRTC) {
callback(context, nullptr, nullptr);
return;
@@ -2658,8 +2664,7 @@
}
bool GrRenderTargetContext::setupDstProxy(GrRenderTargetProxy* rtProxy, const GrClip& clip,
- const GrOp& op,
- GrXferProcessor::DstProxy* dstProxy) {
+ const GrOp& op, GrXferProcessor::DstProxy* dstProxy) {
// If we are wrapping a vulkan secondary command buffer, we can't make a dst copy because we
// don't actually have a VkImage to make a copy of. Additionally we don't have the power to
// start and stop the render pass in order to make the copy.
@@ -2736,7 +2741,6 @@
fit = SkBackingFit::kApprox;
matchRects = GrSurfaceProxy::RectsMustMatch::kNo;
}
-
sk_sp<GrTextureProxy> newProxy = GrSurfaceProxy::Copy(fContext, rtProxy, GrMipMapped::kNo,
copyRect, fit, SkBudgeted::kYes,
matchRects);
diff --git a/src/gpu/GrRenderTargetContext.h b/src/gpu/GrRenderTargetContext.h
index c6869a6..5fa87e5 100644
--- a/src/gpu/GrRenderTargetContext.h
+++ b/src/gpu/GrRenderTargetContext.h
@@ -494,9 +494,8 @@
#endif
protected:
- GrRenderTargetContext(GrRecordingContext*, sk_sp<GrRenderTargetProxy>,
- sk_sp<SkColorSpace>, const SkSurfaceProps*,
- bool managedOpList = true);
+ GrRenderTargetContext(GrRecordingContext*, sk_sp<GrRenderTargetProxy>, GrColorType,
+ sk_sp<SkColorSpace>, const SkSurfaceProps*, bool managedOpList = true);
SkDEBUGCODE(void validate() const override;)
diff --git a/src/gpu/GrResourceProvider.cpp b/src/gpu/GrResourceProvider.cpp
index 9be8bb6..ae847e8 100644
--- a/src/gpu/GrResourceProvider.cpp
+++ b/src/gpu/GrResourceProvider.cpp
@@ -106,8 +106,8 @@
}
auto srcInfo = SkImageInfo::Make(desc.fWidth, desc.fHeight, colorType,
kUnknown_SkAlphaType);
- sk_sp<GrSurfaceContext> sContext =
- context->priv().makeWrappedSurfaceContext(std::move(proxy), kUnknown_SkAlphaType);
+ sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
+ std::move(proxy), SkColorTypeToGrColorType(colorType), kUnknown_SkAlphaType);
if (!sContext) {
return nullptr;
}
diff --git a/src/gpu/GrSurfaceContext.cpp b/src/gpu/GrSurfaceContext.cpp
index 9110477..72f38e0 100644
--- a/src/gpu/GrSurfaceContext.cpp
+++ b/src/gpu/GrSurfaceContext.cpp
@@ -32,10 +32,11 @@
// stack. When this occurs with a closed GrOpList, a new one will be allocated
// when the renderTargetContext attempts to use it (via getOpList).
GrSurfaceContext::GrSurfaceContext(GrRecordingContext* context,
+ GrColorType colorType,
SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace,
GrPixelConfig config)
- : fContext(context), fColorSpaceInfo(alphaType, std::move(colorSpace), config) {}
+ : fContext(context), fColorSpaceInfo(colorType, alphaType, std::move(colorSpace), config) {}
GrAuditTrail* GrSurfaceContext::auditTrail() {
return fContext->priv().auditTrail();
@@ -186,20 +187,23 @@
if (readFlag == GrCaps::kRequiresCopy_ReadFlag || 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();
sk_sp<GrRenderTargetContext> tempCtx = direct->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, width, height, config, std::move(cs), 1,
+ format, SkBackingFit::kApprox, width, height, config, colorType, std::move(cs), 1,
GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin, nullptr, SkBudgeted::kYes);
if (!tempCtx) {
return false;
@@ -356,15 +360,18 @@
desc.fWidth = width;
desc.fHeight = height;
desc.fSampleCnt = 1;
+ GrColorType colorType;
GrBackendFormat format;
SkAlphaType alphaType;
if (canvas2DFastPath) {
desc.fConfig = kRGBA_8888_GrPixelConfig;
+ colorType = GrColorType::kRGBA_8888;
format = caps->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
alphaType = kUnpremul_SkAlphaType;
} else {
desc.fConfig = dstProxy->config();
+ colorType = this->colorSpaceInfo().colorType();
format = dstProxy->backendFormat().makeTexture2D();
if (!format.isValid()) {
return false;
@@ -386,7 +393,7 @@
return false;
}
auto tempCtx = direct->priv().drawingManager()->makeTextureContext(
- tempProxy, alphaType, this->colorSpaceInfo().refColorSpace());
+ tempProxy, colorType, alphaType, this->colorSpaceInfo().refColorSpace());
if (!tempCtx) {
return false;
}
diff --git a/src/gpu/GrSurfaceContext.h b/src/gpu/GrSurfaceContext.h
index 650b041..1b61e5a 100644
--- a/src/gpu/GrSurfaceContext.h
+++ b/src/gpu/GrSurfaceContext.h
@@ -128,7 +128,11 @@
protected:
friend class GrSurfaceContextPriv;
- GrSurfaceContext(GrRecordingContext*, SkAlphaType, sk_sp<SkColorSpace>, GrPixelConfig);
+ GrSurfaceContext(GrRecordingContext*,
+ GrColorType,
+ SkAlphaType,
+ sk_sp<SkColorSpace>,
+ GrPixelConfig);
GrDrawingManager* drawingManager();
const GrDrawingManager* drawingManager() const;
diff --git a/src/gpu/GrSurfaceProxy.cpp b/src/gpu/GrSurfaceProxy.cpp
index 9aa7a30..09224be 100644
--- a/src/gpu/GrSurfaceProxy.cpp
+++ b/src/gpu/GrSurfaceProxy.cpp
@@ -362,11 +362,11 @@
if (!srcRect.intersect(SkIRect::MakeWH(src->width(), src->height()))) {
return nullptr;
}
-
+ auto colorType = GrPixelConfigToColorType(src->config());
if (src->backendFormat().textureType() != GrTextureType::kExternal) {
sk_sp<GrSurfaceContext> dstContext(context->priv().makeDeferredSurfaceContext(
src->backendFormat().makeTexture2D(), dstDesc, src->origin(), mipMapped, fit,
- budgeted, kUnknown_SkAlphaType));
+ budgeted, colorType, kUnknown_SkAlphaType));
if (!dstContext) {
return nullptr;
}
@@ -381,8 +381,8 @@
}
sk_sp<GrRenderTargetContext> dstContext = context->priv().makeDeferredRenderTargetContext(
- format, fit, dstDesc.fWidth, dstDesc.fHeight, dstDesc.fConfig, nullptr, 1,
- mipMapped, src->origin(), nullptr, budgeted);
+ format, fit, dstDesc.fWidth, dstDesc.fHeight, dstDesc.fConfig, colorType, nullptr,
+ 1, mipMapped, src->origin(), nullptr, budgeted);
if (dstContext && dstContext->blitTexture(src->asTextureProxy(), srcRect, dstPoint)) {
return dstContext->asTextureProxyRef();
diff --git a/src/gpu/GrTestUtils.cpp b/src/gpu/GrTestUtils.cpp
index 45a3bb4..0c15e6b 100644
--- a/src/gpu/GrTestUtils.cpp
+++ b/src/gpu/GrTestUtils.cpp
@@ -339,7 +339,8 @@
TestAsFPArgs::TestAsFPArgs(GrProcessorTestData* d)
: fViewMatrixStorage(TestMatrix(d->fRandom))
, fColorSpaceInfoStorage(skstd::make_unique<GrColorSpaceInfo>(
- kPremul_SkAlphaType, TestColorSpace(d->fRandom), kRGBA_8888_GrPixelConfig))
+ GrColorType::kRGBA_8888, kPremul_SkAlphaType, TestColorSpace(d->fRandom),
+ kRGBA_8888_GrPixelConfig))
, fArgs(d->context(), &fViewMatrixStorage, kNone_SkFilterQuality,
fColorSpaceInfoStorage.get()) {}
diff --git a/src/gpu/GrTextureAdjuster.cpp b/src/gpu/GrTextureAdjuster.cpp
index 34aac30..c299fed 100644
--- a/src/gpu/GrTextureAdjuster.cpp
+++ b/src/gpu/GrTextureAdjuster.cpp
@@ -15,12 +15,17 @@
GrTextureAdjuster::GrTextureAdjuster(GrRecordingContext* context,
sk_sp<GrTextureProxy> original,
+ GrColorType colorType,
SkAlphaType alphaType,
uint32_t uniqueID,
SkColorSpace* cs,
bool useDecal)
: INHERITED(context, original->width(), original->height(),
- GrColorSpaceInfo(alphaType, sk_ref_sp(cs), original->config()), useDecal)
+ GrColorSpaceInfo(colorType,
+ alphaType,
+ sk_ref_sp(cs),
+ original->config()),
+ useDecal)
, fOriginal(std::move(original))
, fUniqueID(uniqueID) {}
@@ -52,7 +57,7 @@
sk_sp<GrTextureProxy> proxy = this->originalProxyRef();
- sk_sp<GrTextureProxy> copy = CopyOnGpu(this->context(), std::move(proxy),
+ sk_sp<GrTextureProxy> copy = CopyOnGpu(this->context(), std::move(proxy), this->colorType(),
copyParams, willBeMipped);
if (copy) {
if (key.isValid()) {
diff --git a/src/gpu/GrTextureAdjuster.h b/src/gpu/GrTextureAdjuster.h
index 14bcecd..279398c 100644
--- a/src/gpu/GrTextureAdjuster.h
+++ b/src/gpu/GrTextureAdjuster.h
@@ -31,7 +31,7 @@
// We do not ref the texture nor the colorspace, so the caller must keep them in scope while
// this Adjuster is alive.
- GrTextureAdjuster(GrRecordingContext*, sk_sp<GrTextureProxy>, SkAlphaType,
+ GrTextureAdjuster(GrRecordingContext*, sk_sp<GrTextureProxy>, GrColorType, SkAlphaType,
uint32_t uniqueID, SkColorSpace*, bool useDecal = false);
protected:
diff --git a/src/gpu/GrTextureContext.cpp b/src/gpu/GrTextureContext.cpp
index 7962ae7..c9e5fa5 100644
--- a/src/gpu/GrTextureContext.cpp
+++ b/src/gpu/GrTextureContext.cpp
@@ -17,10 +17,15 @@
#define RETURN_FALSE_IF_ABANDONED if (this->drawingManager()->wasAbandoned()) { return false; }
GrTextureContext::GrTextureContext(GrRecordingContext* context,
- SkAlphaType alphaType,
sk_sp<GrTextureProxy> textureProxy,
+ GrColorType colorType,
+ SkAlphaType alphaType,
sk_sp<SkColorSpace> colorSpace)
- : GrSurfaceContext(context, alphaType, std::move(colorSpace), textureProxy->config())
+ : GrSurfaceContext(context,
+ colorType,
+ alphaType,
+ std::move(colorSpace),
+ textureProxy->config())
, fTextureProxy(std::move(textureProxy))
, fOpList(sk_ref_sp(fTextureProxy->getLastTextureOpList())) {
SkDEBUGCODE(this->validate();)
diff --git a/src/gpu/GrTextureContext.h b/src/gpu/GrTextureContext.h
index da21877..8f1a7f2 100644
--- a/src/gpu/GrTextureContext.h
+++ b/src/gpu/GrTextureContext.h
@@ -39,7 +39,11 @@
sk_sp<GrRenderTargetProxy> asRenderTargetProxyRef() override;
protected:
- GrTextureContext(GrRecordingContext*, SkAlphaType, sk_sp<GrTextureProxy>, sk_sp<SkColorSpace>);
+ GrTextureContext(GrRecordingContext*,
+ sk_sp<GrTextureProxy>,
+ GrColorType,
+ SkAlphaType,
+ sk_sp<SkColorSpace>);
SkDEBUGCODE(void validate() const override;)
diff --git a/src/gpu/GrTextureMaker.cpp b/src/gpu/GrTextureMaker.cpp
index 9908f37..ca25e00 100644
--- a/src/gpu/GrTextureMaker.cpp
+++ b/src/gpu/GrTextureMaker.cpp
@@ -74,7 +74,8 @@
return nullptr;
}
- sk_sp<GrTextureProxy> result = CopyOnGpu(this->context(), source, copyParams, willBeMipped);
+ sk_sp<GrTextureProxy> result =
+ CopyOnGpu(this->context(), source, this->colorType(), copyParams, willBeMipped);
if (!result) {
// If we were unable to make a copy and we only needed a copy for mips, then we will return
diff --git a/src/gpu/GrTextureProducer.cpp b/src/gpu/GrTextureProducer.cpp
index 0e09fc0..87c0633 100644
--- a/src/gpu/GrTextureProducer.cpp
+++ b/src/gpu/GrTextureProducer.cpp
@@ -22,6 +22,7 @@
sk_sp<GrTextureProxy> GrTextureProducer::CopyOnGpu(GrRecordingContext* context,
sk_sp<GrTextureProxy> inputProxy,
+ GrColorType colorType,
const CopyParams& copyParams,
bool dstWillRequireMipMaps) {
SkASSERT(context);
@@ -55,9 +56,9 @@
}
sk_sp<GrRenderTargetContext> copyRTC =
- context->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, dstRect.width(), dstRect.height(),
- config, nullptr, 1, mipMapped, inputProxy->origin());
+ context->priv().makeDeferredRenderTargetContextWithFallback(
+ format, SkBackingFit::kExact, dstRect.width(), dstRect.height(), config,
+ colorType, nullptr, 1, mipMapped, inputProxy->origin());
if (!copyRTC) {
return nullptr;
}
diff --git a/src/gpu/GrTextureProducer.h b/src/gpu/GrTextureProducer.h
index 7b870b7..d73ed25 100644
--- a/src/gpu/GrTextureProducer.h
+++ b/src/gpu/GrTextureProducer.h
@@ -104,6 +104,7 @@
int width() const { return fWidth; }
int height() const { return fHeight; }
+ GrColorType colorType() const { return fColorSpaceInfo.colorType(); }
SkAlphaType alphaType() const { return fColorSpaceInfo.alphaType(); }
SkColorSpace* colorSpace() const { return fColorSpaceInfo.colorSpace(); }
bool isAlphaOnly() const { return GrPixelConfigIsAlphaOnly(fColorSpaceInfo.config()); }
@@ -160,7 +161,9 @@
};
// This can draw to accomplish the copy, thus the recording context is needed
- static sk_sp<GrTextureProxy> CopyOnGpu(GrRecordingContext*, sk_sp<GrTextureProxy> inputProxy,
+ static sk_sp<GrTextureProxy> CopyOnGpu(GrRecordingContext*,
+ sk_sp<GrTextureProxy> inputProxy,
+ GrColorType,
const CopyParams& copyParams,
bool dstWillRequireMipMaps);
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 2e5e29f..15f99a6 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -106,6 +106,7 @@
sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrRecordingContext* ctx,
const GrBackendFormat& format,
const GrSurfaceDesc& desc,
+ GrColorType colorType,
SkColorSpace* srcColorSpace,
SkColorSpace* dstColorSpace) {
SkYUVASizeInfo yuvSizeInfo;
@@ -162,10 +163,9 @@
}
// TODO: investigate preallocating mip maps here
- sk_sp<GrRenderTargetContext> renderTargetContext(
- ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, desc.fWidth, desc.fHeight, desc.fConfig, nullptr,
- desc.fSampleCnt, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
+ sk_sp<GrRenderTargetContext> renderTargetContext(ctx->priv().makeDeferredRenderTargetContext(
+ format, SkBackingFit::kExact, desc.fWidth, desc.fHeight, desc.fConfig, 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 adf4ff3..04abdb5 100644
--- a/src/gpu/GrYUVProvider.h
+++ b/src/gpu/GrYUVProvider.h
@@ -8,6 +8,7 @@
#ifndef GrYUVProvider_DEFINED
#define GrYUVProvider_DEFINED
+#include <include/private/GrTypesPriv.h>
#include "include/core/SkImageInfo.h"
#include "include/core/SkYUVAIndex.h"
#include "include/core/SkYUVASizeInfo.h"
@@ -44,6 +45,7 @@
sk_sp<GrTextureProxy> refAsTextureProxy(GrRecordingContext*,
const GrBackendFormat&,
const GrSurfaceDesc&,
+ GrColorType colorType,
SkColorSpace* srcColorSpace,
SkColorSpace* dstColorSpace);
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 50333f3..c03526a 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -167,10 +167,9 @@
// 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, origInfo.refColorSpace(), sampleCount,
- mipMapped, origin, surfaceProps, budgeted);
+ format, SkBackingFit::kExact, origInfo.width(), origInfo.height(), config,
+ SkColorTypeToGrColorType(origInfo.colorType()), origInfo.refColorSpace(), sampleCount,
+ mipMapped, origin, surfaceProps, budgeted);
}
sk_sp<SkSpecialImage> SkGpuDevice::filterTexture(SkSpecialImage* srcImg,
@@ -1370,7 +1369,8 @@
auto iter = skstd::make_unique<SkLatticeIter>(image->width(), image->height(), center, dst);
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(this->context(),
&pinnedUniqueID)) {
- GrTextureAdjuster adjuster(this->context(), std::move(proxy), image->alphaType(),
+ GrTextureAdjuster adjuster(this->context(), std::move(proxy),
+ SkColorTypeToGrColorType(image->colorType()), image->alphaType(),
pinnedUniqueID, image->colorSpace());
this->drawProducerLattice(&adjuster, std::move(iter), dst, paint);
} else {
@@ -1430,7 +1430,8 @@
auto iter = skstd::make_unique<SkLatticeIter>(lattice, dst);
if (sk_sp<GrTextureProxy> proxy = as_IB(image)->refPinnedTextureProxy(this->context(),
&pinnedUniqueID)) {
- GrTextureAdjuster adjuster(this->context(), std::move(proxy), image->alphaType(),
+ GrTextureAdjuster adjuster(this->context(), std::move(proxy),
+ SkColorTypeToGrColorType(image->colorType()), image->alphaType(),
pinnedUniqueID, image->colorSpace());
this->drawProducerLattice(&adjuster, std::move(iter), dst, paint);
} else {
@@ -1690,10 +1691,18 @@
}
sk_sp<GrRenderTargetContext> rtc(fContext->priv().makeDeferredRenderTargetContext(
- format, fit, cinfo.fInfo.width(), cinfo.fInfo.height(), config,
+ format,
+ fit,
+ cinfo.fInfo.width(),
+ cinfo.fInfo.height(),
+ config,
+ fRenderTargetContext->colorSpaceInfo().colorType(),
fRenderTargetContext->colorSpaceInfo().refColorSpace(),
- fRenderTargetContext->numSamples(), GrMipMapped::kNo,
- kBottomLeft_GrSurfaceOrigin, &props, SkBudgeted::kYes,
+ fRenderTargetContext->numSamples(),
+ GrMipMapped::kNo,
+ kBottomLeft_GrSurfaceOrigin,
+ &props,
+ SkBudgeted::kYes,
fRenderTargetContext->asSurfaceProxy()->isProtected() ? GrProtected::kYes
: GrProtected::kNo));
if (!rtc) {
diff --git a/src/gpu/SkGpuDevice_drawTexture.cpp b/src/gpu/SkGpuDevice_drawTexture.cpp
index 94a7d44..0261635 100644
--- a/src/gpu/SkGpuDevice_drawTexture.cpp
+++ b/src/gpu/SkGpuDevice_drawTexture.cpp
@@ -410,9 +410,9 @@
dstClip, aa, aaFlags, constraint, std::move(proxy), alphaType, colorSpace);
return;
}
-
- GrTextureAdjuster adjuster(fContext.get(), std::move(proxy), alphaType, pinnedUniqueID,
- colorSpace, useDecal);
+ auto colorType = SkColorTypeToGrColorType(image->colorType());
+ GrTextureAdjuster adjuster(fContext.get(), std::move(proxy), colorType, alphaType,
+ pinnedUniqueID, colorSpace, useDecal);
draw_texture_producer(fContext.get(), fRenderTargetContext.get(), this->clip(), ctm,
paint, &adjuster, src, dst, dstClip, srcToDst, aa, aaFlags,
constraint, /* attempt draw_texture */ false);
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 70a1898..34028ae 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -132,7 +132,6 @@
if (!ctx->priv().caps()->isConfigCopyable(baseProxy->config())) {
return nullptr;
}
-
return GrSurfaceProxy::Copy(ctx, baseProxy, GrMipMapped::kYes, SkBackingFit::kExact,
SkBudgeted::kYes);
}
diff --git a/src/gpu/ccpr/GrCCAtlas.cpp b/src/gpu/ccpr/GrCCAtlas.cpp
index d42f4ea..3095939 100644
--- a/src/gpu/ccpr/GrCCAtlas.cpp
+++ b/src/gpu/ccpr/GrCCAtlas.cpp
@@ -199,9 +199,10 @@
SkASSERT(backingTexture->height() == fHeight);
fBackingTexture = std::move(backingTexture);
}
-
+ auto colorType = (CoverageType::kFP16_CoverageCount == fCoverageType) ? GrColorType::kAlpha_F16
+ : GrColorType::kAlpha_8;
sk_sp<GrRenderTargetContext> rtc =
- onFlushRP->makeRenderTargetContext(fTextureProxy, nullptr, nullptr);
+ onFlushRP->makeRenderTargetContext(fTextureProxy, colorType, nullptr, nullptr);
if (!rtc) {
SkDebugf("WARNING: failed to allocate a %ix%i atlas. Some paths will not be drawn.\n",
fWidth, fHeight);
diff --git a/src/gpu/effects/GrConfigConversionEffect.fp b/src/gpu/effects/GrConfigConversionEffect.fp
index 28f64f3..d60c680 100644
--- a/src/gpu/effects/GrConfigConversionEffect.fp
+++ b/src/gpu/effects/GrConfigConversionEffect.fp
@@ -17,9 +17,9 @@
static bool TestForPreservingPMConversions(GrContext* context) {
static constexpr int kSize = 256;
static constexpr GrPixelConfig kConfig = kRGBA_8888_GrPixelConfig;
- static constexpr SkColorType kColorType = kRGBA_8888_SkColorType;
+ static constexpr GrColorType kColorType = GrColorType::kRGBA_8888;
const GrBackendFormat format =
- context->priv().caps()->getBackendFormatFromColorType(kColorType);
+ 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;
@@ -46,11 +46,11 @@
sk_sp<GrRenderTargetContext> readRTC(
context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact,
kSize, kSize,
- kConfig, nullptr));
+ kConfig, kColorType, nullptr));
sk_sp<GrRenderTargetContext> tempRTC(
context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact,
kSize, kSize,
- kConfig, nullptr));
+ kConfig, kColorType, nullptr));
if (!readRTC || !readRTC->asTextureProxy() || !tempRTC) {
return false;
}
diff --git a/src/gpu/effects/GrRRectBlurEffect.fp b/src/gpu/effects/GrRRectBlurEffect.fp
index ddd5207..1f57b4e 100644
--- a/src/gpu/effects/GrRRectBlurEffect.fp
+++ b/src/gpu/effects/GrRRectBlurEffect.fp
@@ -59,7 +59,8 @@
sk_sp<GrRenderTargetContext> rtc(
context->priv().makeDeferredRenderTargetContextWithFallback(
format, SkBackingFit::kExact, size.fWidth,
- size.fHeight, kAlpha_8_GrPixelConfig, nullptr));
+ size.fHeight, kAlpha_8_GrPixelConfig,
+ 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 2ab205a..f7d898d 100644
--- a/src/gpu/effects/generated/GrConfigConversionEffect.h
+++ b/src/gpu/effects/generated/GrConfigConversionEffect.h
@@ -25,9 +25,9 @@
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->priv().caps()->getBackendFormatFromColorType(kColorType);
+ 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 +52,9 @@
SkImageInfo::Make(kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
sk_sp<GrRenderTargetContext> readRTC(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
+ format, SkBackingFit::kExact, kSize, kSize, kConfig, kColorType, nullptr));
sk_sp<GrRenderTargetContext> tempRTC(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kSize, kSize, kConfig, nullptr));
+ format, SkBackingFit::kExact, kSize, kSize, kConfig, 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 5418676..c2b216b 100644
--- a/src/gpu/effects/generated/GrRRectBlurEffect.h
+++ b/src/gpu/effects/generated/GrRRectBlurEffect.h
@@ -60,7 +60,7 @@
sk_sp<GrRenderTargetContext> rtc(
context->priv().makeDeferredRenderTargetContextWithFallback(
format, SkBackingFit::kExact, size.fWidth, size.fHeight,
- kAlpha_8_GrPixelConfig, nullptr));
+ kAlpha_8_GrPixelConfig, GrColorType::kAlpha_8, nullptr));
if (!rtc) {
return nullptr;
}
diff --git a/src/gpu/text/GrAtlasManager.cpp b/src/gpu/text/GrAtlasManager.cpp
index 014f463..952c58b 100644
--- a/src/gpu/text/GrAtlasManager.cpp
+++ b/src/gpu/text/GrAtlasManager.cpp
@@ -82,7 +82,8 @@
* Write the contents of the surface proxy to a PNG. Returns true if successful.
* @param filename Full path to desired file
*/
-static bool save_pixels(GrContext* context, GrSurfaceProxy* sProxy, const char* filename) {
+static bool save_pixels(GrContext* context, GrSurfaceProxy* sProxy, GrColorType colorType,
+ const char* filename) {
if (!sProxy) {
return false;
}
@@ -94,8 +95,8 @@
return false;
}
- sk_sp<GrSurfaceContext> sContext(
- context->priv().makeWrappedSurfaceContext(sk_ref_sp(sProxy), kUnknown_SkAlphaType));
+ sk_sp<GrSurfaceContext> sContext(context->priv().makeWrappedSurfaceContext(
+ sk_ref_sp(sProxy), colorType, kUnknown_SkAlphaType));
if (!sContext || !sContext->asTextureProxy()) {
return false;
}
@@ -138,8 +139,8 @@
#else
filename.printf("fontcache_%d%d%d.png", gDumpCount, i, pageIdx);
#endif
-
- save_pixels(context, proxies[pageIdx].get(), filename.c_str());
+ auto ct = mask_format_to_gr_color_type(AtlasIndexToMaskFormat(i));
+ save_pixels(context, proxies[pageIdx].get(), ct, filename.c_str());
}
}
}
diff --git a/src/gpu/text/GrAtlasManager.h b/src/gpu/text/GrAtlasManager.h
index 321c86f..0f31202 100644
--- a/src/gpu/text/GrAtlasManager.h
+++ b/src/gpu/text/GrAtlasManager.h
@@ -122,17 +122,8 @@
bool initAtlas(GrMaskFormat);
// There is a 1:1 mapping between GrMaskFormats and atlas indices
- static int MaskFormatToAtlasIndex(GrMaskFormat format) {
- static const int sAtlasIndices[] = {
- kA8_GrMaskFormat,
- kA565_GrMaskFormat,
- kARGB_GrMaskFormat,
- };
- static_assert(SK_ARRAY_COUNT(sAtlasIndices) == kMaskFormatCount, "array_size_mismatch");
-
- SkASSERT(sAtlasIndices[format] < kMaskFormatCount);
- return sAtlasIndices[format];
- }
+ static int MaskFormatToAtlasIndex(GrMaskFormat format) { return static_cast<int>(format); }
+ static GrMaskFormat AtlasIndexToMaskFormat(int idx) { return static_cast<GrMaskFormat>(idx); }
GrDrawOpAtlas* getAtlas(GrMaskFormat format) const {
format = this->resolveMaskFormat(format);
diff --git a/src/gpu/text/GrTextContext.cpp b/src/gpu/text/GrTextContext.cpp
index 03374d0..5f1098a 100644
--- a/src/gpu/text/GrTextContext.cpp
+++ b/src/gpu/text/GrTextContext.cpp
@@ -239,7 +239,8 @@
// Setup dummy SkPaint / GrPaint / GrRenderTargetContext
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, 1024, 1024, kRGBA_8888_GrPixelConfig, nullptr));
+ format, SkBackingFit::kApprox, 1024, 1024, kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr));
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index 1a23684..6fefd63 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -92,9 +92,10 @@
}
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContextWithFallback(
- format, SkBackingFit::kExact, this->width(), this->height(),
- SkColorType2GrPixelConfig(targetCT), nullptr));
+ context->priv().makeDeferredRenderTargetContextWithFallback(
+ format, SkBackingFit::kExact, this->width(), this->height(),
+ SkColorType2GrPixelConfig(targetCT), SkColorTypeToGrColorType(targetCT),
+ nullptr));
if (!renderTargetContext) {
return nullptr;
}
@@ -245,10 +246,9 @@
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,
- std::move(imageColorSpace), 1, GrMipMapped::kNo, imageOrigin));
+ 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));
if (!renderTargetContext) {
return nullptr;
}
@@ -277,8 +277,8 @@
// Needs to create a render target with external texture
// in order to draw to it for the yuv->rgb conversion.
sk_sp<GrRenderTargetContext> renderTargetContext(
- ctx->priv().makeBackendTextureRenderTargetContext(backendTextureCopy,
- imageOrigin, 1,
+ ctx->priv().makeBackendTextureRenderTargetContext(backendTextureCopy, imageOrigin, 1,
+ GrColorType::kRGBA_8888,
std::move(imageColorSpace)));
if (!renderTargetContext) {
@@ -379,7 +379,8 @@
if (GrMipMapped::kNo == mipMapped || proxy->mipMapped() == mipMapped) {
return sk_ref_sp(const_cast<SkImage*>(this));
}
- GrTextureAdjuster adjuster(context, std::move(proxy), this->alphaType(),
+ GrTextureAdjuster adjuster(context, std::move(proxy),
+ SkColorTypeToGrColorType(this->colorType()), this->alphaType(),
this->uniqueID(), this->colorSpace());
return create_image_from_producer(context, &adjuster, this->alphaType(),
this->uniqueID(), mipMapped);
@@ -655,7 +656,8 @@
}
sk_sp<GrTextureContext> texContext =
- drawingManager->makeTextureContext(proxy, pixmap.alphaType(), cs);
+ drawingManager->makeTextureContext(proxy, SkColorTypeToGrColorType(pixmap.colorType()),
+ pixmap.alphaType(), cs);
if (!texContext) {
return nullptr;
}
diff --git a/src/image/SkImage_GpuBase.cpp b/src/image/SkImage_GpuBase.cpp
index 51102c5..9912dc0 100644
--- a/src/image/SkImage_GpuBase.cpp
+++ b/src/image/SkImage_GpuBase.cpp
@@ -87,8 +87,11 @@
}
}
- sk_sp<GrSurfaceContext> sContext = direct->priv().makeWrappedSurfaceContext(
- this->asTextureProxyRef(direct), this->alphaType(), this->refColorSpace());
+ sk_sp<GrSurfaceContext> sContext =
+ direct->priv().makeWrappedSurfaceContext(this->asTextureProxyRef(direct),
+ SkColorTypeToGrColorType(this->colorType()),
+ this->alphaType(),
+ this->refColorSpace());
if (!sContext) {
return false;
}
@@ -174,7 +177,8 @@
}
sk_sp<GrSurfaceContext> sContext = direct->priv().makeWrappedSurfaceContext(
- this->asTextureProxyRef(direct), this->alphaType(), this->refColorSpace());
+ this->asTextureProxyRef(direct), SkColorTypeToGrColorType(this->colorType()),
+ this->alphaType(), this->refColorSpace());
if (!sContext) {
return false;
}
@@ -206,7 +210,8 @@
return nullptr;
}
- GrTextureAdjuster adjuster(fContext.get(), this->asTextureProxyRef(context), this->alphaType(),
+ GrTextureAdjuster adjuster(fContext.get(), this->asTextureProxyRef(context),
+ SkColorTypeToGrColorType(this->colorType()), this->alphaType(),
this->uniqueID(), this->colorSpace());
return adjuster.refTextureProxyForParams(params, scaleAdjust);
}
diff --git a/src/image/SkImage_GpuYUVA.cpp b/src/image/SkImage_GpuYUVA.cpp
index fb02f34..2a3b6bb 100644
--- a/src/image/SkImage_GpuYUVA.cpp
+++ b/src/image/SkImage_GpuYUVA.cpp
@@ -147,7 +147,8 @@
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
format, SkBackingFit::kExact, this->width(), this->height(),
- kRGBA_8888_GrPixelConfig, this->refColorSpace(), 1, GrMipMapped::kNo, fOrigin));
+ kRGBA_8888_GrPixelConfig, 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 fb88cc4..a05eddd 100644
--- a/src/image/SkImage_Lazy.cpp
+++ b/src/image/SkImage_Lazy.cpp
@@ -446,7 +446,8 @@
// 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, format, desc, SkColorTypeToGrColorType(colorType),
+ generatorColorSpace, thisColorSpace);
if (proxy) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
kLockTexturePathCount);
diff --git a/src/image/SkImage_Raster.cpp b/src/image/SkImage_Raster.cpp
index 6dcd116..a451dac 100644
--- a/src/image/SkImage_Raster.cpp
+++ b/src/image/SkImage_Raster.cpp
@@ -174,8 +174,9 @@
uint32_t uniqueID;
sk_sp<GrTextureProxy> tex = this->refPinnedTextureProxy(context, &uniqueID);
if (tex) {
- GrTextureAdjuster adjuster(context, fPinnedProxy, fBitmap.alphaType(), fPinnedUniqueID,
- fBitmap.colorSpace());
+ GrTextureAdjuster adjuster(context, fPinnedProxy,
+ SkColorTypeToGrColorType(fBitmap.colorType()),
+ fBitmap.alphaType(), fPinnedUniqueID, fBitmap.colorSpace());
return adjuster.refTextureProxyForParams(params, scaleAdjust);
}
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index d41a022..69160be 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -372,9 +372,13 @@
context->priv().caps()->getBackendFormatFromColorType(c.colorType());
sk_sp<GrSurfaceContext> sc(
- context->priv().makeDeferredSurfaceContext(format, desc, c.origin(),
+ context->priv().makeDeferredSurfaceContext(format,
+ desc,
+ c.origin(),
GrMipMapped(c.isMipMapped()),
- SkBackingFit::kExact, budgeted,
+ SkBackingFit::kExact,
+ budgeted,
+ SkColorTypeToGrColorType(c.colorType()),
kPremul_SkAlphaType,
c.refColorSpace(),
&c.surfaceProps()));
@@ -507,13 +511,14 @@
sampleCnt = SkTMax(1, sampleCnt);
sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
- texCopy,
- origin,
- sampleCnt,
- std::move(colorSpace),
- props,
- textureReleaseProc,
- releaseContext));
+ texCopy,
+ origin,
+ sampleCnt,
+ SkColorTypeToGrColorType(colorType),
+ std::move(colorSpace),
+ props,
+ textureReleaseProc,
+ releaseContext));
if (!rtc) {
return nullptr;
}
@@ -566,14 +571,15 @@
this->getCanvas()->imageInfo().colorType(), colorSpace, true)) {
return false;
}
- sk_sp<GrRenderTargetContext> rtc(
- context->priv().makeBackendTextureRenderTargetContext(texCopy,
- origin,
- sampleCnt,
- std::move(colorSpace),
- &this->props(),
- releaseProc,
- releaseContext));
+ sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
+ texCopy,
+ origin,
+ sampleCnt,
+ oldRTC->colorSpaceInfo().colorType(),
+ std::move(colorSpace),
+ &this->props(),
+ releaseProc,
+ releaseContext));
if (!rtc) {
return false;
}
@@ -631,9 +637,9 @@
return nullptr;
}
- sk_sp<GrRenderTargetContext> rtc(
- context->priv().makeBackendRenderTargetRenderTargetContext(
- rtCopy, origin, std::move(colorSpace), props, relProc, releaseContext));
+ sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendRenderTargetRenderTargetContext(
+ rtCopy, origin, SkColorTypeToGrColorType(colorType), std::move(colorSpace), props,
+ relProc, releaseContext));
if (!rtc) {
return nullptr;
}
@@ -671,12 +677,13 @@
}
sk_sp<GrRenderTargetContext> rtc(
- context->priv().makeBackendTextureAsRenderTargetRenderTargetContext(
- texCopy,
- origin,
- sampleCnt,
- std::move(colorSpace),
- props));
+ context->priv().makeBackendTextureAsRenderTargetRenderTargetContext(
+ texCopy,
+ origin,
+ sampleCnt,
+ SkColorTypeToGrColorType(colorType),
+ std::move(colorSpace),
+ props));
if (!rtc) {
return nullptr;
}
diff --git a/tests/ClearTest.cpp b/tests/ClearTest.cpp
index 8f17716..e4fe323 100644
--- a/tests/ClearTest.cpp
+++ b/tests/ClearTest.cpp
@@ -62,7 +62,8 @@
const GrBackendFormat format =
context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
return context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact, w, h,
- kRGBA_8888_GrPixelConfig, nullptr);
+ kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr);
}
static void clear_op_test(skiatest::Reporter* reporter, GrContext* context) {
diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp
index 6b73e2d..39fc111 100644
--- a/tests/CopySurfaceTest.cpp
+++ b/tests/CopySurfaceTest.cpp
@@ -106,7 +106,9 @@
sk_sp<GrSurfaceContext> dstContext =
context->priv().makeWrappedSurfaceContext(
- std::move(dst), kPremul_SkAlphaType);
+ std::move(dst),
+ SkColorTypeToGrColorType(ii.colorType()),
+ ii.alphaType());
bool result = false;
if (sOrigin == dOrigin) {
diff --git a/tests/DefaultPathRendererTest.cpp b/tests/DefaultPathRendererTest.cpp
index 8149841..eef1f45 100644
--- a/tests/DefaultPathRendererTest.cpp
+++ b/tests/DefaultPathRendererTest.cpp
@@ -85,11 +85,9 @@
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, nullptr);
+ auto rtc = ctx->priv().makeDeferredRenderTargetContext(
+ format, SkBackingFit::kApprox, kBigSize/2 + 1, kBigSize/2 + 1,
+ kRGBA_8888_GrPixelConfig, GrColorType::kRGBA_8888, nullptr);
rtc->clear(nullptr, { 0, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
@@ -107,9 +105,8 @@
{
auto rtc = ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kBigSize,
- kBigSize, kRGBA_8888_GrPixelConfig,
- nullptr);
+ format, SkBackingFit::kExact, kBigSize, kBigSize, kRGBA_8888_GrPixelConfig,
+ 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 32641c6..54ea360 100644
--- a/tests/DrawOpAtlasTest.cpp
+++ b/tests/DrawOpAtlasTest.cpp
@@ -194,11 +194,9 @@
GrBackendFormat format =
context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
- auto rtc = context->priv().makeDeferredRenderTargetContext(format,
- SkBackingFit::kApprox,
- 32, 32,
- kRGBA_8888_GrPixelConfig,
- nullptr);
+ auto rtc = context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kApprox, 32,
+ 32, kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr);
SkPaint paint;
paint.setColor(SK_ColorRED);
diff --git a/tests/EGLImageTest.cpp b/tests/EGLImageTest.cpp
index ab953b4..8c97068 100644
--- a/tests/EGLImageTest.cpp
+++ b/tests/EGLImageTest.cpp
@@ -159,7 +159,8 @@
// TODO: If I make this TopLeft origin to match resolve_origin calls for kDefault, this test
// fails on the Nexus5. Why?
sk_sp<GrTextureContext> surfaceContext = context0->priv().makeBackendTextureContext(
- backendTex, kBottomLeft_GrSurfaceOrigin, kPremul_SkAlphaType, nullptr);
+ backendTex, kBottomLeft_GrSurfaceOrigin, GrColorType::kRGBA_8888, kPremul_SkAlphaType,
+ nullptr);
if (!surfaceContext) {
ERRORF(reporter, "Error wrapping external texture in GrSurfaceContext.");
@@ -179,9 +180,8 @@
// Should not be able to wrap as a RT
{
- sk_sp<GrRenderTargetContext> temp =
- context0->priv().makeBackendTextureRenderTargetContext(
- backendTex, kBottomLeft_GrSurfaceOrigin, 1, nullptr);
+ sk_sp<GrRenderTargetContext> temp = context0->priv().makeBackendTextureRenderTargetContext(
+ backendTex, kBottomLeft_GrSurfaceOrigin, 1, GrColorType::kRGBA_8888, nullptr);
if (temp) {
ERRORF(reporter, "Should not be able to wrap an EXTERNAL texture as a RT.");
}
@@ -195,7 +195,7 @@
// Only test RT-config
// TODO: why do we always need to draw to copy from an external texture?
test_copy_from_surface(reporter, context0, surfaceContext->asSurfaceProxy(),
- pixels.get(), "EGLImageTest-copy");
+ GrColorType::kRGBA_8888, pixels.get(), "EGLImageTest-copy");
cleanup(glCtx0, externalTexture.fID, glCtx1.get(), context1, &backendTexture1, image);
}
diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp
index dad0983..527d815 100644
--- a/tests/FloatingPointTextureTest.cpp
+++ b/tests/FloatingPointTextureTest.cpp
@@ -54,8 +54,8 @@
continue;
}
- sk_sp<GrSurfaceContext> sContext =
- context->priv().makeWrappedSurfaceContext(std::move(fpProxy), kPremul_SkAlphaType);
+ sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
+ std::move(fpProxy), colorType, kPremul_SkAlphaType);
REPORTER_ASSERT(reporter, sContext);
bool result = sContext->readPixels(context, 0, 0, DEV_W, DEV_H, colorType, nullptr,
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 5a26ca8..13f00de 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -157,15 +157,16 @@
sampleCnt = SkTMax(1, sampleCnt);
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContext(format,
- SkBackingFit::kExact,
- kRenderTargetWidth,
- kRenderTargetHeight,
- kRGBA_8888_GrPixelConfig,
- nullptr,
- sampleCnt,
- GrMipMapped::kNo,
- origin));
+ context->priv().makeDeferredRenderTargetContext(format,
+ SkBackingFit::kExact,
+ kRenderTargetWidth,
+ kRenderTargetHeight,
+ kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888,
+ nullptr,
+ sampleCnt,
+ GrMipMapped::kNo,
+ origin));
return renderTargetContext;
}
@@ -326,12 +327,13 @@
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,
- kRenderTargetWidth,
- kRenderTargetHeight,
- kRGBA_8888_GrPixelConfig,
- nullptr));
+ context->priv().makeDeferredRenderTargetContext(format,
+ SkBackingFit::kExact,
+ kRenderTargetWidth,
+ kRenderTargetHeight,
+ kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888,
+ nullptr));
if (!renderTargetContext) {
SkDebugf("Could not allocate a renderTargetContext");
return false;
diff --git a/tests/GrCCPRTest.cpp b/tests/GrCCPRTest.cpp
index e76826b..539180d 100644
--- a/tests/GrCCPRTest.cpp
+++ b/tests/GrCCPRTest.cpp
@@ -63,9 +63,9 @@
: 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,
- nullptr))
+ ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType),
+ SkBackingFit::kExact, kCanvasSize, kCanvasSize, kRGBA_8888_GrPixelConfig,
+ 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 f2d90f3..f2b9d36 100644
--- a/tests/GrMeshTest.cpp
+++ b/tests/GrMeshTest.cpp
@@ -88,7 +88,7 @@
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
format, SkBackingFit::kExact, kImageWidth, kImageHeight, kRGBA_8888_GrPixelConfig,
- nullptr));
+ 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 ad62139..426a37e 100644
--- a/tests/GrPipelineDynamicStateTest.cpp
+++ b/tests/GrPipelineDynamicStateTest.cpp
@@ -168,8 +168,8 @@
context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, kScreenSize,
- kScreenSize, kRGBA_8888_GrPixelConfig, nullptr));
+ format, SkBackingFit::kExact, kScreenSize, kScreenSize, kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr));
if (!rtc) {
ERRORF(reporter, "could not create render target context.");
return;
diff --git a/tests/GrSurfaceTest.cpp b/tests/GrSurfaceTest.cpp
index 4added8..c84851e 100644
--- a/tests/GrSurfaceTest.cpp
+++ b/tests/GrSurfaceTest.cpp
@@ -204,7 +204,8 @@
continue;
}
auto texCtx = context->priv().makeWrappedSurfaceContext(
- std::move(proxy), kPremul_SkAlphaType);
+ std::move(proxy), GrPixelConfigToColorType(desc.fConfig),
+ kPremul_SkAlphaType);
SkImageInfo info = SkImageInfo::Make(
kSize, kSize, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
memset(data.get(), 0xAB, kSize * kSize * sizeof(uint32_t));
@@ -236,7 +237,7 @@
for (int i = 0; i < 2; ++i) {
auto surfCtx = context->priv().makeDeferredSurfaceContext(
format, desc, origin, GrMipMapped::kNo, fit, SkBudgeted::kYes,
- kPremul_SkAlphaType);
+ colorType, kPremul_SkAlphaType);
if (!surfCtx) {
continue;
}
@@ -306,7 +307,8 @@
auto proxy = proxyProvider->wrapBackendTexture(backendTex, kTopLeft_GrSurfaceOrigin,
kBorrow_GrWrapOwnership,
GrWrapCacheable::kNo, ioType);
- auto surfContext = context->priv().makeWrappedSurfaceContext(proxy, kPremul_SkAlphaType);
+ auto surfContext = context->priv().makeWrappedSurfaceContext(proxy, GrColorType::kRGBA_8888,
+ kPremul_SkAlphaType);
// Read pixels should work with a read-only texture.
SkAutoPixmapStorage read;
diff --git a/tests/GrTestingBackendTextureUploadTest.cpp b/tests/GrTestingBackendTextureUploadTest.cpp
index 3672ee0..06cea8a 100644
--- a/tests/GrTestingBackendTextureUploadTest.cpp
+++ b/tests/GrTestingBackendTextureUploadTest.cpp
@@ -77,7 +77,7 @@
}
REPORTER_ASSERT(reporter, wrappedProxy);
- auto surfaceContext = context->priv().makeWrappedSurfaceContext(std::move(wrappedProxy),
+ auto surfaceContext = context->priv().makeWrappedSurfaceContext(std::move(wrappedProxy), grCT,
kPremul_SkAlphaType);
REPORTER_ASSERT(reporter, surfaceContext);
diff --git a/tests/GrUploadPixelsTests.cpp b/tests/GrUploadPixelsTests.cpp
index c0564a6..5ce07cf 100644
--- a/tests/GrUploadPixelsTests.cpp
+++ b/tests/GrUploadPixelsTests.cpp
@@ -33,8 +33,8 @@
kTopLeft_GrSurfaceOrigin, srcBuffer, 0);
REPORTER_ASSERT(reporter, proxy);
if (proxy) {
- sk_sp<GrSurfaceContext> sContext =
- context->priv().makeWrappedSurfaceContext(proxy, kPremul_SkAlphaType);
+ sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
+ proxy, SkColorTypeToGrColorType(ct), kPremul_SkAlphaType);
SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
@@ -65,8 +65,8 @@
srcBuffer, 0);
REPORTER_ASSERT(reporter, proxy);
if (proxy) {
- sk_sp<GrSurfaceContext> sContext =
- context->priv().makeWrappedSurfaceContext(proxy, kPremul_SkAlphaType);
+ sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
+ proxy, SkColorTypeToGrColorType(ct), kPremul_SkAlphaType);
SkImageInfo dstInfo = SkImageInfo::Make(kWidth, kHeight, ct, kPremul_SkAlphaType);
diff --git a/tests/LazyProxyTest.cpp b/tests/LazyProxyTest.cpp
index 76f85d0..d253b11 100644
--- a/tests/LazyProxyTest.cpp
+++ b/tests/LazyProxyTest.cpp
@@ -210,15 +210,15 @@
GrBackendFormat format =
ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrRenderTargetContext> rtc = ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kExact, 100, 100,
- kRGBA_8888_GrPixelConfig, nullptr);
+ format, SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig,
+ 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, nullptr);
+ format, SkBackingFit::kExact, 10, 10, kAlpha_half_GrPixelConfig,
+ 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));
@@ -378,8 +378,8 @@
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, nullptr);
+ format, SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr);
REPORTER_ASSERT(reporter, rtc);
rtc->clear(nullptr, SkPMColor4f::FromBytes_RGBA(0xbaaaaaad),
@@ -449,8 +449,8 @@
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, nullptr);
+ format, SkBackingFit::kExact, 100, 100, kRGBA_8888_GrPixelConfig,
+ 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 2240721..46cd5da 100644
--- a/tests/OnFlushCallbackTest.cpp
+++ b/tests/OnFlushCallbackTest.cpp
@@ -359,8 +359,7 @@
// The backing GrSurface should have only 1 though bc there is only one proxy
SkASSERT(1 == fAtlasProxy->testingOnly_getBackingRefCnt());
sk_sp<GrRenderTargetContext> rtc = resourceProvider->makeRenderTargetContext(
- fAtlasProxy,
- nullptr, nullptr);
+ fAtlasProxy, GrColorType::kRGBA_8888, nullptr, nullptr);
// clear the atlas
rtc->clear(nullptr, SK_PMColor4fTRANSPARENT,
@@ -437,13 +436,14 @@
const GrBackendFormat format =
context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
- sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
- format,
- SkBackingFit::kApprox,
- 3*kDrawnTileSize,
- kDrawnTileSize,
- kRGBA_8888_GrPixelConfig,
- nullptr));
+ sk_sp<GrRenderTargetContext> rtc(
+ context->priv().makeDeferredRenderTargetContext(format,
+ SkBackingFit::kApprox,
+ 3*kDrawnTileSize,
+ kDrawnTileSize,
+ kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888,
+ nullptr));
rtc->clear(nullptr, { 1, 0, 0, 1 }, GrRenderTargetContext::CanClearFullscreen::kYes);
@@ -559,13 +559,14 @@
const GrBackendFormat format =
context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
- sk_sp<GrRenderTargetContext> rtc(context->priv().makeDeferredRenderTargetContext(
- format,
- SkBackingFit::kApprox,
- kFinalWidth,
- kFinalHeight,
- kRGBA_8888_GrPixelConfig,
- nullptr));
+ sk_sp<GrRenderTargetContext> rtc(
+ context->priv().makeDeferredRenderTargetContext(format,
+ SkBackingFit::kApprox,
+ kFinalWidth,
+ kFinalHeight,
+ kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888,
+ nullptr));
rtc->clear(nullptr, SK_PMColor4fWHITE, GrRenderTargetContext::CanClearFullscreen::kYes);
diff --git a/tests/PackedConfigsTextureTest.cpp b/tests/PackedConfigsTextureTest.cpp
index 572940e..5c2ebca 100644
--- a/tests/PackedConfigsTextureTest.cpp
+++ b/tests/PackedConfigsTextureTest.cpp
@@ -117,8 +117,8 @@
controlPixelData.begin(), 0);
SkASSERT(proxy);
- sk_sp<GrSurfaceContext> sContext =
- context->priv().makeWrappedSurfaceContext(std::move(proxy), kPremul_SkAlphaType);
+ sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
+ std::move(proxy), SkColorTypeToGrColorType(colorType), kPremul_SkAlphaType);
if (!sContext->readPixels(dstInfo, readBuffer.begin(), 0, 0, 0)) {
// We only require this to succeed if the format is renderable.
diff --git a/tests/PathRendererCacheTests.cpp b/tests/PathRendererCacheTests.cpp
index f085020..09aa956 100644
--- a/tests/PathRendererCacheTests.cpp
+++ b/tests/PathRendererCacheTests.cpp
@@ -83,8 +83,8 @@
ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrRenderTargetContext> rtc(ctx->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig, nullptr, 1,
- GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
+ format, SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!rtc) {
return;
}
diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp
index 3625dbe..496a522 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -136,9 +136,9 @@
context->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
sk_sp<GrRenderTargetContext> renderTargetContext(
- context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kApprox,
- 1, 1, kRGBA_8888_GrPixelConfig,
- nullptr));
+ context->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kApprox, 1, 1,
+ kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr));
if (!renderTargetContext) {
ERRORF(reporter, "Could not create render target context.");
return;
diff --git a/tests/ProcessorTest.cpp b/tests/ProcessorTest.cpp
index 621ce68..3d68e71 100644
--- a/tests/ProcessorTest.cpp
+++ b/tests/ProcessorTest.cpp
@@ -175,8 +175,8 @@
for (int parentCnt = 0; parentCnt < 2; parentCnt++) {
sk_sp<GrRenderTargetContext> renderTargetContext(
context->priv().makeDeferredRenderTargetContext(
- format, SkBackingFit::kApprox, 1, 1,
- kRGBA_8888_GrPixelConfig, nullptr));
+ format, SkBackingFit::kApprox, 1, 1, kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr));
{
sk_sp<GrTextureProxy> proxy = proxyProvider->createProxy(
format, desc, kTopLeft_GrSurfaceOrigin, SkBackingFit::kExact,
@@ -346,9 +346,9 @@
}
bool log_surface_proxy(GrContext* context, sk_sp<GrSurfaceProxy> src, SkString* dst) {
- // All the proxies are created from premul sources.
- sk_sp<GrSurfaceContext> sContext(
- context->priv().makeWrappedSurfaceContext(src, kPremul_SkAlphaType));
+ // All the inputs are made from kRGBA_8888_SkColorType/kPremul_SkAlphaType bitmaps.
+ sk_sp<GrSurfaceContext> sContext(context->priv().makeWrappedSurfaceContext(
+ src, GrColorType::kRGBA_8888, kPremul_SkAlphaType));
return log_surface_context(sContext, dst);
}
@@ -440,7 +440,7 @@
static constexpr int kRenderSize = 256;
sk_sp<GrRenderTargetContext> rtc = context->priv().makeDeferredRenderTargetContext(
format, SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig,
- nullptr);
+ GrColorType::kRGBA_8888, nullptr);
sk_sp<GrTextureProxy> proxies[2];
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
@@ -678,7 +678,7 @@
static constexpr int kRenderSize = 1024;
sk_sp<GrRenderTargetContext> rtc = context->priv().makeDeferredRenderTargetContext(
format, SkBackingFit::kExact, kRenderSize, kRenderSize, kRGBA_8888_GrPixelConfig,
- nullptr);
+ GrColorType::kRGBA_8888, nullptr);
sk_sp<GrTextureProxy> proxies[2];
if (!init_test_textures(resourceProvider, proxyProvider, &random, proxies)) {
diff --git a/tests/ReadPixelsTest.cpp b/tests/ReadPixelsTest.cpp
index 1d150de..7b15acd 100644
--- a/tests/ReadPixelsTest.cpp
+++ b/tests/ReadPixelsTest.cpp
@@ -544,7 +544,8 @@
context, renderable, DEV_W, DEV_H, bmp.colorType(), bmp.alphaType(), origin,
bmp.getPixels(), bmp.rowBytes());
sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
- std::move(proxy), kPremul_SkAlphaType);
+ std::move(proxy), SkColorTypeToGrColorType(bmp.colorType()),
+ kPremul_SkAlphaType);
auto info = SkImageInfo::Make(DEV_W, DEV_H, kN32_SkColorType, kPremul_SkAlphaType);
test_readpixels_texture(reporter, std::move(sContext), info);
}
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index def8dac..d6047d6 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -77,8 +77,8 @@
ERRORF(reporter, "Could not create alpha texture.");
return;
}
- sk_sp<GrSurfaceContext> sContext(
- context->priv().makeWrappedSurfaceContext(std::move(proxy), kPremul_SkAlphaType));
+ sk_sp<GrSurfaceContext> sContext(context->priv().makeWrappedSurfaceContext(
+ std::move(proxy), GrColorType::kAlpha_8, kPremul_SkAlphaType));
sk_sp<SkSurface> surf(SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, ii));
@@ -198,7 +198,7 @@
}
sk_sp<GrSurfaceContext> sContext = context->priv().makeWrappedSurfaceContext(
- std::move(proxy), kPremul_SkAlphaType);
+ std::move(proxy), info.fColorType, kPremul_SkAlphaType);
for (auto rowBytes : kRowBytes) {
size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE;
diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp
index 8895fb6..c794c14 100644
--- a/tests/RectangleTextureTest.cpp
+++ b/tests/RectangleTextureTest.cpp
@@ -24,14 +24,13 @@
// skbug.com/5932
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrContext* context,
- sk_sp<GrTextureProxy> rectProxy, uint32_t expectedPixelValues[]) {
+ 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(),
- nullptr));
+ format, SkBackingFit::kExact, rectProxy->width(), rectProxy->height(),
+ rectProxy->config(), colorType, nullptr));
for (auto filter : {GrSamplerState::Filter::kNearest,
GrSamplerState::Filter::kBilerp,
GrSamplerState::Filter::kMipMap}) {
@@ -182,14 +181,14 @@
SkASSERT(rectProxy->hasRestrictedSampling());
SkASSERT(rectProxy->peekTexture()->texturePriv().hasRestrictedSampling());
- test_basic_draw_as_src(reporter, context, rectProxy, refPixels);
+ test_basic_draw_as_src(reporter, context, rectProxy, GrColorType::kRGBA_8888, refPixels);
// Test copy to both a texture and RT
- test_copy_from_surface(reporter, context, rectProxy.get(), refPixels,
- "RectangleTexture-copy-from");
+ test_copy_from_surface(reporter, context, rectProxy.get(), GrColorType::kRGBA_8888,
+ refPixels, "RectangleTexture-copy-from");
sk_sp<GrSurfaceContext> rectContext = context->priv().makeWrappedSurfaceContext(
- std::move(rectProxy), kPremul_SkAlphaType);
+ std::move(rectProxy), GrColorType::kRGBA_8888, kPremul_SkAlphaType);
SkASSERT(rectContext);
test_read_pixels(reporter, rectContext.get(), refPixels, "RectangleTexture-read");
diff --git a/tests/RenderTargetContextTest.cpp b/tests/RenderTargetContextTest.cpp
index 27cb9be..57cfa70 100644
--- a/tests/RenderTargetContextTest.cpp
+++ b/tests/RenderTargetContextTest.cpp
@@ -19,9 +19,9 @@
const GrBackendFormat format =
ctx->priv().caps()->getBackendFormatFromColorType(kRGBA_8888_SkColorType);
- return ctx->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact,
- kSize, kSize,
- kRGBA_8888_GrPixelConfig, nullptr);
+ return ctx->priv().makeDeferredRenderTargetContext(format, SkBackingFit::kExact, kSize, kSize,
+ kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr);
}
static void check_instantiation_status(skiatest::Reporter* reporter,
diff --git a/tests/SRGBReadWritePixelsTest.cpp b/tests/SRGBReadWritePixelsTest.cpp
index 12bda54..da01e8c 100644
--- a/tests/SRGBReadWritePixelsTest.cpp
+++ b/tests/SRGBReadWritePixelsTest.cpp
@@ -209,7 +209,8 @@
auto surfaceContext = context->priv().makeDeferredSurfaceContext(
format, desc, kBottomLeft_GrSurfaceOrigin, GrMipMapped::kNo, SkBackingFit::kExact,
- SkBudgeted::kNo, kPremul_SkAlphaType, encoding_as_color_space(contextEncoding));
+ SkBudgeted::kNo, colorType, kPremul_SkAlphaType,
+ encoding_as_color_space(contextEncoding));
if (!surfaceContext) {
ERRORF(reporter, "Could not create %s surface context.", encoding_as_str(contextEncoding));
}
diff --git a/tests/SurfaceTest.cpp b/tests/SurfaceTest.cpp
index 5496bb0..c188bd3 100644
--- a/tests/SurfaceTest.cpp
+++ b/tests/SurfaceTest.cpp
@@ -779,8 +779,9 @@
sk_sp<SkImage> i(s->makeImageSnapshot());
SkImage_Gpu* gpuImage = (SkImage_Gpu *) as_IB(i);
sk_sp<GrTextureProxy> proxy = gpuImage->asTextureProxyRef(context);
- return context->priv().makeWrappedSurfaceContext(std::move(proxy), kPremul_SkAlphaType,
- gpuImage->refColorSpace());
+ return context->priv().makeWrappedSurfaceContext(
+ std::move(proxy), SkColorTypeToGrColorType(i->colorType()), kPremul_SkAlphaType,
+ gpuImage->refColorSpace());
}
};
diff --git a/tests/TessellatingPathRendererTests.cpp b/tests/TessellatingPathRendererTests.cpp
index ba386a2..c7fe815 100644
--- a/tests/TessellatingPathRendererTests.cpp
+++ b/tests/TessellatingPathRendererTests.cpp
@@ -693,7 +693,8 @@
SkColor colors[2] = { SK_ColorGREEN, SK_ColorBLUE };
sk_sp<SkShader> shader = SkGradientShader::MakeLinear(
pts, colors, nullptr, SK_ARRAY_COUNT(colors), SkTileMode::kClamp);
- GrColorSpaceInfo colorSpaceInfo(kPremul_SkAlphaType, nullptr, kRGBA_8888_GrPixelConfig);
+ GrColorSpaceInfo colorSpaceInfo(GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr,
+ kRGBA_8888_GrPixelConfig);
GrFPArgs args(ctx, &SkMatrix::I(), SkFilterQuality::kLow_SkFilterQuality, &colorSpaceInfo);
return as_SB(shader)->asFragmentProcessor(args);
}
@@ -736,8 +737,8 @@
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, nullptr, 1,
- GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
+ format, SkBackingFit::kApprox, 800, 800, kRGBA_8888_GrPixelConfig,
+ GrColorType::kRGBA_8888, nullptr, 1, GrMipMapped::kNo, kTopLeft_GrSurfaceOrigin));
if (!rtc) {
return;
}
diff --git a/tests/TestUtils.cpp b/tests/TestUtils.cpp
index 45fbf5b..61d6150 100644
--- a/tests/TestUtils.cpp
+++ b/tests/TestUtils.cpp
@@ -72,15 +72,15 @@
test_read_pixels(reporter, dstContext, pixels.get(), testName);
}
-void test_copy_from_surface(skiatest::Reporter* reporter, GrContext* context,
- GrSurfaceProxy* proxy, uint32_t expectedPixelValues[],
+void test_copy_from_surface(skiatest::Reporter* reporter, GrContext* context, GrSurfaceProxy* proxy,
+ GrColorType colorType, uint32_t expectedPixelValues[],
const char* testName) {
- sk_sp<GrTextureProxy> dstProxy = GrSurfaceProxy::Copy(context, proxy, GrMipMapped::kNo,
+ sk_sp<GrTextureProxy> dstProxy = GrSurfaceProxy::Copy(context, proxy, GrMipMapped::kNo,
SkBackingFit::kExact, SkBudgeted::kYes);
SkASSERT(dstProxy);
- sk_sp<GrSurfaceContext> dstContext =
- context->priv().makeWrappedSurfaceContext(std::move(dstProxy), kPremul_SkAlphaType);
+ sk_sp<GrSurfaceContext> dstContext = context->priv().makeWrappedSurfaceContext(
+ std::move(dstProxy), colorType, kPremul_SkAlphaType);
SkASSERT(dstContext.get());
test_read_pixels(reporter, dstContext.get(), expectedPixelValues, testName);
diff --git a/tests/TestUtils.h b/tests/TestUtils.h
index 221e051..33a6387 100644
--- a/tests/TestUtils.h
+++ b/tests/TestUtils.h
@@ -13,19 +13,18 @@
typedef uint32_t GrColor;
// Ensure that reading back from 'srcContext' as RGBA 8888 matches 'expectedPixelValues
-void test_read_pixels(skiatest::Reporter*,
- GrSurfaceContext* srcContext, uint32_t expectedPixelValues[],
- const char* testName);
+void test_read_pixels(skiatest::Reporter*, GrSurfaceContext* srcContext,
+ uint32_t expectedPixelValues[], const char* testName);
// See if trying to write RGBA 8888 pixels to 'dstContext' matches matches the
// expectation ('expectedToWork')
-void test_write_pixels(skiatest::Reporter*,
- GrSurfaceContext* srcContext, bool expectedToWork, const char* testName);
+void test_write_pixels(skiatest::Reporter*, GrSurfaceContext* srcContext, bool expectedToWork,
+ const char* testName);
-// Ensure that the pixels can be copied from 'proxy' to an RGBA 8888 destination (both
-// texture-backed and rendertarget-backed).
-void test_copy_from_surface(skiatest::Reporter*, GrContext*,
- GrSurfaceProxy* proxy, uint32_t expectedPixelValues[],
+// Ensure that the pixels can be copied from 'proxy' viewed as colorType, to an RGBA 8888
+// destination (both texture-backed and rendertarget-backed).
+void test_copy_from_surface(skiatest::Reporter*, GrContext*, GrSurfaceProxy* proxy,
+ GrColorType colorType, uint32_t expectedPixelValues[],
const char* testName);
// Fills data with a red-green gradient
diff --git a/tools/gpu/ProxyUtils.cpp b/tools/gpu/ProxyUtils.cpp
index 79e0a9c..10bb6fe 100644
--- a/tools/gpu/ProxyUtils.cpp
+++ b/tools/gpu/ProxyUtils.cpp
@@ -77,7 +77,7 @@
}
}
- auto sContext = context->priv().makeWrappedSurfaceContext(proxy, alphaType, nullptr);
+ auto sContext = context->priv().makeWrappedSurfaceContext(proxy, colorType, alphaType, nullptr);
if (!sContext) {
return nullptr;
}