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

Unified Diff: tests/PictureTest.cpp

Issue 485703002: Counterproposal for skirting the BBH when the query fully contains the picture. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: explain 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PictureTest.cpp
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index b3f13f03a6ee00da479394449cd5b21aaa1fb240..0e56c3bb7b263f0173a28447ca2dd74104a4535e 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -5,6 +5,7 @@
* found in the LICENSE file.
*/
+#include "SkBBoxHierarchy.h"
#include "SkBlurImageFilter.h"
#include "SkCanvas.h"
#include "SkColorPriv.h"
@@ -662,7 +663,7 @@ static void test_gatherpixelrefsandrects(skiatest::Reporter* reporter) {
}
#ifdef SK_DEBUG
-// Ensure that deleting an empty SkPicture does not assert. Asserts only fire
+// Ensure that deleting an empty SkPicture does not assert. Asserts only fire
// in debug mode, so only run in debug mode.
static void test_deleting_empty_picture() {
SkPictureRecorder recorder;
@@ -1658,3 +1659,49 @@ DEF_TEST(DontOptimizeSaveLayerDrawDrawRestore, reporter) {
REPORTER_ASSERT(reporter, replayBM.getColor(30, 30) == 0xff000080);
REPORTER_ASSERT(reporter, replayBM.getColor(55, 55) == 0xff800000);
}
+
+struct CountingBBH : public SkBBoxHierarchy {
+ mutable int searchCalls;
+
+ CountingBBH() : searchCalls(0) {}
+
+ virtual void search(const SkIRect& query, SkTDArray<void*>* results) const {
+ this->searchCalls++;
+ }
+
+ // All other methods unimplemented.
+ virtual void insert(void* data, const SkIRect& bounds, bool defer) {}
+ virtual void flushDeferredInserts() {}
+ virtual void clear() {}
+ virtual int getCount() const { return 0; }
+ virtual int getDepth() const { return 0; }
+ virtual void rewindInserts() {}
+};
+
+class SpoonFedBBHFactory : public SkBBHFactory {
+public:
+ explicit SpoonFedBBHFactory(SkBBoxHierarchy* bbh) : fBBH(bbh) {}
+ virtual SkBBoxHierarchy* operator()(int width, int height) const {
+ return SkRef(fBBH);
+ }
+private:
+ SkBBoxHierarchy* fBBH;
+};
+
+// When the canvas clip covers the full picture, we don't need to call the BBH.
+DEF_TEST(Picture_SkipBBH, r) {
+ CountingBBH bbh;
+ SpoonFedBBHFactory factory(&bbh);
+
+ SkPictureRecorder recorder;
+ recorder.beginRecording(320, 240, &factory);
+ SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
+
+ SkCanvas big(640, 480), small(300, 200);
+
+ picture->draw(&big);
+ REPORTER_ASSERT(r, bbh.searchCalls == 0);
+
+ picture->draw(&small);
+ REPORTER_ASSERT(r, bbh.searchCalls == 1);
+}
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698