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

Side by Side Diff: tests/PictureTest.cpp

Issue 732653004: option to return drawable from recording (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/gpu/GrRecordReplaceDraw.cpp ('k') | tests/RecordDrawTest.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 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 SkPictureRecorder recorder; 1726 SkPictureRecorder recorder;
1727 1727
1728 recorder.beginRecording(0, 0); 1728 recorder.beginRecording(0, 0);
1729 SkAutoTUnref<SkPicture> empty(recorder.endRecording()); 1729 SkAutoTUnref<SkPicture> empty(recorder.endRecording());
1730 1730
1731 // Sanity check to make sure we aren't under-measuring. 1731 // Sanity check to make sure we aren't under-measuring.
1732 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get()) >= 1732 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get()) >=
1733 sizeof(SkPicture) + sizeof(SkRecord)); 1733 sizeof(SkPicture) + sizeof(SkRecord));
1734 1734
1735 // Protect against any unintentional bloat. 1735 // Protect against any unintentional bloat.
1736 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(empty.get()) <= 128); 1736 size_t approxUsed = SkPictureUtils::ApproximateBytesUsed(empty.get());
1737 REPORTER_ASSERT(reporter, approxUsed <= 136);
1737 1738
1738 // Sanity check of nested SkPictures. 1739 // Sanity check of nested SkPictures.
1739 SkPictureRecorder r2; 1740 SkPictureRecorder r2;
1740 r2.beginRecording(0, 0); 1741 r2.beginRecording(0, 0);
1741 r2.getRecordingCanvas()->drawPicture(empty.get()); 1742 r2.getRecordingCanvas()->drawPicture(empty.get());
1742 SkAutoTUnref<SkPicture> nested(r2.endRecording()); 1743 SkAutoTUnref<SkPicture> nested(r2.endRecording());
1743 1744
1744 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(nested.get()) > 1745 REPORTER_ASSERT(reporter, SkPictureUtils::ApproximateBytesUsed(nested.get()) >
1745 SkPictureUtils::ApproximateBytesUsed(empty.get())) ; 1746 SkPictureUtils::ApproximateBytesUsed(empty.get())) ;
1746 } 1747 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1898 mut.allocN32Pixels(300, 200); 1899 mut.allocN32Pixels(300, 200);
1899 immut.allocN32Pixels(300, 200); 1900 immut.allocN32Pixels(300, 200);
1900 immut.setImmutable(); 1901 immut.setImmutable();
1901 SkASSERT(!mut.isImmutable()); 1902 SkASSERT(!mut.isImmutable());
1902 SkASSERT(immut.isImmutable()); 1903 SkASSERT(immut.isImmutable());
1903 1904
1904 // No one can hold a ref on our pixels yet. 1905 // No one can hold a ref on our pixels yet.
1905 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1906 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1906 REPORTER_ASSERT(r, immut.pixelRef()->unique()); 1907 REPORTER_ASSERT(r, immut.pixelRef()->unique());
1907 1908
1908 SkPictureRecorder rec; 1909 SkAutoTUnref<const SkPicture> pic;
1909 SkCanvas* canvas = rec.beginRecording(1920, 1200); 1910 {
1910 canvas->drawBitmap(mut, 0, 0); 1911 // we want the recorder to go out of scope before our subsequent checks, so we
1911 canvas->drawBitmap(immut, 800, 600); 1912 // place it inside local braces.
1912 SkAutoTUnref<const SkPicture> pic(rec.endRecording()); 1913 SkPictureRecorder rec;
1914 SkCanvas* canvas = rec.beginRecording(1920, 1200);
1915 canvas->drawBitmap(mut, 0, 0);
1916 canvas->drawBitmap(immut, 800, 600);
1917 pic.reset(rec.endRecording());
1918 }
1913 1919
1914 // The picture shares the immutable pixels but copies the mutable ones. 1920 // The picture shares the immutable pixels but copies the mutable ones.
1915 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1921 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1916 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); 1922 REPORTER_ASSERT(r, !immut.pixelRef()->unique());
1917 1923
1918 // When the picture goes away, it's just our bitmaps holding the refs. 1924 // When the picture goes away, it's just our bitmaps holding the refs.
1919 pic.reset(NULL); 1925 pic.reset(NULL);
1920 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1926 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1921 REPORTER_ASSERT(r, immut.pixelRef()->unique()); 1927 REPORTER_ASSERT(r, immut.pixelRef()->unique());
1922 } 1928 }
OLDNEW
« no previous file with comments | « src/gpu/GrRecordReplaceDraw.cpp ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698