Chromium Code Reviews| Index: src/core/SkBBoxRecord.cpp |
| diff --git a/src/core/SkBBoxRecord.cpp b/src/core/SkBBoxRecord.cpp |
| index a40ea8ba0d27e531e997dfaa922488e0c19433a3..3670f9145e8bcf7581dea8d4c7f6ff98ccab3ecc 100644 |
| --- a/src/core/SkBBoxRecord.cpp |
| +++ b/src/core/SkBBoxRecord.cpp |
| @@ -8,6 +8,13 @@ |
| #include "SkBBoxRecord.h" |
| +SkBBoxRecord::~SkBBoxRecord() { |
| + while (!fSaveStack.empty()) { |
| + delete fSaveStack.top(); |
| + fSaveStack.pop(); |
| + } |
| +} |
| + |
| void SkBBoxRecord::drawOval(const SkRect& rect, const SkPaint& paint) { |
| if (this->transformBounds(rect, &paint)) { |
| INHERITED::drawOval(rect, paint); |
| @@ -287,6 +294,26 @@ void SkBBoxRecord::onDrawPicture(const SkPicture* picture) { |
| } |
| } |
| +void SkBBoxRecord::willSave() { |
| + fSaveStack.push(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.push(paint && paint->getImageFilter() ? new SkPaint(*paint) : NULL); |
| + return this->INHERITED::willSaveLayer(bounds, paint, flags); |
| +} |
| + |
| +void SkBBoxRecord::willRestore() { |
| + delete fSaveStack.top(); |
| + fSaveStack.pop(); |
| + 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) { |
| } |
| } |
|
robertphillips
2014/07/13 18:57:29
I don't think SkTDStack::index does what you want!
Stephen White
2014/07/14 15:35:13
Yeah; looks like SkTDStack is hopelessly broken. S
|
| + for (int i = fSaveStack.count() - 1; i >= 0; --i) { |
| + const SkPaint* paint = fSaveStack.index(i); |
| + if (paint && paint->canComputeFastBounds()) { |
| + SkRect temp; |
| + outBounds = paint->computeFastBounds(outBounds, &temp); |
| + } |
| + } |
| + |
| if (!outBounds.isEmpty() && !this->quickReject(outBounds)) { |
| this->getTotalMatrix().mapRect(&outBounds); |
| this->handleBBox(outBounds); |