MCPcopy Create free account
hub / github.com/Tencent/tgfx / updateDrawingState

Method updateDrawingState

src/pdf/PDFGraphicStackState.cpp:107–136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105}
106
107void PDFGraphicStackState::updateDrawingState(const PDFGraphicStackState::Entry& state) {
108 // PDF treats a shader as a color, so we only set one or the other.
109 if (state.shaderIndex >= 0) {
110 if (state.shaderIndex != currentEntry()->shaderIndex) {
111 PDFUtils::ApplyPattern(state.shaderIndex, contentStream);
112 currentEntry()->shaderIndex = state.shaderIndex;
113 }
114 } else if (state.color != currentEntry()->color || currentEntry()->shaderIndex >= 0) {
115 EmitPDFColor(state.color, contentStream);
116 contentStream->writeText("RG ");
117 EmitPDFColor(state.color, contentStream);
118 contentStream->writeText("rg\n");
119 currentEntry()->color = state.color;
120 currentEntry()->shaderIndex = -1;
121 }
122
123 if (state.graphicStateIndex != currentEntry()->graphicStateIndex) {
124 PDFUtils::ApplyGraphicState(state.graphicStateIndex, contentStream);
125 currentEntry()->graphicStateIndex = state.graphicStateIndex;
126 }
127
128 if (state.textScaleX != 0) {
129 if (state.textScaleX != currentEntry()->textScaleX) {
130 float pdfScale = state.textScaleX * 100;
131 PDFUtils::AppendFloat(pdfScale, contentStream);
132 contentStream->writeText(" Tz\n");
133 currentEntry()->textScaleX = state.textScaleX;
134 }
135 }
136}
137
138void PDFGraphicStackState::push() {
139 DEBUG_ASSERT(stackDepth < MaxStackDepth);

Callers 1

setUpContentEntryMethod · 0.80

Calls 2

EmitPDFColorFunction · 0.85
writeTextMethod · 0.80

Tested by

no test coverage detected