| 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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 bool PipePictureRenderer::render(SkBitmap** out) { | 383 bool PipePictureRenderer::render(SkBitmap** out) { |
| 384 SkASSERT(fCanvas.get() != NULL); | 384 SkASSERT(fCanvas.get() != NULL); |
| 385 SkASSERT(fPicture != NULL); | 385 SkASSERT(fPicture != NULL); |
| 386 if (NULL == fCanvas.get() || NULL == fPicture) { | 386 if (NULL == fCanvas.get() || NULL == fPicture) { |
| 387 return false; | 387 return false; |
| 388 } | 388 } |
| 389 | 389 |
| 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 } | 400 } |
| 401 if (fEnableWrites) { | 401 if (fEnableWrites) { |
| 402 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu
mmaryPtr, | 402 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu
mmaryPtr, |
| 403 fUseChecksumBasedFilenames); | 403 fUseChecksumBasedFilenames); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 419 this->buildBBoxHierarchy(); | 419 this->buildBBoxHierarchy(); |
| 420 } | 420 } |
| 421 | 421 |
| 422 bool SimplePictureRenderer::render(SkBitmap** out) { | 422 bool SimplePictureRenderer::render(SkBitmap** out) { |
| 423 SkASSERT(fCanvas.get() != NULL); | 423 SkASSERT(fCanvas.get() != NULL); |
| 424 SkASSERT(NULL != fPicture); | 424 SkASSERT(NULL != fPicture); |
| 425 if (NULL == fCanvas.get() || NULL == fPicture) { | 425 if (NULL == fCanvas.get() || NULL == fPicture) { |
| 426 return false; | 426 return false; |
| 427 } | 427 } |
| 428 | 428 |
| 429 fCanvas->drawPicture(*fPicture); | 429 fCanvas->drawPicture(fPicture); |
| 430 fCanvas->flush(); | 430 fCanvas->flush(); |
| 431 if (NULL != out) { | 431 if (NULL != out) { |
| 432 *out = SkNEW(SkBitmap); | 432 *out = SkNEW(SkBitmap); |
| 433 setup_bitmap(*out, fPicture->width(), fPicture->height()); | 433 setup_bitmap(*out, fPicture->width(), fPicture->height()); |
| 434 fCanvas->readPixels(*out, 0, 0); | 434 fCanvas->readPixels(*out, 0, 0); |
| 435 } | 435 } |
| 436 if (fEnableWrites) { | 436 if (fEnableWrites) { |
| 437 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu
mmaryPtr, | 437 return write(fCanvas, fWritePath, fMismatchPath, fInputFilename, fJsonSu
mmaryPtr, |
| 438 fUseChecksumBasedFilenames); | 438 fUseChecksumBasedFilenames); |
| 439 } else { | 439 } else { |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 * Saves and restores so that the initial clip and matrix return to their state
before this function | 585 * Saves and restores so that the initial clip and matrix return to their state
before this function |
| 586 * is called. | 586 * is called. |
| 587 */ | 587 */ |
| 588 static void draw_tile_to_canvas(SkCanvas* canvas, const SkRect& tileRect, SkPict
ure* picture) { | 588 static void draw_tile_to_canvas(SkCanvas* canvas, const SkRect& tileRect, SkPict
ure* picture) { |
| 589 int saveCount = canvas->save(); | 589 int saveCount = canvas->save(); |
| 590 // Translate so that we draw the correct portion of the picture. | 590 // Translate so that we draw the correct portion of the picture. |
| 591 // Perform a postTranslate so that the scaleFactor does not interfere with t
he positioning. | 591 // Perform a postTranslate so that the scaleFactor does not interfere with t
he positioning. |
| 592 SkMatrix mat(canvas->getTotalMatrix()); | 592 SkMatrix mat(canvas->getTotalMatrix()); |
| 593 mat.postTranslate(-tileRect.fLeft, -tileRect.fTop); | 593 mat.postTranslate(-tileRect.fLeft, -tileRect.fTop); |
| 594 canvas->setMatrix(mat); | 594 canvas->setMatrix(mat); |
| 595 canvas->drawPicture(*picture); | 595 canvas->drawPicture(picture); |
| 596 canvas->restoreToCount(saveCount); | 596 canvas->restoreToCount(saveCount); |
| 597 canvas->flush(); | 597 canvas->flush(); |
| 598 } | 598 } |
| 599 | 599 |
| 600 ////////////////////////////////////////////////////////////////////////////////
/////////////// | 600 ////////////////////////////////////////////////////////////////////////////////
/////////////// |
| 601 | 601 |
| 602 /** | 602 /** |
| 603 * Copies the entirety of the src bitmap (typically a tile) into a portion of th
e dst bitmap. | 603 * Copies the entirety of the src bitmap (typically a tile) into a portion of th
e dst bitmap. |
| 604 * If the src bitmap is too large to fit within the dst bitmap after the x and y | 604 * If the src bitmap is too large to fit within the dst bitmap after the x and y |
| 605 * offsets have been applied, any excess will be ignored (so only the top-left p
ortion of the | 605 * offsets have been applied, any excess will be ignored (so only the top-left p
ortion of the |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 | 886 |
| 887 ////////////////////////////////////////////////////////////////////////////////
/////////////// | 887 ////////////////////////////////////////////////////////////////////////////////
/////////////// |
| 888 | 888 |
| 889 void PlaybackCreationRenderer::setup() { | 889 void PlaybackCreationRenderer::setup() { |
| 890 SkAutoTDelete<SkBBHFactory> factory(this->getFactory()); | 890 SkAutoTDelete<SkBBHFactory> factory(this->getFactory()); |
| 891 fRecorder.reset(SkNEW(SkPictureRecorder)); | 891 fRecorder.reset(SkNEW(SkPictureRecorder)); |
| 892 SkCanvas* canvas = fRecorder->beginRecording(this->getViewWidth(), this->get
ViewHeight(), | 892 SkCanvas* canvas = fRecorder->beginRecording(this->getViewWidth(), this->get
ViewHeight(), |
| 893 factory.get(), | 893 factory.get(), |
| 894 this->recordFlags()); | 894 this->recordFlags()); |
| 895 this->scaleToScaleFactor(canvas); | 895 this->scaleToScaleFactor(canvas); |
| 896 canvas->drawPicture(*fPicture); | 896 canvas->drawPicture(fPicture); |
| 897 } | 897 } |
| 898 | 898 |
| 899 bool PlaybackCreationRenderer::render(SkBitmap** out) { | 899 bool PlaybackCreationRenderer::render(SkBitmap** out) { |
| 900 fPicture.reset(fRecorder->endRecording()); | 900 fPicture.reset(fRecorder->endRecording()); |
| 901 // Since this class does not actually render, return false. | 901 // Since this class does not actually render, return false. |
| 902 return false; | 902 return false; |
| 903 } | 903 } |
| 904 | 904 |
| 905 SkString PlaybackCreationRenderer::getConfigNameInternal() { | 905 SkString PlaybackCreationRenderer::getConfigNameInternal() { |
| 906 return SkString("playback_creation"); | 906 return SkString("playback_creation"); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 virtual SkString getConfigNameInternal() SK_OVERRIDE { | 964 virtual SkString getConfigNameInternal() SK_OVERRIDE { |
| 965 return SkString("picture_clone"); | 965 return SkString("picture_clone"); |
| 966 } | 966 } |
| 967 }; | 967 }; |
| 968 | 968 |
| 969 PictureRenderer* CreatePictureCloneRenderer() { | 969 PictureRenderer* CreatePictureCloneRenderer() { |
| 970 return SkNEW(PictureCloneRenderer); | 970 return SkNEW(PictureCloneRenderer); |
| 971 } | 971 } |
| 972 | 972 |
| 973 } // namespace sk_tools | 973 } // namespace sk_tools |
| OLD | NEW |