Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(404)

Side by Side Diff: core/src/fxge/ge/fx_ge_path.cpp

Issue 1258093002: FX Bool considered harmful, part 3 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxge/ge/fx_ge_linux.cpp ('k') | core/src/fxge/ge/fx_ge_ps.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_system.h" 8 #include "../../../include/fxcrt/fx_system.h"
9 #include "../../../include/fxge/fx_ge.h" 9 #include "../../../include/fxge/fx_ge.h"
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 uint8_t* mask_scan = mask_dib->GetBuffer() + (row - top) * mask_dib- >GetPitch(); 103 uint8_t* mask_scan = mask_dib->GetBuffer() + (row - top) * mask_dib- >GetPitch();
104 uint8_t* new_scan = new_dib->GetBuffer() + (row - new_box.top) * new _dib->GetPitch(); 104 uint8_t* new_scan = new_dib->GetBuffer() + (row - new_box.top) * new _dib->GetPitch();
105 for (int col = new_box.left; col < new_box.right; col ++) { 105 for (int col = new_box.left; col < new_box.right; col ++) {
106 new_scan[col - new_box.left] = old_scan[col - m_Box.left] * mask _scan[col - left] / 255; 106 new_scan[col - new_box.left] = 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 CFX_PathData::CFX_PathData()
116 { 116 {
117 m_PointCount = m_AllocCount = 0; 117 m_PointCount = m_AllocCount = 0;
118 m_pPoints = NULL; 118 m_pPoints = NULL;
119 } 119 }
120 CFX_PathData::~CFX_PathData() 120 CFX_PathData::~CFX_PathData()
121 { 121 {
122 if (m_pPoints) { 122 if (m_pPoints) {
123 FX_Free(m_pPoints); 123 FX_Free(m_pPoints);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 FX_FLOAT dx1 = hw * dy / ll; 250 FX_FLOAT dx1 = hw * dy / ll;
251 FX_FLOAT dy1 = hw * dx / ll; 251 FX_FLOAT dy1 = hw * dx / ll;
252 rect.UpdateRect(mx - dx1, my + dy1); 252 rect.UpdateRect(mx - dx1, my + dy1);
253 rect.UpdateRect(mx + dx1, my - dy1); 253 rect.UpdateRect(mx + dx1, my - dy1);
254 } 254 }
255 static void _UpdateLineJoinPoints(CFX_FloatRect& rect, FX_FLOAT start_x, FX_FLOA T start_y, 255 static void _UpdateLineJoinPoints(CFX_FloatRect& rect, FX_FLOAT start_x, FX_FLOA T start_y,
256 FX_FLOAT middle_x, FX_FLOAT middle_y, FX_FLOAT end_x, FX_FLOAT end_y, 256 FX_FLOAT middle_x, FX_FLOAT middle_y, FX_FLOAT end_x, FX_FLOAT end_y,
257 FX_FLOAT half_width, FX_FLOAT miter_limit) 257 FX_FLOAT half_width, FX_FLOAT miter_limit)
258 { 258 {
259 FX_FLOAT start_k = 0, start_c = 0, end_k = 0, end_c = 0, start_len = 0, star t_dc = 0, end_len = 0, end_dc = 0; 259 FX_FLOAT start_k = 0, start_c = 0, end_k = 0, end_c = 0, start_len = 0, star t_dc = 0, end_len = 0, end_dc = 0;
260 FX_BOOL bStartVert = FXSYS_fabs(start_x - middle_x) < 1.0f / 20; 260 bool bStartVert = FXSYS_fabs(start_x - middle_x) < 1.0f / 20;
261 FX_BOOL bEndVert = FXSYS_fabs(middle_x - end_x) < 1.0f / 20; 261 bool bEndVert = FXSYS_fabs(middle_x - end_x) < 1.0f / 20;
262 if (bStartVert && bEndVert) { 262 if (bStartVert && bEndVert) {
263 int start_dir = middle_y > start_y ? 1 : -1; 263 int start_dir = middle_y > start_y ? 1 : -1;
264 FX_FLOAT point_y = middle_y + half_width * start_dir; 264 FX_FLOAT point_y = middle_y + half_width * start_dir;
265 rect.UpdateRect(middle_x + half_width, point_y); 265 rect.UpdateRect(middle_x + half_width, point_y);
266 rect.UpdateRect(middle_x - half_width, point_y); 266 rect.UpdateRect(middle_x - half_width, point_y);
267 return; 267 return;
268 } 268 }
269 if (!bStartVert) { 269 if (!bStartVert) {
270 start_k = FXSYS_Div(middle_y - start_y, middle_x - start_x); 270 start_k = FXSYS_Div(middle_y - start_y, middle_x - start_x);
271 start_c = middle_y - FXSYS_Mul(start_k, middle_x); 271 start_c = middle_y - FXSYS_Mul(start_k, middle_x);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 FX_FLOAT join_x = FXSYS_Div(end_outside_c - start_outside_c, start_k - end_k ); 335 FX_FLOAT join_x = FXSYS_Div(end_outside_c - start_outside_c, start_k - end_k );
336 FX_FLOAT join_y = FXSYS_Mul(start_k, join_x) + start_outside_c; 336 FX_FLOAT join_y = FXSYS_Mul(start_k, join_x) + start_outside_c;
337 rect.UpdateRect(join_x, join_y); 337 rect.UpdateRect(join_x, join_y);
338 } 338 }
339 CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_l imit) const 339 CFX_FloatRect CFX_PathData::GetBoundingBox(FX_FLOAT line_width, FX_FLOAT miter_l imit) const
340 { 340 {
341 CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f, -100000 * 1 .0f); 341 CFX_FloatRect rect(100000 * 1.0f, 100000 * 1.0f, -100000 * 1.0f, -100000 * 1 .0f);
342 int iPoint = 0; 342 int iPoint = 0;
343 FX_FLOAT half_width = line_width; 343 FX_FLOAT half_width = line_width;
344 int iStartPoint, iEndPoint, iMiddlePoint; 344 int iStartPoint, iEndPoint, iMiddlePoint;
345 FX_BOOL bJoin; 345 bool bJoin;
346 while (iPoint < m_PointCount) { 346 while (iPoint < m_PointCount) {
347 if (m_pPoints[iPoint].m_Flag == FXPT_MOVETO) { 347 if (m_pPoints[iPoint].m_Flag == FXPT_MOVETO) {
348 iStartPoint = iPoint + 1; 348 iStartPoint = iPoint + 1;
349 iEndPoint = iPoint; 349 iEndPoint = iPoint;
350 bJoin = FALSE; 350 bJoin = false;
351 } else { 351 } else {
352 if (m_pPoints[iPoint].m_Flag == FXPT_BEZIERTO) { 352 if (m_pPoints[iPoint].m_Flag == FXPT_BEZIERTO) {
353 rect.UpdateRect(m_pPoints[iPoint].m_PointX, m_pPoints[iPoint].m_ PointY); 353 rect.UpdateRect(m_pPoints[iPoint].m_PointX, m_pPoints[iPoint].m_ PointY);
354 rect.UpdateRect(m_pPoints[iPoint + 1].m_PointX, m_pPoints[iPoint + 1].m_PointY); 354 rect.UpdateRect(m_pPoints[iPoint + 1].m_PointX, m_pPoints[iPoint + 1].m_PointY);
355 iPoint += 2; 355 iPoint += 2;
356 } 356 }
357 if (iPoint == m_PointCount - 1 || m_pPoints[iPoint + 1].m_Flag == FX PT_MOVETO) { 357 if (iPoint == m_PointCount - 1 || m_pPoints[iPoint + 1].m_Flag == FX PT_MOVETO) {
358 iStartPoint = iPoint - 1; 358 iStartPoint = iPoint - 1;
359 iEndPoint = iPoint; 359 iEndPoint = iPoint;
360 bJoin = FALSE; 360 bJoin = false;
361 } else { 361 } else {
362 iStartPoint = iPoint - 1; 362 iStartPoint = iPoint - 1;
363 iMiddlePoint = iPoint; 363 iMiddlePoint = iPoint;
364 iEndPoint = iPoint + 1; 364 iEndPoint = iPoint + 1;
365 bJoin = TRUE; 365 bJoin = true;
366 } 366 }
367 } 367 }
368 FX_FLOAT start_x = m_pPoints[iStartPoint].m_PointX; 368 FX_FLOAT start_x = m_pPoints[iStartPoint].m_PointX;
369 FX_FLOAT start_y = m_pPoints[iStartPoint].m_PointY; 369 FX_FLOAT start_y = m_pPoints[iStartPoint].m_PointY;
370 FX_FLOAT end_x = m_pPoints[iEndPoint].m_PointX; 370 FX_FLOAT end_x = m_pPoints[iEndPoint].m_PointX;
371 FX_FLOAT end_y = m_pPoints[iEndPoint].m_PointY; 371 FX_FLOAT end_y = m_pPoints[iEndPoint].m_PointY;
372 if (bJoin) { 372 if (bJoin) {
373 FX_FLOAT middle_x = m_pPoints[iMiddlePoint].m_PointX; 373 FX_FLOAT middle_x = m_pPoints[iMiddlePoint].m_PointX;
374 FX_FLOAT middle_y = m_pPoints[iMiddlePoint].m_PointY; 374 FX_FLOAT middle_y = m_pPoints[iMiddlePoint].m_PointY;
375 _UpdateLineJoinPoints(rect, start_x, start_y, middle_x, middle_y, en d_x, end_y, half_width, miter_limit); 375 _UpdateLineJoinPoints(rect, start_x, start_y, middle_x, middle_y, en d_x, end_y, half_width, miter_limit);
376 } else { 376 } else {
377 _UpdateLineEndPoints(rect, start_x, start_y, end_x, end_y, half_widt h); 377 _UpdateLineEndPoints(rect, start_x, start_y, end_x, end_y, half_widt h);
378 } 378 }
379 iPoint ++; 379 iPoint ++;
380 } 380 }
381 return rect; 381 return rect;
382 } 382 }
383 void CFX_PathData::Transform(const CFX_AffineMatrix* pMatrix) 383 void CFX_PathData::Transform(const CFX_AffineMatrix* pMatrix)
384 { 384 {
385 if (pMatrix == NULL) { 385 if (pMatrix == NULL) {
386 return; 386 return;
387 } 387 }
388 for (int i = 0; i < m_PointCount; i ++) { 388 for (int i = 0; i < m_PointCount; i ++) {
389 pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY); 389 pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY);
390 } 390 }
391 } 391 }
392 FX_BOOL CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, CFX_AffineMatrix* p Matrix, FX_BOOL&bThin, FX_BOOL bAdjust) const 392 bool CFX_PathData::GetZeroAreaPath(CFX_PathData& NewPath, CFX_AffineMatrix* pMat rix, bool&bThin, bool bAdjust) const
393 { 393 {
394 if (m_PointCount < 3) { 394 if (m_PointCount < 3) {
395 return FALSE; 395 return false;
396 } 396 }
397 if (m_PointCount == 3 && (m_pPoints[0].m_Flag & FXPT_TYPE) == FXPT_MOVETO && 397 if (m_PointCount == 3 && (m_pPoints[0].m_Flag & FXPT_TYPE) == FXPT_MOVETO &&
398 (m_pPoints[1].m_Flag & FXPT_TYPE) == FXPT_LINETO && (m_pPoints[2].m_ Flag & FXPT_TYPE) == FXPT_LINETO 398 (m_pPoints[1].m_Flag & FXPT_TYPE) == FXPT_LINETO && (m_pPoints[2].m_ Flag & FXPT_TYPE) == FXPT_LINETO
399 && m_pPoints[0].m_PointX == m_pPoints[2].m_PointX && m_pPoints[0].m_ PointY == m_pPoints[2].m_PointY) { 399 && m_pPoints[0].m_PointX == m_pPoints[2].m_PointX && m_pPoints[0].m_ PointY == m_pPoints[2].m_PointY) {
400 NewPath.AddPointCount(2); 400 NewPath.AddPointCount(2);
401 if (bAdjust) { 401 if (bAdjust) {
402 if (pMatrix) { 402 if (pMatrix) {
403 FX_FLOAT x = m_pPoints[0].m_PointX, y = m_pPoints[0].m_PointY; 403 FX_FLOAT x = m_pPoints[0].m_PointX, y = m_pPoints[0].m_PointY;
404 pMatrix->TransformPoint(x, y); 404 pMatrix->TransformPoint(x, y);
405 x = (int)x + 0.5f; 405 x = (int)x + 0.5f;
406 y = (int)y + 0.5f; 406 y = (int)y + 0.5f;
407 NewPath.SetPoint(0, x, y, FXPT_MOVETO); 407 NewPath.SetPoint(0, x, y, FXPT_MOVETO);
408 x = m_pPoints[1].m_PointX, y = m_pPoints[1].m_PointY; 408 x = m_pPoints[1].m_PointX, y = m_pPoints[1].m_PointY;
409 pMatrix->TransformPoint(x, y); 409 pMatrix->TransformPoint(x, y);
410 x = (int)x + 0.5f; 410 x = (int)x + 0.5f;
411 y = (int)y + 0.5f; 411 y = (int)y + 0.5f;
412 NewPath.SetPoint(1, x, y, FXPT_LINETO); 412 NewPath.SetPoint(1, x, y, FXPT_LINETO);
413 pMatrix->SetIdentity(); 413 pMatrix->SetIdentity();
414 } else { 414 } else {
415 FX_FLOAT x = (int)m_pPoints[0].m_PointX + 0.5f, y = (int)m_pPoin ts[0].m_PointY + 0.5f; 415 FX_FLOAT x = (int)m_pPoints[0].m_PointX + 0.5f, y = (int)m_pPoin ts[0].m_PointY + 0.5f;
416 NewPath.SetPoint(0, x, y, FXPT_MOVETO); 416 NewPath.SetPoint(0, x, y, FXPT_MOVETO);
417 x = (int)m_pPoints[1].m_PointX + 0.5f, y = (int)m_pPoints[1].m_P ointY + 0.5f; 417 x = (int)m_pPoints[1].m_PointX + 0.5f, y = (int)m_pPoints[1].m_P ointY + 0.5f;
418 NewPath.SetPoint(1, x, y, FXPT_LINETO); 418 NewPath.SetPoint(1, x, y, FXPT_LINETO);
419 } 419 }
420 } else { 420 } else {
421 NewPath.SetPoint(0, m_pPoints[0].m_PointX, m_pPoints[0].m_PointY, FX PT_MOVETO); 421 NewPath.SetPoint(0, m_pPoints[0].m_PointX, m_pPoints[0].m_PointY, FX PT_MOVETO);
422 NewPath.SetPoint(1, m_pPoints[1].m_PointX, m_pPoints[1].m_PointY, FX PT_LINETO); 422 NewPath.SetPoint(1, m_pPoints[1].m_PointX, m_pPoints[1].m_PointY, FX PT_LINETO);
423 } 423 }
424 if (m_pPoints[0].m_PointX != m_pPoints[1].m_PointX && m_pPoints[0].m_Poi ntY != m_pPoints[1].m_PointY) { 424 if (m_pPoints[0].m_PointX != m_pPoints[1].m_PointX && m_pPoints[0].m_Poi ntY != m_pPoints[1].m_PointY) {
425 bThin = TRUE; 425 bThin = true;
426 } 426 }
427 return TRUE; 427 return true;
428 } 428 }
429 if (((m_PointCount > 3) && (m_PointCount % 2))) { 429 if (((m_PointCount > 3) && (m_PointCount % 2))) {
430 int mid = m_PointCount / 2; 430 int mid = m_PointCount / 2;
431 FX_BOOL bZeroArea = FALSE; 431 bool bZeroArea = false;
432 CFX_PathData t_path; 432 CFX_PathData t_path;
433 for (int i = 0; i < mid; i++) { 433 for (int i = 0; i < mid; i++) {
434 if (!(m_pPoints[mid - i - 1].m_PointX == m_pPoints[mid + i + 1].m_Po intX 434 if (!(m_pPoints[mid - i - 1].m_PointX == m_pPoints[mid + i + 1].m_Po intX
435 && m_pPoints[mid - i - 1].m_PointY == m_pPoints[mid + i + 1] .m_PointY && 435 && m_pPoints[mid - i - 1].m_PointY == m_pPoints[mid + i + 1] .m_PointY &&
436 ((m_pPoints[mid - i - 1].m_Flag & FXPT_TYPE) != FXPT_BEZIERT O && (m_pPoints[mid + i + 1].m_Flag & FXPT_TYPE) != FXPT_BEZIERTO))) { 436 ((m_pPoints[mid - i - 1].m_Flag & FXPT_TYPE) != FXPT_BEZIERT O && (m_pPoints[mid + i + 1].m_Flag & FXPT_TYPE) != FXPT_BEZIERTO))) {
437 bZeroArea = TRUE; 437 bZeroArea = true;
438 break; 438 break;
439 } 439 }
440 int new_count = t_path.GetPointCount(); 440 int new_count = t_path.GetPointCount();
441 t_path.AddPointCount(2); 441 t_path.AddPointCount(2);
442 t_path.SetPoint(new_count, m_pPoints[mid - i].m_PointX, m_pPoints[mi d - i].m_PointY, FXPT_MOVETO); 442 t_path.SetPoint(new_count, m_pPoints[mid - i].m_PointX, m_pPoints[mi d - i].m_PointY, FXPT_MOVETO);
443 t_path.SetPoint(new_count + 1, m_pPoints[mid - i - 1].m_PointX, m_pP oints[mid - i - 1].m_PointY, FXPT_LINETO); 443 t_path.SetPoint(new_count + 1, m_pPoints[mid - i - 1].m_PointX, m_pP oints[mid - i - 1].m_PointY, FXPT_LINETO);
444 } 444 }
445 if (!bZeroArea) { 445 if (!bZeroArea) {
446 NewPath.Append(&t_path, NULL); 446 NewPath.Append(&t_path, NULL);
447 bThin = TRUE; 447 bThin = true;
448 return TRUE; 448 return true;
449 } 449 }
450 } 450 }
451 int stratPoint = 0; 451 int stratPoint = 0;
452 int next = 0, i; 452 int next = 0, i;
453 for (i = 0; i < m_PointCount; i++) { 453 for (i = 0; i < m_PointCount; i++) {
454 int point_type = m_pPoints[i].m_Flag & FXPT_TYPE; 454 int point_type = m_pPoints[i].m_Flag & FXPT_TYPE;
455 if (point_type == FXPT_MOVETO) { 455 if (point_type == FXPT_MOVETO) {
456 stratPoint = i; 456 stratPoint = i;
457 } else if (point_type == FXPT_LINETO) { 457 } else if (point_type == FXPT_LINETO) {
458 next = (i + 1 - stratPoint) % (m_PointCount - stratPoint) + stratPoi nt; 458 next = (i + 1 - stratPoint) % (m_PointCount - stratPoint) + stratPoi nt;
(...skipping 22 matching lines...) Expand all
481 NewPath.AddPointCount(2); 481 NewPath.AddPointCount(2);
482 NewPath.SetPoint(new_count, m_pPoints[pre].m_PointX, m_pPoin ts[pre].m_PointY, FXPT_MOVETO); 482 NewPath.SetPoint(new_count, m_pPoints[pre].m_PointX, m_pPoin ts[pre].m_PointY, FXPT_MOVETO);
483 NewPath.SetPoint(new_count + 1, m_pPoints[next].m_PointX, m_ pPoints[next].m_PointY, FXPT_LINETO); 483 NewPath.SetPoint(new_count + 1, m_pPoints[next].m_PointX, m_ pPoints[next].m_PointY, FXPT_LINETO);
484 } else if ((m_pPoints[i - 1].m_Flag & FXPT_TYPE) == FXPT_MOVETO && (m_pPoints[next].m_Flag & FXPT_TYPE) == FXPT_LINETO && 484 } else if ((m_pPoints[i - 1].m_Flag & FXPT_TYPE) == FXPT_MOVETO && (m_pPoints[next].m_Flag & FXPT_TYPE) == FXPT_LINETO &&
485 m_pPoints[i - 1].m_PointX == m_pPoints[next].m_PointX && m_pPoints[i - 1].m_PointY == m_pPoints[next].m_PointY 485 m_pPoints[i - 1].m_PointX == m_pPoints[next].m_PointX && m_pPoints[i - 1].m_PointY == m_pPoints[next].m_PointY
486 && m_pPoints[next].m_Flag & FXPT_CLOSEFIGURE) { 486 && m_pPoints[next].m_Flag & FXPT_CLOSEFIGURE) {
487 int new_count = NewPath.GetPointCount(); 487 int new_count = NewPath.GetPointCount();
488 NewPath.AddPointCount(2); 488 NewPath.AddPointCount(2);
489 NewPath.SetPoint(new_count, m_pPoints[i - 1].m_PointX, m_pPo ints[i - 1].m_PointY, FXPT_MOVETO); 489 NewPath.SetPoint(new_count, m_pPoints[i - 1].m_PointX, m_pPo ints[i - 1].m_PointY, FXPT_MOVETO);
490 NewPath.SetPoint(new_count + 1, m_pPoints[i].m_PointX, m_pPo ints[i].m_PointY, FXPT_LINETO); 490 NewPath.SetPoint(new_count + 1, m_pPoints[i].m_PointX, m_pPo ints[i].m_PointY, FXPT_LINETO);
491 bThin = TRUE; 491 bThin = true;
492 } 492 }
493 } 493 }
494 } else if (point_type == FXPT_BEZIERTO) { 494 } else if (point_type == FXPT_BEZIERTO) {
495 i += 2; 495 i += 2;
496 continue; 496 continue;
497 } 497 }
498 } 498 }
499 if (m_PointCount > 3 && NewPath.GetPointCount()) { 499 if (m_PointCount > 3 && NewPath.GetPointCount()) {
500 bThin = TRUE; 500 bThin = true;
501 } 501 }
502 if (NewPath.GetPointCount() == 0) { 502 if (NewPath.GetPointCount() == 0) {
503 return FALSE; 503 return false;
504 } 504 }
505 return TRUE; 505 return true;
506 } 506 }
507 FX_BOOL CFX_PathData::IsRect() const 507 bool CFX_PathData::IsRect() const
508 { 508 {
509 if (m_PointCount != 5 && m_PointCount != 4) { 509 if (m_PointCount != 5 && m_PointCount != 4) {
510 return FALSE; 510 return false;
511 } 511 }
512 if ((m_PointCount == 5 && (m_pPoints[0].m_PointX != m_pPoints[4].m_PointX || 512 if ((m_PointCount == 5 && (m_pPoints[0].m_PointX != m_pPoints[4].m_PointX ||
513 m_pPoints[0].m_PointY != m_pPoints[4].m_PointY)) || 513 m_pPoints[0].m_PointY != m_pPoints[4].m_PointY)) ||
514 (m_pPoints[0].m_PointX == m_pPoints[2].m_PointX && m_pPoints[0].m_Po intY == m_pPoints[2].m_PointY) || 514 (m_pPoints[0].m_PointX == m_pPoints[2].m_PointX && m_pPoints[0].m_Po intY == m_pPoints[2].m_PointY) ||
515 (m_pPoints[1].m_PointX == m_pPoints[3].m_PointX && m_pPoints[1].m_Po intY == m_pPoints[3].m_PointY)) { 515 (m_pPoints[1].m_PointX == m_pPoints[3].m_PointX && m_pPoints[1].m_Po intY == m_pPoints[3].m_PointY)) {
516 return FALSE; 516 return false;
517 } 517 }
518 if (m_pPoints[0].m_PointX != m_pPoints[3].m_PointX && m_pPoints[0].m_PointY != m_pPoints[3].m_PointY) { 518 if (m_pPoints[0].m_PointX != m_pPoints[3].m_PointX && m_pPoints[0].m_PointY != m_pPoints[3].m_PointY) {
519 return FALSE; 519 return false;
520 } 520 }
521 for (int i = 1; i < 4; i ++) { 521 for (int i = 1; i < 4; i ++) {
522 if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) { 522 if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) {
523 return FALSE; 523 return false;
524 } 524 }
525 if (m_pPoints[i].m_PointX != m_pPoints[i - 1].m_PointX && m_pPoints[i].m _PointY != m_pPoints[i - 1].m_PointY) { 525 if (m_pPoints[i].m_PointX != m_pPoints[i - 1].m_PointX && m_pPoints[i].m _PointY != m_pPoints[i - 1].m_PointY) {
526 return FALSE; 526 return false;
527 } 527 }
528 } 528 }
529 return m_PointCount == 5 || (m_pPoints[3].m_Flag & FXPT_CLOSEFIGURE); 529 return m_PointCount == 5 || (m_pPoints[3].m_Flag & FXPT_CLOSEFIGURE);
530 } 530 }
531 FX_BOOL CFX_PathData::IsRect(const CFX_AffineMatrix* pMatrix, CFX_FloatRect* pRe ct) const 531 bool CFX_PathData::IsRect(const CFX_AffineMatrix* pMatrix, CFX_FloatRect* pRect) const
532 { 532 {
533 if (pMatrix == NULL) { 533 if (pMatrix == NULL) {
534 if (!IsRect()) { 534 if (!IsRect()) {
535 return FALSE; 535 return false;
536 } 536 }
537 if (pRect) { 537 if (pRect) {
538 pRect->left = m_pPoints[0].m_PointX; 538 pRect->left = m_pPoints[0].m_PointX;
539 pRect->right = m_pPoints[2].m_PointX; 539 pRect->right = m_pPoints[2].m_PointX;
540 pRect->bottom = m_pPoints[0].m_PointY; 540 pRect->bottom = m_pPoints[0].m_PointY;
541 pRect->top = m_pPoints[2].m_PointY; 541 pRect->top = m_pPoints[2].m_PointY;
542 pRect->Normalize(); 542 pRect->Normalize();
543 } 543 }
544 return TRUE; 544 return true;
545 } 545 }
546 if (m_PointCount != 5 && m_PointCount != 4) { 546 if (m_PointCount != 5 && m_PointCount != 4) {
547 return FALSE; 547 return false;
548 } 548 }
549 if ((m_PointCount == 5 && (m_pPoints[0].m_PointX != m_pPoints[4].m_PointX || m_pPoints[0].m_PointY != m_pPoints[4].m_PointY)) || 549 if ((m_PointCount == 5 && (m_pPoints[0].m_PointX != m_pPoints[4].m_PointX || m_pPoints[0].m_PointY != m_pPoints[4].m_PointY)) ||
550 (m_pPoints[1].m_PointX == m_pPoints[3].m_PointX && m_pPoints[1].m_Po intY == m_pPoints[3].m_PointY)) { 550 (m_pPoints[1].m_PointX == m_pPoints[3].m_PointX && m_pPoints[1].m_Po intY == m_pPoints[3].m_PointY)) {
551 return FALSE; 551 return false;
552 } 552 }
553 if (m_PointCount == 4 && m_pPoints[0].m_PointX != m_pPoints[3].m_PointX && m _pPoints[0].m_PointY != m_pPoints[3].m_PointY) { 553 if (m_PointCount == 4 && m_pPoints[0].m_PointX != m_pPoints[3].m_PointX && m _pPoints[0].m_PointY != m_pPoints[3].m_PointY) {
554 return FALSE; 554 return false;
555 } 555 }
556 FX_FLOAT x[5], y[5]; 556 FX_FLOAT x[5], y[5];
557 for (int i = 0; i < m_PointCount; i ++) { 557 for (int i = 0; i < m_PointCount; i ++) {
558 pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY, x[i], y [i]); 558 pMatrix->Transform(m_pPoints[i].m_PointX, m_pPoints[i].m_PointY, x[i], y [i]);
559 if (i) { 559 if (i) {
560 if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) { 560 if ((m_pPoints[i].m_Flag & FXPT_TYPE) != FXPT_LINETO) {
561 return FALSE; 561 return false;
562 } 562 }
563 if (x[i] != x[i - 1] && y[i] != y[i - 1]) { 563 if (x[i] != x[i - 1] && y[i] != y[i - 1]) {
564 return FALSE; 564 return false;
565 } 565 }
566 } 566 }
567 } 567 }
568 if (pRect) { 568 if (pRect) {
569 pRect->left = x[0]; 569 pRect->left = x[0];
570 pRect->right = x[2]; 570 pRect->right = x[2];
571 pRect->bottom = y[0]; 571 pRect->bottom = y[0];
572 pRect->top = y[2]; 572 pRect->top = y[2];
573 pRect->Normalize(); 573 pRect->Normalize();
574 } 574 }
575 return TRUE; 575 return true;
576 } 576 }
577 void CFX_PathData::Copy(const CFX_PathData &src) 577 void CFX_PathData::Copy(const CFX_PathData &src)
578 { 578 {
579 SetPointCount(src.m_PointCount); 579 SetPointCount(src.m_PointCount);
580 FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount); 580 FXSYS_memcpy(m_pPoints, src.m_pPoints, sizeof(FX_PATHPOINT) * m_PointCount);
581 } 581 }
582 CFX_GraphStateData::CFX_GraphStateData() 582 CFX_GraphStateData::CFX_GraphStateData()
583 { 583 {
584 m_LineCap = LineCapButt; 584 m_LineCap = LineCapButt;
585 m_DashCount = 0; 585 m_DashCount = 0;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 if (m_DashArray) { 622 if (m_DashArray) {
623 FX_Free(m_DashArray); 623 FX_Free(m_DashArray);
624 } 624 }
625 m_DashArray = NULL; 625 m_DashArray = NULL;
626 m_DashCount = count; 626 m_DashCount = count;
627 if (count == 0) { 627 if (count == 0) {
628 return; 628 return;
629 } 629 }
630 m_DashArray = FX_Alloc(FX_FLOAT, count); 630 m_DashArray = FX_Alloc(FX_FLOAT, count);
631 } 631 }
OLDNEW
« no previous file with comments | « core/src/fxge/ge/fx_ge_linux.cpp ('k') | core/src/fxge/ge/fx_ge_ps.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698