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/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);