aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkGlyphRun.cpp
diff options
context:
space:
mode:
authorGravatar Herb Derby <herb@google.com>2018-07-28 18:07:54 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-07-31 13:52:20 +0000
commit74c6ed3d1f179209ec90025532310d9c8151999f (patch)
tree2d20cc433c2136b8a1832698e9c14118615696dc /src/core/SkGlyphRun.cpp
parent0bf5408286ea3dacb197c220e1033dea3eeef2a8 (diff)
Move one leaf loop from GPU to glyph drawer
Encapsulate the bitmap inner loop of regenerate in the SkGlyphRunListDrawer. This changed required placing an SkGlyphRunListDrawer in the two TextTargets. Change-Id: I7ef7a2d0074fe898fce4da82d26ea1f47e1f7a98 Reviewed-on: https://skia-review.googlesource.com/144302 Reviewed-by: Jim Van Verth <jvanverth@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkGlyphRun.cpp')
-rw-r--r--src/core/SkGlyphRun.cpp57
1 files changed, 45 insertions, 12 deletions
diff --git a/src/core/SkGlyphRun.cpp b/src/core/SkGlyphRun.cpp
index f53f90986e..1a24c3bdb9 100644
--- a/src/core/SkGlyphRun.cpp
+++ b/src/core/SkGlyphRun.cpp
@@ -11,6 +11,11 @@
#include <new>
#include <tuple>
+#if SK_SUPPORT_GPU
+#include "GrColorSpaceInfo.h"
+#include "GrRenderTargetContext.h"
+#endif
+
#include "SkDevice.h"
#include "SkDraw.h"
#include "SkFindAndPlaceGlyph.h"
@@ -109,6 +114,29 @@ SkGlyphRunListDrawer::SkGlyphRunListDrawer(
, fColorType{colorType}
, fScalerContextFlags{flags} {}
+#if SK_SUPPORT_GPU
+
+// TODO: unify with code in GrTextContext.cpp
+static SkScalerContextFlags compute_scaler_context_flags(
+ const GrColorSpaceInfo& colorSpaceInfo) {
+ // 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 dest transfer function?
+ if (colorSpaceInfo.isLinearlyBlended()) {
+ return SkScalerContextFlags::kBoostContrast;
+ } else {
+ return SkScalerContextFlags::kFakeGammaAndBoostContrast;
+ }
+}
+
+SkGlyphRunListDrawer::SkGlyphRunListDrawer(
+ const SkSurfaceProps& props, const GrColorSpaceInfo& csi)
+ : SkGlyphRunListDrawer(props, kUnknown_SkColorType, compute_scaler_context_flags(csi)) {}
+
+SkGlyphRunListDrawer::SkGlyphRunListDrawer(const GrRenderTargetContext& rtc)
+ : SkGlyphRunListDrawer{rtc.surfaceProps(), rtc.colorSpaceInfo()} {}
+#endif
+
bool SkGlyphRunListDrawer::ShouldDrawAsPath(const SkPaint& paint, const SkMatrix& matrix) {
// hairline glyphs are fast enough so we don't need to cache them
if (SkPaint::kStroke_Style == paint.getStyle() && 0 == paint.getStrokeWidth()) {
@@ -134,7 +162,7 @@ bool SkGlyphRunListDrawer::ensureBitmapBuffers(size_t runSize) {
return true;
}
-void SkGlyphRunListDrawer::drawGlyphRunAsPaths(
+void SkGlyphRunListDrawer::drawUsingPaths(
const SkGlyphRun& glyphRun, SkPoint origin,
const SkSurfaceProps& props, PerPath perPath) const {
// setup our std paint, in hopes of getting hits in the cache
@@ -243,7 +271,7 @@ void SkGlyphRunListDrawer::drawGlyphRunAsSubpixelMask(
const SkGlyph& glyph = cache->getGlyphIDMetrics(glyphID, lookupX, lookupY);
SkMask mask;
if (prepare_mask(cache, glyph, position, &mask)) {
- perMask(mask);
+ perMask(mask, glyph, position);
}
}
}
@@ -270,14 +298,14 @@ void SkGlyphRunListDrawer::drawGlyphRunAsFullpixelMask(
const SkGlyph& glyph = cache->getGlyphIDMetrics(glyphID);
SkMask mask;
if (prepare_mask(cache, glyph, position, &mask)) {
- perMask(mask);
+ perMask(mask, glyph, position);
}
}
}
}
}
-void SkGlyphRunListDrawer::drawForBitmap(
+void SkGlyphRunListDrawer::drawForBitmapDevice(
const SkGlyphRunList& glyphRunList, const SkMatrix& deviceMatrix,
PerMaskCreator perMaskCreator, PerPathCreator perPathCreator) {
@@ -292,22 +320,27 @@ void SkGlyphRunListDrawer::drawForBitmap(
auto paint = glyphRun.paint();
if (ShouldDrawAsPath(glyphRun.paint(), deviceMatrix)) {
auto perPath = perPathCreator(paint, &alloc);
- this->drawGlyphRunAsPaths(glyphRun, origin, props, perPath);
+ this->drawUsingPaths(glyphRun, origin, props, perPath);
} else {
auto cache = SkStrikeCache::FindOrCreateStrikeExclusive(
paint, &props, fScalerContextFlags, &deviceMatrix);
auto perMask = perMaskCreator(paint, &alloc);
- if (cache->isSubpixel()) {
- this->drawGlyphRunAsSubpixelMask(
- cache.get(), glyphRun, origin, deviceMatrix, perMask);
- } else {
- this->drawGlyphRunAsFullpixelMask(
- cache.get(), glyphRun, origin, deviceMatrix, perMask);
- }
+ this->drawUsingMasks(cache.get(), glyphRun, origin, deviceMatrix, perMask);
}
}
}
+void SkGlyphRunListDrawer::drawUsingMasks(
+ SkGlyphCache* cache, const SkGlyphRun& glyphRun,
+ SkPoint origin, const SkMatrix& deviceMatrix,
+ SkGlyphRunListDrawer::PerMask perMask) {
+ if (cache->isSubpixel()) {
+ this->drawGlyphRunAsSubpixelMask(cache, glyphRun, origin, deviceMatrix, perMask);
+ } else {
+ this->drawGlyphRunAsFullpixelMask(cache, glyphRun, origin, deviceMatrix, perMask);
+ }
+}
+
// -- SkGlyphRunList -------------------------------------------------------------------------------
SkGlyphRunList::SkGlyphRunList() = default;
SkGlyphRunList::SkGlyphRunList(