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

Side by Side Diff: tests/PictureTest.cpp

Issue 971803002: Update SkPicture cull rects with RTree information (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix extra line 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 | « src/core/SkRecordDraw.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 1230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 replayCanvas.flush(); 1241 replayCanvas.flush();
1242 1242
1243 // With the bug present, at (55, 55) we would get a fully opaque red 1243 // With the bug present, at (55, 55) we would get a fully opaque red
1244 // intead of a dark red. 1244 // intead of a dark red.
1245 REPORTER_ASSERT(reporter, replayBM.getColor(30, 30) == 0xff000080); 1245 REPORTER_ASSERT(reporter, replayBM.getColor(30, 30) == 0xff000080);
1246 REPORTER_ASSERT(reporter, replayBM.getColor(55, 55) == 0xff800000); 1246 REPORTER_ASSERT(reporter, replayBM.getColor(55, 55) == 0xff800000);
1247 } 1247 }
1248 1248
1249 struct CountingBBH : public SkBBoxHierarchy { 1249 struct CountingBBH : public SkBBoxHierarchy {
1250 mutable int searchCalls; 1250 mutable int searchCalls;
1251 SkRect rootBound;
1251 1252
1252 CountingBBH() : searchCalls(0) {} 1253 CountingBBH(const SkRect& bound) : searchCalls(0), rootBound(bound) {}
1253 1254
1254 void search(const SkRect& query, SkTDArray<unsigned>* results) const SK_OVER RIDE { 1255 void search(const SkRect& query, SkTDArray<unsigned>* results) const SK_OVER RIDE {
1255 this->searchCalls++; 1256 this->searchCalls++;
1256 } 1257 }
1257 1258
1258 void insert(const SkRect[], int) SK_OVERRIDE {} 1259 void insert(const SkRect[], int) SK_OVERRIDE {}
1259 virtual size_t bytesUsed() const SK_OVERRIDE { return 0; } 1260 virtual size_t bytesUsed() const SK_OVERRIDE { return 0; }
1261 SkRect getRootBound() const SK_OVERRIDE { return rootBound; }
1260 }; 1262 };
1261 1263
1262 class SpoonFedBBHFactory : public SkBBHFactory { 1264 class SpoonFedBBHFactory : public SkBBHFactory {
1263 public: 1265 public:
1264 explicit SpoonFedBBHFactory(SkBBoxHierarchy* bbh) : fBBH(bbh) {} 1266 explicit SpoonFedBBHFactory(SkBBoxHierarchy* bbh) : fBBH(bbh) {}
1265 SkBBoxHierarchy* operator()(const SkRect&) const SK_OVERRIDE { 1267 SkBBoxHierarchy* operator()(const SkRect&) const SK_OVERRIDE {
1266 return SkRef(fBBH); 1268 return SkRef(fBBH);
1267 } 1269 }
1268 private: 1270 private:
1269 SkBBoxHierarchy* fBBH; 1271 SkBBoxHierarchy* fBBH;
1270 }; 1272 };
1271 1273
1272 // When the canvas clip covers the full picture, we don't need to call the BBH. 1274 // When the canvas clip covers the full picture, we don't need to call the BBH.
1273 DEF_TEST(Picture_SkipBBH, r) { 1275 DEF_TEST(Picture_SkipBBH, r) {
1274 CountingBBH bbh; 1276 SkRect bound = SkRect::MakeWH(320, 240);
1277 CountingBBH bbh(bound);
1275 SpoonFedBBHFactory factory(&bbh); 1278 SpoonFedBBHFactory factory(&bbh);
1276 1279
1277 SkPictureRecorder recorder; 1280 SkPictureRecorder recorder;
1278 recorder.beginRecording(320, 240, &factory); 1281 recorder.beginRecording(bound, &factory);
1279 SkAutoTUnref<const SkPicture> picture(recorder.endRecording()); 1282 SkAutoTUnref<const SkPicture> picture(recorder.endRecording());
1280 1283
1281 SkCanvas big(640, 480), small(300, 200); 1284 SkCanvas big(640, 480), small(300, 200);
1282 1285
1283 picture->playback(&big); 1286 picture->playback(&big);
1284 REPORTER_ASSERT(r, bbh.searchCalls == 0); 1287 REPORTER_ASSERT(r, bbh.searchCalls == 0);
1285 1288
1286 picture->playback(&small); 1289 picture->playback(&small);
1287 REPORTER_ASSERT(r, bbh.searchCalls == 1); 1290 REPORTER_ASSERT(r, bbh.searchCalls == 1);
1288 } 1291 }
(...skipping 23 matching lines...) Expand all
1312 1315
1313 // The picture shares the immutable pixels but copies the mutable ones. 1316 // The picture shares the immutable pixels but copies the mutable ones.
1314 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1317 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1315 REPORTER_ASSERT(r, !immut.pixelRef()->unique()); 1318 REPORTER_ASSERT(r, !immut.pixelRef()->unique());
1316 1319
1317 // When the picture goes away, it's just our bitmaps holding the refs. 1320 // When the picture goes away, it's just our bitmaps holding the refs.
1318 pic.reset(NULL); 1321 pic.reset(NULL);
1319 REPORTER_ASSERT(r, mut.pixelRef()->unique()); 1322 REPORTER_ASSERT(r, mut.pixelRef()->unique());
1320 REPORTER_ASSERT(r, immut.pixelRef()->unique()); 1323 REPORTER_ASSERT(r, immut.pixelRef()->unique());
1321 } 1324 }
OLDNEW
« no previous file with comments | « src/core/SkRecordDraw.cpp ('k') | tests/RecordDrawTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698