Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: tools/PictureRenderer.cpp

Issue 788143007: add const to encodePixels pixel parameter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/PictureTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « tests/PictureTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698