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

Side by Side Diff: tests/PictureTest.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 | « src/images/SkImageEncoder.cpp ('k') | tools/PictureRenderer.cpp » ('j') | 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 "SkBBoxHierarchy.h" 8 #include "SkBBoxHierarchy.h"
9 #include "SkBlurImageFilter.h" 9 #include "SkBlurImageFilter.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
(...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 SkCanvas canvas; 1441 SkCanvas canvas;
1442 canvas.drawPicture(picture); 1442 canvas.drawPicture(picture);
1443 } 1443 }
1444 #endif 1444 #endif
1445 1445
1446 // Encodes to PNG, unless there is already encoded data, in which case that gets 1446 // Encodes to PNG, unless there is already encoded data, in which case that gets
1447 // used. 1447 // used.
1448 // FIXME: Share with PictureRenderer.cpp? 1448 // FIXME: Share with PictureRenderer.cpp?
1449 class PngPixelSerializer : public SkPixelSerializer { 1449 class PngPixelSerializer : public SkPixelSerializer {
1450 public: 1450 public:
1451 virtual bool onUseEncodedData(const void*, size_t) SK_OVERRIDE { return true ; } 1451 bool onUseEncodedData(const void*, size_t) SK_OVERRIDE { return true; }
1452 virtual SkData* onEncodePixels(const SkImageInfo& info, void* pixels, 1452 SkData* onEncodePixels(const SkImageInfo& info, const void* pixels,
1453 size_t rowBytes) SK_OVERRIDE { 1453 size_t rowBytes) SK_OVERRIDE {
1454 SkBitmap bm; 1454 return SkImageEncoder::EncodeData(info, pixels, rowBytes, SkImageEncoder ::kPNG_Type, 100);
1455 if (!bm.installPixels(info, pixels, rowBytes)) {
1456 return NULL;
1457 }
1458 return SkImageEncoder::EncodeData(bm, SkImageEncoder::kPNG_Type, 100);
1459 } 1455 }
1460 }; 1456 };
1461 1457
1462 static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) { 1458 static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) {
1463 SkPictureRecorder recorder; 1459 SkPictureRecorder recorder;
1464 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()), 1460 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()),
1465 SkIntToScalar(bitmap.height())); 1461 SkIntToScalar(bitmap.height()));
1466 canvas->drawBitmap(bitmap, 0, 0); 1462 canvas->drawBitmap(bitmap, 0, 0);
1467 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 1463 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
1468 1464
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
1932 1928
1933 // The picture shares the immutable pixels but copies the mutable ones. 1929 // The picture shares the immutable pixels but copies the mutable ones.
1934 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1930 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1935 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); 1931 REPORTER_ASSERT(r, !immut.pixelRef()->unique());
1936 1932
1937 // When the picture goes away, it's just our bitmaps holding the refs. 1933 // When the picture goes away, it's just our bitmaps holding the refs.
1938 pic.reset(NULL); 1934 pic.reset(NULL);
1939 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1935 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1940 REPORTER_ASSERT(r, immut.pixelRef()->unique()); 1936 REPORTER_ASSERT(r, immut.pixelRef()->unique());
1941 } 1937 }
OLDNEW
« no previous file with comments | « src/images/SkImageEncoder.cpp ('k') | tools/PictureRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698