| 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/page/cpdf_clippath.h" | 7 #include "core/fpdfapi/page/cpdf_clippath.h" |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 uint32_t CPDF_ClipPath::GetTextCount() const { | 35 uint32_t CPDF_ClipPath::GetTextCount() const { |
| 36 return pdfium::CollectionSize<uint32_t>(m_Ref.GetObject()->m_TextList); | 36 return pdfium::CollectionSize<uint32_t>(m_Ref.GetObject()->m_TextList); |
| 37 } | 37 } |
| 38 | 38 |
| 39 CPDF_TextObject* CPDF_ClipPath::GetText(size_t i) const { | 39 CPDF_TextObject* CPDF_ClipPath::GetText(size_t i) const { |
| 40 return m_Ref.GetObject()->m_TextList[i].get(); | 40 return m_Ref.GetObject()->m_TextList[i].get(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 CFX_FloatRect CPDF_ClipPath::GetClipBox() const { | 43 CFX_FloatRect CPDF_ClipPath::GetClipBox() const { |
| 44 CFX_FloatRect rect; | 44 CFX_FloatRect rect; |
| 45 FX_BOOL bStarted = FALSE; | 45 bool bStarted = false; |
| 46 int count = GetPathCount(); | 46 int count = GetPathCount(); |
| 47 if (count) { | 47 if (count) { |
| 48 rect = GetPath(0).GetBoundingBox(); | 48 rect = GetPath(0).GetBoundingBox(); |
| 49 for (int i = 1; i < count; i++) { | 49 for (int i = 1; i < count; i++) { |
| 50 CFX_FloatRect path_rect = GetPath(i).GetBoundingBox(); | 50 CFX_FloatRect path_rect = GetPath(i).GetBoundingBox(); |
| 51 rect.Intersect(path_rect); | 51 rect.Intersect(path_rect); |
| 52 } | 52 } |
| 53 bStarted = TRUE; | 53 bStarted = true; |
| 54 } | 54 } |
| 55 count = GetTextCount(); | 55 count = GetTextCount(); |
| 56 if (count) { | 56 if (count) { |
| 57 CFX_FloatRect layer_rect; | 57 CFX_FloatRect layer_rect; |
| 58 FX_BOOL bLayerStarted = FALSE; | 58 bool bLayerStarted = false; |
| 59 for (int i = 0; i < count; i++) { | 59 for (int i = 0; i < count; i++) { |
| 60 CPDF_TextObject* pTextObj = GetText(i); | 60 CPDF_TextObject* pTextObj = GetText(i); |
| 61 if (!pTextObj) { | 61 if (!pTextObj) { |
| 62 if (!bStarted) { | 62 if (!bStarted) { |
| 63 rect = layer_rect; | 63 rect = layer_rect; |
| 64 bStarted = TRUE; | 64 bStarted = true; |
| 65 } else { | 65 } else { |
| 66 rect.Intersect(layer_rect); | 66 rect.Intersect(layer_rect); |
| 67 } | 67 } |
| 68 bLayerStarted = FALSE; | 68 bLayerStarted = false; |
| 69 } else { | 69 } else { |
| 70 if (!bLayerStarted) { | 70 if (!bLayerStarted) { |
| 71 layer_rect = CFX_FloatRect(pTextObj->GetBBox(nullptr)); | 71 layer_rect = CFX_FloatRect(pTextObj->GetBBox(nullptr)); |
| 72 bLayerStarted = TRUE; | 72 bLayerStarted = true; |
| 73 } else { | 73 } else { |
| 74 layer_rect.Union(CFX_FloatRect(pTextObj->GetBBox(nullptr))); | 74 layer_rect.Union(CFX_FloatRect(pTextObj->GetBBox(nullptr))); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 return rect; | 79 return rect; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) { | 82 void CPDF_ClipPath::AppendPath(CPDF_Path path, uint8_t type, bool bAutoMerge) { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 m_PathAndTypeList = that.m_PathAndTypeList; | 121 m_PathAndTypeList = that.m_PathAndTypeList; |
| 122 | 122 |
| 123 m_TextList.resize(that.m_TextList.size()); | 123 m_TextList.resize(that.m_TextList.size()); |
| 124 for (size_t i = 0; i < that.m_TextList.size(); ++i) { | 124 for (size_t i = 0; i < that.m_TextList.size(); ++i) { |
| 125 if (that.m_TextList[i]) | 125 if (that.m_TextList[i]) |
| 126 m_TextList[i].reset(that.m_TextList[i]->Clone()); | 126 m_TextList[i].reset(that.m_TextList[i]->Clone()); |
| 127 } | 127 } |
| 128 } | 128 } |
| 129 | 129 |
| 130 CPDF_ClipPath::PathData::~PathData() {} | 130 CPDF_ClipPath::PathData::~PathData() {} |
| OLD | NEW |