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

Side by Side Diff: src/core/SkRecordDraw.cpp

Issue 971803002: Update SkPicture cull rects with RTree information (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix the bug breaking CC unit tests. 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 | « no previous file | no next file » | 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 2014 Google Inc. 2 * Copyright 2014 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 "SkLayerInfo.h" 8 #include "SkLayerInfo.h"
9 #include "SkRecordDraw.h" 9 #include "SkRecordDraw.h"
10 #include "SkPatchUtils.h" 10 #include "SkPatchUtils.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 void updateClipBounds(const ClipPath& op) { this->updateClipBoundsForClipO p(op.devBounds); } 241 void updateClipBounds(const ClipPath& op) { this->updateClipBoundsForClipO p(op.devBounds); }
242 void updateClipBounds(const ClipRRect& op) { this->updateClipBoundsForClipO p(op.devBounds); } 242 void updateClipBounds(const ClipRRect& op) { this->updateClipBoundsForClipO p(op.devBounds); }
243 void updateClipBounds(const ClipRect& op) { this->updateClipBoundsForClipO p(op.devBounds); } 243 void updateClipBounds(const ClipRect& op) { this->updateClipBoundsForClipO p(op.devBounds); }
244 void updateClipBounds(const ClipRegion& op) { this->updateClipBoundsForClipO p(op.devBounds); } 244 void updateClipBounds(const ClipRegion& op) { this->updateClipBoundsForClipO p(op.devBounds); }
245 245
246 // The bounds of clip ops need to be adjusted for the paints of saveLayers t hey're inside. 246 // The bounds of clip ops need to be adjusted for the paints of saveLayers t hey're inside.
247 void updateClipBoundsForClipOp(const SkIRect& devBounds) { 247 void updateClipBoundsForClipOp(const SkIRect& devBounds) {
248 Bounds clip = SkRect::Make(devBounds); 248 Bounds clip = SkRect::Make(devBounds);
249 // We don't call adjustAndMap() because as its last step it would inters ect the adjusted 249 // We don't call adjustAndMap() because as its last step it would inters ect the adjusted
250 // clip bounds with the previous clip, exactly what we can't do when the clip grows. 250 // clip bounds with the previous clip, exactly what we can't do when the clip grows.
251 fCurrentClipBounds = this->adjustForSaveLayerPaints(&clip) ? clip : fCul lRect; 251 bool isBoundedClip = this->adjustForSaveLayerPaints(&clip);
252 if (isBoundedClip) {
mtklein 2015/03/06 18:18:50 Let's definitely create a little method for the as
253 bool intersects = clip.intersect(fCullRect);
254 if (intersects)
255 fCurrentClipBounds = clip;
256 else
257 fCurrentClipBounds = Bounds::MakeEmpty();
258 } else {
259 fCurrentClipBounds = fCullRect;
260 }
261 SkASSERT((fCurrentClipBounds.isEmpty() || fCullRect.contains(fCurrentCli pBounds))
262 || (fCurrentClipBounds.isEmpty() && fCullRect.isEmpty()));
252 } 263 }
253 264
254 // Restore holds the devBounds for the clip after the {save,saveLayer}/resto re block completes. 265 // Restore holds the devBounds for the clip after the {save,saveLayer}/resto re block completes.
255 void updateClipBounds(const Restore& op) { 266 void updateClipBounds(const Restore& op) {
256 // This is just like the clip ops above, but we need to skip the effects (if any) of our 267 // This is just like the clip ops above, but we need to skip the effects (if any) of our
257 // paired saveLayer (if it is one); it has not yet been popped off the s ave stack. Our 268 // paired saveLayer (if it is one); it has not yet been popped off the s ave stack. Our
258 // devBounds reflect the state of the world after the saveLayer/restore block is done, 269 // devBounds reflect the state of the world after the saveLayer/restore block is done,
259 // so they are not affected by the saveLayer's paint. 270 // so they are not affected by the saveLayer's paint.
260 const int kSavesToIgnore = 1; 271 const int kSavesToIgnore = 1;
261 Bounds clip = SkRect::Make(op.devBounds); 272 Bounds clip = SkRect::Make(op.devBounds);
262 fCurrentClipBounds = 273 bool isBoundedClip = this->adjustForSaveLayerPaints(&clip, kSavesToIgnor e);
263 this->adjustForSaveLayerPaints(&clip, kSavesToIgnore) ? clip : fCull Rect; 274 if (isBoundedClip) {
275 bool intersects = clip.intersect(fCullRect);
276 if (intersects)
277 fCurrentClipBounds = clip;
278 else
279 fCurrentClipBounds = Bounds::MakeEmpty();
280 } else {
281 fCurrentClipBounds = fCullRect;
282 }
283 SkASSERT((fCurrentClipBounds.isEmpty() || fCullRect.contains(fCurrentCli pBounds))
284 || (fCurrentClipBounds.isEmpty() && fCullRect.isEmpty()));
264 } 285 }
265 286
266 // We also take advantage of SaveLayer bounds when present to further cut th e clip down. 287 // We also take advantage of SaveLayer bounds when present to further cut th e clip down.
267 void updateClipBounds(const SaveLayer& op) { 288 void updateClipBounds(const SaveLayer& op) {
268 if (op.bounds) { 289 if (op.bounds) {
269 // adjustAndMap() intersects these layer bounds with the previous cl ip for us. 290 // adjustAndMap() intersects these layer bounds with the previous cl ip for us.
270 fCurrentClipBounds = this->adjustAndMap(*op.bounds, op.paint); 291 fCurrentClipBounds = this->adjustAndMap(*op.bounds, op.paint);
292 SkASSERT((fCurrentClipBounds.isEmpty() || fCullRect.contains(fCurren tClipBounds))
293 || (fCurrentClipBounds.isEmpty() && fCullRect.isEmpty()));
271 } 294 }
272 } 295 }
273 296
274 // The bounds of these ops must be calculated when we hit the Restore 297 // The bounds of these ops must be calculated when we hit the Restore
275 // from the bounds of the ops in the same Save block. 298 // from the bounds of the ops in the same Save block.
276 void trackBounds(const Save&) { this->pushSaveBlock(NULL); } 299 void trackBounds(const Save&) { this->pushSaveBlock(NULL); }
277 void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } 300 void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); }
278 void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock( ); } 301 void trackBounds(const Restore&) {
302 fBounds[fCurrentOp] = this->popSaveBlock();
303 SkASSERT((fBounds[fCurrentOp].isEmpty() || fCullRect.contains(fBounds[fC urrentOp]))
304 || (fBounds[fCurrentOp].isEmpty() && fCullRect.isEmpty()));
305 }
279 306
280 void trackBounds(const SetMatrix&) { this->pushControl(); } 307 void trackBounds(const SetMatrix&) { this->pushControl(); }
281 void trackBounds(const ClipRect&) { this->pushControl(); } 308 void trackBounds(const ClipRect&) { this->pushControl(); }
282 void trackBounds(const ClipRRect&) { this->pushControl(); } 309 void trackBounds(const ClipRRect&) { this->pushControl(); }
283 void trackBounds(const ClipPath&) { this->pushControl(); } 310 void trackBounds(const ClipPath&) { this->pushControl(); }
284 void trackBounds(const ClipRegion&) { this->pushControl(); } 311 void trackBounds(const ClipRegion&) { this->pushControl(); }
285 void trackBounds(const BeginCommentGroup&) { this->pushControl(); } 312 void trackBounds(const BeginCommentGroup&) { this->pushControl(); }
286 void trackBounds(const AddComment&) { this->pushControl(); } 313 void trackBounds(const AddComment&) { this->pushControl(); }
287 void trackBounds(const EndCommentGroup&) { this->pushControl(); } 314 void trackBounds(const EndCommentGroup&) { this->pushControl(); }
288 315
289 // For all other ops, we can calculate and store the bounds directly now. 316 // For all other ops, we can calculate and store the bounds directly now.
290 template <typename T> void trackBounds(const T& op) { 317 template <typename T> void trackBounds(const T& op) {
291 fBounds[fCurrentOp] = this->bounds(op); 318 fBounds[fCurrentOp] = this->bounds(op);
319 SkASSERT((fBounds[fCurrentOp].isEmpty() || fCullRect.contains(fBounds[fC urrentOp]))
320 || (fBounds[fCurrentOp].isEmpty() && fCullRect.isEmpty()));
292 this->updateSaveBounds(fBounds[fCurrentOp]); 321 this->updateSaveBounds(fBounds[fCurrentOp]);
293 } 322 }
294 323
295 void pushSaveBlock(const SkPaint* paint) { 324 void pushSaveBlock(const SkPaint* paint) {
296 // Starting a new Save block. Push a new entry to represent that. 325 // Starting a new Save block. Push a new entry to represent that.
297 SaveBounds sb; 326 SaveBounds sb;
298 sb.controlOps = 0; 327 sb.controlOps = 0;
299 // If the paint affects transparent black, the bound shouldn't be smalle r 328 // If the paint affects transparent black, the bound shouldn't be smalle r
300 // than the current clip bounds. 329 // than the current clip bounds.
301 sb.bounds = 330 sb.bounds =
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 } 392 }
364 393
365 void pushControl() { 394 void pushControl() {
366 fControlIndices.push(fCurrentOp); 395 fControlIndices.push(fCurrentOp);
367 if (!fSaveStack.isEmpty()) { 396 if (!fSaveStack.isEmpty()) {
368 fSaveStack.top().controlOps++; 397 fSaveStack.top().controlOps++;
369 } 398 }
370 } 399 }
371 400
372 void popControl(const Bounds& bounds) { 401 void popControl(const Bounds& bounds) {
402 SkASSERT((bounds.isEmpty() || fCullRect.contains(bounds))
403 || (bounds.isEmpty() && fCullRect.isEmpty()));
373 fBounds[fControlIndices.top()] = bounds; 404 fBounds[fControlIndices.top()] = bounds;
374 fControlIndices.pop(); 405 fControlIndices.pop();
375 } 406 }
376 407
377 void updateSaveBounds(const Bounds& bounds) { 408 void updateSaveBounds(const Bounds& bounds) {
378 // If we're in a Save block, expand its bounds to cover these bounds too . 409 // If we're in a Save block, expand its bounds to cover these bounds too .
379 if (!fSaveStack.isEmpty()) { 410 if (!fSaveStack.isEmpty()) {
380 fSaveStack.top().bounds.join(bounds); 411 fSaveStack.top().bounds.join(bounds);
381 } 412 }
382 } 413 }
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); 822 SkRecords::CollectLayers visitor(cullRect, record, pictList, data);
792 823
793 for (unsigned curOp = 0; curOp < record.count(); curOp++) { 824 for (unsigned curOp = 0; curOp < record.count(); curOp++) {
794 visitor.setCurrentOp(curOp); 825 visitor.setCurrentOp(curOp);
795 record.visit<void>(curOp, visitor); 826 record.visit<void>(curOp, visitor);
796 } 827 }
797 828
798 visitor.cleanUp(bbh); 829 visitor.cleanUp(bbh);
799 } 830 }
800 831
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698