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

Side by Side Diff: src/core/SkPicturePlayback.cpp

Issue 473633002: SkTextBlob (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: More const API, minimal docs. Created 6 years, 4 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
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "SkCanvas.h" 8 #include "SkCanvas.h"
9 #include "SkPatchUtils.h" 9 #include "SkPatchUtils.h"
10 #include "SkPictureData.h" 10 #include "SkPictureData.h"
11 #include "SkPicturePlayback.h" 11 #include "SkPicturePlayback.h"
12 #include "SkPictureRecord.h" 12 #include "SkPictureRecord.h"
13 #include "SkPictureStateTree.h" 13 #include "SkPictureStateTree.h"
14 #include "SkReader32.h" 14 #include "SkReader32.h"
15 #include "SkTextBlob.h"
15 #include "SkTDArray.h" 16 #include "SkTDArray.h"
16 #include "SkTypes.h" 17 #include "SkTypes.h"
17 18
18 /* 19 /*
19 * Read the next op code and chunk size from 'reader'. The returned size 20 * Read the next op code and chunk size from 'reader'. The returned size
20 * is the entire size of the chunk (including the opcode). Thus, the 21 * is the entire size of the chunk (including the opcode). Thus, the
21 * offset just prior to calling ReadOpAndSize + 'size' is the offset 22 * offset just prior to calling ReadOpAndSize + 'size' is the offset
22 * to the next chunk's op code. This also means that the size of a chunk 23 * to the next chunk's op code. This also means that the size of a chunk
23 * with no arguments (just an opcode) will be 4. 24 * with no arguments (just an opcode) will be 4.
24 */ 25 */
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 } break; 436 } break;
436 case DRAW_TEXT_ON_PATH: { 437 case DRAW_TEXT_ON_PATH: {
437 const SkPaint& paint = *fPictureData->getPaint(reader); 438 const SkPaint& paint = *fPictureData->getPaint(reader);
438 TextContainer text; 439 TextContainer text;
439 get_text(reader, &text); 440 get_text(reader, &text);
440 const SkPath& path = fPictureData->getPath(reader); 441 const SkPath& path = fPictureData->getPath(reader);
441 SkMatrix matrix; 442 SkMatrix matrix;
442 reader->readMatrix(&matrix); 443 reader->readMatrix(&matrix);
443 canvas->drawTextOnPath(text.text(), text.length(), path, &matrix, pa int); 444 canvas->drawTextOnPath(text.text(), text.length(), path, &matrix, pa int);
444 } break; 445 } break;
446 case DRAW_TEXT_BLOB: {
447 const SkPaint& paint = *fPictureData->getPaint(reader);
448 uint32_t chunkCount = reader->readInt();
449 const SkPoint& offset = reader->skipT<SkPoint>();
450
451 SkTextBlobBuilder blobBuilder;
452 for (unsigned i = 0; i < chunkCount; ++i) {
453 uint32_t glyphCount = reader->readInt();
454 const SkPaint& glyphPaint = *fPictureData->getPaint(reader);
455 unsigned scalarsPerPos = reader->readInt();
456 const SkRect* boundsPtr = get_rect_ptr(reader);
457 const uint16_t* glyphs = (uint16_t*)reader->skip(
458 SkAlign4(glyphCount * sizeof(uint16_t)));
459 const SkTextChunk* chunk;
460 if (scalarsPerPos > 0) {
461 const SkScalar* pos = (const SkScalar*)reader->skip(
462 SkAlign4(glyphCount * sizeof(SkScalar) * scalarsPerPos)) ;
463 if (1 == scalarsPerPos) {
464 chunk = SkTextChunk::Create(glyphs, glyphCount, pos, gly phPaint, boundsPtr);
465 } else {
466 SkASSERT(2 == scalarsPerPos);
467 chunk = SkTextChunk::Create(glyphs, glyphCount, (const S kPoint*)pos,
468 glyphPaint, boundsPtr);
469 }
470
471 } else {
472 chunk = SkTextChunk::Create(glyphs, glyphCount, glyphPaint, boundsPtr);
473 }
474
475 blobBuilder.addChunk(chunk);
476 }
477
478 SkAutoTUnref<const SkTextBlob> blob(blobBuilder.build());
479 canvas->drawTextBlob(blob, offset, paint);
480 } break;
445 case DRAW_VERTICES: { 481 case DRAW_VERTICES: {
446 SkAutoTUnref<SkXfermode> xfer; 482 SkAutoTUnref<SkXfermode> xfer;
447 const SkPaint& paint = *fPictureData->getPaint(reader); 483 const SkPaint& paint = *fPictureData->getPaint(reader);
448 DrawVertexFlags flags = (DrawVertexFlags)reader->readInt(); 484 DrawVertexFlags flags = (DrawVertexFlags)reader->readInt();
449 SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader->readInt() ; 485 SkCanvas::VertexMode vmode = (SkCanvas::VertexMode)reader->readInt() ;
450 int vCount = reader->readInt(); 486 int vCount = reader->readInt();
451 const SkPoint* verts = (const SkPoint*)reader->skip(vCount * sizeof( SkPoint)); 487 const SkPoint* verts = (const SkPoint*)reader->skip(vCount * sizeof( SkPoint));
452 const SkPoint* texs = NULL; 488 const SkPoint* texs = NULL;
453 const SkColor* colors = NULL; 489 const SkColor* colors = NULL;
454 const uint16_t* indices = NULL; 490 const uint16_t* indices = NULL;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 case TRANSLATE: { 546 case TRANSLATE: {
511 SkScalar dx = reader->readScalar(); 547 SkScalar dx = reader->readScalar();
512 SkScalar dy = reader->readScalar(); 548 SkScalar dy = reader->readScalar();
513 canvas->translate(dx, dy); 549 canvas->translate(dx, dy);
514 } break; 550 } break;
515 default: 551 default:
516 SkASSERT(0); 552 SkASSERT(0);
517 } 553 }
518 } 554 }
519 555
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698