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

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

Issue 1514933002: Create GrTextUtils (Closed) Base URL: https://skia.googlesource.com/skia.git@cleanuptext9
Patch Set: Created 5 years 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/GrAtlasTextBlob.h ('k') | src/gpu/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"
11 #include "GrContext.h" 11 #include "GrContext.h"
12 #include "GrDrawContext.h" 12 #include "GrDrawContext.h"
13 #include "GrTextUtils.h"
13 #include "SkColorFilter.h" 14 #include "SkColorFilter.h"
14 #include "SkDrawFilter.h" 15 #include "SkDrawFilter.h"
15 #include "SkTextBlobRunIterator.h" 16 #include "SkTextBlobRunIterator.h"
16 #include "batches/GrAtlasTextBatch.h" 17 #include "batches/GrAtlasTextBatch.h"
17 18
18 void GrAtlasTextBlob::appendGlyph(int runIndex, 19 void GrAtlasTextBlob::appendGlyph(int runIndex,
19 const SkRect& positions, 20 const SkRect& positions,
20 GrColor color, 21 GrColor color,
21 GrBatchTextStrike* strike, 22 GrBatchTextStrike* strike,
22 GrGlyph* glyph, 23 GrGlyph* glyph,
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 ctm.postTranslate(bigGlyph.fVx, bigGlyph.fVy); 294 ctm.postTranslate(bigGlyph.fVx, bigGlyph.fVy);
294 if (bigGlyph.fApplyVM) { 295 if (bigGlyph.fApplyVM) {
295 ctm.postConcat(fViewMatrix); 296 ctm.postConcat(fViewMatrix);
296 } 297 }
297 298
298 GrBlurUtils::drawPathWithMaskFilter(context, dc, clip, bigGlyph.fPath, 299 GrBlurUtils::drawPathWithMaskFilter(context, dc, clip, bigGlyph.fPath,
299 skPaint, ctm, nullptr, clipBounds, f alse); 300 skPaint, ctm, nullptr, clipBounds, f alse);
300 } 301 }
301 } 302 }
302 303
303 void GrAtlasTextBlob::flushRunAsPaths(GrDrawContext* dc, 304 void GrAtlasTextBlob::flushRunAsPaths(GrContext* context, GrDrawContext* dc,
304 GrTextContext* textContext,
305 const SkSurfaceProps& props, 305 const SkSurfaceProps& props,
306 const SkTextBlobRunIterator& it, 306 const SkTextBlobRunIterator& it,
307 const GrClip& clip, const SkPaint& skPaint , 307 const GrClip& clip, const SkPaint& skPaint ,
308 SkDrawFilter* drawFilter, const SkMatrix& viewMatrix, 308 SkDrawFilter* drawFilter, const SkMatrix& viewMatrix,
309 const SkIRect& clipBounds, SkScalar x, SkS calar y) { 309 const SkIRect& clipBounds, SkScalar x, SkS calar y) {
310 SkPaint runPaint = skPaint; 310 SkPaint runPaint = skPaint;
311 311
312 size_t textLen = it.glyphCount() * sizeof(uint16_t); 312 size_t textLen = it.glyphCount() * sizeof(uint16_t);
313 const SkPoint& offset = it.offset(); 313 const SkPoint& offset = it.offset();
314 314
315 it.applyFontToPaint(&runPaint); 315 it.applyFontToPaint(&runPaint);
316 316
317 if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Type)) { 317 if (drawFilter && !drawFilter->filter(&runPaint, SkDrawFilter::kText_Type)) {
318 return; 318 return;
319 } 319 }
320 320
321 runPaint.setFlags(GrTextContext::FilterTextFlags(props, runPaint)); 321 runPaint.setFlags(GrTextContext::FilterTextFlags(props, runPaint));
322 322
323 switch (it.positioning()) { 323 switch (it.positioning()) {
324 case SkTextBlob::kDefault_Positioning: 324 case SkTextBlob::kDefault_Positioning:
325 textContext->drawTextAsPath(dc, clip, runPaint, viewMatrix, 325 GrTextUtils::DrawTextAsPath(context, dc, clip, runPaint, viewMatrix,
326 (const char *)it.glyphs(), 326 (const char *)it.glyphs(),
327 textLen, x + offset.x(), y + offset.y(), clipBounds); 327 textLen, x + offset.x(), y + offset.y(), clipBounds);
328 break; 328 break;
329 case SkTextBlob::kHorizontal_Positioning: 329 case SkTextBlob::kHorizontal_Positioning:
330 textContext->drawPosTextAsPath(dc, clip, runPaint, viewMatrix, 330 GrTextUtils::DrawPosTextAsPath(context, dc, props, clip, runPaint, v iewMatrix,
331 (const char*)it.glyphs(), 331 (const char*)it.glyphs(),
332 textLen, it.pos(), 1, SkPoint::Make(x , y + offset.y()), 332 textLen, it.pos(), 1, SkPoint::Make(x , y + offset.y()),
333 clipBounds); 333 clipBounds);
334 break; 334 break;
335 case SkTextBlob::kFull_Positioning: 335 case SkTextBlob::kFull_Positioning:
336 textContext->drawPosTextAsPath(dc, clip, runPaint, viewMatrix, 336 GrTextUtils::DrawPosTextAsPath(context, dc, props, clip, runPaint, v iewMatrix,
337 (const char*)it.glyphs(), 337 (const char*)it.glyphs(),
338 textLen, it.pos(), 2, SkPoint::Make(x , y), clipBounds); 338 textLen, it.pos(), 2, SkPoint::Make(x , y), clipBounds);
339 break; 339 break;
340 } 340 }
341 } 341 }
342 342
343 void GrAtlasTextBlob::flushCached(const SkTextBlob* blob, 343 void GrAtlasTextBlob::flushCached(GrContext* context,
344 GrContext* context,
345 GrDrawContext* dc, 344 GrDrawContext* dc,
346 GrTextContext* textContext, 345 const SkTextBlob* blob,
347 const SkSurfaceProps& props, 346 const SkSurfaceProps& props,
348 const GrDistanceFieldAdjustTable* distanceAdju stTable, 347 const GrDistanceFieldAdjustTable* distanceAdju stTable,
349 const SkPaint& skPaint, 348 const SkPaint& skPaint,
350 const GrPaint& grPaint, 349 const GrPaint& grPaint,
351 SkDrawFilter* drawFilter, 350 SkDrawFilter* drawFilter,
352 const GrClip& clip, 351 const GrClip& clip,
353 const SkMatrix& viewMatrix, 352 const SkMatrix& viewMatrix,
354 const SkIRect& clipBounds, 353 const SkIRect& clipBounds,
355 SkScalar x, SkScalar y, 354 SkScalar x, SkScalar y,
356 SkScalar transX, SkScalar transY) { 355 SkScalar transX, SkScalar transY) {
357 // We loop through the runs of the blob, flushing each. If any run is too l arge, then we flush 356 // We loop through the runs of the blob, flushing each. If any run is too l arge, then we flush
358 // it as paths 357 // it as paths
359 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget(), clip); 358 GrPipelineBuilder pipelineBuilder(grPaint, dc->accessRenderTarget(), clip);
360 359
361 GrColor color = grPaint.getColor(); 360 GrColor color = grPaint.getColor();
362 361
363 SkTextBlobRunIterator it(blob); 362 SkTextBlobRunIterator it(blob);
364 for (int run = 0; !it.done(); it.next(), run++) { 363 for (int run = 0; !it.done(); it.next(), run++) {
365 if (fRuns[run].fDrawAsPaths) { 364 if (fRuns[run].fDrawAsPaths) {
366 this->flushRunAsPaths(dc, textContext, props, it, clip, skPaint, 365 this->flushRunAsPaths(context, dc, props, it, clip, skPaint,
367 drawFilter, viewMatrix, clipBounds, x, y); 366 drawFilter, viewMatrix, clipBounds, x, y);
368 continue; 367 continue;
369 } 368 }
370 fRuns[run].fVertexBounds.offset(transX, transY); 369 fRuns[run].fVertexBounds.offset(transX, transY);
371 this->flushRun(dc, &pipelineBuilder, run, color, 370 this->flushRun(dc, &pipelineBuilder, run, color,
372 transX, transY, skPaint, props, 371 transX, transY, skPaint, props,
373 distanceAdjustTable, context->getBatchFontCache()); 372 distanceAdjustTable, context->getBatchFontCache());
374 } 373 }
375 374
376 // Now flush big glyphs 375 // Now flush big glyphs
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 rSubRun.fBulkUseToken.fPlotAlreadyUpdated); 491 rSubRun.fBulkUseToken.fPlotAlreadyUpdated);
493 for (int k = 0; k < lSubRun.fBulkUseToken.fPlotsToUpdate.count(); k+ +) { 492 for (int k = 0; k < lSubRun.fBulkUseToken.fPlotsToUpdate.count(); k+ +) {
494 SkASSERT(lSubRun.fBulkUseToken.fPlotsToUpdate[k] == 493 SkASSERT(lSubRun.fBulkUseToken.fPlotsToUpdate[k] ==
495 rSubRun.fBulkUseToken.fPlotsToUpdate[k]); 494 rSubRun.fBulkUseToken.fPlotsToUpdate[k]);
496 }*/ 495 }*/
497 } 496 }
498 } 497 }
499 } 498 }
500 499
501 #endif 500 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAtlasTextBlob.h ('k') | src/gpu/GrAtlasTextContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698