Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(378)

Side by Side Diff: src/gpu/text/GrAtlasTextBlob.cpp

Issue 1605013002: Fix GrAtlasTextBlob bounds management (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanuptext17
Patch Set: fix glprograms Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/text/GrAtlasTextBlob.h ('k') | src/gpu/text/GrAtlasTextContext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 } else if (!run.fInitialized) { 56 } else if (!run.fInitialized) {
57 subRun->setStrike(strike); 57 subRun->setStrike(strike);
58 } 58 }
59 59
60 run.fInitialized = true; 60 run.fInitialized = true;
61 61
62 size_t vertexStride = GetVertexStride(format); 62 size_t vertexStride = GetVertexStride(format);
63 63
64 subRun->setMaskFormat(format); 64 subRun->setMaskFormat(format);
65 65
66 run.fVertexBounds.joinNonEmptyArg(positions); 66 subRun->joinGlyphBounds(positions);
67 subRun->setColor(color); 67 subRun->setColor(color);
68 68
69 intptr_t vertex = reinterpret_cast<intptr_t>(this->fVertices + subRun->verte xEndIndex()); 69 intptr_t vertex = reinterpret_cast<intptr_t>(this->fVertices + subRun->verte xEndIndex());
70 70
71 if (kARGB_GrMaskFormat != glyph->fMaskFormat) { 71 if (kARGB_GrMaskFormat != glyph->fMaskFormat) {
72 // V0 72 // V0
73 SkPoint* position = reinterpret_cast<SkPoint*>(vertex); 73 SkPoint* position = reinterpret_cast<SkPoint*>(vertex);
74 position->set(positions.fLeft, positions.fTop); 74 position->set(positions.fLeft, positions.fTop);
75 SkColor* colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)) ; 75 SkColor* colorPtr = reinterpret_cast<SkColor*>(vertex + sizeof(SkPoint)) ;
76 *colorPtr = color; 76 *colorPtr = color;
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 SkScalar oldMaxScale = fViewMatrix.getMaxScale(); 212 SkScalar oldMaxScale = fViewMatrix.getMaxScale();
213 SkScalar scaleAdjust = newMaxScale / oldMaxScale; 213 SkScalar scaleAdjust = newMaxScale / oldMaxScale;
214 if (scaleAdjust < fMaxMinScale || scaleAdjust > fMinMaxScale) { 214 if (scaleAdjust < fMaxMinScale || scaleAdjust > fMinMaxScale) {
215 return true; 215 return true;
216 } 216 }
217 217
218 (*outTransX) = x - fX; 218 (*outTransX) = x - fX;
219 (*outTransY) = y - fY; 219 (*outTransY) = y - fY;
220 } 220 }
221 221
222
223 // If we can reuse the blob, then make sure we update the blob's viewmatrix, and x/y 222 // If we can reuse the blob, then make sure we update the blob's viewmatrix, and x/y
224 // offsets. Note, we offset the vertex bounds right before flushing 223 // offsets. Note, we offset the vertex bounds right before flushing
225 fViewMatrix = viewMatrix; 224 fViewMatrix = viewMatrix;
226 fX = x; 225 fX = x;
227 fY = y; 226 fY = y;
228 227
229 // It is possible that a blob has neither distanceField nor bitmaptext. Thi s is in the case 228 // It is possible that a blob has neither distanceField nor bitmaptext. Thi s is in the case
230 // when all of the runs inside the blob are drawn as paths. In this case, w e always regenerate 229 // when all of the runs inside the blob are drawn as paths. In this case, w e always regenerate
231 // the blob anyways at flush time, so no need to regenerate explicitly 230 // the blob anyways at flush time, so no need to regenerate explicitly
232 return false; 231 return false;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 375
377 GrColor color = grPaint.getColor(); 376 GrColor color = grPaint.getColor();
378 377
379 SkTextBlobRunIterator it(blob); 378 SkTextBlobRunIterator it(blob);
380 for (int run = 0; !it.done(); it.next(), run++) { 379 for (int run = 0; !it.done(); it.next(), run++) {
381 if (fRuns[run].fDrawAsPaths) { 380 if (fRuns[run].fDrawAsPaths) {
382 this->flushRunAsPaths(context, dc, props, it, clip, skPaint, 381 this->flushRunAsPaths(context, dc, props, it, clip, skPaint,
383 drawFilter, viewMatrix, clipBounds, x, y); 382 drawFilter, viewMatrix, clipBounds, x, y);
384 continue; 383 continue;
385 } 384 }
386 fRuns[run].fVertexBounds.offset(transX, transY);
387 this->flushRun(dc, &pipelineBuilder, run, color, 385 this->flushRun(dc, &pipelineBuilder, run, color,
388 transX, transY, skPaint, props, 386 transX, transY, skPaint, props,
389 distanceAdjustTable, context->getBatchFontCache()); 387 distanceAdjustTable, context->getBatchFontCache());
390 } 388 }
391 389
392 // Now flush big glyphs 390 // Now flush big glyphs
393 this->flushBigGlyphs(context, dc, clip, skPaint, transX, transY, clipBounds) ; 391 this->flushBigGlyphs(context, dc, clip, skPaint, transX, transY, clipBounds) ;
394 } 392 }
395 393
396 void GrAtlasTextBlob::flushThrowaway(GrContext* context, 394 void GrAtlasTextBlob::flushThrowaway(GrContext* context,
(...skipping 15 matching lines...) Expand all
412 // Now flush big glyphs 410 // Now flush big glyphs
413 this->flushBigGlyphs(context, dc, clip, skPaint, 0, 0, clipBounds); 411 this->flushBigGlyphs(context, dc, clip, skPaint, 0, 0, clipBounds);
414 } 412 }
415 413
416 GrDrawBatch* GrAtlasTextBlob::test_createBatch( 414 GrDrawBatch* GrAtlasTextBlob::test_createBatch(
417 int glyphCount, int run, int subRu n, 415 int glyphCount, int run, int subRu n,
418 GrColor color, SkScalar transX, Sk Scalar transY, 416 GrColor color, SkScalar transX, Sk Scalar transY,
419 const SkPaint& skPaint, const SkSu rfaceProps& props, 417 const SkPaint& skPaint, const SkSu rfaceProps& props,
420 const GrDistanceFieldAdjustTable* distanceAdjustTable, 418 const GrDistanceFieldAdjustTable* distanceAdjustTable,
421 GrBatchFontCache* cache) { 419 GrBatchFontCache* cache) {
422 const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[0].fSubRunInfo[0]; 420 const GrAtlasTextBlob::Run::SubRunInfo& info = fRuns[run].fSubRunInfo[subRun ];
423 return this->createBatch(info, glyphCount, 0, 0, color, transX, transY, skPa int, 421 return this->createBatch(info, glyphCount, run, subRun, color, transX, trans Y, skPaint,
424 props, distanceAdjustTable, cache); 422 props, distanceAdjustTable, cache);
425 } 423 }
426 424
427 // TODO get this code building again 425 // TODO get this code building again
428 #ifdef CACHE_SANITY_CHECK 426 #ifdef CACHE_SANITY_CHECK
429 void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlo b& r) { 427 void GrAtlasTextBlob::AssertEqual(const GrAtlasTextBlob& l, const GrAtlasTextBlo b& r) {
430 SkASSERT(l.fSize == r.fSize); 428 SkASSERT(l.fSize == r.fSize);
431 SkASSERT(l.fPool == r.fPool); 429 SkASSERT(l.fPool == r.fPool);
432 430
433 SkASSERT(l.fBlurRec.fSigma == r.fBlurRec.fSigma); 431 SkASSERT(l.fBlurRec.fSigma == r.fBlurRec.fSigma);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 rSubRun.fBulkUseToken.fPlotAlreadyUpdated); 516 rSubRun.fBulkUseToken.fPlotAlreadyUpdated);
519 for (int k = 0; k < lSubRun.fBulkUseToken.fPlotsToUpdate.count(); k+ +) { 517 for (int k = 0; k < lSubRun.fBulkUseToken.fPlotsToUpdate.count(); k+ +) {
520 SkASSERT(lSubRun.fBulkUseToken.fPlotsToUpdate[k] == 518 SkASSERT(lSubRun.fBulkUseToken.fPlotsToUpdate[k] ==
521 rSubRun.fBulkUseToken.fPlotsToUpdate[k]); 519 rSubRun.fBulkUseToken.fPlotsToUpdate[k]);
522 }*/ 520 }*/
523 } 521 }
524 } 522 }
525 } 523 }
526 524
527 #endif 525 #endif
OLDNEW
« no previous file with comments | « src/gpu/text/GrAtlasTextBlob.h ('k') | src/gpu/text/GrAtlasTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698