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 28 matching lines...) Expand all Loading... |
39 #include "core/fpdfapi/render/cpdf_pagerendercache.h" | 39 #include "core/fpdfapi/render/cpdf_pagerendercache.h" |
40 #include "core/fpdfapi/render/cpdf_rendercontext.h" | 40 #include "core/fpdfapi/render/cpdf_rendercontext.h" |
41 #include "core/fpdfapi/render/cpdf_renderoptions.h" | 41 #include "core/fpdfapi/render/cpdf_renderoptions.h" |
42 #include "core/fpdfapi/render/cpdf_scaledrenderbuffer.h" | 42 #include "core/fpdfapi/render/cpdf_scaledrenderbuffer.h" |
43 #include "core/fpdfapi/render/cpdf_textrenderer.h" | 43 #include "core/fpdfapi/render/cpdf_textrenderer.h" |
44 #include "core/fpdfapi/render/cpdf_transferfunc.h" | 44 #include "core/fpdfapi/render/cpdf_transferfunc.h" |
45 #include "core/fpdfapi/render/cpdf_type3cache.h" | 45 #include "core/fpdfapi/render/cpdf_type3cache.h" |
46 #include "core/fpdfapi/render/render_int.h" | 46 #include "core/fpdfapi/render/render_int.h" |
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/fx_safe_types.h" | 50 #include "core/fxcrt/fx_safe_types.h" |
50 #include "core/fxge/cfx_fxgedevice.h" | 51 #include "core/fxge/cfx_fxgedevice.h" |
51 #include "core/fxge/cfx_graphstatedata.h" | 52 #include "core/fxge/cfx_graphstatedata.h" |
52 #include "core/fxge/cfx_pathdata.h" | 53 #include "core/fxge/cfx_pathdata.h" |
53 #include "core/fxge/cfx_renderdevice.h" | 54 #include "core/fxge/cfx_renderdevice.h" |
54 #include "core/fxge/ifx_renderdevicedriver.h" | 55 #include "core/fxge/ifx_renderdevicedriver.h" |
55 #include "third_party/base/numerics/safe_math.h" | 56 #include "third_party/base/numerics/safe_math.h" |
56 | 57 |
57 #ifdef _SKIA_SUPPORT_ | 58 #ifdef _SKIA_SUPPORT_ |
58 #include "core/fxge/skia/fx_skia_device.h" | 59 #include "core/fxge/skia/fx_skia_device.h" |
(...skipping 2199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2258 max_row--; | 2259 max_row--; |
2259 } | 2260 } |
2260 } | 2261 } |
2261 FX_FLOAT left_offset = cell_bbox.left - mtPattern2Device.e; | 2262 FX_FLOAT left_offset = cell_bbox.left - mtPattern2Device.e; |
2262 FX_FLOAT top_offset = cell_bbox.bottom - mtPattern2Device.f; | 2263 FX_FLOAT top_offset = cell_bbox.bottom - mtPattern2Device.f; |
2263 std::unique_ptr<CFX_DIBitmap> pPatternBitmap; | 2264 std::unique_ptr<CFX_DIBitmap> pPatternBitmap; |
2264 if (width * height < 16) { | 2265 if (width * height < 16) { |
2265 std::unique_ptr<CFX_DIBitmap> pEnlargedBitmap = | 2266 std::unique_ptr<CFX_DIBitmap> pEnlargedBitmap = |
2266 DrawPatternBitmap(m_pContext->GetDocument(), m_pContext->GetPageCache(), | 2267 DrawPatternBitmap(m_pContext->GetDocument(), m_pContext->GetPageCache(), |
2267 pPattern, pObj2Device, 8, 8, m_Options.m_Flags); | 2268 pPattern, pObj2Device, 8, 8, m_Options.m_Flags); |
2268 pPatternBitmap.reset(pEnlargedBitmap->StretchTo(width, height)); | 2269 pPatternBitmap = pEnlargedBitmap->StretchTo(width, height); |
2269 } else { | 2270 } else { |
2270 pPatternBitmap = DrawPatternBitmap( | 2271 pPatternBitmap = DrawPatternBitmap( |
2271 m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern, | 2272 m_pContext->GetDocument(), m_pContext->GetPageCache(), pPattern, |
2272 pObj2Device, width, height, m_Options.m_Flags); | 2273 pObj2Device, width, height, m_Options.m_Flags); |
2273 } | 2274 } |
2274 if (!pPatternBitmap) { | 2275 if (!pPatternBitmap) { |
2275 m_pDevice->RestoreState(false); | 2276 m_pDevice->RestoreState(false); |
2276 return; | 2277 return; |
2277 } | 2278 } |
2278 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) { | 2279 if (m_Options.m_ColorMode == RENDER_COLOR_GRAY) { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2432 if (bGetBackGround) { | 2433 if (bGetBackGround) { |
2433 if (bIsolated || !bGroup) { | 2434 if (bIsolated || !bGroup) { |
2434 if (pDIBitmap->IsAlphaMask()) { | 2435 if (pDIBitmap->IsAlphaMask()) { |
2435 return; | 2436 return; |
2436 } | 2437 } |
2437 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); | 2438 m_pDevice->SetDIBitsWithBlend(pDIBitmap, left, top, blend_mode); |
2438 } else { | 2439 } else { |
2439 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), | 2440 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), |
2440 top + pDIBitmap->GetHeight()); | 2441 top + pDIBitmap->GetHeight()); |
2441 rect.Intersect(m_pDevice->GetClipBox()); | 2442 rect.Intersect(m_pDevice->GetClipBox()); |
2442 CFX_DIBitmap* pClone = nullptr; | 2443 CFX_MaybeOwned<CFX_DIBitmap> pClone; |
2443 bool bClone = false; | |
2444 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { | 2444 if (m_pDevice->GetBackDrop() && m_pDevice->GetBitmap()) { |
2445 bClone = true; | |
2446 pClone = m_pDevice->GetBackDrop()->Clone(&rect); | 2445 pClone = m_pDevice->GetBackDrop()->Clone(&rect); |
2447 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); | 2446 CFX_DIBitmap* pForeBitmap = m_pDevice->GetBitmap(); |
2448 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), | 2447 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), |
2449 pForeBitmap, rect.left, rect.top); | 2448 pForeBitmap, rect.left, rect.top); |
2450 left = left >= 0 ? 0 : left; | 2449 left = left >= 0 ? 0 : left; |
2451 top = top >= 0 ? 0 : top; | 2450 top = top >= 0 ? 0 : top; |
2452 if (!pDIBitmap->IsAlphaMask()) | 2451 if (!pDIBitmap->IsAlphaMask()) |
2453 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), | 2452 pClone->CompositeBitmap(0, 0, pClone->GetWidth(), pClone->GetHeight(), |
2454 pDIBitmap, left, top, blend_mode); | 2453 pDIBitmap, left, top, blend_mode); |
2455 else | 2454 else |
2456 pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(), | 2455 pClone->CompositeMask(0, 0, pClone->GetWidth(), pClone->GetHeight(), |
2457 pDIBitmap, mask_argb, left, top, blend_mode); | 2456 pDIBitmap, mask_argb, left, top, blend_mode); |
2458 } else { | 2457 } else { |
2459 pClone = pDIBitmap; | 2458 pClone = pDIBitmap; |
2460 } | 2459 } |
2461 if (m_pDevice->GetBackDrop()) { | 2460 if (m_pDevice->GetBackDrop()) { |
2462 m_pDevice->SetDIBits(pClone, rect.left, rect.top); | 2461 m_pDevice->SetDIBits(pClone.Get(), rect.left, rect.top); |
2463 } else { | 2462 } else { |
2464 if (pDIBitmap->IsAlphaMask()) { | 2463 if (pDIBitmap->IsAlphaMask()) |
2465 return; | 2464 return; |
2466 } | |
2467 m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top, | 2465 m_pDevice->SetDIBitsWithBlend(pDIBitmap, rect.left, rect.top, |
2468 blend_mode); | 2466 blend_mode); |
2469 } | 2467 } |
2470 if (bClone) { | |
2471 delete pClone; | |
2472 } | |
2473 } | 2468 } |
2474 return; | 2469 return; |
2475 } | 2470 } |
2476 int back_left, back_top; | 2471 int back_left, back_top; |
2477 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), | 2472 FX_RECT rect(left, top, left + pDIBitmap->GetWidth(), |
2478 top + pDIBitmap->GetHeight()); | 2473 top + pDIBitmap->GetHeight()); |
2479 std::unique_ptr<CFX_DIBitmap> pBackdrop = | 2474 std::unique_ptr<CFX_DIBitmap> pBackdrop = |
2480 GetBackdrop(m_pCurObj, rect, back_left, back_top, | 2475 GetBackdrop(m_pCurObj, rect, back_left, back_top, |
2481 blend_mode > FXDIB_BLEND_NORMAL && bIsolated); | 2476 blend_mode > FXDIB_BLEND_NORMAL && bIsolated); |
2482 if (!pBackdrop) | 2477 if (!pBackdrop) |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2630 } else if (pFunc) { | 2625 } else if (pFunc) { |
2631 int size = dest_pitch * height; | 2626 int size = dest_pitch * height; |
2632 for (int i = 0; i < size; i++) { | 2627 for (int i = 0; i < size; i++) { |
2633 dest_buf[i] = transfers[src_buf[i]]; | 2628 dest_buf[i] = transfers[src_buf[i]]; |
2634 } | 2629 } |
2635 } else { | 2630 } else { |
2636 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 2631 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
2637 } | 2632 } |
2638 return pMask; | 2633 return pMask; |
2639 } | 2634 } |
OLD | NEW |