| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "GrAtlasTextBlob.h" | 8 #include "GrAtlasTextBlob.h" |
| 9 | 9 |
| 10 #include "GrBlurUtils.h" | 10 #include "GrBlurUtils.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 const SkPath* glyphPath = scaler->getGlyphPath(skGlyph); | 158 const SkPath* glyphPath = scaler->getGlyphPath(skGlyph); |
| 159 if (!glyphPath) { | 159 if (!glyphPath) { |
| 160 return; | 160 return; |
| 161 } | 161 } |
| 162 | 162 |
| 163 glyph->fPath = new SkPath(*glyphPath); | 163 glyph->fPath = new SkPath(*glyphPath); |
| 164 } | 164 } |
| 165 fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, scale, a
pplyVM)); | 165 fBigGlyphs.push_back(GrAtlasTextBlob::BigGlyph(*glyph->fPath, x, y, scale, a
pplyVM)); |
| 166 } | 166 } |
| 167 | 167 |
| 168 bool GrAtlasTextBlob::mustRegenerate(SkScalar* outTransX, SkScalar* outTransY, | 168 bool GrAtlasTextBlob::mustRegenerate(const SkPaint& paint, |
| 169 const SkPaint& paint, | |
| 170 GrColor color, const SkMaskFilter::BlurRec&
blurRec, | 169 GrColor color, const SkMaskFilter::BlurRec&
blurRec, |
| 171 const SkMatrix& viewMatrix, SkScalar x, SkS
calar y) { | 170 const SkMatrix& viewMatrix, SkScalar x, SkS
calar y) { |
| 172 // If we have LCD text then our canonical color will be set to transparent,
in this case we have | 171 // If we have LCD text then our canonical color will be set to transparent,
in this case we have |
| 173 // to regenerate the blob on any color change | 172 // to regenerate the blob on any color change |
| 174 // We use the grPaint to get any color filter effects | 173 // We use the grPaint to get any color filter effects |
| 175 if (fKey.fCanonicalColor == SK_ColorTRANSPARENT && | 174 if (fKey.fCanonicalColor == SK_ColorTRANSPARENT && |
| 176 fPaintColor != color) { | 175 fPaintColor != color) { |
| 177 return true; | 176 return true; |
| 178 } | 177 } |
| 179 | 178 |
| 180 if (fViewMatrix.hasPerspective() != viewMatrix.hasPerspective()) { | 179 if (fInitialViewMatrix.hasPerspective() != viewMatrix.hasPerspective()) { |
| 181 return true; | 180 return true; |
| 182 } | 181 } |
| 183 | 182 |
| 184 if (fViewMatrix.hasPerspective() && !fViewMatrix.cheapEqualTo(viewMatrix)) { | 183 if (fInitialViewMatrix.hasPerspective() && !fInitialViewMatrix.cheapEqualTo(
viewMatrix)) { |
| 185 return true; | 184 return true; |
| 186 } | 185 } |
| 187 | 186 |
| 188 // We only cache one masked version | 187 // We only cache one masked version |
| 189 if (fKey.fHasBlur && | 188 if (fKey.fHasBlur && |
| 190 (fBlurRec.fSigma != blurRec.fSigma || | 189 (fBlurRec.fSigma != blurRec.fSigma || |
| 191 fBlurRec.fStyle != blurRec.fStyle || | 190 fBlurRec.fStyle != blurRec.fStyle || |
| 192 fBlurRec.fQuality != blurRec.fQuality)) { | 191 fBlurRec.fQuality != blurRec.fQuality)) { |
| 193 return true; | 192 return true; |
| 194 } | 193 } |
| 195 | 194 |
| 196 // Similarly, we only cache one version for each style | 195 // Similarly, we only cache one version for each style |
| 197 if (fKey.fStyle != SkPaint::kFill_Style && | 196 if (fKey.fStyle != SkPaint::kFill_Style && |
| 198 (fStrokeInfo.fFrameWidth != paint.getStrokeWidth() || | 197 (fStrokeInfo.fFrameWidth != paint.getStrokeWidth() || |
| 199 fStrokeInfo.fMiterLimit != paint.getStrokeMiter() || | 198 fStrokeInfo.fMiterLimit != paint.getStrokeMiter() || |
| 200 fStrokeInfo.fJoin != paint.getStrokeJoin())) { | 199 fStrokeInfo.fJoin != paint.getStrokeJoin())) { |
| 201 return true; | 200 return true; |
| 202 } | 201 } |
| 203 | 202 |
| 204 // Mixed blobs must be regenerated. We could probably figure out a way to d
o integer scrolls | 203 // Mixed blobs must be regenerated. We could probably figure out a way to d
o integer scrolls |
| 205 // for mixed blobs if this becomes an issue. | 204 // for mixed blobs if this becomes an issue. |
| 206 if (this->hasBitmap() && this->hasDistanceField()) { | 205 if (this->hasBitmap() && this->hasDistanceField()) { |
| 207 // Identical viewmatrices and we can reuse in all cases | 206 // Identical viewmatrices and we can reuse in all cases |
| 208 if (fViewMatrix.cheapEqualTo(viewMatrix) && x == fX && y == fY) { | 207 if (fInitialViewMatrix.cheapEqualTo(viewMatrix) && x == fInitialX && y =
= fInitialY) { |
| 209 return false; | 208 return false; |
| 210 } | 209 } |
| 211 return true; | 210 return true; |
| 212 } | 211 } |
| 213 | 212 |
| 214 if (this->hasBitmap()) { | 213 if (this->hasBitmap()) { |
| 215 if (fViewMatrix.getScaleX() != viewMatrix.getScaleX() || | 214 if (fInitialViewMatrix.getScaleX() != viewMatrix.getScaleX() || |
| 216 fViewMatrix.getScaleY() != viewMatrix.getScaleY() || | 215 fInitialViewMatrix.getScaleY() != viewMatrix.getScaleY() || |
| 217 fViewMatrix.getSkewX() != viewMatrix.getSkewX() || | 216 fInitialViewMatrix.getSkewX() != viewMatrix.getSkewX() || |
| 218 fViewMatrix.getSkewY() != viewMatrix.getSkewY()) { | 217 fInitialViewMatrix.getSkewY() != viewMatrix.getSkewY()) { |
| 219 return true; | 218 return true; |
| 220 } | 219 } |
| 221 | 220 |
| 222 // We can update the positions in the cachedtextblobs without regenerati
ng the whole blob, | 221 // We can update the positions in the cachedtextblobs without regenerati
ng the whole blob, |
| 223 // but only for integer translations. | 222 // but only for integer translations. |
| 224 // This cool bit of math will determine the necessary translation to app
ly to the already | 223 // This cool bit of math will determine the necessary translation to app
ly to the already |
| 225 // generated vertex coordinates to move them to the correct position | 224 // generated vertex coordinates to move them to the correct position |
| 226 SkScalar transX = viewMatrix.getTranslateX() + | 225 SkScalar transX = viewMatrix.getTranslateX() + |
| 227 viewMatrix.getScaleX() * (x - fX) + | 226 viewMatrix.getScaleX() * (x - fInitialX) + |
| 228 viewMatrix.getSkewX() * (y - fY) - | 227 viewMatrix.getSkewX() * (y - fInitialY) - |
| 229 fViewMatrix.getTranslateX(); | 228 fInitialViewMatrix.getTranslateX(); |
| 230 SkScalar transY = viewMatrix.getTranslateY() + | 229 SkScalar transY = viewMatrix.getTranslateY() + |
| 231 viewMatrix.getSkewY() * (x - fX) + | 230 viewMatrix.getSkewY() * (x - fInitialX) + |
| 232 viewMatrix.getScaleY() * (y - fY) - | 231 viewMatrix.getScaleY() * (y - fInitialY) - |
| 233 fViewMatrix.getTranslateY(); | 232 fInitialViewMatrix.getTranslateY(); |
| 234 if (!SkScalarIsInt(transX) || !SkScalarIsInt(transY) ) { | 233 if (!SkScalarIsInt(transX) || !SkScalarIsInt(transY)) { |
| 235 return true; | 234 return true; |
| 236 } | 235 } |
| 237 | |
| 238 (*outTransX) = transX; | |
| 239 (*outTransY) = transY; | |
| 240 } else if (this->hasDistanceField()) { | 236 } else if (this->hasDistanceField()) { |
| 241 // A scale outside of [blob.fMaxMinScale, blob.fMinMaxScale] would resul
t in a different | 237 // A scale outside of [blob.fMaxMinScale, blob.fMinMaxScale] would resul
t in a different |
| 242 // distance field being generated, so we have to regenerate in those cas
es | 238 // distance field being generated, so we have to regenerate in those cas
es |
| 243 SkScalar newMaxScale = viewMatrix.getMaxScale(); | 239 SkScalar newMaxScale = viewMatrix.getMaxScale(); |
| 244 SkScalar oldMaxScale = fViewMatrix.getMaxScale(); | 240 SkScalar oldMaxScale = fInitialViewMatrix.getMaxScale(); |
| 245 SkScalar scaleAdjust = newMaxScale / oldMaxScale; | 241 SkScalar scaleAdjust = newMaxScale / oldMaxScale; |
| 246 if (scaleAdjust < fMaxMinScale || scaleAdjust > fMinMaxScale) { | 242 if (scaleAdjust < fMaxMinScale || scaleAdjust > fMinMaxScale) { |
| 247 return true; | 243 return true; |
| 248 } | 244 } |
| 249 | |
| 250 (*outTransX) = x - fX; | |
| 251 (*outTransY) = y - fY; | |
| 252 } | 245 } |
| 253 | 246 |
| 254 // If we can reuse the blob, then make sure we update the blob's viewmatrix,
and x/y | |
| 255 // offsets. Note, we offset the vertex bounds right before flushing | |
| 256 fViewMatrix = viewMatrix; | |
| 257 fX = x; | |
| 258 fY = y; | |
| 259 | |
| 260 // It is possible that a blob has neither distanceField nor bitmaptext. Thi
s is in the case | 247 // It is possible that a blob has neither distanceField nor bitmaptext. Thi
s is in the case |
| 261 // when all of the runs inside the blob are drawn as paths. In this case, w
e always regenerate | 248 // when all of the runs inside the blob are drawn as paths. In this case, w
e always regenerate |
| 262 // the blob anyways at flush time, so no need to regenerate explicitly | 249 // the blob anyways at flush time, so no need to regenerate explicitly |
| 263 return false; | 250 return false; |
| 264 } | 251 } |
| 265 | 252 |
| 266 inline GrDrawBatch* GrAtlasTextBlob::createBatch( | 253 inline GrDrawBatch* GrAtlasTextBlob::createBatch( |
| 267 const Run::SubRunInfo& info, | 254 const Run::SubRunInfo& info, |
| 268 int glyphCount, int run, int subRu
n, | 255 int glyphCount, int run, int subRu
n, |
| 269 GrColor color, SkScalar transX, Sk
Scalar transY, | 256 const SkMatrix& viewMatrix, SkScal
ar x, SkScalar y, |
| 257 GrColor color, |
| 270 const SkPaint& skPaint, const SkSu
rfaceProps& props, | 258 const SkPaint& skPaint, const SkSu
rfaceProps& props, |
| 271 const GrDistanceFieldAdjustTable*
distanceAdjustTable, | 259 const GrDistanceFieldAdjustTable*
distanceAdjustTable, |
| 272 GrBatchFontCache* cache) { | 260 GrBatchFontCache* cache) { |
| 273 GrMaskFormat format = info.maskFormat(); | 261 GrMaskFormat format = info.maskFormat(); |
| 274 GrColor subRunColor; | 262 GrColor subRunColor; |
| 275 if (kARGB_GrMaskFormat == format) { | 263 if (kARGB_GrMaskFormat == format) { |
| 276 uint8_t paintAlpha = skPaint.getAlpha(); | 264 uint8_t paintAlpha = skPaint.getAlpha(); |
| 277 subRunColor = SkColorSetARGB(paintAlpha, paintAlpha, paintAlpha, paintAl
pha); | 265 subRunColor = SkColorSetARGB(paintAlpha, paintAlpha, paintAlpha, paintAl
pha); |
| 278 } else { | 266 } else { |
| 279 subRunColor = color; | 267 subRunColor = color; |
| 280 } | 268 } |
| 281 | 269 |
| 282 GrAtlasTextBatch* batch; | 270 GrAtlasTextBatch* batch; |
| 283 if (info.drawAsDistanceFields()) { | 271 if (info.drawAsDistanceFields()) { |
| 284 SkColor filteredColor; | 272 SkColor filteredColor; |
| 285 SkColorFilter* colorFilter = skPaint.getColorFilter(); | 273 SkColorFilter* colorFilter = skPaint.getColorFilter(); |
| 286 if (colorFilter) { | 274 if (colorFilter) { |
| 287 filteredColor = colorFilter->filterColor(skPaint.getColor()); | 275 filteredColor = colorFilter->filterColor(skPaint.getColor()); |
| 288 } else { | 276 } else { |
| 289 filteredColor = skPaint.getColor(); | 277 filteredColor = skPaint.getColor(); |
| 290 } | 278 } |
| 291 bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); | 279 bool useBGR = SkPixelGeometryIsBGR(props.pixelGeometry()); |
| 292 batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache, | 280 batch = GrAtlasTextBatch::CreateDistanceField(glyphCount, cache, |
| 293 distanceAdjustTable, filte
redColor, | 281 distanceAdjustTable, filte
redColor, |
| 294 info.hasUseLCDText(), useB
GR); | 282 info.hasUseLCDText(), useB
GR); |
| 295 } else { | 283 } else { |
| 296 batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache); | 284 batch = GrAtlasTextBatch::CreateBitmap(format, glyphCount, cache); |
| 297 } | 285 } |
| 298 GrAtlasTextBatch::Geometry& geometry = batch->geometry(); | 286 GrAtlasTextBatch::Geometry& geometry = batch->geometry(); |
| 287 geometry.fViewMatrix = viewMatrix; |
| 299 geometry.fBlob = SkRef(this); | 288 geometry.fBlob = SkRef(this); |
| 300 geometry.fRun = run; | 289 geometry.fRun = run; |
| 301 geometry.fSubRun = subRun; | 290 geometry.fSubRun = subRun; |
| 302 geometry.fColor = subRunColor; | 291 geometry.fColor = subRunColor; |
| 303 geometry.fTransX = transX; | 292 geometry.fX = x; |
| 304 geometry.fTransY = transY; | 293 geometry.fY = y; |
| 305 batch->init(); | 294 batch->init(); |
| 306 | 295 |
| 307 return batch; | 296 return batch; |
| 308 } | 297 } |
| 309 | 298 |
| 310 inline | 299 inline |
| 311 void GrAtlasTextBlob::flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBui
lder, | 300 void GrAtlasTextBlob::flushRun(GrDrawContext* dc, GrPipelineBuilder* pipelineBui
lder, |
| 312 int run, GrColor color, | 301 int run, const SkMatrix& viewMatrix, SkScalar x,
SkScalar y, |
| 313 SkScalar transX, SkScalar transY, | 302 GrColor color, |
| 314 const SkPaint& skPaint, const SkSurfaceProps& pro
ps, | 303 const SkPaint& skPaint, const SkSurfaceProps& pro
ps, |
| 315 const GrDistanceFieldAdjustTable* distanceAdjustT
able, | 304 const GrDistanceFieldAdjustTable* distanceAdjustT
able, |
| 316 GrBatchFontCache* cache) { | 305 GrBatchFontCache* cache) { |
| 317 for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) { | 306 for (int subRun = 0; subRun < fRuns[run].fSubRunInfo.count(); subRun++) { |
| 318 const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; | 307 const Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun]; |
| 319 int glyphCount = info.glyphCount(); | 308 int glyphCount = info.glyphCount(); |
| 320 if (0 == glyphCount) { | 309 if (0 == glyphCount) { |
| 321 continue; | 310 continue; |
| 322 } | 311 } |
| 323 | 312 |
| 324 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run, | 313 SkAutoTUnref<GrDrawBatch> batch(this->createBatch(info, glyphCount, run, |
| 325 subRun, color, transX,
transY, | 314 subRun, viewMatrix, x,
y, color, |
| 326 skPaint, props, | 315 skPaint, props, |
| 327 distanceAdjustTable, c
ache)); | 316 distanceAdjustTable, c
ache)); |
| 328 dc->drawBatch(pipelineBuilder, batch); | 317 dc->drawBatch(pipelineBuilder, batch); |
| 329 } | 318 } |
| 330 } | 319 } |
| 331 | 320 |
| 321 static void calculate_translation(bool applyVM, |
| 322 const SkMatrix& newViewMatrix, SkScalar newX,
SkScalar newY, |
| 323 const SkMatrix& currentViewMatrix, SkScalar cu
rrentX, |
| 324 SkScalar currentY, SkScalar* transX, SkScalar*
transY) { |
| 325 if (applyVM) { |
| 326 *transX = newViewMatrix.getTranslateX() + |
| 327 newViewMatrix.getScaleX() * (newX - currentX) + |
| 328 newViewMatrix.getSkewX() * (newY - currentY) - |
| 329 currentViewMatrix.getTranslateX(); |
| 330 |
| 331 *transY = newViewMatrix.getTranslateY() + |
| 332 newViewMatrix.getSkewY() * (newX - currentX) + |
| 333 newViewMatrix.getScaleY() * (newY - currentY) - |
| 334 currentViewMatrix.getTranslateY(); |
| 335 } else { |
| 336 *transX = newX - currentX; |
| 337 *transY = newY - currentY; |
| 338 } |
| 339 } |
| 340 |
| 341 |
| 332 void GrAtlasTextBlob::flushBigGlyphs(GrContext* context, GrDrawContext* dc, | 342 void GrAtlasTextBlob::flushBigGlyphs(GrContext* context, GrDrawContext* dc, |
| 333 const GrClip& clip, const SkPaint& skPaint, | 343 const GrClip& clip, const SkPaint& skPaint, |
| 334 SkScalar transX, SkScalar transY, | 344 const SkMatrix& viewMatrix, SkScalar x, SkS
calar y, |
| 335 const SkIRect& clipBounds) { | 345 const SkIRect& clipBounds) { |
| 346 SkScalar transX, transY; |
| 336 for (int i = 0; i < fBigGlyphs.count(); i++) { | 347 for (int i = 0; i < fBigGlyphs.count(); i++) { |
| 337 GrAtlasTextBlob::BigGlyph& bigGlyph = fBigGlyphs[i]; | 348 GrAtlasTextBlob::BigGlyph& bigGlyph = fBigGlyphs[i]; |
| 338 bigGlyph.fVx += transX; | 349 calculate_translation(bigGlyph.fApplyVM, viewMatrix, x, y, |
| 339 bigGlyph.fVy += transY; | 350 fInitialViewMatrix, fInitialX, fInitialY, &transX,
&transY); |
| 340 SkMatrix ctm; | 351 SkMatrix ctm; |
| 341 ctm.setScale(bigGlyph.fScale, bigGlyph.fScale); | 352 ctm.setScale(bigGlyph.fScale, bigGlyph.fScale); |
| 342 ctm.postTranslate(bigGlyph.fVx, bigGlyph.fVy); | 353 ctm.postTranslate(bigGlyph.fX + transX, bigGlyph.fY + transY); |
| 343 if (bigGlyph.fApplyVM) { | 354 if (bigGlyph.fApplyVM) { |
| 344 ctm.postConcat(fViewMatrix); | 355 ctm.postConcat(viewMatrix); |
| 345 } | 356 } |
| 346 | 357 |
| 347 GrBlurUtils::drawPathWithMaskFilter(context, dc, clip, bigGlyph.fPath, | 358 GrBlurUtils::drawPathWithMaskFilter(context, dc, clip, bigGlyph.fPath, |
| 348 skPaint, ctm, nullptr, clipBounds, f
alse); | 359 skPaint, ctm, nullptr, clipBounds, f
alse); |
| 349 } | 360 } |
| 350 } | 361 } |
| 351 | 362 |
| 352 void GrAtlasTextBlob::flushRunAsPaths(GrContext* context, GrDrawContext* dc, | 363 void GrAtlasTextBlob::flushRunAsPaths(GrContext* context, GrDrawContext* dc, |
| 353 const SkSurfaceProps& props, | 364 const SkSurfaceProps& props, |
| 354 const SkTextBlobRunIterator& it, | 365 const SkTextBlobRunIterator& it, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 GrDrawContext* dc, | 403 GrDrawContext* dc, |
| 393 const SkTextBlob* blob, | 404 const SkTextBlob* blob, |
| 394 const SkSurfaceProps& props, | 405 const SkSurfaceProps& props, |
| 395 const GrDistanceFieldAdjustTable* distanceAdju
stTable, | 406 const GrDistanceFieldAdjustTable* distanceAdju
stTable, |
| 396 const SkPaint& skPaint, | 407 const SkPaint& skPaint, |
| 397 const GrPaint& grPaint, | 408 const GrPaint& grPaint, |
| 398 SkDrawFilter* drawFilter, | 409 SkDrawFilter* drawFilter, |
| 399 const GrClip& clip, | 410 const GrClip& clip, |
| 400 const SkMatrix& viewMatrix, | 411 const SkMatrix& viewMatrix, |
| 401 const SkIRect& clipBounds, | 412 const SkIRect& clipBounds, |
| 402 SkScalar x, SkScalar y, | 413 SkScalar x, SkScalar y) { |
| 403 SkScalar transX, SkScalar transY) { | |
| 404 // We loop through the runs of the blob, flushing each. If any run is too l
arge, then we flush | 414 // We loop through the runs of the blob, flushing each. If any run is too l
arge, then we flush |
| 405 // it as paths | 415 // it as paths |
| 406 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget(), clip); | 416 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget(), clip); |
| 407 | 417 |
| 408 GrColor color = grPaint.getColor(); | 418 GrColor color = grPaint.getColor(); |
| 409 | 419 |
| 410 SkTextBlobRunIterator it(blob); | 420 SkTextBlobRunIterator it(blob); |
| 411 for (int run = 0; !it.done(); it.next(), run++) { | 421 for (int run = 0; !it.done(); it.next(), run++) { |
| 412 if (fRuns[run].fDrawAsPaths) { | 422 if (fRuns[run].fDrawAsPaths) { |
| 413 this->flushRunAsPaths(context, dc, props, it, clip, skPaint, | 423 this->flushRunAsPaths(context, dc, props, it, clip, skPaint, |
| 414 drawFilter, viewMatrix, clipBounds, x, y); | 424 drawFilter, viewMatrix, clipBounds, x, y); |
| 415 continue; | 425 continue; |
| 416 } | 426 } |
| 417 this->flushRun(dc, &pipelineBuilder, run, color, | 427 this->flushRun(dc, &pipelineBuilder, run, viewMatrix, x, y, color, skPai
nt, props, |
| 418 transX, transY, skPaint, props, | |
| 419 distanceAdjustTable, context->getBatchFontCache()); | 428 distanceAdjustTable, context->getBatchFontCache()); |
| 420 } | 429 } |
| 421 | 430 |
| 422 // Now flush big glyphs | 431 // Now flush big glyphs |
| 423 this->flushBigGlyphs(context, dc, clip, skPaint, transX, transY, clipBounds)
; | 432 this->flushBigGlyphs(context, dc, clip, skPaint, viewMatrix, x, y, clipBound
s); |
| 424 } | 433 } |
| 425 | 434 |
| 426 void GrAtlasTextBlob::flushThrowaway(GrContext* context, | 435 void GrAtlasTextBlob::flushThrowaway(GrContext* context, |
| 427 GrDrawContext* dc, | 436 GrDrawContext* dc, |
| 428 const SkSurfaceProps& props, | 437 const SkSurfaceProps& props, |
| 429 const GrDistanceFieldAdjustTable* distanceA
djustTable, | 438 const GrDistanceFieldAdjustTable* distanceA
djustTable, |
| 430 const SkPaint& skPaint, | 439 const SkPaint& skPaint, |
| 431 const GrPaint& grPaint, | 440 const GrPaint& grPaint, |
| 432 const GrClip& clip, | 441 const GrClip& clip, |
| 433 const SkIRect& clipBounds) { | 442 const SkMatrix& viewMatrix, |
| 443 const SkIRect& clipBounds, |
| 444 SkScalar x, SkScalar y) { |
| 434 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget(), clip); | 445 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget(), clip); |
| 435 | 446 |
| 436 GrColor color = grPaint.getColor(); | 447 GrColor color = grPaint.getColor(); |
| 437 for (int run = 0; run < fRunCount; run++) { | 448 for (int run = 0; run < fRunCount; run++) { |
| 438 this->flushRun(dc, &pipelineBuilder, run, color, 0, 0, skPaint, props, | 449 this->flushRun(dc, &pipelineBuilder, run, viewMatrix, x, y, color, skPai
nt, props, |
| 439 distanceAdjustTable, context->getBatchFontCache()); | 450 distanceAdjustTable, context->getBatchFontCache()); |
| 440 } | 451 } |
| 441 | 452 |
| 442 // Now flush big glyphs | 453 // Now flush big glyphs |
| 443 this->flushBigGlyphs(context, dc, clip, skPaint, 0, 0, clipBounds); | 454 this->flushBigGlyphs(context, dc, clip, skPaint, viewMatrix, x, y, clipBound
s); |
| 444 } | 455 } |
| 445 | 456 |
| 446 GrDrawBatch* GrAtlasTextBlob::test_createBatch( | 457 GrDrawBatch* GrAtlasTextBlob::test_createBatch( |
| 447 int glyphCount, int run, int subRu
n, | 458 int glyphCount, int run, int subRu
n, |
| 448 GrColor color, SkScalar transX, Sk
Scalar transY, | 459 const SkMatrix& viewMatrix, SkScal
ar x, SkScalar y, |
| 460 GrColor color, |
| 449 const SkPaint& skPaint, const SkSu
rfaceProps& props, | 461 const SkPaint& skPaint, const SkSu
rfaceProps& props, |
| 450 const GrDistanceFieldAdjustTable*
distanceAdjustTable, | 462 const GrDistanceFieldAdjustTable*
distanceAdjustTable, |
| 451 GrBatchFontCache* cache) { | 463 GrBatchFontCache* cache) { |
| 452 const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun
]; | 464 const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun
]; |
| 453 return this->createBatch(info, glyphCount, run, subRun, color, transX, trans
Y, skPaint, | 465 return this->createBatch(info, glyphCount, run, subRun, viewMatrix, x, y, co
lor, skPaint, |
| 454 props, distanceAdjustTable, cache); | 466 props, distanceAdjustTable, cache); |
| 455 } | 467 } |
| 456 | 468 |
| 457 void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlo
b& r) { | 469 void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlo
b& r) { |
| 458 SkASSERT_RELEASE(l.fSize == r.fSize); | 470 SkASSERT_RELEASE(l.fSize == r.fSize); |
| 459 SkASSERT_RELEASE(l.fPool == r.fPool); | 471 SkASSERT_RELEASE(l.fPool == r.fPool); |
| 460 | 472 |
| 461 SkASSERT_RELEASE(l.fBlurRec.fSigma == r.fBlurRec.fSigma); | 473 SkASSERT_RELEASE(l.fBlurRec.fSigma == r.fBlurRec.fSigma); |
| 462 SkASSERT_RELEASE(l.fBlurRec.fStyle == r.fBlurRec.fStyle); | 474 SkASSERT_RELEASE(l.fBlurRec.fStyle == r.fBlurRec.fStyle); |
| 463 SkASSERT_RELEASE(l.fBlurRec.fQuality == r.fBlurRec.fQuality); | 475 SkASSERT_RELEASE(l.fBlurRec.fQuality == r.fBlurRec.fQuality); |
| 464 | 476 |
| 465 SkASSERT_RELEASE(l.fStrokeInfo.fFrameWidth == r.fStrokeInfo.fFrameWidth); | 477 SkASSERT_RELEASE(l.fStrokeInfo.fFrameWidth == r.fStrokeInfo.fFrameWidth); |
| 466 SkASSERT_RELEASE(l.fStrokeInfo.fMiterLimit == r.fStrokeInfo.fMiterLimit); | 478 SkASSERT_RELEASE(l.fStrokeInfo.fMiterLimit == r.fStrokeInfo.fMiterLimit); |
| 467 SkASSERT_RELEASE(l.fStrokeInfo.fJoin == r.fStrokeInfo.fJoin); | 479 SkASSERT_RELEASE(l.fStrokeInfo.fJoin == r.fStrokeInfo.fJoin); |
| 468 | 480 |
| 469 SkASSERT_RELEASE(l.fBigGlyphs.count() == r.fBigGlyphs.count()); | 481 SkASSERT_RELEASE(l.fBigGlyphs.count() == r.fBigGlyphs.count()); |
| 470 for (int i = 0; i < l.fBigGlyphs.count(); i++) { | 482 for (int i = 0; i < l.fBigGlyphs.count(); i++) { |
| 471 const BigGlyph& lBigGlyph = l.fBigGlyphs[i]; | 483 const BigGlyph& lBigGlyph = l.fBigGlyphs[i]; |
| 472 const BigGlyph& rBigGlyph = r.fBigGlyphs[i]; | 484 const BigGlyph& rBigGlyph = r.fBigGlyphs[i]; |
| 473 | 485 |
| 474 SkASSERT_RELEASE(lBigGlyph.fPath == rBigGlyph.fPath); | 486 SkASSERT_RELEASE(lBigGlyph.fPath == rBigGlyph.fPath); |
| 475 // We can't assert that these have the same translations | 487 // We can't assert that these have the same translations |
| 476 } | 488 } |
| 477 | 489 |
| 478 SkASSERT_RELEASE(l.fKey == r.fKey); | 490 SkASSERT_RELEASE(l.fKey == r.fKey); |
| 479 SkASSERT_RELEASE(l.fViewMatrix.cheapEqualTo(r.fViewMatrix)); | |
| 480 //SkASSERT_RELEASE(l.fPaintColor == r.fPaintColor); // Colors might not actu
ally be identical | 491 //SkASSERT_RELEASE(l.fPaintColor == r.fPaintColor); // Colors might not actu
ally be identical |
| 481 SkASSERT_RELEASE(l.fMaxMinScale == r.fMaxMinScale); | 492 SkASSERT_RELEASE(l.fMaxMinScale == r.fMaxMinScale); |
| 482 SkASSERT_RELEASE(l.fMinMaxScale == r.fMinMaxScale); | 493 SkASSERT_RELEASE(l.fMinMaxScale == r.fMinMaxScale); |
| 483 SkASSERT_RELEASE(l.fTextType == r.fTextType); | 494 SkASSERT_RELEASE(l.fTextType == r.fTextType); |
| 484 | 495 |
| 485 SkASSERT_RELEASE(l.fRunCount == r.fRunCount); | 496 SkASSERT_RELEASE(l.fRunCount == r.fRunCount); |
| 486 for (int i = 0; i < l.fRunCount; i++) { | 497 for (int i = 0; i < l.fRunCount; i++) { |
| 487 const Run& lRun = l.fRuns[i]; | 498 const Run& lRun = l.fRuns[i]; |
| 488 const Run& rRun = r.fRuns[i]; | 499 const Run& rRun = r.fRuns[i]; |
| 489 | 500 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 SkASSERT_RELEASE(lSubRun.vertexStartIndex() == rSubRun.vertexStartIn
dex()); | 544 SkASSERT_RELEASE(lSubRun.vertexStartIndex() == rSubRun.vertexStartIn
dex()); |
| 534 SkASSERT_RELEASE(lSubRun.vertexEndIndex() == rSubRun.vertexEndIndex(
)); | 545 SkASSERT_RELEASE(lSubRun.vertexEndIndex() == rSubRun.vertexEndIndex(
)); |
| 535 SkASSERT_RELEASE(lSubRun.glyphStartIndex() == rSubRun.glyphStartInde
x()); | 546 SkASSERT_RELEASE(lSubRun.glyphStartIndex() == rSubRun.glyphStartInde
x()); |
| 536 SkASSERT_RELEASE(lSubRun.glyphEndIndex() == rSubRun.glyphEndIndex())
; | 547 SkASSERT_RELEASE(lSubRun.glyphEndIndex() == rSubRun.glyphEndIndex())
; |
| 537 SkASSERT_RELEASE(lSubRun.maskFormat() == rSubRun.maskFormat()); | 548 SkASSERT_RELEASE(lSubRun.maskFormat() == rSubRun.maskFormat()); |
| 538 SkASSERT_RELEASE(lSubRun.drawAsDistanceFields() == rSubRun.drawAsDis
tanceFields()); | 549 SkASSERT_RELEASE(lSubRun.drawAsDistanceFields() == rSubRun.drawAsDis
tanceFields()); |
| 539 SkASSERT_RELEASE(lSubRun.hasUseLCDText() == rSubRun.hasUseLCDText())
; | 550 SkASSERT_RELEASE(lSubRun.hasUseLCDText() == rSubRun.hasUseLCDText())
; |
| 540 } | 551 } |
| 541 } | 552 } |
| 542 } | 553 } |
| 554 |
| 555 void GrAtlasTextBlob::Run::SubRunInfo::computeTranslation(const SkMatrix& viewMa
trix, |
| 556 SkScalar x, SkScalar y
, SkScalar* transX, |
| 557 SkScalar* transY) { |
| 558 calculate_translation(!this->drawAsDistanceFields(), viewMatrix, x, y, |
| 559 fCurrentViewMatrix, fX, fY, transX, transY); |
| 560 fCurrentViewMatrix = viewMatrix; |
| 561 fX = x; |
| 562 fY = y; |
| 563 } |
| OLD | NEW |