Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 16 of file SkPDFGraphicStackState.h.

Constructor & Destructor Documentation

◆ SkPDFGraphicStackState()

SkPDFGraphicStackState::SkPDFGraphicStackState ( SkDynamicMemoryWStream s = nullptr)
inline

Definition at line 31 of file SkPDFGraphicStackState.h.

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

Member Function Documentation

◆ currentEntry()

Entry * SkPDFGraphicStackState::currentEntry ( )
inline

Definition at line 38 of file SkPDFGraphicStackState.h.

◆ drainStack()

void SkPDFGraphicStackState::drainStack ( )

Definition at line 230 of file SkPDFGraphicStackState.cpp.

230 {
231 if (fContentStream) {
232 while (fStackDepth) {
233 this->pop();
234 }
235 }
236 SkASSERT(fStackDepth == 0);
237}
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ pop()

void SkPDFGraphicStackState::pop ( )

Definition at line 223 of file SkPDFGraphicStackState.cpp.

◆ push()

void SkPDFGraphicStackState::push ( )

Definition at line 216 of file SkPDFGraphicStackState.cpp.

◆ updateClip()

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

Definition at line 140 of file SkPDFGraphicStackState.cpp.

140 {
141 uint32_t clipStackGenID = clipStack ? clipStack->getTopmostGenID()
143 if (clipStackGenID == currentEntry()->fClipStackGenID) {
144 return;
145 }
146 while (fStackDepth > 0) {
147 this->pop();
148 if (clipStackGenID == currentEntry()->fClipStackGenID) {
149 return;
150 }
151 }
153 if (clipStackGenID != SkClipStack::kWideOpenGenID) {
154 SkASSERT(clipStack);
155 this->push();
156
157 currentEntry()->fClipStackGenID = clipStackGenID;
158 append_clip(*clipStack, bounds, fContentStream);
159 }
160}
static void append_clip(const SkClipStack &clipStack, const SkIRect &bounds, SkWStream *wStream)
uint32_t getTopmostGenID() const
static const uint32_t kWideOpenGenID

◆ updateDrawingState()

void SkPDFGraphicStackState::updateDrawingState ( const Entry state)

Definition at line 185 of file SkPDFGraphicStackState.cpp.

185 {
186 // PDF treats a shader as a color, so we only set one or the other.
187 if (state.fShaderIndex >= 0) {
188 if (state.fShaderIndex != currentEntry()->fShaderIndex) {
190 currentEntry()->fShaderIndex = state.fShaderIndex;
191 }
192 } else if (state.fColor != currentEntry()->fColor || currentEntry()->fShaderIndex >= 0) {
196 fContentStream->writeText("rg\n");
197 currentEntry()->fColor = state.fColor;
199 }
200
201 if (state.fGraphicStateIndex != currentEntry()->fGraphicStateIndex) {
203 currentEntry()->fGraphicStateIndex = state.fGraphicStateIndex;
204 }
205
206 if (state.fTextScaleX) {
207 if (state.fTextScaleX != currentEntry()->fTextScaleX) {
208 SkScalar pdfScale = state.fTextScaleX * 100;
210 fContentStream->writeText(" Tz\n");
211 currentEntry()->fTextScaleX = state.fTextScaleX;
212 }
213 }
214}
static void emit_pdf_color(SkColor4f color, SkWStream *result)
float SkScalar
Definition extension.cpp:12
AtkStateType state
void ApplyGraphicState(int objectIndex, SkWStream *content)
void AppendScalar(SkScalar value, SkWStream *stream)
Definition SkPDFUtils.h:86
void ApplyPattern(int objectIndex, SkWStream *content)

◆ updateMatrix()

void SkPDFGraphicStackState::updateMatrix ( const SkMatrix matrix)

Definition at line 163 of file SkPDFGraphicStackState.cpp.

163 {
164 if (matrix == currentEntry()->fMatrix) {
165 return;
166 }
167
168 if (currentEntry()->fMatrix.getType() != SkMatrix::kIdentity_Mask) {
170 SkASSERT(fEntries[fStackDepth].fClipStackGenID ==
171 fEntries[fStackDepth -1].fClipStackGenID);
172 this->pop();
173
175 }
176 if (matrix.getType() == SkMatrix::kIdentity_Mask) {
177 return;
178 }
179
180 this->push();
183}
@ kIdentity_Mask
identity SkMatrix; all bits clear
Definition SkMatrix.h:192
TypeMask getType() const
Definition SkMatrix.h:207
void AppendTransform(const SkMatrix &, SkWStream *)
unsigned useCenter Optional< SkMatrix > matrix
Definition SkRecords.h:258

Member Data Documentation

◆ fContentStream

SkDynamicMemoryWStream* SkPDFGraphicStackState::fContentStream

Definition at line 29 of file SkPDFGraphicStackState.h.

◆ fEntries

Entry SkPDFGraphicStackState::fEntries[kMaxStackDepth+1]

Definition at line 27 of file SkPDFGraphicStackState.h.

◆ fStackDepth

int SkPDFGraphicStackState::fStackDepth = 0

Definition at line 28 of file SkPDFGraphicStackState.h.

◆ kMaxStackDepth

constexpr int SkPDFGraphicStackState::kMaxStackDepth = 2
inlinestaticconstexpr

Definition at line 26 of file SkPDFGraphicStackState.h.


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