joshualitt | 374b2f7 | 2015-07-21 08:05:03 -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 | |
| 8 | #ifndef GrAtlasTextBlob_DEFINED |
| 9 | #define GrAtlasTextBlob_DEFINED |
| 10 | |
Brian Salomon | f856fd1 | 2016-12-16 14:24:34 -0500 | [diff] [blame] | 11 | #include "GrAtlasGlyphCache.h" |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 12 | #include "GrColor.h" |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 13 | #include "GrDrawOpAtlas.h" |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 14 | #include "GrMemoryPool.h" |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 15 | #include "GrTextUtils.h" |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 16 | #include "SkDescriptor.h" |
| 17 | #include "SkMaskFilter.h" |
mtklein | 4e97607 | 2016-08-08 09:06:27 -0700 | [diff] [blame] | 18 | #include "SkOpts.h" |
bsalomon | 8b6fa5e | 2016-05-19 16:23:47 -0700 | [diff] [blame] | 19 | #include "SkPathEffect.h" |
| 20 | #include "SkRasterizer.h" |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 21 | #include "SkSurfaceProps.h" |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 22 | #include "SkTInternalLList.h" |
| 23 | |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 24 | class GrBlobRegenHelper; |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 25 | struct GrDistanceFieldAdjustTable; |
joshualitt | 9230377 | 2016-02-10 11:55:52 -0800 | [diff] [blame] | 26 | class GrMemoryPool; |
Brian Salomon | d3ccb0a | 2017-04-03 10:38:00 -0400 | [diff] [blame] | 27 | class GrLegacyMeshDrawOp; |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 28 | class SkDrawFilter; |
| 29 | class SkTextBlob; |
| 30 | class SkTextBlobRunIterator; |
| 31 | |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 32 | // With this flag enabled, the GrAtlasTextContext will, as a sanity check, regenerate every blob |
| 33 | // that comes in to verify the integrity of its cache |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 34 | #define CACHE_SANITY_CHECK 0 |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 35 | |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 36 | /* |
| 37 | * A GrAtlasTextBlob contains a fully processed SkTextBlob, suitable for nearly immediate drawing |
| 38 | * on the GPU. These are initially created with valid positions and colors, but invalid |
| 39 | * texture coordinates. The GrAtlasTextBlob itself has a few Blob-wide properties, and also |
| 40 | * consists of a number of runs. Runs inside a blob are flushed individually so they can be |
| 41 | * reordered. |
| 42 | * |
| 43 | * The only thing(aside from a memcopy) required to flush a GrAtlasTextBlob is to ensure that |
| 44 | * the GrAtlas will not evict anything the Blob needs. |
| 45 | * |
| 46 | * Note: This struct should really be named GrCachedAtasTextBlob, but that is too verbose. |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 47 | * |
| 48 | * *WARNING* If you add new fields to this struct, then you may need to to update AssertEqual |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 49 | */ |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 50 | class GrAtlasTextBlob : public SkNVRefCnt<GrAtlasTextBlob> { |
| 51 | public: |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 52 | SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrAtlasTextBlob); |
| 53 | |
Florin Malita | c337c9e | 2017-03-10 18:02:29 +0000 | [diff] [blame] | 54 | static sk_sp<GrAtlasTextBlob> Make(GrMemoryPool* pool, int glyphCount, int runCount); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 55 | |
| 56 | struct Key { |
| 57 | Key() { |
| 58 | sk_bzero(this, sizeof(Key)); |
| 59 | } |
| 60 | uint32_t fUniqueID; |
| 61 | // Color may affect the gamma of the mask we generate, but in a fairly limited way. |
| 62 | // Each color is assigned to on of a fixed number of buckets based on its |
| 63 | // luminance. For each luminance bucket there is a "canonical color" that |
| 64 | // represents the bucket. This functionality is currently only supported for A8 |
| 65 | SkColor fCanonicalColor; |
| 66 | SkPaint::Style fStyle; |
| 67 | SkPixelGeometry fPixelGeometry; |
| 68 | bool fHasBlur; |
brianosman | 8d7ffce | 2016-04-21 08:29:06 -0700 | [diff] [blame] | 69 | uint32_t fScalerContextFlags; |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 70 | |
| 71 | bool operator==(const Key& other) const { |
| 72 | return 0 == memcmp(this, &other, sizeof(Key)); |
| 73 | } |
| 74 | }; |
| 75 | |
joshualitt | 9230377 | 2016-02-10 11:55:52 -0800 | [diff] [blame] | 76 | void setupKey(const GrAtlasTextBlob::Key& key, |
| 77 | const SkMaskFilter::BlurRec& blurRec, |
| 78 | const SkPaint& paint) { |
| 79 | fKey = key; |
| 80 | if (key.fHasBlur) { |
| 81 | fBlurRec = blurRec; |
| 82 | } |
| 83 | if (key.fStyle != SkPaint::kFill_Style) { |
| 84 | fStrokeInfo.fFrameWidth = paint.getStrokeWidth(); |
| 85 | fStrokeInfo.fMiterLimit = paint.getStrokeMiter(); |
| 86 | fStrokeInfo.fJoin = paint.getStrokeJoin(); |
| 87 | } |
| 88 | } |
| 89 | |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 90 | static const Key& GetKey(const GrAtlasTextBlob& blob) { |
| 91 | return blob.fKey; |
| 92 | } |
| 93 | |
| 94 | static uint32_t Hash(const Key& key) { |
mtklein | 4e97607 | 2016-08-08 09:06:27 -0700 | [diff] [blame] | 95 | return SkOpts::hash(&key, sizeof(Key)); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 96 | } |
| 97 | |
| 98 | void operator delete(void* p) { |
| 99 | GrAtlasTextBlob* blob = reinterpret_cast<GrAtlasTextBlob*>(p); |
| 100 | blob->fPool->release(p); |
| 101 | } |
| 102 | void* operator new(size_t) { |
| 103 | SkFAIL("All blobs are created by placement new."); |
| 104 | return sk_malloc_throw(0); |
| 105 | } |
| 106 | |
| 107 | void* operator new(size_t, void* p) { return p; } |
| 108 | void operator delete(void* target, void* placement) { |
| 109 | ::operator delete(target, placement); |
| 110 | } |
| 111 | |
| 112 | bool hasDistanceField() const { return SkToBool(fTextType & kHasDistanceField_TextType); } |
| 113 | bool hasBitmap() const { return SkToBool(fTextType & kHasBitmap_TextType); } |
| 114 | void setHasDistanceField() { fTextType |= kHasDistanceField_TextType; } |
| 115 | void setHasBitmap() { fTextType |= kHasBitmap_TextType; } |
| 116 | |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 117 | int runCount() const { return fRunCount; } |
| 118 | |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 119 | void push_back_run(int currRun) { |
| 120 | SkASSERT(currRun < fRunCount); |
| 121 | if (currRun > 0) { |
| 122 | Run::SubRunInfo& newRun = fRuns[currRun].fSubRunInfo.back(); |
| 123 | Run::SubRunInfo& lastRun = fRuns[currRun - 1].fSubRunInfo.back(); |
| 124 | newRun.setAsSuccessor(lastRun); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | // sets the last subrun of runIndex to use distance field text |
Jim Van Verth | 90e89b3 | 2017-07-06 16:36:55 -0400 | [diff] [blame^] | 129 | void setSubRunHasDistanceFields(int runIndex, bool hasLCD, bool isAntiAlias) { |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 130 | Run& run = fRuns[runIndex]; |
| 131 | Run::SubRunInfo& subRun = run.fSubRunInfo.back(); |
| 132 | subRun.setUseLCDText(hasLCD); |
Jim Van Verth | 90e89b3 | 2017-07-06 16:36:55 -0400 | [diff] [blame^] | 133 | subRun.setAntiAliased(isAntiAlias); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 134 | subRun.setDrawAsDistanceFields(); |
| 135 | } |
| 136 | |
| 137 | void setRunDrawAsPaths(int runIndex) { |
| 138 | fRuns[runIndex].fDrawAsPaths = true; |
| 139 | } |
| 140 | |
| 141 | void setMinAndMaxScale(SkScalar scaledMax, SkScalar scaledMin) { |
| 142 | // we init fMaxMinScale and fMinMaxScale in the constructor |
| 143 | fMaxMinScale = SkMaxScalar(scaledMax, fMaxMinScale); |
| 144 | fMinMaxScale = SkMinScalar(scaledMin, fMinMaxScale); |
| 145 | } |
| 146 | |
| 147 | // inits the override descriptor on the current run. All following subruns must use this |
| 148 | // descriptor |
| 149 | void initOverride(int runIndex) { |
| 150 | Run& run = fRuns[runIndex]; |
| 151 | // Push back a new subrun to fill and set the override descriptor |
| 152 | run.push_back(); |
| 153 | run.fOverrideDescriptor.reset(new SkAutoDescriptor); |
| 154 | } |
| 155 | |
| 156 | SkGlyphCache* setupCache(int runIndex, |
| 157 | const SkSurfaceProps& props, |
brianosman | a1e8f8d | 2016-04-08 06:47:54 -0700 | [diff] [blame] | 158 | uint32_t scalerContextFlags, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 159 | const SkPaint& skPaint, |
bungeman | f6d1e60 | 2016-02-22 13:20:28 -0800 | [diff] [blame] | 160 | const SkMatrix* viewMatrix); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 161 | |
| 162 | // Appends a glyph to the blob. If the glyph is too large, the glyph will be appended |
| 163 | // as a path. |
| 164 | void appendGlyph(int runIndex, |
| 165 | const SkRect& positions, |
| 166 | GrColor color, |
Brian Salomon | f856fd1 | 2016-12-16 14:24:34 -0500 | [diff] [blame] | 167 | GrAtlasTextStrike* strike, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 168 | GrGlyph* glyph, |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 169 | SkGlyphCache*, const SkGlyph& skGlyph, |
Jim Van Verth | 08576e6 | 2016-11-16 10:15:23 -0500 | [diff] [blame] | 170 | SkScalar x, SkScalar y, SkScalar scale, bool treatAsBMP); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 171 | |
| 172 | static size_t GetVertexStride(GrMaskFormat maskFormat) { |
| 173 | switch (maskFormat) { |
| 174 | case kA8_GrMaskFormat: |
| 175 | return kGrayTextVASize; |
| 176 | case kARGB_GrMaskFormat: |
| 177 | return kColorTextVASize; |
| 178 | default: |
| 179 | return kLCDTextVASize; |
| 180 | } |
| 181 | } |
| 182 | |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 183 | bool mustRegenerate(const GrTextUtils::Paint&, const SkMaskFilter::BlurRec& blurRec, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 184 | const SkMatrix& viewMatrix, SkScalar x, SkScalar y); |
| 185 | |
| 186 | // flush a GrAtlasTextBlob associated with a SkTextBlob |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 187 | void flushCached(GrContext* context, GrRenderTargetContext* rtc, const SkTextBlob* blob, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 188 | const SkSurfaceProps& props, |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 189 | const GrDistanceFieldAdjustTable* distanceAdjustTable, |
| 190 | const GrTextUtils::Paint&, SkDrawFilter* drawFilter, const GrClip& clip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 191 | const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x, SkScalar y); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 192 | |
| 193 | // flush a throwaway GrAtlasTextBlob *not* associated with an SkTextBlob |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 194 | void flushThrowaway(GrContext* context, GrRenderTargetContext* rtc, const SkSurfaceProps& props, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 195 | const GrDistanceFieldAdjustTable* distanceAdjustTable, |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 196 | const GrTextUtils::Paint& paint, const GrClip& clip, |
Brian Salomon | 82f4431 | 2017-01-11 13:42:54 -0500 | [diff] [blame] | 197 | const SkMatrix& viewMatrix, const SkIRect& clipBounds, SkScalar x, |
| 198 | SkScalar y); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 199 | |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 200 | void computeSubRunBounds(SkRect* outBounds, int runIndex, int subRunIndex, |
| 201 | const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
joshualitt | bc81111 | 2016-02-11 12:42:02 -0800 | [diff] [blame] | 202 | // We don't yet position distance field text on the cpu, so we have to map the vertex bounds |
| 203 | // into device space. |
| 204 | // We handle vertex bounds differently for distance field text and bitmap text because |
| 205 | // the vertex bounds of bitmap text are in device space. If we are flushing multiple runs |
| 206 | // from one blob then we are going to pay the price here of mapping the rect for each run. |
| 207 | const Run& run = fRuns[runIndex]; |
| 208 | const Run::SubRunInfo& subRun = run.fSubRunInfo[subRunIndex]; |
| 209 | *outBounds = subRun.vertexBounds(); |
| 210 | if (subRun.drawAsDistanceFields()) { |
| 211 | // Distance field text is positioned with the (X,Y) as part of the glyph position, |
| 212 | // and currently the view matrix is applied on the GPU |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 213 | outBounds->offset(x - fInitialX, y - fInitialY); |
| 214 | viewMatrix.mapRect(outBounds); |
joshualitt | bc81111 | 2016-02-11 12:42:02 -0800 | [diff] [blame] | 215 | } else { |
| 216 | // Bitmap text is fully positioned on the CPU, and offset by an (X,Y) translate in |
| 217 | // device space. |
| 218 | SkMatrix boundsMatrix = fInitialViewMatrixInverse; |
| 219 | |
| 220 | boundsMatrix.postTranslate(-fInitialX, -fInitialY); |
| 221 | |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 222 | boundsMatrix.postTranslate(x, y); |
joshualitt | bc81111 | 2016-02-11 12:42:02 -0800 | [diff] [blame] | 223 | |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 224 | boundsMatrix.postConcat(viewMatrix); |
joshualitt | bc81111 | 2016-02-11 12:42:02 -0800 | [diff] [blame] | 225 | boundsMatrix.mapRect(outBounds); |
| 226 | |
| 227 | // Due to floating point numerical inaccuracies, we have to round out here |
| 228 | outBounds->roundOut(outBounds); |
| 229 | } |
| 230 | } |
| 231 | |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 232 | // position + local coord |
| 233 | static const size_t kColorTextVASize = sizeof(SkPoint) + sizeof(SkIPoint16); |
| 234 | static const size_t kGrayTextVASize = sizeof(SkPoint) + sizeof(GrColor) + sizeof(SkIPoint16); |
| 235 | static const size_t kLCDTextVASize = kGrayTextVASize; |
joshualitt | 9230377 | 2016-02-10 11:55:52 -0800 | [diff] [blame] | 236 | static const size_t kMaxVASize = kGrayTextVASize; |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 237 | static const int kVerticesPerGlyph = 4; |
| 238 | |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 239 | static void AssertEqual(const GrAtlasTextBlob&, const GrAtlasTextBlob&); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 240 | |
| 241 | // The color here is the GrPaint color, and it is used to determine whether we |
| 242 | // have to regenerate LCD text blobs. |
| 243 | // We use this color vs the SkPaint color because it has the colorfilter applied. |
Jim Van Verth | bc2cdd1 | 2017-06-08 11:14:35 -0400 | [diff] [blame] | 244 | void initReusableBlob(SkColor luminanceColor, const SkMatrix& viewMatrix, SkScalar x, |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 245 | SkScalar y) { |
Jim Van Verth | bc2cdd1 | 2017-06-08 11:14:35 -0400 | [diff] [blame] | 246 | fLuminanceColor = luminanceColor; |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 247 | this->setupViewMatrix(viewMatrix, x, y); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 248 | } |
| 249 | |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 250 | void initThrowawayBlob(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
| 251 | this->setupViewMatrix(viewMatrix, x, y); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 252 | } |
| 253 | |
bsalomon | d1c71fd | 2016-05-19 12:51:46 -0700 | [diff] [blame] | 254 | /** |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 255 | * Consecutive calls to regenInOp often use the same SkGlyphCache. If the same instance of |
| 256 | * SkAutoGlyphCache is passed to multiple calls of regenInOp then it can save the cost of |
bsalomon | d1c71fd | 2016-05-19 12:51:46 -0700 | [diff] [blame] | 257 | * multiple detach/attach operations of SkGlyphCache. |
| 258 | */ |
Brian Salomon | 09d994e | 2016-12-21 11:14:46 -0500 | [diff] [blame] | 259 | void regenInOp(GrDrawOp::Target* target, GrAtlasGlyphCache* fontCache, |
| 260 | GrBlobRegenHelper* helper, int run, int subRun, SkAutoGlyphCache*, |
| 261 | size_t vertexStride, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
| 262 | GrColor color, void** vertices, size_t* byteCount, int* glyphCount); |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 263 | |
joshualitt | 9230377 | 2016-02-10 11:55:52 -0800 | [diff] [blame] | 264 | const Key& key() const { return fKey; } |
| 265 | |
| 266 | ~GrAtlasTextBlob() { |
| 267 | for (int i = 0; i < fRunCount; i++) { |
| 268 | fRuns[i].~Run(); |
| 269 | } |
| 270 | } |
| 271 | |
joshualitt | bc81111 | 2016-02-11 12:42:02 -0800 | [diff] [blame] | 272 | //////////////////////////////////////////////////////////////////////////////////////////////// |
| 273 | // Internal test methods |
Brian Salomon | d3ccb0a | 2017-04-03 10:38:00 -0400 | [diff] [blame] | 274 | std::unique_ptr<GrLegacyMeshDrawOp> test_makeOp( |
| 275 | int glyphCount, int run, int subRun, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
| 276 | const GrTextUtils::Paint& paint, const SkSurfaceProps& props, |
| 277 | const GrDistanceFieldAdjustTable* distanceAdjustTable, GrAtlasGlyphCache* cache); |
joshualitt | bc81111 | 2016-02-11 12:42:02 -0800 | [diff] [blame] | 278 | |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 279 | private: |
joshualitt | 9230377 | 2016-02-10 11:55:52 -0800 | [diff] [blame] | 280 | GrAtlasTextBlob() |
| 281 | : fMaxMinScale(-SK_ScalarMax) |
| 282 | , fMinMaxScale(SK_ScalarMax) |
| 283 | , fTextType(0) {} |
| 284 | |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 285 | void appendLargeGlyph(GrGlyph* glyph, SkGlyphCache* cache, const SkGlyph& skGlyph, |
Jim Van Verth | 08576e6 | 2016-11-16 10:15:23 -0500 | [diff] [blame] | 286 | SkScalar x, SkScalar y, SkScalar scale, bool treatAsBMP); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 287 | |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 288 | inline void flushRun(GrRenderTargetContext* rtc, const GrClip&, int run, |
| 289 | const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
| 290 | const GrTextUtils::Paint& paint, const SkSurfaceProps& props, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 291 | const GrDistanceFieldAdjustTable* distanceAdjustTable, |
Brian Salomon | f856fd1 | 2016-12-16 14:24:34 -0500 | [diff] [blame] | 292 | GrAtlasGlyphCache* cache); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 293 | |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 294 | void flushBigGlyphs(GrContext* context, GrRenderTargetContext* rtc, const GrClip& clip, |
| 295 | const SkPaint& paint, const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 296 | const SkIRect& clipBounds); |
| 297 | |
Brian Salomon | 6f1d36c | 2017-01-13 12:02:17 -0500 | [diff] [blame] | 298 | void flushRunAsPaths(GrContext* context, GrRenderTargetContext* rtc, |
| 299 | const SkSurfaceProps& props, const SkTextBlobRunIterator& it, |
| 300 | const GrClip& clip, const GrTextUtils::Paint& paint, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 301 | SkDrawFilter* drawFilter, const SkMatrix& viewMatrix, |
| 302 | const SkIRect& clipBounds, SkScalar x, SkScalar y); |
| 303 | |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 304 | // This function will only be called when we are generating a blob from scratch. We record the |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 305 | // initial view matrix and initial offsets(x,y), because we record vertex bounds relative to |
| 306 | // these numbers. When blobs are reused with new matrices, we need to return to model space so |
| 307 | // we can update the vertex bounds appropriately. |
| 308 | void setupViewMatrix(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 309 | fInitialViewMatrix = viewMatrix; |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 310 | if (!viewMatrix.invert(&fInitialViewMatrixInverse)) { |
| 311 | fInitialViewMatrixInverse = SkMatrix::I(); |
| 312 | SkDebugf("Could not invert viewmatrix\n"); |
| 313 | } |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 314 | fInitialX = x; |
| 315 | fInitialY = y; |
| 316 | |
| 317 | // make sure all initial subruns have the correct VM and X/Y applied |
| 318 | for (int i = 0; i < fRunCount; i++) { |
| 319 | fRuns[i].fSubRunInfo[0].init(fInitialViewMatrix, x, y); |
| 320 | } |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 321 | } |
| 322 | |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 323 | /* |
| 324 | * Each Run inside of the blob can have its texture coordinates regenerated if required. |
| 325 | * To determine if regeneration is necessary, fAtlasGeneration is used. If there have been |
| 326 | * any evictions inside of the atlas, then we will simply regenerate Runs. We could track |
| 327 | * this at a more fine grained level, but its not clear if this is worth it, as evictions |
| 328 | * should be fairly rare. |
| 329 | * |
| 330 | * One additional point, each run can contain glyphs with any of the three mask formats. |
| 331 | * We call these SubRuns. Because a subrun must be a contiguous range, we have to create |
| 332 | * a new subrun each time the mask format changes in a run. In theory, a run can have as |
| 333 | * many SubRuns as it has glyphs, ie if a run alternates between color emoji and A8. In |
| 334 | * practice, the vast majority of runs have only a single subrun. |
| 335 | * |
| 336 | * Finally, for runs where the entire thing is too large for the GrAtlasTextContext to |
| 337 | * handle, we have a bit to mark the run as flusahable via rendering as paths. It is worth |
| 338 | * pointing. It would be a bit expensive to figure out ahead of time whether or not a run |
| 339 | * can flush in this manner, so we always allocate vertices for the run, regardless of |
| 340 | * whether or not it is too large. The benefit of this strategy is that we can always reuse |
| 341 | * a blob allocation regardless of viewmatrix changes. We could store positions for these |
| 342 | * glyphs. However, its not clear if this is a win because we'd still have to either go the |
| 343 | * glyph cache to get the path at flush time, or hold onto the path in the cache, which |
| 344 | * would greatly increase the memory of these cached items. |
| 345 | */ |
| 346 | struct Run { |
| 347 | Run() |
joshualitt | f9e658b | 2015-12-09 09:26:44 -0800 | [diff] [blame] | 348 | : fInitialized(false) |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 349 | , fDrawAsPaths(false) { |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 350 | // To ensure we always have one subrun, we push back a fresh run here |
| 351 | fSubRunInfo.push_back(); |
| 352 | } |
| 353 | struct SubRunInfo { |
| 354 | SubRunInfo() |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 355 | : fAtlasGeneration(GrDrawOpAtlas::kInvalidAtlasGeneration) |
| 356 | , fVertexStartIndex(0) |
| 357 | , fVertexEndIndex(0) |
| 358 | , fGlyphStartIndex(0) |
| 359 | , fGlyphEndIndex(0) |
| 360 | , fColor(GrColor_ILLEGAL) |
| 361 | , fMaskFormat(kA8_GrMaskFormat) |
Jim Van Verth | 90e89b3 | 2017-07-06 16:36:55 -0400 | [diff] [blame^] | 362 | , fFlags(0) { |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 363 | fVertexBounds.setLargestInverted(); |
| 364 | } |
joshualitt | 7e97b0b | 2015-07-31 15:18:08 -0700 | [diff] [blame] | 365 | SubRunInfo(const SubRunInfo& that) |
| 366 | : fBulkUseToken(that.fBulkUseToken) |
| 367 | , fStrike(SkSafeRef(that.fStrike.get())) |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 368 | , fCurrentViewMatrix(that.fCurrentViewMatrix) |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 369 | , fVertexBounds(that.fVertexBounds) |
joshualitt | 7e97b0b | 2015-07-31 15:18:08 -0700 | [diff] [blame] | 370 | , fAtlasGeneration(that.fAtlasGeneration) |
| 371 | , fVertexStartIndex(that.fVertexStartIndex) |
| 372 | , fVertexEndIndex(that.fVertexEndIndex) |
| 373 | , fGlyphStartIndex(that.fGlyphStartIndex) |
| 374 | , fGlyphEndIndex(that.fGlyphEndIndex) |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 375 | , fX(that.fX) |
| 376 | , fY(that.fY) |
joshualitt | f9e658b | 2015-12-09 09:26:44 -0800 | [diff] [blame] | 377 | , fColor(that.fColor) |
joshualitt | 7e97b0b | 2015-07-31 15:18:08 -0700 | [diff] [blame] | 378 | , fMaskFormat(that.fMaskFormat) |
Jim Van Verth | 90e89b3 | 2017-07-06 16:36:55 -0400 | [diff] [blame^] | 379 | , fFlags(that.fFlags) { |
joshualitt | 7e97b0b | 2015-07-31 15:18:08 -0700 | [diff] [blame] | 380 | } |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 381 | |
joshualitt | 18b072d | 2015-12-07 12:26:12 -0800 | [diff] [blame] | 382 | // TODO when this object is more internal, drop the privacy |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 383 | void resetBulkUseToken() { fBulkUseToken.reset(); } |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 384 | GrDrawOpAtlas::BulkUseTokenUpdater* bulkUseToken() { return &fBulkUseToken; } |
Brian Salomon | f856fd1 | 2016-12-16 14:24:34 -0500 | [diff] [blame] | 385 | void setStrike(GrAtlasTextStrike* strike) { fStrike.reset(SkRef(strike)); } |
| 386 | GrAtlasTextStrike* strike() const { return fStrike.get(); } |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 387 | |
| 388 | void setAtlasGeneration(uint64_t atlasGeneration) { fAtlasGeneration = atlasGeneration;} |
| 389 | uint64_t atlasGeneration() const { return fAtlasGeneration; } |
| 390 | |
| 391 | size_t byteCount() const { return fVertexEndIndex - fVertexStartIndex; } |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 392 | size_t vertexStartIndex() const { return fVertexStartIndex; } |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 393 | size_t vertexEndIndex() const { return fVertexEndIndex; } |
| 394 | void appendVertices(size_t vertexStride) { |
| 395 | fVertexEndIndex += vertexStride * kVerticesPerGlyph; |
| 396 | } |
| 397 | |
| 398 | uint32_t glyphCount() const { return fGlyphEndIndex - fGlyphStartIndex; } |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 399 | uint32_t glyphStartIndex() const { return fGlyphStartIndex; } |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 400 | uint32_t glyphEndIndex() const { return fGlyphEndIndex; } |
| 401 | void glyphAppended() { fGlyphEndIndex++; } |
joshualitt | f9e658b | 2015-12-09 09:26:44 -0800 | [diff] [blame] | 402 | void setColor(GrColor color) { fColor = color; } |
| 403 | GrColor color() const { return fColor; } |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 404 | void setMaskFormat(GrMaskFormat format) { fMaskFormat = format; } |
| 405 | GrMaskFormat maskFormat() const { return fMaskFormat; } |
| 406 | |
joshualitt | 18b072d | 2015-12-07 12:26:12 -0800 | [diff] [blame] | 407 | void setAsSuccessor(const SubRunInfo& prev) { |
| 408 | fGlyphStartIndex = prev.glyphEndIndex(); |
| 409 | fGlyphEndIndex = prev.glyphEndIndex(); |
| 410 | |
| 411 | fVertexStartIndex = prev.vertexEndIndex(); |
| 412 | fVertexEndIndex = prev.vertexEndIndex(); |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 413 | |
| 414 | // copy over viewmatrix settings |
| 415 | this->init(prev.fCurrentViewMatrix, prev.fX, prev.fY); |
joshualitt | 18b072d | 2015-12-07 12:26:12 -0800 | [diff] [blame] | 416 | } |
| 417 | |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 418 | const SkRect& vertexBounds() const { return fVertexBounds; } |
| 419 | void joinGlyphBounds(const SkRect& glyphBounds) { |
| 420 | fVertexBounds.joinNonEmptyArg(glyphBounds); |
| 421 | } |
| 422 | |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 423 | void init(const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
| 424 | fCurrentViewMatrix = viewMatrix; |
| 425 | fX = x; |
| 426 | fY = y; |
| 427 | } |
| 428 | |
| 429 | // This function assumes the translation will be applied before it is called again |
| 430 | void computeTranslation(const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
| 431 | SkScalar*transX, SkScalar* transY); |
| 432 | |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 433 | // df properties |
Jim Van Verth | 90e89b3 | 2017-07-06 16:36:55 -0400 | [diff] [blame^] | 434 | void setDrawAsDistanceFields() { fFlags |= kDrawAsSDF_Flag; } |
| 435 | bool drawAsDistanceFields() const { return SkToBool(fFlags & kDrawAsSDF_Flag); } |
| 436 | void setUseLCDText(bool useLCDText) { |
| 437 | fFlags = useLCDText ? fFlags | kUseLCDText_Flag : fFlags & ~kUseLCDText_Flag; |
| 438 | } |
| 439 | bool hasUseLCDText() const { return SkToBool(fFlags & kUseLCDText_Flag); } |
| 440 | void setAntiAliased(bool antiAliased) { |
| 441 | fFlags = antiAliased ? fFlags | kAntiAliased_Flag : fFlags & ~kAntiAliased_Flag; |
| 442 | } |
| 443 | bool isAntiAliased() const { return SkToBool(fFlags & kAntiAliased_Flag); } |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 444 | |
| 445 | private: |
Jim Van Verth | 90e89b3 | 2017-07-06 16:36:55 -0400 | [diff] [blame^] | 446 | enum Flag { |
| 447 | kDrawAsSDF_Flag = 0x1, |
| 448 | kUseLCDText_Flag = 0x2, |
| 449 | kAntiAliased_Flag = 0x4 |
| 450 | }; |
| 451 | |
Brian Salomon | 2ee084e | 2016-12-16 18:59:19 -0500 | [diff] [blame] | 452 | GrDrawOpAtlas::BulkUseTokenUpdater fBulkUseToken; |
Brian Salomon | f856fd1 | 2016-12-16 14:24:34 -0500 | [diff] [blame] | 453 | sk_sp<GrAtlasTextStrike> fStrike; |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 454 | SkMatrix fCurrentViewMatrix; |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 455 | SkRect fVertexBounds; |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 456 | uint64_t fAtlasGeneration; |
| 457 | size_t fVertexStartIndex; |
| 458 | size_t fVertexEndIndex; |
| 459 | uint32_t fGlyphStartIndex; |
| 460 | uint32_t fGlyphEndIndex; |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 461 | SkScalar fX; |
| 462 | SkScalar fY; |
joshualitt | f9e658b | 2015-12-09 09:26:44 -0800 | [diff] [blame] | 463 | GrColor fColor; |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 464 | GrMaskFormat fMaskFormat; |
Jim Van Verth | 90e89b3 | 2017-07-06 16:36:55 -0400 | [diff] [blame^] | 465 | uint32_t fFlags; |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 466 | }; |
| 467 | |
| 468 | SubRunInfo& push_back() { |
| 469 | // Forward glyph / vertex information to seed the new sub run |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 470 | SubRunInfo& newSubRun = fSubRunInfo.push_back(); |
joshualitt | 18b072d | 2015-12-07 12:26:12 -0800 | [diff] [blame] | 471 | const SubRunInfo& prevSubRun = fSubRunInfo.fromBack(1); |
joshualitt | e43e3bd | 2015-07-29 11:10:38 -0700 | [diff] [blame] | 472 | |
joshualitt | 18b072d | 2015-12-07 12:26:12 -0800 | [diff] [blame] | 473 | newSubRun.setAsSuccessor(prevSubRun); |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 474 | return newSubRun; |
| 475 | } |
| 476 | static const int kMinSubRuns = 1; |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame] | 477 | sk_sp<SkTypeface> fTypeface; |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 478 | SkSTArray<kMinSubRuns, SubRunInfo> fSubRunInfo; |
| 479 | SkAutoDescriptor fDescriptor; |
bsalomon | 8b6fa5e | 2016-05-19 16:23:47 -0700 | [diff] [blame] | 480 | |
| 481 | // Effects from the paint that are used to build a SkScalerContext. |
| 482 | sk_sp<SkPathEffect> fPathEffect; |
| 483 | sk_sp<SkRasterizer> fRasterizer; |
| 484 | sk_sp<SkMaskFilter> fMaskFilter; |
joshualitt | 3660d53 | 2015-12-07 11:32:50 -0800 | [diff] [blame] | 485 | |
| 486 | // Distance field text cannot draw coloremoji, and so has to fall back. However, |
| 487 | // though the distance field text and the coloremoji may share the same run, they |
| 488 | // will have different descriptors. If fOverrideDescriptor is non-nullptr, then it |
| 489 | // will be used in place of the run's descriptor to regen texture coords |
Ben Wagner | 145dbcd | 2016-11-03 14:40:50 -0400 | [diff] [blame] | 490 | std::unique_ptr<SkAutoDescriptor> fOverrideDescriptor; // df properties |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 491 | bool fInitialized; |
| 492 | bool fDrawAsPaths; |
| 493 | }; |
| 494 | |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 495 | template <bool regenPos, bool regenCol, bool regenTexCoords, bool regenGlyphs> |
Brian Salomon | f856fd1 | 2016-12-16 14:24:34 -0500 | [diff] [blame] | 496 | void regenInOp(GrDrawOp::Target* target, GrAtlasGlyphCache* fontCache, GrBlobRegenHelper* helper, |
Brian Salomon | 344ec42 | 2016-12-15 10:58:41 -0500 | [diff] [blame] | 497 | Run* run, Run::SubRunInfo* info, SkAutoGlyphCache*, int glyphCount, |
| 498 | size_t vertexStride, GrColor color, SkScalar transX, SkScalar transY) const; |
joshualitt | ddd22d8 | 2016-02-16 06:47:52 -0800 | [diff] [blame] | 499 | |
Brian Salomon | d3ccb0a | 2017-04-03 10:38:00 -0400 | [diff] [blame] | 500 | inline std::unique_ptr<GrLegacyMeshDrawOp> makeOp( |
Brian Salomon | 649a341 | 2017-03-09 13:50:43 -0500 | [diff] [blame] | 501 | const Run::SubRunInfo& info, int glyphCount, int run, int subRun, |
| 502 | const SkMatrix& viewMatrix, SkScalar x, SkScalar y, const GrTextUtils::Paint& paint, |
| 503 | const SkSurfaceProps& props, const GrDistanceFieldAdjustTable* distanceAdjustTable, |
| 504 | bool useGammaCorrectDistanceTable, GrAtlasGlyphCache* cache); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 505 | |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 506 | struct BigGlyph { |
Jim Van Verth | 08576e6 | 2016-11-16 10:15:23 -0500 | [diff] [blame] | 507 | BigGlyph(const SkPath& path, SkScalar vx, SkScalar vy, SkScalar scale, bool treatAsBMP) |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 508 | : fPath(path) |
joshualitt | 0fe04a2 | 2015-08-25 12:05:50 -0700 | [diff] [blame] | 509 | , fScale(scale) |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 510 | , fX(vx) |
| 511 | , fY(vy) |
Jim Van Verth | 08576e6 | 2016-11-16 10:15:23 -0500 | [diff] [blame] | 512 | , fTreatAsBMP(treatAsBMP) {} |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 513 | SkPath fPath; |
joshualitt | 0fe04a2 | 2015-08-25 12:05:50 -0700 | [diff] [blame] | 514 | SkScalar fScale; |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 515 | SkScalar fX; |
| 516 | SkScalar fY; |
Jim Van Verth | 08576e6 | 2016-11-16 10:15:23 -0500 | [diff] [blame] | 517 | bool fTreatAsBMP; |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 518 | }; |
| 519 | |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 520 | struct StrokeInfo { |
| 521 | SkScalar fFrameWidth; |
| 522 | SkScalar fMiterLimit; |
| 523 | SkPaint::Join fJoin; |
| 524 | }; |
| 525 | |
| 526 | enum TextType { |
| 527 | kHasDistanceField_TextType = 0x1, |
| 528 | kHasBitmap_TextType = 0x2, |
| 529 | }; |
| 530 | |
| 531 | // all glyph / vertex offsets are into these pools. |
| 532 | unsigned char* fVertices; |
| 533 | GrGlyph** fGlyphs; |
| 534 | Run* fRuns; |
| 535 | GrMemoryPool* fPool; |
| 536 | SkMaskFilter::BlurRec fBlurRec; |
| 537 | StrokeInfo fStrokeInfo; |
| 538 | SkTArray<BigGlyph> fBigGlyphs; |
| 539 | Key fKey; |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 540 | SkMatrix fInitialViewMatrix; |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 541 | SkMatrix fInitialViewMatrixInverse; |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 542 | size_t fSize; |
Jim Van Verth | bc2cdd1 | 2017-06-08 11:14:35 -0400 | [diff] [blame] | 543 | SkColor fLuminanceColor; |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 544 | SkScalar fInitialX; |
| 545 | SkScalar fInitialY; |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 546 | |
| 547 | // We can reuse distance field text, but only if the new viewmatrix would not result in |
| 548 | // a mip change. Because there can be multiple runs in a blob, we track the overall |
| 549 | // maximum minimum scale, and minimum maximum scale, we can support before we need to regen |
| 550 | SkScalar fMaxMinScale; |
| 551 | SkScalar fMinMaxScale; |
| 552 | int fRunCount; |
| 553 | uint8_t fTextType; |
joshualitt | 374b2f7 | 2015-07-21 08:05:03 -0700 | [diff] [blame] | 554 | }; |
| 555 | |
| 556 | #endif |