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

Side by Side Diff: tests/PictureTest.cpp

Issue 490253003: Implement SkPicture::bytesUsed() for SkRecord backend (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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
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 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after
1800 this->searchCalls++; 1800 this->searchCalls++;
1801 } 1801 }
1802 1802
1803 // All other methods unimplemented. 1803 // All other methods unimplemented.
1804 virtual void insert(void* data, const SkIRect& bounds, bool defer) {} 1804 virtual void insert(void* data, const SkIRect& bounds, bool defer) {}
1805 virtual void flushDeferredInserts() {} 1805 virtual void flushDeferredInserts() {}
1806 virtual void clear() {} 1806 virtual void clear() {}
1807 virtual int getCount() const { return 0; } 1807 virtual int getCount() const { return 0; }
1808 virtual int getDepth() const { return 0; } 1808 virtual int getDepth() const { return 0; }
1809 virtual void rewindInserts() {} 1809 virtual void rewindInserts() {}
1810 virtual size_t bytesUsed() const { return 0; }
1810 }; 1811 };
1811 1812
1812 class SpoonFedBBHFactory : public SkBBHFactory { 1813 class SpoonFedBBHFactory : public SkBBHFactory {
1813 public: 1814 public:
1814 explicit SpoonFedBBHFactory(SkBBoxHierarchy* bbh) : fBBH(bbh) {} 1815 explicit SpoonFedBBHFactory(SkBBoxHierarchy* bbh) : fBBH(bbh) {}
1815 virtual SkBBoxHierarchy* operator()(int width, int height) const { 1816 virtual SkBBoxHierarchy* operator()(int width, int height) const {
1816 return SkRef(fBBH); 1817 return SkRef(fBBH);
1817 } 1818 }
1818 private: 1819 private:
1819 SkBBoxHierarchy* fBBH; 1820 SkBBoxHierarchy* fBBH;
1820 }; 1821 };
1821 1822
1822 // When the canvas clip covers the full picture, we don't need to call the BBH. 1823 // When the canvas clip covers the full picture, we don't need to call the BBH.
1823 DEF_TEST(Picture_SkipBBH, r) { 1824 DEF_TEST(Picture_SkipBBH, r) {
1824 CountingBBH bbh; 1825 CountingBBH bbh;
1825 SpoonFedBBHFactory factory(&bbh); 1826 SpoonFedBBHFactory factory(&bbh);
1826 1827
1827 SkPictureRecorder recorder; 1828 SkPictureRecorder recorder;
1828 recorder.beginRecording(320, 240, &factory); 1829 recorder.beginRecording(320, 240, &factory);
1829 SkAutoTUnref<const SkPicture> picture(recorder.endRecording()); 1830 SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
1830 1831
1831 SkCanvas big(640, 480), small(300, 200); 1832 SkCanvas big(640, 480), small(300, 200);
1832 1833
1833 picture->draw(&big); 1834 picture->draw(&big);
1834 REPORTER_ASSERT(r, bbh.searchCalls == 0); 1835 REPORTER_ASSERT(r, bbh.searchCalls == 0);
1835 1836
1836 picture->draw(&small); 1837 picture->draw(&small);
1837 REPORTER_ASSERT(r, bbh.searchCalls == 1); 1838 REPORTER_ASSERT(r, bbh.searchCalls == 1);
1838 } 1839 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698