Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 |
| 274 // The bounds of these ops must be calculated when we hit the Restore | 281 // 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. | 282 // from the bounds of the ops in the same Save block. |
| 276 void trackBounds(const Save&) { this->pushSaveBlock(NULL); } | 283 void trackBounds(const Save&) { this->pushSaveBlock(NULL); } |
| 277 void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } | 284 void trackBounds(const SaveLayer& op) { this->pushSaveBlock(op.paint); } |
| 278 void trackBounds(const Restore&) { fBounds[fCurrentOp] = this->popSaveBlock( ); } | 285 void trackBounds(const Restore&) { |
| 286 fBounds[fCurrentOp] = this->popSaveBlock(); | |
|
mtklein
2015/03/06 20:54:25
Might want to put this guy back on one line?
| |
| 287 } | |
| 279 | 288 |
| 280 void trackBounds(const SetMatrix&) { this->pushControl(); } | 289 void trackBounds(const SetMatrix&) { this->pushControl(); } |
| 281 void trackBounds(const ClipRect&) { this->pushControl(); } | 290 void trackBounds(const ClipRect&) { this->pushControl(); } |
| 282 void trackBounds(const ClipRRect&) { this->pushControl(); } | 291 void trackBounds(const ClipRRect&) { this->pushControl(); } |
| 283 void trackBounds(const ClipPath&) { this->pushControl(); } | 292 void trackBounds(const ClipPath&) { this->pushControl(); } |
| 284 void trackBounds(const ClipRegion&) { this->pushControl(); } | 293 void trackBounds(const ClipRegion&) { this->pushControl(); } |
| 285 void trackBounds(const BeginCommentGroup&) { this->pushControl(); } | 294 void trackBounds(const BeginCommentGroup&) { this->pushControl(); } |
| 286 void trackBounds(const AddComment&) { this->pushControl(); } | 295 void trackBounds(const AddComment&) { this->pushControl(); } |
| 287 void trackBounds(const EndCommentGroup&) { this->pushControl(); } | 296 void trackBounds(const EndCommentGroup&) { this->pushControl(); } |
| 288 | 297 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 fSaveStack.top().bounds.join(bounds); | 389 fSaveStack.top().bounds.join(bounds); |
| 381 } | 390 } |
| 382 } | 391 } |
| 383 | 392 |
| 384 // FIXME: this method could use better bounds | 393 // FIXME: this method could use better bounds |
| 385 Bounds bounds(const DrawText&) const { return fCurrentClipBounds; } | 394 Bounds bounds(const DrawText&) const { return fCurrentClipBounds; } |
| 386 | 395 |
| 387 Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } | 396 Bounds bounds(const DrawPaint&) const { return fCurrentClipBounds; } |
| 388 Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOp s don't draw. | 397 Bounds bounds(const NoOp&) const { return Bounds::MakeEmpty(); } // NoOp s don't draw. |
| 389 | 398 |
| 390 Bounds bounds(const DrawSprite& op) const { // Ignores the matrix. | 399 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()); | 400 SkRect rect = Bounds::MakeXYWH(op.left, op.top, op.bitmap.width(), op.bi tmap.height()); |
| 401 if (!rect.intersect(fCurrentClipBounds)) { | |
| 402 return Bounds::MakeEmpty(); | |
| 403 } | |
| 404 return rect; | |
| 392 } | 405 } |
| 393 | 406 |
| 394 Bounds bounds(const DrawRect& op) const { return this->adjustAndMap(op.rect, &op.paint); } | 407 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); } | 408 Bounds bounds(const DrawOval& op) const { return this->adjustAndMap(op.oval, &op.paint); } |
| 396 Bounds bounds(const DrawRRect& op) const { | 409 Bounds bounds(const DrawRRect& op) const { |
| 397 return this->adjustAndMap(op.rrect.rect(), &op.paint); | 410 return this->adjustAndMap(op.rrect.rect(), &op.paint); |
| 398 } | 411 } |
| 399 Bounds bounds(const DrawDRRect& op) const { | 412 Bounds bounds(const DrawDRRect& op) const { |
| 400 return this->adjustAndMap(op.outer.rect(), &op.paint); | 413 return this->adjustAndMap(op.outer.rect(), &op.paint); |
| 401 } | 414 } |
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 787 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); | 800 SkRecords::CollectLayers visitor(cullRect, record, pictList, data); |
| 788 | 801 |
| 789 for (unsigned curOp = 0; curOp < record.count(); curOp++) { | 802 for (unsigned curOp = 0; curOp < record.count(); curOp++) { |
| 790 visitor.setCurrentOp(curOp); | 803 visitor.setCurrentOp(curOp); |
| 791 record.visit<void>(curOp, visitor); | 804 record.visit<void>(curOp, visitor); |
| 792 } | 805 } |
| 793 | 806 |
| 794 visitor.cleanUp(bbh); | 807 visitor.cleanUp(bbh); |
| 795 } | 808 } |
| 796 | 809 |
| OLD | NEW |