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

Side by Side Diff: core/fxge/ge/cfx_renderdevice.cpp

Issue 2477443002: Remove FX_BOOL from core (Closed)
Patch Set: Created 4 years, 1 month 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/fxge/ge/cfx_pathdata.cpp ('k') | core/fxge/ge/fx_ge_fontmap.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 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/cfx_renderdevice.h" 7 #include "core/fxge/cfx_renderdevice.h"
8 8
9 #include "core/fxcrt/fx_safe_types.h" 9 #include "core/fxcrt/fx_safe_types.h"
10 #include "core/fxge/cfx_facecache.h" 10 #include "core/fxge/cfx_facecache.h"
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 UpdateClipBox(); 386 UpdateClipBox();
387 } 387 }
388 388
389 int CFX_RenderDevice::GetDeviceCaps(int caps_id) const { 389 int CFX_RenderDevice::GetDeviceCaps(int caps_id) const {
390 return m_pDeviceDriver->GetDeviceCaps(caps_id); 390 return m_pDeviceDriver->GetDeviceCaps(caps_id);
391 } 391 }
392 CFX_Matrix CFX_RenderDevice::GetCTM() const { 392 CFX_Matrix CFX_RenderDevice::GetCTM() const {
393 return m_pDeviceDriver->GetCTM(); 393 return m_pDeviceDriver->GetCTM();
394 } 394 }
395 395
396 FX_BOOL CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB, 396 bool CFX_RenderDevice::CreateCompatibleBitmap(CFX_DIBitmap* pDIB,
397 int width, 397 int width,
398 int height) const { 398 int height) const {
399 if (m_RenderCaps & FXRC_CMYK_OUTPUT) { 399 if (m_RenderCaps & FXRC_CMYK_OUTPUT) {
400 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT 400 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT
401 ? FXDIB_Cmyka 401 ? FXDIB_Cmyka
402 : FXDIB_Cmyk); 402 : FXDIB_Cmyk);
403 } 403 }
404 if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT) 404 if (m_RenderCaps & FXRC_BYTEMASK_OUTPUT)
405 return pDIB->Create(width, height, FXDIB_8bppMask); 405 return pDIB->Create(width, height, FXDIB_8bppMask);
406 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ 406 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
407 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT 407 return pDIB->Create(width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT
408 ? FXDIB_Argb 408 ? FXDIB_Argb
409 : FXDIB_Rgb32); 409 : FXDIB_Rgb32);
410 #else 410 #else
411 return pDIB->Create( 411 return pDIB->Create(
412 width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb); 412 width, height, m_RenderCaps & FXRC_ALPHA_OUTPUT ? FXDIB_Argb : FXDIB_Rgb);
413 #endif 413 #endif
414 } 414 }
415 415
416 FX_BOOL CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData, 416 bool CFX_RenderDevice::SetClip_PathFill(const CFX_PathData* pPathData,
417 const CFX_Matrix* pObject2Device, 417 const CFX_Matrix* pObject2Device,
418 int fill_mode) { 418 int fill_mode) {
419 if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device, 419 if (!m_pDeviceDriver->SetClip_PathFill(pPathData, pObject2Device,
420 fill_mode)) { 420 fill_mode)) {
421 return FALSE; 421 return false;
422 } 422 }
423 UpdateClipBox(); 423 UpdateClipBox();
424 return TRUE; 424 return true;
425 } 425 }
426 426
427 FX_BOOL CFX_RenderDevice::SetClip_PathStroke( 427 bool CFX_RenderDevice::SetClip_PathStroke(
428 const CFX_PathData* pPathData, 428 const CFX_PathData* pPathData,
429 const CFX_Matrix* pObject2Device, 429 const CFX_Matrix* pObject2Device,
430 const CFX_GraphStateData* pGraphState) { 430 const CFX_GraphStateData* pGraphState) {
431 if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device, 431 if (!m_pDeviceDriver->SetClip_PathStroke(pPathData, pObject2Device,
432 pGraphState)) { 432 pGraphState)) {
433 return FALSE; 433 return false;
434 } 434 }
435 UpdateClipBox(); 435 UpdateClipBox();
436 return TRUE; 436 return true;
437 } 437 }
438 438
439 FX_BOOL CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) { 439 bool CFX_RenderDevice::SetClip_Rect(const FX_RECT& rect) {
440 CFX_PathData path; 440 CFX_PathData path;
441 path.AppendRect(rect.left, rect.bottom, rect.right, rect.top); 441 path.AppendRect(rect.left, rect.bottom, rect.right, rect.top);
442 if (!SetClip_PathFill(&path, nullptr, FXFILL_WINDING)) 442 if (!SetClip_PathFill(&path, nullptr, FXFILL_WINDING))
443 return FALSE; 443 return false;
444 444
445 UpdateClipBox(); 445 UpdateClipBox();
446 return TRUE; 446 return true;
447 } 447 }
448 448
449 void CFX_RenderDevice::UpdateClipBox() { 449 void CFX_RenderDevice::UpdateClipBox() {
450 if (m_pDeviceDriver->GetClipBox(&m_ClipBox)) 450 if (m_pDeviceDriver->GetClipBox(&m_ClipBox))
451 return; 451 return;
452 m_ClipBox.left = 0; 452 m_ClipBox.left = 0;
453 m_ClipBox.top = 0; 453 m_ClipBox.top = 0;
454 m_ClipBox.right = m_Width; 454 m_ClipBox.right = m_Width;
455 m_ClipBox.bottom = m_Height; 455 m_ClipBox.bottom = m_Height;
456 } 456 }
457 457
458 FX_BOOL CFX_RenderDevice::DrawPathWithBlend( 458 bool CFX_RenderDevice::DrawPathWithBlend(const CFX_PathData* pPathData,
459 const CFX_PathData* pPathData, 459 const CFX_Matrix* pObject2Device,
460 const CFX_Matrix* pObject2Device, 460 const CFX_GraphStateData* pGraphState,
461 const CFX_GraphStateData* pGraphState, 461 uint32_t fill_color,
462 uint32_t fill_color, 462 uint32_t stroke_color,
463 uint32_t stroke_color, 463 int fill_mode,
464 int fill_mode, 464 int blend_type) {
465 int blend_type) {
466 uint8_t stroke_alpha = pGraphState ? FXARGB_A(stroke_color) : 0; 465 uint8_t stroke_alpha = pGraphState ? FXARGB_A(stroke_color) : 0;
467 uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0; 466 uint8_t fill_alpha = (fill_mode & 3) ? FXARGB_A(fill_color) : 0;
468 if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) { 467 if (stroke_alpha == 0 && pPathData->GetPointCount() == 2) {
469 FX_PATHPOINT* pPoints = pPathData->GetPoints(); 468 FX_PATHPOINT* pPoints = pPathData->GetPoints();
470 FX_FLOAT x1, x2, y1, y2; 469 FX_FLOAT x1, x2, y1, y2;
471 if (pObject2Device) { 470 if (pObject2Device) {
472 pObject2Device->Transform(pPoints[0].m_PointX, pPoints[0].m_PointY, x1, 471 pObject2Device->Transform(pPoints[0].m_PointX, pPoints[0].m_PointY, x1,
473 y1); 472 y1);
474 pObject2Device->Transform(pPoints[1].m_PointX, pPoints[1].m_PointY, x2, 473 pObject2Device->Transform(pPoints[1].m_PointX, pPoints[1].m_PointY, x2,
475 y2); 474 y2);
476 } else { 475 } else {
477 x1 = pPoints[0].m_PointX; 476 x1 = pPoints[0].m_PointX;
478 y1 = pPoints[0].m_PointY; 477 y1 = pPoints[0].m_PointY;
479 x2 = pPoints[1].m_PointX; 478 x2 = pPoints[1].m_PointX;
480 y2 = pPoints[1].m_PointY; 479 y2 = pPoints[1].m_PointY;
481 } 480 }
482 DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, blend_type); 481 DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, blend_type);
483 return TRUE; 482 return true;
484 } 483 }
485 if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && 484 if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) &&
486 stroke_alpha == 0) { 485 stroke_alpha == 0) {
487 CFX_FloatRect rect_f; 486 CFX_FloatRect rect_f;
488 if (!(fill_mode & FXFILL_RECT_AA) && 487 if (!(fill_mode & FXFILL_RECT_AA) &&
489 pPathData->IsRect(pObject2Device, &rect_f)) { 488 pPathData->IsRect(pObject2Device, &rect_f)) {
490 FX_RECT rect_i = rect_f.GetOuterRect(); 489 FX_RECT rect_i = rect_f.GetOuterRect();
491 490
492 // Depending on the top/bottom, left/right values of the rect it's 491 // Depending on the top/bottom, left/right values of the rect it's
493 // possible to overflow the Width() and Height() calculations. Check that 492 // possible to overflow the Width() and Height() calculations. Check that
494 // the rect will have valid dimension before continuing. 493 // the rect will have valid dimension before continuing.
495 if (!rect_i.Valid()) 494 if (!rect_i.Valid())
496 return FALSE; 495 return false;
497 496
498 int width = (int)FXSYS_ceil(rect_f.right - rect_f.left); 497 int width = (int)FXSYS_ceil(rect_f.right - rect_f.left);
499 if (width < 1) { 498 if (width < 1) {
500 width = 1; 499 width = 1;
501 if (rect_i.left == rect_i.right) 500 if (rect_i.left == rect_i.right)
502 rect_i.right++; 501 rect_i.right++;
503 } 502 }
504 int height = (int)FXSYS_ceil(rect_f.top - rect_f.bottom); 503 int height = (int)FXSYS_ceil(rect_f.top - rect_f.bottom);
505 if (height < 1) { 504 if (height < 1) {
506 height = 1; 505 height = 1;
(...skipping 10 matching lines...) Expand all
517 } 516 }
518 if (rect_i.Height() >= height + 1) { 517 if (rect_i.Height() >= height + 1) {
519 if (rect_f.top - (FX_FLOAT)(rect_i.top) > 518 if (rect_f.top - (FX_FLOAT)(rect_i.top) >
520 (FX_FLOAT)(rect_i.bottom) - rect_f.bottom) { 519 (FX_FLOAT)(rect_i.bottom) - rect_f.bottom) {
521 rect_i.top++; 520 rect_i.top++;
522 } else { 521 } else {
523 rect_i.bottom--; 522 rect_i.bottom--;
524 } 523 }
525 } 524 }
526 if (FillRectWithBlend(&rect_i, fill_color, blend_type)) 525 if (FillRectWithBlend(&rect_i, fill_color, blend_type))
527 return TRUE; 526 return true;
528 } 527 }
529 } 528 }
530 if ((fill_mode & 3) && stroke_alpha == 0 && !(fill_mode & FX_FILL_STROKE) && 529 if ((fill_mode & 3) && stroke_alpha == 0 && !(fill_mode & FX_FILL_STROKE) &&
531 !(fill_mode & FX_FILL_TEXT_MODE)) { 530 !(fill_mode & FX_FILL_TEXT_MODE)) {
532 CFX_PathData newPath; 531 CFX_PathData newPath;
533 FX_BOOL bThin = FALSE; 532 bool bThin = false;
534 if (pPathData->GetZeroAreaPath(newPath, (CFX_Matrix*)pObject2Device, bThin, 533 if (pPathData->GetZeroAreaPath(newPath, (CFX_Matrix*)pObject2Device, bThin,
535 !!m_pDeviceDriver->GetDriverType())) { 534 !!m_pDeviceDriver->GetDriverType())) {
536 CFX_GraphStateData graphState; 535 CFX_GraphStateData graphState;
537 graphState.m_LineWidth = 0.0f; 536 graphState.m_LineWidth = 0.0f;
538 uint32_t strokecolor = fill_color; 537 uint32_t strokecolor = fill_color;
539 if (bThin) 538 if (bThin)
540 strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff)); 539 strokecolor = (((fill_alpha >> 2) << 24) | (strokecolor & 0x00ffffff));
541 CFX_Matrix* pMatrix = nullptr; 540 CFX_Matrix* pMatrix = nullptr;
542 if (pObject2Device && !pObject2Device->IsIdentity()) 541 if (pObject2Device && !pObject2Device->IsIdentity())
543 pMatrix = (CFX_Matrix*)pObject2Device; 542 pMatrix = (CFX_Matrix*)pObject2Device;
(...skipping 13 matching lines...) Expand all
557 } 556 }
558 return DrawFillStrokePath(pPathData, pObject2Device, pGraphState, 557 return DrawFillStrokePath(pPathData, pObject2Device, pGraphState,
559 fill_color, stroke_color, fill_mode, blend_type); 558 fill_color, stroke_color, fill_mode, blend_type);
560 } 559 }
561 return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState, 560 return m_pDeviceDriver->DrawPath(pPathData, pObject2Device, pGraphState,
562 fill_color, stroke_color, fill_mode, 561 fill_color, stroke_color, fill_mode,
563 blend_type); 562 blend_type);
564 } 563 }
565 564
566 // This can be removed once PDFium entirely relies on Skia 565 // This can be removed once PDFium entirely relies on Skia
567 FX_BOOL CFX_RenderDevice::DrawFillStrokePath( 566 bool CFX_RenderDevice::DrawFillStrokePath(const CFX_PathData* pPathData,
568 const CFX_PathData* pPathData, 567 const CFX_Matrix* pObject2Device,
569 const CFX_Matrix* pObject2Device, 568 const CFX_GraphStateData* pGraphState,
570 const CFX_GraphStateData* pGraphState, 569 uint32_t fill_color,
571 uint32_t fill_color, 570 uint32_t stroke_color,
572 uint32_t stroke_color, 571 int fill_mode,
573 int fill_mode, 572 int blend_type) {
574 int blend_type) {
575 if (!(m_RenderCaps & FXRC_GET_BITS)) 573 if (!(m_RenderCaps & FXRC_GET_BITS))
576 return FALSE; 574 return false;
577 CFX_FloatRect bbox; 575 CFX_FloatRect bbox;
578 if (pGraphState) { 576 if (pGraphState) {
579 bbox = pPathData->GetBoundingBox(pGraphState->m_LineWidth, 577 bbox = pPathData->GetBoundingBox(pGraphState->m_LineWidth,
580 pGraphState->m_MiterLimit); 578 pGraphState->m_MiterLimit);
581 } else { 579 } else {
582 bbox = pPathData->GetBoundingBox(); 580 bbox = pPathData->GetBoundingBox();
583 } 581 }
584 if (pObject2Device) 582 if (pObject2Device)
585 bbox.Transform(pObject2Device); 583 bbox.Transform(pObject2Device);
586 CFX_Matrix ctm = GetCTM(); 584 CFX_Matrix ctm = GetCTM();
587 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); 585 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a);
588 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); 586 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d);
589 FX_RECT rect = bbox.GetOuterRect(); 587 FX_RECT rect = bbox.GetOuterRect();
590 CFX_DIBitmap bitmap, Backdrop; 588 CFX_DIBitmap bitmap, Backdrop;
591 if (!CreateCompatibleBitmap(&bitmap, FXSYS_round(rect.Width() * fScaleX), 589 if (!CreateCompatibleBitmap(&bitmap, FXSYS_round(rect.Width() * fScaleX),
592 FXSYS_round(rect.Height() * fScaleY))) { 590 FXSYS_round(rect.Height() * fScaleY))) {
593 return FALSE; 591 return false;
594 } 592 }
595 if (bitmap.HasAlpha()) { 593 if (bitmap.HasAlpha()) {
596 bitmap.Clear(0); 594 bitmap.Clear(0);
597 Backdrop.Copy(&bitmap); 595 Backdrop.Copy(&bitmap);
598 } else { 596 } else {
599 if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top)) 597 if (!m_pDeviceDriver->GetDIBits(&bitmap, rect.left, rect.top))
600 return FALSE; 598 return false;
601 Backdrop.Copy(&bitmap); 599 Backdrop.Copy(&bitmap);
602 } 600 }
603 CFX_FxgeDevice bitmap_device; 601 CFX_FxgeDevice bitmap_device;
604 bitmap_device.Attach(&bitmap, false, &Backdrop, true); 602 bitmap_device.Attach(&bitmap, false, &Backdrop, true);
605 CFX_Matrix matrix; 603 CFX_Matrix matrix;
606 if (pObject2Device) 604 if (pObject2Device)
607 matrix = *pObject2Device; 605 matrix = *pObject2Device;
608 matrix.TranslateI(-rect.left, -rect.top); 606 matrix.TranslateI(-rect.left, -rect.top);
609 matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0); 607 matrix.Concat(fScaleX, 0, 0, fScaleY, 0, 0);
610 if (!bitmap_device.GetDeviceDriver()->DrawPath( 608 if (!bitmap_device.GetDeviceDriver()->DrawPath(
611 pPathData, &matrix, pGraphState, fill_color, stroke_color, fill_mode, 609 pPathData, &matrix, pGraphState, fill_color, stroke_color, fill_mode,
612 blend_type)) { 610 blend_type)) {
613 return FALSE; 611 return false;
614 } 612 }
615 FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX), 613 FX_RECT src_rect(0, 0, FXSYS_round(rect.Width() * fScaleX),
616 FXSYS_round(rect.Height() * fScaleY)); 614 FXSYS_round(rect.Height() * fScaleY));
617 return m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, rect.left, rect.top, 615 return m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, rect.left, rect.top,
618 FXDIB_BLEND_NORMAL); 616 FXDIB_BLEND_NORMAL);
619 } 617 }
620 618
621 FX_BOOL CFX_RenderDevice::SetPixel(int x, int y, uint32_t color) { 619 bool CFX_RenderDevice::SetPixel(int x, int y, uint32_t color) {
622 if (m_pDeviceDriver->SetPixel(x, y, color)) 620 if (m_pDeviceDriver->SetPixel(x, y, color))
623 return TRUE; 621 return true;
624 622
625 FX_RECT rect(x, y, x + 1, y + 1); 623 FX_RECT rect(x, y, x + 1, y + 1);
626 return FillRectWithBlend(&rect, color, FXDIB_BLEND_NORMAL); 624 return FillRectWithBlend(&rect, color, FXDIB_BLEND_NORMAL);
627 } 625 }
628 626
629 FX_BOOL CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect, 627 bool CFX_RenderDevice::FillRectWithBlend(const FX_RECT* pRect,
630 uint32_t fill_color, 628 uint32_t fill_color,
631 int blend_type) { 629 int blend_type) {
632 if (m_pDeviceDriver->FillRectWithBlend(pRect, fill_color, blend_type)) 630 if (m_pDeviceDriver->FillRectWithBlend(pRect, fill_color, blend_type))
633 return TRUE; 631 return true;
634 632
635 if (!(m_RenderCaps & FXRC_GET_BITS)) 633 if (!(m_RenderCaps & FXRC_GET_BITS))
636 return FALSE; 634 return false;
637 635
638 CFX_DIBitmap bitmap; 636 CFX_DIBitmap bitmap;
639 if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height())) 637 if (!CreateCompatibleBitmap(&bitmap, pRect->Width(), pRect->Height()))
640 return FALSE; 638 return false;
641 639
642 if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top)) 640 if (!m_pDeviceDriver->GetDIBits(&bitmap, pRect->left, pRect->top))
643 return FALSE; 641 return false;
644 642
645 if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, 643 if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color,
646 0, nullptr)) { 644 0, nullptr)) {
647 return FALSE; 645 return false;
648 } 646 }
649 FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); 647 FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height());
650 m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, 648 m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top,
651 FXDIB_BLEND_NORMAL); 649 FXDIB_BLEND_NORMAL);
652 return TRUE; 650 return true;
653 } 651 }
654 652
655 FX_BOOL CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, 653 bool CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1,
656 FX_FLOAT y1, 654 FX_FLOAT y1,
657 FX_FLOAT x2, 655 FX_FLOAT x2,
658 FX_FLOAT y2, 656 FX_FLOAT y2,
659 uint32_t color, 657 uint32_t color,
660 int fill_mode, 658 int fill_mode,
661 int blend_type) { 659 int blend_type) {
662 if ((color >= 0xff000000) && 660 if ((color >= 0xff000000) &&
663 m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, blend_type)) { 661 m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, blend_type)) {
664 return TRUE; 662 return true;
665 } 663 }
666 CFX_GraphStateData graph_state; 664 CFX_GraphStateData graph_state;
667 CFX_PathData path; 665 CFX_PathData path;
668 path.SetPointCount(2); 666 path.SetPointCount(2);
669 path.SetPoint(0, x1, y1, FXPT_MOVETO); 667 path.SetPoint(0, x1, y1, FXPT_MOVETO);
670 path.SetPoint(1, x2, y2, FXPT_LINETO); 668 path.SetPoint(1, x2, y2, FXPT_LINETO);
671 return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color, 669 return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color,
672 fill_mode, blend_type); 670 fill_mode, blend_type);
673 } 671 }
674 672
675 FX_BOOL CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { 673 bool CFX_RenderDevice::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) {
676 if (!(m_RenderCaps & FXRC_GET_BITS)) 674 if (!(m_RenderCaps & FXRC_GET_BITS))
677 return FALSE; 675 return false;
678 return m_pDeviceDriver->GetDIBits(pBitmap, left, top); 676 return m_pDeviceDriver->GetDIBits(pBitmap, left, top);
679 } 677 }
680 678
681 CFX_DIBitmap* CFX_RenderDevice::GetBackDrop() { 679 CFX_DIBitmap* CFX_RenderDevice::GetBackDrop() {
682 return m_pDeviceDriver->GetBackDrop(); 680 return m_pDeviceDriver->GetBackDrop();
683 } 681 }
684 682
685 FX_BOOL CFX_RenderDevice::SetDIBitsWithBlend(const CFX_DIBSource* pBitmap, 683 bool CFX_RenderDevice::SetDIBitsWithBlend(const CFX_DIBSource* pBitmap,
686 int left, 684 int left,
687 int top, 685 int top,
688 int blend_mode) { 686 int blend_mode) {
689 ASSERT(!pBitmap->IsAlphaMask()); 687 ASSERT(!pBitmap->IsAlphaMask());
690 CFX_Matrix ctm = GetCTM(); 688 CFX_Matrix ctm = GetCTM();
691 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); 689 FX_FLOAT fScaleX = FXSYS_fabs(ctm.a);
692 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d); 690 FX_FLOAT fScaleY = FXSYS_fabs(ctm.d);
693 FX_RECT dest_rect(left, top, 691 FX_RECT dest_rect(left, top,
694 FXSYS_round(left + pBitmap->GetWidth() / fScaleX), 692 FXSYS_round(left + pBitmap->GetWidth() / fScaleX),
695 FXSYS_round(top + pBitmap->GetHeight() / fScaleY)); 693 FXSYS_round(top + pBitmap->GetHeight() / fScaleY));
696 dest_rect.Intersect(m_ClipBox); 694 dest_rect.Intersect(m_ClipBox);
697 if (dest_rect.IsEmpty()) 695 if (dest_rect.IsEmpty())
698 return TRUE; 696 return true;
699 FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top, 697 FX_RECT src_rect(dest_rect.left - left, dest_rect.top - top,
700 dest_rect.left - left + dest_rect.Width(), 698 dest_rect.left - left + dest_rect.Width(),
701 dest_rect.top - top + dest_rect.Height()); 699 dest_rect.top - top + dest_rect.Height());
702 src_rect.left = FXSYS_round(src_rect.left * fScaleX); 700 src_rect.left = FXSYS_round(src_rect.left * fScaleX);
703 src_rect.top = FXSYS_round(src_rect.top * fScaleY); 701 src_rect.top = FXSYS_round(src_rect.top * fScaleY);
704 src_rect.right = FXSYS_round(src_rect.right * fScaleX); 702 src_rect.right = FXSYS_round(src_rect.right * fScaleX);
705 src_rect.bottom = FXSYS_round(src_rect.bottom * fScaleY); 703 src_rect.bottom = FXSYS_round(src_rect.bottom * fScaleY);
706 if ((blend_mode != FXDIB_BLEND_NORMAL && !(m_RenderCaps & FXRC_BLEND_MODE)) || 704 if ((blend_mode != FXDIB_BLEND_NORMAL && !(m_RenderCaps & FXRC_BLEND_MODE)) ||
707 (pBitmap->HasAlpha() && !(m_RenderCaps & FXRC_ALPHA_IMAGE))) { 705 (pBitmap->HasAlpha() && !(m_RenderCaps & FXRC_ALPHA_IMAGE))) {
708 if (!(m_RenderCaps & FXRC_GET_BITS)) 706 if (!(m_RenderCaps & FXRC_GET_BITS))
709 return FALSE; 707 return false;
710 int bg_pixel_width = FXSYS_round(dest_rect.Width() * fScaleX); 708 int bg_pixel_width = FXSYS_round(dest_rect.Width() * fScaleX);
711 int bg_pixel_height = FXSYS_round(dest_rect.Height() * fScaleY); 709 int bg_pixel_height = FXSYS_round(dest_rect.Height() * fScaleY);
712 CFX_DIBitmap background; 710 CFX_DIBitmap background;
713 if (!background.Create( 711 if (!background.Create(
714 bg_pixel_width, bg_pixel_height, 712 bg_pixel_width, bg_pixel_height,
715 (m_RenderCaps & FXRC_CMYK_OUTPUT) ? FXDIB_Cmyk : FXDIB_Rgb32)) { 713 (m_RenderCaps & FXRC_CMYK_OUTPUT) ? FXDIB_Cmyk : FXDIB_Rgb32)) {
716 return FALSE; 714 return false;
717 } 715 }
718 if (!m_pDeviceDriver->GetDIBits(&background, dest_rect.left, 716 if (!m_pDeviceDriver->GetDIBits(&background, dest_rect.left,
719 dest_rect.top)) { 717 dest_rect.top)) {
720 return FALSE; 718 return false;
721 } 719 }
722 if (!background.CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height, 720 if (!background.CompositeBitmap(0, 0, bg_pixel_width, bg_pixel_height,
723 pBitmap, src_rect.left, src_rect.top, 721 pBitmap, src_rect.left, src_rect.top,
724 blend_mode, nullptr, FALSE, nullptr)) { 722 blend_mode, nullptr, false, nullptr)) {
725 return FALSE; 723 return false;
726 } 724 }
727 FX_RECT rect(0, 0, bg_pixel_width, bg_pixel_height); 725 FX_RECT rect(0, 0, bg_pixel_width, bg_pixel_height);
728 return m_pDeviceDriver->SetDIBits(&background, 0, &rect, dest_rect.left, 726 return m_pDeviceDriver->SetDIBits(&background, 0, &rect, dest_rect.left,
729 dest_rect.top, FXDIB_BLEND_NORMAL); 727 dest_rect.top, FXDIB_BLEND_NORMAL);
730 } 728 }
731 return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left, 729 return m_pDeviceDriver->SetDIBits(pBitmap, 0, &src_rect, dest_rect.left,
732 dest_rect.top, blend_mode); 730 dest_rect.top, blend_mode);
733 } 731 }
734 732
735 FX_BOOL CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend( 733 bool CFX_RenderDevice::StretchDIBitsWithFlagsAndBlend(
736 const CFX_DIBSource* pBitmap, 734 const CFX_DIBSource* pBitmap,
737 int left, 735 int left,
738 int top, 736 int top,
739 int dest_width, 737 int dest_width,
740 int dest_height, 738 int dest_height,
741 uint32_t flags, 739 uint32_t flags,
742 int blend_mode) { 740 int blend_mode) {
743 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); 741 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height);
744 FX_RECT clip_box = m_ClipBox; 742 FX_RECT clip_box = m_ClipBox;
745 clip_box.Intersect(dest_rect); 743 clip_box.Intersect(dest_rect);
746 if (clip_box.IsEmpty()) 744 if (clip_box.IsEmpty())
747 return TRUE; 745 return true;
748 return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width, 746 return m_pDeviceDriver->StretchDIBits(pBitmap, 0, left, top, dest_width,
749 dest_height, &clip_box, flags, 747 dest_height, &clip_box, flags,
750 blend_mode); 748 blend_mode);
751 } 749 }
752 750
753 FX_BOOL CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap, 751 bool CFX_RenderDevice::SetBitMask(const CFX_DIBSource* pBitmap,
754 int left, 752 int left,
755 int top, 753 int top,
756 uint32_t argb) { 754 uint32_t argb) {
757 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); 755 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
758 return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top, 756 return m_pDeviceDriver->SetDIBits(pBitmap, argb, &src_rect, left, top,
759 FXDIB_BLEND_NORMAL); 757 FXDIB_BLEND_NORMAL);
760 } 758 }
761 759
762 FX_BOOL CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap, 760 bool CFX_RenderDevice::StretchBitMask(const CFX_DIBSource* pBitmap,
763 int left, 761 int left,
764 int top, 762 int top,
765 int dest_width, 763 int dest_width,
766 int dest_height, 764 int dest_height,
767 uint32_t color) { 765 uint32_t color) {
768 return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height, 766 return StretchBitMaskWithFlags(pBitmap, left, top, dest_width, dest_height,
769 color, 0); 767 color, 0);
770 } 768 }
771 769
772 FX_BOOL CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap, 770 bool CFX_RenderDevice::StretchBitMaskWithFlags(const CFX_DIBSource* pBitmap,
773 int left, 771 int left,
774 int top, 772 int top,
775 int dest_width, 773 int dest_width,
776 int dest_height, 774 int dest_height,
777 uint32_t argb, 775 uint32_t argb,
778 uint32_t flags) { 776 uint32_t flags) {
779 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height); 777 FX_RECT dest_rect(left, top, left + dest_width, top + dest_height);
780 FX_RECT clip_box = m_ClipBox; 778 FX_RECT clip_box = m_ClipBox;
781 clip_box.Intersect(dest_rect); 779 clip_box.Intersect(dest_rect);
782 return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width, 780 return m_pDeviceDriver->StretchDIBits(pBitmap, argb, left, top, dest_width,
783 dest_height, &clip_box, flags, 781 dest_height, &clip_box, flags,
784 FXDIB_BLEND_NORMAL); 782 FXDIB_BLEND_NORMAL);
785 } 783 }
786 784
787 FX_BOOL CFX_RenderDevice::StartDIBitsWithBlend(const CFX_DIBSource* pBitmap, 785 bool CFX_RenderDevice::StartDIBitsWithBlend(const CFX_DIBSource* pBitmap,
788 int bitmap_alpha, 786 int bitmap_alpha,
789 uint32_t argb, 787 uint32_t argb,
790 const CFX_Matrix* pMatrix, 788 const CFX_Matrix* pMatrix,
791 uint32_t flags, 789 uint32_t flags,
792 void*& handle, 790 void*& handle,
793 int blend_mode) { 791 int blend_mode) {
794 return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix, 792 return m_pDeviceDriver->StartDIBits(pBitmap, bitmap_alpha, argb, pMatrix,
795 flags, handle, blend_mode); 793 flags, handle, blend_mode);
796 } 794 }
797 795
798 FX_BOOL CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) { 796 bool CFX_RenderDevice::ContinueDIBits(void* handle, IFX_Pause* pPause) {
799 return m_pDeviceDriver->ContinueDIBits(handle, pPause); 797 return m_pDeviceDriver->ContinueDIBits(handle, pPause);
800 } 798 }
801 799
802 void CFX_RenderDevice::CancelDIBits(void* handle) { 800 void CFX_RenderDevice::CancelDIBits(void* handle) {
803 m_pDeviceDriver->CancelDIBits(handle); 801 m_pDeviceDriver->CancelDIBits(handle);
804 } 802 }
805 803
806 #ifdef _SKIA_SUPPORT_ 804 #ifdef _SKIA_SUPPORT_
807 void CFX_RenderDevice::DebugVerifyBitmapIsPreMultiplied() const { 805 void CFX_RenderDevice::DebugVerifyBitmapIsPreMultiplied() const {
808 SkASSERT(0); 806 SkASSERT(0);
809 } 807 }
810 808
811 bool CFX_RenderDevice::SetBitsWithMask(const CFX_DIBSource* pBitmap, 809 bool CFX_RenderDevice::SetBitsWithMask(const CFX_DIBSource* pBitmap,
812 const CFX_DIBSource* pMask, 810 const CFX_DIBSource* pMask,
813 int left, 811 int left,
814 int top, 812 int top,
815 int bitmap_alpha, 813 int bitmap_alpha,
816 int blend_type) { 814 int blend_type) {
817 return m_pDeviceDriver->SetBitsWithMask(pBitmap, pMask, left, top, 815 return m_pDeviceDriver->SetBitsWithMask(pBitmap, pMask, left, top,
818 bitmap_alpha, blend_type); 816 bitmap_alpha, blend_type);
819 } 817 }
820 #endif 818 #endif
821 819
822 FX_BOOL CFX_RenderDevice::DrawNormalText(int nChars, 820 bool CFX_RenderDevice::DrawNormalText(int nChars,
823 const FXTEXT_CHARPOS* pCharPos, 821 const FXTEXT_CHARPOS* pCharPos,
824 CFX_Font* pFont, 822 CFX_Font* pFont,
825 FX_FLOAT font_size, 823 FX_FLOAT font_size,
826 const CFX_Matrix* pText2Device, 824 const CFX_Matrix* pText2Device,
827 uint32_t fill_color, 825 uint32_t fill_color,
828 uint32_t text_flags) { 826 uint32_t text_flags) {
829 int nativetext_flags = text_flags; 827 int nativetext_flags = text_flags;
830 if (m_DeviceClass != FXDC_DISPLAY) { 828 if (m_DeviceClass != FXDC_DISPLAY) {
831 if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) { 829 if (!(text_flags & FXTEXT_PRINTGRAPHICTEXT)) {
832 if (ShouldDrawDeviceText(pFont, text_flags) && 830 if (ShouldDrawDeviceText(pFont, text_flags) &&
833 m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pText2Device, 831 m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pText2Device,
834 font_size, fill_color)) { 832 font_size, fill_color)) {
835 return TRUE; 833 return true;
836 } 834 }
837 } 835 }
838 if (FXARGB_A(fill_color) < 255) 836 if (FXARGB_A(fill_color) < 255)
839 return FALSE; 837 return false;
840 } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) { 838 } else if (!(text_flags & FXTEXT_NO_NATIVETEXT)) {
841 if (ShouldDrawDeviceText(pFont, text_flags) && 839 if (ShouldDrawDeviceText(pFont, text_flags) &&
842 m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pText2Device, 840 m_pDeviceDriver->DrawDeviceText(nChars, pCharPos, pFont, pText2Device,
843 font_size, fill_color)) { 841 font_size, fill_color)) {
844 return TRUE; 842 return true;
845 } 843 }
846 } 844 }
847 CFX_Matrix char2device; 845 CFX_Matrix char2device;
848 CFX_Matrix text2Device; 846 CFX_Matrix text2Device;
849 if (pText2Device) { 847 if (pText2Device) {
850 char2device = *pText2Device; 848 char2device = *pText2Device;
851 text2Device = *pText2Device; 849 text2Device = *pText2Device;
852 } 850 }
853 char2device.Scale(font_size, -font_size); 851 char2device.Scale(font_size, -font_size);
854 if (FXSYS_fabs(char2device.a) + FXSYS_fabs(char2device.b) > 50 * 1.0f || 852 if (FXSYS_fabs(char2device.a) + FXSYS_fabs(char2device.b) > 50 * 1.0f ||
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 bmp_rect1.top--; 926 bmp_rect1.top--;
929 bmp_rect1.right++; 927 bmp_rect1.right++;
930 bmp_rect1.bottom++; 928 bmp_rect1.bottom++;
931 } 929 }
932 FX_RECT bmp_rect(FXSYS_round((FX_FLOAT)(bmp_rect1.left) / scale_x), 930 FX_RECT bmp_rect(FXSYS_round((FX_FLOAT)(bmp_rect1.left) / scale_x),
933 FXSYS_round((FX_FLOAT)(bmp_rect1.top) / scale_y), 931 FXSYS_round((FX_FLOAT)(bmp_rect1.top) / scale_y),
934 FXSYS_round((FX_FLOAT)bmp_rect1.right / scale_x), 932 FXSYS_round((FX_FLOAT)bmp_rect1.right / scale_x),
935 FXSYS_round((FX_FLOAT)bmp_rect1.bottom / scale_y)); 933 FXSYS_round((FX_FLOAT)bmp_rect1.bottom / scale_y));
936 bmp_rect.Intersect(m_ClipBox); 934 bmp_rect.Intersect(m_ClipBox);
937 if (bmp_rect.IsEmpty()) 935 if (bmp_rect.IsEmpty())
938 return TRUE; 936 return true;
939 int pixel_width = FXSYS_round(bmp_rect.Width() * scale_x); 937 int pixel_width = FXSYS_round(bmp_rect.Width() * scale_x);
940 int pixel_height = FXSYS_round(bmp_rect.Height() * scale_y); 938 int pixel_height = FXSYS_round(bmp_rect.Height() * scale_y);
941 int pixel_left = FXSYS_round(bmp_rect.left * scale_x); 939 int pixel_left = FXSYS_round(bmp_rect.left * scale_x);
942 int pixel_top = FXSYS_round(bmp_rect.top * scale_y); 940 int pixel_top = FXSYS_round(bmp_rect.top * scale_y);
943 if (anti_alias == FXFT_RENDER_MODE_MONO) { 941 if (anti_alias == FXFT_RENDER_MODE_MONO) {
944 CFX_DIBitmap bitmap; 942 CFX_DIBitmap bitmap;
945 if (!bitmap.Create(pixel_width, pixel_height, FXDIB_1bppMask)) 943 if (!bitmap.Create(pixel_width, pixel_height, FXDIB_1bppMask))
946 return FALSE; 944 return false;
947 bitmap.Clear(0); 945 bitmap.Clear(0);
948 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { 946 for (const FXTEXT_GLYPHPOS& glyph : glyphs) {
949 if (!glyph.m_pGlyph) 947 if (!glyph.m_pGlyph)
950 continue; 948 continue;
951 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; 949 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap;
952 bitmap.TransferBitmap( 950 bitmap.TransferBitmap(
953 glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left, 951 glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left,
954 glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top, 952 glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top,
955 pGlyph->GetWidth(), pGlyph->GetHeight(), pGlyph, 0, 0); 953 pGlyph->GetWidth(), pGlyph->GetHeight(), pGlyph, 0, 0);
956 } 954 }
957 return SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); 955 return SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color);
958 } 956 }
959 CFX_DIBitmap bitmap; 957 CFX_DIBitmap bitmap;
960 if (m_bpp == 8) { 958 if (m_bpp == 8) {
961 if (!bitmap.Create(pixel_width, pixel_height, FXDIB_8bppMask)) 959 if (!bitmap.Create(pixel_width, pixel_height, FXDIB_8bppMask))
962 return FALSE; 960 return false;
963 } else { 961 } else {
964 if (!CreateCompatibleBitmap(&bitmap, pixel_width, pixel_height)) 962 if (!CreateCompatibleBitmap(&bitmap, pixel_width, pixel_height))
965 return FALSE; 963 return false;
966 } 964 }
967 if (!bitmap.HasAlpha() && !bitmap.IsAlphaMask()) { 965 if (!bitmap.HasAlpha() && !bitmap.IsAlphaMask()) {
968 bitmap.Clear(0xFFFFFFFF); 966 bitmap.Clear(0xFFFFFFFF);
969 if (!GetDIBits(&bitmap, bmp_rect.left, bmp_rect.top)) 967 if (!GetDIBits(&bitmap, bmp_rect.left, bmp_rect.top))
970 return FALSE; 968 return false;
971 } else { 969 } else {
972 bitmap.Clear(0); 970 bitmap.Clear(0);
973 if (bitmap.m_pAlphaMask) 971 if (bitmap.m_pAlphaMask)
974 bitmap.m_pAlphaMask->Clear(0); 972 bitmap.m_pAlphaMask->Clear(0);
975 } 973 }
976 int dest_width = pixel_width; 974 int dest_width = pixel_width;
977 int a = 0; 975 int a = 0;
978 int r = 0; 976 int r = 0;
979 int g = 0; 977 int g = 0;
980 int b = 0; 978 int b = 0;
981 if (anti_alias == FXFT_RENDER_MODE_LCD) 979 if (anti_alias == FXFT_RENDER_MODE_LCD)
982 ArgbDecode(fill_color, a, r, g, b); 980 ArgbDecode(fill_color, a, r, g, b);
983 981
984 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { 982 for (const FXTEXT_GLYPHPOS& glyph : glyphs) {
985 if (!glyph.m_pGlyph) 983 if (!glyph.m_pGlyph)
986 continue; 984 continue;
987 985
988 pdfium::base::CheckedNumeric<int> left = glyph.m_OriginX; 986 pdfium::base::CheckedNumeric<int> left = glyph.m_OriginX;
989 left += glyph.m_pGlyph->m_Left; 987 left += glyph.m_pGlyph->m_Left;
990 left -= pixel_left; 988 left -= pixel_left;
991 if (!left.IsValid()) 989 if (!left.IsValid())
992 return FALSE; 990 return false;
993 991
994 pdfium::base::CheckedNumeric<int> top = glyph.m_OriginY; 992 pdfium::base::CheckedNumeric<int> top = glyph.m_OriginY;
995 top -= glyph.m_pGlyph->m_Top; 993 top -= glyph.m_pGlyph->m_Top;
996 top -= pixel_top; 994 top -= pixel_top;
997 if (!top.IsValid()) 995 if (!top.IsValid())
998 return FALSE; 996 return false;
999 997
1000 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; 998 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap;
1001 int ncols = pGlyph->GetWidth(); 999 int ncols = pGlyph->GetWidth();
1002 int nrows = pGlyph->GetHeight(); 1000 int nrows = pGlyph->GetHeight();
1003 if (anti_alias == FXFT_RENDER_MODE_NORMAL) { 1001 if (anti_alias == FXFT_RENDER_MODE_NORMAL) {
1004 if (!bitmap.CompositeMask(left.ValueOrDie(), top.ValueOrDie(), ncols, 1002 if (!bitmap.CompositeMask(left.ValueOrDie(), top.ValueOrDie(), ncols,
1005 nrows, pGlyph, fill_color, 0, 0, 1003 nrows, pGlyph, fill_color, 0, 0,
1006 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, 1004 FXDIB_BLEND_NORMAL, nullptr, false, 0,
1007 nullptr)) { 1005 nullptr)) {
1008 return FALSE; 1006 return false;
1009 } 1007 }
1010 continue; 1008 continue;
1011 } 1009 }
1012 bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE); 1010 bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE);
1013 ncols /= 3; 1011 ncols /= 3;
1014 int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; 1012 int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3;
1015 int start_col = std::max(left.ValueOrDie(), 0); 1013 int start_col = std::max(left.ValueOrDie(), 0);
1016 pdfium::base::CheckedNumeric<int> end_col_safe = left; 1014 pdfium::base::CheckedNumeric<int> end_col_safe = left;
1017 end_col_safe += ncols; 1015 end_col_safe += ncols;
1018 if (!end_col_safe.IsValid()) 1016 if (!end_col_safe.IsValid())
1019 return FALSE; 1017 return false;
1020 1018
1021 int end_col = std::min(end_col_safe.ValueOrDie(), dest_width); 1019 int end_col = std::min(end_col_safe.ValueOrDie(), dest_width);
1022 if (start_col >= end_col) 1020 if (start_col >= end_col)
1023 continue; 1021 continue;
1024 1022
1025 DrawNormalTextHelper(&bitmap, pGlyph, nrows, left.ValueOrDie(), 1023 DrawNormalTextHelper(&bitmap, pGlyph, nrows, left.ValueOrDie(),
1026 top.ValueOrDie(), start_col, end_col, bNormal, 1024 top.ValueOrDie(), start_col, end_col, bNormal,
1027 bBGRStripe, x_subpixel, a, r, g, b); 1025 bBGRStripe, x_subpixel, a, r, g, b);
1028 } 1026 }
1029 if (bitmap.IsAlphaMask()) 1027 if (bitmap.IsAlphaMask())
1030 SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); 1028 SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color);
1031 else 1029 else
1032 SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); 1030 SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top);
1033 return TRUE; 1031 return true;
1034 } 1032 }
1035 1033
1036 FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars, 1034 bool CFX_RenderDevice::DrawTextPath(int nChars,
1037 const FXTEXT_CHARPOS* pCharPos, 1035 const FXTEXT_CHARPOS* pCharPos,
1038 CFX_Font* pFont, 1036 CFX_Font* pFont,
1039 FX_FLOAT font_size, 1037 FX_FLOAT font_size,
1040 const CFX_Matrix* pText2User, 1038 const CFX_Matrix* pText2User,
1041 const CFX_Matrix* pUser2Device, 1039 const CFX_Matrix* pUser2Device,
1042 const CFX_GraphStateData* pGraphState, 1040 const CFX_GraphStateData* pGraphState,
1043 uint32_t fill_color, 1041 uint32_t fill_color,
1044 FX_ARGB stroke_color, 1042 FX_ARGB stroke_color,
1045 CFX_PathData* pClippingPath, 1043 CFX_PathData* pClippingPath,
1046 int nFlag) { 1044 int nFlag) {
1047 for (int iChar = 0; iChar < nChars; iChar++) { 1045 for (int iChar = 0; iChar < nChars; iChar++) {
1048 const FXTEXT_CHARPOS& charpos = pCharPos[iChar]; 1046 const FXTEXT_CHARPOS& charpos = pCharPos[iChar];
1049 CFX_Matrix matrix; 1047 CFX_Matrix matrix;
1050 if (charpos.m_bGlyphAdjust) { 1048 if (charpos.m_bGlyphAdjust) {
1051 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], 1049 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1],
1052 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); 1050 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0);
1053 } 1051 }
1054 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, 1052 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX,
1055 charpos.m_OriginY); 1053 charpos.m_OriginY);
1056 const CFX_PathData* pPath = 1054 const CFX_PathData* pPath =
1057 pFont->LoadGlyphPath(charpos.m_GlyphIndex, charpos.m_FontCharWidth); 1055 pFont->LoadGlyphPath(charpos.m_GlyphIndex, charpos.m_FontCharWidth);
1058 if (!pPath) 1056 if (!pPath)
1059 continue; 1057 continue;
1060 matrix.Concat(*pText2User); 1058 matrix.Concat(*pText2User);
1061 CFX_PathData TransformedPath(*pPath); 1059 CFX_PathData TransformedPath(*pPath);
1062 TransformedPath.Transform(&matrix); 1060 TransformedPath.Transform(&matrix);
1063 if (fill_color || stroke_color) { 1061 if (fill_color || stroke_color) {
1064 int fill_mode = nFlag; 1062 int fill_mode = nFlag;
1065 if (fill_color) 1063 if (fill_color)
1066 fill_mode |= FXFILL_WINDING; 1064 fill_mode |= FXFILL_WINDING;
1067 fill_mode |= FX_FILL_TEXT_MODE; 1065 fill_mode |= FX_FILL_TEXT_MODE;
1068 if (!DrawPathWithBlend(&TransformedPath, pUser2Device, pGraphState, 1066 if (!DrawPathWithBlend(&TransformedPath, pUser2Device, pGraphState,
1069 fill_color, stroke_color, fill_mode, 1067 fill_color, stroke_color, fill_mode,
1070 FXDIB_BLEND_NORMAL)) { 1068 FXDIB_BLEND_NORMAL)) {
1071 return FALSE; 1069 return false;
1072 } 1070 }
1073 } 1071 }
1074 if (pClippingPath) 1072 if (pClippingPath)
1075 pClippingPath->Append(&TransformedPath, pUser2Device); 1073 pClippingPath->Append(&TransformedPath, pUser2Device);
1076 } 1074 }
1077 return TRUE; 1075 return true;
1078 } 1076 }
OLDNEW
« no previous file with comments | « core/fxge/ge/cfx_pathdata.cpp ('k') | core/fxge/ge/fx_ge_fontmap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698