| 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 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 int height, | 869 int height, |
| 870 int flags) { | 870 int flags) { |
| 871 std::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); | 871 std::unique_ptr<CFX_DIBitmap> pBitmap(new CFX_DIBitmap); |
| 872 if (!pBitmap->Create(width, height, | 872 if (!pBitmap->Create(width, height, |
| 873 pPattern->colored() ? FXDIB_Argb : FXDIB_8bppMask)) { | 873 pPattern->colored() ? FXDIB_Argb : FXDIB_8bppMask)) { |
| 874 return nullptr; | 874 return nullptr; |
| 875 } | 875 } |
| 876 CFX_FxgeDevice bitmap_device; | 876 CFX_FxgeDevice bitmap_device; |
| 877 bitmap_device.Attach(pBitmap.get(), false, nullptr, false); | 877 bitmap_device.Attach(pBitmap.get(), false, nullptr, false); |
| 878 pBitmap->Clear(0); | 878 pBitmap->Clear(0); |
| 879 #if defined _SKIA_SUPPORT_PATHS_ |
| 880 pBitmap->SetIsOffscreen(true); |
| 881 #endif |
| 879 CFX_FloatRect cell_bbox = pPattern->bbox(); | 882 CFX_FloatRect cell_bbox = pPattern->bbox(); |
| 880 pPattern->pattern_to_form()->TransformRect(cell_bbox); | 883 pPattern->pattern_to_form()->TransformRect(cell_bbox); |
| 881 pObject2Device->TransformRect(cell_bbox); | 884 pObject2Device->TransformRect(cell_bbox); |
| 882 CFX_FloatRect bitmap_rect(0.0f, 0.0f, (FX_FLOAT)width, (FX_FLOAT)height); | 885 CFX_FloatRect bitmap_rect(0.0f, 0.0f, (FX_FLOAT)width, (FX_FLOAT)height); |
| 883 CFX_Matrix mtAdjust; | 886 CFX_Matrix mtAdjust; |
| 884 mtAdjust.MatchRect(bitmap_rect, cell_bbox); | 887 mtAdjust.MatchRect(bitmap_rect, cell_bbox); |
| 885 CFX_Matrix mtPattern2Bitmap = *pObject2Device; | 888 CFX_Matrix mtPattern2Bitmap = *pObject2Device; |
| 886 mtPattern2Bitmap.Concat(mtAdjust); | 889 mtPattern2Bitmap.Concat(mtAdjust); |
| 887 CPDF_RenderOptions options; | 890 CPDF_RenderOptions options; |
| 888 if (!pPattern->colored()) | 891 if (!pPattern->colored()) |
| 889 options.m_ColorMode = RENDER_COLOR_ALPHA; | 892 options.m_ColorMode = RENDER_COLOR_ALPHA; |
| 890 | 893 |
| 891 flags |= RENDER_FORCE_HALFTONE; | 894 flags |= RENDER_FORCE_HALFTONE; |
| 892 options.m_Flags = flags; | 895 options.m_Flags = flags; |
| 893 CPDF_RenderContext context(pDoc, pCache); | 896 CPDF_RenderContext context(pDoc, pCache); |
| 894 context.AppendLayer(pPattern->form(), &mtPattern2Bitmap); | 897 context.AppendLayer(pPattern->form(), &mtPattern2Bitmap); |
| 895 context.Render(&bitmap_device, &options, nullptr); | 898 context.Render(&bitmap_device, &options, nullptr); |
| 899 #if defined _SKIA_SUPPORT_PATHS_ |
| 900 pBitmap->UnPreMultiply(); |
| 901 #endif |
| 896 return pBitmap; | 902 return pBitmap; |
| 897 } | 903 } |
| 898 | 904 |
| 899 bool IsAvailableMatrix(const CFX_Matrix& matrix) { | 905 bool IsAvailableMatrix(const CFX_Matrix& matrix) { |
| 900 if (matrix.a == 0 || matrix.d == 0) | 906 if (matrix.a == 0 || matrix.d == 0) |
| 901 return matrix.b != 0 && matrix.c != 0; | 907 return matrix.b != 0 && matrix.c != 0; |
| 902 | 908 |
| 903 if (matrix.b == 0 || matrix.c == 0) | 909 if (matrix.b == 0 || matrix.c == 0) |
| 904 return matrix.a != 0 && matrix.d != 0; | 910 return matrix.a != 0 && matrix.d != 0; |
| 905 | 911 |
| (...skipping 603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { | 1515 if (!isolated && (m_pDevice->GetRenderCaps() & FXRC_GET_BITS)) { |
| 1510 oriDevice.reset(new CFX_DIBitmap); | 1516 oriDevice.reset(new CFX_DIBitmap); |
| 1511 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) | 1517 if (!m_pDevice->CreateCompatibleBitmap(oriDevice.get(), width, height)) |
| 1512 return true; | 1518 return true; |
| 1513 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); | 1519 m_pDevice->GetDIBits(oriDevice.get(), rect.left, rect.top); |
| 1514 } | 1520 } |
| 1515 if (!bitmap_device.Create(width, height, FXDIB_Argb, oriDevice.get())) | 1521 if (!bitmap_device.Create(width, height, FXDIB_Argb, oriDevice.get())) |
| 1516 return true; | 1522 return true; |
| 1517 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); | 1523 CFX_DIBitmap* bitmap = bitmap_device.GetBitmap(); |
| 1518 bitmap->Clear(0); | 1524 bitmap->Clear(0); |
| 1525 #ifdef _SKIA_SUPPORT_PATHS_ |
| 1526 bitmap->SetIsOffscreen(true); |
| 1527 #endif |
| 1519 CFX_Matrix new_matrix = *pObj2Device; | 1528 CFX_Matrix new_matrix = *pObj2Device; |
| 1520 new_matrix.TranslateI(-rect.left, -rect.top); | 1529 new_matrix.TranslateI(-rect.left, -rect.top); |
| 1521 new_matrix.Scale(scaleX, scaleY); | 1530 new_matrix.Scale(scaleX, scaleY); |
| 1522 std::unique_ptr<CFX_DIBitmap> pTextMask; | 1531 std::unique_ptr<CFX_DIBitmap> pTextMask; |
| 1523 if (bTextClip) { | 1532 if (bTextClip) { |
| 1524 pTextMask.reset(new CFX_DIBitmap); | 1533 pTextMask.reset(new CFX_DIBitmap); |
| 1525 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) | 1534 if (!pTextMask->Create(width, height, FXDIB_8bppMask)) |
| 1526 return true; | 1535 return true; |
| 1527 | 1536 |
| 1528 pTextMask->Clear(0); | 1537 pTextMask->Clear(0); |
| (...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2627 } else if (pFunc) { | 2636 } else if (pFunc) { |
| 2628 int size = dest_pitch * height; | 2637 int size = dest_pitch * height; |
| 2629 for (int i = 0; i < size; i++) { | 2638 for (int i = 0; i < size; i++) { |
| 2630 dest_buf[i] = transfers[src_buf[i]]; | 2639 dest_buf[i] = transfers[src_buf[i]]; |
| 2631 } | 2640 } |
| 2632 } else { | 2641 } else { |
| 2633 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); | 2642 FXSYS_memcpy(dest_buf, src_buf, dest_pitch * height); |
| 2634 } | 2643 } |
| 2635 return pMask.release(); | 2644 return pMask.release(); |
| 2636 } | 2645 } |
| OLD | NEW |