From cce3e58f6660a77e1a6f93d8579a279a2450b0da Mon Sep 17 00:00:00 2001 From: Brian Osman Date: Fri, 14 Oct 2016 11:42:20 -0400 Subject: [PATCH] Always use RGBA textures for color font atlases This is the last use of kSkiaGamma8888_GrPixelConfig BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=3417 Change-Id: I307479c41f1ca437733dfafd044bb1baeb42f31d Reviewed-on: https://skia-review.googlesource.com/3417 Reviewed-by: Brian Salomon Commit-Queue: Brian Osman --- include/gpu/GrTypes.h | 2 -- src/gpu/GrBatchAtlas.cpp | 18 +++++++++++++----- src/gpu/text/GrBatchFontCache.h | 2 +- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/gpu/GrTypes.h b/include/gpu/GrTypes.h index 6b73f3c073..3ec3023373 100644 --- a/include/gpu/GrTypes.h +++ b/include/gpu/GrTypes.h @@ -280,10 +280,8 @@ static const int kGrPixelConfigCnt = kLast_GrPixelConfig + 1; #endif #if SK_PMCOLOR_BYTE_ORDER(B,G,R,A) static const GrPixelConfig kSkia8888_GrPixelConfig = kBGRA_8888_GrPixelConfig; - static const GrPixelConfig kSkiaGamma8888_GrPixelConfig = kSBGRA_8888_GrPixelConfig; #elif SK_PMCOLOR_BYTE_ORDER(R,G,B,A) static const GrPixelConfig kSkia8888_GrPixelConfig = kRGBA_8888_GrPixelConfig; - static const GrPixelConfig kSkiaGamma8888_GrPixelConfig = kSRGBA_8888_GrPixelConfig; #else #error "SK_*32_SHIFT values must correspond to GL_BGRA or GL_RGBA format." #endif diff --git a/src/gpu/GrBatchAtlas.cpp b/src/gpu/GrBatchAtlas.cpp index e0828a4e6a..e478ca1c7d 100644 --- a/src/gpu/GrBatchAtlas.cpp +++ b/src/gpu/GrBatchAtlas.cpp @@ -62,11 +62,19 @@ bool GrBatchAtlas::BatchPlot::addSubImage(int width, int height, const void* ima unsigned char* dataPtr = fData; dataPtr += fBytesPerPixel * fWidth * loc->fY; dataPtr += fBytesPerPixel * loc->fX; - // copy into the data buffer - for (int i = 0; i < height; ++i) { - memcpy(dataPtr, imagePtr, rowBytes); - dataPtr += fBytesPerPixel * fWidth; - imagePtr += rowBytes; + // copy into the data buffer, swizzling as we go if this is ARGB data + if (4 == fBytesPerPixel && kSkia8888_GrPixelConfig == kBGRA_8888_GrPixelConfig) { + for (int i = 0; i < height; ++i) { + SkOpts::RGBA_to_BGRA(reinterpret_cast(dataPtr), imagePtr, width); + dataPtr += fBytesPerPixel * fWidth; + imagePtr += rowBytes; + } + } else { + for (int i = 0; i < height; ++i) { + memcpy(dataPtr, imagePtr, rowBytes); + dataPtr += fBytesPerPixel * fWidth; + imagePtr += rowBytes; + } } fDirtyRect.join(loc->fX, loc->fY, loc->fX + width, loc->fY + height); diff --git a/src/gpu/text/GrBatchFontCache.h b/src/gpu/text/GrBatchFontCache.h index 9e08c5303f..9bb19f5274 100644 --- a/src/gpu/text/GrBatchFontCache.h +++ b/src/gpu/text/GrBatchFontCache.h @@ -194,7 +194,7 @@ private: case kA565_GrMaskFormat: return kRGB_565_GrPixelConfig; case kARGB_GrMaskFormat: - return caps.srgbSupport() ? kSkiaGamma8888_GrPixelConfig : kSkia8888_GrPixelConfig; + return caps.srgbSupport() ? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig; default: SkDEBUGFAIL("unsupported GrMaskFormat"); return kAlpha_8_GrPixelConfig;