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

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

Issue 375703002: Turn on threaded DMQuiltTask drawing for old-format SkPictures too. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: borrow Created 6 years, 5 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 | « dm/DMQuiltTask.cpp ('k') | no next file » | 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 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 "SkPictureData.h" 9 #include "SkPictureData.h"
10 #include "SkPicturePlayback.h" 10 #include "SkPicturePlayback.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 const void* text() { return (const void*)fText; } 108 const void* text() { return (const void*)fText; }
109 size_t fByteLength; 109 size_t fByteLength;
110 const char* fText; 110 const char* fText;
111 }; 111 };
112 112
113 void get_text(SkReader32* reader, TextContainer* text) { 113 void get_text(SkReader32* reader, TextContainer* text) {
114 size_t length = text->fByteLength = reader->readInt(); 114 size_t length = text->fByteLength = reader->readInt();
115 text->fText = (const char*)reader->skip(length); 115 text->fText = (const char*)reader->skip(length);
116 } 116 }
117 117
118 // FIXME: SkBitmaps are stateful, so we need to copy them to play back in multip le threads.
119 static SkBitmap shallow_copy(const SkBitmap& bitmap) {
120 return bitmap;
121 }
122
118 void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) { 123 void SkPicturePlayback::draw(SkCanvas* canvas, SkDrawPictureCallback* callback) {
119 SkAutoResetOpID aroi(this); 124 SkAutoResetOpID aroi(this);
120 SkASSERT(0 == fCurOffset); 125 SkASSERT(0 == fCurOffset);
121 126
122 #ifdef ENABLE_TIME_DRAW 127 #ifdef ENABLE_TIME_DRAW
123 SkAutoTime at("SkPicture::draw", 50); 128 SkAutoTime at("SkPicture::draw", 50);
124 #endif 129 #endif
125 130
126 #ifdef SPEW_CLIP_SKIPPING 131 #ifdef SPEW_CLIP_SKIPPING
127 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull; 132 SkipClipRec skipRect, skipRRect, skipRegion, skipPath, skipCull;
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 canvas->popCull(); 387 canvas->popCull();
383 break; 388 break;
384 case CONCAT: { 389 case CONCAT: {
385 SkMatrix matrix; 390 SkMatrix matrix;
386 reader.readMatrix(&matrix); 391 reader.readMatrix(&matrix);
387 canvas->concat(matrix); 392 canvas->concat(matrix);
388 break; 393 break;
389 } 394 }
390 case DRAW_BITMAP: { 395 case DRAW_BITMAP: {
391 const SkPaint* paint = fPictureData->getPaint(reader); 396 const SkPaint* paint = fPictureData->getPaint(reader);
392 const SkBitmap& bitmap = fPictureData->getBitmap(reader); 397 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) );
393 const SkPoint& loc = reader.skipT<SkPoint>(); 398 const SkPoint& loc = reader.skipT<SkPoint>();
394 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint); 399 canvas->drawBitmap(bitmap, loc.fX, loc.fY, paint);
395 } break; 400 } break;
396 case DRAW_BITMAP_RECT_TO_RECT: { 401 case DRAW_BITMAP_RECT_TO_RECT: {
397 const SkPaint* paint = fPictureData->getPaint(reader); 402 const SkPaint* paint = fPictureData->getPaint(reader);
398 const SkBitmap& bitmap = fPictureData->getBitmap(reader); 403 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) );
399 const SkRect* src = get_rect_ptr(reader); // may be null 404 const SkRect* src = get_rect_ptr(reader); // may be null
400 const SkRect& dst = reader.skipT<SkRect>(); // required 405 const SkRect& dst = reader.skipT<SkRect>(); // required
401 SkCanvas::DrawBitmapRectFlags flags; 406 SkCanvas::DrawBitmapRectFlags flags;
402 flags = (SkCanvas::DrawBitmapRectFlags) reader.readInt(); 407 flags = (SkCanvas::DrawBitmapRectFlags) reader.readInt();
403 canvas->drawBitmapRectToRect(bitmap, src, dst, paint, flags); 408 canvas->drawBitmapRectToRect(bitmap, src, dst, paint, flags);
404 } break; 409 } break;
405 case DRAW_BITMAP_MATRIX: { 410 case DRAW_BITMAP_MATRIX: {
406 const SkPaint* paint = fPictureData->getPaint(reader); 411 const SkPaint* paint = fPictureData->getPaint(reader);
407 const SkBitmap& bitmap = fPictureData->getBitmap(reader); 412 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) );
408 SkMatrix matrix; 413 SkMatrix matrix;
409 reader.readMatrix(&matrix); 414 reader.readMatrix(&matrix);
410 canvas->drawBitmapMatrix(bitmap, matrix, paint); 415 canvas->drawBitmapMatrix(bitmap, matrix, paint);
411 } break; 416 } break;
412 case DRAW_BITMAP_NINE: { 417 case DRAW_BITMAP_NINE: {
413 const SkPaint* paint = fPictureData->getPaint(reader); 418 const SkPaint* paint = fPictureData->getPaint(reader);
414 const SkBitmap& bitmap = fPictureData->getBitmap(reader); 419 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) );
415 const SkIRect& src = reader.skipT<SkIRect>(); 420 const SkIRect& src = reader.skipT<SkIRect>();
416 const SkRect& dst = reader.skipT<SkRect>(); 421 const SkRect& dst = reader.skipT<SkRect>();
417 canvas->drawBitmapNine(bitmap, src, dst, paint); 422 canvas->drawBitmapNine(bitmap, src, dst, paint);
418 } break; 423 } break;
419 case DRAW_CLEAR: 424 case DRAW_CLEAR:
420 canvas->clear(reader.readInt()); 425 canvas->clear(reader.readInt());
421 break; 426 break;
422 case DRAW_DATA: { 427 case DRAW_DATA: {
423 size_t length = reader.readInt(); 428 size_t length = reader.readInt();
424 canvas->drawData(reader.skip(length), length); 429 canvas->drawData(reader.skip(length), length);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 canvas->drawRect(reader.skipT<SkRect>(), paint); 512 canvas->drawRect(reader.skipT<SkRect>(), paint);
508 } break; 513 } break;
509 case DRAW_RRECT: { 514 case DRAW_RRECT: {
510 const SkPaint& paint = *fPictureData->getPaint(reader); 515 const SkPaint& paint = *fPictureData->getPaint(reader);
511 SkRRect rrect; 516 SkRRect rrect;
512 reader.readRRect(&rrect); 517 reader.readRRect(&rrect);
513 canvas->drawRRect(rrect, paint); 518 canvas->drawRRect(rrect, paint);
514 } break; 519 } break;
515 case DRAW_SPRITE: { 520 case DRAW_SPRITE: {
516 const SkPaint* paint = fPictureData->getPaint(reader); 521 const SkPaint* paint = fPictureData->getPaint(reader);
517 const SkBitmap& bitmap = fPictureData->getBitmap(reader); 522 const SkBitmap bitmap = shallow_copy(fPictureData->getBitmap(reader) );
518 int left = reader.readInt(); 523 int left = reader.readInt();
519 int top = reader.readInt(); 524 int top = reader.readInt();
520 canvas->drawSprite(bitmap, left, top, paint); 525 canvas->drawSprite(bitmap, left, top, paint);
521 } break; 526 } break;
522 case DRAW_TEXT: { 527 case DRAW_TEXT: {
523 const SkPaint& paint = *fPictureData->getPaint(reader); 528 const SkPaint& paint = *fPictureData->getPaint(reader);
524 get_text(&reader, &text); 529 get_text(&reader, &text);
525 SkScalar x = reader.readScalar(); 530 SkScalar x = reader.readScalar();
526 SkScalar y = reader.readScalar(); 531 SkScalar y = reader.readScalar();
527 canvas->drawText(text.text(), text.length(), x, y, paint); 532 canvas->drawText(text.text(), text.length(), x, y, paint);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
639 skipCull.fSize; 644 skipCull.fSize;
640 SkDebugf("--- Clip skips %d%% rect:%d rrect:%d path:%d rgn:%d cull:%d\n" , 645 SkDebugf("--- Clip skips %d%% rect:%d rrect:%d path:%d rgn:%d cull:%d\n" ,
641 size * 100 / reader.offset(), skipRect.fCount, skipRRect.fCount, 646 size * 100 / reader.offset(), skipRect.fCount, skipRRect.fCount,
642 skipPath.fCount, skipRegion.fCount, skipCull.fCount); 647 skipPath.fCount, skipRegion.fCount, skipCull.fCount);
643 SkDebugf("--- Total ops: %d\n", opCount); 648 SkDebugf("--- Total ops: %d\n", opCount);
644 } 649 }
645 #endif 650 #endif
646 // this->dumpSize(); 651 // this->dumpSize();
647 } 652 }
648 653
OLDNEW
« no previous file with comments | « dm/DMQuiltTask.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698