Flutter Engine
The Flutter Engine
Classes | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
SkPDFGraphicStackState Struct Reference

#include <SkPDFGraphicStackState.h>

Classes

struct  Entry
 

Public Member Functions

 SkPDFGraphicStackState (SkDynamicMemoryWStream *s=nullptr)
 
void updateClip (const SkClipStack *clipStack, const SkIRect &bounds)
 
void updateMatrix (const SkMatrix &matrix)
 
void updateDrawingState (const Entry &state)
 
void push ()
 
void pop ()
 
void drainStack ()
 
EntrycurrentEntry ()
 

Public Attributes

Entry fEntries [kMaxStackDepth+1]
 
int fStackDepth = 0
 
SkDynamicMemoryWStreamfContentStream
 

Static Public Attributes

static constexpr int kMaxStackDepth = 2
 

Detailed Description

Definition at line 19 of file SkPDFGraphicStackState.h.

Constructor & Destructor Documentation

◆ SkPDFGraphicStackState()

SkPDFGraphicStackState::SkPDFGraphicStackState ( SkDynamicMemoryWStream s = nullptr)
inline

Definition at line 34 of file SkPDFGraphicStackState.h.

34: fContentStream(s) {}
struct MyStruct s
SkDynamicMemoryWStream * fContentStream

Member Function Documentation

◆ currentEntry()

Entry * SkPDFGraphicStackState::currentEntry ( )
inline

Definition at line 41 of file SkPDFGraphicStackState.h.

◆ drainStack()

void SkPDFGraphicStackState::drainStack ( )

Definition at line 236 of file SkPDFGraphicStackState.cpp.

236 {
237 if (fContentStream) {
238 while (fStackDepth) {
239 this->pop();
240 }
241 }
242 SkASSERT(fStackDepth == 0);
243}
#define SkASSERT(cond)
Definition: SkAssert.h:116

◆ pop()

void SkPDFGraphicStackState::pop ( )

Definition at line 229 of file SkPDFGraphicStackState.cpp.

◆ push()

void SkPDFGraphicStackState::push ( )

Definition at line 222 of file SkPDFGraphicStackState.cpp.

◆ updateClip()

void SkPDFGraphicStackState::updateClip ( const SkClipStack clipStack,
const SkIRect bounds 
)

Definition at line 146 of file SkPDFGraphicStackState.cpp.

146 {
147 uint32_t clipStackGenID = clipStack ? clipStack->getTopmostGenID()
149 if (clipStackGenID == currentEntry()->fClipStackGenID) {
150 return;
151 }
152 while (fStackDepth > 0) {
153 this->pop();
154 if (clipStackGenID == currentEntry()->fClipStackGenID) {
155 return;
156 }
157 }
159 if (clipStackGenID != SkClipStack::kWideOpenGenID) {
160 SkASSERT(clipStack);
161 this->push();
162
163 currentEntry()->fClipStackGenID = clipStackGenID;
164 append_clip(*clipStack, bounds, fContentStream);
165 }
166}
static void append_clip(const SkClipStack &clipStack, const SkIRect &bounds, SkWStream *wStream)
uint32_t getTopmostGenID() const
static const uint32_t kWideOpenGenID
Definition: SkClipStack.h:387
Optional< SkRect > bounds
Definition: SkRecords.h:189

◆ updateDrawingState()

void SkPDFGraphicStackState::updateDrawingState ( const Entry state)

Definition at line 191 of file SkPDFGraphicStackState.cpp.

191 {
192 // PDF treats a shader as a color, so we only set one or the other.
193 if (state.fShaderIndex >= 0) {
194 if (state.fShaderIndex != currentEntry()->fShaderIndex) {
196 currentEntry()->fShaderIndex = state.fShaderIndex;
197 }
198 } else if (state.fColor != currentEntry()->fColor || currentEntry()->fShaderIndex >= 0) {
202 fContentStream->writeText("rg\n");
203 currentEntry()->fColor = state.fColor;
205 }
206
207 if (state.fGraphicStateIndex != currentEntry()->fGraphicStateIndex) {
209 currentEntry()->fGraphicStateIndex = state.fGraphicStateIndex;
210 }
211
212 if (state.fTextScaleX) {
213 if (state.fTextScaleX != currentEntry()->fTextScaleX) {
214 SkScalar pdfScale = state.fTextScaleX * 100;
216 fContentStream->writeText(" Tz\n");
217 currentEntry()->fTextScaleX = state.fTextScaleX;
218 }
219 }
220}
static void emit_pdf_color(SkColor4f color, SkWStream *result)
float SkScalar
Definition: extension.cpp:12
AtkStateType state
void ApplyGraphicState(int objectIndex, SkWStream *content)
Definition: SkPDFUtils.cpp:254
void AppendScalar(SkScalar value, SkWStream *stream)
Definition: SkPDFUtils.h:98
void ApplyPattern(int objectIndex, SkWStream *content)
Definition: SkPDFUtils.cpp:259

◆ updateMatrix()

void SkPDFGraphicStackState::updateMatrix ( const SkMatrix matrix)

Definition at line 169 of file SkPDFGraphicStackState.cpp.

169 {
170 if (matrix == currentEntry()->fMatrix) {
171 return;
172 }
173
176 SkASSERT(fEntries[fStackDepth].fClipStackGenID ==
177 fEntries[fStackDepth -1].fClipStackGenID);
178 this->pop();
179
181 }
182 if (matrix.getType() == SkMatrix::kIdentity_Mask) {
183 return;
184 }
185
186 this->push();
189}
SkMatrix fMatrix
Definition: FillRRectOp.cpp:74
@ kIdentity_Mask
identity SkMatrix; all bits clear
Definition: SkMatrix.h:192
TypeMask getType() const
Definition: SkMatrix.h:207
void AppendTransform(const SkMatrix &, SkWStream *)
Definition: SkPDFUtils.cpp:399
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258

Member Data Documentation

◆ fContentStream

SkDynamicMemoryWStream* SkPDFGraphicStackState::fContentStream

Definition at line 32 of file SkPDFGraphicStackState.h.

◆ fEntries

Entry SkPDFGraphicStackState::fEntries[kMaxStackDepth+1]

Definition at line 30 of file SkPDFGraphicStackState.h.

◆ fStackDepth

int SkPDFGraphicStackState::fStackDepth = 0

Definition at line 31 of file SkPDFGraphicStackState.h.

◆ kMaxStackDepth

constexpr int SkPDFGraphicStackState::kMaxStackDepth = 2
inlinestaticconstexpr

Definition at line 29 of file SkPDFGraphicStackState.h.


The documentation for this struct was generated from the following files: