OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/render/cpdf_renderstatus.h" | 7 #include "core/fpdfapi/render/cpdf_renderstatus.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 #include "core/fpdfdoc/cpdf_occontext.h" | 47 #include "core/fpdfdoc/cpdf_occontext.h" |
48 #include "core/fxcodec/fx_codec.h" | 48 #include "core/fxcodec/fx_codec.h" |
49 #include "core/fxcrt/cfx_maybe_owned.h" | 49 #include "core/fxcrt/cfx_maybe_owned.h" |
50 #include "core/fxcrt/fx_safe_types.h" | 50 #include "core/fxcrt/fx_safe_types.h" |
51 #include "core/fxge/cfx_fxgedevice.h" | 51 #include "core/fxge/cfx_fxgedevice.h" |
52 #include "core/fxge/cfx_graphstatedata.h" | 52 #include "core/fxge/cfx_graphstatedata.h" |
53 #include "core/fxge/cfx_pathdata.h" | 53 #include "core/fxge/cfx_pathdata.h" |
54 #include "core/fxge/cfx_renderdevice.h" | 54 #include "core/fxge/cfx_renderdevice.h" |
55 #include "core/fxge/ifx_renderdevicedriver.h" | 55 #include "core/fxge/ifx_renderdevicedriver.h" |
56 #include "third_party/base/numerics/safe_math.h" | 56 #include "third_party/base/numerics/safe_math.h" |
| 57 #include "third_party/base/ptr_util.h" |
57 | 58 |
58 #ifdef _SKIA_SUPPORT_ | 59 #ifdef _SKIA_SUPPORT_ |
59 #include "core/fxge/skia/fx_skia_device.h" | 60 #include "core/fxge/skia/fx_skia_device.h" |
60 #endif | 61 #endif |
61 | 62 |
62 #define SHADING_STEPS 256 | 63 #define SHADING_STEPS 256 |
63 | 64 |
64 namespace { | 65 namespace { |
65 | 66 |
66 void ReleaseCachedType3(CPDF_Type3Font* pFont) { | 67 void ReleaseCachedType3(CPDF_Type3Font* pFont) { |
(...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 if (m_Options.m_pOCContext && pObj->m_ContentMark && | 1073 if (m_Options.m_pOCContext && pObj->m_ContentMark && |
1073 !m_Options.m_pOCContext->CheckObjectVisible(pObj)) { | 1074 !m_Options.m_pOCContext->CheckObjectVisible(pObj)) { |
1074 return false; | 1075 return false; |
1075 } | 1076 } |
1076 | 1077 |
1077 ProcessClipPath(pObj->m_ClipPath, pObj2Device); | 1078 ProcessClipPath(pObj->m_ClipPath, pObj2Device); |
1078 if (ProcessTransparency(pObj, pObj2Device)) | 1079 if (ProcessTransparency(pObj, pObj2Device)) |
1079 return false; | 1080 return false; |
1080 | 1081 |
1081 if (pObj->IsImage()) { | 1082 if (pObj->IsImage()) { |
1082 m_pImageRenderer.reset(new CPDF_ImageRenderer); | 1083 m_pImageRenderer = pdfium::MakeUnique<CPDF_ImageRenderer>(); |
1083 if (!m_pImageRenderer->Start(this, pObj, pObj2Device, false, | 1084 if (!m_pImageRenderer->Start(this, pObj, pObj2Device, false, |
1084 FXDIB_BLEND_NORMAL)) { | 1085 FXDIB_BLEND_NORMAL)) { |
1085 if (!m_pImageRenderer->GetResult()) | 1086 if (!m_pImageRenderer->GetResult()) |
1086 DrawObjWithBackground(pObj, pObj2Device); | 1087 DrawObjWithBackground(pObj, pObj2Device); |
1087 m_pImageRenderer.reset(); | 1088 m_pImageRenderer.reset(); |
1088 return false; | 1089 return false; |
1089 } | 1090 } |
1090 return ContinueSingleObject(pObj, pObj2Device, pPause); | 1091 return ContinueSingleObject(pObj, pObj2Device, pPause); |
1091 } | 1092 } |
1092 | 1093 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 if (m_pDevice->GetDeviceClass() == FXDC_DISPLAY && | 1376 if (m_pDevice->GetDeviceClass() == FXDC_DISPLAY && |
1376 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { | 1377 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)) { |
1377 return; | 1378 return; |
1378 } | 1379 } |
1379 | 1380 |
1380 std::unique_ptr<CFX_PathData> pTextClippingPath; | 1381 std::unique_ptr<CFX_PathData> pTextClippingPath; |
1381 for (int i = 0; i < textcount; ++i) { | 1382 for (int i = 0; i < textcount; ++i) { |
1382 CPDF_TextObject* pText = ClipPath.GetText(i); | 1383 CPDF_TextObject* pText = ClipPath.GetText(i); |
1383 if (pText) { | 1384 if (pText) { |
1384 if (!pTextClippingPath) | 1385 if (!pTextClippingPath) |
1385 pTextClippingPath.reset(new CFX_PathData); | 1386 pTextClippingPath = pdfium::MakeUnique<CFX_PathData>(); |
1386 ProcessText(pText, pObj2Device, pTextClippingPath.get()); | 1387 ProcessText(pText, pObj2Device, pTextClippingPath.get()); |
1387 continue; | 1388 continue; |
1388 } | 1389 } |
1389 | 1390 |
1390 if (!pTextClippingPath) | 1391 if (!pTextClippingPath) |
1391 continue; | 1392 continue; |
1392 | 1393 |
1393 int fill_mode = FXFILL_WINDING; | 1394 int fill_mode = FXFILL_WINDING; |
1394 if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH) | 1395 if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH) |
1395 fill_mode |= FXFILL_NOPATHSMOOTH; | 1396 fill_mode |= FXFILL_NOPATHSMOOTH; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1506 return true; | 1507 return true; |
1507 } | 1508 } |
1508 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); | 1509 CFX_Matrix deviceCTM = m_pDevice->GetCTM(); |
1509 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); | 1510 FX_FLOAT scaleX = FXSYS_fabs(deviceCTM.a); |
1510 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); | 1511 FX_FLOAT scaleY = FXSYS_fabs(deviceCTM.d); |
1511 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); | 1512 int width = FXSYS_round((FX_FLOAT)rect.Width() * scaleX); |
1512 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); | 1513 int height = FXSYS_round((FX_FLOAT)rect.Height() * scaleY); |
1513 CFX_FxgeDevice bitmap_device; | 1514 CFX_FxgeDevice bitmap_device; |
1514 std::unique_ptr<CFX_DIBitmap> oriDevice; | 1515 std::unique_ptr<CFX_DIBitmap> oriDevice; |
1515 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { | 1516 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { |
1516 oriDevice.reset(new CFX_DIBitmap); | 1517 oriDevice = pdfium::MakeUnique<CFX_DIBitmap>(); |
1517 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) | 1518 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) |
1518 return true; | 1519 return true; |
1519 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); | 1520 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); |
1520 } | 1521 } |
1521 if (!bitmap_device.Create(width, height, FXDIB_Argb, oriDevice.get())) | 1522 if (!bitmap_device.Create(width, height, FXDIB_Argb, oriDevice.get())) |
1522 return true; | 1523 return true; |
1523 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); | 1524 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); |
1524 bitmap->Clear(0); | 1525 bitmap->Clear(0); |
1525 CFX_Matrix new_matrix = *pObj2Device; | 1526 CFX_Matrix new_matrix = *pObj2Device; |
1526 new_matrix.TranslateI(-rect.left, -rect.top); | 1527 new_matrix.TranslateI(-rect.left, -rect.top); |
1527 new_matrix.Scale(scaleX, scaleY); | 1528 new_matrix.Scale(scaleX, scaleY); |
1528 std::unique_ptr<CFX_DIBitmap> pTextMask; | 1529 std::unique_ptr<CFX_DIBitmap> pTextMask; |
1529 if (bTextClip) { | 1530 if (bTextClip) { |
1530 pTextMask.reset(new CFX_DIBitmap); | 1531 pTextMask = pdfium::MakeUnique<CFX_DIBitmap>(); |
1531 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) | 1532 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) |
1532 return true; | 1533 return true; |
1533 | 1534 |
1534 pTextMask->Clear(0); | 1535 pTextMask->Clear(0); |
1535 CFX_FxgeDevice text_device; | 1536 CFX_FxgeDevice text_device; |
1536 text_device.Attach(pTextMask.get(), false, nullptr, false); | 1537 text_device.Attach(pTextMask.get(), false, nullptr, false); |
1537 for (uint32_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { | 1538 for (uint32_t i = 0; i < pPageObj->m_ClipPath.GetTextCount(); i++) { |
1538 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); | 1539 CPDF_TextObject* textobj = pPageObj->m_ClipPath.GetText(i); |
1539 if (!textobj) { | 1540 if (!textobj) { |
1540 break; | 1541 break; |
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2627 } else if (pFunc) { | 2628 } else if (pFunc) { |
2628 int size = dest_pitch * height; | 2629 int size = dest_pitch * height; |
2629 for (int i = 0; i < size; i++) { | 2630 for (int i = 0; i < size; i++) { |
2630 dest_buf[i] = transfers[src_buf[i]]; | 2631 dest_buf[i] = transfers[src_buf[i]]; |
2631 } | 2632 } |
2632 } else { | 2633 } else { |
2633 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 2634 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
2634 } | 2635 } |
2635 return pMask; | 2636 return pMask; |
2636 } | 2637 } |
OLD | NEW |