joshualitt | 259fbf1 | 2015-07-21 11:39:34 -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 | #include "GrAtlasTextBlob.h" |
| 9 | |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 10 | #include "GrBlurUtils.h" |
| 11 | #include "GrContext.h" |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 12 | #include "GrRenderTargetContext.h" |
bsalomon | bb24383 | 2016-07-22 07:10:19 -0700 | [diff] [blame] | 13 | #include "GrPipelineBuilder.h" |
joshualitt | 0a42e68 | 2015-12-10 13:20:58 -0800 | [diff] [blame] | 14 | #include "GrTextUtils.h" |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 15 | #include "SkColorFilter.h" |
| 16 | #include "SkDrawFilter.h" |
joshualitt | e76b4bb3 | 2015-12-28 07:23:58 -0800 | [diff] [blame] | 17 | #include "SkGlyphCache.h" |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 18 | #include "SkTextBlobRunIterator.h" |
| 19 | #include "batches/GrAtlasTextBatch.h" |
| 20 | |
joshualitt | 9230377 | 2016-02-10 11:55:52 -0800 | [diff] [blame] | 21 | GrAtlasTextBlob* GrAtlasTextBlob::Create(GrMemoryPool* pool, int glyphCount, int runCount) { |
| 22 | // We allocate size for the GrAtlasTextBlob itself, plus size for the vertices array, |
| 23 | // and size for the glyphIds array. |
| 24 | size_t verticesCount = glyphCount * kVerticesPerGlyph * kMaxVASize; |
| 25 | size_t size = sizeof(GrAtlasTextBlob) + |
| 26 | verticesCount + |
| 27 | glyphCount * sizeof(GrGlyph**) + |
| 28 | sizeof(GrAtlasTextBlob::Run) * runCount; |
| 29 | |
| 30 | void* allocation = pool->allocate(size); |
| 31 | if (CACHE_SANITY_CHECK) { |
| 32 | sk_bzero(allocation, size); |
| 33 | } |
| 34 | |
| 35 | GrAtlasTextBlob* cacheBlob = new (allocation) GrAtlasTextBlob; |
| 36 | cacheBlob->fSize = size; |
| 37 | |
| 38 | // setup offsets for vertices / glyphs |
| 39 | cacheBlob->fVertices = sizeof(GrAtlasTextBlob) + reinterpret_cast<unsigned char*>(cacheBlob); |
| 40 | cacheBlob->fGlyphs = reinterpret_cast<GrGlyph**>(cacheBlob->fVertices + verticesCount); |
| 41 | cacheBlob->fRuns = reinterpret_cast<GrAtlasTextBlob::Run*>(cacheBlob->fGlyphs + glyphCount); |
| 42 | |
| 43 | // Initialize runs |
| 44 | for (int i = 0; i < runCount; i++) { |
| 45 | new (&cacheBlob->fRuns[i]) GrAtlasTextBlob::Run; |
| 46 | } |
| 47 | cacheBlob->fRunCount = runCount; |
| 48 | cacheBlob->fPool = pool; |
| 49 | return cacheBlob; |
| 50 | } |
| 51 | |
joshualitt | e76b4bb3 | 2015-12-28 07:23:58 -0800 | [diff] [blame] | 52 | SkGlyphCache* GrAtlasTextBlob::setupCache(int runIndex, |
| 53 | const SkSurfaceProps& props, |
brianosman | a1e8f8d | 2016-04-08 06:47:54 -0700 | [diff] [blame] | 54 | uint32_t scalerContextFlags, |
joshualitt | e76b4bb3 | 2015-12-28 07:23:58 -0800 | [diff] [blame] | 55 | const SkPaint& skPaint, |
bungeman | f6d1e60 | 2016-02-22 13:20:28 -0800 | [diff] [blame] | 56 | const SkMatrix* viewMatrix) { |
joshualitt | e76b4bb3 | 2015-12-28 07:23:58 -0800 | [diff] [blame] | 57 | GrAtlasTextBlob::Run* run = &fRuns[runIndex]; |
| 58 | |
| 59 | // if we have an override descriptor for the run, then we should use that |
| 60 | SkAutoDescriptor* desc = run->fOverrideDescriptor.get() ? run->fOverrideDescriptor.get() : |
| 61 | &run->fDescriptor; |
bsalomon | 8b6fa5e | 2016-05-19 16:23:47 -0700 | [diff] [blame] | 62 | SkScalerContextEffects effects; |
| 63 | skPaint.getScalerContextDescriptor(&effects, desc, props, scalerContextFlags, viewMatrix); |
joshualitt | e76b4bb3 | 2015-12-28 07:23:58 -0800 | [diff] [blame] | 64 | run->fTypeface.reset(SkSafeRef(skPaint.getTypeface())); |
bsalomon | 8b6fa5e | 2016-05-19 16:23:47 -0700 | [diff] [blame] | 65 | run->fPathEffect = sk_ref_sp(effects.fPathEffect); |
| 66 | run->fRasterizer = sk_ref_sp(effects.fRasterizer); |
| 67 | run->fMaskFilter = sk_ref_sp(effects.fMaskFilter); |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame^] | 68 | return SkGlyphCache::DetachCache(run->fTypeface.get(), effects, desc->getDesc()); |
joshualitt | e76b4bb3 | 2015-12-28 07:23:58 -0800 | [diff] [blame] | 69 | } |
| 70 | |
joshualitt | f528e0d | 2015-12-09 06:42:52 -0800 | [diff] [blame] | 71 | void GrAtlasTextBlob::appendGlyph(int runIndex, |
| 72 | const SkRect& positions, |
| 73 | GrColor color, |
| 74 | GrBatchTextStrike* strike, |
joshualitt | a06e6ab | 2015-12-10 08:54:41 -0800 | [diff] [blame] | 75 | GrGlyph* glyph, |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 76 | SkGlyphCache* cache, const SkGlyph& skGlyph, |
joshualitt | a06e6ab | 2015-12-10 08:54:41 -0800 | [diff] [blame] | 77 | SkScalar x, SkScalar y, SkScalar scale, bool applyVM) { |
| 78 | |
| 79 | // If the glyph is too large we fall back to paths |
| 80 | if (glyph->fTooLargeForAtlas) { |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 81 | this->appendLargeGlyph(glyph, cache, skGlyph, x, y, scale, applyVM); |
joshualitt | a06e6ab | 2015-12-10 08:54:41 -0800 | [diff] [blame] | 82 | return; |
| 83 | } |
| 84 | |
joshualitt | f528e0d | 2015-12-09 06:42:52 -0800 | [diff] [blame] | 85 | Run& run = fRuns[runIndex]; |
| 86 | GrMaskFormat format = glyph->fMaskFormat; |
| 87 | |
| 88 | Run::SubRunInfo* subRun = &run.fSubRunInfo.back(); |
| 89 | if (run.fInitialized && subRun->maskFormat() != format) { |
| 90 | subRun = &run.push_back(); |
| 91 | subRun->setStrike(strike); |
| 92 | } else if (!run.fInitialized) { |
| 93 | subRun->setStrike(strike); |
| 94 | } |
| 95 | |
| 96 | run.fInitialized = true; |
| 97 | |
| 98 | size_t vertexStride = GetVertexStride(format); |
| 99 | |
| 100 | subRun->setMaskFormat(format); |
| 101 | |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 102 | subRun->joinGlyphBounds(positions); |
joshualitt | f9e658b | 2015-12-09 09:26:44 -0800 | [diff] [blame] | 103 | subRun->setColor(color); |
joshualitt | 18b072d | 2015-12-07 12:26:12 -0800 | [diff] [blame] | 104 | |
| 105 | intptr_t vertex = reinterpret_cast<intptr_t>(this->fVertices + subRun->vertexEndIndex()); |
| 106 | |
joshualitt | f528e0d | 2015-12-09 06:42:52 -0800 | [diff] [blame] | 107 | if (kARGB_GrMaskFormat != glyph->fMaskFormat) { |
joshualitt | 18b072d | 2015-12-07 12:26:12 -0800 | [diff] [blame] | 108 | // V0 |
| 109 | SkPoint* position = reinterpret_cast<SkPoint*>(vertex); |
| 110 | position->set(positions.fLeft, positions.fTop); |
| 111 | SkColor* colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); |
| 112 | *colorPtr = color; |
| 113 | vertex += vertexStride; |
| 114 | |
| 115 | // V1 |
| 116 | position = reinterpret_cast<SkPoint*>(vertex); |
| 117 | position->set(positions.fLeft, positions.fBottom); |
| 118 | colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); |
| 119 | *colorPtr = color; |
| 120 | vertex += vertexStride; |
| 121 | |
| 122 | // V2 |
| 123 | position = reinterpret_cast<SkPoint*>(vertex); |
| 124 | position->set(positions.fRight, positions.fBottom); |
| 125 | colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); |
| 126 | *colorPtr = color; |
| 127 | vertex += vertexStride; |
| 128 | |
| 129 | // V3 |
| 130 | position = reinterpret_cast<SkPoint*>(vertex); |
| 131 | position->set(positions.fRight, positions.fTop); |
| 132 | colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)); |
| 133 | *colorPtr = color; |
| 134 | } else { |
| 135 | // V0 |
| 136 | SkPoint* position = reinterpret_cast<SkPoint*>(vertex); |
| 137 | position->set(positions.fLeft, positions.fTop); |
| 138 | vertex += vertexStride; |
| 139 | |
| 140 | // V1 |
| 141 | position = reinterpret_cast<SkPoint*>(vertex); |
| 142 | position->set(positions.fLeft, positions.fBottom); |
| 143 | vertex += vertexStride; |
| 144 | |
| 145 | // V2 |
| 146 | position = reinterpret_cast<SkPoint*>(vertex); |
| 147 | position->set(positions.fRight, positions.fBottom); |
| 148 | vertex += vertexStride; |
| 149 | |
| 150 | // V3 |
| 151 | position = reinterpret_cast<SkPoint*>(vertex); |
| 152 | position->set(positions.fRight, positions.fTop); |
| 153 | } |
| 154 | subRun->appendVertices(vertexStride); |
| 155 | fGlyphs[subRun->glyphEndIndex()] = glyph; |
| 156 | subRun->glyphAppended(); |
| 157 | } |
| 158 | |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 159 | void GrAtlasTextBlob::appendLargeGlyph(GrGlyph* glyph, SkGlyphCache* cache, const SkGlyph& skGlyph, |
joshualitt | a06e6ab | 2015-12-10 08:54:41 -0800 | [diff] [blame] | 160 | SkScalar x, SkScalar y, SkScalar scale, bool applyVM) { |
| 161 | if (nullptr == glyph->fPath) { |
bsalomon | c2878e2 | 2016-05-17 13:18:03 -0700 | [diff] [blame] | 162 | const SkPath* glyphPath = cache->findPath(skGlyph); |
joshualitt | a06e6ab | 2015-12-10 08:54:41 -0800 | [diff] [blame] | 163 | if (!glyphPath) { |
| 164 | return; |
| 165 | } |
| 166 | |
| 167 | glyph->fPath = new SkPath(*glyphPath); |
| 168 | } |
| 169 | fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, scale, applyVM)); |
| 170 | } |
| 171 | |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 172 | bool GrAtlasTextBlob::mustRegenerate(const SkPaint& paint, |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 173 | GrColor color, const SkMaskFilter::BlurRec& blurRec, |
| 174 | const SkMatrix& viewMatrix, SkScalar x, SkScalar y) { |
| 175 | // If we have LCD text then our canonical color will be set to transparent, in this case we have |
| 176 | // to regenerate the blob on any color change |
| 177 | // We use the grPaint to get any color filter effects |
| 178 | if (fKey.fCanonicalColor == SK_ColorTRANSPARENT && |
| 179 | fPaintColor != color) { |
| 180 | return true; |
| 181 | } |
| 182 | |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 183 | if (fInitialViewMatrix.hasPerspective() != viewMatrix.hasPerspective()) { |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 184 | return true; |
| 185 | } |
| 186 | |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 187 | if (fInitialViewMatrix.hasPerspective() && !fInitialViewMatrix.cheapEqualTo(viewMatrix)) { |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 188 | return true; |
| 189 | } |
| 190 | |
| 191 | // We only cache one masked version |
| 192 | if (fKey.fHasBlur && |
| 193 | (fBlurRec.fSigma != blurRec.fSigma || |
| 194 | fBlurRec.fStyle != blurRec.fStyle || |
| 195 | fBlurRec.fQuality != blurRec.fQuality)) { |
| 196 | return true; |
| 197 | } |
| 198 | |
| 199 | // Similarly, we only cache one version for each style |
| 200 | if (fKey.fStyle != SkPaint::kFill_Style && |
| 201 | (fStrokeInfo.fFrameWidth != paint.getStrokeWidth() || |
| 202 | fStrokeInfo.fMiterLimit != paint.getStrokeMiter() || |
| 203 | fStrokeInfo.fJoin != paint.getStrokeJoin())) { |
| 204 | return true; |
| 205 | } |
| 206 | |
| 207 | // Mixed blobs must be regenerated. We could probably figure out a way to do integer scrolls |
| 208 | // for mixed blobs if this becomes an issue. |
| 209 | if (this->hasBitmap() && this->hasDistanceField()) { |
| 210 | // Identical viewmatrices and we can reuse in all cases |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 211 | if (fInitialViewMatrix.cheapEqualTo(viewMatrix) && x == fInitialX && y == fInitialY) { |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 212 | return false; |
| 213 | } |
| 214 | return true; |
| 215 | } |
| 216 | |
| 217 | if (this->hasBitmap()) { |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 218 | if (fInitialViewMatrix.getScaleX() != viewMatrix.getScaleX() || |
| 219 | fInitialViewMatrix.getScaleY() != viewMatrix.getScaleY() || |
| 220 | fInitialViewMatrix.getSkewX() != viewMatrix.getSkewX() || |
| 221 | fInitialViewMatrix.getSkewY() != viewMatrix.getSkewY()) { |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 222 | return true; |
| 223 | } |
| 224 | |
| 225 | // We can update the positions in the cachedtextblobs without regenerating the whole blob, |
| 226 | // but only for integer translations. |
| 227 | // This cool bit of math will determine the necessary translation to apply to the already |
| 228 | // generated vertex coordinates to move them to the correct position |
| 229 | SkScalar transX = viewMatrix.getTranslateX() + |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 230 | viewMatrix.getScaleX() * (x - fInitialX) + |
| 231 | viewMatrix.getSkewX() * (y - fInitialY) - |
| 232 | fInitialViewMatrix.getTranslateX(); |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 233 | SkScalar transY = viewMatrix.getTranslateY() + |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 234 | viewMatrix.getSkewY() * (x - fInitialX) + |
| 235 | viewMatrix.getScaleY() * (y - fInitialY) - |
| 236 | fInitialViewMatrix.getTranslateY(); |
| 237 | if (!SkScalarIsInt(transX) || !SkScalarIsInt(transY)) { |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 238 | return true; |
| 239 | } |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 240 | } else if (this->hasDistanceField()) { |
| 241 | // A scale outside of [blob.fMaxMinScale, blob.fMinMaxScale] would result in a different |
| 242 | // distance field being generated, so we have to regenerate in those cases |
| 243 | SkScalar newMaxScale = viewMatrix.getMaxScale(); |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 244 | SkScalar oldMaxScale = fInitialViewMatrix.getMaxScale(); |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 245 | SkScalar scaleAdjust = newMaxScale / oldMaxScale; |
| 246 | if (scaleAdjust < fMaxMinScale || scaleAdjust > fMinMaxScale) { |
| 247 | return true; |
| 248 | } |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 249 | } |
| 250 | |
joshualitt | fd5f6c1 | 2015-12-10 07:44:50 -0800 | [diff] [blame] | 251 | // It is possible that a blob has neither distanceField nor bitmaptext. This is in the case |
| 252 | // when all of the runs inside the blob are drawn as paths. In this case, we always regenerate |
| 253 | // the blob anyways at flush time, so no need to regenerate explicitly |
| 254 | return false; |
| 255 | } |
| 256 | |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 257 | inline GrDrawBatch* GrAtlasTextBlob::createBatch( |
| 258 | const Run::SubRunInfo& info, |
| 259 | int glyphCount, int run, int subRun, |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 260 | const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
| 261 | GrColor color, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 262 | const SkPaint& skPaint, const SkSurfaceProps& props, |
| 263 | const GrDistanceFieldAdjustTable* distanceAdjustTable, |
brianosman | b461d34 | 2016-04-13 13:10:14 -0700 | [diff] [blame] | 264 | bool useGammaCorrectDistanceTable, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 265 | GrBatchFontCache* cache) { |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 266 | GrMaskFormat format = info.maskFormat(); |
| 267 | GrColor subRunColor; |
| 268 | if (kARGB_GrMaskFormat == format) { |
| 269 | uint8_t paintAlpha = skPaint.getAlpha(); |
| 270 | subRunColor = SkColorSetARGB(paintAlpha, paintAlpha, paintAlpha, paintAlpha); |
| 271 | } else { |
| 272 | subRunColor = color; |
| 273 | } |
| 274 | |
| 275 | GrAtlasTextBatch* batch; |
| 276 | if (info.drawAsDistanceFields()) { |
| 277 | SkColor filteredColor; |
| 278 | SkColorFilter* colorFilter = skPaint.getColorFilter(); |
| 279 | if (colorFilter) { |
| 280 | filteredColor = colorFilter->filterColor(skPaint.getColor()); |
| 281 | } else { |
| 282 | filteredColor = skPaint.getColor(); |
| 283 | } |
| 284 | bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); |
| 285 | batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache, |
brianosman | b461d34 | 2016-04-13 13:10:14 -0700 | [diff] [blame] | 286 | distanceAdjustTable, |
| 287 | useGammaCorrectDistanceTable, |
brianosman | 0586f5c | 2016-04-12 12:48:21 -0700 | [diff] [blame] | 288 | filteredColor, info.hasUseLCDText(), useBGR); |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 289 | } else { |
| 290 | batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache); |
| 291 | } |
| 292 | GrAtlasTextBatch::Geometry& geometry = batch->geometry(); |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 293 | geometry.fViewMatrix = viewMatrix; |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 294 | geometry.fBlob = SkRef(this); |
| 295 | geometry.fRun = run; |
| 296 | geometry.fSubRun = subRun; |
| 297 | geometry.fColor = subRunColor; |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 298 | geometry.fX = x; |
| 299 | geometry.fY = y; |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 300 | batch->init(); |
| 301 | |
| 302 | return batch; |
| 303 | } |
| 304 | |
| 305 | inline |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 306 | void GrAtlasTextBlob::flushRun(GrRenderTargetContext* rtc, const GrPaint& grPaint, |
cdalton | 862cff3 | 2016-05-12 15:09:48 -0700 | [diff] [blame] | 307 | const GrClip& clip, int run, const SkMatrix& viewMatrix, SkScalar x, |
robertphillips | 640789d | 2016-07-18 14:56:06 -0700 | [diff] [blame] | 308 | SkScalar y, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 309 | const SkPaint& skPaint, const SkSurfaceProps& props, |
| 310 | const GrDistanceFieldAdjustTable* distanceAdjustTable, |
| 311 | GrBatchFontCache* cache) { |
| 312 | for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) { |
| 313 | const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; |
| 314 | int glyphCount = info.glyphCount(); |
| 315 | if (0 == glyphCount) { |
| 316 | continue; |
| 317 | } |
| 318 | |
robertphillips | 640789d | 2016-07-18 14:56:06 -0700 | [diff] [blame] | 319 | GrColor color = grPaint.getColor(); |
| 320 | |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame^] | 321 | sk_sp<GrDrawBatch> batch(this->createBatch(info, glyphCount, run, |
| 322 | subRun, viewMatrix, x, y, color, |
| 323 | skPaint, props, |
| 324 | distanceAdjustTable, |
| 325 | rtc->isGammaCorrect(), |
| 326 | cache)); |
robertphillips | 640789d | 2016-07-18 14:56:06 -0700 | [diff] [blame] | 327 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 328 | GrPipelineBuilder pipelineBuilder(grPaint, rtc->mustUseHWAA(grPaint)); |
bsalomon | bb24383 | 2016-07-22 07:10:19 -0700 | [diff] [blame] | 329 | |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame^] | 330 | rtc->drawBatch(pipelineBuilder, clip, batch.get()); |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 331 | } |
| 332 | } |
| 333 | |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 334 | static void calculate_translation(bool applyVM, |
| 335 | const SkMatrix& newViewMatrix, SkScalar newX, SkScalar newY, |
| 336 | const SkMatrix& currentViewMatrix, SkScalar currentX, |
| 337 | SkScalar currentY, SkScalar* transX, SkScalar* transY) { |
| 338 | if (applyVM) { |
| 339 | *transX = newViewMatrix.getTranslateX() + |
| 340 | newViewMatrix.getScaleX() * (newX - currentX) + |
| 341 | newViewMatrix.getSkewX() * (newY - currentY) - |
| 342 | currentViewMatrix.getTranslateX(); |
| 343 | |
| 344 | *transY = newViewMatrix.getTranslateY() + |
| 345 | newViewMatrix.getSkewY() * (newX - currentX) + |
| 346 | newViewMatrix.getScaleY() * (newY - currentY) - |
| 347 | currentViewMatrix.getTranslateY(); |
| 348 | } else { |
| 349 | *transX = newX - currentX; |
| 350 | *transY = newY - currentY; |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 355 | void GrAtlasTextBlob::flushBigGlyphs(GrContext* context, GrRenderTargetContext* rtc, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 356 | const GrClip& clip, const SkPaint& skPaint, |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 357 | const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 358 | const SkIRect& clipBounds) { |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 359 | SkScalar transX, transY; |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 360 | for (int i = 0; i < fBigGlyphs.count(); i++) { |
| 361 | GrAtlasTextBlob::BigGlyph& bigGlyph = fBigGlyphs[i]; |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 362 | calculate_translation(bigGlyph.fApplyVM, viewMatrix, x, y, |
| 363 | fInitialViewMatrix, fInitialX, fInitialY, &transX, &transY); |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 364 | SkMatrix ctm; |
| 365 | ctm.setScale(bigGlyph.fScale, bigGlyph.fScale); |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 366 | ctm.postTranslate(bigGlyph.fX + transX, bigGlyph.fY + transY); |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 367 | if (bigGlyph.fApplyVM) { |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 368 | ctm.postConcat(viewMatrix); |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 369 | } |
| 370 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 371 | GrBlurUtils::drawPathWithMaskFilter(context, rtc, clip, bigGlyph.fPath, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 372 | skPaint, ctm, nullptr, clipBounds, false); |
| 373 | } |
| 374 | } |
| 375 | |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 376 | void GrAtlasTextBlob::flushRunAsPaths(GrContext* context, GrRenderTargetContext* rtc, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 377 | const SkSurfaceProps& props, |
| 378 | const SkTextBlobRunIterator& it, |
| 379 | const GrClip& clip, const SkPaint& skPaint, |
| 380 | SkDrawFilter* drawFilter, const SkMatrix& viewMatrix, |
| 381 | const SkIRect& clipBounds, SkScalar x, SkScalar y) { |
| 382 | SkPaint runPaint = skPaint; |
| 383 | |
| 384 | size_t textLen = it.glyphCount() * sizeof(uint16_t); |
| 385 | const SkPoint& offset = it.offset(); |
| 386 | |
| 387 | it.applyFontToPaint(&runPaint); |
| 388 | |
| 389 | if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Type)) { |
| 390 | return; |
| 391 | } |
| 392 | |
joshualitt | 8e84a1e | 2016-02-16 11:09:25 -0800 | [diff] [blame] | 393 | runPaint.setFlags(GrTextUtils::FilterTextFlags(props, runPaint)); |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 394 | |
| 395 | switch (it.positioning()) { |
| 396 | case SkTextBlob::kDefault_Positioning: |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 397 | GrTextUtils::DrawTextAsPath(context, rtc, clip, runPaint, viewMatrix, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 398 | (const char *)it.glyphs(), |
| 399 | textLen, x + offset.x(), y + offset.y(), clipBounds); |
| 400 | break; |
| 401 | case SkTextBlob::kHorizontal_Positioning: |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 402 | GrTextUtils::DrawPosTextAsPath(context, rtc, props, clip, runPaint, viewMatrix, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 403 | (const char*)it.glyphs(), |
| 404 | textLen, it.pos(), 1, SkPoint::Make(x, y + offset.y()), |
| 405 | clipBounds); |
| 406 | break; |
| 407 | case SkTextBlob::kFull_Positioning: |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 408 | GrTextUtils::DrawPosTextAsPath(context, rtc, props, clip, runPaint, viewMatrix, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 409 | (const char*)it.glyphs(), |
| 410 | textLen, it.pos(), 2, SkPoint::Make(x, y), clipBounds); |
| 411 | break; |
| 412 | } |
| 413 | } |
| 414 | |
joshualitt | 0a42e68 | 2015-12-10 13:20:58 -0800 | [diff] [blame] | 415 | void GrAtlasTextBlob::flushCached(GrContext* context, |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 416 | GrRenderTargetContext* rtc, |
joshualitt | 0a42e68 | 2015-12-10 13:20:58 -0800 | [diff] [blame] | 417 | const SkTextBlob* blob, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 418 | const SkSurfaceProps& props, |
| 419 | const GrDistanceFieldAdjustTable* distanceAdjustTable, |
| 420 | const SkPaint& skPaint, |
| 421 | const GrPaint& grPaint, |
| 422 | SkDrawFilter* drawFilter, |
| 423 | const GrClip& clip, |
| 424 | const SkMatrix& viewMatrix, |
| 425 | const SkIRect& clipBounds, |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 426 | SkScalar x, SkScalar y) { |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 427 | // We loop through the runs of the blob, flushing each. If any run is too large, then we flush |
| 428 | // it as paths |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 429 | SkTextBlobRunIterator it(blob); |
| 430 | for (int run = 0; !it.done(); it.next(), run++) { |
| 431 | if (fRuns[run].fDrawAsPaths) { |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 432 | this->flushRunAsPaths(context, rtc, props, it, clip, skPaint, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 433 | drawFilter, viewMatrix, clipBounds, x, y); |
| 434 | continue; |
| 435 | } |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 436 | this->flushRun(rtc, grPaint, clip, run, viewMatrix, x, y, skPaint, props, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 437 | distanceAdjustTable, context->getBatchFontCache()); |
| 438 | } |
| 439 | |
| 440 | // Now flush big glyphs |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 441 | this->flushBigGlyphs(context, rtc, clip, skPaint, viewMatrix, x, y, clipBounds); |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | void GrAtlasTextBlob::flushThrowaway(GrContext* context, |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 445 | GrRenderTargetContext* rtc, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 446 | const SkSurfaceProps& props, |
| 447 | const GrDistanceFieldAdjustTable* distanceAdjustTable, |
| 448 | const SkPaint& skPaint, |
| 449 | const GrPaint& grPaint, |
| 450 | const GrClip& clip, |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 451 | const SkMatrix& viewMatrix, |
| 452 | const SkIRect& clipBounds, |
| 453 | SkScalar x, SkScalar y) { |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 454 | for (int run = 0; run < fRunCount; run++) { |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 455 | this->flushRun(rtc, grPaint, clip, run, viewMatrix, x, y, skPaint, props, |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 456 | distanceAdjustTable, context->getBatchFontCache()); |
| 457 | } |
| 458 | |
| 459 | // Now flush big glyphs |
Brian Osman | 1105224 | 2016-10-27 14:47:55 -0400 | [diff] [blame] | 460 | this->flushBigGlyphs(context, rtc, clip, skPaint, viewMatrix, x, y, clipBounds); |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 461 | } |
| 462 | |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 463 | GrDrawBatch* GrAtlasTextBlob::test_createBatch( |
| 464 | int glyphCount, int run, int subRun, |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 465 | const SkMatrix& viewMatrix, SkScalar x, SkScalar y, |
| 466 | GrColor color, |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 467 | const SkPaint& skPaint, const SkSurfaceProps& props, |
| 468 | const GrDistanceFieldAdjustTable* distanceAdjustTable, |
| 469 | GrBatchFontCache* cache) { |
joshualitt | 7481e75 | 2016-01-22 06:08:48 -0800 | [diff] [blame] | 470 | const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 471 | return this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, color, skPaint, |
brianosman | 0586f5c | 2016-04-12 12:48:21 -0700 | [diff] [blame] | 472 | props, distanceAdjustTable, false, cache); |
joshualitt | 323c2eb | 2016-01-20 06:48:47 -0800 | [diff] [blame] | 473 | } |
joshualitt | 2e2202e | 2015-12-10 11:22:08 -0800 | [diff] [blame] | 474 | |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 475 | void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlob& r) { |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 476 | SkASSERT_RELEASE(l.fSize == r.fSize); |
| 477 | SkASSERT_RELEASE(l.fPool == r.fPool); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 478 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 479 | SkASSERT_RELEASE(l.fBlurRec.fSigma == r.fBlurRec.fSigma); |
| 480 | SkASSERT_RELEASE(l.fBlurRec.fStyle == r.fBlurRec.fStyle); |
| 481 | SkASSERT_RELEASE(l.fBlurRec.fQuality == r.fBlurRec.fQuality); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 482 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 483 | SkASSERT_RELEASE(l.fStrokeInfo.fFrameWidth == r.fStrokeInfo.fFrameWidth); |
| 484 | SkASSERT_RELEASE(l.fStrokeInfo.fMiterLimit == r.fStrokeInfo.fMiterLimit); |
| 485 | SkASSERT_RELEASE(l.fStrokeInfo.fJoin == r.fStrokeInfo.fJoin); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 486 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 487 | SkASSERT_RELEASE(l.fBigGlyphs.count() == r.fBigGlyphs.count()); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 488 | for (int i = 0; i < l.fBigGlyphs.count(); i++) { |
| 489 | const BigGlyph& lBigGlyph = l.fBigGlyphs[i]; |
| 490 | const BigGlyph& rBigGlyph = r.fBigGlyphs[i]; |
| 491 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 492 | SkASSERT_RELEASE(lBigGlyph.fPath == rBigGlyph.fPath); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 493 | // We can't assert that these have the same translations |
| 494 | } |
| 495 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 496 | SkASSERT_RELEASE(l.fKey == r.fKey); |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 497 | //SkASSERT_RELEASE(l.fPaintColor == r.fPaintColor); // Colors might not actually be identical |
| 498 | SkASSERT_RELEASE(l.fMaxMinScale == r.fMaxMinScale); |
| 499 | SkASSERT_RELEASE(l.fMinMaxScale == r.fMinMaxScale); |
| 500 | SkASSERT_RELEASE(l.fTextType == r.fTextType); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 501 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 502 | SkASSERT_RELEASE(l.fRunCount == r.fRunCount); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 503 | for (int i = 0; i < l.fRunCount; i++) { |
| 504 | const Run& lRun = l.fRuns[i]; |
| 505 | const Run& rRun = r.fRuns[i]; |
| 506 | |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 507 | if (lRun.fTypeface.get()) { |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 508 | SkASSERT_RELEASE(rRun.fTypeface.get()); |
Hal Canary | 144caf5 | 2016-11-07 17:57:18 -0500 | [diff] [blame^] | 509 | SkASSERT_RELEASE(SkTypeface::Equal(lRun.fTypeface.get(), rRun.fTypeface.get())); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 510 | } else { |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 511 | SkASSERT_RELEASE(!rRun.fTypeface.get()); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 512 | } |
| 513 | |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 514 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 515 | SkASSERT_RELEASE(lRun.fDescriptor.getDesc()); |
| 516 | SkASSERT_RELEASE(rRun.fDescriptor.getDesc()); |
bsalomon | c5d07fa | 2016-05-17 10:17:45 -0700 | [diff] [blame] | 517 | SkASSERT_RELEASE(*lRun.fDescriptor.getDesc() == *rRun.fDescriptor.getDesc()); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 518 | |
| 519 | if (lRun.fOverrideDescriptor.get()) { |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 520 | SkASSERT_RELEASE(lRun.fOverrideDescriptor->getDesc()); |
| 521 | SkASSERT_RELEASE(rRun.fOverrideDescriptor.get() && rRun.fOverrideDescriptor->getDesc()); |
bsalomon | c5d07fa | 2016-05-17 10:17:45 -0700 | [diff] [blame] | 522 | SkASSERT_RELEASE(*lRun.fOverrideDescriptor->getDesc() == |
| 523 | *rRun.fOverrideDescriptor->getDesc()); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 524 | } else { |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 525 | SkASSERT_RELEASE(!rRun.fOverrideDescriptor.get()); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 526 | } |
| 527 | |
| 528 | // color can be changed |
| 529 | //SkASSERT(lRun.fColor == rRun.fColor); |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 530 | SkASSERT_RELEASE(lRun.fInitialized == rRun.fInitialized); |
| 531 | SkASSERT_RELEASE(lRun.fDrawAsPaths == rRun.fDrawAsPaths); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 532 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 533 | SkASSERT_RELEASE(lRun.fSubRunInfo.count() == rRun.fSubRunInfo.count()); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 534 | for(int j = 0; j < lRun.fSubRunInfo.count(); j++) { |
| 535 | const Run::SubRunInfo& lSubRun = lRun.fSubRunInfo[j]; |
| 536 | const Run::SubRunInfo& rSubRun = rRun.fSubRunInfo[j]; |
| 537 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 538 | // TODO we can do this check, but we have to apply the VM to the old vertex bounds |
| 539 | //SkASSERT_RELEASE(lSubRun.vertexBounds() == rSubRun.vertexBounds()); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 540 | |
joshualitt | 2f2ee83 | 2016-02-10 08:52:24 -0800 | [diff] [blame] | 541 | if (lSubRun.strike()) { |
| 542 | SkASSERT_RELEASE(rSubRun.strike()); |
| 543 | SkASSERT_RELEASE(GrBatchTextStrike::GetKey(*lSubRun.strike()) == |
| 544 | GrBatchTextStrike::GetKey(*rSubRun.strike())); |
| 545 | |
| 546 | } else { |
| 547 | SkASSERT_RELEASE(!rSubRun.strike()); |
| 548 | } |
| 549 | |
| 550 | SkASSERT_RELEASE(lSubRun.vertexStartIndex() == rSubRun.vertexStartIndex()); |
| 551 | SkASSERT_RELEASE(lSubRun.vertexEndIndex() == rSubRun.vertexEndIndex()); |
| 552 | SkASSERT_RELEASE(lSubRun.glyphStartIndex() == rSubRun.glyphStartIndex()); |
| 553 | SkASSERT_RELEASE(lSubRun.glyphEndIndex() == rSubRun.glyphEndIndex()); |
| 554 | SkASSERT_RELEASE(lSubRun.maskFormat() == rSubRun.maskFormat()); |
| 555 | SkASSERT_RELEASE(lSubRun.drawAsDistanceFields() == rSubRun.drawAsDistanceFields()); |
| 556 | SkASSERT_RELEASE(lSubRun.hasUseLCDText() == rSubRun.hasUseLCDText()); |
joshualitt | 259fbf1 | 2015-07-21 11:39:34 -0700 | [diff] [blame] | 557 | } |
| 558 | } |
| 559 | } |
joshualitt | 8e0ef29 | 2016-02-19 14:13:03 -0800 | [diff] [blame] | 560 | |
| 561 | void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMatrix, |
| 562 | SkScalar x, SkScalar y, SkScalar* transX, |
| 563 | SkScalar* transY) { |
| 564 | calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, |
| 565 | fCurrentViewMatrix, fX, fY, transX, transY); |
| 566 | fCurrentViewMatrix = viewMatrix; |
| 567 | fX = x; |
| 568 | fY = y; |
| 569 | } |