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

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

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