diff options
author | Herb Derby <herb@google.com> | 2018-07-23 16:20:53 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-07-26 18:16:46 +0000 |
commit | 1347144e3ef790c9431d18a8005dcf8914899b1d (patch) | |
tree | 212383343d996fcc2a9249760f93bff317ec4490 /src/core/SkBitmapDevice.cpp | |
parent | 97e858f359d165b35a304a840d43c2b6412fc241 (diff) |
Centralize bitmap glyph positioning
Centralize all text drawing for bitmap devices into SkGlyphRunListDrawer.
All drawing decisions are encapsulated in this class, and its behavior
only depends on contant properties of the device.
The method drawForBitmap will probably have to be converted to a template
based in preliminary performance numbers.
Change-Id: Id21567c1511eee9d2e9e20c7ae93544530cfdb81
Reviewed-on: https://skia-review.googlesource.com/143106
Reviewed-by: Mike Klein <mtklein@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Commit-Queue: Herb Derby <herb@google.com>
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 } |