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

Side by Side Diff: tests/PictureTest.cpp

Issue 1020103005: Preserve texture compression when saving a revised skp from debugger (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: clean up Created 5 years, 9 months 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 | « gm/displacement.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 10 matching lines...) Expand all
21 #include "SkPicture.h" 21 #include "SkPicture.h"
22 #include "SkPictureRecorder.h" 22 #include "SkPictureRecorder.h"
23 #include "SkPictureUtils.h" 23 #include "SkPictureUtils.h"
24 #include "SkPixelRef.h" 24 #include "SkPixelRef.h"
25 #include "SkPixelSerializer.h" 25 #include "SkPixelSerializer.h"
26 #include "SkRRect.h" 26 #include "SkRRect.h"
27 #include "SkRandom.h" 27 #include "SkRandom.h"
28 #include "SkRecord.h" 28 #include "SkRecord.h"
29 #include "SkShader.h" 29 #include "SkShader.h"
30 #include "SkStream.h" 30 #include "SkStream.h"
31 #include "sk_tool_utils.h"
31 32
32 #if SK_SUPPORT_GPU 33 #if SK_SUPPORT_GPU
33 #include "SkSurface.h" 34 #include "SkSurface.h"
34 #include "GrContextFactory.h" 35 #include "GrContextFactory.h"
35 #endif 36 #endif
36 #include "Test.h" 37 #include "Test.h"
37 38
38 #include "SkLumaColorFilter.h" 39 #include "SkLumaColorFilter.h"
39 #include "SkColorFilterImageFilter.h" 40 #include "SkColorFilterImageFilter.h"
40 41
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 SkPictureRecorder recorder; 824 SkPictureRecorder recorder;
824 SkCanvas* recordingCanvas = recorder.beginRecording(100, 100); 825 SkCanvas* recordingCanvas = recorder.beginRecording(100, 100);
825 recordingCanvas->drawBitmap(bm, 0, 0); 826 recordingCanvas->drawBitmap(bm, 0, 0);
826 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 827 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
827 828
828 SkCanvas canvas; 829 SkCanvas canvas;
829 canvas.drawPicture(picture); 830 canvas.drawPicture(picture);
830 } 831 }
831 #endif 832 #endif
832 833
833 // Encodes to PNG, unless there is already encoded data, in which case that gets
834 // used.
835 // FIXME: Share with PictureRenderer.cpp?
836 class PngPixelSerializer : public SkPixelSerializer {
837 public:
838 bool onUseEncodedData(const void*, size_t) SK_OVERRIDE { return true; }
839 SkData* onEncodePixels(const SkImageInfo& info, const void* pixels,
840 size_t rowBytes) SK_OVERRIDE {
841 return SkImageEncoder::EncodeData(info, pixels, rowBytes, SkImageEncoder ::kPNG_Type, 100);
842 }
843 };
844
845 static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) { 834 static SkData* serialized_picture_from_bitmap(const SkBitmap& bitmap) {
846 SkPictureRecorder recorder; 835 SkPictureRecorder recorder;
847 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()), 836 SkCanvas* canvas = recorder.beginRecording(SkIntToScalar(bitmap.width()),
848 SkIntToScalar(bitmap.height())); 837 SkIntToScalar(bitmap.height()));
849 canvas->drawBitmap(bitmap, 0, 0); 838 canvas->drawBitmap(bitmap, 0, 0);
850 SkAutoTUnref<SkPicture> picture(recorder.endRecording()); 839 SkAutoTUnref<SkPicture> picture(recorder.endRecording());
851 840
852 SkDynamicMemoryWStream wStream; 841 SkDynamicMemoryWStream wStream;
853 PngPixelSerializer serializer; 842 sk_tool_utils::PngPixelSerializer serializer;
854 picture->serialize(&wStream, &serializer); 843 picture->serialize(&wStream, &serializer);
855 return wStream.copyToData(); 844 return wStream.copyToData();
856 } 845 }
857 846
858 struct ErrorContext { 847 struct ErrorContext {
859 int fErrors; 848 int fErrors;
860 skiatest::Reporter* fReporter; 849 skiatest::Reporter* fReporter;
861 }; 850 };
862 851
863 static void assert_one_parse_error_cb(SkError error, void* context) { 852 static void assert_one_parse_error_cb(SkError error, void* context) {
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 1304
1316 // The picture shares the immutable pixels but copies the mutable ones. 1305 // The picture shares the immutable pixels but copies the mutable ones.
1317 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1306 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1318 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); 1307 REPORTER_ASSERT(r, !immut.pixelRef()->unique());
1319 1308
1320 // When the picture goes away, it's just our bitmaps holding the refs. 1309 // When the picture goes away, it's just our bitmaps holding the refs.
1321 pic.reset(NULL); 1310 pic.reset(NULL);
1322 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1311 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1323 REPORTER_ASSERT(r, immut.pixelRef()->unique()); 1312 REPORTER_ASSERT(r, immut.pixelRef()->unique());
1324 } 1313 }
OLDNEW
« no previous file with comments | « gm/displacement.cpp ('k') | tools/PictureRenderer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698