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/fpdfapi/fpdf_render/render_int.h" | 7 #include "core/fpdfapi/fpdf_render/render_int.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" | 9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" |
10 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" | 10 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 const CPDF_PageObject* pStopObj, | 201 const CPDF_PageObject* pStopObj, |
202 const CPDF_RenderStatus* pParentState, | 202 const CPDF_RenderStatus* pParentState, |
203 const CPDF_GraphicStates* pInitialStates, | 203 const CPDF_GraphicStates* pInitialStates, |
204 const CPDF_RenderOptions* pOptions, | 204 const CPDF_RenderOptions* pOptions, |
205 int transparency, | 205 int transparency, |
206 FX_BOOL bDropObjects, | 206 FX_BOOL bDropObjects, |
207 CPDF_Dictionary* pFormResource, | 207 CPDF_Dictionary* pFormResource, |
208 FX_BOOL bStdCS, | 208 FX_BOOL bStdCS, |
209 CPDF_Type3Char* pType3Char, | 209 CPDF_Type3Char* pType3Char, |
210 FX_ARGB fill_color, | 210 FX_ARGB fill_color, |
211 FX_DWORD GroupFamily, | 211 uint32_t GroupFamily, |
212 FX_BOOL bLoadMask) { | 212 FX_BOOL bLoadMask) { |
213 m_pContext = pContext; | 213 m_pContext = pContext; |
214 m_pDevice = pDevice; | 214 m_pDevice = pDevice; |
215 m_DitherBits = pDevice->GetDeviceCaps(FXDC_DITHER_BITS); | 215 m_DitherBits = pDevice->GetDeviceCaps(FXDC_DITHER_BITS); |
216 m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; | 216 m_bPrint = m_pDevice->GetDeviceClass() != FXDC_DISPLAY; |
217 if (pDeviceMatrix) { | 217 if (pDeviceMatrix) { |
218 m_DeviceMatrix = *pDeviceMatrix; | 218 m_DeviceMatrix = *pDeviceMatrix; |
219 } | 219 } |
220 m_pStopObj = pStopObj; | 220 m_pStopObj = pStopObj; |
221 if (pOptions) { | 221 if (pOptions) { |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 return TRUE; | 501 return TRUE; |
502 } | 502 } |
503 FX_BOOL CPDF_RenderStatus::ProcessPath(const CPDF_PathObject* pPathObj, | 503 FX_BOOL CPDF_RenderStatus::ProcessPath(const CPDF_PathObject* pPathObj, |
504 const CFX_Matrix* pObj2Device) { | 504 const CFX_Matrix* pObj2Device) { |
505 int FillType = pPathObj->m_FillType; | 505 int FillType = pPathObj->m_FillType; |
506 FX_BOOL bStroke = pPathObj->m_bStroke; | 506 FX_BOOL bStroke = pPathObj->m_bStroke; |
507 ProcessPathPattern(pPathObj, pObj2Device, FillType, bStroke); | 507 ProcessPathPattern(pPathObj, pObj2Device, FillType, bStroke); |
508 if (FillType == 0 && !bStroke) { | 508 if (FillType == 0 && !bStroke) { |
509 return TRUE; | 509 return TRUE; |
510 } | 510 } |
511 FX_DWORD fill_argb = 0; | 511 uint32_t fill_argb = 0; |
512 if (FillType) { | 512 if (FillType) { |
513 fill_argb = GetFillArgb(pPathObj); | 513 fill_argb = GetFillArgb(pPathObj); |
514 } | 514 } |
515 FX_DWORD stroke_argb = 0; | 515 uint32_t stroke_argb = 0; |
516 if (bStroke) { | 516 if (bStroke) { |
517 stroke_argb = GetStrokeArgb(pPathObj); | 517 stroke_argb = GetStrokeArgb(pPathObj); |
518 } | 518 } |
519 CFX_Matrix path_matrix = pPathObj->m_Matrix; | 519 CFX_Matrix path_matrix = pPathObj->m_Matrix; |
520 path_matrix.Concat(*pObj2Device); | 520 path_matrix.Concat(*pObj2Device); |
521 if (!IsAvailableMatrix(path_matrix)) { | 521 if (!IsAvailableMatrix(path_matrix)) { |
522 return TRUE; | 522 return TRUE; |
523 } | 523 } |
524 if (FillType && (m_Options.m_Flags & RENDER_RECT_AA)) { | 524 if (FillType && (m_Options.m_Flags & RENDER_RECT_AA)) { |
525 FillType |= FXFILL_RECT_AA; | 525 FillType |= FXFILL_RECT_AA; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 (!m_pType3Char->m_bColored || | 562 (!m_pType3Char->m_bColored || |
563 (m_pType3Char->m_bColored && | 563 (m_pType3Char->m_bColored && |
564 (!pColorData || pColorData->m_FillColor.IsNull())))) { | 564 (!pColorData || pColorData->m_FillColor.IsNull())))) { |
565 return m_T3FillColor; | 565 return m_T3FillColor; |
566 } | 566 } |
567 if (!pColorData || pColorData->m_FillColor.IsNull()) { | 567 if (!pColorData || pColorData->m_FillColor.IsNull()) { |
568 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*) | 568 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*) |
569 m_InitialStates.m_ColorState; | 569 m_InitialStates.m_ColorState; |
570 } | 570 } |
571 FX_COLORREF rgb = pColorData->m_FillRGB; | 571 FX_COLORREF rgb = pColorData->m_FillRGB; |
572 if (rgb == (FX_DWORD)-1) { | 572 if (rgb == (uint32_t)-1) { |
573 return 0; | 573 return 0; |
574 } | 574 } |
575 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState; | 575 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState; |
576 int alpha; | 576 int alpha; |
577 if (pGeneralData) { | 577 if (pGeneralData) { |
578 alpha = (int32_t)(pGeneralData->m_FillAlpha * 255); | 578 alpha = (int32_t)(pGeneralData->m_FillAlpha * 255); |
579 if (pGeneralData->m_pTR) { | 579 if (pGeneralData->m_pTR) { |
580 if (!pGeneralData->m_pTransferFunc) { | 580 if (!pGeneralData->m_pTransferFunc) { |
581 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = | 581 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = |
582 GetTransferFunc(pGeneralData->m_pTR); | 582 GetTransferFunc(pGeneralData->m_pTR); |
(...skipping 13 matching lines...) Expand all Loading... |
596 if (m_pType3Char && (!m_pType3Char->m_bColored || | 596 if (m_pType3Char && (!m_pType3Char->m_bColored || |
597 (m_pType3Char->m_bColored && | 597 (m_pType3Char->m_bColored && |
598 (!pColorData || pColorData->m_StrokeColor.IsNull())))) { | 598 (!pColorData || pColorData->m_StrokeColor.IsNull())))) { |
599 return m_T3FillColor; | 599 return m_T3FillColor; |
600 } | 600 } |
601 if (!pColorData || pColorData->m_StrokeColor.IsNull()) { | 601 if (!pColorData || pColorData->m_StrokeColor.IsNull()) { |
602 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*) | 602 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*) |
603 m_InitialStates.m_ColorState; | 603 m_InitialStates.m_ColorState; |
604 } | 604 } |
605 FX_COLORREF rgb = pColorData->m_StrokeRGB; | 605 FX_COLORREF rgb = pColorData->m_StrokeRGB; |
606 if (rgb == (FX_DWORD)-1) { | 606 if (rgb == (uint32_t)-1) { |
607 return 0; | 607 return 0; |
608 } | 608 } |
609 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState; | 609 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState; |
610 int alpha; | 610 int alpha; |
611 if (pGeneralData) { | 611 if (pGeneralData) { |
612 alpha = (int32_t)(pGeneralData->m_StrokeAlpha * 255); | 612 alpha = (int32_t)(pGeneralData->m_StrokeAlpha * 255); |
613 if (pGeneralData->m_pTR) { | 613 if (pGeneralData->m_pTR) { |
614 if (!pGeneralData->m_pTransferFunc) { | 614 if (!pGeneralData->m_pTransferFunc) { |
615 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = | 615 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = |
616 GetTransferFunc(pGeneralData->m_pTR); | 616 GetTransferFunc(pGeneralData->m_pTR); |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
840 new_matrix.Scale(scaleX, scaleY); | 840 new_matrix.Scale(scaleX, scaleY); |
841 std::unique_ptr<CFX_DIBitmap> pTextMask; | 841 std::unique_ptr<CFX_DIBitmap> pTextMask; |
842 if (bTextClip) { | 842 if (bTextClip) { |
843 pTextMask.reset(new CFX_DIBitmap); | 843 pTextMask.reset(new CFX_DIBitmap); |
844 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) | 844 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) |
845 return TRUE; | 845 return TRUE; |
846 | 846 |
847 pTextMask->Clear(0); | 847 pTextMask->Clear(0); |
848 CFX_FxgeDevice text_device; | 848 CFX_FxgeDevice text_device; |
849 text_device.Attach(pTextMask.get()); | 849 text_device.Attach(pTextMask.get()); |
850 for (FX_DWORD i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { | 850 for (uint32_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { |
851 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); | 851 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); |
852 if (!textobj) { | 852 if (!textobj) { |
853 break; | 853 break; |
854 } | 854 } |
855 CFX_Matrix text_matrix; | 855 CFX_Matrix text_matrix; |
856 textobj->GetTextMatrix(&text_matrix); | 856 textobj->GetTextMatrix(&text_matrix); |
857 CPDF_TextRenderer::DrawTextPath( | 857 CPDF_TextRenderer::DrawTextPath( |
858 &text_device, textobj->m_nChars, textobj->m_pCharCodes, | 858 &text_device, textobj->m_nChars, textobj->m_pCharCodes, |
859 textobj->m_pCharPos, textobj->m_TextState.GetFont(), | 859 textobj->m_pCharPos, textobj->m_TextState.GetFont(), |
860 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, | 860 textobj->m_TextState.GetFontSize(), &text_matrix, &new_matrix, |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1149 } | 1149 } |
1150 | 1150 |
1151 std::unique_ptr<CPDF_Function> pFuncs[3]; | 1151 std::unique_ptr<CPDF_Function> pFuncs[3]; |
1152 FX_BOOL bUniTransfer = TRUE; | 1152 FX_BOOL bUniTransfer = TRUE; |
1153 FX_BOOL bIdentity = TRUE; | 1153 FX_BOOL bIdentity = TRUE; |
1154 if (CPDF_Array* pArray = pObj->AsArray()) { | 1154 if (CPDF_Array* pArray = pObj->AsArray()) { |
1155 bUniTransfer = FALSE; | 1155 bUniTransfer = FALSE; |
1156 if (pArray->GetCount() < 3) | 1156 if (pArray->GetCount() < 3) |
1157 return nullptr; | 1157 return nullptr; |
1158 | 1158 |
1159 for (FX_DWORD i = 0; i < 3; ++i) { | 1159 for (uint32_t i = 0; i < 3; ++i) { |
1160 pFuncs[2 - i].reset(CPDF_Function::Load(pArray->GetElementValue(i))); | 1160 pFuncs[2 - i].reset(CPDF_Function::Load(pArray->GetElementValue(i))); |
1161 if (!pFuncs[2 - i]) | 1161 if (!pFuncs[2 - i]) |
1162 return nullptr; | 1162 return nullptr; |
1163 } | 1163 } |
1164 } else { | 1164 } else { |
1165 pFuncs[0].reset(CPDF_Function::Load(pObj)); | 1165 pFuncs[0].reset(CPDF_Function::Load(pObj)); |
1166 if (!pFuncs[0]) | 1166 if (!pFuncs[0]) |
1167 return nullptr; | 1167 return nullptr; |
1168 } | 1168 } |
1169 CPDF_TransferFunc* pTransfer = new CPDF_TransferFunc(m_pPDFDoc); | 1169 CPDF_TransferFunc* pTransfer = new CPDF_TransferFunc(m_pPDFDoc); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1332 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, | 1332 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, |
1333 &m_Matrix); | 1333 &m_Matrix); |
1334 return TRUE; | 1334 return TRUE; |
1335 } | 1335 } |
1336 void CPDF_ScaledRenderBuffer::OutputToDevice() { | 1336 void CPDF_ScaledRenderBuffer::OutputToDevice() { |
1337 if (m_pBitmapDevice) { | 1337 if (m_pBitmapDevice) { |
1338 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, | 1338 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, |
1339 m_Rect.top, m_Rect.Width(), m_Rect.Height()); | 1339 m_Rect.top, m_Rect.Width(), m_Rect.Height()); |
1340 } | 1340 } |
1341 } | 1341 } |
OLD | NEW |