| 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/fxge/ge/cfx_cliprgn.h" | 7 #include "core/fxge/ge/cfx_cliprgn.h" |
| 8 | 8 |
| 9 CFX_ClipRgn::CFX_ClipRgn(int width, int height) | 9 CFX_ClipRgn::CFX_ClipRgn(int width, int height) |
| 10 : m_Type(RectI), m_Box(0, 0, width, height) {} | 10 : m_Type(RectI), m_Box(0, 0, width, height) {} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 m_Box = rect; | 42 m_Box = rect; |
| 43 m_Box.Intersect(mask_rect); | 43 m_Box.Intersect(mask_rect); |
| 44 if (m_Box.IsEmpty()) { | 44 if (m_Box.IsEmpty()) { |
| 45 m_Type = RectI; | 45 m_Type = RectI; |
| 46 return; | 46 return; |
| 47 } | 47 } |
| 48 if (m_Box == mask_rect) { | 48 if (m_Box == mask_rect) { |
| 49 m_Mask = Mask; | 49 m_Mask = Mask; |
| 50 return; | 50 return; |
| 51 } | 51 } |
| 52 CFX_DIBitmap* new_dib = m_Mask.New(); | 52 CFX_DIBitmap* new_dib = m_Mask.Emplace(); |
| 53 if (!new_dib) | |
| 54 return; | |
| 55 new_dib->Create(m_Box.Width(), m_Box.Height(), FXDIB_8bppMask); | 53 new_dib->Create(m_Box.Width(), m_Box.Height(), FXDIB_8bppMask); |
| 56 for (int row = m_Box.top; row < m_Box.bottom; row++) { | 54 for (int row = m_Box.top; row < m_Box.bottom; row++) { |
| 57 uint8_t* dest_scan = | 55 uint8_t* dest_scan = |
| 58 new_dib->GetBuffer() + new_dib->GetPitch() * (row - m_Box.top); | 56 new_dib->GetBuffer() + new_dib->GetPitch() * (row - m_Box.top); |
| 59 uint8_t* src_scan = | 57 uint8_t* src_scan = |
| 60 mask_dib->GetBuffer() + mask_dib->GetPitch() * (row - mask_rect.top); | 58 mask_dib->GetBuffer() + mask_dib->GetPitch() * (row - mask_rect.top); |
| 61 for (int col = m_Box.left; col < m_Box.right; col++) | 59 for (int col = m_Box.left; col < m_Box.right; col++) |
| 62 dest_scan[col - m_Box.left] = src_scan[col - mask_rect.left]; | 60 dest_scan[col - m_Box.left] = src_scan[col - mask_rect.left]; |
| 63 } | 61 } |
| 64 } | 62 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 75 if (m_Type == MaskF) { | 73 if (m_Type == MaskF) { |
| 76 FX_RECT new_box = m_Box; | 74 FX_RECT new_box = m_Box; |
| 77 new_box.Intersect(mask_box); | 75 new_box.Intersect(mask_box); |
| 78 if (new_box.IsEmpty()) { | 76 if (new_box.IsEmpty()) { |
| 79 m_Type = RectI; | 77 m_Type = RectI; |
| 80 m_Mask.SetNull(); | 78 m_Mask.SetNull(); |
| 81 m_Box = new_box; | 79 m_Box = new_box; |
| 82 return; | 80 return; |
| 83 } | 81 } |
| 84 CFX_DIBitmapRef new_mask; | 82 CFX_DIBitmapRef new_mask; |
| 85 CFX_DIBitmap* new_dib = new_mask.New(); | 83 CFX_DIBitmap* new_dib = new_mask.Emplace(); |
| 86 if (!new_dib) | |
| 87 return; | |
| 88 new_dib->Create(new_box.Width(), new_box.Height(), FXDIB_8bppMask); | 84 new_dib->Create(new_box.Width(), new_box.Height(), FXDIB_8bppMask); |
| 89 const CFX_DIBitmap* old_dib = m_Mask.GetObject(); | 85 const CFX_DIBitmap* old_dib = m_Mask.GetObject(); |
| 90 for (int row = new_box.top; row < new_box.bottom; row++) { | 86 for (int row = new_box.top; row < new_box.bottom; row++) { |
| 91 uint8_t* old_scan = | 87 uint8_t* old_scan = |
| 92 old_dib->GetBuffer() + (row - m_Box.top) * old_dib->GetPitch(); | 88 old_dib->GetBuffer() + (row - m_Box.top) * old_dib->GetPitch(); |
| 93 uint8_t* mask_scan = | 89 uint8_t* mask_scan = |
| 94 mask_dib->GetBuffer() + (row - top) * mask_dib->GetPitch(); | 90 mask_dib->GetBuffer() + (row - top) * mask_dib->GetPitch(); |
| 95 uint8_t* new_scan = | 91 uint8_t* new_scan = |
| 96 new_dib->GetBuffer() + (row - new_box.top) * new_dib->GetPitch(); | 92 new_dib->GetBuffer() + (row - new_box.top) * new_dib->GetPitch(); |
| 97 for (int col = new_box.left; col < new_box.right; col++) { | 93 for (int col = new_box.left; col < new_box.right; col++) { |
| 98 new_scan[col - new_box.left] = | 94 new_scan[col - new_box.left] = |
| 99 old_scan[col - m_Box.left] * mask_scan[col - left] / 255; | 95 old_scan[col - m_Box.left] * mask_scan[col - left] / 255; |
| 100 } | 96 } |
| 101 } | 97 } |
| 102 m_Box = new_box; | 98 m_Box = new_box; |
| 103 m_Mask = new_mask; | 99 m_Mask = new_mask; |
| 104 return; | 100 return; |
| 105 } | 101 } |
| 106 ASSERT(FALSE); | 102 ASSERT(FALSE); |
| 107 } | 103 } |
| OLD | NEW |