| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "PictureRenderer.h" | 8 #include "PictureRenderer.h" |
| 9 #include "picture_utils.h" | 9 #include "picture_utils.h" |
| 10 #include "SamplePipeControllers.h" | 10 #include "SamplePipeControllers.h" |
| 11 #include "SkBitmapHasher.h" | 11 #include "SkBitmapHasher.h" |
| 12 #include "SkCanvas.h" | 12 #include "SkCanvas.h" |
| 13 #include "SkData.h" | 13 #include "SkData.h" |
| 14 #include "SkDevice.h" | 14 #include "SkDevice.h" |
| 15 #include "SkDiscardableMemoryPool.h" | 15 #include "SkDiscardableMemoryPool.h" |
| 16 #include "SkGPipe.h" | 16 #include "SkGPipe.h" |
| 17 #if SK_SUPPORT_GPU | 17 #if SK_SUPPORT_GPU |
| 18 #include "gl/GrGLDefines.h" | 18 #include "gl/GrGLDefines.h" |
| 19 #include "SkGpuDevice.h" | 19 #include "SkGpuDevice.h" |
| 20 #endif | 20 #endif |
| 21 #include "SkGraphics.h" | 21 #include "SkGraphics.h" |
| 22 #include "SkImageEncoder.h" | 22 #include "SkImageEncoder.h" |
| 23 #include "SkMaskFilter.h" | 23 #include "SkMaskFilter.h" |
| 24 #include "SkMatrix.h" | 24 #include "SkMatrix.h" |
| 25 #include "SkMultiPictureDraw.h" |
| 25 #include "SkOSFile.h" | 26 #include "SkOSFile.h" |
| 26 #include "SkPicture.h" | 27 #include "SkPicture.h" |
| 27 #include "SkPictureRecorder.h" | 28 #include "SkPictureRecorder.h" |
| 28 #include "SkPictureUtils.h" | 29 #include "SkPictureUtils.h" |
| 29 #include "SkPixelRef.h" | 30 #include "SkPixelRef.h" |
| 30 #include "SkScalar.h" | 31 #include "SkScalar.h" |
| 31 #include "SkStream.h" | 32 #include "SkStream.h" |
| 32 #include "SkString.h" | 33 #include "SkString.h" |
| 34 #include "SkSurface.h" |
| 33 #include "SkTemplates.h" | 35 #include "SkTemplates.h" |
| 34 #include "SkTDArray.h" | 36 #include "SkTDArray.h" |
| 35 #include "SkThreadUtils.h" | 37 #include "SkThreadUtils.h" |
| 36 #include "SkTypes.h" | 38 #include "SkTypes.h" |
| 37 | 39 |
| 38 static inline SkScalar scalar_log2(SkScalar x) { | 40 static inline SkScalar scalar_log2(SkScalar x) { |
| 39 static const SkScalar log2_conversion_factor = SkScalarDiv(1, SkScalarLog(2)
); | 41 static const SkScalar log2_conversion_factor = SkScalarDiv(1, SkScalarLog(2)
); |
| 40 | 42 |
| 41 return SkScalarLog(x) * log2_conversion_factor; | 43 return SkScalarLog(x) * log2_conversion_factor; |
| 42 } | 44 } |
| 43 | 45 |
| 44 namespace sk_tools { | 46 namespace sk_tools { |
| 45 | 47 |
| 46 enum { | 48 enum { |
| 47 kDefaultTileWidth = 256, | 49 kDefaultTileWidth = 256, |
| 48 kDefaultTileHeight = 256 | 50 kDefaultTileHeight = 256 |
| 49 }; | 51 }; |
| 50 | 52 |
| 51 void PictureRenderer::init(const SkPicture* pict, | 53 void PictureRenderer::init(const SkPicture* pict, |
| 52 const SkString* writePath, | 54 const SkString* writePath, |
| 53 const SkString* mismatchPath, | 55 const SkString* mismatchPath, |
| 54 const SkString* inputFilename, | 56 const SkString* inputFilename, |
| 55 bool useChecksumBasedFilenames) { | 57 bool useChecksumBasedFilenames, |
| 58 bool useMultiPictureDraw) { |
| 56 this->CopyString(&fWritePath, writePath); | 59 this->CopyString(&fWritePath, writePath); |
| 57 this->CopyString(&fMismatchPath, mismatchPath); | 60 this->CopyString(&fMismatchPath, mismatchPath); |
| 58 this->CopyString(&fInputFilename, inputFilename); | 61 this->CopyString(&fInputFilename, inputFilename); |
| 59 fUseChecksumBasedFilenames = useChecksumBasedFilenames; | 62 fUseChecksumBasedFilenames = useChecksumBasedFilenames; |
| 63 fUseMultiPictureDraw = useMultiPictureDraw; |
| 60 | 64 |
| 61 SkASSERT(NULL == fPicture); | 65 SkASSERT(NULL == fPicture); |
| 62 SkASSERT(NULL == fCanvas.get()); | 66 SkASSERT(NULL == fCanvas.get()); |
| 63 if (fPicture || fCanvas.get()) { | 67 if (fPicture || fCanvas.get()) { |
| 64 return; | 68 return; |
| 65 } | 69 } |
| 66 | 70 |
| 67 SkASSERT(pict != NULL); | 71 SkASSERT(pict != NULL); |
| 68 if (NULL == pict) { | 72 if (NULL == pict) { |
| 69 return; | 73 return; |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 } | 412 } |
| 409 | 413 |
| 410 SkString PipePictureRenderer::getConfigNameInternal() { | 414 SkString PipePictureRenderer::getConfigNameInternal() { |
| 411 return SkString("pipe"); | 415 return SkString("pipe"); |
| 412 } | 416 } |
| 413 | 417 |
| 414 ////////////////////////////////////////////////////////////////////////////////
/////////////// | 418 ////////////////////////////////////////////////////////////////////////////////
/////////////// |
| 415 | 419 |
| 416 void SimplePictureRenderer::init(const SkPicture* picture, const SkString* write
Path, | 420 void SimplePictureRenderer::init(const SkPicture* picture, const SkString* write
Path, |
| 417 const SkString* mismatchPath, const SkString* i
nputFilename, | 421 const SkString* mismatchPath, const SkString* i
nputFilename, |
| 418 bool useChecksumBasedFilenames) { | 422 bool useChecksumBasedFilenames, bool useMultiPi
ctureDraw) { |
| 419 INHERITED::init(picture, writePath, mismatchPath, inputFilename, useChecksum
BasedFilenames); | 423 INHERITED::init(picture, writePath, mismatchPath, inputFilename, |
| 424 useChecksumBasedFilenames, useMultiPictureDraw); |
| 420 this->buildBBoxHierarchy(); | 425 this->buildBBoxHierarchy(); |
| 421 } | 426 } |
| 422 | 427 |
| 423 bool SimplePictureRenderer::render(SkBitmap** out) { | 428 bool SimplePictureRenderer::render(SkBitmap** out) { |
| 424 SkASSERT(fCanvas.get() != NULL); | 429 SkASSERT(fCanvas.get() != NULL); |
| 425 SkASSERT(fPicture); | 430 SkASSERT(fPicture); |
| 426 if (NULL == fCanvas.get() || NULL == fPicture) { | 431 if (NULL == fCanvas.get() || NULL == fPicture) { |
| 427 return false; | 432 return false; |
| 428 } | 433 } |
| 429 | 434 |
| 430 fCanvas->drawPicture(fPicture); | 435 if (fUseMultiPictureDraw) { |
| 436 SkMultiPictureDraw mpd; |
| 437 |
| 438 mpd.add(fCanvas, fPicture); |
| 439 |
| 440 mpd.draw(); |
| 441 } else { |
| 442 fCanvas->drawPicture(fPicture); |
| 443 } |
| 431 fCanvas->flush(); | 444 fCanvas->flush(); |
| 432 if (out) { | 445 if (out) { |
| 433 *out = SkNEW(SkBitmap); | 446 *out = SkNEW(SkBitmap); |
| 434 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()), | 447 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()), |
| 435 SkScalarCeilToInt(fPicture->cullRect().height())); | 448 SkScalarCeilToInt(fPicture->cullRect().height())); |
| 436 fCanvas->readPixels(*out, 0, 0); | 449 fCanvas->readPixels(*out, 0, 0); |
| 437 } | 450 } |
| 438 if (fEnableWrites) { | 451 if (fEnableWrites) { |
| 439 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu
mmaryPtr, | 452 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu
mmaryPtr, |
| 440 fUseChecksumBasedFilenames); | 453 fUseChecksumBasedFilenames); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 460 , fTileHeight(kDefaultTileHeight) | 473 , fTileHeight(kDefaultTileHeight) |
| 461 , fTileWidthPercentage(0.0) | 474 , fTileWidthPercentage(0.0) |
| 462 , fTileHeightPercentage(0.0) | 475 , fTileHeightPercentage(0.0) |
| 463 , fTileMinPowerOf2Width(0) | 476 , fTileMinPowerOf2Width(0) |
| 464 , fCurrentTileOffset(-1) | 477 , fCurrentTileOffset(-1) |
| 465 , fTilesX(0) | 478 , fTilesX(0) |
| 466 , fTilesY(0) { } | 479 , fTilesY(0) { } |
| 467 | 480 |
| 468 void TiledPictureRenderer::init(const SkPicture* pict, const SkString* writePath
, | 481 void TiledPictureRenderer::init(const SkPicture* pict, const SkString* writePath
, |
| 469 const SkString* mismatchPath, const SkString* in
putFilename, | 482 const SkString* mismatchPath, const SkString* in
putFilename, |
| 470 bool useChecksumBasedFilenames) { | 483 bool useChecksumBasedFilenames, bool useMultiPic
tureDraw) { |
| 471 SkASSERT(pict); | 484 SkASSERT(pict); |
| 472 SkASSERT(0 == fTileRects.count()); | 485 SkASSERT(0 == fTileRects.count()); |
| 473 if (NULL == pict || fTileRects.count() != 0) { | 486 if (NULL == pict || fTileRects.count() != 0) { |
| 474 return; | 487 return; |
| 475 } | 488 } |
| 476 | 489 |
| 477 // Do not call INHERITED::init(), which would create a (potentially large) c
anvas which is not | 490 // Do not call INHERITED::init(), which would create a (potentially large) c
anvas which is not |
| 478 // used by bench_pictures. | 491 // used by bench_pictures. |
| 479 fPicture.reset(pict)->ref(); | 492 fPicture.reset(pict)->ref(); |
| 480 this->CopyString(&fWritePath, writePath); | 493 this->CopyString(&fWritePath, writePath); |
| 481 this->CopyString(&fMismatchPath, mismatchPath); | 494 this->CopyString(&fMismatchPath, mismatchPath); |
| 482 this->CopyString(&fInputFilename, inputFilename); | 495 this->CopyString(&fInputFilename, inputFilename); |
| 483 fUseChecksumBasedFilenames = useChecksumBasedFilenames; | 496 fUseChecksumBasedFilenames = useChecksumBasedFilenames; |
| 497 fUseMultiPictureDraw = useMultiPictureDraw; |
| 484 this->buildBBoxHierarchy(); | 498 this->buildBBoxHierarchy(); |
| 485 | 499 |
| 486 if (fTileWidthPercentage > 0) { | 500 if (fTileWidthPercentage > 0) { |
| 487 fTileWidth = SkScalarCeilToInt(float(fTileWidthPercentage * fPicture->cu
llRect().width() / 100)); | 501 fTileWidth = SkScalarCeilToInt(float(fTileWidthPercentage * fPicture->cu
llRect().width() / 100)); |
| 488 } | 502 } |
| 489 if (fTileHeightPercentage > 0) { | 503 if (fTileHeightPercentage > 0) { |
| 490 fTileHeight = SkScalarCeilToInt(float(fTileHeightPercentage * fPicture->
cullRect().height() / 100)); | 504 fTileHeight = SkScalarCeilToInt(float(fTileHeightPercentage * fPicture->
cullRect().height() / 100)); |
| 491 } | 505 } |
| 492 | 506 |
| 493 if (fTileMinPowerOf2Width > 0) { | 507 if (fTileMinPowerOf2Width > 0) { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 512 const int height = this->getViewHeight(); | 526 const int height = this->getViewHeight(); |
| 513 | 527 |
| 514 fTilesX = fTilesY = 0; | 528 fTilesX = fTilesY = 0; |
| 515 for (int tile_y_start = 0; tile_y_start < height; tile_y_start += fTileHeigh
t) { | 529 for (int tile_y_start = 0; tile_y_start < height; tile_y_start += fTileHeigh
t) { |
| 516 fTilesY++; | 530 fTilesY++; |
| 517 for (int tile_x_start = 0; tile_x_start < width; tile_x_start += fTileWi
dth) { | 531 for (int tile_x_start = 0; tile_x_start < width; tile_x_start += fTileWi
dth) { |
| 518 if (0 == tile_y_start) { | 532 if (0 == tile_y_start) { |
| 519 // Only count tiles in the X direction on the first pass. | 533 // Only count tiles in the X direction on the first pass. |
| 520 fTilesX++; | 534 fTilesX++; |
| 521 } | 535 } |
| 522 *fTileRects.append() = SkRect::MakeXYWH(SkIntToScalar(tile_x_start), | 536 *fTileRects.append() = SkIRect::MakeXYWH(tile_x_start, tile_y_start, |
| 523 SkIntToScalar(tile_y_start), | 537 fTileWidth, fTileHeight); |
| 524 SkIntToScalar(fTileWidth), | |
| 525 SkIntToScalar(fTileHeight)); | |
| 526 } | 538 } |
| 527 } | 539 } |
| 528 } | 540 } |
| 529 | 541 |
| 530 bool TiledPictureRenderer::tileDimensions(int &x, int &y) { | 542 bool TiledPictureRenderer::tileDimensions(int &x, int &y) { |
| 531 if (fTileRects.count() == 0 || NULL == fPicture) { | 543 if (fTileRects.count() == 0 || NULL == fPicture) { |
| 532 return false; | 544 return false; |
| 533 } | 545 } |
| 534 x = fTilesX; | 546 x = fTilesX; |
| 535 y = fTilesY; | 547 y = fTilesY; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 // to draw each tile. | 580 // to draw each tile. |
| 569 fTileWidth = current_width; | 581 fTileWidth = current_width; |
| 570 | 582 |
| 571 while (current_width >= fTileMinPowerOf2Width) { | 583 while (current_width >= fTileMinPowerOf2Width) { |
| 572 // It is very important this is a bitwise AND. | 584 // It is very important this is a bitwise AND. |
| 573 if (current_width & rounded_value) { | 585 if (current_width & rounded_value) { |
| 574 if (0 == tile_y_start) { | 586 if (0 == tile_y_start) { |
| 575 // Only count tiles in the X direction on the first pass. | 587 // Only count tiles in the X direction on the first pass. |
| 576 fTilesX++; | 588 fTilesX++; |
| 577 } | 589 } |
| 578 *fTileRects.append() = SkRect::MakeXYWH(SkIntToScalar(tile_x_sta
rt), | 590 *fTileRects.append() = SkIRect::MakeXYWH(tile_x_start, tile_y_st
art, |
| 579 SkIntToScalar(tile_y_sta
rt), | 591 current_width, fTileHei
ght); |
| 580 SkIntToScalar(current_wi
dth), | |
| 581 SkIntToScalar(fTileHeigh
t)); | |
| 582 tile_x_start += current_width; | 592 tile_x_start += current_width; |
| 583 } | 593 } |
| 584 | 594 |
| 585 current_width >>= 1; | 595 current_width >>= 1; |
| 586 } | 596 } |
| 587 } | 597 } |
| 588 } | 598 } |
| 589 | 599 |
| 590 /** | 600 /** |
| 591 * Draw the specified picture to the canvas translated to rectangle provided, so
that this mini | 601 * Draw the specified picture to the canvas translated to rectangle provided, so
that this mini |
| 592 * canvas represents the rectangle's portion of the overall picture. | 602 * canvas represents the rectangle's portion of the overall picture. |
| 593 * Saves and restores so that the initial clip and matrix return to their state
before this function | 603 * Saves and restores so that the initial clip and matrix return to their state
before this function |
| 594 * is called. | 604 * is called. |
| 595 */ | 605 */ |
| 596 static void draw_tile_to_canvas(SkCanvas* canvas, | 606 static void draw_tile_to_canvas(SkCanvas* canvas, |
| 597 const SkRect& tileRect, | 607 const SkIRect& tileRect, |
| 598 const SkPicture* picture) { | 608 const SkPicture* picture) { |
| 599 int saveCount = canvas->save(); | 609 int saveCount = canvas->save(); |
| 600 // Translate so that we draw the correct portion of the picture. | 610 // Translate so that we draw the correct portion of the picture. |
| 601 // Perform a postTranslate so that the scaleFactor does not interfere with t
he positioning. | 611 // Perform a postTranslate so that the scaleFactor does not interfere with t
he positioning. |
| 602 SkMatrix mat(canvas->getTotalMatrix()); | 612 SkMatrix mat(canvas->getTotalMatrix()); |
| 603 mat.postTranslate(-tileRect.fLeft, -tileRect.fTop); | 613 mat.postTranslate(-SkIntToScalar(tileRect.fLeft), -SkIntToScalar(tileRect.fT
op)); |
| 604 canvas->setMatrix(mat); | 614 canvas->setMatrix(mat); |
| 605 canvas->drawPicture(picture); | 615 canvas->drawPicture(picture); |
| 606 canvas->restoreToCount(saveCount); | 616 canvas->restoreToCount(saveCount); |
| 607 canvas->flush(); | 617 canvas->flush(); |
| 608 } | 618 } |
| 609 | 619 |
| 610 ////////////////////////////////////////////////////////////////////////////////
/////////////// | 620 ////////////////////////////////////////////////////////////////////////////////
/////////////// |
| 611 | 621 |
| 612 /** | 622 /** |
| 613 * Copies the entirety of the src bitmap (typically a tile) into a portion of th
e dst bitmap. | 623 * Copies the entirety of the src bitmap (typically a tile) into a portion of th
e dst bitmap. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 636 return true; | 646 return true; |
| 637 } | 647 } |
| 638 return false; | 648 return false; |
| 639 } | 649 } |
| 640 | 650 |
| 641 void TiledPictureRenderer::drawCurrentTile() { | 651 void TiledPictureRenderer::drawCurrentTile() { |
| 642 SkASSERT(fCurrentTileOffset >= 0 && fCurrentTileOffset < fTileRects.count())
; | 652 SkASSERT(fCurrentTileOffset >= 0 && fCurrentTileOffset < fTileRects.count())
; |
| 643 draw_tile_to_canvas(fCanvas, fTileRects[fCurrentTileOffset], fPicture); | 653 draw_tile_to_canvas(fCanvas, fTileRects[fCurrentTileOffset], fPicture); |
| 644 } | 654 } |
| 645 | 655 |
| 656 bool TiledPictureRenderer::postRender(SkCanvas* canvas, const SkIRect& tileRect,
|
| 657 SkBitmap* tempBM, SkBitmap** out, |
| 658 int tileNumber) { |
| 659 bool success = true; |
| 660 |
| 661 if (fEnableWrites) { |
| 662 success &= write(canvas, fWritePath, fMismatchPath, fInputFilename, fJso
nSummaryPtr, |
| 663 fUseChecksumBasedFilenames, &tileNumber); |
| 664 } |
| 665 if (out) { |
| 666 if (canvas->readPixels(tempBM, 0, 0)) { |
| 667 // Add this tile to the entire bitmap. |
| 668 bitmapCopyAtOffset(*tempBM, *out, tileRect.left(), tileRect.top()); |
| 669 } else { |
| 670 success = false; |
| 671 } |
| 672 } |
| 673 |
| 674 return success; |
| 675 } |
| 676 |
| 646 bool TiledPictureRenderer::render(SkBitmap** out) { | 677 bool TiledPictureRenderer::render(SkBitmap** out) { |
| 647 SkASSERT(fPicture != NULL); | 678 SkASSERT(fPicture != NULL); |
| 648 if (NULL == fPicture) { | 679 if (NULL == fPicture) { |
| 649 return false; | 680 return false; |
| 650 } | 681 } |
| 651 | 682 |
| 652 SkBitmap bitmap; | 683 SkBitmap bitmap; |
| 653 if (out){ | 684 if (out) { |
| 654 *out = SkNEW(SkBitmap); | 685 *out = SkNEW(SkBitmap); |
| 655 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()), | 686 setup_bitmap(*out, SkScalarCeilToInt(fPicture->cullRect().width()), |
| 656 SkScalarCeilToInt(fPicture->cullRect().height())); | 687 SkScalarCeilToInt(fPicture->cullRect().height())); |
| 657 setup_bitmap(&bitmap, fTileWidth, fTileHeight); | 688 setup_bitmap(&bitmap, fTileWidth, fTileHeight); |
| 658 } | 689 } |
| 659 bool success = true; | 690 bool success = true; |
| 660 for (int i = 0; i < fTileRects.count(); ++i) { | 691 |
| 661 draw_tile_to_canvas(fCanvas, fTileRects[i], fPicture); | 692 if (fUseMultiPictureDraw) { |
| 662 if (fEnableWrites) { | 693 SkMultiPictureDraw mpd; |
| 663 success &= write(fCanvas, fWritePath, fMismatchPath, fInputFilename,
fJsonSummaryPtr, | 694 SkTDArray<SkSurface*> surfaces; |
| 664 fUseChecksumBasedFilenames, &i); | 695 surfaces.setReserve(fTileRects.count()); |
| 696 |
| 697 // Create a separate SkSurface/SkCanvas for each tile along with a |
| 698 // translated version of the skp (to mimic Chrome's behavior) and |
| 699 // feed all such pairs to the MultiPictureDraw. |
| 700 for (int i = 0; i < fTileRects.count(); ++i) { |
| 701 SkImageInfo ii = fCanvas->imageInfo().makeWH(fTileRects[i].width(), |
| 702 fTileRects[i].height())
; |
| 703 *surfaces.append() = fCanvas->newSurface(ii); |
| 704 surfaces[i]->getCanvas()->setMatrix(fCanvas->getTotalMatrix()); |
| 705 |
| 706 SkPictureRecorder recorder; |
| 707 SkCanvas* c = recorder.beginRecording(SkIntToScalar(fTileRects[i].wi
dth()), |
| 708 SkIntToScalar(fTileRects[i].he
ight())); |
| 709 c->save(); |
| 710 SkMatrix mat; |
| 711 mat.setTranslate(-SkIntToScalar(fTileRects[i].fLeft), |
| 712 -SkIntToScalar(fTileRects[i].fTop)); |
| 713 c->setMatrix(mat); |
| 714 c->drawPicture(fPicture); |
| 715 c->restore(); |
| 716 |
| 717 SkAutoTUnref<SkPicture> xlatedPicture(recorder.endRecording()); |
| 718 |
| 719 mpd.add(surfaces[i]->getCanvas(), xlatedPicture); |
| 665 } | 720 } |
| 666 if (out) { | 721 |
| 667 if (fCanvas->readPixels(&bitmap, 0, 0)) { | 722 // Render all the buffered SkCanvases/SkPictures |
| 668 // Add this tile to the entire bitmap. | 723 mpd.draw(); |
| 669 bitmapCopyAtOffset(bitmap, *out, SkScalarFloorToInt(fTileRects[i
].left()), | 724 |
| 670 SkScalarFloorToInt(fTileRects[i].top())); | 725 // Sort out the results and cleanup the allocated surfaces |
| 671 } else { | 726 for (int i = 0; i < fTileRects.count(); ++i) { |
| 672 success = false; | 727 success &= this->postRender(surfaces[i]->getCanvas(), fTileRects[i],
&bitmap, out, i); |
| 673 } | 728 surfaces[i]->unref(); |
| 729 } |
| 730 } else { |
| 731 for (int i = 0; i < fTileRects.count(); ++i) { |
| 732 draw_tile_to_canvas(fCanvas, fTileRects[i], fPicture); |
| 733 success &= this->postRender(fCanvas, fTileRects[i], &bitmap, out, i)
; |
| 674 } | 734 } |
| 675 } | 735 } |
| 736 |
| 676 return success; | 737 return success; |
| 677 } | 738 } |
| 678 | 739 |
| 679 SkCanvas* TiledPictureRenderer::setupCanvas(int width, int height) { | 740 SkCanvas* TiledPictureRenderer::setupCanvas(int width, int height) { |
| 680 SkCanvas* canvas = this->INHERITED::setupCanvas(width, height); | 741 SkCanvas* canvas = this->INHERITED::setupCanvas(width, height); |
| 681 SkASSERT(fPicture); | 742 SkASSERT(fPicture); |
| 682 // Clip the tile to an area that is completely inside both the SkPicture and
the viewport. This | 743 // Clip the tile to an area that is completely inside both the SkPicture and
the viewport. This |
| 683 // is mostly important for tiles on the right and bottom edges as they may g
o over this area and | 744 // is mostly important for tiles on the right and bottom edges as they may g
o over this area and |
| 684 // the picture may have some commands that draw outside of this area and so
should not actually | 745 // the picture may have some commands that draw outside of this area and so
should not actually |
| 685 // be written. | 746 // be written. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { | 842 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { |
| 782 return SkNEW_ARGS(GatherRenderer, (opts)); | 843 return SkNEW_ARGS(GatherRenderer, (opts)); |
| 783 } | 844 } |
| 784 #else | 845 #else |
| 785 PictureRenderer* CreateGatherPixelRefsRenderer() { | 846 PictureRenderer* CreateGatherPixelRefsRenderer() { |
| 786 return SkNEW(GatherRenderer); | 847 return SkNEW(GatherRenderer); |
| 787 } | 848 } |
| 788 #endif | 849 #endif |
| 789 | 850 |
| 790 } // namespace sk_tools | 851 } // namespace sk_tools |
| OLD | NEW |