Replace glyph debugging macros with if constexpr
Replace SK_SHOW_TEXT_BLIT_COVERAGE macro with kSkShowTextBlitCoverage. Covert the ifdefs to if constexpr. Also fix issue with debugging converage of aliased masks with FreeType (don't try to treat them like a8 masks). Change-Id: I50b5c06b2b4f8ee74ea9c3710740af623be7d6fa Reviewed-on: https://skia-review.googlesource.com/c/skia/+/526520 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
087b5a2fff
commit
06fd22c7aa
@ -63,9 +63,7 @@ public:
|
||||
uint32_t fLen;
|
||||
};
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
uint32_t getCount() const { return fCount; }
|
||||
#endif
|
||||
|
||||
SkString dumpRec() const;
|
||||
|
||||
|
@ -37,9 +37,10 @@
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef SK_DEBUG
|
||||
#define DUMP_RECx
|
||||
#endif
|
||||
namespace {
|
||||
static inline const constexpr bool kSkShowTextBlitCoverage = false;
|
||||
static inline const constexpr bool kSkScalerContextDumpRec = false;
|
||||
}
|
||||
|
||||
SkScalerContextRec SkScalerContext::PreprocessRec(const SkTypeface& typeface,
|
||||
const SkScalerContextEffects& effects,
|
||||
@ -84,12 +85,12 @@ SkScalerContext::SkScalerContext(sk_sp<SkTypeface> typeface, const SkScalerConte
|
||||
|
||||
, fPreBlend(fMaskFilter ? SkMaskGamma::PreBlend() : SkScalerContext::GetMaskPreBlend(fRec))
|
||||
{
|
||||
#ifdef DUMP_REC
|
||||
SkDebugf("SkScalerContext checksum %x count %d length %d\n",
|
||||
desc->getChecksum(), desc->getCount(), desc->getLength());
|
||||
SkDebugf("%s", fRec.dump().c_str());
|
||||
SkDebugf(" effects %x\n", desc->findEntry(kEffects_SkDescriptorTag, nullptr));
|
||||
#endif
|
||||
if constexpr (kSkScalerContextDumpRec) {
|
||||
SkDebugf("SkScalerContext checksum %x count %d length %d\n",
|
||||
desc->getChecksum(), desc->getCount(), desc->getLength());
|
||||
SkDebugf("%s", fRec.dump().c_str());
|
||||
SkDebugf(" effects %p\n", desc->findEntry(kEffects_SkDescriptorTag, nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
SkScalerContext::~SkScalerContext() {}
|
||||
@ -275,8 +276,6 @@ SK_ERROR:
|
||||
return glyph;
|
||||
}
|
||||
|
||||
#define SK_SHOW_TEXT_BLIT_COVERAGE 0
|
||||
|
||||
static void applyLUTToA8Mask(const SkMask& mask, const uint8_t* lut) {
|
||||
uint8_t* SK_RESTRICT dst = (uint8_t*)mask.fImage;
|
||||
unsigned rowBytes = mask.fRowBytes;
|
||||
@ -385,9 +384,11 @@ static void pack4xHToMask(const SkPixmap& src, const SkMask& dst,
|
||||
g = fir[1];
|
||||
b = fir[2];
|
||||
}
|
||||
#if SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
r = std::max(r, 10); g = std::max(g, 10); b = std::max(b, 10);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
r = std::max(r, 10u);
|
||||
g = std::max(g, 10u);
|
||||
b = std::max(b, 10u);
|
||||
}
|
||||
if (toA8) {
|
||||
U8CPU a = (r + g + b) / 3;
|
||||
if (maskPreBlend.isApplicable()) {
|
||||
|
@ -33,6 +33,10 @@
|
||||
// In the past, FT_GlyphSlot_Own_Bitmap was defined in this header file.
|
||||
#include <freetype/ftsynth.h>
|
||||
|
||||
namespace {
|
||||
static inline const constexpr bool kSkShowTextBlitCoverage = false;
|
||||
}
|
||||
|
||||
#ifdef TT_SUPPORT_COLRV1
|
||||
// FT_ClipBox and FT_Get_Color_Glyph_ClipBox introduced VER-2-11-0-18-g47cf8ebf4
|
||||
// FT_COLR_COMPOSITE_PLUS and renumbering introduced VER-2-11-0-21-ge40ae7569
|
||||
@ -100,18 +104,18 @@ FT_Pixel_Mode compute_pixel_mode(SkMask::Format format) {
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint16_t packTriple(U8CPU r, U8CPU g, U8CPU b) {
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
r = std::max(r, (U8CPU)0x40);
|
||||
g = std::max(g, (U8CPU)0x40);
|
||||
b = std::max(b, (U8CPU)0x40);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
r = std::max(r, (U8CPU)0x40);
|
||||
g = std::max(g, (U8CPU)0x40);
|
||||
b = std::max(b, (U8CPU)0x40);
|
||||
}
|
||||
return SkPack888ToRGB16(r, g, b);
|
||||
}
|
||||
|
||||
uint16_t grayToRGB16(U8CPU gray) {
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
gray = std::max(gray, (U8CPU)0x40);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
gray = std::max(gray, (U8CPU)0x40);
|
||||
}
|
||||
return SkPack888ToRGB16(gray, gray, gray);
|
||||
}
|
||||
|
||||
@ -302,9 +306,9 @@ void copyFTBitmap(const FT_Bitmap& srcFTBitmap, SkMask& dstMask) {
|
||||
uint8_t r = *src_row++;
|
||||
uint8_t a = *src_row++;
|
||||
*dst_row++ = SkPackARGB32(a, r, g, b);
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
*(dst_row-1) = SkFourByteInterp256(*(dst_row-1), SK_ColorWHITE, 0x40);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
*(dst_row-1) = SkFourByteInterp256(*(dst_row-1), SK_ColorWHITE, 0x40);
|
||||
}
|
||||
}
|
||||
src += srcPitch;
|
||||
dst += dstRowBytes;
|
||||
@ -745,12 +749,12 @@ void colrv1_draw_paint(SkCanvas* canvas,
|
||||
* pass that to the path generation. */
|
||||
if (generateFacePathCOLRv1(face, glyphID, &path)) {
|
||||
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
SkPaint highlight_paint;
|
||||
highlight_paint.setColor(0x33FF0000);
|
||||
canvas->drawRect(path.getBounds(), highlight_paint);
|
||||
#endif
|
||||
canvas->clipPath(path, true /* doAntiAlias */);
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
SkPaint highlight_paint;
|
||||
highlight_paint.setColor(0x33FF0000);
|
||||
canvas->drawRect(path.getBounds(), highlight_paint);
|
||||
}
|
||||
canvas->clipPath(path, true /* doAntiAlias */);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -800,14 +804,12 @@ void colrv1_draw_glyph_with_path(SkCanvas* canvas, const SkSpan<SkColor>& palett
|
||||
* glyph graph, we need to extract at least the requested glyph width and height and
|
||||
* pass that to the path generation. */
|
||||
if (generateFacePathCOLRv1(face, glyphID, &path)) {
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
SkPaint highlight_paint;
|
||||
highlight_paint.setColor(0x33FF0000);
|
||||
canvas->drawRect(path.getBounds(), highlight_paint);
|
||||
#endif
|
||||
{
|
||||
canvas->drawPath(path, skiaFillPaint);
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
SkPaint highlight_paint;
|
||||
highlight_paint.setColor(0x33FF0000);
|
||||
canvas->drawRect(path.getBounds(), highlight_paint);
|
||||
}
|
||||
canvas->drawPath(path, skiaFillPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1322,11 +1324,11 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face,
|
||||
|
||||
// Scale unscaledBitmap into dstBitmap.
|
||||
SkCanvas canvas(dstBitmap);
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
canvas.clear(0x33FF0000);
|
||||
#else
|
||||
canvas.clear(SK_ColorTRANSPARENT);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
canvas.clear(0x33FF0000);
|
||||
} else {
|
||||
canvas.clear(SK_ColorTRANSPARENT);
|
||||
}
|
||||
canvas.translate(-glyph.fLeft, -glyph.fTop);
|
||||
|
||||
if (this->isSubpixel()) {
|
||||
@ -1343,7 +1345,7 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face,
|
||||
return;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
#endif // FT_COLOR_H
|
||||
if (SkMask::kLCD16_Format == glyph.fMaskFormat) {
|
||||
FT_Outline_Translate(outline, dx, dy);
|
||||
FT_Error err = FT_Render_Glyph(face->glyph, doVert ? FT_RENDER_MODE_LCD_V :
|
||||
@ -1354,9 +1356,9 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face,
|
||||
}
|
||||
|
||||
SkMask mask = glyph.mask();
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
memset(mask.fImage, 0x80, mask.fBounds.height() * mask.fRowBytes);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
memset(mask.fImage, 0x80, mask.fBounds.height() * mask.fRowBytes);
|
||||
}
|
||||
FT_GlyphSlotRec& ftGlyph = *face->glyph;
|
||||
|
||||
if (!SkIRect::Intersects(mask.fBounds,
|
||||
@ -1439,14 +1441,23 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face,
|
||||
target.num_grays = 256;
|
||||
|
||||
FT_Outline_Get_Bitmap(face->glyph->library, outline, &target);
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
for (int y = 0; y < glyph.fHeight; ++y) {
|
||||
for (int x = 0; x < glyph.fWidth; ++x) {
|
||||
uint8_t& a = ((uint8_t*)glyph.fImage)[(glyph.rowBytes() * y) + x];
|
||||
a = std::max<uint8_t>(a, 0x20);
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
if (glyph.fMaskFormat == SkMask::kBW_Format) {
|
||||
for (unsigned y = 0; y < target.rows; y += 2) {
|
||||
for (unsigned x = (y & 0x2); x < target.width; x+=4) {
|
||||
uint8_t& b = target.buffer[(target.pitch * y) + (x >> 3)];
|
||||
b = b ^ (1 << (0x7 - (x & 0x7)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (unsigned y = 0; y < target.rows; ++y) {
|
||||
for (unsigned x = 0; x < target.width; ++x) {
|
||||
uint8_t& a = target.buffer[(target.pitch * y) + x];
|
||||
a = std::max<uint8_t>(a, 0x20);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} break;
|
||||
|
||||
@ -1511,11 +1522,11 @@ void SkScalerContext_FreeType_Base::generateGlyphImage(FT_Face face,
|
||||
|
||||
// Scale unscaledBitmap into dstBitmap.
|
||||
SkCanvas canvas(dstBitmap);
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
canvas.clear(0x33FF0000);
|
||||
#else
|
||||
canvas.clear(SK_ColorTRANSPARENT);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
canvas.clear(0x33FF0000);
|
||||
} else {
|
||||
canvas.clear(SK_ColorTRANSPARENT);
|
||||
}
|
||||
canvas.translate(-glyph.fLeft, -glyph.fTop);
|
||||
canvas.concat(bitmapTransform);
|
||||
canvas.translate(face->glyph->bitmap_left, -face->glyph->bitmap_top);
|
||||
|
@ -41,6 +41,10 @@
|
||||
#include <usp10.h>
|
||||
#include <objbase.h>
|
||||
|
||||
namespace {
|
||||
static inline const constexpr bool kSkShowTextBlitCoverage = false;
|
||||
}
|
||||
|
||||
static void (*gEnsureLOGFONTAccessibleProc)(const LOGFONT&);
|
||||
|
||||
void SkTypeface_SetEnsureLOGFONTAccessibleProc(void (*proc)(const LOGFONT&)) {
|
||||
@ -982,8 +986,6 @@ void SkScalerContext_GDI::generateFontMetrics(SkFontMetrics* metrics) {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#define SK_SHOW_TEXT_BLIT_COVERAGE 0
|
||||
|
||||
static void build_power_table(uint8_t table[], float ee) {
|
||||
for (int i = 0; i < 256; i++) {
|
||||
float x = i / 255.f;
|
||||
@ -1052,9 +1054,11 @@ static inline uint16_t rgb_to_lcd16(SkGdiRGB rgb, const uint8_t* tableR,
|
||||
U8CPU r = sk_apply_lut_if<APPLY_PREBLEND>((rgb >> 16) & 0xFF, tableR);
|
||||
U8CPU g = sk_apply_lut_if<APPLY_PREBLEND>((rgb >> 8) & 0xFF, tableG);
|
||||
U8CPU b = sk_apply_lut_if<APPLY_PREBLEND>((rgb >> 0) & 0xFF, tableB);
|
||||
#if SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
r = std::max(r, 10); g = std::max(g, 10); b = std::max(b, 10);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
r = std::max(r, 10u);
|
||||
g = std::max(g, 10u);
|
||||
b = std::max(b, 10u);
|
||||
}
|
||||
return SkPack888ToRGB16(r, g, b);
|
||||
}
|
||||
|
||||
@ -1068,9 +1072,9 @@ void SkScalerContext_GDI::RGBToA8(const SkGdiRGB* SK_RESTRICT src, size_t srcRB,
|
||||
for (int y = 0; y < glyph.fHeight; y++) {
|
||||
for (int i = 0; i < width; i++) {
|
||||
dst[i] = rgb_to_a8<APPLY_PREBLEND>(src[i], table8);
|
||||
#if SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
dst[i] = std::max(dst[i], 10);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
dst[i] = std::max(dst[i], 10u);
|
||||
}
|
||||
}
|
||||
src = SkTAddOffset<const SkGdiRGB>(src, srcRB);
|
||||
dst -= dstRB;
|
||||
@ -1146,7 +1150,7 @@ void SkScalerContext_GDI::generateImage(const SkGlyph& glyph) {
|
||||
src += srcRB;
|
||||
dst -= dstRB;
|
||||
}
|
||||
#if SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
if (glyph.width() > 0 && glyph.fHeight > 0) {
|
||||
int bitCount = glyph.width() & 7;
|
||||
uint8_t* first = (uint8_t*)glyph.fImage;
|
||||
@ -1154,7 +1158,7 @@ void SkScalerContext_GDI::generateImage(const SkGlyph& glyph) {
|
||||
*first |= 1 << 7;
|
||||
*last |= bitCount == 0 ? 1 : 1 << (8 - bitCount);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
} else if (isAA) {
|
||||
// since the caller may require A8 for maskfilters, we can't check for BW
|
||||
// ... until we have the caller tell us that explicitly
|
||||
|
@ -54,8 +54,9 @@
|
||||
class SkDescriptor;
|
||||
|
||||
|
||||
// Set to make glyph bounding boxes visible.
|
||||
#define SK_SHOW_TEXT_BLIT_COVERAGE 0
|
||||
namespace {
|
||||
static inline const constexpr bool kSkShowTextBlitCoverage = false;
|
||||
}
|
||||
|
||||
static void sk_memset_rect32(uint32_t* ptr, uint32_t value,
|
||||
int width, int height, size_t rowBytes) {
|
||||
@ -409,9 +410,9 @@ static inline uint8_t rgb_to_a8(CGRGBPixel rgb, const uint8_t* table8) {
|
||||
U8CPU g = 0xFF - ((rgb >> 8) & 0xFF);
|
||||
U8CPU b = 0xFF - ((rgb >> 0) & 0xFF);
|
||||
U8CPU lum = sk_apply_lut_if<APPLY_PREBLEND>(SkComputeLuminance(r, g, b), table8);
|
||||
#if SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
lum = std::max(lum, (U8CPU)0x30);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
lum = std::max(lum, (U8CPU)0x30);
|
||||
}
|
||||
return lum;
|
||||
}
|
||||
|
||||
@ -438,11 +439,11 @@ static uint16_t RGBToLcd16(CGRGBPixel rgb,
|
||||
U8CPU r = sk_apply_lut_if<APPLY_PREBLEND>(0xFF - ((rgb >> 16) & 0xFF), tableR);
|
||||
U8CPU g = sk_apply_lut_if<APPLY_PREBLEND>(0xFF - ((rgb >> 8) & 0xFF), tableG);
|
||||
U8CPU b = sk_apply_lut_if<APPLY_PREBLEND>(0xFF - ((rgb >> 0) & 0xFF), tableB);
|
||||
#if SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
r = std::max(r, (U8CPU)0x30);
|
||||
g = std::max(g, (U8CPU)0x30);
|
||||
b = std::max(b, (U8CPU)0x30);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
r = std::max(r, (U8CPU)0x30);
|
||||
g = std::max(g, (U8CPU)0x30);
|
||||
b = std::max(b, (U8CPU)0x30);
|
||||
}
|
||||
return SkPack888ToRGB16(r, g, b);
|
||||
}
|
||||
|
||||
@ -469,9 +470,9 @@ static SkPMColor cgpixels_to_pmcolor(CGRGBPixel rgb) {
|
||||
U8CPU r = (rgb >> 16) & 0xFF;
|
||||
U8CPU g = (rgb >> 8) & 0xFF;
|
||||
U8CPU b = (rgb >> 0) & 0xFF;
|
||||
#if SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
a = std::max(a, (U8CPU)0x30);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
a = std::max(a, (U8CPU)0x30);
|
||||
}
|
||||
return SkPackARGB32(a, r, g, b);
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,7 @@
|
||||
#include <dwrite_3.h>
|
||||
|
||||
namespace {
|
||||
static inline const constexpr bool kSkShowTextBlitCoverage = false;
|
||||
|
||||
/* Note:
|
||||
* In versions 8 and 8.1 of Windows, some calls in DWrite are not thread safe.
|
||||
@ -1119,11 +1120,11 @@ void SkScalerContext_DW::generateColorGlyphImage(const SkGlyph& glyph) {
|
||||
dstBitmap.setPixels(glyph.fImage);
|
||||
|
||||
SkCanvas canvas(dstBitmap);
|
||||
#ifdef SK_SHOW_TEXT_BLIT_COVERAGE
|
||||
canvas.clear(0x33FF0000);
|
||||
#else
|
||||
canvas.clear(SK_ColorTRANSPARENT);
|
||||
#endif
|
||||
if constexpr (kSkShowTextBlitCoverage) {
|
||||
canvas.clear(0x33FF0000);
|
||||
} else {
|
||||
canvas.clear(SK_ColorTRANSPARENT);
|
||||
}
|
||||
canvas.translate(-SkIntToScalar(glyph.fLeft), -SkIntToScalar(glyph.fTop));
|
||||
|
||||
this->drawColorGlyphImage(glyph, canvas);
|
||||
|
Loading…
Reference in New Issue
Block a user