Chromium Code Reviews| Index: src/core/SkBBoxRecord.cpp |
| diff --git a/src/core/SkBBoxRecord.cpp b/src/core/SkBBoxRecord.cpp |
| index a40ea8ba0d27e531e997dfaa922488e0c19433a3..4a9f623dad1a256971015c024a774aaf32530a54 100644 |
| --- a/src/core/SkBBoxRecord.cpp |
| +++ b/src/core/SkBBoxRecord.cpp |
| @@ -8,6 +8,12 @@ |
| #include "SkBBoxRecord.h" |
| +SkBBoxRecord::~SkBBoxRecord() { |
|
mtklein
2014/07/14 16:43:12
Consider just calling fSaveStack.deleteAll() ?
Stephen White
2014/07/14 16:55:00
Done.
|
| + for (int i = fSaveStack.count() - 1; i >= 0; --i) { |
| + delete fSaveStack.getAt(i); |
| + } |
| +} |
| + |
| void SkBBoxRecord::drawOval(const SkRect& rect, const SkPaint& paint) { |
| if (this->transformBounds(rect, &paint)) { |
| INHERITED::drawOval(rect, paint); |
| @@ -287,6 +293,27 @@ void SkBBoxRecord::onDrawPicture(const SkPicture* picture) { |
| } |
| } |
| +void SkBBoxRecord::willSave() { |
| + *fSaveStack.append() = NULL; |
| + this->INHERITED::willSave(); |
| +} |
| + |
| +SkCanvas::SaveLayerStrategy SkBBoxRecord::willSaveLayer(const SkRect* bounds, |
| + const SkPaint* paint, |
| + SaveFlags flags) { |
| + // Image filters can affect the effective bounds of primitives drawn inside saveLayer(). |
| + // Copy the paint so we can compute the modified bounds in transformBounds(). |
| + *fSaveStack.append() = paint && paint->getImageFilter() ? new SkPaint(*paint) : NULL; |
|
mtklein
2014/07/14 16:43:12
Completely fine, but consider
fSaveStack.push(pai
Stephen White
2014/07/14 16:55:00
Ha! Didn't notice those, thanks!
Done.
|
| + return this->INHERITED::willSaveLayer(bounds, paint, flags); |
| +} |
| + |
| +void SkBBoxRecord::willRestore() { |
| + int last = fSaveStack.count() - 1; |
|
mtklein
2014/07/14 16:43:12
delete fSaveStack.top();
fSaveStack.pop();
?
Stephen White
2014/07/14 16:55:00
Done.
|
| + delete fSaveStack.getAt(last); |
| + fSaveStack.setCount(last); |
| + this->INHERITED::willRestore(); |
| +} |
| + |
| bool SkBBoxRecord::transformBounds(const SkRect& bounds, const SkPaint* paint) { |
| SkRect outBounds = bounds; |
| outBounds.sort(); |
| @@ -305,6 +332,14 @@ bool SkBBoxRecord::transformBounds(const SkRect& bounds, const SkPaint* paint) { |
| } |
| } |
| + for (int i = fSaveStack.count() - 1; i >= 0; --i) { |
| + const SkPaint* paint = fSaveStack.getAt(i); |
|
mtklein
2014/07/14 16:43:12
fSaveStack[i] ?
Stephen White
2014/07/14 16:55:00
Think I'll stick with the explicit version here (o
|
| + if (paint && paint->canComputeFastBounds()) { |
| + SkRect temp; |
| + outBounds = paint->computeFastBounds(outBounds, &temp); |
| + } |
| + } |
| + |
| if (!outBounds.isEmpty() && !this->quickReject(outBounds)) { |
| this->getTotalMatrix().mapRect(&outBounds); |
| this->handleBBox(outBounds); |