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 "../../../include/fpdfapi/fpdf_render.h" | 7 #include "../../../include/fpdfapi/fpdf_render.h" |
8 #include "../../../include/fpdfapi/fpdf_module.h" | 8 #include "../../../include/fpdfapi/fpdf_module.h" |
9 #include "../fpdf_page/pageint.h" | 9 #include "../fpdf_page/pageint.h" |
10 #include "../../../include/fxge/fx_ge.h" | 10 #include "../../../include/fxge/fx_ge.h" |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 } | 354 } |
355 FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, con
st CFX_AffineMatrix* pObj2Device, FX_BOOL bLogical, FX_RECT &rect) const | 355 FX_BOOL CPDF_RenderStatus::GetObjectClippedRect(const CPDF_PageObject* pObj, con
st CFX_AffineMatrix* pObj2Device, FX_BOOL bLogical, FX_RECT &rect) const |
356 { | 356 { |
357 rect = pObj->GetBBox(pObj2Device); | 357 rect = pObj->GetBBox(pObj2Device); |
358 FX_RECT rtClip = m_pDevice->GetClipBox(); | 358 FX_RECT rtClip = m_pDevice->GetClipBox(); |
359 if (!bLogical) { | 359 if (!bLogical) { |
360 CFX_Matrix dCTM = m_pDevice->GetCTM(); | 360 CFX_Matrix dCTM = m_pDevice->GetCTM(); |
361 FX_FLOAT a = FXSYS_fabs(dCTM.a); | 361 FX_FLOAT a = FXSYS_fabs(dCTM.a); |
362 FX_FLOAT d = FXSYS_fabs(dCTM.d); | 362 FX_FLOAT d = FXSYS_fabs(dCTM.d); |
363 if (a != 1.0f || d != 1.0f) { | 363 if (a != 1.0f || d != 1.0f) { |
364 rect.right = rect.left + (FX_INT32)FXSYS_ceil((FX_FLOAT)rect.Width()
* a); | 364 rect.right = rect.left + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Width()
* a); |
365 rect.bottom = rect.top + (FX_INT32)FXSYS_ceil((FX_FLOAT)rect.Height(
) * d); | 365 rect.bottom = rect.top + (int32_t)FXSYS_ceil((FX_FLOAT)rect.Height()
* d); |
366 rtClip.right = rtClip.left + (FX_INT32)FXSYS_ceil((FX_FLOAT)rtClip.W
idth() * a); | 366 rtClip.right = rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Wi
dth() * a); |
367 rtClip.bottom = rtClip.top + (FX_INT32)FXSYS_ceil((FX_FLOAT)rtClip.H
eight() * d); | 367 rtClip.bottom = rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.He
ight() * d); |
368 } | 368 } |
369 } | 369 } |
370 rect.Intersect(rtClip); | 370 rect.Intersect(rtClip); |
371 return rect.IsEmpty(); | 371 return rect.IsEmpty(); |
372 } | 372 } |
373 void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj, const CFX_
AffineMatrix* pObj2Device) | 373 void CPDF_RenderStatus::DitherObjectArea(const CPDF_PageObject* pObj, const CFX_
AffineMatrix* pObj2Device) |
374 { | 374 { |
375 CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap(); | 375 CFX_DIBitmap* pBitmap = m_pDevice->GetBitmap(); |
376 if (pBitmap == NULL) { | 376 if (pBitmap == NULL) { |
377 return; | 377 return; |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 } else if (!pColorData || pColorData->m_FillColor.IsNull()) { | 561 } else if (!pColorData || pColorData->m_FillColor.IsNull()) { |
562 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_Initial
States.m_ColorState; | 562 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_Initial
States.m_ColorState; |
563 } | 563 } |
564 FX_COLORREF rgb = pColorData->m_FillRGB; | 564 FX_COLORREF rgb = pColorData->m_FillRGB; |
565 if (rgb == (FX_DWORD) - 1) { | 565 if (rgb == (FX_DWORD) - 1) { |
566 return 0; | 566 return 0; |
567 } | 567 } |
568 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState; | 568 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState; |
569 int alpha; | 569 int alpha; |
570 if (pGeneralData) { | 570 if (pGeneralData) { |
571 alpha = (FX_INT32)(pGeneralData->m_FillAlpha * 255); | 571 alpha = (int32_t)(pGeneralData->m_FillAlpha * 255); |
572 if (pGeneralData->m_pTR) { | 572 if (pGeneralData->m_pTR) { |
573 if (!pGeneralData->m_pTransferFunc) { | 573 if (!pGeneralData->m_pTransferFunc) { |
574 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = GetTra
nsferFunc(pGeneralData->m_pTR); | 574 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = GetTra
nsferFunc(pGeneralData->m_pTR); |
575 } | 575 } |
576 if (pGeneralData->m_pTransferFunc) { | 576 if (pGeneralData->m_pTransferFunc) { |
577 rgb = pGeneralData->m_pTransferFunc->TranslateColor(rgb); | 577 rgb = pGeneralData->m_pTransferFunc->TranslateColor(rgb); |
578 } | 578 } |
579 } | 579 } |
580 } else { | 580 } else { |
581 alpha = 255; | 581 alpha = 255; |
582 } | 582 } |
583 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); | 583 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); |
584 } | 584 } |
585 FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const | 585 FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const |
586 { | 586 { |
587 CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorSta
teData*)pObj->m_ColorState; | 587 CPDF_ColorStateData* pColorData = (CPDF_ColorStateData*)(const CPDF_ColorSta
teData*)pObj->m_ColorState; |
588 if (m_pType3Char && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored
&& (!pColorData || pColorData->m_StrokeColor.IsNull())))) { | 588 if (m_pType3Char && (!m_pType3Char->m_bColored || (m_pType3Char->m_bColored
&& (!pColorData || pColorData->m_StrokeColor.IsNull())))) { |
589 return m_T3FillColor; | 589 return m_T3FillColor; |
590 } else if (!pColorData || pColorData->m_StrokeColor.IsNull()) { | 590 } else if (!pColorData || pColorData->m_StrokeColor.IsNull()) { |
591 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_Initial
States.m_ColorState; | 591 pColorData = (CPDF_ColorStateData*)(const CPDF_ColorStateData*)m_Initial
States.m_ColorState; |
592 } | 592 } |
593 FX_COLORREF rgb = pColorData->m_StrokeRGB; | 593 FX_COLORREF rgb = pColorData->m_StrokeRGB; |
594 if (rgb == (FX_DWORD) - 1) { | 594 if (rgb == (FX_DWORD) - 1) { |
595 return 0; | 595 return 0; |
596 } | 596 } |
597 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState; | 597 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState; |
598 int alpha; | 598 int alpha; |
599 if (pGeneralData) { | 599 if (pGeneralData) { |
600 alpha = (FX_INT32)(pGeneralData->m_StrokeAlpha * 255); | 600 alpha = (int32_t)(pGeneralData->m_StrokeAlpha * 255); |
601 if (pGeneralData->m_pTR) { | 601 if (pGeneralData->m_pTR) { |
602 if (!pGeneralData->m_pTransferFunc) { | 602 if (!pGeneralData->m_pTransferFunc) { |
603 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = GetTra
nsferFunc(pGeneralData->m_pTR); | 603 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = GetTra
nsferFunc(pGeneralData->m_pTR); |
604 } | 604 } |
605 if (pGeneralData->m_pTransferFunc) { | 605 if (pGeneralData->m_pTransferFunc) { |
606 rgb = pGeneralData->m_pTransferFunc->TranslateColor(rgb); | 606 rgb = pGeneralData->m_pTransferFunc->TranslateColor(rgb); |
607 } | 607 } |
608 } | 608 } |
609 } else { | 609 } else { |
610 alpha = 255; | 610 alpha = 255; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 bitmap->MultiplyAlpha(pSMaskSource); | 850 bitmap->MultiplyAlpha(pSMaskSource); |
851 delete pSMaskSource; | 851 delete pSMaskSource; |
852 } | 852 } |
853 } | 853 } |
854 if (pTextMask) { | 854 if (pTextMask) { |
855 bitmap->MultiplyAlpha(pTextMask); | 855 bitmap->MultiplyAlpha(pTextMask); |
856 delete pTextMask; | 856 delete pTextMask; |
857 pTextMask = NULL; | 857 pTextMask = NULL; |
858 } | 858 } |
859 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) { | 859 if (Transparency & PDFTRANS_GROUP && group_alpha != 1.0f) { |
860 bitmap->MultiplyAlpha((FX_INT32)(group_alpha * 255)); | 860 bitmap->MultiplyAlpha((int32_t)(group_alpha * 255)); |
861 } | 861 } |
862 Transparency = m_Transparency; | 862 Transparency = m_Transparency; |
863 if (pPageObj->m_Type == PDFPAGE_FORM) { | 863 if (pPageObj->m_Type == PDFPAGE_FORM) { |
864 Transparency |= PDFTRANS_GROUP; | 864 Transparency |= PDFTRANS_GROUP; |
865 } | 865 } |
866 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, Transpare
ncy); | 866 CompositeDIBitmap(bitmap, rect.left, rect.top, 0, 255, blend_type, Transpare
ncy); |
867 if (oriDevice) { | 867 if (oriDevice) { |
868 delete oriDevice; | 868 delete oriDevice; |
869 } | 869 } |
870 return TRUE; | 870 return TRUE; |
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 int dpiv = pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size
* 10); | 1364 int dpiv = pDevice->GetDeviceCaps(FXDC_PIXEL_HEIGHT) * 254 / (vert_size
* 10); |
1365 if (dpih > max_dpi) { | 1365 if (dpih > max_dpi) { |
1366 m_Matrix.Scale((FX_FLOAT)(max_dpi) / dpih, 1.0f); | 1366 m_Matrix.Scale((FX_FLOAT)(max_dpi) / dpih, 1.0f); |
1367 } | 1367 } |
1368 if (dpiv > max_dpi) { | 1368 if (dpiv > max_dpi) { |
1369 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); | 1369 m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); |
1370 } | 1370 } |
1371 } | 1371 } |
1372 m_pBitmapDevice = new CFX_FxgeDevice; | 1372 m_pBitmapDevice = new CFX_FxgeDevice; |
1373 FXDIB_Format dibFormat = FXDIB_Rgb; | 1373 FXDIB_Format dibFormat = FXDIB_Rgb; |
1374 FX_INT32 bpp = 24; | 1374 int32_t bpp = 24; |
1375 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) { | 1375 if (m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_ALPHA_OUTPUT) { |
1376 dibFormat = FXDIB_Argb; | 1376 dibFormat = FXDIB_Argb; |
1377 bpp = 32; | 1377 bpp = 32; |
1378 } | 1378 } |
1379 CFX_FloatRect rect; | 1379 CFX_FloatRect rect; |
1380 FX_INT32 iWidth, iHeight, iPitch; | 1380 int32_t iWidth, iHeight, iPitch; |
1381 while (1) { | 1381 while (1) { |
1382 rect = *pRect; | 1382 rect = *pRect; |
1383 m_Matrix.TransformRect(rect); | 1383 m_Matrix.TransformRect(rect); |
1384 FX_RECT bitmap_rect = rect.GetOutterRect(); | 1384 FX_RECT bitmap_rect = rect.GetOutterRect(); |
1385 iWidth = bitmap_rect.Width(); | 1385 iWidth = bitmap_rect.Width(); |
1386 iHeight = bitmap_rect.Height(); | 1386 iHeight = bitmap_rect.Height(); |
1387 iPitch = (iWidth * bpp + 31) / 32 * 4; | 1387 iPitch = (iWidth * bpp + 31) / 32 * 4; |
1388 if (iWidth * iHeight < 1) { | 1388 if (iWidth * iHeight < 1) { |
1389 return FALSE; | 1389 return FALSE; |
1390 } | 1390 } |
(...skipping 20 matching lines...) Expand all Loading... |
1411 CPDF_ContentMarkItem& item = pData->GetItem(i); | 1411 CPDF_ContentMarkItem& item = pData->GetItem(i); |
1412 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont
entMarkItem::PropertiesDict) { | 1412 if (item.GetName() == FX_BSTRC("OC") && item.GetParamType() == CPDF_Cont
entMarkItem::PropertiesDict) { |
1413 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam(); | 1413 CPDF_Dictionary* pOCG = (CPDF_Dictionary*)item.GetParam(); |
1414 if (!CheckOCGVisible(pOCG)) { | 1414 if (!CheckOCGVisible(pOCG)) { |
1415 return FALSE; | 1415 return FALSE; |
1416 } | 1416 } |
1417 } | 1417 } |
1418 } | 1418 } |
1419 return TRUE; | 1419 return TRUE; |
1420 } | 1420 } |
OLD | NEW |