| 105 | } |
| 106 | |
| 107 | void 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 | |
| 138 | void PDFGraphicStackState::push() { |
| 139 | DEBUG_ASSERT(stackDepth < MaxStackDepth); |
no test coverage detected