diff options
author | 2011-09-30 20:31:25 +0000 | |
---|---|---|
committer | 2011-09-30 20:31:25 +0000 | |
commit | 6fc3c1fe428eaaa1581d32988354870cf005d03b (patch) | |
tree | 78e6a679bd78bf668ee13fd0885fc396e82e26b5 /src/core | |
parent | e958c6949af2def03ae894917e81eab008116947 (diff) |
Detect that we're drawing to a device that has per-pixel alpha, and if so,
disable LCD text.
Add experimental flag to force AA in fontscaler (windows-only). Hope to remove
this later.
git-svn-id: http://skia.googlecode.com/svn/trunk@2387 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkBlitter_ARGB32.cpp | 35 | ||||
-rw-r--r-- | src/core/SkDevice.cpp | 7 | ||||
-rw-r--r-- | src/core/SkPaint.cpp | 5 |
3 files changed, 26 insertions, 21 deletions
diff --git a/src/core/SkBlitter_ARGB32.cpp b/src/core/SkBlitter_ARGB32.cpp index af55aba951..4e2916af0e 100644 --- a/src/core/SkBlitter_ARGB32.cpp +++ b/src/core/SkBlitter_ARGB32.cpp @@ -60,18 +60,16 @@ static void blit_lcd16_row(SkPMColor dst[], const uint16_t src[], maskG = maskG * srcA >> 8; maskB = maskB * srcA >> 8; - int maskA = SkMax32(SkMax32(maskR, maskG), maskB); - - int dstA = SkGetPackedA32(d); int dstR = SkGetPackedR32(d); int dstG = SkGetPackedG32(d); int dstB = SkGetPackedB32(d); - // nocheck version for now, until we cleanup GDI's garbage bits - dst[i] = SkPackARGB32NoCheck(blend32(0xFF, dstA, maskA), - blend32(srcR, dstR, maskR), - blend32(srcG, dstG, maskG), - blend32(srcB, dstB, maskB)); + // LCD blitting is only supported if the dst is known/required\ + // to be opaque + dst[i] = SkPackARGB32(0xFF, + blend32(srcR, dstR, maskR), + blend32(srcG, dstG, maskG), + blend32(srcB, dstB, maskB)); } } @@ -105,18 +103,16 @@ static void blit_lcd16_opaque_row(SkPMColor dst[], const uint16_t src[], maskG = upscale31To32(maskG); maskB = upscale31To32(maskB); - int maskA = SkMax32(SkMax32(maskR, maskG), maskB); - - int dstA = SkGetPackedA32(d); int dstR = SkGetPackedR32(d); int dstG = SkGetPackedG32(d); int dstB = SkGetPackedB32(d); - // nocheck version for now, until we cleanup GDI's garbage bits - dst[i] = SkPackARGB32NoCheck(blend32(0xFF, dstA, maskA), - blend32(srcR, dstR, maskR), - blend32(srcG, dstG, maskG), - blend32(srcB, dstB, maskB)); + // LCD blitting is only supported if the dst is known/required + // to be opaque + dst[i] = SkPackARGB32(0xFF, + blend32(srcR, dstR, maskR), + blend32(srcG, dstG, maskG), + blend32(srcB, dstB, maskB)); } } @@ -150,14 +146,13 @@ static void blit_lcd32_row(SkPMColor dst[], const uint32_t src[], maskG = maskG * srcA >> 8; maskB = maskB * srcA >> 8; - int maskA = SkMax32(SkMax32(maskR, maskG), maskB); - - int dstA = SkGetPackedA32(d); int dstR = SkGetPackedR32(d); int dstG = SkGetPackedG32(d); int dstB = SkGetPackedB32(d); - dst[i] = SkPackARGB32(SkAlphaBlend(0xFF, dstA, maskA), + // LCD blitting is only supported if the dst is known/required + // to be opaque + dst[i] = SkPackARGB32(0xFF, SkAlphaBlend(srcR, dstR, maskR), SkAlphaBlend(srcG, dstG, maskG), SkAlphaBlend(srcB, dstB, maskB)); diff --git a/src/core/SkDevice.cpp b/src/core/SkDevice.cpp index 69f86ccf52..c88ad9afb7 100644 --- a/src/core/SkDevice.cpp +++ b/src/core/SkDevice.cpp @@ -219,12 +219,13 @@ void SkDevice::drawDevice(const SkDraw& draw, SkDevice* device, /////////////////////////////////////////////////////////////////////////////// bool SkDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { - if (!paint.isLCDRenderText()) { + if (!paint.isLCDRenderText() || !paint.isAntiAlias()) { // we're cool with the paint as is return false; } if (SkBitmap::kARGB_8888_Config != fBitmap.config() || + !fBitmap.isOpaque() || paint.getShader() || paint.getXfermode() || // unless its srcover paint.getMaskFilter() || @@ -235,6 +236,10 @@ bool SkDevice::filterTextFlags(const SkPaint& paint, TextFlags* flags) { paint.getStyle() != SkPaint::kFill_Style) { // turn off lcd flags->fFlags = paint.getFlags() & ~SkPaint::kLCDRenderText_Flag; +#ifdef SK_BUILD_FOR_WIN + // flag that we *really* want AA + flags->fFlags |= SkPaint::kForceAAText_Flag; +#endif flags->fHinting = paint.getHinting(); return true; } diff --git a/src/core/SkPaint.cpp b/src/core/SkPaint.cpp index 9197adde0f..b2f5d8e0e1 100644 --- a/src/core/SkPaint.cpp +++ b/src/core/SkPaint.cpp @@ -1340,6 +1340,11 @@ void SkScalerContext::MakeRec(const SkPaint& paint, if (paint.isAutohinted()) { flags |= SkScalerContext::kAutohinting_Flag; } +#ifdef SK_BUILD_FOR_WIN + if (paint.getFlags() & SkPaint::kForceAAText_Flag) { + flags |= SkScalerContext::kForceAA_Flag; + } +#endif rec->fFlags = SkToU16(flags); // setHinting modifies fFlags, so do this last |