SkPDF: no over-allocating stack that won't be used.
Change-Id: I27c0609a2be6ea18879cfc799f969b7a2a72cd06 Reviewed-on: https://skia-review.googlesource.com/157741 Auto-Submit: Hal Canary <halcanary@google.com> Reviewed-by: Ben Wagner <bungeman@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
23952e2694
commit
b5b7279349
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user