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" |
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
390 PipeController pipeController(fCanvas.get()); | 390 PipeController pipeController(fCanvas.get()); |
391 SkGPipeWriter writer; | 391 SkGPipeWriter writer; |
392 SkCanvas* pipeCanvas = writer.startRecording(&pipeController); | 392 SkCanvas* pipeCanvas = writer.startRecording(&pipeController); |
393 pipeCanvas->drawPicture(*fPicture); | 393 pipeCanvas->drawPicture(*fPicture); |
394 writer.endRecording(); | 394 writer.endRecording(); |
395 fCanvas->flush(); | 395 fCanvas->flush(); |
396 if (NULL != out) { | 396 if (NULL != out) { |
397 *out = SkNEW(SkBitmap); | 397 *out = SkNEW(SkBitmap); |
398 setup_bitmap(*out, fPicture->width(), fPicture->height()); | 398 setup_bitmap(*out, fPicture->width(), fPicture->height()); |
399 fCanvas->readPixels(*out, 0, 0); | 399 fCanvas->readPixels(*out, 0, 0); |
400 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu mmaryPtr, | |
epoger
2014/05/21 19:25:37
The changes in here were exactly what Brian sent m
| |
401 fUseChecksumBasedFilenames); | |
400 } | 402 } |
401 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummar yPtr, | 403 return true; |
402 fUseChecksumBasedFilenames); | |
403 } | 404 } |
404 | 405 |
405 SkString PipePictureRenderer::getConfigNameInternal() { | 406 SkString PipePictureRenderer::getConfigNameInternal() { |
406 return SkString("pipe"); | 407 return SkString("pipe"); |
407 } | 408 } |
408 | 409 |
409 //////////////////////////////////////////////////////////////////////////////// /////////////// | 410 //////////////////////////////////////////////////////////////////////////////// /////////////// |
410 | 411 |
411 void SimplePictureRenderer::init(SkPicture* picture, const SkString* writePath, | 412 void SimplePictureRenderer::init(SkPicture* picture, const SkString* writePath, |
412 const SkString* mismatchPath, const SkString* i nputFilename, | 413 const SkString* mismatchPath, const SkString* i nputFilename, |
413 bool useChecksumBasedFilenames) { | 414 bool useChecksumBasedFilenames) { |
414 INHERITED::init(picture, writePath, mismatchPath, inputFilename, useChecksum BasedFilenames); | 415 INHERITED::init(picture, writePath, mismatchPath, inputFilename, useChecksum BasedFilenames); |
415 this->buildBBoxHierarchy(); | 416 this->buildBBoxHierarchy(); |
416 } | 417 } |
417 | 418 |
418 bool SimplePictureRenderer::render(SkBitmap** out) { | 419 bool SimplePictureRenderer::render(SkBitmap** out) { |
419 SkASSERT(fCanvas.get() != NULL); | 420 SkASSERT(fCanvas.get() != NULL); |
420 SkASSERT(NULL != fPicture); | 421 SkASSERT(NULL != fPicture); |
421 if (NULL == fCanvas.get() || NULL == fPicture) { | 422 if (NULL == fCanvas.get() || NULL == fPicture) { |
422 return false; | 423 return false; |
423 } | 424 } |
424 | 425 |
425 fCanvas->drawPicture(*fPicture); | 426 fCanvas->drawPicture(*fPicture); |
426 fCanvas->flush(); | 427 fCanvas->flush(); |
427 if (NULL != out) { | 428 if (NULL != out) { |
428 *out = SkNEW(SkBitmap); | 429 *out = SkNEW(SkBitmap); |
429 setup_bitmap(*out, fPicture->width(), fPicture->height()); | 430 setup_bitmap(*out, fPicture->width(), fPicture->height()); |
430 fCanvas->readPixels(*out, 0, 0); | 431 fCanvas->readPixels(*out, 0, 0); |
432 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu mmaryPtr, | |
433 fUseChecksumBasedFilenames); | |
431 } | 434 } |
432 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummar yPtr, | 435 return true; |
433 fUseChecksumBasedFilenames); | |
434 } | 436 } |
435 | 437 |
436 SkString SimplePictureRenderer::getConfigNameInternal() { | 438 SkString SimplePictureRenderer::getConfigNameInternal() { |
437 return SkString("simple"); | 439 return SkString("simple"); |
438 } | 440 } |
439 | 441 |
440 //////////////////////////////////////////////////////////////////////////////// /////////////// | 442 //////////////////////////////////////////////////////////////////////////////// /////////////// |
441 | 443 |
442 TiledPictureRenderer::TiledPictureRenderer() | 444 TiledPictureRenderer::TiledPictureRenderer() |
443 : fTileWidth(kDefaultTileWidth) | 445 : fTileWidth(kDefaultTileWidth) |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
633 | 635 |
634 SkBitmap bitmap; | 636 SkBitmap bitmap; |
635 if (out){ | 637 if (out){ |
636 *out = SkNEW(SkBitmap); | 638 *out = SkNEW(SkBitmap); |
637 setup_bitmap(*out, fPicture->width(), fPicture->height()); | 639 setup_bitmap(*out, fPicture->width(), fPicture->height()); |
638 setup_bitmap(&bitmap, fTileWidth, fTileHeight); | 640 setup_bitmap(&bitmap, fTileWidth, fTileHeight); |
639 } | 641 } |
640 bool success = true; | 642 bool success = true; |
641 for (int i = 0; i < fTileRects.count(); ++i) { | 643 for (int i = 0; i < fTileRects.count(); ++i) { |
642 draw_tile_to_canvas(fCanvas, fTileRects[i], fPicture); | 644 draw_tile_to_canvas(fCanvas, fTileRects[i], fPicture); |
643 success &= write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJs onSummaryPtr, | |
644 fUseChecksumBasedFilenames, &i); | |
645 if (NULL != out) { | 645 if (NULL != out) { |
646 success &= write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSummaryPtr, | |
647 fUseChecksumBasedFilenames, &i); | |
646 if (fCanvas->readPixels(&bitmap, 0, 0)) { | 648 if (fCanvas->readPixels(&bitmap, 0, 0)) { |
647 // Add this tile to the entire bitmap. | 649 // Add this tile to the entire bitmap. |
648 bitmapCopyAtOffset(bitmap, *out, SkScalarFloorToInt(fTileRects[i ].left()), | 650 bitmapCopyAtOffset(bitmap, *out, SkScalarFloorToInt(fTileRects[i ].left()), |
649 SkScalarFloorToInt(fTileRects[i].top())); | 651 SkScalarFloorToInt(fTileRects[i].top())); |
650 } else { | 652 } else { |
651 success = false; | 653 success = false; |
652 } | 654 } |
653 } | 655 } |
654 } | 656 } |
655 return success; | 657 return success; |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
949 virtual SkString getConfigNameInternal() SK_OVERRIDE { | 951 virtual SkString getConfigNameInternal() SK_OVERRIDE { |
950 return SkString("picture_clone"); | 952 return SkString("picture_clone"); |
951 } | 953 } |
952 }; | 954 }; |
953 | 955 |
954 PictureRenderer* CreatePictureCloneRenderer() { | 956 PictureRenderer* CreatePictureCloneRenderer() { |
955 return SkNEW(PictureCloneRenderer); | 957 return SkNEW(PictureCloneRenderer); |
956 } | 958 } |
957 | 959 |
958 } // namespace sk_tools | 960 } // namespace sk_tools |
OLD | NEW |