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 "core/fxcrt/include/fx_system.h" | 7 #include "core/fxcrt/include/fx_system.h" |
8 #include "core/fxge/include/fx_ge.h" | 8 #include "core/fxge/include/fx_ge.h" |
9 #include "third_party/base/numerics/safe_math.h" | 9 #include "third_party/base/numerics/safe_math.h" |
10 | 10 |
11 CFX_ClipRgn::CFX_ClipRgn(int width, int height) { | 11 CFX_ClipRgn::CFX_ClipRgn(int width, int height) |
12 m_Type = RectI; | 12 : m_Type(RectI), m_Box(0, 0, width, height) {} |
13 m_Box.left = m_Box.top = 0; | 13 |
14 m_Box.right = width; | 14 CFX_ClipRgn::CFX_ClipRgn(const FX_RECT& rect) : m_Type(RectI), m_Box(rect) {} |
15 m_Box.bottom = height; | 15 |
16 } | |
17 CFX_ClipRgn::CFX_ClipRgn(const FX_RECT& rect) { | |
18 m_Type = RectI; | |
19 m_Box = rect; | |
20 } | |
21 CFX_ClipRgn::CFX_ClipRgn(const CFX_ClipRgn& src) { | 16 CFX_ClipRgn::CFX_ClipRgn(const CFX_ClipRgn& src) { |
22 m_Type = src.m_Type; | 17 m_Type = src.m_Type; |
23 m_Box = src.m_Box; | 18 m_Box = src.m_Box; |
24 m_Mask = src.m_Mask; | 19 m_Mask = src.m_Mask; |
25 } | 20 } |
| 21 |
26 CFX_ClipRgn::~CFX_ClipRgn() {} | 22 CFX_ClipRgn::~CFX_ClipRgn() {} |
| 23 |
27 void CFX_ClipRgn::Reset(const FX_RECT& rect) { | 24 void CFX_ClipRgn::Reset(const FX_RECT& rect) { |
28 m_Type = RectI; | 25 m_Type = RectI; |
29 m_Box = rect; | 26 m_Box = rect; |
30 m_Mask.SetNull(); | 27 m_Mask.SetNull(); |
31 } | 28 } |
| 29 |
32 void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) { | 30 void CFX_ClipRgn::IntersectRect(const FX_RECT& rect) { |
33 if (m_Type == RectI) { | 31 if (m_Type == RectI) { |
34 m_Box.Intersect(rect); | 32 m_Box.Intersect(rect); |
35 return; | 33 return; |
36 } | 34 } |
37 if (m_Type == MaskF) { | 35 if (m_Type == MaskF) { |
38 IntersectMaskRect(rect, m_Box, m_Mask); | 36 IntersectMaskRect(rect, m_Box, m_Mask); |
39 return; | 37 return; |
40 } | 38 } |
41 } | 39 } |
| 40 |
42 void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect, | 41 void CFX_ClipRgn::IntersectMaskRect(FX_RECT rect, |
43 FX_RECT mask_rect, | 42 FX_RECT mask_rect, |
44 CFX_DIBitmapRef Mask) { | 43 CFX_DIBitmapRef Mask) { |
45 const CFX_DIBitmap* mask_dib = Mask.GetObject(); | 44 const CFX_DIBitmap* mask_dib = Mask.GetObject(); |
46 m_Type = MaskF; | 45 m_Type = MaskF; |
47 m_Box = rect; | 46 m_Box = rect; |
48 m_Box.Intersect(mask_rect); | 47 m_Box.Intersect(mask_rect); |
49 if (m_Box.IsEmpty()) { | 48 if (m_Box.IsEmpty()) { |
50 m_Type = RectI; | 49 m_Type = RectI; |
51 return; | 50 return; |
(...skipping 10 matching lines...) Expand all Loading... |
62 for (int row = m_Box.top; row < m_Box.bottom; row++) { | 61 for (int row = m_Box.top; row < m_Box.bottom; row++) { |
63 uint8_t* dest_scan = | 62 uint8_t* dest_scan = |
64 new_dib->GetBuffer() + new_dib->GetPitch() * (row - m_Box.top); | 63 new_dib->GetBuffer() + new_dib->GetPitch() * (row - m_Box.top); |
65 uint8_t* src_scan = | 64 uint8_t* src_scan = |
66 mask_dib->GetBuffer() + mask_dib->GetPitch() * (row - mask_rect.top); | 65 mask_dib->GetBuffer() + mask_dib->GetPitch() * (row - mask_rect.top); |
67 for (int col = m_Box.left; col < m_Box.right; col++) { | 66 for (int col = m_Box.left; col < m_Box.right; col++) { |
68 dest_scan[col - m_Box.left] = src_scan[col - mask_rect.left]; | 67 dest_scan[col - m_Box.left] = src_scan[col - mask_rect.left]; |
69 } | 68 } |
70 } | 69 } |
71 } | 70 } |
| 71 |
72 void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) { | 72 void CFX_ClipRgn::IntersectMaskF(int left, int top, CFX_DIBitmapRef Mask) { |
73 const CFX_DIBitmap* mask_dib = Mask.GetObject(); | 73 const CFX_DIBitmap* mask_dib = Mask.GetObject(); |
74 ASSERT(mask_dib->GetFormat() == FXDIB_8bppMask); | 74 ASSERT(mask_dib->GetFormat() == FXDIB_8bppMask); |
75 FX_RECT mask_box(left, top, left + mask_dib->GetWidth(), | 75 FX_RECT mask_box(left, top, left + mask_dib->GetWidth(), |
76 top + mask_dib->GetHeight()); | 76 top + mask_dib->GetHeight()); |
77 if (m_Type == RectI) { | 77 if (m_Type == RectI) { |
78 IntersectMaskRect(m_Box, mask_box, Mask); | 78 IntersectMaskRect(m_Box, mask_box, Mask); |
79 return; | 79 return; |
80 } | 80 } |
81 if (m_Type == MaskF) { | 81 if (m_Type == MaskF) { |
(...skipping 23 matching lines...) Expand all Loading... |
105 new_scan[col - new_box.left] = | 105 new_scan[col - new_box.left] = |
106 old_scan[col - m_Box.left] * mask_scan[col - left] / 255; | 106 old_scan[col - m_Box.left] * mask_scan[col - left] / 255; |
107 } | 107 } |
108 } | 108 } |
109 m_Box = new_box; | 109 m_Box = new_box; |
110 m_Mask = new_mask; | 110 m_Mask = new_mask; |
111 return; | 111 return; |
112 } | 112 } |
113 ASSERT(FALSE); | 113 ASSERT(FALSE); |
114 } | 114 } |
115 CFX_PathData::CFX_PathData() { | 115 |
116 m_PointCount = m_AllocCount = 0; | 116 CFX_PathData::CFX_PathData() |
117 m_pPoints = nullptr; | 117 : m_PointCount(0), m_pPoints(nullptr), m_AllocCount(0) {} |
118 } | 118 |
119 CFX_PathData::~CFX_PathData() { | 119 CFX_PathData::~CFX_PathData() { |
120 FX_Free(m_pPoints); | 120 FX_Free(m_pPoints); |
121 } | 121 } |
| 122 |
122 void CFX_PathData::SetPointCount(int nPoints) { | 123 void CFX_PathData::SetPointCount(int nPoints) { |
123 m_PointCount = nPoints; | 124 m_PointCount = nPoints; |
124 if (m_AllocCount < nPoints) { | 125 if (m_AllocCount < nPoints) { |
125 FX_Free(m_pPoints); | 126 FX_Free(m_pPoints); |
126 m_pPoints = FX_Alloc(FX_PATHPOINT, nPoints); | 127 m_pPoints = FX_Alloc(FX_PATHPOINT, nPoints); |
127 m_AllocCount = nPoints; | 128 m_AllocCount = nPoints; |
128 } | 129 } |
129 } | 130 } |
| 131 |
130 void CFX_PathData::AllocPointCount(int nPoints) { | 132 void CFX_PathData::AllocPointCount(int nPoints) { |
131 if (m_AllocCount < nPoints) { | 133 if (m_AllocCount < nPoints) { |
132 FX_PATHPOINT* pNewBuf = FX_Alloc(FX_PATHPOINT, nPoints); | 134 FX_PATHPOINT* pNewBuf = FX_Alloc(FX_PATHPOINT, nPoints); |
133 if (m_PointCount) { | 135 if (m_PointCount) { |
134 FXSYS_memcpy(pNewBuf, m_pPoints, m_PointCount * sizeof(FX_PATHPOINT)); | 136 FXSYS_memcpy(pNewBuf, m_pPoints, m_PointCount * sizeof(FX_PATHPOINT)); |
135 } | 137 } |
136 FX_Free(m_pPoints); | 138 FX_Free(m_pPoints); |
137 m_pPoints = pNewBuf; | 139 m_pPoints = pNewBuf; |
138 m_AllocCount = nPoints; | 140 m_AllocCount = nPoints; |
139 } | 141 } |
140 } | 142 } |
| 143 |
141 CFX_PathData::CFX_PathData(const CFX_PathData& src) { | 144 CFX_PathData::CFX_PathData(const CFX_PathData& src) { |
142 m_PointCount = m_AllocCount = src.m_PointCount; | 145 m_PointCount = m_AllocCount = src.m_PointCount; |
143 m_pPoints = FX_Alloc(FX_PATHPOINT, src.m_PointCount); | 146 m_pPoints = FX_Alloc(FX_PATHPOINT, src.m_PointCount); |
144 FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount); | 147 FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount); |
145 } | 148 } |
| 149 |
146 void CFX_PathData::TrimPoints(int nPoints) { | 150 void CFX_PathData::TrimPoints(int nPoints) { |
147 if (m_PointCount <= nPoints) { | 151 if (m_PointCount <= nPoints) { |
148 return; | 152 return; |
149 } | 153 } |
150 SetPointCount(nPoints); | 154 SetPointCount(nPoints); |
151 } | 155 } |
| 156 |
152 void CFX_PathData::AddPointCount(int addPoints) { | 157 void CFX_PathData::AddPointCount(int addPoints) { |
153 pdfium::base::CheckedNumeric<int> safe_new_count = m_PointCount; | 158 pdfium::base::CheckedNumeric<int> safe_new_count = m_PointCount; |
154 safe_new_count += addPoints; | 159 safe_new_count += addPoints; |
155 int new_count = safe_new_count.ValueOrDie(); | 160 int new_count = safe_new_count.ValueOrDie(); |
156 AllocPointCount(new_count); | 161 AllocPointCount(new_count); |
157 m_PointCount = new_count; | 162 m_PointCount = new_count; |
158 } | 163 } |
| 164 |
159 void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) { | 165 void CFX_PathData::Append(const CFX_PathData* pSrc, const CFX_Matrix* pMatrix) { |
160 int old_count = m_PointCount; | 166 int old_count = m_PointCount; |
161 AddPointCount(pSrc->m_PointCount); | 167 AddPointCount(pSrc->m_PointCount); |
162 FXSYS_memcpy(m_pPoints + old_count, pSrc->m_pPoints, | 168 FXSYS_memcpy(m_pPoints + old_count, pSrc->m_pPoints, |
163 pSrc->m_PointCount * sizeof(FX_PATHPOINT)); | 169 pSrc->m_PointCount * sizeof(FX_PATHPOINT)); |
164 if (pMatrix) { | 170 if (pMatrix) { |
165 for (int i = 0; i < pSrc->m_PointCount; i++) { | 171 for (int i = 0; i < pSrc->m_PointCount; i++) { |
166 pMatrix->Transform(m_pPoints[old_count + i].m_PointX, | 172 pMatrix->Transform(m_pPoints[old_count + i].m_PointX, |
167 m_pPoints[old_count + i].m_PointY); | 173 m_pPoints[old_count + i].m_PointY); |
168 } | 174 } |
169 } | 175 } |
170 } | 176 } |
| 177 |
171 void CFX_PathData::SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag) { | 178 void CFX_PathData::SetPoint(int index, FX_FLOAT x, FX_FLOAT y, int flag) { |
172 ASSERT(index < m_PointCount); | 179 ASSERT(index < m_PointCount); |
173 m_pPoints[index].m_PointX = x; | 180 m_pPoints[index].m_PointX = x; |
174 m_pPoints[index].m_PointY = y; | 181 m_pPoints[index].m_PointY = y; |
175 m_pPoints[index].m_Flag = flag; | 182 m_pPoints[index].m_Flag = flag; |
176 } | 183 } |
| 184 |
177 void CFX_PathData::AppendRect(FX_FLOAT left, | 185 void CFX_PathData::AppendRect(FX_FLOAT left, |
178 FX_FLOAT bottom, | 186 FX_FLOAT bottom, |
179 FX_FLOAT right, | 187 FX_FLOAT right, |
180 FX_FLOAT top) { | 188 FX_FLOAT top) { |
181 int old_count = m_PointCount; | 189 int old_count = m_PointCount; |
182 AddPointCount(5); | 190 AddPointCount(5); |
183 FX_PATHPOINT* pPoints = m_pPoints + old_count; | 191 FX_PATHPOINT* pPoints = m_pPoints + old_count; |
184 pPoints[0].m_PointX = pPoints[1].m_PointX = pPoints[4].m_PointX = left; | 192 pPoints[0].m_PointX = pPoints[1].m_PointX = pPoints[4].m_PointX = left; |
185 pPoints[2].m_PointX = pPoints[3].m_PointX = right; | 193 pPoints[2].m_PointX = pPoints[3].m_PointX = right; |
186 pPoints[0].m_PointY = pPoints[3].m_PointY = pPoints[4].m_PointY = bottom; | 194 pPoints[0].m_PointY = pPoints[3].m_PointY = pPoints[4].m_PointY = bottom; |
187 pPoints[1].m_PointY = pPoints[2].m_PointY = top; | 195 pPoints[1].m_PointY = pPoints[2].m_PointY = top; |
188 pPoints[0].m_Flag = FXPT_MOVETO; | 196 pPoints[0].m_Flag = FXPT_MOVETO; |
189 pPoints[1].m_Flag = pPoints[2].m_Flag = pPoints[3].m_Flag = FXPT_LINETO; | 197 pPoints[1].m_Flag = pPoints[2].m_Flag = pPoints[3].m_Flag = FXPT_LINETO; |
190 pPoints[4].m_Flag = FXPT_LINETO | FXPT_CLOSEFIGURE; | 198 pPoints[4].m_Flag = FXPT_LINETO | FXPT_CLOSEFIGURE; |
191 } | 199 } |
| 200 |
192 CFX_FloatRect CFX_PathData::GetBoundingBox() const { | 201 CFX_FloatRect CFX_PathData::GetBoundingBox() const { |
193 CFX_FloatRect rect; | 202 CFX_FloatRect rect; |
194 if (m_PointCount) { | 203 if (m_PointCount) { |
195 rect.InitRect(m_pPoints[0].m_PointX, m_pPoints[0].m_PointY); | 204 rect.InitRect(m_pPoints[0].m_PointX, m_pPoints[0].m_PointY); |
196 for (int i = 1; i < m_PointCount; i++) { | 205 for (int i = 1; i < m_PointCount; i++) { |
197 rect.UpdateRect(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY); | 206 rect.UpdateRect(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY); |
198 } | 207 } |
199 } | 208 } |
200 return rect; | 209 return rect; |
201 } | 210 } |
| 211 |
202 static void _UpdateLineEndPoints(CFX_FloatRect& rect, | 212 static void _UpdateLineEndPoints(CFX_FloatRect& rect, |
203 FX_FLOAT start_x, | 213 FX_FLOAT start_x, |
204 FX_FLOAT start_y, | 214 FX_FLOAT start_y, |
205 FX_FLOAT end_x, | 215 FX_FLOAT end_x, |
206 FX_FLOAT end_y, | 216 FX_FLOAT end_y, |
207 FX_FLOAT hw) { | 217 FX_FLOAT hw) { |
208 if (start_x == end_x) { | 218 if (start_x == end_x) { |
209 if (start_y == end_y) { | 219 if (start_y == end_y) { |
210 rect.UpdateRect(end_x + hw, end_y + hw); | 220 rect.UpdateRect(end_x + hw, end_y + hw); |
211 rect.UpdateRect(end_x - hw, end_y - hw); | 221 rect.UpdateRect(end_x - hw, end_y - hw); |
(...skipping 23 matching lines...) Expand all Loading... |
235 FX_FLOAT dx = end_x - start_x; | 245 FX_FLOAT dx = end_x - start_x; |
236 FX_FLOAT dy = end_y - start_y; | 246 FX_FLOAT dy = end_y - start_y; |
237 FX_FLOAT ll = FXSYS_sqrt2(dx, dy); | 247 FX_FLOAT ll = FXSYS_sqrt2(dx, dy); |
238 FX_FLOAT mx = end_x + hw * dx / ll; | 248 FX_FLOAT mx = end_x + hw * dx / ll; |
239 FX_FLOAT my = end_y + hw * dy / ll; | 249 FX_FLOAT my = end_y + hw * dy / ll; |
240 FX_FLOAT dx1 = hw * dy / ll; | 250 FX_FLOAT dx1 = hw * dy / ll; |
241 FX_FLOAT dy1 = hw * dx / ll; | 251 FX_FLOAT dy1 = hw * dx / ll; |
242 rect.UpdateRect(mx - dx1, my + dy1); | 252 rect.UpdateRect(mx - dx1, my + dy1); |
243 rect.UpdateRect(mx + dx1, my - dy1); | 253 rect.UpdateRect(mx + dx1, my - dy1); |
244 } | 254 } |
| 255 |
245 static void _UpdateLineJoinPoints(CFX_FloatRect& rect, | 256 static void _UpdateLineJoinPoints(CFX_FloatRect& rect, |
246 FX_FLOAT start_x, | 257 FX_FLOAT start_x, |
247 FX_FLOAT start_y, | 258 FX_FLOAT start_y, |
248 FX_FLOAT middle_x, | 259 FX_FLOAT middle_x, |
249 FX_FLOAT middle_y, | 260 FX_FLOAT middle_y, |
250 FX_FLOAT end_x, | 261 FX_FLOAT end_x, |
251 FX_FLOAT end_y, | 262 FX_FLOAT end_y, |
252 FX_FLOAT half_width, | 263 FX_FLOAT half_width, |
253 FX_FLOAT miter_limit) { | 264 FX_FLOAT miter_limit) { |
254 FX_FLOAT start_k = 0, start_c = 0, end_k = 0, end_c = 0, start_len = 0, | 265 FX_FLOAT start_k = 0, start_c = 0, end_k = 0, end_c = 0, start_len = 0, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 FX_FLOAT end_outside_c = end_c; | 338 FX_FLOAT end_outside_c = end_c; |
328 if (start_y < (end_k * start_x) + end_c) { | 339 if (start_y < (end_k * start_x) + end_c) { |
329 end_outside_c += end_dc; | 340 end_outside_c += end_dc; |
330 } else { | 341 } else { |
331 end_outside_c -= end_dc; | 342 end_outside_c -= end_dc; |
332 } | 343 } |
333 FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k); | 344 FX_FLOAT join_x = (end_outside_c - start_outside_c) / (start_k - end_k); |
334 FX_FLOAT join_y = (start_k * join_x) + start_outside_c; | 345 FX_FLOAT join_y = (start_k * join_x) + start_outside_c; |
335 rect.UpdateRect(join_x, join_y); | 346 rect.UpdateRect(join_x, join_y); |
336 } | 347 } |
| 348 |
337 CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, | 349 CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, |
338 FX_FLOAT miter_limit) const { | 350 FX_FLOAT miter_limit) const { |
339 CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f, | 351 CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f, |
340 -100000 * 1.0f); | 352 -100000 * 1.0f); |
341 int iPoint = 0; | 353 int iPoint = 0; |
342 FX_FLOAT half_width = line_width; | 354 FX_FLOAT half_width = line_width; |
343 int iStartPoint = 0; | 355 int iStartPoint = 0; |
344 int iEndPoint = 0; | 356 int iEndPoint = 0; |
345 int iMiddlePoint = 0; | 357 int iMiddlePoint = 0; |
346 FX_BOOL bJoin; | 358 FX_BOOL bJoin; |
(...skipping 30 matching lines...) Expand all Loading... |
377 FX_FLOAT middle_y = m_pPoints[iMiddlePoint].m_PointY; | 389 FX_FLOAT middle_y = m_pPoints[iMiddlePoint].m_PointY; |
378 _UpdateLineJoinPoints(rect, start_x, start_y, middle_x, middle_y, end_x, | 390 _UpdateLineJoinPoints(rect, start_x, start_y, middle_x, middle_y, end_x, |
379 end_y, half_width, miter_limit); | 391 end_y, half_width, miter_limit); |
380 } else { | 392 } else { |
381 _UpdateLineEndPoints(rect, start_x, start_y, end_x, end_y, half_width); | 393 _UpdateLineEndPoints(rect, start_x, start_y, end_x, end_y, half_width); |
382 } | 394 } |
383 iPoint++; | 395 iPoint++; |
384 } | 396 } |
385 return rect; | 397 return rect; |
386 } | 398 } |
| 399 |
387 void CFX_PathData::Transform(const CFX_Matrix* pMatrix) { | 400 void CFX_PathData::Transform(const CFX_Matrix* pMatrix) { |
388 if (!pMatrix) { | 401 if (!pMatrix) { |
389 return; | 402 return; |
390 } | 403 } |
391 for (int i = 0; i < m_PointCount; i++) { | 404 for (int i = 0; i < m_PointCount; i++) { |
392 pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY); | 405 pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY); |
393 } | 406 } |
394 } | 407 } |
| 408 |
395 FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, | 409 FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, |
396 CFX_Matrix* pMatrix, | 410 CFX_Matrix* pMatrix, |
397 FX_BOOL& bThin, | 411 FX_BOOL& bThin, |
398 FX_BOOL bAdjust) const { | 412 FX_BOOL bAdjust) const { |
399 if (m_PointCount < 3) { | 413 if (m_PointCount < 3) { |
400 return FALSE; | 414 return FALSE; |
401 } | 415 } |
402 if (m_PointCount == 3 && (m_pPoints[0].m_Flag & FXPT_TYPE) == FXPT_MOVETO && | 416 if (m_PointCount == 3 && (m_pPoints[0].m_Flag & FXPT_TYPE) == FXPT_MOVETO && |
403 (m_pPoints[1].m_Flag & FXPT_TYPE) == FXPT_LINETO && | 417 (m_pPoints[1].m_Flag & FXPT_TYPE) == FXPT_LINETO && |
404 (m_pPoints[2].m_Flag & FXPT_TYPE) == FXPT_LINETO && | 418 (m_pPoints[2].m_Flag & FXPT_TYPE) == FXPT_LINETO && |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 } | 543 } |
530 } | 544 } |
531 if (m_PointCount > 3 && NewPath.GetPointCount()) { | 545 if (m_PointCount > 3 && NewPath.GetPointCount()) { |
532 bThin = TRUE; | 546 bThin = TRUE; |
533 } | 547 } |
534 if (NewPath.GetPointCount() == 0) { | 548 if (NewPath.GetPointCount() == 0) { |
535 return FALSE; | 549 return FALSE; |
536 } | 550 } |
537 return TRUE; | 551 return TRUE; |
538 } | 552 } |
| 553 |
539 FX_BOOL CFX_PathData::IsRect() const { | 554 FX_BOOL CFX_PathData::IsRect() const { |
540 if (m_PointCount != 5 && m_PointCount != 4) { | 555 if (m_PointCount != 5 && m_PointCount != 4) { |
541 return FALSE; | 556 return FALSE; |
542 } | 557 } |
543 if ((m_PointCount == 5 && (m_pPoints[0].m_PointX != m_pPoints[4].m_PointX || | 558 if ((m_PointCount == 5 && (m_pPoints[0].m_PointX != m_pPoints[4].m_PointX || |
544 m_pPoints[0].m_PointY != m_pPoints[4].m_PointY)) || | 559 m_pPoints[0].m_PointY != m_pPoints[4].m_PointY)) || |
545 (m_pPoints[0].m_PointX == m_pPoints[2].m_PointX && | 560 (m_pPoints[0].m_PointX == m_pPoints[2].m_PointX && |
546 m_pPoints[0].m_PointY == m_pPoints[2].m_PointY) || | 561 m_pPoints[0].m_PointY == m_pPoints[2].m_PointY) || |
547 (m_pPoints[1].m_PointX == m_pPoints[3].m_PointX && | 562 (m_pPoints[1].m_PointX == m_pPoints[3].m_PointX && |
548 m_pPoints[1].m_PointY == m_pPoints[3].m_PointY)) { | 563 m_pPoints[1].m_PointY == m_pPoints[3].m_PointY)) { |
549 return FALSE; | 564 return FALSE; |
550 } | 565 } |
551 if (m_pPoints[0].m_PointX != m_pPoints[3].m_PointX && | 566 if (m_pPoints[0].m_PointX != m_pPoints[3].m_PointX && |
552 m_pPoints[0].m_PointY != m_pPoints[3].m_PointY) { | 567 m_pPoints[0].m_PointY != m_pPoints[3].m_PointY) { |
553 return FALSE; | 568 return FALSE; |
554 } | 569 } |
555 for (int i = 1; i < 4; i++) { | 570 for (int i = 1; i < 4; i++) { |
556 if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) { | 571 if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) { |
557 return FALSE; | 572 return FALSE; |
558 } | 573 } |
559 if (m_pPoints[i].m_PointX != m_pPoints[i - 1].m_PointX && | 574 if (m_pPoints[i].m_PointX != m_pPoints[i - 1].m_PointX && |
560 m_pPoints[i].m_PointY != m_pPoints[i - 1].m_PointY) { | 575 m_pPoints[i].m_PointY != m_pPoints[i - 1].m_PointY) { |
561 return FALSE; | 576 return FALSE; |
562 } | 577 } |
563 } | 578 } |
564 return m_PointCount == 5 || (m_pPoints[3].m_Flag & FXPT_CLOSEFIGURE); | 579 return m_PointCount == 5 || (m_pPoints[3].m_Flag & FXPT_CLOSEFIGURE); |
565 } | 580 } |
| 581 |
566 FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix, | 582 FX_BOOL CFX_PathData::IsRect(const CFX_Matrix* pMatrix, |
567 CFX_FloatRect* pRect) const { | 583 CFX_FloatRect* pRect) const { |
568 if (!pMatrix) { | 584 if (!pMatrix) { |
569 if (!IsRect()) { | 585 if (!IsRect()) { |
570 return FALSE; | 586 return FALSE; |
571 } | 587 } |
572 if (pRect) { | 588 if (pRect) { |
573 pRect->left = m_pPoints[0].m_PointX; | 589 pRect->left = m_pPoints[0].m_PointX; |
574 pRect->right = m_pPoints[2].m_PointX; | 590 pRect->right = m_pPoints[2].m_PointX; |
575 pRect->bottom = m_pPoints[0].m_PointY; | 591 pRect->bottom = m_pPoints[0].m_PointY; |
(...skipping 30 matching lines...) Expand all Loading... |
606 } | 622 } |
607 if (pRect) { | 623 if (pRect) { |
608 pRect->left = x[0]; | 624 pRect->left = x[0]; |
609 pRect->right = x[2]; | 625 pRect->right = x[2]; |
610 pRect->bottom = y[0]; | 626 pRect->bottom = y[0]; |
611 pRect->top = y[2]; | 627 pRect->top = y[2]; |
612 pRect->Normalize(); | 628 pRect->Normalize(); |
613 } | 629 } |
614 return TRUE; | 630 return TRUE; |
615 } | 631 } |
| 632 |
616 void CFX_PathData::Copy(const CFX_PathData& src) { | 633 void CFX_PathData::Copy(const CFX_PathData& src) { |
617 SetPointCount(src.m_PointCount); | 634 SetPointCount(src.m_PointCount); |
618 FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount); | 635 FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount); |
619 } | 636 } |
620 CFX_GraphStateData::CFX_GraphStateData() { | 637 |
621 m_LineCap = LineCapButt; | 638 CFX_GraphStateData::CFX_GraphStateData() |
622 m_DashCount = 0; | 639 : m_LineCap(LineCapButt), |
623 m_DashArray = nullptr; | 640 m_DashCount(0), |
624 m_DashPhase = 0; | 641 m_DashArray(nullptr), |
625 m_LineJoin = LineJoinMiter; | 642 m_DashPhase(0), |
626 m_MiterLimit = 10 * 1.0f; | 643 m_LineJoin(LineJoinMiter), |
627 m_LineWidth = 1.0f; | 644 m_MiterLimit(10 * 1.0f), |
628 } | 645 m_LineWidth(1.0f) {} |
| 646 |
629 CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) { | 647 CFX_GraphStateData::CFX_GraphStateData(const CFX_GraphStateData& src) { |
630 m_DashArray = nullptr; | 648 m_DashArray = nullptr; |
631 Copy(src); | 649 Copy(src); |
632 } | 650 } |
| 651 |
633 void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { | 652 void CFX_GraphStateData::Copy(const CFX_GraphStateData& src) { |
634 m_LineCap = src.m_LineCap; | 653 m_LineCap = src.m_LineCap; |
635 m_DashCount = src.m_DashCount; | 654 m_DashCount = src.m_DashCount; |
636 FX_Free(m_DashArray); | 655 FX_Free(m_DashArray); |
637 m_DashArray = nullptr; | 656 m_DashArray = nullptr; |
638 m_DashPhase = src.m_DashPhase; | 657 m_DashPhase = src.m_DashPhase; |
639 m_LineJoin = src.m_LineJoin; | 658 m_LineJoin = src.m_LineJoin; |
640 m_MiterLimit = src.m_MiterLimit; | 659 m_MiterLimit = src.m_MiterLimit; |
641 m_LineWidth = src.m_LineWidth; | 660 m_LineWidth = src.m_LineWidth; |
642 if (m_DashCount) { | 661 if (m_DashCount) { |
643 m_DashArray = FX_Alloc(FX_FLOAT, m_DashCount); | 662 m_DashArray = FX_Alloc(FX_FLOAT, m_DashCount); |
644 FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT)); | 663 FXSYS_memcpy(m_DashArray, src.m_DashArray, m_DashCount * sizeof(FX_FLOAT)); |
645 } | 664 } |
646 } | 665 } |
| 666 |
647 CFX_GraphStateData::~CFX_GraphStateData() { | 667 CFX_GraphStateData::~CFX_GraphStateData() { |
648 FX_Free(m_DashArray); | 668 FX_Free(m_DashArray); |
649 } | 669 } |
| 670 |
650 void CFX_GraphStateData::SetDashCount(int count) { | 671 void CFX_GraphStateData::SetDashCount(int count) { |
651 FX_Free(m_DashArray); | 672 FX_Free(m_DashArray); |
652 m_DashArray = nullptr; | 673 m_DashArray = nullptr; |
653 m_DashCount = count; | 674 m_DashCount = count; |
654 if (count == 0) { | 675 if (count == 0) { |
655 return; | 676 return; |
656 } | 677 } |
657 m_DashArray = FX_Alloc(FX_FLOAT, count); | 678 m_DashArray = FX_Alloc(FX_FLOAT, count); |
658 } | 679 } |
OLD | NEW |