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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 // defer the canvas setup until the render step | 359 // defer the canvas setup until the render step |
360 return NULL; | 360 return NULL; |
361 } | 361 } |
362 | 362 |
363 // Encodes to PNG, unless there is already encoded data, in which case that gets | 363 // Encodes to PNG, unless there is already encoded data, in which case that gets |
364 // used. | 364 // used. |
365 // FIXME: Share with PictureTest.cpp? | 365 // FIXME: Share with PictureTest.cpp? |
366 | 366 |
367 class PngPixelSerializer : public SkPixelSerializer { | 367 class PngPixelSerializer : public SkPixelSerializer { |
368 public: | 368 public: |
369 virtual bool onUseEncodedData(const void*, size_t) SK_OVERRIDE { return true
; } | 369 bool onUseEncodedData(const void*, size_t) SK_OVERRIDE { return true; } |
370 virtual SkData* onEncodePixels(const SkImageInfo& info, void* pixels, | 370 SkData* onEncodePixels(const SkImageInfo& info, const void* pixels, |
371 size_t rowBytes) SK_OVERRIDE { | 371 size_t rowBytes) SK_OVERRIDE { |
372 SkBitmap bm; | 372 return SkImageEncoder::EncodeData(info, pixels, rowBytes, SkImageEncoder
::kPNG_Type, 100); |
373 if (!bm.installPixels(info, pixels, rowBytes)) { | |
374 return NULL; | |
375 } | |
376 return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100); | |
377 } | 373 } |
378 }; | 374 }; |
379 | 375 |
380 bool RecordPictureRenderer::render(SkBitmap** out) { | 376 bool RecordPictureRenderer::render(SkBitmap** out) { |
381 SkAutoTDelete<SkBBHFactory> factory(this->getFactory()); | 377 SkAutoTDelete<SkBBHFactory> factory(this->getFactory()); |
382 SkPictureRecorder recorder; | 378 SkPictureRecorder recorder; |
383 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(this->getViewWidth(
)), | 379 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(this->getViewWidth(
)), |
384 SkIntToScalar(this->getViewHeight
()), | 380 SkIntToScalar(this->getViewHeight
()), |
385 factory.get(), | 381 factory.get(), |
386 this->recordFlags()); | 382 this->recordFlags()); |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
868 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { | 864 PictureRenderer* CreateGatherPixelRefsRenderer(const GrContext::Options& opts) { |
869 return SkNEW_ARGS(GatherRenderer, (opts)); | 865 return SkNEW_ARGS(GatherRenderer, (opts)); |
870 } | 866 } |
871 #else | 867 #else |
872 PictureRenderer* CreateGatherPixelRefsRenderer() { | 868 PictureRenderer* CreateGatherPixelRefsRenderer() { |
873 return SkNEW(GatherRenderer); | 869 return SkNEW(GatherRenderer); |
874 } | 870 } |
875 #endif | 871 #endif |
876 | 872 |
877 } // namespace sk_tools | 873 } // namespace sk_tools |
OLD | NEW |