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 "../../../../third_party/base/numerics/safe_math.h" | 7 #include "../../../../third_party/base/numerics/safe_math.h" |
8 #include "../../../include/fxcrt/fx_basic.h" | 8 #include "../../../include/fxcrt/fx_basic.h" |
9 #include "../../../include/fxge/fx_ge.h" | 9 #include "../../../include/fxge/fx_ge.h" |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 } else if (m_Box == mask_rect) { | 58 } else if (m_Box == mask_rect) { |
59 m_Mask = Mask; | 59 m_Mask = Mask; |
60 return; | 60 return; |
61 } | 61 } |
62 CFX_DIBitmap* new_dib = m_Mask.New(); | 62 CFX_DIBitmap* new_dib = m_Mask.New(); |
63 if (!new_dib) { | 63 if (!new_dib) { |
64 return; | 64 return; |
65 } | 65 } |
66 new_dib->Create(m_Box.Width(), m_Box.Height(), FXDIB_8bppMask); | 66 new_dib->Create(m_Box.Width(), m_Box.Height(), FXDIB_8bppMask); |
67 for (int row = m_Box.top; row < m_Box.bottom; row ++) { | 67 for (int row = m_Box.top; row < m_Box.bottom; row ++) { |
68 FX_LPBYTE dest_scan = new_dib->GetBuffer() + new_dib->GetPitch() * (row
- m_Box.top); | 68 uint8_t* dest_scan = new_dib->GetBuffer() + new_dib->GetPitch() * (row -
m_Box.top); |
69 FX_LPBYTE src_scan = mask_dib->GetBuffer() + mask_dib->GetPitch() * (row
- mask_rect.top); | 69 uint8_t* src_scan = mask_dib->GetBuffer() + mask_dib->GetPitch() * (row
- mask_rect.top); |
70 for (int col = m_Box.left; col < m_Box.right; col ++) { | 70 for (int col = m_Box.left; col < m_Box.right; col ++) { |
71 dest_scan[col - m_Box.left] = src_scan[col - mask_rect.left]; | 71 dest_scan[col - m_Box.left] = src_scan[col - mask_rect.left]; |
72 } | 72 } |
73 } | 73 } |
74 } | 74 } |
75 void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) | 75 void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) |
76 { | 76 { |
77 const CFX_DIBitmap* mask_dib = Mask; | 77 const CFX_DIBitmap* mask_dib = Mask; |
78 ASSERT(mask_dib->GetFormat() == FXDIB_8bppMask); | 78 ASSERT(mask_dib->GetFormat() == FXDIB_8bppMask); |
79 FX_RECT mask_box(left, top, left + mask_dib->GetWidth(), top + mask_dib->Get
Height()); | 79 FX_RECT mask_box(left, top, left + mask_dib->GetWidth(), top + mask_dib->Get
Height()); |
(...skipping 11 matching lines...) Expand all Loading... |
91 return; | 91 return; |
92 } | 92 } |
93 CFX_DIBitmapRef new_mask; | 93 CFX_DIBitmapRef new_mask; |
94 CFX_DIBitmap* new_dib = new_mask.New(); | 94 CFX_DIBitmap* new_dib = new_mask.New(); |
95 if (!new_dib) { | 95 if (!new_dib) { |
96 return; | 96 return; |
97 } | 97 } |
98 new_dib->Create(new_box.Width(), new_box.Height(), FXDIB_8bppMask); | 98 new_dib->Create(new_box.Width(), new_box.Height(), FXDIB_8bppMask); |
99 const CFX_DIBitmap* old_dib = m_Mask; | 99 const CFX_DIBitmap* old_dib = m_Mask; |
100 for (int row = new_box.top; row < new_box.bottom; row ++) { | 100 for (int row = new_box.top; row < new_box.bottom; row ++) { |
101 FX_LPBYTE old_scan = old_dib->GetBuffer() + (row - m_Box.top) * old_
dib->GetPitch(); | 101 uint8_t* old_scan = old_dib->GetBuffer() + (row - m_Box.top) * old_d
ib->GetPitch(); |
102 FX_LPBYTE mask_scan = mask_dib->GetBuffer() + (row - top) * mask_dib
->GetPitch(); | 102 uint8_t* mask_scan = mask_dib->GetBuffer() + (row - top) * mask_dib-
>GetPitch(); |
103 FX_LPBYTE new_scan = new_dib->GetBuffer() + (row - new_box.top) * ne
w_dib->GetPitch(); | 103 uint8_t* new_scan = new_dib->GetBuffer() + (row - new_box.top) * new
_dib->GetPitch(); |
104 for (int col = new_box.left; col < new_box.right; col ++) { | 104 for (int col = new_box.left; col < new_box.right; col ++) { |
105 new_scan[col - new_box.left] = old_scan[col - m_Box.left] * mask
_scan[col - left] / 255; | 105 new_scan[col - new_box.left] = old_scan[col - m_Box.left] * mask
_scan[col - left] / 255; |
106 } | 106 } |
107 } | 107 } |
108 m_Box = new_box; | 108 m_Box = new_box; |
109 m_Mask = new_mask; | 109 m_Mask = new_mask; |
110 return; | 110 return; |
111 } | 111 } |
112 ASSERT(FALSE); | 112 ASSERT(FALSE); |
113 } | 113 } |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 if (m_DashArray) { | 620 if (m_DashArray) { |
621 FX_Free(m_DashArray); | 621 FX_Free(m_DashArray); |
622 } | 622 } |
623 m_DashArray = NULL; | 623 m_DashArray = NULL; |
624 m_DashCount = count; | 624 m_DashCount = count; |
625 if (count == 0) { | 625 if (count == 0) { |
626 return; | 626 return; |
627 } | 627 } |
628 m_DashArray = FX_Alloc(FX_FLOAT, count); | 628 m_DashArray = FX_Alloc(FX_FLOAT, count); |
629 } | 629 } |
OLD | NEW |