diff --git a/src/pdf/SkPDFDevice.cpp b/src/pdf/SkPDFDevice.cpp index 3185037e01..36276e8f2d 100644 --- a/src/pdf/SkPDFDevice.cpp +++ b/src/pdf/SkPDFDevice.cpp @@ -188,7 +188,7 @@ void remove_color_filter(SkPaint* paint) { void SkPDFDevice::GraphicStackState::drainStack() { if (fContentStream) { while (fStackDepth) { - pop(); + this->pop(); } } SkASSERT(fStackDepth == 0); @@ -328,14 +328,15 @@ void SkPDFDevice::GraphicStackState::updateClip(const SkClipStack* clipStack, } while (fStackDepth > 0) { - pop(); + this->pop(); if (clipStackGenID == currentEntry()->fClipStackGenID) { return; } } + SkASSERT(currentEntry()->fClipStackGenID == SkClipStack::kWideOpenGenID); if (clipStackGenID != SkClipStack::kWideOpenGenID) { SkASSERT(clipStack); - push(); + this->push(); currentEntry()->fClipStackGenID = clipStackGenID; append_clip(*clipStack, bounds, fContentStream); @@ -363,7 +364,7 @@ void SkPDFDevice::GraphicStackState::updateMatrix(const SkMatrix& matrix) { SkASSERT(fStackDepth > 0); SkASSERT(fEntries[fStackDepth].fClipStackGenID == fEntries[fStackDepth -1].fClipStackGenID); - pop(); + this->pop(); SkASSERT(currentEntry()->fMatrix.getType() == SkMatrix::kIdentity_Mask); } @@ -371,7 +372,7 @@ void SkPDFDevice::GraphicStackState::updateMatrix(const SkMatrix& matrix) { return; } - push(); + this->push(); append_transform(matrix, fContentStream); currentEntry()->fMatrix = matrix; } diff --git a/src/pdf/SkPDFDevice.h b/src/pdf/SkPDFDevice.h index 666c36bf36..18dab9a19f 100644 --- a/src/pdf/SkPDFDevice.h +++ b/src/pdf/SkPDFDevice.h @@ -179,8 +179,8 @@ private: void pop(); void drainStack(); SkPDFDevice::GraphicStateEntry* currentEntry() { return &fEntries[fStackDepth]; } - // Conservative limit on save depth, see impl. notes in PDF 1.4 spec. - static const int kMaxStackDepth = 11; + // Must use stack for matrix, and for clip, plus one for no matrix or clip. + static constexpr int kMaxStackDepth = 2; SkPDFDevice::GraphicStateEntry fEntries[kMaxStackDepth + 1]; int fStackDepth = 0; SkDynamicMemoryWStream* fContentStream;