joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | #include "GrAtlasTextContext.h" |
robertphillips | 73c4e64 | 2016-03-02 11:36:59 -0800 | [diff] [blame] | 8 | #include "GrContext.h" |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 9 | #include "GrContextPriv.h" |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 10 | #include "GrTextBlobCache.h" |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 11 | #include "SkDistanceFieldGen.h" |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 12 | #include "SkDraw.h" |
| 13 | #include "SkDrawFilter.h" |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 14 | #include "SkDrawProcs.h" |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 15 | #include "SkFindAndPlaceGlyph.h" |
Brian Osman | 3b65598 | 2017-03-07 16:58:08 -0500 | [diff] [blame] | 16 | #include "SkGr.h" |
Jim Van Verth | c65b65d | 2018-01-16 16:26:35 -0500 | [diff] [blame] | 17 | #include "SkGraphics.h" |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 18 | #include "SkMakeUnique.h" |
Mike Reed | 80747ef | 2018-01-23 15:29:32 -0500 | [diff] [blame] | 19 | #include "SkMaskFilterBase.h" |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 20 | #include "SkTextMapStateProc.h" |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 21 | |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 22 | #include "ops/GrMeshDrawOp.h" |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 23 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 24 | // DF sizes and thresholds for usage of the small and medium sizes. For example, above |
| 25 | // kSmallDFFontLimit we will use the medium size. The large size is used up until the size at |
| 26 | // which we switch over to drawing as paths as controlled by Options. |
| 27 | static const int kSmallDFFontSize = 32; |
| 28 | static const int kSmallDFFontLimit = 32; |
Jim Van Verth | 825d4d7 | 2018-01-30 20:37:03 +0000 | [diff] [blame] | 29 | static const int kMediumDFFontSize = 72; |
| 30 | static const int kMediumDFFontLimit = 72; |
| 31 | static const int kLargeDFFontSize = 162; |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 32 | |
| 33 | static const int kDefaultMinDistanceFieldFontSize = 18; |
| 34 | #ifdef SK_BUILD_FOR_ANDROID |
| 35 | static const int kDefaultMaxDistanceFieldFontSize = 384; |
| 36 | #else |
| 37 | static const int kDefaultMaxDistanceFieldFontSize = 2 * kLargeDFFontSize; |
| 38 | #endif |
| 39 | |
| 40 | GrAtlasTextContext::GrAtlasTextContext(const Options& options) |
| 41 | : fDistanceAdjustTable(new GrDistanceFieldAdjustTable) { |
| 42 | fMaxDistanceFieldFontSize = options.fMaxDistanceFieldFontSize < 0.f |
| 43 | ? kDefaultMaxDistanceFieldFontSize |
| 44 | : options.fMaxDistanceFieldFontSize; |
| 45 | fMinDistanceFieldFontSize = options.fMinDistanceFieldFontSize < 0.f |
| 46 | ? kDefaultMinDistanceFieldFontSize |
| 47 | : options.fMinDistanceFieldFontSize; |
Brian Salomon | b508696 | 2017-12-13 10:59:33 -0500 | [diff] [blame] | 48 | fDistanceFieldVerticesAlwaysHaveW = options.fDistanceFieldVerticesAlwaysHaveW; |
joshualitt | 9bd2daf | 2015-04-17 09:30:06 -0700 | [diff] [blame] | 49 | } |
| 50 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 51 | std::unique_ptr<GrAtlasTextContext> GrAtlasTextContext::Make(const Options& options) { |
| 52 | return std::unique_ptr<GrAtlasTextContext>(new GrAtlasTextContext(options)); |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 53 | } |
| 54 | |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 55 | SkColor GrAtlasTextContext::ComputeCanonicalColor(const SkPaint& paint, bool lcd) { |
| 56 | SkColor canonicalColor = paint.computeLuminanceColor(); |
joshualitt | 9e36c1a | 2015-04-14 12:17:27 -0700 | [diff] [blame] | 57 | if (lcd) { |
| 58 | // This is the correct computation, but there are tons of cases where LCD can be overridden. |
| 59 | // For now we just regenerate if any run in a textblob has LCD. |
| 60 | // TODO figure out where all of these overrides are and see if we can incorporate that logic |
| 61 | // at a higher level *OR* use sRGB |
| 62 | SkASSERT(false); |
| 63 | //canonicalColor = SkMaskGamma::CanonicalColor(canonicalColor); |
| 64 | } else { |
| 65 | // A8, though can have mixed BMP text but it shouldn't matter because BMP text won't have |
| 66 | // gamma corrected masks anyways, nor color |
| 67 | U8CPU lum = SkComputeLuminance(SkColorGetR(canonicalColor), |
| 68 | SkColorGetG(canonicalColor), |
| 69 | SkColorGetB(canonicalColor)); |
| 70 | // reduce to our finite number of bits |
| 71 | canonicalColor = SkMaskGamma::CanonicalColor(SkColorSetRGB(lum, lum, lum)); |
| 72 | } |
| 73 | return canonicalColor; |
| 74 | } |
| 75 | |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 76 | SkScalerContextFlags GrAtlasTextContext::ComputeScalerContextFlags( |
| 77 | const GrColorSpaceInfo& colorSpaceInfo) { |
brianosman | 5280dcb | 2016-04-14 06:02:59 -0700 | [diff] [blame] | 78 | // If we're doing gamma-correct rendering, then we can disable the gamma hacks. |
| 79 | // Otherwise, leave them on. In either case, we still want the contrast boost: |
Brian Salomon | f3569f0 | 2017-10-24 12:52:33 -0400 | [diff] [blame] | 80 | if (colorSpaceInfo.isGammaCorrect()) { |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 81 | return SkScalerContextFlags::kBoostContrast; |
brianosman | 32f7782 | 2016-04-07 06:25:45 -0700 | [diff] [blame] | 82 | } else { |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 83 | return SkScalerContextFlags::kFakeGammaAndBoostContrast; |
brianosman | 32f7782 | 2016-04-07 06:25:45 -0700 | [diff] [blame] | 84 | } |
| 85 | } |
| 86 | |
joshualitt | 9e36c1a | 2015-04-14 12:17:27 -0700 | [diff] [blame] | 87 | // TODO if this function ever shows up in profiling, then we can compute this value when the |
| 88 | // textblob is being built and cache it. However, for the time being textblobs mostly only have 1 |
| 89 | // run so this is not a big deal to compute here. |
| 90 | bool GrAtlasTextContext::HasLCD(const SkTextBlob* blob) { |
halcanary | 3377975 | 2015-10-27 14:01:05 -0700 | [diff] [blame] | 91 | SkTextBlobRunIterator it(blob); |
joshualitt | 9e36c1a | 2015-04-14 12:17:27 -0700 | [diff] [blame] | 92 | for (; !it.done(); it.next()) { |
| 93 | if (it.isLCD()) { |
| 94 | return true; |
| 95 | } |
| 96 | } |
| 97 | return false; |
| 98 | } |
| 99 | |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 100 | void GrAtlasTextContext::drawTextBlob(GrContext* context, GrTextUtils::Target* target, |
robertphillips | ccb1b57 | 2015-05-27 11:02:55 -0700 | [diff] [blame] | 101 | const GrClip& clip, const SkPaint& skPaint, |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 102 | const SkMatrix& viewMatrix, const SkSurfaceProps& props, |
| 103 | const SkTextBlob* blob, SkScalar x, SkScalar y, |
joshualitt | dbd3593 | 2015-04-02 09:19:04 -0700 | [diff] [blame] | 104 | SkDrawFilter* drawFilter, const SkIRect& clipBounds) { |
joshualitt | 9b8e79e | 2015-04-24 09:57:12 -0700 | [diff] [blame] | 105 | // If we have been abandoned, then don't draw |
joshualitt | 27004b7 | 2016-02-11 12:00:33 -0800 | [diff] [blame] | 106 | if (context->abandoned()) { |
robertphillips | ea46150 | 2015-05-26 11:38:03 -0700 | [diff] [blame] | 107 | return; |
| 108 | } |
| 109 | |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 110 | sk_sp<GrAtlasTextBlob> cacheBlob; |
Mike Reed | 80747ef | 2018-01-23 15:29:32 -0500 | [diff] [blame] | 111 | SkMaskFilterBase::BlurRec blurRec; |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 112 | GrAtlasTextBlob::Key key; |
joshualitt | 53b5f44 | 2015-04-13 06:33:59 -0700 | [diff] [blame] | 113 | // It might be worth caching these things, but its not clear at this time |
| 114 | // TODO for animated mask filters, this will fill up our cache. We need a safeguard here |
| 115 | const SkMaskFilter* mf = skPaint.getMaskFilter(); |
joshualitt | 2a0e9f3 | 2015-04-13 06:12:21 -0700 | [diff] [blame] | 116 | bool canCache = !(skPaint.getPathEffect() || |
Mike Reed | 80747ef | 2018-01-23 15:29:32 -0500 | [diff] [blame] | 117 | (mf && !as_MFB(mf)->asABlur(&blurRec)) || |
joshualitt | 2a0e9f3 | 2015-04-13 06:12:21 -0700 | [diff] [blame] | 118 | drawFilter); |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 119 | SkScalerContextFlags scalerContextFlags = ComputeScalerContextFlags(target->colorSpaceInfo()); |
joshualitt | 2a0e9f3 | 2015-04-13 06:12:21 -0700 | [diff] [blame] | 120 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 121 | auto glyphCache = context->contextPriv().getGlyphCache(); |
| 122 | auto restrictedAtlasManager = context->contextPriv().getRestrictedAtlasManager(); |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 123 | GrTextBlobCache* textBlobCache = context->contextPriv().getTextBlobCache(); |
| 124 | |
joshualitt | 2a0e9f3 | 2015-04-13 06:12:21 -0700 | [diff] [blame] | 125 | if (canCache) { |
joshualitt | 9e36c1a | 2015-04-14 12:17:27 -0700 | [diff] [blame] | 126 | bool hasLCD = HasLCD(blob); |
joshualitt | e4cee1f | 2015-05-11 13:04:28 -0700 | [diff] [blame] | 127 | |
| 128 | // We canonicalize all non-lcd draws to use kUnknown_SkPixelGeometry |
joshualitt | 2c89bc1 | 2016-02-11 05:42:30 -0800 | [diff] [blame] | 129 | SkPixelGeometry pixelGeometry = hasLCD ? props.pixelGeometry() : |
joshualitt | e4cee1f | 2015-05-11 13:04:28 -0700 | [diff] [blame] | 130 | kUnknown_SkPixelGeometry; |
| 131 | |
joshualitt | 9e36c1a | 2015-04-14 12:17:27 -0700 | [diff] [blame] | 132 | // TODO we want to figure out a way to be able to use the canonical color on LCD text, |
| 133 | // see the note on ComputeCanonicalColor above. We pick a dummy value for LCD text to |
| 134 | // ensure we always match the same key |
| 135 | GrColor canonicalColor = hasLCD ? SK_ColorTRANSPARENT : |
| 136 | ComputeCanonicalColor(skPaint, hasLCD); |
| 137 | |
joshualitt | e4cee1f | 2015-05-11 13:04:28 -0700 | [diff] [blame] | 138 | key.fPixelGeometry = pixelGeometry; |
joshualitt | 53b5f44 | 2015-04-13 06:33:59 -0700 | [diff] [blame] | 139 | key.fUniqueID = blob->uniqueID(); |
| 140 | key.fStyle = skPaint.getStyle(); |
| 141 | key.fHasBlur = SkToBool(mf); |
joshualitt | 9e36c1a | 2015-04-14 12:17:27 -0700 | [diff] [blame] | 142 | key.fCanonicalColor = canonicalColor; |
brianosman | 8d7ffce | 2016-04-21 08:29:06 -0700 | [diff] [blame] | 143 | key.fScalerContextFlags = scalerContextFlags; |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 144 | cacheBlob = textBlobCache->find(key); |
joshualitt | 2a0e9f3 | 2015-04-13 06:12:21 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 147 | GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo()); |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 148 | if (cacheBlob) { |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 149 | if (cacheBlob->mustRegenerate(paint, blurRec, viewMatrix, x, y)) { |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 150 | // We have to remake the blob because changes may invalidate our masks. |
| 151 | // TODO we could probably get away reuse most of the time if the pointer is unique, |
| 152 | // but we'd have to clear the subrun information |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 153 | textBlobCache->remove(cacheBlob.get()); |
| 154 | cacheBlob = textBlobCache->makeCachedBlob(blob, key, blurRec, skPaint); |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 155 | this->regenerateTextBlob(cacheBlob.get(), glyphCache, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 156 | *context->caps()->shaderCaps(), paint, scalerContextFlags, |
| 157 | viewMatrix, props, blob, x, y, drawFilter); |
joshualitt | b7133be | 2015-04-08 09:08:31 -0700 | [diff] [blame] | 158 | } else { |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 159 | textBlobCache->makeMRU(cacheBlob.get()); |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 160 | |
| 161 | if (CACHE_SANITY_CHECK) { |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 162 | int glyphCount = 0; |
| 163 | int runCount = 0; |
| 164 | GrTextBlobCache::BlobGlyphCount(&glyphCount, &runCount, blob); |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 165 | sk_sp<GrAtlasTextBlob> sanityBlob(textBlobCache->makeBlob(glyphCount, runCount)); |
joshualitt | 9230377 | 2016-02-10 11:55:52 -0800 | [diff] [blame] | 166 | sanityBlob->setupKey(key, blurRec, skPaint); |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 167 | this->regenerateTextBlob(sanityBlob.get(), glyphCache, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 168 | *context->caps()->shaderCaps(), paint, scalerContextFlags, |
| 169 | viewMatrix, props, blob, x, y, drawFilter); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 170 | GrAtlasTextBlob::AssertEqual(*sanityBlob, *cacheBlob); |
| 171 | } |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 172 | } |
| 173 | } else { |
joshualitt | 2a0e9f3 | 2015-04-13 06:12:21 -0700 | [diff] [blame] | 174 | if (canCache) { |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 175 | cacheBlob = textBlobCache->makeCachedBlob(blob, key, blurRec, skPaint); |
joshualitt | 2a0e9f3 | 2015-04-13 06:12:21 -0700 | [diff] [blame] | 176 | } else { |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 177 | cacheBlob = textBlobCache->makeBlob(blob); |
joshualitt | 2a0e9f3 | 2015-04-13 06:12:21 -0700 | [diff] [blame] | 178 | } |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 179 | this->regenerateTextBlob(cacheBlob.get(), glyphCache, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 180 | *context->caps()->shaderCaps(), paint, scalerContextFlags, |
| 181 | viewMatrix, props, blob, x, y, drawFilter); |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 182 | } |
| 183 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 184 | cacheBlob->flush(restrictedAtlasManager, target, props, fDistanceAdjustTable.get(), paint, |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 185 | clip, viewMatrix, clipBounds, x, y); |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 188 | void GrAtlasTextContext::regenerateTextBlob(GrAtlasTextBlob* cacheBlob, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 189 | GrGlyphCache* glyphCache, |
joshualitt | 27004b7 | 2016-02-11 12:00:33 -0800 | [diff] [blame] | 190 | const GrShaderCaps& shaderCaps, |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 191 | const GrTextUtils::Paint& paint, |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 192 | SkScalerContextFlags scalerContextFlags, |
Jim Van Verth | 58c3cce | 2017-10-19 15:50:24 -0400 | [diff] [blame] | 193 | const SkMatrix& viewMatrix, |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 194 | const SkSurfaceProps& props, const SkTextBlob* blob, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 195 | SkScalar x, SkScalar y, |
| 196 | SkDrawFilter* drawFilter) const { |
Jim Van Verth | bc2cdd1 | 2017-06-08 11:14:35 -0400 | [diff] [blame] | 197 | cacheBlob->initReusableBlob(paint.luminanceColor(), viewMatrix, x, y); |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 198 | |
| 199 | // Regenerate textblob |
halcanary | 3377975 | 2015-10-27 14:01:05 -0700 | [diff] [blame] | 200 | SkTextBlobRunIterator it(blob); |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 201 | GrTextUtils::RunPaint runPaint(&paint, drawFilter, props); |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 202 | for (int run = 0; !it.done(); it.next(), run++) { |
| 203 | int glyphCount = it.glyphCount(); |
| 204 | size_t textLen = glyphCount * sizeof(uint16_t); |
| 205 | const SkPoint& offset = it.offset(); |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 206 | cacheBlob->push_back_run(run); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 207 | if (!runPaint.modifyForRun([it](SkPaint* p) { it.applyFontToPaint(p); })) { |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 208 | continue; |
| 209 | } |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 210 | cacheBlob->setRunPaintFlags(run, runPaint.skPaint().getFlags()); |
| 211 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 212 | if (this->canDrawAsDistanceFields(runPaint, viewMatrix, props, shaderCaps)) { |
joshualitt | fcfb9fc | 2015-04-21 07:35:10 -0700 | [diff] [blame] | 213 | switch (it.positioning()) { |
| 214 | case SkTextBlob::kDefault_Positioning: { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 215 | this->drawDFText(cacheBlob, run, glyphCache, props, runPaint, scalerContextFlags, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 216 | viewMatrix, (const char*)it.glyphs(), textLen, x + offset.x(), |
| 217 | y + offset.y()); |
joshualitt | fcfb9fc | 2015-04-21 07:35:10 -0700 | [diff] [blame] | 218 | break; |
| 219 | } |
| 220 | case SkTextBlob::kHorizontal_Positioning: { |
joshualitt | 5425a9a | 2015-12-11 11:05:43 -0800 | [diff] [blame] | 221 | SkPoint dfOffset = SkPoint::Make(x, y + offset.y()); |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 222 | this->drawDFPosText(cacheBlob, run, glyphCache, props, runPaint, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 223 | scalerContextFlags, viewMatrix, (const char*)it.glyphs(), |
| 224 | textLen, it.pos(), 1, dfOffset); |
joshualitt | fcfb9fc | 2015-04-21 07:35:10 -0700 | [diff] [blame] | 225 | break; |
| 226 | } |
| 227 | case SkTextBlob::kFull_Positioning: { |
joshualitt | 5425a9a | 2015-12-11 11:05:43 -0800 | [diff] [blame] | 228 | SkPoint dfOffset = SkPoint::Make(x, y); |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 229 | this->drawDFPosText(cacheBlob, run, glyphCache, props, runPaint, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 230 | scalerContextFlags, viewMatrix, (const char*)it.glyphs(), |
| 231 | textLen, it.pos(), 2, dfOffset); |
joshualitt | fcfb9fc | 2015-04-21 07:35:10 -0700 | [diff] [blame] | 232 | break; |
| 233 | } |
| 234 | } |
joshualitt | fcfb9fc | 2015-04-21 07:35:10 -0700 | [diff] [blame] | 235 | } else { |
joshualitt | fcfb9fc | 2015-04-21 07:35:10 -0700 | [diff] [blame] | 236 | switch (it.positioning()) { |
| 237 | case SkTextBlob::kDefault_Positioning: |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 238 | DrawBmpText(cacheBlob, run, glyphCache, props, runPaint, scalerContextFlags, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 239 | viewMatrix, (const char*)it.glyphs(), textLen, x + offset.x(), |
| 240 | y + offset.y()); |
joshualitt | fcfb9fc | 2015-04-21 07:35:10 -0700 | [diff] [blame] | 241 | break; |
| 242 | case SkTextBlob::kHorizontal_Positioning: |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 243 | DrawBmpPosText(cacheBlob, run, glyphCache, props, runPaint, scalerContextFlags, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 244 | viewMatrix, (const char*)it.glyphs(), textLen, it.pos(), 1, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 245 | SkPoint::Make(x, y + offset.y())); |
joshualitt | fcfb9fc | 2015-04-21 07:35:10 -0700 | [diff] [blame] | 246 | break; |
| 247 | case SkTextBlob::kFull_Positioning: |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 248 | DrawBmpPosText(cacheBlob, run, glyphCache, props, runPaint, scalerContextFlags, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 249 | viewMatrix, (const char*)it.glyphs(), textLen, it.pos(), 2, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 250 | SkPoint::Make(x, y)); |
joshualitt | fcfb9fc | 2015-04-21 07:35:10 -0700 | [diff] [blame] | 251 | break; |
| 252 | } |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 253 | } |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 254 | } |
| 255 | } |
| 256 | |
Florin Malita | c337c9e | 2017-03-10 18:02:29 +0000 | [diff] [blame] | 257 | inline sk_sp<GrAtlasTextBlob> |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 258 | GrAtlasTextContext::makeDrawTextBlob(GrTextBlobCache* blobCache, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 259 | GrGlyphCache* glyphCache, |
Florin Malita | c337c9e | 2017-03-10 18:02:29 +0000 | [diff] [blame] | 260 | const GrShaderCaps& shaderCaps, |
| 261 | const GrTextUtils::Paint& paint, |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 262 | SkScalerContextFlags scalerContextFlags, |
Florin Malita | c337c9e | 2017-03-10 18:02:29 +0000 | [diff] [blame] | 263 | const SkMatrix& viewMatrix, |
| 264 | const SkSurfaceProps& props, |
| 265 | const char text[], size_t byteLength, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 266 | SkScalar x, SkScalar y) const { |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 267 | int glyphCount = paint.skPaint().countText(text, byteLength); |
Brian Salomon | b3f6ac4 | 2017-07-31 08:00:25 -0400 | [diff] [blame] | 268 | if (!glyphCount) { |
| 269 | return nullptr; |
| 270 | } |
Florin Malita | c337c9e | 2017-03-10 18:02:29 +0000 | [diff] [blame] | 271 | sk_sp<GrAtlasTextBlob> blob = blobCache->makeBlob(glyphCount, 1); |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 272 | blob->initThrowawayBlob(viewMatrix, x, y); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 273 | blob->setRunPaintFlags(0, paint.skPaint().getFlags()); |
joshualitt | a6bf4c5 | 2016-01-19 06:59:29 -0800 | [diff] [blame] | 274 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 275 | if (this->canDrawAsDistanceFields(paint, viewMatrix, props, shaderCaps)) { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 276 | this->drawDFText(blob.get(), 0, glyphCache, props, paint, scalerContextFlags, viewMatrix, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 277 | text, byteLength, x, y); |
joshualitt | 9bd2daf | 2015-04-17 09:30:06 -0700 | [diff] [blame] | 278 | } else { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 279 | DrawBmpText(blob.get(), 0, glyphCache, props, paint, scalerContextFlags, viewMatrix, text, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 280 | byteLength, x, y); |
joshualitt | 9bd2daf | 2015-04-17 09:30:06 -0700 | [diff] [blame] | 281 | } |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 282 | return blob; |
joshualitt | 1d89e8d | 2015-04-01 12:40:54 -0700 | [diff] [blame] | 283 | } |
| 284 | |
Florin Malita | c337c9e | 2017-03-10 18:02:29 +0000 | [diff] [blame] | 285 | inline sk_sp<GrAtlasTextBlob> |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 286 | GrAtlasTextContext::makeDrawPosTextBlob(GrTextBlobCache* blobCache, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 287 | GrGlyphCache* glyphCache, |
Florin Malita | c337c9e | 2017-03-10 18:02:29 +0000 | [diff] [blame] | 288 | const GrShaderCaps& shaderCaps, |
| 289 | const GrTextUtils::Paint& paint, |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 290 | SkScalerContextFlags scalerContextFlags, |
Florin Malita | c337c9e | 2017-03-10 18:02:29 +0000 | [diff] [blame] | 291 | const SkMatrix& viewMatrix, |
| 292 | const SkSurfaceProps& props, |
| 293 | const char text[], size_t byteLength, |
| 294 | const SkScalar pos[], int scalarsPerPosition, const |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 295 | SkPoint& offset) const { |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 296 | int glyphCount = paint.skPaint().countText(text, byteLength); |
Brian Salomon | b3f6ac4 | 2017-07-31 08:00:25 -0400 | [diff] [blame] | 297 | if (!glyphCount) { |
| 298 | return nullptr; |
| 299 | } |
joshualitt | 9bd2daf | 2015-04-17 09:30:06 -0700 | [diff] [blame] | 300 | |
Florin Malita | c337c9e | 2017-03-10 18:02:29 +0000 | [diff] [blame] | 301 | sk_sp<GrAtlasTextBlob> blob = blobCache->makeBlob(glyphCount, 1); |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 302 | blob->initThrowawayBlob(viewMatrix, offset.x(), offset.y()); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 303 | blob->setRunPaintFlags(0, paint.skPaint().getFlags()); |
joshualitt | 9bd2daf | 2015-04-17 09:30:06 -0700 | [diff] [blame] | 304 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 305 | if (this->canDrawAsDistanceFields(paint, viewMatrix, props, shaderCaps)) { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 306 | this->drawDFPosText(blob.get(), 0, glyphCache, props, paint, scalerContextFlags, viewMatrix, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 307 | text, byteLength, pos, scalarsPerPosition, offset); |
joshualitt | 9bd2daf | 2015-04-17 09:30:06 -0700 | [diff] [blame] | 308 | } else { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 309 | DrawBmpPosText(blob.get(), 0, glyphCache, props, paint, scalerContextFlags, viewMatrix, |
| 310 | text, byteLength, pos, scalarsPerPosition, offset); |
joshualitt | 9bd2daf | 2015-04-17 09:30:06 -0700 | [diff] [blame] | 311 | } |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 312 | return blob; |
| 313 | } |
| 314 | |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 315 | void GrAtlasTextContext::drawText(GrContext* context, GrTextUtils::Target* target, |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 316 | const GrClip& clip, const SkPaint& skPaint, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 317 | const SkMatrix& viewMatrix, const SkSurfaceProps& props, |
| 318 | const char text[], size_t byteLength, SkScalar x, SkScalar y, |
| 319 | const SkIRect& regionClipBounds) { |
joshualitt | 27004b7 | 2016-02-11 12:00:33 -0800 | [diff] [blame] | 320 | if (context->abandoned()) { |
joshualitt | e55750e | 2016-02-10 12:52:21 -0800 | [diff] [blame] | 321 | return; |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 322 | } |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 323 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 324 | auto glyphCache = context->contextPriv().getGlyphCache(); |
| 325 | auto restrictedAtlasManager = context->contextPriv().getRestrictedAtlasManager(); |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 326 | auto textBlobCache = context->contextPriv().getTextBlobCache(); |
| 327 | |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 328 | GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo()); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 329 | sk_sp<GrAtlasTextBlob> blob( |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 330 | this->makeDrawTextBlob(textBlobCache, glyphCache, |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 331 | *context->caps()->shaderCaps(), paint, |
| 332 | ComputeScalerContextFlags(target->colorSpaceInfo()), |
| 333 | viewMatrix, props, text, byteLength, x, y)); |
| 334 | if (blob) { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 335 | blob->flush(restrictedAtlasManager, target, props, fDistanceAdjustTable.get(), paint, |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 336 | clip, viewMatrix, regionClipBounds, x, y); |
joshualitt | e55750e | 2016-02-10 12:52:21 -0800 | [diff] [blame] | 337 | } |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 338 | } |
| 339 | |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 340 | void GrAtlasTextContext::drawPosText(GrContext* context, GrTextUtils::Target* target, |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 341 | const GrClip& clip, const SkPaint& skPaint, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 342 | const SkMatrix& viewMatrix, const SkSurfaceProps& props, |
| 343 | const char text[], size_t byteLength, const SkScalar pos[], |
| 344 | int scalarsPerPosition, const SkPoint& offset, |
| 345 | const SkIRect& regionClipBounds) { |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 346 | GrTextUtils::Paint paint(&skPaint, &target->colorSpaceInfo()); |
joshualitt | 27004b7 | 2016-02-11 12:00:33 -0800 | [diff] [blame] | 347 | if (context->abandoned()) { |
joshualitt | e55750e | 2016-02-10 12:52:21 -0800 | [diff] [blame] | 348 | return; |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 349 | } |
| 350 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 351 | auto glyphCache = context->contextPriv().getGlyphCache(); |
| 352 | auto restrictedAtlasManager = context->contextPriv().getRestrictedAtlasManager(); |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 353 | auto textBlobCache = context->contextPriv().getTextBlobCache(); |
| 354 | |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 355 | sk_sp<GrAtlasTextBlob> blob(this->makeDrawPosTextBlob( |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 356 | textBlobCache, glyphCache, |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 357 | *context->caps()->shaderCaps(), paint, |
| 358 | ComputeScalerContextFlags(target->colorSpaceInfo()), viewMatrix, props, text, |
| 359 | byteLength, pos, scalarsPerPosition, offset)); |
| 360 | if (blob) { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 361 | blob->flush(restrictedAtlasManager, target, props, fDistanceAdjustTable.get(), paint, |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 362 | clip, viewMatrix, regionClipBounds, offset.fX, offset.fY); |
joshualitt | e55750e | 2016-02-10 12:52:21 -0800 | [diff] [blame] | 363 | } |
joshualitt | 9bd2daf | 2015-04-17 09:30:06 -0700 | [diff] [blame] | 364 | } |
| 365 | |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 366 | void GrAtlasTextContext::DrawBmpText(GrAtlasTextBlob* blob, int runIndex, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 367 | GrGlyphCache* glyphCache, const SkSurfaceProps& props, |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 368 | const GrTextUtils::Paint& paint, |
| 369 | SkScalerContextFlags scalerContextFlags, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 370 | const SkMatrix& viewMatrix, const char text[], |
| 371 | size_t byteLength, SkScalar x, SkScalar y) { |
| 372 | SkASSERT(byteLength == 0 || text != nullptr); |
| 373 | |
| 374 | // nothing to draw |
| 375 | if (text == nullptr || byteLength == 0) { |
| 376 | return; |
| 377 | } |
| 378 | |
| 379 | // Ensure the blob is set for bitmaptext |
| 380 | blob->setHasBitmap(); |
| 381 | |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 382 | if (SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix)) { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 383 | DrawBmpTextAsPaths(blob, runIndex, glyphCache, props, paint, scalerContextFlags, viewMatrix, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 384 | text, byteLength, x, y); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 385 | return; |
| 386 | } |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 387 | GrAtlasTextStrike* currStrike = nullptr; |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 388 | SkGlyphCache* cache = blob->setupCache(runIndex, props, scalerContextFlags, paint, &viewMatrix); |
| 389 | SkFindAndPlaceGlyph::ProcessText(paint.skPaint().getTextEncoding(), text, byteLength, {x, y}, |
| 390 | viewMatrix, paint.skPaint().getTextAlign(), cache, |
| 391 | [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) { |
| 392 | position += rounding; |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 393 | BmpAppendGlyph(blob, runIndex, glyphCache, &currStrike, |
Jim Van Verth | c65b65d | 2018-01-16 16:26:35 -0500 | [diff] [blame] | 394 | glyph, SkScalarFloorToScalar(position.fX), |
| 395 | SkScalarFloorToScalar(position.fY), |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 396 | paint.filteredPremulColor(), cache, |
| 397 | SK_Scalar1); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 398 | }); |
| 399 | |
| 400 | SkGlyphCache::AttachCache(cache); |
| 401 | } |
| 402 | |
| 403 | void GrAtlasTextContext::DrawBmpPosText(GrAtlasTextBlob* blob, int runIndex, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 404 | GrGlyphCache* glyphCache, const SkSurfaceProps& props, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 405 | const GrTextUtils::Paint& paint, |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 406 | SkScalerContextFlags scalerContextFlags, |
| 407 | const SkMatrix& viewMatrix, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 408 | const char text[], size_t byteLength, const SkScalar pos[], |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 409 | int scalarsPerPosition, const SkPoint& offset) { |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 410 | SkASSERT(byteLength == 0 || text != nullptr); |
| 411 | SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); |
| 412 | |
| 413 | // nothing to draw |
| 414 | if (text == nullptr || byteLength == 0) { |
| 415 | return; |
| 416 | } |
| 417 | |
| 418 | // Ensure the blob is set for bitmaptext |
| 419 | blob->setHasBitmap(); |
| 420 | |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 421 | if (SkDraw::ShouldDrawTextAsPaths(paint, viewMatrix)) { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 422 | DrawBmpPosTextAsPaths(blob, runIndex, glyphCache, props, paint, scalerContextFlags, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 423 | viewMatrix, text, byteLength, pos, scalarsPerPosition, offset); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 424 | return; |
| 425 | } |
| 426 | |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 427 | GrAtlasTextStrike* currStrike = nullptr; |
| 428 | |
| 429 | SkGlyphCache* cache = blob->setupCache(runIndex, props, scalerContextFlags, paint, &viewMatrix); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 430 | SkFindAndPlaceGlyph::ProcessPosText( |
| 431 | paint.skPaint().getTextEncoding(), text, byteLength, offset, viewMatrix, pos, |
| 432 | scalarsPerPosition, paint.skPaint().getTextAlign(), cache, |
| 433 | [&](const SkGlyph& glyph, SkPoint position, SkPoint rounding) { |
| 434 | position += rounding; |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 435 | BmpAppendGlyph(blob, runIndex, glyphCache, &currStrike, glyph, |
Jim Van Verth | c65b65d | 2018-01-16 16:26:35 -0500 | [diff] [blame] | 436 | SkScalarFloorToScalar(position.fX), |
| 437 | SkScalarFloorToScalar(position.fY), |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 438 | paint.filteredPremulColor(), cache, SK_Scalar1); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 439 | }); |
| 440 | |
| 441 | SkGlyphCache::AttachCache(cache); |
| 442 | } |
| 443 | |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 444 | void GrAtlasTextContext::DrawBmpTextAsPaths(GrAtlasTextBlob* blob, int runIndex, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 445 | GrGlyphCache* glyphCache, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 446 | const SkSurfaceProps& props, |
| 447 | const GrTextUtils::Paint& origPaint, |
| 448 | SkScalerContextFlags scalerContextFlags, |
| 449 | const SkMatrix& viewMatrix, const char text[], |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 450 | size_t byteLength, SkScalar x, SkScalar y) { |
| 451 | // nothing to draw |
| 452 | if (text == nullptr || byteLength == 0) { |
| 453 | return; |
| 454 | } |
| 455 | |
| 456 | // Temporarily jam in kFill, so we only ever ask for the raw outline from the cache. |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 457 | SkPaint pathPaint(origPaint); |
| 458 | pathPaint.setStyle(SkPaint::kFill_Style); |
| 459 | pathPaint.setPathEffect(nullptr); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 460 | |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 461 | GrTextUtils::PathTextIter iter(text, byteLength, pathPaint, true); |
| 462 | FallbackTextHelper fallbackTextHelper(viewMatrix, pathPaint.getTextSize(), |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 463 | glyphCache->getGlyphSizeLimit(), |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 464 | iter.getPathScale()); |
| 465 | |
| 466 | const SkGlyph* iterGlyph; |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 467 | const SkPath* iterPath; |
| 468 | SkScalar xpos = 0; |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 469 | const char* lastText = text; |
| 470 | while (iter.next(&iterGlyph, &iterPath, &xpos)) { |
| 471 | if (iterGlyph) { |
| 472 | SkPoint pos = SkPoint::Make(xpos + x, y); |
| 473 | fallbackTextHelper.appendText(*iterGlyph, iter.getText() - lastText, lastText, pos); |
| 474 | } else if (iterPath) { |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 475 | blob->appendPathGlyph(runIndex, *iterPath, xpos + x, y, iter.getPathScale(), false); |
| 476 | } |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 477 | lastText = iter.getText(); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 478 | } |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 479 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 480 | fallbackTextHelper.drawText(blob, runIndex, glyphCache, props, origPaint, scalerContextFlags); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | void GrAtlasTextContext::DrawBmpPosTextAsPaths(GrAtlasTextBlob* blob, int runIndex, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 484 | GrGlyphCache* glyphCache, |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 485 | const SkSurfaceProps& props, |
| 486 | const GrTextUtils::Paint& origPaint, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 487 | SkScalerContextFlags scalerContextFlags, |
| 488 | const SkMatrix& viewMatrix, |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 489 | const char text[], size_t byteLength, |
| 490 | const SkScalar pos[], int scalarsPerPosition, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 491 | const SkPoint& offset) { |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 492 | SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); |
| 493 | |
| 494 | // nothing to draw |
| 495 | if (text == nullptr || byteLength == 0) { |
| 496 | return; |
| 497 | } |
| 498 | |
| 499 | // setup our std paint, in hopes of getting hits in the cache |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 500 | SkPaint pathPaint(origPaint); |
| 501 | SkScalar matrixScale = pathPaint.setupForAsPaths(); |
| 502 | FallbackTextHelper fallbackTextHelper(viewMatrix, pathPaint.getTextSize(), matrixScale, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 503 | glyphCache->getGlyphSizeLimit()); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 504 | |
| 505 | // Temporarily jam in kFill, so we only ever ask for the raw outline from the cache. |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 506 | pathPaint.setStyle(SkPaint::kFill_Style); |
| 507 | pathPaint.setPathEffect(nullptr); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 508 | |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 509 | SkPaint::GlyphCacheProc glyphCacheProc = SkPaint::GetGlyphCacheProc(pathPaint.getTextEncoding(), |
| 510 | pathPaint.isDevKernText(), |
| 511 | true); |
| 512 | SkAutoGlyphCache autoCache(pathPaint, &props, nullptr); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 513 | SkGlyphCache* cache = autoCache.getCache(); |
| 514 | |
| 515 | const char* stop = text + byteLength; |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 516 | const char* lastText = text; |
| 517 | SkTextAlignProc alignProc(pathPaint.getTextAlign()); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 518 | SkTextMapStateProc tmsProc(SkMatrix::I(), offset, scalarsPerPosition); |
| 519 | |
| 520 | while (text < stop) { |
| 521 | const SkGlyph& glyph = glyphCacheProc(cache, &text); |
| 522 | if (glyph.fWidth) { |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 523 | SkPoint tmsLoc; |
| 524 | tmsProc(pos, &tmsLoc); |
| 525 | SkPoint loc; |
| 526 | alignProc(tmsLoc, glyph, &loc); |
| 527 | if (SkMask::kARGB32_Format == glyph.fMaskFormat) { |
| 528 | fallbackTextHelper.appendText(glyph, text - lastText, lastText, loc); |
| 529 | } else { |
| 530 | const SkPath* path = cache->findPath(glyph); |
| 531 | if (path) { |
| 532 | blob->appendPathGlyph(runIndex, *path, loc.fX, loc.fY, matrixScale, false); |
| 533 | } |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 534 | } |
| 535 | } |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 536 | lastText = text; |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 537 | pos += scalarsPerPosition; |
| 538 | } |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 539 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 540 | fallbackTextHelper.drawText(blob, runIndex, glyphCache, props, origPaint, scalerContextFlags); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 541 | } |
| 542 | |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 543 | void GrAtlasTextContext::BmpAppendGlyph(GrAtlasTextBlob* blob, int runIndex, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 544 | GrGlyphCache* grGlyphCache, GrAtlasTextStrike** strike, |
Jim Van Verth | c65b65d | 2018-01-16 16:26:35 -0500 | [diff] [blame] | 545 | const SkGlyph& skGlyph, SkScalar sx, SkScalar sy, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 546 | GrColor color, SkGlyphCache* skGlyphCache, |
Jim Van Verth | c65b65d | 2018-01-16 16:26:35 -0500 | [diff] [blame] | 547 | SkScalar textRatio) { |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 548 | if (!*strike) { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 549 | *strike = grGlyphCache->getStrike(skGlyphCache); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(), |
| 553 | skGlyph.getSubXFixed(), |
| 554 | skGlyph.getSubYFixed(), |
| 555 | GrGlyph::kCoverage_MaskStyle); |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 556 | GrGlyph* glyph = (*strike)->getGlyph(skGlyph, id, skGlyphCache); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 557 | if (!glyph) { |
| 558 | return; |
| 559 | } |
| 560 | |
Jim Van Verth | c65b65d | 2018-01-16 16:26:35 -0500 | [diff] [blame] | 561 | SkASSERT(skGlyph.fWidth == glyph->width()); |
| 562 | SkASSERT(skGlyph.fHeight == glyph->height()); |
| 563 | |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 564 | SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft); |
| 565 | SkScalar dy = SkIntToScalar(glyph->fBounds.fTop); |
| 566 | SkScalar width = SkIntToScalar(glyph->fBounds.width()); |
| 567 | SkScalar height = SkIntToScalar(glyph->fBounds.height()); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 568 | |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 569 | dx *= textRatio; |
| 570 | dy *= textRatio; |
| 571 | width *= textRatio; |
| 572 | height *= textRatio; |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 573 | |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 574 | SkRect glyphRect = SkRect::MakeXYWH(sx + dx, sy + dy, width, height); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 575 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 576 | blob->appendGlyph(runIndex, glyphRect, color, *strike, glyph, skGlyphCache, skGlyph, sx, sy, |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 577 | textRatio, true); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 578 | } |
| 579 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 580 | bool GrAtlasTextContext::canDrawAsDistanceFields(const SkPaint& skPaint, const SkMatrix& viewMatrix, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 581 | const SkSurfaceProps& props, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 582 | const GrShaderCaps& caps) const { |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 583 | if (!viewMatrix.hasPerspective()) { |
| 584 | SkScalar maxScale = viewMatrix.getMaxScale(); |
| 585 | SkScalar scaledTextSize = maxScale * skPaint.getTextSize(); |
| 586 | // Hinted text looks far better at small resolutions |
| 587 | // Scaling up beyond 2x yields undesireable artifacts |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 588 | if (scaledTextSize < fMinDistanceFieldFontSize || |
| 589 | scaledTextSize > fMaxDistanceFieldFontSize) { |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 590 | return false; |
| 591 | } |
| 592 | |
| 593 | bool useDFT = props.isUseDeviceIndependentFonts(); |
| 594 | #if SK_FORCE_DISTANCE_FIELD_TEXT |
| 595 | useDFT = true; |
| 596 | #endif |
| 597 | |
| 598 | if (!useDFT && scaledTextSize < kLargeDFFontSize) { |
| 599 | return false; |
| 600 | } |
| 601 | } |
| 602 | |
Mike Reed | 8ad91a9 | 2018-01-19 19:09:32 -0500 | [diff] [blame] | 603 | // mask filters modify alpha, which doesn't translate well to distance |
| 604 | if (skPaint.getMaskFilter() || !caps.shaderDerivativeSupport()) { |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 605 | return false; |
| 606 | } |
| 607 | |
| 608 | // TODO: add some stroking support |
| 609 | if (skPaint.getStyle() != SkPaint::kFill_Style) { |
| 610 | return false; |
| 611 | } |
| 612 | |
| 613 | return true; |
| 614 | } |
| 615 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 616 | void GrAtlasTextContext::initDistanceFieldPaint(GrAtlasTextBlob* blob, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 617 | SkPaint* skPaint, |
| 618 | SkScalar* textRatio, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 619 | const SkMatrix& viewMatrix) const { |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 620 | SkScalar textSize = skPaint->getTextSize(); |
| 621 | SkScalar scaledTextSize = textSize; |
| 622 | |
| 623 | if (viewMatrix.hasPerspective()) { |
| 624 | // for perspective, we simply force to the medium size |
| 625 | // TODO: compute a size based on approximate screen area |
| 626 | scaledTextSize = kMediumDFFontLimit; |
| 627 | } else { |
| 628 | SkScalar maxScale = viewMatrix.getMaxScale(); |
| 629 | // if we have non-unity scale, we need to choose our base text size |
| 630 | // based on the SkPaint's text size multiplied by the max scale factor |
| 631 | // TODO: do we need to do this if we're scaling down (i.e. maxScale < 1)? |
| 632 | if (maxScale > 0 && !SkScalarNearlyEqual(maxScale, SK_Scalar1)) { |
| 633 | scaledTextSize *= maxScale; |
| 634 | } |
| 635 | } |
| 636 | |
| 637 | // We have three sizes of distance field text, and within each size 'bucket' there is a floor |
| 638 | // and ceiling. A scale outside of this range would require regenerating the distance fields |
| 639 | SkScalar dfMaskScaleFloor; |
| 640 | SkScalar dfMaskScaleCeil; |
| 641 | if (scaledTextSize <= kSmallDFFontLimit) { |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 642 | dfMaskScaleFloor = fMinDistanceFieldFontSize; |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 643 | dfMaskScaleCeil = kSmallDFFontLimit; |
| 644 | *textRatio = textSize / kSmallDFFontSize; |
| 645 | skPaint->setTextSize(SkIntToScalar(kSmallDFFontSize)); |
| 646 | } else if (scaledTextSize <= kMediumDFFontLimit) { |
| 647 | dfMaskScaleFloor = kSmallDFFontLimit; |
| 648 | dfMaskScaleCeil = kMediumDFFontLimit; |
| 649 | *textRatio = textSize / kMediumDFFontSize; |
| 650 | skPaint->setTextSize(SkIntToScalar(kMediumDFFontSize)); |
| 651 | } else { |
| 652 | dfMaskScaleFloor = kMediumDFFontLimit; |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 653 | dfMaskScaleCeil = fMaxDistanceFieldFontSize; |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 654 | *textRatio = textSize / kLargeDFFontSize; |
| 655 | skPaint->setTextSize(SkIntToScalar(kLargeDFFontSize)); |
| 656 | } |
| 657 | |
| 658 | // Because there can be multiple runs in the blob, we want the overall maxMinScale, and |
| 659 | // minMaxScale to make regeneration decisions. Specifically, we want the maximum minimum scale |
| 660 | // we can tolerate before we'd drop to a lower mip size, and the minimum maximum scale we can |
| 661 | // tolerate before we'd have to move to a large mip size. When we actually test these values |
| 662 | // we look at the delta in scale between the new viewmatrix and the old viewmatrix, and test |
| 663 | // against these values to decide if we can reuse or not(ie, will a given scale change our mip |
| 664 | // level) |
| 665 | SkASSERT(dfMaskScaleFloor <= scaledTextSize && scaledTextSize <= dfMaskScaleCeil); |
| 666 | blob->setMinAndMaxScale(dfMaskScaleFloor / scaledTextSize, dfMaskScaleCeil / scaledTextSize); |
| 667 | |
| 668 | skPaint->setAntiAlias(true); |
| 669 | skPaint->setLCDRenderText(false); |
| 670 | skPaint->setAutohinted(false); |
| 671 | skPaint->setHinting(SkPaint::kNormal_Hinting); |
| 672 | skPaint->setSubpixelText(true); |
| 673 | } |
| 674 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 675 | void GrAtlasTextContext::drawDFText(GrAtlasTextBlob* blob, int runIndex, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 676 | GrGlyphCache* glyphCache, const SkSurfaceProps& props, |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 677 | const GrTextUtils::Paint& paint, |
| 678 | SkScalerContextFlags scalerContextFlags, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 679 | const SkMatrix& viewMatrix, const char text[], |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 680 | size_t byteLength, SkScalar x, SkScalar y) const { |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 681 | SkASSERT(byteLength == 0 || text != nullptr); |
| 682 | |
| 683 | // nothing to draw |
| 684 | if (text == nullptr || byteLength == 0) { |
| 685 | return; |
| 686 | } |
| 687 | |
| 688 | const SkPaint& skPaint = paint.skPaint(); |
| 689 | SkPaint::GlyphCacheProc glyphCacheProc = |
| 690 | SkPaint::GetGlyphCacheProc(skPaint.getTextEncoding(), skPaint.isDevKernText(), true); |
| 691 | SkAutoDescriptor desc; |
| 692 | SkScalerContextEffects effects; |
| 693 | // We apply the fake-gamma by altering the distance in the shader, so we ignore the |
| 694 | // passed-in scaler context flags. (It's only used when we fall-back to bitmap text). |
Herb Derby | 980a48d | 2018-01-23 13:39:21 -0500 | [diff] [blame] | 695 | SkScalerContext::CreateDescriptorAndEffectsUsingPaint( |
| 696 | skPaint, &props, SkScalerContextFlags::kNone, nullptr, &desc, &effects); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 697 | SkGlyphCache* origPaintCache = |
| 698 | SkGlyphCache::DetachCache(skPaint.getTypeface(), effects, desc.getDesc()); |
| 699 | |
| 700 | SkTArray<SkScalar> positions; |
| 701 | |
| 702 | const char* textPtr = text; |
| 703 | SkScalar stopX = 0; |
| 704 | SkScalar stopY = 0; |
| 705 | SkScalar origin = 0; |
| 706 | switch (skPaint.getTextAlign()) { |
| 707 | case SkPaint::kRight_Align: origin = SK_Scalar1; break; |
| 708 | case SkPaint::kCenter_Align: origin = SK_ScalarHalf; break; |
| 709 | case SkPaint::kLeft_Align: origin = 0; break; |
| 710 | } |
| 711 | |
| 712 | SkAutoKern autokern; |
| 713 | const char* stop = text + byteLength; |
| 714 | while (textPtr < stop) { |
| 715 | // don't need x, y here, since all subpixel variants will have the |
| 716 | // same advance |
| 717 | const SkGlyph& glyph = glyphCacheProc(origPaintCache, &textPtr); |
| 718 | |
| 719 | SkScalar width = SkFloatToScalar(glyph.fAdvanceX) + autokern.adjust(glyph); |
| 720 | positions.push_back(stopX + origin * width); |
| 721 | |
| 722 | SkScalar height = SkFloatToScalar(glyph.fAdvanceY); |
| 723 | positions.push_back(stopY + origin * height); |
| 724 | |
| 725 | stopX += width; |
| 726 | stopY += height; |
| 727 | } |
| 728 | SkASSERT(textPtr == stop); |
| 729 | |
| 730 | SkGlyphCache::AttachCache(origPaintCache); |
| 731 | |
| 732 | // now adjust starting point depending on alignment |
| 733 | SkScalar alignX = stopX; |
| 734 | SkScalar alignY = stopY; |
| 735 | if (skPaint.getTextAlign() == SkPaint::kCenter_Align) { |
| 736 | alignX = SkScalarHalf(alignX); |
| 737 | alignY = SkScalarHalf(alignY); |
| 738 | } else if (skPaint.getTextAlign() == SkPaint::kLeft_Align) { |
| 739 | alignX = 0; |
| 740 | alignY = 0; |
| 741 | } |
| 742 | x -= alignX; |
| 743 | y -= alignY; |
| 744 | SkPoint offset = SkPoint::Make(x, y); |
| 745 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 746 | this->drawDFPosText(blob, runIndex, glyphCache, props, paint, scalerContextFlags, viewMatrix, |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 747 | text, byteLength, positions.begin(), 2, offset); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 748 | } |
| 749 | |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 750 | void GrAtlasTextContext::drawDFPosText(GrAtlasTextBlob* blob, int runIndex, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 751 | GrGlyphCache* glyphCache, const SkSurfaceProps& props, |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 752 | const GrTextUtils::Paint& paint, |
| 753 | SkScalerContextFlags scalerContextFlags, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 754 | const SkMatrix& viewMatrix, const char text[], |
| 755 | size_t byteLength, const SkScalar pos[], |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 756 | int scalarsPerPosition, const SkPoint& offset) const { |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 757 | SkASSERT(byteLength == 0 || text != nullptr); |
| 758 | SkASSERT(1 == scalarsPerPosition || 2 == scalarsPerPosition); |
| 759 | |
| 760 | // nothing to draw |
| 761 | if (text == nullptr || byteLength == 0) { |
| 762 | return; |
| 763 | } |
| 764 | |
Brian Salomon | b508696 | 2017-12-13 10:59:33 -0500 | [diff] [blame] | 765 | bool hasWCoord = viewMatrix.hasPerspective() || fDistanceFieldVerticesAlwaysHaveW; |
| 766 | |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 767 | // Setup distance field paint and text ratio |
| 768 | SkScalar textRatio; |
| 769 | SkPaint dfPaint(paint); |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 770 | this->initDistanceFieldPaint(blob, &dfPaint, &textRatio, viewMatrix); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 771 | blob->setHasDistanceField(); |
| 772 | blob->setSubRunHasDistanceFields(runIndex, paint.skPaint().isLCDRenderText(), |
Brian Salomon | 5c6ac64 | 2017-12-19 11:09:32 -0500 | [diff] [blame] | 773 | paint.skPaint().isAntiAlias(), hasWCoord); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 774 | |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 775 | FallbackTextHelper fallbackTextHelper(viewMatrix, |
| 776 | paint.skPaint().getTextSize(), |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 777 | glyphCache->getGlyphSizeLimit(), |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 778 | textRatio); |
| 779 | |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 780 | GrAtlasTextStrike* currStrike = nullptr; |
| 781 | |
| 782 | // We apply the fake-gamma by altering the distance in the shader, so we ignore the |
| 783 | // passed-in scaler context flags. (It's only used when we fall-back to bitmap text). |
| 784 | SkGlyphCache* cache = |
Herb Derby | d8327a8 | 2018-01-22 14:39:27 -0500 | [diff] [blame] | 785 | blob->setupCache(runIndex, props, SkScalerContextFlags::kNone, dfPaint, nullptr); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 786 | SkPaint::GlyphCacheProc glyphCacheProc = |
| 787 | SkPaint::GetGlyphCacheProc(dfPaint.getTextEncoding(), dfPaint.isDevKernText(), true); |
| 788 | |
| 789 | const char* stop = text + byteLength; |
| 790 | |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 791 | SkPaint::Align align = dfPaint.getTextAlign(); |
| 792 | SkScalar alignMul = SkPaint::kCenter_Align == align ? SK_ScalarHalf : |
| 793 | (SkPaint::kRight_Align == align ? SK_Scalar1 : 0); |
| 794 | while (text < stop) { |
| 795 | const char* lastText = text; |
| 796 | // the last 2 parameters are ignored |
| 797 | const SkGlyph& glyph = glyphCacheProc(cache, &text); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 798 | |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 799 | if (glyph.fWidth) { |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 800 | SkPoint glyphPos(offset); |
| 801 | glyphPos.fX += pos[0] - SkFloatToScalar(glyph.fAdvanceX) * alignMul * textRatio; |
| 802 | glyphPos.fY += (2 == scalarsPerPosition ? pos[1] : 0) - |
| 803 | SkFloatToScalar(glyph.fAdvanceY) * alignMul * textRatio; |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 804 | |
| 805 | if (glyph.fMaskFormat != SkMask::kARGB32_Format) { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 806 | DfAppendGlyph(blob, runIndex, glyphCache, &currStrike, glyph, glyphPos.fX, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 807 | glyphPos.fY, paint.filteredPremulColor(), cache, textRatio); |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 808 | } else { |
| 809 | // can't append color glyph to SDF batch, send to fallback |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 810 | fallbackTextHelper.appendText(glyph, SkToInt(text - lastText), lastText, glyphPos); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 811 | } |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 812 | } |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 813 | pos += scalarsPerPosition; |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 814 | } |
| 815 | |
| 816 | SkGlyphCache::AttachCache(cache); |
Jim Van Verth | 54d9c88 | 2018-02-08 16:14:48 -0500 | [diff] [blame] | 817 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 818 | fallbackTextHelper.drawText(blob, runIndex, glyphCache, props, paint, scalerContextFlags); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 819 | } |
| 820 | |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 821 | // TODO: merge with BmpAppendGlyph |
| 822 | void GrAtlasTextContext::DfAppendGlyph(GrAtlasTextBlob* blob, int runIndex, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 823 | GrGlyphCache* grGlyphCache, GrAtlasTextStrike** strike, |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 824 | const SkGlyph& skGlyph, SkScalar sx, SkScalar sy, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 825 | GrColor color, SkGlyphCache* skGlyphCache, |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 826 | SkScalar textRatio) { |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 827 | if (!*strike) { |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 828 | *strike = grGlyphCache->getStrike(skGlyphCache); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 829 | } |
| 830 | |
| 831 | GrGlyph::PackedID id = GrGlyph::Pack(skGlyph.getGlyphID(), |
| 832 | skGlyph.getSubXFixed(), |
| 833 | skGlyph.getSubYFixed(), |
| 834 | GrGlyph::kDistance_MaskStyle); |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 835 | GrGlyph* glyph = (*strike)->getGlyph(skGlyph, id, skGlyphCache); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 836 | if (!glyph) { |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 837 | return; |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 838 | } |
| 839 | |
| 840 | SkScalar dx = SkIntToScalar(glyph->fBounds.fLeft + SK_DistanceFieldInset); |
| 841 | SkScalar dy = SkIntToScalar(glyph->fBounds.fTop + SK_DistanceFieldInset); |
| 842 | SkScalar width = SkIntToScalar(glyph->fBounds.width() - 2 * SK_DistanceFieldInset); |
| 843 | SkScalar height = SkIntToScalar(glyph->fBounds.height() - 2 * SK_DistanceFieldInset); |
| 844 | |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 845 | dx *= textRatio; |
| 846 | dy *= textRatio; |
| 847 | width *= textRatio; |
| 848 | height *= textRatio; |
| 849 | SkRect glyphRect = SkRect::MakeXYWH(sx + dx, sy + dy, width, height); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 850 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 851 | blob->appendGlyph(runIndex, glyphRect, color, *strike, glyph, skGlyphCache, skGlyph, sx, sy, |
Jim Van Verth | f4c1316 | 2018-01-11 16:40:24 -0500 | [diff] [blame] | 852 | textRatio, false); |
Brian Salomon | 52db940 | 2017-11-07 14:58:55 -0500 | [diff] [blame] | 853 | } |
| 854 | |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 855 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 856 | |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 857 | void GrAtlasTextContext::FallbackTextHelper::appendText(const SkGlyph& glyph, int count, |
| 858 | const char* text, SkPoint glyphPos) { |
| 859 | SkScalar maxDim = SkTMax(glyph.fWidth, glyph.fHeight)*fTextRatio; |
| 860 | if (!fUseScaledFallback) { |
| 861 | SkScalar scaledGlyphSize = maxDim * fMaxScale; |
| 862 | if (!fViewMatrix.hasPerspective() && scaledGlyphSize > fMaxTextSize) { |
| 863 | fUseScaledFallback = true; |
| 864 | } |
| 865 | } |
| 866 | |
| 867 | fFallbackTxt.append(count, text); |
| 868 | if (fUseScaledFallback) { |
| 869 | SkScalar glyphTextSize = SkScalarFloorToScalar(fMaxTextSize*fTextSize / maxDim); |
| 870 | fScaledFallbackTextSize = SkTMin(glyphTextSize, fScaledFallbackTextSize); |
| 871 | } |
| 872 | *fFallbackPos.append() = glyphPos; |
| 873 | } |
| 874 | |
| 875 | void GrAtlasTextContext::FallbackTextHelper::drawText(GrAtlasTextBlob* blob, int runIndex, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 876 | GrGlyphCache* glyphCache, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 877 | const SkSurfaceProps& props, |
| 878 | const GrTextUtils::Paint& paint, |
| 879 | SkScalerContextFlags scalerContextFlags) { |
| 880 | if (fFallbackTxt.count()) { |
| 881 | blob->initOverride(runIndex); |
| 882 | blob->setHasBitmap(); |
| 883 | SkGlyphCache* cache = nullptr; |
| 884 | const SkPaint& skPaint = paint.skPaint(); |
| 885 | SkPaint::GlyphCacheProc glyphCacheProc = |
| 886 | SkPaint::GetGlyphCacheProc(skPaint.getTextEncoding(), |
| 887 | skPaint.isDevKernText(), true); |
| 888 | SkColor textColor = paint.filteredPremulColor(); |
| 889 | SkScalar textRatio = SK_Scalar1; |
| 890 | fViewMatrix.mapPoints(fFallbackPos.begin(), fFallbackPos.count()); |
| 891 | if (fUseScaledFallback) { |
| 892 | // Set up paint and matrix to scale glyphs |
| 893 | SkPaint scaledPaint(skPaint); |
| 894 | scaledPaint.setTextSize(fScaledFallbackTextSize); |
| 895 | // remove maxScale from viewMatrix and move it into textRatio |
| 896 | // this keeps the base glyph size consistent regardless of matrix scale |
| 897 | SkMatrix modMatrix(fViewMatrix); |
| 898 | SkScalar invScale = SkScalarInvert(fMaxScale); |
| 899 | modMatrix.preScale(invScale, invScale); |
| 900 | textRatio = fTextSize * fMaxScale / fScaledFallbackTextSize; |
| 901 | cache = blob->setupCache(runIndex, props, scalerContextFlags, scaledPaint, |
| 902 | &modMatrix); |
| 903 | } else { |
| 904 | cache = blob->setupCache(runIndex, props, scalerContextFlags, paint, |
| 905 | &fViewMatrix); |
| 906 | } |
| 907 | |
| 908 | GrAtlasTextStrike* currStrike = nullptr; |
| 909 | const char* text = fFallbackTxt.begin(); |
| 910 | const char* stop = text + fFallbackTxt.count(); |
| 911 | SkPoint* glyphPos = fFallbackPos.begin(); |
| 912 | while (text < stop) { |
| 913 | const SkGlyph& glyph = glyphCacheProc(cache, &text); |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 914 | GrAtlasTextContext::BmpAppendGlyph(blob, runIndex, glyphCache, &currStrike, glyph, |
Jim Van Verth | c401bb9 | 2018-02-15 14:05:24 -0500 | [diff] [blame] | 915 | glyphPos->fX, glyphPos->fY, textColor, |
| 916 | cache, textRatio); |
| 917 | glyphPos++; |
| 918 | } |
| 919 | |
| 920 | SkGlyphCache::AttachCache(cache); |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
| 925 | |
Hal Canary | 6f6961e | 2017-01-31 13:50:44 -0500 | [diff] [blame] | 926 | #if GR_TEST_UTILS |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 927 | |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 928 | #include "GrRenderTargetContext.h" |
| 929 | |
Brian Salomon | 44acb5b | 2017-07-18 19:59:24 -0400 | [diff] [blame] | 930 | GR_DRAW_OP_TEST_DEFINE(GrAtlasTextOp) { |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 931 | static uint32_t gContextID = SK_InvalidGenID; |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 932 | static std::unique_ptr<GrAtlasTextContext> gTextContext; |
robertphillips | fcf7829 | 2015-06-19 11:49:52 -0700 | [diff] [blame] | 933 | static SkSurfaceProps gSurfaceProps(SkSurfaceProps::kLegacyFontHost_InitType); |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 934 | |
| 935 | if (context->uniqueID() != gContextID) { |
| 936 | gContextID = context->uniqueID(); |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 937 | gTextContext = GrAtlasTextContext::Make(GrAtlasTextContext::Options()); |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 938 | } |
| 939 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 940 | // Setup dummy SkPaint / GrPaint / GrRenderTargetContext |
Brian Osman | ec8f8b0 | 2017-05-11 10:57:37 -0400 | [diff] [blame] | 941 | sk_sp<GrRenderTargetContext> rtc(context->makeDeferredRenderTargetContext( |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 942 | SkBackingFit::kApprox, 1024, 1024, kRGBA_8888_GrPixelConfig, nullptr)); |
brianosman | 8fe485b | 2016-07-25 12:31:51 -0700 | [diff] [blame] | 943 | |
joshualitt | 6c89110 | 2015-05-13 08:51:49 -0700 | [diff] [blame] | 944 | SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random); |
Brian Salomon | 44acb5b | 2017-07-18 19:59:24 -0400 | [diff] [blame] | 945 | |
| 946 | // Because we the GrTextUtils::Paint requires an SkPaint for font info, we ignore the GrPaint |
| 947 | // param. |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 948 | SkPaint skPaint; |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 949 | skPaint.setColor(random->nextU()); |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 950 | skPaint.setLCDRenderText(random->nextBool()); |
| 951 | skPaint.setAntiAlias(skPaint.isLCDRenderText() ? true : random->nextBool()); |
| 952 | skPaint.setSubpixelText(random->nextBool()); |
Brian Salomon | 4cbb6e6 | 2017-10-25 15:12:19 -0400 | [diff] [blame] | 953 | GrTextUtils::Paint utilsPaint(&skPaint, &rtc->colorSpaceInfo()); |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 954 | |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 955 | const char* text = "The quick brown fox jumps over the lazy dog."; |
| 956 | int textLen = (int)strlen(text); |
| 957 | |
joshualitt | b8d8649 | 2016-02-24 09:23:03 -0800 | [diff] [blame] | 958 | // create some random x/y offsets, including negative offsets |
| 959 | static const int kMaxTrans = 1024; |
| 960 | int xPos = (random->nextU() % 2) * 2 - 1; |
| 961 | int yPos = (random->nextU() % 2) * 2 - 1; |
| 962 | int xInt = (random->nextU() % kMaxTrans) * xPos; |
| 963 | int yInt = (random->nextU() % kMaxTrans) * yPos; |
| 964 | SkScalar x = SkIntToScalar(xInt); |
| 965 | SkScalar y = SkIntToScalar(yInt); |
halcanary | 9d524f2 | 2016-03-29 09:03:52 -0700 | [diff] [blame] | 966 | |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 967 | auto glyphCache = context->contextPriv().getGlyphCache(); |
| 968 | auto restrictedAtlasManager = context->contextPriv().getRestrictedAtlasManager(); |
Robert Phillips | f35fd8d | 2018-01-22 10:48:15 -0500 | [diff] [blame] | 969 | |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 970 | // right now we don't handle textblobs, nor do we handle drawPosText. Since we only intend to |
| 971 | // test the text op with this unit test, that is okay. |
Brian Salomon | af59748 | 2017-11-07 16:23:34 -0500 | [diff] [blame] | 972 | sk_sp<GrAtlasTextBlob> blob(gTextContext->makeDrawTextBlob( |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 973 | context->contextPriv().getTextBlobCache(), glyphCache, |
Brian Salomon | 44acb5b | 2017-07-18 19:59:24 -0400 | [diff] [blame] | 974 | *context->caps()->shaderCaps(), utilsPaint, |
Brian Salomon | 5ec9def | 2016-12-20 15:34:05 -0500 | [diff] [blame] | 975 | GrAtlasTextContext::kTextBlobOpScalerContextFlags, viewMatrix, gSurfaceProps, text, |
| 976 | static_cast<size_t>(textLen), x, y)); |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 977 | |
Brian Salomon | 44acb5b | 2017-07-18 19:59:24 -0400 | [diff] [blame] | 978 | return blob->test_makeOp(textLen, 0, 0, viewMatrix, x, y, utilsPaint, gSurfaceProps, |
Robert Phillips | acf1790 | 2018-02-27 16:43:18 -0500 | [diff] [blame^] | 979 | gTextContext->dfAdjustTable(), restrictedAtlasManager, |
Brian Salomon | f18b1d8 | 2017-10-27 11:30:49 -0400 | [diff] [blame] | 980 | rtc->textTarget()); |
joshualitt | 79dfb2b | 2015-05-11 08:58:08 -0700 | [diff] [blame] | 981 | } |
| 982 | |
| 983 | #endif |