Move last few uses of SkColorType out of GrCaps.
Change-Id: Ie13e511f42afa7a06fad674ead3e1d5d8e051e77
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/226216
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
diff --git a/src/core/SkSurfaceCharacterization.cpp b/src/core/SkSurfaceCharacterization.cpp
index 4e84ca5..a97ffc5 100644
--- a/src/core/SkSurfaceCharacterization.cpp
+++ b/src/core/SkSurfaceCharacterization.cpp
@@ -16,7 +16,7 @@
const GrCaps* caps = fContextInfo->priv().caps();
GrColorType grCT = SkColorTypeToGrColorType(this->colorType());
- int maxColorSamples = caps->maxRenderTargetSampleCount(this->colorType(), fBackendFormat);
+ int maxColorSamples = caps->maxRenderTargetSampleCount(grCT, fBackendFormat);
SkASSERT(maxColorSamples && fSampleCnt && fSampleCnt <= maxColorSamples);
SkASSERT(caps->areColorTypeAndFormatCompatible(grCT, fBackendFormat));
diff --git a/src/gpu/GrCaps.h b/src/gpu/GrCaps.h
index c39a1d7..314165b 100644
--- a/src/gpu/GrCaps.h
+++ b/src/gpu/GrCaps.h
@@ -162,12 +162,12 @@
virtual bool isConfigTexturable(GrPixelConfig) const = 0;
// Returns whether a texture of the given config can be copied to a texture of the same config.
- virtual bool isFormatCopyable(SkColorType, const GrBackendFormat&) const = 0;
+ virtual bool isFormatCopyable(GrColorType, const GrBackendFormat&) const = 0;
virtual bool isConfigCopyable(GrPixelConfig) const = 0;
// Returns the maximum supported sample count for a config. 0 means the config is not renderable
// 1 means the config is renderable but doesn't support MSAA.
- virtual int maxRenderTargetSampleCount(SkColorType, const GrBackendFormat&) const = 0;
+ virtual int maxRenderTargetSampleCount(GrColorType, const GrBackendFormat&) const = 0;
virtual int maxRenderTargetSampleCount(GrPixelConfig) const = 0;
// Returns the number of samples to use when performing internal draws to the given config with
@@ -190,7 +190,7 @@
// sample count is 1 then 1 will be returned if non-MSAA rendering is supported, otherwise 0.
// For historical reasons requestedCount==0 is handled identically to requestedCount==1.
virtual int getRenderTargetSampleCount(int requestedCount,
- SkColorType, const GrBackendFormat&) const = 0;
+ GrColorType, const GrBackendFormat&) const = 0;
virtual int getRenderTargetSampleCount(int requestedCount, GrPixelConfig) const = 0;
/**
diff --git a/src/gpu/GrContextThreadSafeProxy.cpp b/src/gpu/GrContextThreadSafeProxy.cpp
index f01e8d6..9a1a37a 100644
--- a/src/gpu/GrContextThreadSafeProxy.cpp
+++ b/src/gpu/GrContextThreadSafeProxy.cpp
@@ -59,7 +59,7 @@
return SkSurfaceCharacterization(); // return an invalid characterization
}
- sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, ii.colorType(), backendFormat);
+ sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, grColorType, backendFormat);
if (!sampleCnt) {
return SkSurfaceCharacterization(); // return an invalid characterization
}
diff --git a/src/gpu/GrProxyProvider.cpp b/src/gpu/GrProxyProvider.cpp
index 25d8839..1fc2756 100644
--- a/src/gpu/GrProxyProvider.cpp
+++ b/src/gpu/GrProxyProvider.cpp
@@ -235,7 +235,7 @@
}
if (SkToBool(descFlags & kRenderTarget_GrSurfaceFlag)) {
- sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, ct, format);
+ sampleCnt = this->caps()->getRenderTargetSampleCount(sampleCnt, grCT, format);
if (!sampleCnt) {
return nullptr;
}
diff --git a/src/gpu/gl/GrGLCaps.cpp b/src/gpu/gl/GrGLCaps.cpp
index 22e81ee..72425aa 100644
--- a/src/gpu/gl/GrGLCaps.cpp
+++ b/src/gpu/gl/GrGLCaps.cpp
@@ -3620,9 +3620,8 @@
return this->isGLFormatTexturable(ct, *glFormat);
}
-int GrGLCaps::getRenderTargetSampleCount(int requestedCount, SkColorType skCT,
+int GrGLCaps::getRenderTargetSampleCount(int requestedCount, GrColorType grCT,
const GrBackendFormat& format) const {
- GrColorType grCT = SkColorTypeToGrColorType(skCT);
if (GrColorType::kUnknown == grCT) {
return 0;
}
@@ -3658,8 +3657,7 @@
return 0;
}
-int GrGLCaps::maxRenderTargetSampleCount(SkColorType skCT, const GrBackendFormat& format) const {
- GrColorType grCT = SkColorTypeToGrColorType(skCT);
+int GrGLCaps::maxRenderTargetSampleCount(GrColorType grCT, const GrBackendFormat& format) const {
if (GrColorType::kUnknown == grCT) {
return 0;
}
@@ -3691,7 +3689,7 @@
return SkToBool(this->getFormatInfo(glFormat).fFlags & FormatInfo::kFBOColorAttachment_Flag);
}
-bool GrGLCaps::isFormatCopyable(SkColorType ct, const GrBackendFormat& format) const {
+bool GrGLCaps::isFormatCopyable(GrColorType, const GrBackendFormat& format) const {
const GrGLenum* glFormat = format.getGLFormat();
if (!glFormat || !GrGLFormatIsSupported(*glFormat)) {
return false;
diff --git a/src/gpu/gl/GrGLCaps.h b/src/gpu/gl/GrGLCaps.h
index be1ceaf..91b01d1 100644
--- a/src/gpu/gl/GrGLCaps.h
+++ b/src/gpu/gl/GrGLCaps.h
@@ -117,13 +117,13 @@
}
int getRenderTargetSampleCount(int requestedCount,
- SkColorType, const GrBackendFormat&) const override;
+ GrColorType, const GrBackendFormat&) const override;
int getRenderTargetSampleCount(int requestedCount, GrPixelConfig config) const override;
- int maxRenderTargetSampleCount(SkColorType, const GrBackendFormat&) const override;
+ int maxRenderTargetSampleCount(GrColorType, const GrBackendFormat&) const override;
int maxRenderTargetSampleCount(GrPixelConfig config) const override;
- bool isFormatCopyable(SkColorType, const GrBackendFormat&) const override;
+ bool isFormatCopyable(GrColorType, const GrBackendFormat&) const override;
bool isConfigCopyable(GrPixelConfig config) const override {
// In GL we have three ways to be able to copy. CopyTexImage, blit, and draw. CopyTexImage
// requires the src to be an FBO attachment, blit requires both src and dst to be FBO
diff --git a/src/gpu/mock/GrMockCaps.h b/src/gpu/mock/GrMockCaps.h
index f4f05c9..c58dc62 100644
--- a/src/gpu/mock/GrMockCaps.h
+++ b/src/gpu/mock/GrMockCaps.h
@@ -60,7 +60,7 @@
return fOptions.fConfigOptions[(int)ct].fTexturable;
}
- bool isFormatCopyable(SkColorType, const GrBackendFormat& format) const override {
+ bool isFormatCopyable(GrColorType, const GrBackendFormat& format) const override {
return false;
}
@@ -83,7 +83,7 @@
}
int getRenderTargetSampleCount(int requestCount,
- SkColorType, const GrBackendFormat& format) const override {
+ GrColorType, const GrBackendFormat& format) const override {
if (!format.getMockColorType()) {
return 0;
}
@@ -111,7 +111,7 @@
return 0;
}
- int maxRenderTargetSampleCount(SkColorType, const GrBackendFormat& format) const override {
+ int maxRenderTargetSampleCount(GrColorType, const GrBackendFormat& format) const override {
if (!format.getMockColorType()) {
return 0;
}
diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h
index 04b5213..14bb0da 100644
--- a/src/gpu/mtl/GrMtlCaps.h
+++ b/src/gpu/mtl/GrMtlCaps.h
@@ -35,17 +35,17 @@
}
int getRenderTargetSampleCount(int requestedCount,
- SkColorType, const GrBackendFormat&) const override;
+ GrColorType, const GrBackendFormat&) const override;
int getRenderTargetSampleCount(int requestedCount, GrPixelConfig) const override;
- int maxRenderTargetSampleCount(SkColorType, const GrBackendFormat&) const override;
+ int maxRenderTargetSampleCount(GrColorType, const GrBackendFormat&) const override;
int maxRenderTargetSampleCount(GrPixelConfig) const override;
SurfaceReadPixelsSupport surfaceSupportsReadPixels(const GrSurface*) const override {
return SurfaceReadPixelsSupport::kSupported;
}
- bool isFormatCopyable(SkColorType, const GrBackendFormat&) const override { return true; }
+ bool isFormatCopyable(GrColorType, const GrBackendFormat&) const override { return true; }
bool isConfigCopyable(GrPixelConfig) const override { return true; }
/**
diff --git a/src/gpu/mtl/GrMtlCaps.mm b/src/gpu/mtl/GrMtlCaps.mm
index ea5de88..e852ee9 100644
--- a/src/gpu/mtl/GrMtlCaps.mm
+++ b/src/gpu/mtl/GrMtlCaps.mm
@@ -266,8 +266,7 @@
return this->isConfigTexturable(config);
}
-int GrMtlCaps::maxRenderTargetSampleCount(SkColorType skCT, const GrBackendFormat& format) const {
- GrColorType grCT = SkColorTypeToGrColorType(skCT);
+int GrMtlCaps::maxRenderTargetSampleCount(GrColorType grCT, const GrBackendFormat& format) const {
if (GrColorType::kUnknown == grCT) {
return 0;
}
@@ -290,8 +289,7 @@
}
int GrMtlCaps::getRenderTargetSampleCount(int requestedCount,
- SkColorType skCT, const GrBackendFormat& format) const {
- GrColorType grCT = SkColorTypeToGrColorType(skCT);
+ GrColorType grCT, const GrBackendFormat& format) const {
if (GrColorType::kUnknown == grCT) {
return 0;
}
diff --git a/src/gpu/vk/GrVkCaps.cpp b/src/gpu/vk/GrVkCaps.cpp
index 85229c3..c60b918 100644
--- a/src/gpu/vk/GrVkCaps.cpp
+++ b/src/gpu/vk/GrVkCaps.cpp
@@ -825,7 +825,7 @@
}
int GrVkCaps::getRenderTargetSampleCount(int requestedCount,
- SkColorType, const GrBackendFormat& format) const {
+ GrColorType, const GrBackendFormat& format) const {
if (!format.getVkFormat()) {
return 0;
}
@@ -872,7 +872,7 @@
return 0;
}
-int GrVkCaps::maxRenderTargetSampleCount(SkColorType, const GrBackendFormat& format) const {
+int GrVkCaps::maxRenderTargetSampleCount(GrColorType, const GrBackendFormat& format) const {
if (!format.getVkFormat()) {
return 0;
}
diff --git a/src/gpu/vk/GrVkCaps.h b/src/gpu/vk/GrVkCaps.h
index e1dc4c3..dafe0a9 100644
--- a/src/gpu/vk/GrVkCaps.h
+++ b/src/gpu/vk/GrVkCaps.h
@@ -38,17 +38,17 @@
bool isVkFormatTexturable(VkFormat) const;
bool isConfigTexturable(GrPixelConfig config) const override;
- bool isFormatCopyable(SkColorType, const GrBackendFormat&) const override { return true; }
+ bool isFormatCopyable(GrColorType, const GrBackendFormat&) const override { return true; }
bool isConfigCopyable(GrPixelConfig config) const override { return true; }
bool isFormatRenderable(VkFormat) const;
int getRenderTargetSampleCount(int requestedCount,
- SkColorType, const GrBackendFormat&) const override;
+ GrColorType, const GrBackendFormat&) const override;
int getRenderTargetSampleCount(int requestedCount, GrPixelConfig config) const override;
int getRenderTargetSampleCount(int requestedCount, VkFormat) const;
- int maxRenderTargetSampleCount(SkColorType, const GrBackendFormat&) const override;
+ int maxRenderTargetSampleCount(GrColorType, const GrBackendFormat&) const override;
int maxRenderTargetSampleCount(GrPixelConfig config) const override;
int maxRenderTargetSampleCount(VkFormat format) const;
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp
index 9523dbd..2771dae 100644
--- a/src/gpu/vk/GrVkGpu.cpp
+++ b/src/gpu/vk/GrVkGpu.cpp
@@ -1324,8 +1324,7 @@
return nullptr;
}
GrColorType grColorType = SkColorTypeToGrColorType(imageInfo.colorType());
- int sampleCnt = this->caps()->getRenderTargetSampleCount(1, imageInfo.colorType(),
- backendFormat);
+ int sampleCnt = this->caps()->getRenderTargetSampleCount(1, grColorType, backendFormat);
if (!sampleCnt) {
return nullptr;
}
diff --git a/src/image/SkSurface_Gpu.cpp b/src/image/SkSurface_Gpu.cpp
index 4400106..2459294 100644
--- a/src/image/SkSurface_Gpu.cpp
+++ b/src/image/SkSurface_Gpu.cpp
@@ -406,10 +406,8 @@
}
static bool validate_backend_texture(GrContext* ctx, const GrBackendTexture& tex,
- GrPixelConfig* config, int sampleCnt, SkColorType ct,
+ GrPixelConfig* config, int sampleCnt, GrColorType grCT,
bool texturable) {
- GrColorType grCT = SkColorTypeToGrColorType(ct);
-
if (!tex.isValid()) {
return false;
}
@@ -425,7 +423,7 @@
// We don't require that the client gave us an exact valid sample cnt. However, it must be
// less than the max supported sample count and 1 if MSAA is unsupported for the color type.
- if (!ctx->priv().caps()->getRenderTargetSampleCount(sampleCnt, ct, backendFormat)) {
+ if (!ctx->priv().caps()->getRenderTargetSampleCount(sampleCnt, grCT, backendFormat)) {
return false;
}
@@ -453,9 +451,11 @@
return nullptr;
}
+ GrColorType grCT = SkColorTypeToGrColorType(c.colorType());
+
GrBackendTexture texCopy = backendTexture;
if (!validate_backend_texture(context, texCopy, &texCopy.fConfig,
- c.sampleCount(), c.colorType(), true)) {
+ c.sampleCount(), grCT, true)) {
return nullptr;
}
@@ -464,7 +464,7 @@
}
sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
- texCopy, c.origin(), c.sampleCount(), SkColorTypeToGrColorType(c.colorType()),
+ texCopy, c.origin(), c.sampleCount(), grCT,
c.refColorSpace(), &c.surfaceProps(), textureReleaseProc, releaseContext));
if (!rtc) {
return nullptr;
@@ -538,9 +538,10 @@
return nullptr;
}
sampleCnt = SkTMax(1, sampleCnt);
+ GrColorType grColorType = SkColorTypeToGrColorType(colorType);
GrBackendTexture texCopy = tex;
- if (!validate_backend_texture(context, texCopy, &texCopy.fConfig,
- sampleCnt, colorType, true)) {
+ if (!validate_backend_texture(context, texCopy, &texCopy.fConfig, sampleCnt, grColorType,
+ true)) {
return nullptr;
}
@@ -552,8 +553,8 @@
}
sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
- texCopy, origin, sampleCnt, SkColorTypeToGrColorType(colorType),
- std::move(colorSpace), props, textureReleaseProc, releaseContext));
+ texCopy, origin, sampleCnt, grColorType, std::move(colorSpace), props,
+ textureReleaseProc, releaseContext));
if (!rtc) {
return nullptr;
}
@@ -601,9 +602,10 @@
SkASSERT(oldTexture->asRenderTarget());
int sampleCnt = oldTexture->asRenderTarget()->numSamples();
GrBackendTexture texCopy = backendTexture;
+ GrColorType grColorType = SkColorTypeToGrColorType(this->getCanvas()->imageInfo().colorType());
auto colorSpace = sk_ref_sp(oldRTC->colorSpaceInfo().colorSpace());
- if (!validate_backend_texture(context, texCopy, &texCopy.fConfig, sampleCnt,
- this->getCanvas()->imageInfo().colorType(), true)) {
+ if (!validate_backend_texture(context, texCopy, &texCopy.fConfig, sampleCnt, grColorType,
+ true)) {
return false;
}
sk_sp<GrRenderTargetContext> rtc(context->priv().makeBackendTextureRenderTargetContext(
@@ -703,9 +705,10 @@
}
sampleCnt = SkTMax(1, sampleCnt);
+ GrColorType grColorType = SkColorTypeToGrColorType(colorType);
GrBackendTexture texCopy = tex;
if (!validate_backend_texture(context, texCopy, &texCopy.fConfig,
- sampleCnt, colorType, false)) {
+ sampleCnt, grColorType, false)) {
return nullptr;
}
@@ -718,7 +721,7 @@
texCopy,
origin,
sampleCnt,
- SkColorTypeToGrColorType(colorType),
+ grColorType,
std::move(colorSpace),
props));
if (!rtc) {
diff --git a/tests/DeferredDisplayListTest.cpp b/tests/DeferredDisplayListTest.cpp
index b86cf83..2aebda5 100644
--- a/tests/DeferredDisplayListTest.cpp
+++ b/tests/DeferredDisplayListTest.cpp
@@ -341,7 +341,8 @@
if (SurfaceParameters::kSampleCount == i) {
int supportedSampleCount = caps->getRenderTargetSampleCount(
- params.sampleCount(), params.colorType(), backend.getBackendFormat());
+ params.sampleCount(), SkColorTypeToGrColorType(params.colorType()),
+ backend.getBackendFormat());
if (1 == supportedSampleCount) {
// If changing the sample count won't result in a different
// surface characterization, skip this step
diff --git a/tests/GLProgramsTest.cpp b/tests/GLProgramsTest.cpp
index 4fe45de..c20e842 100644
--- a/tests/GLProgramsTest.cpp
+++ b/tests/GLProgramsTest.cpp
@@ -148,11 +148,10 @@
GrSurfaceOrigin origin = random->nextBool() ? kTopLeft_GrSurfaceOrigin
: kBottomLeft_GrSurfaceOrigin;
- const GrBackendFormat format = caps->getBackendFormatFromColorType(GrColorType::kRGBA_8888);
+ GrColorType ct = GrColorType::kRGBA_8888;
+ const GrBackendFormat format = caps->getBackendFormatFromColorType(ct);
- int sampleCnt = random->nextBool()
- ? caps->getRenderTargetSampleCount(2, kRGBA_8888_SkColorType, format)
- : 1;
+ int sampleCnt = random->nextBool() ? caps->getRenderTargetSampleCount(2, ct, format) : 1;
// Above could be 0 if msaa isn't supported.
sampleCnt = SkTMax(1, sampleCnt);
diff --git a/tests/ResourceCacheTest.cpp b/tests/ResourceCacheTest.cpp
index 24ed504..29b13d0 100644
--- a/tests/ResourceCacheTest.cpp
+++ b/tests/ResourceCacheTest.cpp
@@ -129,7 +129,8 @@
GrResourceProvider* resourceProvider = context->priv().resourceProvider();
- GrBackendFormat format = caps->getBackendFormatFromColorType(GrColorType::kRGBA_8888);
+ GrColorType grColorType = GrColorType::kRGBA_8888;
+ GrBackendFormat format = caps->getBackendFormatFromColorType(grColorType);
sk_sp<GrRenderTarget> smallRT0 = create_RT_with_SB(resourceProvider, 4, 1, SkBudgeted::kYes);
REPORTER_ASSERT(reporter, smallRT0);
@@ -159,7 +160,7 @@
}
int smallSampleCount =
- context->priv().caps()->getRenderTargetSampleCount(2, kRGBA_8888_SkColorType, format);
+ context->priv().caps()->getRenderTargetSampleCount(2, grColorType, format);
if (smallSampleCount > 1) {
// An RT with a different sample count should not share.
sk_sp<GrRenderTarget> smallMSAART0 = create_RT_with_SB(resourceProvider, 4,
@@ -181,7 +182,7 @@
// But one with a larger sample count should not. (Also check that the two requests didn't
// rounded up to the same actual sample count or else they could share.).
int bigSampleCount = context->priv().caps()->getRenderTargetSampleCount(
- 5, kRGBA_8888_SkColorType, format);
+ 5, grColorType, format);
if (bigSampleCount > 0 && bigSampleCount != smallSampleCount) {
sk_sp<GrRenderTarget> smallMSAART2 = create_RT_with_SB(resourceProvider, 4,
bigSampleCount,