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

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 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/SkRTree.cpp ('k') | tests/PictureTest.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 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 if (this->adjustForSaveLayerPaints(&clip)) {
252 fCurrentClipBounds = clip.intersect(fCullRect) ? clip : Bounds::Make Empty();
253 } else {
254 fCurrentClipBounds = fCullRect;
255 }
252 } 256 }
253 257
254 // Restore holds the devBounds for the clip after the {save,saveLayer}/resto re block completes. 258 // Restore holds the devBounds for the clip after the {save,saveLayer}/resto re block completes.
255 void updateClipBounds(const Restore& op) { 259 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 260 // 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 261 // 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, 262 // 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. 263 // so they are not affected by the saveLayer's paint.
260 const int kSavesToIgnore = 1; 264 const int kSavesToIgnore = 1;
261 Bounds clip = SkRect::Make(op.devBounds); 265 Bounds clip = SkRect::Make(op.devBounds);
262 fCurrentClipBounds = 266 if (this->adjustForSaveLayerPaints(&clip, kSavesToIgnore)) {
263 this->adjustForSaveLayerPaints(&clip, kSavesToIgnore) ? clip : fCull Rect; 267 fCurrentClipBounds = clip.intersect(fCullRect) ? clip : Bounds::Make Empty();
268 } else {
269 fCurrentClipBounds = fCullRect;
270 }
264 } 271 }
265 272
266 // We also take advantage of SaveLayer bounds when present to further cut th e clip down. 273 // We also take advantage of SaveLayer bounds when present to further cut th e clip down.
267 void updateClipBounds(const SaveLayer& op) { 274 void updateClipBounds(const SaveLayer& op) {
268 if (op.bounds) { 275 if (op.bounds) {
269 // adjustAndMap() intersects these layer bounds with the previous cl ip for us. 276 // adjustAndMap() intersects these layer bounds with the previous cl ip for us.
270 fCurrentClipBounds = this->adjustAndMap(*op.bounds, op.paint); 277 fCurrentClipBounds = this->adjustAndMap(*op.bounds, op.paint);
271 } 278 }
272 } 279 }
273 280
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 fSaveStack.top().bounds.join(bounds); 387 fSaveStack.top().bounds.join(bounds);
381 } 388 }
382 } 389 }
383 390
384 // FIXME: this method could use better bounds 391 // FIXME: this method could use better bounds
385 Bounds bounds(const DrawText&) const { return fCurrentClipBounds; } 392 Bounds bounds(const DrawText&) const { return fCurrentClipBounds; }
386 393
387 Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } 394 Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; }
388 Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOp s don't draw. 395 Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOp s don't draw.
389 396
390 Bounds bounds(const DrawSprite& op) const { // Ignores the matrix. 397 Bounds bounds(const DrawSprite& op) const { // Ignores the matrix, but resp ects the clip.
391 return Bounds::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bitmap.he ight()); 398 SkRect rect = Bounds::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bi tmap.height());
399 if (!rect.intersect(fCurrentClipBounds)) {
400 return Bounds::MakeEmpty();
401 }
402 return rect;
392 } 403 }
393 404
394 Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); } 405 Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); }
395 Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); } 406 Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); }
396 Bounds bounds(const DrawRRect& op) const { 407 Bounds bounds(const DrawRRect& op) const {
397 return this->adjustAndMap(op.rrect.rect(), &op.paint); 408 return this->adjustAndMap(op.rrect.rect(), &op.paint);
398 } 409 }
399 Bounds bounds(const DrawDRRect& op) const { 410 Bounds bounds(const DrawDRRect& op) const {
400 return this->adjustAndMap(op.outer.rect(), &op.paint); 411 return this->adjustAndMap(op.outer.rect(), &op.paint);
401 } 412 }
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); 798 SkRecords::CollectLayers visitor(cullRect, record, pictList, data);
788 799
789 for (unsigned curOp = 0; curOp < record.count(); curOp++) { 800 for (unsigned curOp = 0; curOp < record.count(); curOp++) {
790 visitor.setCurrentOp(curOp); 801 visitor.setCurrentOp(curOp);
791 record.visit<void>(curOp, visitor); 802 record.visit<void>(curOp, visitor);
792 } 803 }
793 804
794 visitor.cleanUp(bbh); 805 visitor.cleanUp(bbh);
795 } 806 }
796 807
OLDNEW
« no previous file with comments | « src/core/SkRTree.cpp ('k') | tests/PictureTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698