| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 */ | 213 */ |
| 214 void PictureRenderer::buildBBoxHierarchy() { | 214 void PictureRenderer::buildBBoxHierarchy() { |
| 215 SkASSERT(NULL != fPicture); | 215 SkASSERT(NULL != fPicture); |
| 216 if (kNone_BBoxHierarchyType != fBBoxHierarchyType && NULL != fPicture) { | 216 if (kNone_BBoxHierarchyType != fBBoxHierarchyType && NULL != fPicture) { |
| 217 SkAutoTDelete<SkBBHFactory> factory(this->getFactory()); | 217 SkAutoTDelete<SkBBHFactory> factory(this->getFactory()); |
| 218 SkPictureRecorder recorder; | 218 SkPictureRecorder recorder; |
| 219 SkCanvas* canvas = recorder.beginRecording(fPicture->cullRect().width(),
| 219 SkCanvas* canvas = recorder.beginRecording(fPicture->cullRect().width(),
|
| 220 fPicture->cullRect().height()
, | 220 fPicture->cullRect().height()
, |
| 221 factory.get(), | 221 factory.get(), |
| 222 this->recordFlags()); | 222 this->recordFlags()); |
| 223 fPicture->draw(canvas); | 223 fPicture->playback(canvas); |
| 224 fPicture.reset(recorder.endRecording()); | 224 fPicture.reset(recorder.endRecording()); |
| 225 } | 225 } |
| 226 } | 226 } |
| 227 | 227 |
| 228 void PictureRenderer::resetState(bool callFinish) { | 228 void PictureRenderer::resetState(bool callFinish) { |
| 229 #if SK_SUPPORT_GPU | 229 #if SK_SUPPORT_GPU |
| 230 SkGLContextHelper* glContext = this->getGLContext(); | 230 SkGLContextHelper* glContext = this->getGLContext(); |
| 231 if (NULL == glContext) { | 231 if (NULL == glContext) { |
| 232 SkASSERT(kBitmap_DeviceType == fDeviceType); | 232 SkASSERT(kBitmap_DeviceType == fDeviceType); |
| 233 return; | 233 return; |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 } | 354 } |
| 355 | 355 |
| 356 bool RecordPictureRenderer::render(SkBitmap** out) { | 356 bool RecordPictureRenderer::render(SkBitmap** out) { |
| 357 SkAutoTDelete<SkBBHFactory> factory(this->getFactory()); | 357 SkAutoTDelete<SkBBHFactory> factory(this->getFactory()); |
| 358 SkPictureRecorder recorder; | 358 SkPictureRecorder recorder; |
| 359 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(this->getViewWidth(
)), | 359 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(this->getViewWidth(
)), |
| 360 SkIntToScalar(this->getViewHeight
()), | 360 SkIntToScalar(this->getViewHeight
()), |
| 361 factory.get(), | 361 factory.get(), |
| 362 this->recordFlags()); | 362 this->recordFlags()); |
| 363 this->scaleToScaleFactor(canvas); | 363 this->scaleToScaleFactor(canvas); |
| 364 fPicture->draw(canvas); | 364 fPicture->playback(canvas); |
| 365 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); | 365 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); |
| 366 if (!fWritePath.isEmpty()) { | 366 if (!fWritePath.isEmpty()) { |
| 367 // Record the new picture as a new SKP with PNG encoded bitmaps. | 367 // Record the new picture as a new SKP with PNG encoded bitmaps. |
| 368 SkString skpPath = SkOSPath::Join(fWritePath.c_str(), fInputFilename.c_s
tr()); | 368 SkString skpPath = SkOSPath::Join(fWritePath.c_str(), fInputFilename.c_s
tr()); |
| 369 SkFILEWStream stream(skpPath.c_str()); | 369 SkFILEWStream stream(skpPath.c_str()); |
| 370 picture->serialize(&stream, &encode_bitmap_to_data); | 370 picture->serialize(&stream, &encode_bitmap_to_data); |
| 371 return true; | 371 return true; |
| 372 } | 372 } |
| 373 return false; | 373 return false; |
| 374 } | 374 } |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { | 780 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { |
| 781 return SkNEW_ARGS(GatherRenderer, (opts)); | 781 return SkNEW_ARGS(GatherRenderer, (opts)); |
| 782 } | 782 } |
| 783 #else | 783 #else |
| 784 PictureRenderer* CreateGatherPixelRefsRenderer() { | 784 PictureRenderer* CreateGatherPixelRefsRenderer() { |
| 785 return SkNEW(GatherRenderer); | 785 return SkNEW(GatherRenderer); |
| 786 } | 786 } |
| 787 #endif | 787 #endif |
| 788 | 788 |
| 789 } // namespace sk_tools | 789 } // namespace sk_tools |
| OLD | NEW |