diff options
Diffstat (limited to 'src/core/SkBitmapDevice.cpp')
-rw-r--r-- | src/core/SkBitmapDevice.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/core/SkBitmapDevice.cpp b/src/core/SkBitmapDevice.cpp index 94a4ddcd0d..c789496557 100644 --- a/src/core/SkBitmapDevice.cpp +++ b/src/core/SkBitmapDevice.cpp @@ -229,10 +229,23 @@ static bool valid_for_bitmap_device(const SkImageInfo& info, return true; } +// TODO: unify this with the same functionality on SkDraw. +static SkScalerContextFlags scaler_context_flags(const SkBitmap& bitmap) { + // If we're doing linear blending, then we can disable the gamma hacks. + // Otherwise, leave them on. In either case, we still want the contrast boost: + // TODO: Can we be even smarter about mask gamma based on the dst transfer function? + if (bitmap.colorSpace() && bitmap.colorSpace()->gammaIsLinear()) { + return SkScalerContextFlags::kBoostContrast; + } else { + return SkScalerContextFlags::kFakeGammaAndBoostContrast; + } +} + SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap) : INHERITED(bitmap.info(), SkSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType)) , fBitmap(bitmap) , fRCStack(bitmap.width(), bitmap.height()) + , fGlyphDraw(this->surfaceProps(), bitmap.colorType(), scaler_context_flags(bitmap)) { SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); } @@ -247,6 +260,7 @@ SkBitmapDevice::SkBitmapDevice(const SkBitmap& bitmap, const SkSurfaceProps& sur , fBitmap(bitmap) , fRasterHandle(hndl) , fRCStack(bitmap.width(), bitmap.height()) + , fGlyphDraw(this->surfaceProps(), bitmap.colorType(), scaler_context_flags(bitmap)) { SkASSERT(valid_for_bitmap_device(bitmap.info(), nullptr)); @@ -583,8 +597,7 @@ void SkBitmapDevice::drawGlyphRunList(SkGlyphRunList* glyphRunList) { this->drawTextBlob(blob, origin.x(), origin.y(), paint); } #else - SkBitmapDeviceFilteredSurfaceProps props(fBitmap, glyphRunList->paint(), fSurfaceProps); - LOOP_TILER( drawGlyphRunList(glyphRunList, &props()), nullptr ) + LOOP_TILER( drawGlyphRunList(glyphRunList, &fGlyphDraw), nullptr ) #endif } |