diff options
-rw-r--r-- | bench/FontScalerBench.cpp | 13 | ||||
-rw-r--r-- | src/ports/SkFontHost_mac_coretext.cpp | 50 |
2 files changed, 58 insertions, 5 deletions
diff --git a/bench/FontScalerBench.cpp b/bench/FontScalerBench.cpp index 596b830809..4255f67bad 100644 --- a/bench/FontScalerBench.cpp +++ b/bench/FontScalerBench.cpp @@ -17,10 +17,12 @@ extern bool gSkSuppressFontCachePurgeSpew; class FontScalerBench : public SkBenchmark { SkString fName; SkString fText; + bool fDoLCD; public: - FontScalerBench(void* param) : INHERITED(param) { - fName.set("fontscaler"); + FontScalerBench(void* param, bool doLCD) : INHERITED(param) { + fName.printf("fontscaler_%s", doLCD ? "lcd" : "aa"); fText.set("abcdefghijklmnopqrstuvwxyz01234567890"); + fDoLCD = doLCD; } protected: @@ -28,6 +30,7 @@ protected: virtual void onDraw(SkCanvas* canvas) { SkPaint paint; this->setupPaint(&paint); + paint.setLCDRenderText(fDoLCD); bool prev = gSkSuppressFontCachePurgeSpew; gSkSuppressFontCachePurgeSpew = true; @@ -49,6 +52,8 @@ private: /////////////////////////////////////////////////////////////////////////////// -static SkBenchmark* Fact(void* p) { return SkNEW_ARGS(FontScalerBench, (p)); } +static SkBenchmark* Fact0(void* p) { return SkNEW_ARGS(FontScalerBench, (p, false)); } +static SkBenchmark* Fact1(void* p) { return SkNEW_ARGS(FontScalerBench, (p, true)); } -static BenchRegistry gReg(Fact); +static BenchRegistry gReg0(Fact0); +static BenchRegistry gReg1(Fact1); diff --git a/src/ports/SkFontHost_mac_coretext.cpp b/src/ports/SkFontHost_mac_coretext.cpp index 79a0c14fa4..61919c1a3f 100644 --- a/src/ports/SkFontHost_mac_coretext.cpp +++ b/src/ports/SkFontHost_mac_coretext.cpp @@ -29,6 +29,50 @@ #include "SkUtils.h" #include "SkTypefaceCache.h" +static void sk_memset_rect32(uint32_t* ptr, uint32_t value, size_t width, + size_t height, size_t rowBytes) { + SkASSERT(width); + SkASSERT(width * sizeof(uint32_t) <= rowBytes); + + if (width >= 32) { + while (height) { + sk_memset32(ptr, value, width); + ptr = (uint32_t*)((char*)ptr + rowBytes); + height -= 1; + } + return; + } + + rowBytes -= width * sizeof(uint32_t); + + if (width >= 8) { + while (height) { + int w = width; + do { + *ptr++ = value; *ptr++ = value; + *ptr++ = value; *ptr++ = value; + *ptr++ = value; *ptr++ = value; + *ptr++ = value; *ptr++ = value; + w -= 8; + } while (w >= 8); + while (--w >= 0) { + *ptr++ = value; + } + ptr = (uint32_t*)((char*)ptr + rowBytes); + height -= 1; + } + } else { + while (height) { + int w = width; + do { + *ptr++ = value; + } while (--w > 0); + ptr = (uint32_t*)((char*)ptr + rowBytes); + height -= 1; + } + } +} + // Potentially this should be made (1) public (2) optimized when width is small. // Also might want 16 and 32 bit version // @@ -299,9 +343,13 @@ CGRGBPixel* Offscreen::getCG(const SkGlyph& glyph, bool fgColorIsWhite, image += (fSize.fHeight - glyph.fHeight) * fSize.fWidth; // erase with the "opposite" of the fgColor - uint8_t erase = fgColorIsWhite ? 0 : 0xFF; + uint32_t erase = fgColorIsWhite ? 0 : ~0; +#if 0 sk_memset_rect(image, erase, glyph.fWidth * sizeof(CGRGBPixel), glyph.fHeight, rowBytes); +#else + sk_memset_rect32(image, erase, glyph.fWidth, glyph.fHeight, rowBytes); +#endif float subX = 0; float subY = 0; |