| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/include/fxge/fx_ge.h" | 7 #include "core/include/fxge/fx_ge.h" |
| 8 #include "core/include/fxcodec/fx_codec.h" | 8 #include "core/include/fxcodec/fx_codec.h" |
| 9 #include "text_int.h" | 9 #include "text_int.h" |
| 10 | 10 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 } else { | 83 } else { |
| 84 OUTPUT_PS("Q\n"); | 84 OUTPUT_PS("Q\n"); |
| 85 } | 85 } |
| 86 m_bColorSet = m_bGraphStateSet = FALSE; | 86 m_bColorSet = m_bGraphStateSet = FALSE; |
| 87 m_ClipBox = m_ClipBoxStack.GetAt(m_ClipBoxStack.GetSize() - 1); | 87 m_ClipBox = m_ClipBoxStack.GetAt(m_ClipBoxStack.GetSize() - 1); |
| 88 if (!bKeepSaved) { | 88 if (!bKeepSaved) { |
| 89 m_ClipBoxStack.RemoveAt(m_ClipBoxStack.GetSize() - 1); | 89 m_ClipBoxStack.RemoveAt(m_ClipBoxStack.GetSize() - 1); |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, | 92 void CFX_PSRenderer::OutputPath(const CFX_PathData* pPathData, |
| 93 const CFX_AffineMatrix* pObject2Device) { | 93 const CFX_Matrix* pObject2Device) { |
| 94 int nPoints = pPathData->GetPointCount(); | 94 int nPoints = pPathData->GetPointCount(); |
| 95 CFX_ByteTextBuf buf; | 95 CFX_ByteTextBuf buf; |
| 96 buf.EstimateSize(nPoints * 10); | 96 buf.EstimateSize(nPoints * 10); |
| 97 for (int i = 0; i < nPoints; i++) { | 97 for (int i = 0; i < nPoints; i++) { |
| 98 uint8_t flag = pPathData->GetFlag(i); | 98 uint8_t flag = pPathData->GetFlag(i); |
| 99 FX_FLOAT x = pPathData->GetPointX(i); | 99 FX_FLOAT x = pPathData->GetPointX(i); |
| 100 FX_FLOAT y = pPathData->GetPointY(i); | 100 FX_FLOAT y = pPathData->GetPointY(i); |
| 101 if (pObject2Device) { | 101 if (pObject2Device) { |
| 102 pObject2Device->Transform(x, y); | 102 pObject2Device->Transform(x, y); |
| 103 } | 103 } |
| (...skipping 26 matching lines...) Expand all Loading... |
| 130 buf << FX_BSTRC(" c\n"); | 130 buf << FX_BSTRC(" c\n"); |
| 131 } | 131 } |
| 132 i += 2; | 132 i += 2; |
| 133 break; | 133 break; |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize()); | 137 m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize()); |
| 138 } | 138 } |
| 139 void CFX_PSRenderer::SetClip_PathFill(const CFX_PathData* pPathData, | 139 void CFX_PSRenderer::SetClip_PathFill(const CFX_PathData* pPathData, |
| 140 const CFX_AffineMatrix* pObject2Device, | 140 const CFX_Matrix* pObject2Device, |
| 141 int fill_mode) { | 141 int fill_mode) { |
| 142 StartRendering(); | 142 StartRendering(); |
| 143 OutputPath(pPathData, pObject2Device); | 143 OutputPath(pPathData, pObject2Device); |
| 144 CFX_FloatRect rect = pPathData->GetBoundingBox(); | 144 CFX_FloatRect rect = pPathData->GetBoundingBox(); |
| 145 if (pObject2Device) { | 145 if (pObject2Device) { |
| 146 rect.Transform(pObject2Device); | 146 rect.Transform(pObject2Device); |
| 147 } | 147 } |
| 148 m_ClipBox.Intersect(rect.GetOutterRect()); | 148 m_ClipBox.Intersect(rect.GetOutterRect()); |
| 149 if ((fill_mode & 3) == FXFILL_WINDING) { | 149 if ((fill_mode & 3) == FXFILL_WINDING) { |
| 150 OUTPUT_PS("W n\n"); | 150 OUTPUT_PS("W n\n"); |
| 151 } else { | 151 } else { |
| 152 OUTPUT_PS("W* n\n"); | 152 OUTPUT_PS("W* n\n"); |
| 153 } | 153 } |
| 154 } | 154 } |
| 155 void CFX_PSRenderer::SetClip_PathStroke(const CFX_PathData* pPathData, | 155 void CFX_PSRenderer::SetClip_PathStroke(const CFX_PathData* pPathData, |
| 156 const CFX_AffineMatrix* pObject2Device, | 156 const CFX_Matrix* pObject2Device, |
| 157 const CFX_GraphStateData* pGraphState) { | 157 const CFX_GraphStateData* pGraphState) { |
| 158 StartRendering(); | 158 StartRendering(); |
| 159 SetGraphState(pGraphState); | 159 SetGraphState(pGraphState); |
| 160 if (pObject2Device) { | 160 if (pObject2Device) { |
| 161 CFX_ByteTextBuf buf; | 161 CFX_ByteTextBuf buf; |
| 162 buf << FX_BSTRC("mx Cm [") << pObject2Device->a << FX_BSTRC(" ") | 162 buf << FX_BSTRC("mx Cm [") << pObject2Device->a << FX_BSTRC(" ") |
| 163 << pObject2Device->b << FX_BSTRC(" ") << pObject2Device->c | 163 << pObject2Device->b << FX_BSTRC(" ") << pObject2Device->c |
| 164 << FX_BSTRC(" ") << pObject2Device->d << FX_BSTRC(" ") | 164 << FX_BSTRC(" ") << pObject2Device->d << FX_BSTRC(" ") |
| 165 << pObject2Device->e << FX_BSTRC(" ") << pObject2Device->f | 165 << pObject2Device->e << FX_BSTRC(" ") << pObject2Device->f |
| 166 << FX_BSTRC("]cm "); | 166 << FX_BSTRC("]cm "); |
| 167 m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize()); | 167 m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize()); |
| 168 } | 168 } |
| 169 OutputPath(pPathData, NULL); | 169 OutputPath(pPathData, NULL); |
| 170 CFX_FloatRect rect = pPathData->GetBoundingBox(pGraphState->m_LineWidth, | 170 CFX_FloatRect rect = pPathData->GetBoundingBox(pGraphState->m_LineWidth, |
| 171 pGraphState->m_MiterLimit); | 171 pGraphState->m_MiterLimit); |
| 172 rect.Transform(pObject2Device); | 172 rect.Transform(pObject2Device); |
| 173 m_ClipBox.Intersect(rect.GetOutterRect()); | 173 m_ClipBox.Intersect(rect.GetOutterRect()); |
| 174 if (pObject2Device) { | 174 if (pObject2Device) { |
| 175 OUTPUT_PS("strokepath W n sm\n"); | 175 OUTPUT_PS("strokepath W n sm\n"); |
| 176 } else { | 176 } else { |
| 177 OUTPUT_PS("strokepath W n\n"); | 177 OUTPUT_PS("strokepath W n\n"); |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 FX_BOOL CFX_PSRenderer::DrawPath(const CFX_PathData* pPathData, | 180 FX_BOOL CFX_PSRenderer::DrawPath(const CFX_PathData* pPathData, |
| 181 const CFX_AffineMatrix* pObject2Device, | 181 const CFX_Matrix* pObject2Device, |
| 182 const CFX_GraphStateData* pGraphState, | 182 const CFX_GraphStateData* pGraphState, |
| 183 FX_DWORD fill_color, | 183 FX_DWORD fill_color, |
| 184 FX_DWORD stroke_color, | 184 FX_DWORD stroke_color, |
| 185 int fill_mode, | 185 int fill_mode, |
| 186 int alpha_flag, | 186 int alpha_flag, |
| 187 void* pIccTransform) { | 187 void* pIccTransform) { |
| 188 StartRendering(); | 188 StartRendering(); |
| 189 int fill_alpha = FXGETFLAG_COLORTYPE(alpha_flag) | 189 int fill_alpha = FXGETFLAG_COLORTYPE(alpha_flag) |
| 190 ? FXGETFLAG_ALPHA_FILL(alpha_flag) | 190 ? FXGETFLAG_ALPHA_FILL(alpha_flag) |
| 191 : FXARGB_A(fill_color); | 191 : FXARGB_A(fill_color); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 FX_Free(dest_buf); | 326 FX_Free(dest_buf); |
| 327 } | 327 } |
| 328 } | 328 } |
| 329 FX_BOOL CFX_PSRenderer::SetDIBits(const CFX_DIBSource* pSource, | 329 FX_BOOL CFX_PSRenderer::SetDIBits(const CFX_DIBSource* pSource, |
| 330 FX_DWORD color, | 330 FX_DWORD color, |
| 331 int left, | 331 int left, |
| 332 int top, | 332 int top, |
| 333 int alpha_flag, | 333 int alpha_flag, |
| 334 void* pIccTransform) { | 334 void* pIccTransform) { |
| 335 StartRendering(); | 335 StartRendering(); |
| 336 CFX_AffineMatrix matrix((FX_FLOAT)(pSource->GetWidth()), 0.0f, 0.0f, | 336 CFX_Matrix matrix((FX_FLOAT)(pSource->GetWidth()), 0.0f, 0.0f, |
| 337 -(FX_FLOAT)(pSource->GetHeight()), (FX_FLOAT)(left), | 337 -(FX_FLOAT)(pSource->GetHeight()), (FX_FLOAT)(left), |
| 338 (FX_FLOAT)(top + pSource->GetHeight())); | 338 (FX_FLOAT)(top + pSource->GetHeight())); |
| 339 return DrawDIBits(pSource, color, &matrix, 0, alpha_flag, pIccTransform); | 339 return DrawDIBits(pSource, color, &matrix, 0, alpha_flag, pIccTransform); |
| 340 } | 340 } |
| 341 FX_BOOL CFX_PSRenderer::StretchDIBits(const CFX_DIBSource* pSource, | 341 FX_BOOL CFX_PSRenderer::StretchDIBits(const CFX_DIBSource* pSource, |
| 342 FX_DWORD color, | 342 FX_DWORD color, |
| 343 int dest_left, | 343 int dest_left, |
| 344 int dest_top, | 344 int dest_top, |
| 345 int dest_width, | 345 int dest_width, |
| 346 int dest_height, | 346 int dest_height, |
| 347 FX_DWORD flags, | 347 FX_DWORD flags, |
| 348 int alpha_flag, | 348 int alpha_flag, |
| 349 void* pIccTransform) { | 349 void* pIccTransform) { |
| 350 StartRendering(); | 350 StartRendering(); |
| 351 CFX_AffineMatrix matrix((FX_FLOAT)(dest_width), 0.0f, 0.0f, | 351 CFX_Matrix matrix((FX_FLOAT)(dest_width), 0.0f, 0.0f, |
| 352 (FX_FLOAT)(-dest_height), (FX_FLOAT)(dest_left), | 352 (FX_FLOAT)(-dest_height), (FX_FLOAT)(dest_left), |
| 353 (FX_FLOAT)(dest_top + dest_height)); | 353 (FX_FLOAT)(dest_top + dest_height)); |
| 354 return DrawDIBits(pSource, color, &matrix, flags, alpha_flag, pIccTransform); | 354 return DrawDIBits(pSource, color, &matrix, flags, alpha_flag, pIccTransform); |
| 355 } | 355 } |
| 356 FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource, | 356 FX_BOOL CFX_PSRenderer::DrawDIBits(const CFX_DIBSource* pSource, |
| 357 FX_DWORD color, | 357 FX_DWORD color, |
| 358 const CFX_AffineMatrix* pMatrix, | 358 const CFX_Matrix* pMatrix, |
| 359 FX_DWORD flags, | 359 FX_DWORD flags, |
| 360 int alpha_flag, | 360 int alpha_flag, |
| 361 void* pIccTransform) { | 361 void* pIccTransform) { |
| 362 StartRendering(); | 362 StartRendering(); |
| 363 if ((pMatrix->a == 0 && pMatrix->b == 0) || | 363 if ((pMatrix->a == 0 && pMatrix->b == 0) || |
| 364 (pMatrix->c == 0 && pMatrix->d == 0)) { | 364 (pMatrix->c == 0 && pMatrix->d == 0)) { |
| 365 return TRUE; | 365 return TRUE; |
| 366 } | 366 } |
| 367 if (pSource->HasAlpha()) { | 367 if (pSource->HasAlpha()) { |
| 368 return FALSE; | 368 return FALSE; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[0] = | 600 pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[0] = |
| 601 charpos.m_AdjustMatrix[0]; | 601 charpos.m_AdjustMatrix[0]; |
| 602 pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[1] = | 602 pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[1] = |
| 603 charpos.m_AdjustMatrix[1]; | 603 charpos.m_AdjustMatrix[1]; |
| 604 pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[2] = | 604 pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[2] = |
| 605 charpos.m_AdjustMatrix[2]; | 605 charpos.m_AdjustMatrix[2]; |
| 606 pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[3] = | 606 pPSFont->m_Glyphs[ps_glyphindex].m_AdjustMatrix[3] = |
| 607 charpos.m_AdjustMatrix[3]; | 607 charpos.m_AdjustMatrix[3]; |
| 608 } | 608 } |
| 609 pPSFont->m_nGlyphs++; | 609 pPSFont->m_nGlyphs++; |
| 610 CFX_AffineMatrix matrix; | 610 CFX_Matrix matrix; |
| 611 if (charpos.m_bGlyphAdjust) | 611 if (charpos.m_bGlyphAdjust) |
| 612 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], | 612 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], |
| 613 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); | 613 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); |
| 614 matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0); | 614 matrix.Concat(1.0f, 0, 0, 1.0f, 0, 0); |
| 615 const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath( | 615 const CFX_PathData* pPathData = pFaceCache->LoadGlyphPath( |
| 616 pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth); | 616 pFont, charpos.m_GlyphIndex, charpos.m_FontCharWidth); |
| 617 if (pPathData == NULL) { | 617 if (pPathData == NULL) { |
| 618 return; | 618 return; |
| 619 } | 619 } |
| 620 CFX_PathData TransformedPath(*pPathData); | 620 CFX_PathData TransformedPath(*pPathData); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 650 buf << FX_BSTRC("f"); | 650 buf << FX_BSTRC("f"); |
| 651 buf << FX_BSTRC("}bind def end\n"); | 651 buf << FX_BSTRC("}bind def end\n"); |
| 652 buf << FX_BSTRC("/X") << ps_fontnum << FX_BSTRC(" Ff/Encoding get ") | 652 buf << FX_BSTRC("/X") << ps_fontnum << FX_BSTRC(" Ff/Encoding get ") |
| 653 << ps_glyphindex << FX_BSTRC("/") << ps_glyphindex << FX_BSTRC(" put\n"); | 653 << ps_glyphindex << FX_BSTRC("/") << ps_glyphindex << FX_BSTRC(" put\n"); |
| 654 m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize()); | 654 m_pOutput->OutputPS((const FX_CHAR*)buf.GetBuffer(), buf.GetSize()); |
| 655 } | 655 } |
| 656 FX_BOOL CFX_PSRenderer::DrawText(int nChars, | 656 FX_BOOL CFX_PSRenderer::DrawText(int nChars, |
| 657 const FXTEXT_CHARPOS* pCharPos, | 657 const FXTEXT_CHARPOS* pCharPos, |
| 658 CFX_Font* pFont, | 658 CFX_Font* pFont, |
| 659 CFX_FontCache* pCache, | 659 CFX_FontCache* pCache, |
| 660 const CFX_AffineMatrix* pObject2Device, | 660 const CFX_Matrix* pObject2Device, |
| 661 FX_FLOAT font_size, | 661 FX_FLOAT font_size, |
| 662 FX_DWORD color, | 662 FX_DWORD color, |
| 663 int alpha_flag, | 663 int alpha_flag, |
| 664 void* pIccTransform) { | 664 void* pIccTransform) { |
| 665 StartRendering(); | 665 StartRendering(); |
| 666 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha_flag) | 666 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha_flag) |
| 667 : FXARGB_A(color); | 667 : FXARGB_A(color); |
| 668 if (alpha < 255) { | 668 if (alpha < 255) { |
| 669 return FALSE; | 669 return FALSE; |
| 670 } | 670 } |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 FX_DWORD dest_size; | 708 FX_DWORD dest_size; |
| 709 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule(); | 709 CCodec_ModuleMgr* pEncoders = CFX_GEModule::Get()->GetCodecModule(); |
| 710 if (pEncoders && | 710 if (pEncoders && |
| 711 pEncoders->GetBasicModule()->A85Encode(data, len, dest_buf, dest_size)) { | 711 pEncoders->GetBasicModule()->A85Encode(data, len, dest_buf, dest_size)) { |
| 712 m_pOutput->OutputPS((const FX_CHAR*)dest_buf, dest_size); | 712 m_pOutput->OutputPS((const FX_CHAR*)dest_buf, dest_size); |
| 713 FX_Free(dest_buf); | 713 FX_Free(dest_buf); |
| 714 } else { | 714 } else { |
| 715 m_pOutput->OutputPS((const FX_CHAR*)data, len); | 715 m_pOutput->OutputPS((const FX_CHAR*)data, len); |
| 716 } | 716 } |
| 717 } | 717 } |
| OLD | NEW |