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

Side by Side Diff: xfa/fxgraphics/cfx_graphics.cpp

Issue 1952693003: Convert FWL_ERR into an enum class. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 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 | « xfa/fxgraphics/cfx_color.cpp ('k') | xfa/fxgraphics/cfx_path.h » ('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 "xfa/fxgraphics/include/cfx_graphics.h" 7 #include "xfa/fxgraphics/include/cfx_graphics.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 }}, 563 }},
564 }; 564 };
565 565
566 } // namespace 566 } // namespace
567 567
568 CFX_Graphics::CFX_Graphics() 568 CFX_Graphics::CFX_Graphics()
569 : m_type(FX_CONTEXT_None), 569 : m_type(FX_CONTEXT_None),
570 m_renderDevice(nullptr), 570 m_renderDevice(nullptr),
571 m_aggGraphics(nullptr) {} 571 m_aggGraphics(nullptr) {}
572 572
573 FX_ERR CFX_Graphics::Create(CFX_RenderDevice* renderDevice, 573 FWL_Error CFX_Graphics::Create(CFX_RenderDevice* renderDevice,
574 FX_BOOL isAntialiasing) { 574 FX_BOOL isAntialiasing) {
575 if (!renderDevice) 575 if (!renderDevice)
576 return FX_ERR_Parameter_Invalid; 576 return FWL_Error::ParameterInvalid;
577 if (m_type != FX_CONTEXT_None) 577 if (m_type != FX_CONTEXT_None)
578 return FX_ERR_Property_Invalid; 578 return FWL_Error::PropertyInvalid;
579 579
580 m_type = FX_CONTEXT_Device; 580 m_type = FX_CONTEXT_Device;
581 m_info.isAntialiasing = isAntialiasing; 581 m_info.isAntialiasing = isAntialiasing;
582 m_renderDevice = renderDevice; 582 m_renderDevice = renderDevice;
583 if (m_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP) 583 if (m_renderDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)
584 return FX_ERR_Succeeded; 584 return FWL_Error::Succeeded;
585 return FX_ERR_Indefinite; 585 return FWL_Error::Indefinite;
586 } 586 }
587 587
588 FX_ERR CFX_Graphics::Create(int32_t width, 588 FWL_Error CFX_Graphics::Create(int32_t width,
589 int32_t height, 589 int32_t height,
590 FXDIB_Format format, 590 FXDIB_Format format,
591 FX_BOOL isNative, 591 FX_BOOL isNative,
592 FX_BOOL isAntialiasing) { 592 FX_BOOL isAntialiasing) {
593 if (m_type != FX_CONTEXT_None) 593 if (m_type != FX_CONTEXT_None)
594 return FX_ERR_Property_Invalid; 594 return FWL_Error::PropertyInvalid;
595 595
596 m_type = FX_CONTEXT_Device; 596 m_type = FX_CONTEXT_Device;
597 m_info.isAntialiasing = isAntialiasing; 597 m_info.isAntialiasing = isAntialiasing;
598 m_aggGraphics = new CAGG_Graphics; 598 m_aggGraphics = new CAGG_Graphics;
599 return m_aggGraphics->Create(this, width, height, format); 599 return m_aggGraphics->Create(this, width, height, format);
600 } 600 }
601 601
602 CFX_Graphics::~CFX_Graphics() { 602 CFX_Graphics::~CFX_Graphics() {
603 delete m_aggGraphics; 603 delete m_aggGraphics;
604 } 604 }
605 605
606 FX_ERR CFX_Graphics::GetDeviceCap(const int32_t capID, FX_DeviceCap& capVal) { 606 FWL_Error CFX_Graphics::GetDeviceCap(const int32_t capID,
607 FX_DeviceCap& capVal) {
607 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 608 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
608 capVal = m_renderDevice->GetDeviceCaps(capID); 609 capVal = m_renderDevice->GetDeviceCaps(capID);
609 return FX_ERR_Succeeded; 610 return FWL_Error::Succeeded;
610 } 611 }
611 return FX_ERR_Property_Invalid; 612 return FWL_Error::PropertyInvalid;
612 } 613 }
613 614
614 FX_ERR CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) { 615 FWL_Error CFX_Graphics::IsPrinterDevice(FX_BOOL& isPrinter) {
615 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 616 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
616 isPrinter = m_renderDevice->GetDeviceClass() == FXDC_PRINTER; 617 isPrinter = m_renderDevice->GetDeviceClass() == FXDC_PRINTER;
617 return FX_ERR_Succeeded; 618 return FWL_Error::Succeeded;
618 } 619 }
619 return FX_ERR_Property_Invalid; 620 return FWL_Error::PropertyInvalid;
620 } 621 }
621 622
622 FX_ERR CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) { 623 FWL_Error CFX_Graphics::EnableAntialiasing(FX_BOOL isAntialiasing) {
623 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 624 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
624 m_info.isAntialiasing = isAntialiasing; 625 m_info.isAntialiasing = isAntialiasing;
625 return FX_ERR_Succeeded; 626 return FWL_Error::Succeeded;
626 } 627 }
627 return FX_ERR_Property_Invalid; 628 return FWL_Error::PropertyInvalid;
628 } 629 }
629 630
630 FX_ERR CFX_Graphics::SaveGraphState() { 631 FWL_Error CFX_Graphics::SaveGraphState() {
631 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 632 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
632 m_renderDevice->SaveState(); 633 m_renderDevice->SaveState();
633 m_infoStack.Add(new TInfo(m_info)); 634 m_infoStack.Add(new TInfo(m_info));
634 return FX_ERR_Succeeded; 635 return FWL_Error::Succeeded;
635 } 636 }
636 return FX_ERR_Property_Invalid; 637 return FWL_Error::PropertyInvalid;
637 } 638 }
638 639
639 FX_ERR CFX_Graphics::RestoreGraphState() { 640 FWL_Error CFX_Graphics::RestoreGraphState() {
640 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 641 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
641 m_renderDevice->RestoreState(); 642 m_renderDevice->RestoreState();
642 int32_t size = m_infoStack.GetSize(); 643 int32_t size = m_infoStack.GetSize();
643 if (size <= 0) { 644 if (size <= 0) {
644 return FX_ERR_Intermediate_Value_Invalid; 645 return FWL_Error::IntermediateValueInvalid;
645 } 646 }
646 int32_t topIndex = size - 1; 647 int32_t topIndex = size - 1;
647 std::unique_ptr<TInfo> info(m_infoStack.GetAt(topIndex)); 648 std::unique_ptr<TInfo> info(m_infoStack.GetAt(topIndex));
648 if (!info) 649 if (!info)
649 return FX_ERR_Intermediate_Value_Invalid; 650 return FWL_Error::IntermediateValueInvalid;
650 m_info = *info; 651 m_info = *info;
651 m_infoStack.RemoveAt(topIndex); 652 m_infoStack.RemoveAt(topIndex);
652 return FX_ERR_Succeeded; 653 return FWL_Error::Succeeded;
653 } 654 }
654 return FX_ERR_Property_Invalid; 655 return FWL_Error::PropertyInvalid;
655 } 656 }
656 657
657 FX_ERR CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) const { 658 FWL_Error CFX_Graphics::GetLineCap(CFX_GraphStateData::LineCap& lineCap) const {
658 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 659 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
659 lineCap = m_info.graphState.m_LineCap; 660 lineCap = m_info.graphState.m_LineCap;
660 return FX_ERR_Succeeded; 661 return FWL_Error::Succeeded;
661 } 662 }
662 return FX_ERR_Property_Invalid; 663 return FWL_Error::PropertyInvalid;
663 } 664 }
664 665
665 FX_ERR CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) { 666 FWL_Error CFX_Graphics::SetLineCap(CFX_GraphStateData::LineCap lineCap) {
666 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 667 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
667 m_info.graphState.m_LineCap = lineCap; 668 m_info.graphState.m_LineCap = lineCap;
668 return FX_ERR_Succeeded; 669 return FWL_Error::Succeeded;
669 } 670 }
670 return FX_ERR_Property_Invalid; 671 return FWL_Error::PropertyInvalid;
671 } 672 }
672 673
673 FX_ERR CFX_Graphics::GetDashCount(int32_t& dashCount) const { 674 FWL_Error CFX_Graphics::GetDashCount(int32_t& dashCount) const {
674 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 675 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
675 dashCount = m_info.graphState.m_DashCount; 676 dashCount = m_info.graphState.m_DashCount;
676 return FX_ERR_Succeeded; 677 return FWL_Error::Succeeded;
677 } 678 }
678 return FX_ERR_Property_Invalid; 679 return FWL_Error::PropertyInvalid;
679 } 680 }
680 681
681 FX_ERR CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase, 682 FWL_Error CFX_Graphics::GetLineDash(FX_FLOAT& dashPhase,
682 FX_FLOAT* dashArray) const { 683 FX_FLOAT* dashArray) const {
683 if (!dashArray) 684 if (!dashArray)
684 return FX_ERR_Parameter_Invalid; 685 return FWL_Error::ParameterInvalid;
685 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 686 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
686 dashPhase = m_info.graphState.m_DashPhase; 687 dashPhase = m_info.graphState.m_DashPhase;
687 FXSYS_memcpy(dashArray, m_info.graphState.m_DashArray, 688 FXSYS_memcpy(dashArray, m_info.graphState.m_DashArray,
688 m_info.graphState.m_DashCount * sizeof(FX_FLOAT)); 689 m_info.graphState.m_DashCount * sizeof(FX_FLOAT));
689 return FX_ERR_Succeeded; 690 return FWL_Error::Succeeded;
690 } 691 }
691 return FX_ERR_Property_Invalid; 692 return FWL_Error::PropertyInvalid;
692 } 693 }
693 694
694 FX_ERR CFX_Graphics::SetLineDash(FX_FLOAT dashPhase, 695 FWL_Error CFX_Graphics::SetLineDash(FX_FLOAT dashPhase,
695 FX_FLOAT* dashArray, 696 FX_FLOAT* dashArray,
696 int32_t dashCount) { 697 int32_t dashCount) {
697 if (dashCount > 0 && !dashArray) 698 if (dashCount > 0 && !dashArray)
698 return FX_ERR_Parameter_Invalid; 699 return FWL_Error::ParameterInvalid;
699 700
700 dashCount = dashCount < 0 ? 0 : dashCount; 701 dashCount = dashCount < 0 ? 0 : dashCount;
701 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 702 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
702 FX_FLOAT scale = 1.0; 703 FX_FLOAT scale = 1.0;
703 if (m_info.isActOnDash) { 704 if (m_info.isActOnDash) {
704 scale = m_info.graphState.m_LineWidth; 705 scale = m_info.graphState.m_LineWidth;
705 } 706 }
706 m_info.graphState.m_DashPhase = dashPhase; 707 m_info.graphState.m_DashPhase = dashPhase;
707 m_info.graphState.SetDashCount(dashCount); 708 m_info.graphState.SetDashCount(dashCount);
708 for (int32_t i = 0; i < dashCount; i++) { 709 for (int32_t i = 0; i < dashCount; i++) {
709 m_info.graphState.m_DashArray[i] = dashArray[i] * scale; 710 m_info.graphState.m_DashArray[i] = dashArray[i] * scale;
710 } 711 }
711 return FX_ERR_Succeeded; 712 return FWL_Error::Succeeded;
712 } 713 }
713 return FX_ERR_Property_Invalid; 714 return FWL_Error::PropertyInvalid;
714 } 715 }
715 716
716 FX_ERR CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) { 717 FWL_Error CFX_Graphics::SetLineDash(FX_DashStyle dashStyle) {
717 if (m_type == FX_CONTEXT_Device && m_renderDevice) 718 if (m_type == FX_CONTEXT_Device && m_renderDevice)
718 return RenderDeviceSetLineDash(dashStyle); 719 return RenderDeviceSetLineDash(dashStyle);
719 return FX_ERR_Property_Invalid; 720 return FWL_Error::PropertyInvalid;
720 } 721 }
721 722
722 FX_ERR CFX_Graphics::GetLineJoin(CFX_GraphStateData::LineJoin& lineJoin) const { 723 FWL_Error CFX_Graphics::GetLineJoin(
724 CFX_GraphStateData::LineJoin& lineJoin) const {
723 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 725 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
724 lineJoin = m_info.graphState.m_LineJoin; 726 lineJoin = m_info.graphState.m_LineJoin;
725 return FX_ERR_Succeeded; 727 return FWL_Error::Succeeded;
726 } 728 }
727 return FX_ERR_Property_Invalid; 729 return FWL_Error::PropertyInvalid;
728 } 730 }
729 731
730 FX_ERR CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) { 732 FWL_Error CFX_Graphics::SetLineJoin(CFX_GraphStateData::LineJoin lineJoin) {
731 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 733 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
732 m_info.graphState.m_LineJoin = lineJoin; 734 m_info.graphState.m_LineJoin = lineJoin;
733 return FX_ERR_Succeeded; 735 return FWL_Error::Succeeded;
734 } 736 }
735 return FX_ERR_Property_Invalid; 737 return FWL_Error::PropertyInvalid;
736 } 738 }
737 739
738 FX_ERR CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) const { 740 FWL_Error CFX_Graphics::GetMiterLimit(FX_FLOAT& miterLimit) const {
739 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 741 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
740 miterLimit = m_info.graphState.m_MiterLimit; 742 miterLimit = m_info.graphState.m_MiterLimit;
741 return FX_ERR_Succeeded; 743 return FWL_Error::Succeeded;
742 } 744 }
743 return FX_ERR_Property_Invalid; 745 return FWL_Error::PropertyInvalid;
744 } 746 }
745 747
746 FX_ERR CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) { 748 FWL_Error CFX_Graphics::SetMiterLimit(FX_FLOAT miterLimit) {
747 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 749 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
748 m_info.graphState.m_MiterLimit = miterLimit; 750 m_info.graphState.m_MiterLimit = miterLimit;
749 return FX_ERR_Succeeded; 751 return FWL_Error::Succeeded;
750 } 752 }
751 return FX_ERR_Property_Invalid; 753 return FWL_Error::PropertyInvalid;
752 } 754 }
753 755
754 FX_ERR CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) const { 756 FWL_Error CFX_Graphics::GetLineWidth(FX_FLOAT& lineWidth) const {
755 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 757 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
756 lineWidth = m_info.graphState.m_LineWidth; 758 lineWidth = m_info.graphState.m_LineWidth;
757 return FX_ERR_Succeeded; 759 return FWL_Error::Succeeded;
758 } 760 }
759 return FX_ERR_Property_Invalid; 761 return FWL_Error::PropertyInvalid;
760 } 762 }
761 763
762 FX_ERR CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) { 764 FWL_Error CFX_Graphics::SetLineWidth(FX_FLOAT lineWidth, FX_BOOL isActOnDash) {
763 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 765 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
764 m_info.graphState.m_LineWidth = lineWidth; 766 m_info.graphState.m_LineWidth = lineWidth;
765 m_info.isActOnDash = isActOnDash; 767 m_info.isActOnDash = isActOnDash;
766 return FX_ERR_Succeeded; 768 return FWL_Error::Succeeded;
767 } 769 }
768 return FX_ERR_Property_Invalid; 770 return FWL_Error::PropertyInvalid;
769 } 771 }
770 772
771 FX_ERR CFX_Graphics::GetStrokeAlignment( 773 FWL_Error CFX_Graphics::GetStrokeAlignment(
772 FX_StrokeAlignment& strokeAlignment) const { 774 FX_StrokeAlignment& strokeAlignment) const {
773 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 775 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
774 strokeAlignment = m_info.strokeAlignment; 776 strokeAlignment = m_info.strokeAlignment;
775 return FX_ERR_Succeeded; 777 return FWL_Error::Succeeded;
776 } 778 }
777 return FX_ERR_Property_Invalid; 779 return FWL_Error::PropertyInvalid;
778 } 780 }
779 781
780 FX_ERR CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) { 782 FWL_Error CFX_Graphics::SetStrokeAlignment(FX_StrokeAlignment strokeAlignment) {
781 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 783 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
782 m_info.strokeAlignment = strokeAlignment; 784 m_info.strokeAlignment = strokeAlignment;
783 return FX_ERR_Succeeded; 785 return FWL_Error::Succeeded;
784 } 786 }
785 return FX_ERR_Property_Invalid; 787 return FWL_Error::PropertyInvalid;
786 } 788 }
787 789
788 FX_ERR CFX_Graphics::SetStrokeColor(CFX_Color* color) { 790 FWL_Error CFX_Graphics::SetStrokeColor(CFX_Color* color) {
789 if (!color) 791 if (!color)
790 return FX_ERR_Parameter_Invalid; 792 return FWL_Error::ParameterInvalid;
791 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 793 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
792 m_info.strokeColor = color; 794 m_info.strokeColor = color;
793 return FX_ERR_Succeeded; 795 return FWL_Error::Succeeded;
794 } 796 }
795 return FX_ERR_Property_Invalid; 797 return FWL_Error::PropertyInvalid;
796 } 798 }
797 799
798 FX_ERR CFX_Graphics::SetFillColor(CFX_Color* color) { 800 FWL_Error CFX_Graphics::SetFillColor(CFX_Color* color) {
799 if (!color) 801 if (!color)
800 return FX_ERR_Parameter_Invalid; 802 return FWL_Error::ParameterInvalid;
801 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 803 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
802 m_info.fillColor = color; 804 m_info.fillColor = color;
803 return FX_ERR_Succeeded; 805 return FWL_Error::Succeeded;
804 } 806 }
805 return FX_ERR_Property_Invalid; 807 return FWL_Error::PropertyInvalid;
806 } 808 }
807 809
808 FX_ERR CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) { 810 FWL_Error CFX_Graphics::StrokePath(CFX_Path* path, CFX_Matrix* matrix) {
809 if (!path) 811 if (!path)
810 return FX_ERR_Parameter_Invalid; 812 return FWL_Error::ParameterInvalid;
811 if (m_type == FX_CONTEXT_Device && m_renderDevice) 813 if (m_type == FX_CONTEXT_Device && m_renderDevice)
812 return RenderDeviceStrokePath(path, matrix); 814 return RenderDeviceStrokePath(path, matrix);
813 return FX_ERR_Property_Invalid; 815 return FWL_Error::PropertyInvalid;
814 } 816 }
815 817
816 FX_ERR CFX_Graphics::FillPath(CFX_Path* path, 818 FWL_Error CFX_Graphics::FillPath(CFX_Path* path,
817 FX_FillMode fillMode, 819 FX_FillMode fillMode,
818 CFX_Matrix* matrix) { 820 CFX_Matrix* matrix) {
819 if (!path) 821 if (!path)
820 return FX_ERR_Parameter_Invalid; 822 return FWL_Error::ParameterInvalid;
821 if (m_type == FX_CONTEXT_Device && m_renderDevice) 823 if (m_type == FX_CONTEXT_Device && m_renderDevice)
822 return RenderDeviceFillPath(path, fillMode, matrix); 824 return RenderDeviceFillPath(path, fillMode, matrix);
823 return FX_ERR_Property_Invalid; 825 return FWL_Error::PropertyInvalid;
824 } 826 }
825 827
826 FX_ERR CFX_Graphics::ClipPath(CFX_Path* path, 828 FWL_Error CFX_Graphics::ClipPath(CFX_Path* path,
827 FX_FillMode fillMode, 829 FX_FillMode fillMode,
828 CFX_Matrix* matrix) { 830 CFX_Matrix* matrix) {
829 if (!path) 831 if (!path)
830 return FX_ERR_Parameter_Invalid; 832 return FWL_Error::ParameterInvalid;
831 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 833 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
832 FX_BOOL result = m_renderDevice->SetClip_PathFill( 834 FX_BOOL result = m_renderDevice->SetClip_PathFill(
833 path->GetPathData(), (CFX_Matrix*)matrix, fillMode); 835 path->GetPathData(), (CFX_Matrix*)matrix, fillMode);
834 if (!result) 836 if (!result)
835 return FX_ERR_Indefinite; 837 return FWL_Error::Indefinite;
836 return FX_ERR_Succeeded; 838 return FWL_Error::Succeeded;
837 } 839 }
838 return FX_ERR_Property_Invalid; 840 return FWL_Error::PropertyInvalid;
839 } 841 }
840 842
841 FX_ERR CFX_Graphics::DrawImage(CFX_DIBSource* source, 843 FWL_Error CFX_Graphics::DrawImage(CFX_DIBSource* source,
842 const CFX_PointF& point, 844 const CFX_PointF& point,
843 CFX_Matrix* matrix) { 845 CFX_Matrix* matrix) {
844 if (!source) 846 if (!source)
845 return FX_ERR_Parameter_Invalid; 847 return FWL_Error::ParameterInvalid;
846 if (m_type == FX_CONTEXT_Device && m_renderDevice) 848 if (m_type == FX_CONTEXT_Device && m_renderDevice)
847 return RenderDeviceDrawImage(source, point, matrix); 849 return RenderDeviceDrawImage(source, point, matrix);
848 return FX_ERR_Property_Invalid; 850 return FWL_Error::PropertyInvalid;
849 } 851 }
850 852
851 FX_ERR CFX_Graphics::StretchImage(CFX_DIBSource* source, 853 FWL_Error CFX_Graphics::StretchImage(CFX_DIBSource* source,
852 const CFX_RectF& rect, 854 const CFX_RectF& rect,
853 CFX_Matrix* matrix) { 855 CFX_Matrix* matrix) {
854 if (!source) 856 if (!source)
855 return FX_ERR_Parameter_Invalid; 857 return FWL_Error::ParameterInvalid;
856 if (m_type == FX_CONTEXT_Device && m_renderDevice) 858 if (m_type == FX_CONTEXT_Device && m_renderDevice)
857 return RenderDeviceStretchImage(source, rect, matrix); 859 return RenderDeviceStretchImage(source, rect, matrix);
858 return FX_ERR_Property_Invalid; 860 return FWL_Error::PropertyInvalid;
859 } 861 }
860 862
861 FX_ERR CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) { 863 FWL_Error CFX_Graphics::ConcatMatrix(const CFX_Matrix* matrix) {
862 if (!matrix) 864 if (!matrix)
863 return FX_ERR_Parameter_Invalid; 865 return FWL_Error::ParameterInvalid;
864 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 866 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
865 m_info.CTM.Concat(*matrix); 867 m_info.CTM.Concat(*matrix);
866 return FX_ERR_Succeeded; 868 return FWL_Error::Succeeded;
867 } 869 }
868 return FX_ERR_Property_Invalid; 870 return FWL_Error::PropertyInvalid;
869 } 871 }
870 872
871 CFX_Matrix* CFX_Graphics::GetMatrix() { 873 CFX_Matrix* CFX_Graphics::GetMatrix() {
872 if (m_type == FX_CONTEXT_Device && m_renderDevice) 874 if (m_type == FX_CONTEXT_Device && m_renderDevice)
873 return &m_info.CTM; 875 return &m_info.CTM;
874 return nullptr; 876 return nullptr;
875 } 877 }
876 878
877 FX_ERR CFX_Graphics::GetClipRect(CFX_RectF& rect) const { 879 FWL_Error CFX_Graphics::GetClipRect(CFX_RectF& rect) const {
878 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 880 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
879 FX_RECT r = m_renderDevice->GetClipBox(); 881 FX_RECT r = m_renderDevice->GetClipBox();
880 rect.left = (FX_FLOAT)r.left; 882 rect.left = (FX_FLOAT)r.left;
881 rect.top = (FX_FLOAT)r.top; 883 rect.top = (FX_FLOAT)r.top;
882 rect.width = (FX_FLOAT)r.Width(); 884 rect.width = (FX_FLOAT)r.Width();
883 rect.height = (FX_FLOAT)r.Height(); 885 rect.height = (FX_FLOAT)r.Height();
884 return FX_ERR_Succeeded; 886 return FWL_Error::Succeeded;
885 } 887 }
886 return FX_ERR_Property_Invalid; 888 return FWL_Error::PropertyInvalid;
887 } 889 }
888 890
889 FX_ERR CFX_Graphics::SetClipRect(const CFX_RectF& rect) { 891 FWL_Error CFX_Graphics::SetClipRect(const CFX_RectF& rect) {
890 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 892 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
891 if (!m_renderDevice->SetClip_Rect( 893 if (!m_renderDevice->SetClip_Rect(
892 FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top), 894 FX_RECT(FXSYS_round(rect.left), FXSYS_round(rect.top),
893 FXSYS_round(rect.right()), FXSYS_round(rect.bottom())))) { 895 FXSYS_round(rect.right()), FXSYS_round(rect.bottom())))) {
894 return FX_ERR_Method_Not_Supported; 896 return FWL_Error::MethodNotSupported;
895 } 897 }
896 return FX_ERR_Succeeded; 898 return FWL_Error::Succeeded;
897 } 899 }
898 return FX_ERR_Property_Invalid; 900 return FWL_Error::PropertyInvalid;
899 } 901 }
900 902
901 FX_ERR CFX_Graphics::ClearClip() { 903 FWL_Error CFX_Graphics::ClearClip() {
902 if (m_type == FX_CONTEXT_Device && m_renderDevice) 904 if (m_type == FX_CONTEXT_Device && m_renderDevice)
903 return FX_ERR_Succeeded; 905 return FWL_Error::Succeeded;
904 return FX_ERR_Property_Invalid; 906 return FWL_Error::PropertyInvalid;
905 } 907 }
906 908
907 FX_ERR CFX_Graphics::SetFont(CFX_Font* font) { 909 FWL_Error CFX_Graphics::SetFont(CFX_Font* font) {
908 if (!font) 910 if (!font)
909 return FX_ERR_Parameter_Invalid; 911 return FWL_Error::ParameterInvalid;
910 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 912 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
911 m_info.font = font; 913 m_info.font = font;
912 return FX_ERR_Succeeded; 914 return FWL_Error::Succeeded;
913 } 915 }
914 return FX_ERR_Property_Invalid; 916 return FWL_Error::PropertyInvalid;
915 } 917 }
916 918
917 FX_ERR CFX_Graphics::SetFontSize(const FX_FLOAT size) { 919 FWL_Error CFX_Graphics::SetFontSize(const FX_FLOAT size) {
918 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 920 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
919 m_info.fontSize = size <= 0 ? 1.0f : size; 921 m_info.fontSize = size <= 0 ? 1.0f : size;
920 return FX_ERR_Succeeded; 922 return FWL_Error::Succeeded;
921 } 923 }
922 return FX_ERR_Property_Invalid; 924 return FWL_Error::PropertyInvalid;
923 } 925 }
924 926
925 FX_ERR CFX_Graphics::SetFontHScale(const FX_FLOAT scale) { 927 FWL_Error CFX_Graphics::SetFontHScale(const FX_FLOAT scale) {
926 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 928 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
927 m_info.fontHScale = scale <= 0 ? 1.0f : scale; 929 m_info.fontHScale = scale <= 0 ? 1.0f : scale;
928 return FX_ERR_Succeeded; 930 return FWL_Error::Succeeded;
929 } 931 }
930 return FX_ERR_Property_Invalid; 932 return FWL_Error::PropertyInvalid;
931 } 933 }
932 934
933 FX_ERR CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) { 935 FWL_Error CFX_Graphics::SetCharSpacing(const FX_FLOAT spacing) {
934 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 936 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
935 m_info.fontSpacing = spacing < 0 ? 0 : spacing; 937 m_info.fontSpacing = spacing < 0 ? 0 : spacing;
936 return FX_ERR_Succeeded; 938 return FWL_Error::Succeeded;
937 } 939 }
938 return FX_ERR_Property_Invalid; 940 return FWL_Error::PropertyInvalid;
939 } 941 }
940 942
941 FX_ERR CFX_Graphics::SetTextDrawingMode(const int32_t mode) { 943 FWL_Error CFX_Graphics::SetTextDrawingMode(const int32_t mode) {
942 if (m_type == FX_CONTEXT_Device && m_renderDevice) 944 if (m_type == FX_CONTEXT_Device && m_renderDevice)
943 return FX_ERR_Succeeded; 945 return FWL_Error::Succeeded;
944 return FX_ERR_Property_Invalid; 946 return FWL_Error::PropertyInvalid;
945 } 947 }
946 948
947 FX_ERR CFX_Graphics::ShowText(const CFX_PointF& point, 949 FWL_Error CFX_Graphics::ShowText(const CFX_PointF& point,
948 const CFX_WideString& text, 950 const CFX_WideString& text,
949 CFX_Matrix* matrix) { 951 CFX_Matrix* matrix) {
950 if (m_type == FX_CONTEXT_Device && m_renderDevice) 952 if (m_type == FX_CONTEXT_Device && m_renderDevice)
951 return RenderDeviceShowText(point, text, matrix); 953 return RenderDeviceShowText(point, text, matrix);
952 return FX_ERR_Property_Invalid; 954 return FWL_Error::PropertyInvalid;
953 } 955 }
954 956
955 FX_ERR CFX_Graphics::CalcTextRect(CFX_RectF& rect, 957 FWL_Error CFX_Graphics::CalcTextRect(CFX_RectF& rect,
956 const CFX_WideString& text, 958 const CFX_WideString& text,
957 FX_BOOL isMultiline, 959 FX_BOOL isMultiline,
958 CFX_Matrix* matrix) { 960 CFX_Matrix* matrix) {
959 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 961 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
960 int32_t length = text.GetLength(); 962 int32_t length = text.GetLength();
961 uint32_t* charCodes = FX_Alloc(uint32_t, length); 963 uint32_t* charCodes = FX_Alloc(uint32_t, length);
962 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); 964 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length);
963 CalcTextInfo(text, charCodes, charPos, rect); 965 CalcTextInfo(text, charCodes, charPos, rect);
964 FX_Free(charPos); 966 FX_Free(charPos);
965 FX_Free(charCodes); 967 FX_Free(charCodes);
966 return FX_ERR_Succeeded; 968 return FWL_Error::Succeeded;
967 } 969 }
968 return FX_ERR_Property_Invalid; 970 return FWL_Error::PropertyInvalid;
969 } 971 }
970 972
971 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, 973 FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics,
972 const CFX_Matrix* matrix) { 974 const CFX_Matrix* matrix) {
973 if (!graphics || !graphics->m_renderDevice) 975 if (!graphics || !graphics->m_renderDevice)
974 return FX_ERR_Parameter_Invalid; 976 return FWL_Error::ParameterInvalid;
975 CFX_Matrix m; 977 CFX_Matrix m;
976 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, 978 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
977 m_info.CTM.f); 979 m_info.CTM.f);
978 if (matrix) { 980 if (matrix) {
979 m.Concat(*matrix); 981 m.Concat(*matrix);
980 } 982 }
981 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 983 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
982 CFX_DIBitmap* bitmap = graphics->m_renderDevice->GetBitmap(); 984 CFX_DIBitmap* bitmap = graphics->m_renderDevice->GetBitmap();
983 FX_BOOL result = m_renderDevice->SetDIBits(bitmap, 0, 0); 985 FX_BOOL result = m_renderDevice->SetDIBits(bitmap, 0, 0);
984 if (!result) 986 if (!result)
985 return FX_ERR_Method_Not_Supported; 987 return FWL_Error::MethodNotSupported;
986 return FX_ERR_Succeeded; 988 return FWL_Error::Succeeded;
987 } 989 }
988 return FX_ERR_Property_Invalid; 990 return FWL_Error::PropertyInvalid;
989 } 991 }
990 992
991 FX_ERR CFX_Graphics::Transfer(CFX_Graphics* graphics, 993 FWL_Error CFX_Graphics::Transfer(CFX_Graphics* graphics,
992 FX_FLOAT srcLeft, 994 FX_FLOAT srcLeft,
993 FX_FLOAT srcTop, 995 FX_FLOAT srcTop,
994 const CFX_RectF& dstRect, 996 const CFX_RectF& dstRect,
995 const CFX_Matrix* matrix) { 997 const CFX_Matrix* matrix) {
996 if (!graphics || !graphics->m_renderDevice) 998 if (!graphics || !graphics->m_renderDevice)
997 return FX_ERR_Parameter_Invalid; 999 return FWL_Error::ParameterInvalid;
998 CFX_Matrix m; 1000 CFX_Matrix m;
999 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, 1001 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
1000 m_info.CTM.f); 1002 m_info.CTM.f);
1001 if (matrix) { 1003 if (matrix) {
1002 m.Concat(*matrix); 1004 m.Concat(*matrix);
1003 } 1005 }
1004 if (m_type == FX_CONTEXT_Device && m_renderDevice) { 1006 if (m_type == FX_CONTEXT_Device && m_renderDevice) {
1005 CFX_DIBitmap bmp; 1007 CFX_DIBitmap bmp;
1006 FX_BOOL result = 1008 FX_BOOL result =
1007 bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height, 1009 bmp.Create((int32_t)dstRect.width, (int32_t)dstRect.height,
1008 graphics->m_renderDevice->GetBitmap()->GetFormat()); 1010 graphics->m_renderDevice->GetBitmap()->GetFormat());
1009 if (!result) 1011 if (!result)
1010 return FX_ERR_Intermediate_Value_Invalid; 1012 return FWL_Error::IntermediateValueInvalid;
1011 result = graphics->m_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft, 1013 result = graphics->m_renderDevice->GetDIBits(&bmp, (int32_t)srcLeft,
1012 (int32_t)srcTop); 1014 (int32_t)srcTop);
1013 if (!result) 1015 if (!result)
1014 return FX_ERR_Method_Not_Supported; 1016 return FWL_Error::MethodNotSupported;
1015 result = m_renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left, 1017 result = m_renderDevice->SetDIBits(&bmp, (int32_t)dstRect.left,
1016 (int32_t)dstRect.top); 1018 (int32_t)dstRect.top);
1017 if (!result) 1019 if (!result)
1018 return FX_ERR_Method_Not_Supported; 1020 return FWL_Error::MethodNotSupported;
1019 return FX_ERR_Succeeded; 1021 return FWL_Error::Succeeded;
1020 } 1022 }
1021 return FX_ERR_Property_Invalid; 1023 return FWL_Error::PropertyInvalid;
1022 } 1024 }
1023 1025
1024 CFX_RenderDevice* CFX_Graphics::GetRenderDevice() { 1026 CFX_RenderDevice* CFX_Graphics::GetRenderDevice() {
1025 return m_renderDevice; 1027 return m_renderDevice;
1026 } 1028 }
1027 1029
1028 FX_ERR CFX_Graphics::InverseRect(const CFX_RectF& rect) { 1030 FWL_Error CFX_Graphics::InverseRect(const CFX_RectF& rect) {
1029 if (!m_renderDevice) 1031 if (!m_renderDevice)
1030 return FX_ERR_Property_Invalid; 1032 return FWL_Error::PropertyInvalid;
1031 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); 1033 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
1032 if (!bitmap) 1034 if (!bitmap)
1033 return FX_ERR_Property_Invalid; 1035 return FWL_Error::PropertyInvalid;
1034 CFX_RectF temp(rect); 1036 CFX_RectF temp(rect);
1035 m_info.CTM.TransformRect(temp); 1037 m_info.CTM.TransformRect(temp);
1036 CFX_RectF r; 1038 CFX_RectF r;
1037 r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth()); 1039 r.Set(0, 0, (FX_FLOAT)bitmap->GetWidth(), (FX_FLOAT)bitmap->GetWidth());
1038 r.Intersect(temp); 1040 r.Intersect(temp);
1039 if (r.IsEmpty()) { 1041 if (r.IsEmpty()) {
1040 return FX_ERR_Parameter_Invalid; 1042 return FWL_Error::ParameterInvalid;
1041 } 1043 }
1042 FX_ARGB* pBuf = 1044 FX_ARGB* pBuf =
1043 (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch()); 1045 (FX_ARGB*)(bitmap->GetBuffer() + int32_t(r.top) * bitmap->GetPitch());
1044 int32_t bottom = (int32_t)r.bottom(); 1046 int32_t bottom = (int32_t)r.bottom();
1045 int32_t right = (int32_t)r.right(); 1047 int32_t right = (int32_t)r.right();
1046 for (int32_t i = (int32_t)r.top; i < bottom; i++) { 1048 for (int32_t i = (int32_t)r.top; i < bottom; i++) {
1047 FX_ARGB* pLine = pBuf + (int32_t)r.left; 1049 FX_ARGB* pLine = pBuf + (int32_t)r.left;
1048 for (int32_t j = (int32_t)r.left; j < right; j++) { 1050 for (int32_t j = (int32_t)r.left; j < right; j++) {
1049 FX_ARGB c = *pLine; 1051 FX_ARGB c = *pLine;
1050 *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF)); 1052 *pLine++ = (c & 0xFF000000) | (0xFFFFFF - (c & 0x00FFFFFF));
1051 } 1053 }
1052 pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch()); 1054 pBuf = (FX_ARGB*)((uint8_t*)pBuf + bitmap->GetPitch());
1053 } 1055 }
1054 return FX_ERR_Succeeded; 1056 return FWL_Error::Succeeded;
1055 } 1057 }
1056 1058
1057 FX_ERR CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap, 1059 FWL_Error CFX_Graphics::XorDIBitmap(const CFX_DIBitmap* srcBitmap,
1058 const CFX_RectF& rect) { 1060 const CFX_RectF& rect) {
1059 if (!m_renderDevice) 1061 if (!m_renderDevice)
1060 return FX_ERR_Property_Invalid; 1062 return FWL_Error::PropertyInvalid;
1061 CFX_DIBitmap* dst = m_renderDevice->GetBitmap(); 1063 CFX_DIBitmap* dst = m_renderDevice->GetBitmap();
1062 if (!dst) 1064 if (!dst)
1063 return FX_ERR_Property_Invalid; 1065 return FWL_Error::PropertyInvalid;
1064 CFX_RectF temp(rect); 1066 CFX_RectF temp(rect);
1065 m_info.CTM.TransformRect(temp); 1067 m_info.CTM.TransformRect(temp);
1066 CFX_RectF r; 1068 CFX_RectF r;
1067 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); 1069 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth());
1068 r.Intersect(temp); 1070 r.Intersect(temp);
1069 if (r.IsEmpty()) { 1071 if (r.IsEmpty()) {
1070 return FX_ERR_Parameter_Invalid; 1072 return FWL_Error::ParameterInvalid;
1071 } 1073 }
1072 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + 1074 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() +
1073 int32_t(r.top) * srcBitmap->GetPitch()); 1075 int32_t(r.top) * srcBitmap->GetPitch());
1074 FX_ARGB* pDstBuf = 1076 FX_ARGB* pDstBuf =
1075 (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); 1077 (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch());
1076 int32_t bottom = (int32_t)r.bottom(); 1078 int32_t bottom = (int32_t)r.bottom();
1077 int32_t right = (int32_t)r.right(); 1079 int32_t right = (int32_t)r.right();
1078 for (int32_t i = (int32_t)r.top; i < bottom; i++) { 1080 for (int32_t i = (int32_t)r.top; i < bottom; i++) {
1079 FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; 1081 FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left;
1080 FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; 1082 FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left;
1081 for (int32_t j = (int32_t)r.left; j < right; j++) { 1083 for (int32_t j = (int32_t)r.left; j < right; j++) {
1082 FX_ARGB c = *pDstLine; 1084 FX_ARGB c = *pDstLine;
1083 *pDstLine++ = 1085 *pDstLine++ =
1084 ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)); 1086 ArgbEncode(FXARGB_A(c), (c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF));
1085 pSrcLine++; 1087 pSrcLine++;
1086 } 1088 }
1087 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); 1089 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch());
1088 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); 1090 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch());
1089 } 1091 }
1090 return FX_ERR_Succeeded; 1092 return FWL_Error::Succeeded;
1091 } 1093 }
1092 1094
1093 FX_ERR CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap, 1095 FWL_Error CFX_Graphics::EqvDIBitmap(const CFX_DIBitmap* srcBitmap,
1094 const CFX_RectF& rect) { 1096 const CFX_RectF& rect) {
1095 if (!m_renderDevice) 1097 if (!m_renderDevice)
1096 return FX_ERR_Property_Invalid; 1098 return FWL_Error::PropertyInvalid;
1097 CFX_DIBitmap* dst = m_renderDevice->GetBitmap(); 1099 CFX_DIBitmap* dst = m_renderDevice->GetBitmap();
1098 if (!dst) 1100 if (!dst)
1099 return FX_ERR_Property_Invalid; 1101 return FWL_Error::PropertyInvalid;
1100 CFX_RectF temp(rect); 1102 CFX_RectF temp(rect);
1101 m_info.CTM.TransformRect(temp); 1103 m_info.CTM.TransformRect(temp);
1102 CFX_RectF r; 1104 CFX_RectF r;
1103 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth()); 1105 r.Set(0, 0, (FX_FLOAT)dst->GetWidth(), (FX_FLOAT)dst->GetWidth());
1104 r.Intersect(temp); 1106 r.Intersect(temp);
1105 if (r.IsEmpty()) { 1107 if (r.IsEmpty()) {
1106 return FX_ERR_Parameter_Invalid; 1108 return FWL_Error::ParameterInvalid;
1107 } 1109 }
1108 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() + 1110 FX_ARGB* pSrcBuf = (FX_ARGB*)(srcBitmap->GetBuffer() +
1109 int32_t(r.top) * srcBitmap->GetPitch()); 1111 int32_t(r.top) * srcBitmap->GetPitch());
1110 FX_ARGB* pDstBuf = 1112 FX_ARGB* pDstBuf =
1111 (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch()); 1113 (FX_ARGB*)(dst->GetBuffer() + int32_t(r.top) * dst->GetPitch());
1112 int32_t bottom = (int32_t)r.bottom(); 1114 int32_t bottom = (int32_t)r.bottom();
1113 int32_t right = (int32_t)r.right(); 1115 int32_t right = (int32_t)r.right();
1114 for (int32_t i = (int32_t)r.top; i < bottom; i++) { 1116 for (int32_t i = (int32_t)r.top; i < bottom; i++) {
1115 FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left; 1117 FX_ARGB* pSrcLine = pSrcBuf + (int32_t)r.left;
1116 FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left; 1118 FX_ARGB* pDstLine = pDstBuf + (int32_t)r.left;
1117 for (int32_t j = (int32_t)r.left; j < right; j++) { 1119 for (int32_t j = (int32_t)r.left; j < right; j++) {
1118 FX_ARGB c = *pDstLine; 1120 FX_ARGB c = *pDstLine;
1119 *pDstLine++ = 1121 *pDstLine++ =
1120 ArgbEncode(FXARGB_A(c), ~((c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF))); 1122 ArgbEncode(FXARGB_A(c), ~((c & 0xFFFFFF) ^ (*pSrcLine & 0xFFFFFF)));
1121 pSrcLine++; 1123 pSrcLine++;
1122 } 1124 }
1123 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch()); 1125 pSrcBuf = (FX_ARGB*)((uint8_t*)pSrcBuf + srcBitmap->GetPitch());
1124 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch()); 1126 pDstBuf = (FX_ARGB*)((uint8_t*)pDstBuf + dst->GetPitch());
1125 } 1127 }
1126 return FX_ERR_Succeeded; 1128 return FWL_Error::Succeeded;
1127 } 1129 }
1128 1130
1129 FX_ERR CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) { 1131 FWL_Error CFX_Graphics::RenderDeviceSetLineDash(FX_DashStyle dashStyle) {
1130 switch (dashStyle) { 1132 switch (dashStyle) {
1131 case FX_DASHSTYLE_Solid: { 1133 case FX_DASHSTYLE_Solid: {
1132 m_info.graphState.SetDashCount(0); 1134 m_info.graphState.SetDashCount(0);
1133 return FX_ERR_Succeeded; 1135 return FWL_Error::Succeeded;
1134 } 1136 }
1135 case FX_DASHSTYLE_Dash: { 1137 case FX_DASHSTYLE_Dash: {
1136 FX_FLOAT dashArray[] = {3, 1}; 1138 FX_FLOAT dashArray[] = {3, 1};
1137 SetLineDash(0, dashArray, 2); 1139 SetLineDash(0, dashArray, 2);
1138 return FX_ERR_Succeeded; 1140 return FWL_Error::Succeeded;
1139 } 1141 }
1140 case FX_DASHSTYLE_Dot: { 1142 case FX_DASHSTYLE_Dot: {
1141 FX_FLOAT dashArray[] = {1, 1}; 1143 FX_FLOAT dashArray[] = {1, 1};
1142 SetLineDash(0, dashArray, 2); 1144 SetLineDash(0, dashArray, 2);
1143 return FX_ERR_Succeeded; 1145 return FWL_Error::Succeeded;
1144 } 1146 }
1145 case FX_DASHSTYLE_DashDot: { 1147 case FX_DASHSTYLE_DashDot: {
1146 FX_FLOAT dashArray[] = {3, 1, 1, 1}; 1148 FX_FLOAT dashArray[] = {3, 1, 1, 1};
1147 SetLineDash(0, dashArray, 4); 1149 SetLineDash(0, dashArray, 4);
1148 return FX_ERR_Succeeded; 1150 return FWL_Error::Succeeded;
1149 } 1151 }
1150 case FX_DASHSTYLE_DashDotDot: { 1152 case FX_DASHSTYLE_DashDotDot: {
1151 FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1}; 1153 FX_FLOAT dashArray[] = {4, 1, 2, 1, 2, 1};
1152 SetLineDash(0, dashArray, 6); 1154 SetLineDash(0, dashArray, 6);
1153 return FX_ERR_Succeeded; 1155 return FWL_Error::Succeeded;
1154 } 1156 }
1155 default: 1157 default:
1156 return FX_ERR_Parameter_Invalid; 1158 return FWL_Error::ParameterInvalid;
1157 } 1159 }
1158 } 1160 }
1159 1161
1160 FX_ERR CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path, 1162 FWL_Error CFX_Graphics::RenderDeviceStrokePath(CFX_Path* path,
1161 CFX_Matrix* matrix) { 1163 CFX_Matrix* matrix) {
1162 if (!m_info.strokeColor) 1164 if (!m_info.strokeColor)
1163 return FX_ERR_Property_Invalid; 1165 return FWL_Error::PropertyInvalid;
1164 CFX_Matrix m; 1166 CFX_Matrix m;
1165 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, 1167 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
1166 m_info.CTM.f); 1168 m_info.CTM.f);
1167 if (matrix) { 1169 if (matrix) {
1168 m.Concat(*matrix); 1170 m.Concat(*matrix);
1169 } 1171 }
1170 switch (m_info.strokeColor->m_type) { 1172 switch (m_info.strokeColor->m_type) {
1171 case FX_COLOR_Solid: { 1173 case FX_COLOR_Solid: {
1172 FX_BOOL result = m_renderDevice->DrawPath( 1174 FX_BOOL result = m_renderDevice->DrawPath(
1173 path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState, 0x0, 1175 path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState, 0x0,
1174 m_info.strokeColor->m_info.argb, 0); 1176 m_info.strokeColor->m_info.argb, 0);
1175 if (!result) 1177 if (!result)
1176 return FX_ERR_Indefinite; 1178 return FWL_Error::Indefinite;
1177 return FX_ERR_Succeeded; 1179 return FWL_Error::Succeeded;
1178 } 1180 }
1179 case FX_COLOR_Pattern: 1181 case FX_COLOR_Pattern:
1180 return StrokePathWithPattern(path, &m); 1182 return StrokePathWithPattern(path, &m);
1181 case FX_COLOR_Shading: 1183 case FX_COLOR_Shading:
1182 return StrokePathWithShading(path, &m); 1184 return StrokePathWithShading(path, &m);
1183 default: 1185 default:
1184 return FX_ERR_Property_Invalid; 1186 return FWL_Error::PropertyInvalid;
1185 } 1187 }
1186 } 1188 }
1187 1189
1188 FX_ERR CFX_Graphics::RenderDeviceFillPath(CFX_Path* path, 1190 FWL_Error CFX_Graphics::RenderDeviceFillPath(CFX_Path* path,
1189 FX_FillMode fillMode, 1191 FX_FillMode fillMode,
1190 CFX_Matrix* matrix) { 1192 CFX_Matrix* matrix) {
1191 if (!m_info.fillColor) 1193 if (!m_info.fillColor)
1192 return FX_ERR_Property_Invalid; 1194 return FWL_Error::PropertyInvalid;
1193 CFX_Matrix m; 1195 CFX_Matrix m;
1194 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, 1196 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
1195 m_info.CTM.f); 1197 m_info.CTM.f);
1196 if (matrix) { 1198 if (matrix) {
1197 m.Concat(*matrix); 1199 m.Concat(*matrix);
1198 } 1200 }
1199 switch (m_info.fillColor->m_type) { 1201 switch (m_info.fillColor->m_type) {
1200 case FX_COLOR_Solid: { 1202 case FX_COLOR_Solid: {
1201 FX_BOOL result = m_renderDevice->DrawPath( 1203 FX_BOOL result = m_renderDevice->DrawPath(
1202 path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState, 1204 path->GetPathData(), (CFX_Matrix*)&m, &m_info.graphState,
1203 m_info.fillColor->m_info.argb, 0x0, fillMode); 1205 m_info.fillColor->m_info.argb, 0x0, fillMode);
1204 if (!result) 1206 if (!result)
1205 return FX_ERR_Indefinite; 1207 return FWL_Error::Indefinite;
1206 return FX_ERR_Succeeded; 1208 return FWL_Error::Succeeded;
1207 } 1209 }
1208 case FX_COLOR_Pattern: 1210 case FX_COLOR_Pattern:
1209 return FillPathWithPattern(path, fillMode, &m); 1211 return FillPathWithPattern(path, fillMode, &m);
1210 case FX_COLOR_Shading: 1212 case FX_COLOR_Shading:
1211 return FillPathWithShading(path, fillMode, &m); 1213 return FillPathWithShading(path, fillMode, &m);
1212 default: 1214 default:
1213 return FX_ERR_Property_Invalid; 1215 return FWL_Error::PropertyInvalid;
1214 } 1216 }
1215 } 1217 }
1216 1218
1217 FX_ERR CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source, 1219 FWL_Error CFX_Graphics::RenderDeviceDrawImage(CFX_DIBSource* source,
1218 const CFX_PointF& point, 1220 const CFX_PointF& point,
1219 CFX_Matrix* matrix) { 1221 CFX_Matrix* matrix) {
1220 CFX_Matrix m1; 1222 CFX_Matrix m1;
1221 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, 1223 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
1222 m_info.CTM.f); 1224 m_info.CTM.f);
1223 if (matrix) { 1225 if (matrix) {
1224 m1.Concat(*matrix); 1226 m1.Concat(*matrix);
1225 } 1227 }
1226 CFX_Matrix m2; 1228 CFX_Matrix m2;
1227 m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(), 1229 m2.Set((FX_FLOAT)source->GetWidth(), 0.0, 0.0, (FX_FLOAT)source->GetHeight(),
1228 point.x, point.y); 1230 point.x, point.y);
1229 m2.Concat(m1); 1231 m2.Concat(m1);
1230 int32_t left, top; 1232 int32_t left, top;
1231 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(FALSE, TRUE)); 1233 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(FALSE, TRUE));
1232 std::unique_ptr<CFX_DIBitmap> bmp2( 1234 std::unique_ptr<CFX_DIBitmap> bmp2(
1233 bmp1->TransformTo((CFX_Matrix*)&m2, left, top)); 1235 bmp1->TransformTo((CFX_Matrix*)&m2, left, top));
1234 CFX_RectF r; 1236 CFX_RectF r;
1235 GetClipRect(r); 1237 GetClipRect(r);
1236 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); 1238 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
1237 CFX_DIBitmap bmp; 1239 CFX_DIBitmap bmp;
1238 if (bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb) && 1240 if (bmp.Create(bitmap->GetWidth(), bitmap->GetHeight(), FXDIB_Argb) &&
1239 m_renderDevice->GetDIBits(&bmp, 0, 0) && 1241 m_renderDevice->GetDIBits(&bmp, 0, 0) &&
1240 bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top), 1242 bmp.TransferBitmap(FXSYS_round(r.left), FXSYS_round(r.top),
1241 FXSYS_round(r.Width()), FXSYS_round(r.Height()), 1243 FXSYS_round(r.Width()), FXSYS_round(r.Height()),
1242 bmp2.get(), FXSYS_round(r.left - left), 1244 bmp2.get(), FXSYS_round(r.left - left),
1243 FXSYS_round(r.top - top)) && 1245 FXSYS_round(r.top - top)) &&
1244 m_renderDevice->SetDIBits(&bmp, 0, 0)) { 1246 m_renderDevice->SetDIBits(&bmp, 0, 0)) {
1245 return FX_ERR_Succeeded; 1247 return FWL_Error::Succeeded;
1246 } 1248 }
1247 return FX_ERR_Indefinite; 1249 return FWL_Error::Indefinite;
1248 } 1250 }
1249 1251
1250 FX_ERR CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source, 1252 FWL_Error CFX_Graphics::RenderDeviceStretchImage(CFX_DIBSource* source,
1251 const CFX_RectF& rect, 1253 const CFX_RectF& rect,
1252 CFX_Matrix* matrix) { 1254 CFX_Matrix* matrix) {
1253 CFX_Matrix m1; 1255 CFX_Matrix m1;
1254 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, 1256 m1.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
1255 m_info.CTM.f); 1257 m_info.CTM.f);
1256 if (matrix) { 1258 if (matrix) {
1257 m1.Concat(*matrix); 1259 m1.Concat(*matrix);
1258 } 1260 }
1259 std::unique_ptr<CFX_DIBitmap> bmp1( 1261 std::unique_ptr<CFX_DIBitmap> bmp1(
1260 source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height())); 1262 source->StretchTo((int32_t)rect.Width(), (int32_t)rect.Height()));
1261 CFX_Matrix m2; 1263 CFX_Matrix m2;
1262 m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top); 1264 m2.Set(rect.Width(), 0.0, 0.0, rect.Height(), rect.left, rect.top);
1263 m2.Concat(m1); 1265 m2.Concat(m1);
1264 int32_t left, top; 1266 int32_t left, top;
1265 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->FlipImage(FALSE, TRUE)); 1267 std::unique_ptr<CFX_DIBitmap> bmp2(bmp1->FlipImage(FALSE, TRUE));
1266 std::unique_ptr<CFX_DIBitmap> bmp3( 1268 std::unique_ptr<CFX_DIBitmap> bmp3(
1267 bmp2->TransformTo((CFX_Matrix*)&m2, left, top)); 1269 bmp2->TransformTo((CFX_Matrix*)&m2, left, top));
1268 CFX_RectF r; 1270 CFX_RectF r;
1269 GetClipRect(r); 1271 GetClipRect(r);
1270 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); 1272 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
1271 if (bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top), 1273 if (bitmap->CompositeBitmap(FXSYS_round(r.left), FXSYS_round(r.top),
1272 FXSYS_round(r.Width()), FXSYS_round(r.Height()), 1274 FXSYS_round(r.Width()), FXSYS_round(r.Height()),
1273 bmp3.get(), FXSYS_round(r.left - left), 1275 bmp3.get(), FXSYS_round(r.left - left),
1274 FXSYS_round(r.top - top))) { 1276 FXSYS_round(r.top - top))) {
1275 return FX_ERR_Succeeded; 1277 return FWL_Error::Succeeded;
1276 } 1278 }
1277 return FX_ERR_Indefinite; 1279 return FWL_Error::Indefinite;
1278 } 1280 }
1279 1281
1280 FX_ERR CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point, 1282 FWL_Error CFX_Graphics::RenderDeviceShowText(const CFX_PointF& point,
1281 const CFX_WideString& text, 1283 const CFX_WideString& text,
1282 CFX_Matrix* matrix) { 1284 CFX_Matrix* matrix) {
1283 int32_t length = text.GetLength(); 1285 int32_t length = text.GetLength();
1284 uint32_t* charCodes = FX_Alloc(uint32_t, length); 1286 uint32_t* charCodes = FX_Alloc(uint32_t, length);
1285 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length); 1287 FXTEXT_CHARPOS* charPos = FX_Alloc(FXTEXT_CHARPOS, length);
1286 CFX_RectF rect; 1288 CFX_RectF rect;
1287 rect.Set(point.x, point.y, 0, 0); 1289 rect.Set(point.x, point.y, 0, 0);
1288 CalcTextInfo(text, charCodes, charPos, rect); 1290 CalcTextInfo(text, charCodes, charPos, rect);
1289 CFX_Matrix m; 1291 CFX_Matrix m;
1290 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e, 1292 m.Set(m_info.CTM.a, m_info.CTM.b, m_info.CTM.c, m_info.CTM.d, m_info.CTM.e,
1291 m_info.CTM.f); 1293 m_info.CTM.f);
1292 m.Translate(0, m_info.fontSize * m_info.fontHScale); 1294 m.Translate(0, m_info.fontSize * m_info.fontHScale);
1293 if (matrix) { 1295 if (matrix) {
1294 m.Concat(*matrix); 1296 m.Concat(*matrix);
1295 } 1297 }
1296 FX_BOOL result = m_renderDevice->DrawNormalText( 1298 FX_BOOL result = m_renderDevice->DrawNormalText(
1297 length, charPos, m_info.font, CFX_GEModule::Get()->GetFontCache(), 1299 length, charPos, m_info.font, CFX_GEModule::Get()->GetFontCache(),
1298 -m_info.fontSize * m_info.fontHScale, (CFX_Matrix*)&m, 1300 -m_info.fontSize * m_info.fontHScale, (CFX_Matrix*)&m,
1299 m_info.fillColor->m_info.argb, FXTEXT_CLEARTYPE); 1301 m_info.fillColor->m_info.argb, FXTEXT_CLEARTYPE);
1300 if (!result) 1302 if (!result)
1301 return FX_ERR_Indefinite; 1303 return FWL_Error::Indefinite;
1302 FX_Free(charPos); 1304 FX_Free(charPos);
1303 FX_Free(charCodes); 1305 FX_Free(charCodes);
1304 return FX_ERR_Succeeded; 1306 return FWL_Error::Succeeded;
1305 } 1307 }
1306 1308
1307 FX_ERR CFX_Graphics::StrokePathWithPattern(CFX_Path* path, CFX_Matrix* matrix) { 1309 FWL_Error CFX_Graphics::StrokePathWithPattern(CFX_Path* path,
1308 return FX_ERR_Method_Not_Supported; 1310 CFX_Matrix* matrix) {
1311 return FWL_Error::MethodNotSupported;
1309 } 1312 }
1310 1313
1311 FX_ERR CFX_Graphics::StrokePathWithShading(CFX_Path* path, CFX_Matrix* matrix) { 1314 FWL_Error CFX_Graphics::StrokePathWithShading(CFX_Path* path,
1312 return FX_ERR_Method_Not_Supported; 1315 CFX_Matrix* matrix) {
1316 return FWL_Error::MethodNotSupported;
1313 } 1317 }
1314 1318
1315 FX_ERR CFX_Graphics::FillPathWithPattern(CFX_Path* path, 1319 FWL_Error CFX_Graphics::FillPathWithPattern(CFX_Path* path,
1316 FX_FillMode fillMode, 1320 FX_FillMode fillMode,
1317 CFX_Matrix* matrix) { 1321 CFX_Matrix* matrix) {
1318 CFX_Pattern* pattern = m_info.fillColor->m_info.pattern; 1322 CFX_Pattern* pattern = m_info.fillColor->m_info.pattern;
1319 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); 1323 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
1320 int32_t width = bitmap->GetWidth(); 1324 int32_t width = bitmap->GetWidth();
1321 int32_t height = bitmap->GetHeight(); 1325 int32_t height = bitmap->GetHeight();
1322 CFX_DIBitmap bmp; 1326 CFX_DIBitmap bmp;
1323 bmp.Create(width, height, FXDIB_Argb); 1327 bmp.Create(width, height, FXDIB_Argb);
1324 m_renderDevice->GetDIBits(&bmp, 0, 0); 1328 m_renderDevice->GetDIBits(&bmp, 0, 0);
1325 1329
1326 FX_HatchStyle hatchStyle = m_info.fillColor->m_info.pattern->m_hatchStyle; 1330 FX_HatchStyle hatchStyle = m_info.fillColor->m_info.pattern->m_hatchStyle;
1327 if (hatchStyle < FX_HATCHSTYLE_Horizontal || 1331 if (hatchStyle < FX_HATCHSTYLE_Horizontal ||
1328 hatchStyle > FX_HATCHSTYLE_SolidDiamond) { 1332 hatchStyle > FX_HATCHSTYLE_SolidDiamond) {
1329 return FX_ERR_Intermediate_Value_Invalid; 1333 return FWL_Error::IntermediateValueInvalid;
1330 } 1334 }
1331 const FX_HATCHDATA& data = hatchBitmapData[hatchStyle]; 1335 const FX_HATCHDATA& data = hatchBitmapData[hatchStyle];
1332 CFX_DIBitmap mask; 1336 CFX_DIBitmap mask;
1333 mask.Create(data.width, data.height, FXDIB_1bppMask); 1337 mask.Create(data.width, data.height, FXDIB_1bppMask);
1334 FXSYS_memcpy(mask.GetBuffer(), data.maskBits, mask.GetPitch() * data.height); 1338 FXSYS_memcpy(mask.GetBuffer(), data.maskBits, mask.GetPitch() * data.height);
1335 CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox(); 1339 CFX_FloatRect rectf = path->GetPathData()->GetBoundingBox();
1336 if (matrix) { 1340 if (matrix) {
1337 rectf.Transform((const CFX_Matrix*)matrix); 1341 rectf.Transform((const CFX_Matrix*)matrix);
1338 } 1342 }
1339 FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), 1343 FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top),
1340 FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); 1344 FXSYS_round(rectf.right), FXSYS_round(rectf.bottom));
1341 CFX_FxgeDevice device; 1345 CFX_FxgeDevice device;
1342 device.Attach(&bmp); 1346 device.Attach(&bmp);
1343 device.FillRect(&rect, m_info.fillColor->m_info.pattern->m_backArgb); 1347 device.FillRect(&rect, m_info.fillColor->m_info.pattern->m_backArgb);
1344 for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) { 1348 for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) {
1345 for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { 1349 for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) {
1346 device.SetBitMask(&mask, i, j, 1350 device.SetBitMask(&mask, i, j,
1347 m_info.fillColor->m_info.pattern->m_foreArgb); 1351 m_info.fillColor->m_info.pattern->m_foreArgb);
1348 } 1352 }
1349 } 1353 }
1350 1354
1351 m_renderDevice->SaveState(); 1355 m_renderDevice->SaveState();
1352 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, 1356 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix,
1353 fillMode); 1357 fillMode);
1354 SetDIBitsWithMatrix(&bmp, &pattern->m_matrix); 1358 SetDIBitsWithMatrix(&bmp, &pattern->m_matrix);
1355 m_renderDevice->RestoreState(); 1359 m_renderDevice->RestoreState();
1356 return FX_ERR_Succeeded; 1360 return FWL_Error::Succeeded;
1357 } 1361 }
1358 1362
1359 FX_ERR CFX_Graphics::FillPathWithShading(CFX_Path* path, 1363 FWL_Error CFX_Graphics::FillPathWithShading(CFX_Path* path,
1360 FX_FillMode fillMode, 1364 FX_FillMode fillMode,
1361 CFX_Matrix* matrix) { 1365 CFX_Matrix* matrix) {
1362 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap(); 1366 CFX_DIBitmap* bitmap = m_renderDevice->GetBitmap();
1363 int32_t width = bitmap->GetWidth(); 1367 int32_t width = bitmap->GetWidth();
1364 int32_t height = bitmap->GetHeight(); 1368 int32_t height = bitmap->GetHeight();
1365 FX_FLOAT start_x = m_info.fillColor->m_shading->m_beginPoint.x; 1369 FX_FLOAT start_x = m_info.fillColor->m_shading->m_beginPoint.x;
1366 FX_FLOAT start_y = m_info.fillColor->m_shading->m_beginPoint.y; 1370 FX_FLOAT start_y = m_info.fillColor->m_shading->m_beginPoint.y;
1367 FX_FLOAT end_x = m_info.fillColor->m_shading->m_endPoint.x; 1371 FX_FLOAT end_x = m_info.fillColor->m_shading->m_endPoint.x;
1368 FX_FLOAT end_y = m_info.fillColor->m_shading->m_endPoint.y; 1372 FX_FLOAT end_y = m_info.fillColor->m_shading->m_endPoint.y;
1369 CFX_DIBitmap bmp; 1373 CFX_DIBitmap bmp;
1370 bmp.Create(width, height, FXDIB_Argb); 1374 bmp.Create(width, height, FXDIB_Argb);
1371 m_renderDevice->GetDIBits(&bmp, 0, 0); 1375 m_renderDevice->GetDIBits(&bmp, 0, 0);
1372 int32_t pitch = bmp.GetPitch(); 1376 int32_t pitch = bmp.GetPitch();
1373 FX_BOOL result = FALSE; 1377 bool result = false;
1374 switch (m_info.fillColor->m_shading->m_type) { 1378 switch (m_info.fillColor->m_shading->m_type) {
1375 case FX_SHADING_Axial: { 1379 case FX_SHADING_Axial: {
1376 FX_FLOAT x_span = end_x - start_x; 1380 FX_FLOAT x_span = end_x - start_x;
1377 FX_FLOAT y_span = end_y - start_y; 1381 FX_FLOAT y_span = end_y - start_y;
1378 FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span); 1382 FX_FLOAT axis_len_square = (x_span * x_span) + (y_span * y_span);
1379 for (int32_t row = 0; row < height; row++) { 1383 for (int32_t row = 0; row < height; row++) {
1380 uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch); 1384 uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch);
1381 for (int32_t column = 0; column < width; column++) { 1385 for (int32_t column = 0; column < width; column++) {
1382 FX_FLOAT x = (FX_FLOAT)(column); 1386 FX_FLOAT x = (FX_FLOAT)(column);
1383 FX_FLOAT y = (FX_FLOAT)(row); 1387 FX_FLOAT y = (FX_FLOAT)(row);
1384 FX_FLOAT scale = 1388 FX_FLOAT scale =
1385 (((x - start_x) * x_span) + ((y - start_y) * y_span)) / 1389 (((x - start_x) * x_span) + ((y - start_y) * y_span)) /
1386 axis_len_square; 1390 axis_len_square;
1387 if (scale < 0) { 1391 if (scale < 0) {
1388 if (!m_info.fillColor->m_shading->m_isExtendedBegin) { 1392 if (!m_info.fillColor->m_shading->m_isExtendedBegin) {
1389 continue; 1393 continue;
1390 } 1394 }
1391 scale = 0; 1395 scale = 0;
1392 } else if (scale > 1.0f) { 1396 } else if (scale > 1.0f) {
1393 if (!m_info.fillColor->m_shading->m_isExtendedEnd) { 1397 if (!m_info.fillColor->m_shading->m_isExtendedEnd) {
1394 continue; 1398 continue;
1395 } 1399 }
1396 scale = 1.0f; 1400 scale = 1.0f;
1397 } 1401 }
1398 int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1)); 1402 int32_t index = (int32_t)(scale * (FX_SHADING_Steps - 1));
1399 dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index]; 1403 dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index];
1400 } 1404 }
1401 } 1405 }
1402 result = TRUE; 1406 result = true;
1403 break; 1407 break;
1404 } 1408 }
1405 case FX_SHADING_Radial: { 1409 case FX_SHADING_Radial: {
1406 FX_FLOAT start_r = m_info.fillColor->m_shading->m_beginRadius; 1410 FX_FLOAT start_r = m_info.fillColor->m_shading->m_beginRadius;
1407 FX_FLOAT end_r = m_info.fillColor->m_shading->m_endRadius; 1411 FX_FLOAT end_r = m_info.fillColor->m_shading->m_endRadius;
1408 FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) + 1412 FX_FLOAT a = ((start_x - end_x) * (start_x - end_x)) +
1409 ((start_y - end_y) * (start_y - end_y)) - 1413 ((start_y - end_y) * (start_y - end_y)) -
1410 ((start_r - end_r) * (start_r - end_r)); 1414 ((start_r - end_r) * (start_r - end_r));
1411 for (int32_t row = 0; row < height; row++) { 1415 for (int32_t row = 0; row < height; row++) {
1412 uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch); 1416 uint32_t* dib_buf = (uint32_t*)(bmp.GetBuffer() + row * pitch);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 if (s > 1.0f) { 1457 if (s > 1.0f) {
1454 if (!m_info.fillColor->m_shading->m_isExtendedEnd) { 1458 if (!m_info.fillColor->m_shading->m_isExtendedEnd) {
1455 continue; 1459 continue;
1456 } 1460 }
1457 s = 1.0f; 1461 s = 1.0f;
1458 } 1462 }
1459 int index = (int32_t)(s * (FX_SHADING_Steps - 1)); 1463 int index = (int32_t)(s * (FX_SHADING_Steps - 1));
1460 dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index]; 1464 dib_buf[column] = m_info.fillColor->m_shading->m_argbArray[index];
1461 } 1465 }
1462 } 1466 }
1463 result = TRUE; 1467 result = true;
1464 break; 1468 break;
1465 } 1469 }
1466 default: { result = FALSE; } 1470 default: {
1471 result = false;
1472 break;
1473 }
1467 } 1474 }
1468 if (result) { 1475 if (result) {
1469 m_renderDevice->SaveState(); 1476 m_renderDevice->SaveState();
1470 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix, 1477 m_renderDevice->SetClip_PathFill(path->GetPathData(), (CFX_Matrix*)matrix,
1471 fillMode); 1478 fillMode);
1472 SetDIBitsWithMatrix(&bmp, matrix); 1479 SetDIBitsWithMatrix(&bmp, matrix);
1473 m_renderDevice->RestoreState(); 1480 m_renderDevice->RestoreState();
1474 } 1481 }
1475 return result; 1482 return result ? FWL_Error::Succeeded : FWL_Error::PropertyInvalid;
1476 } 1483 }
1477 1484
1478 FX_ERR CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source, 1485 FWL_Error CFX_Graphics::SetDIBitsWithMatrix(CFX_DIBSource* source,
1479 CFX_Matrix* matrix) { 1486 CFX_Matrix* matrix) {
1480 if (matrix->IsIdentity()) { 1487 if (matrix->IsIdentity()) {
1481 m_renderDevice->SetDIBits(source, 0, 0); 1488 m_renderDevice->SetDIBits(source, 0, 0);
1482 } else { 1489 } else {
1483 CFX_Matrix m; 1490 CFX_Matrix m;
1484 m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0, 1491 m.Set((FX_FLOAT)source->GetWidth(), 0, 0, (FX_FLOAT)source->GetHeight(), 0,
1485 0); 1492 0);
1486 m.Concat(*matrix); 1493 m.Concat(*matrix);
1487 int32_t left, top; 1494 int32_t left, top;
1488 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(FALSE, TRUE)); 1495 std::unique_ptr<CFX_DIBitmap> bmp1(source->FlipImage(FALSE, TRUE));
1489 std::unique_ptr<CFX_DIBitmap> bmp2( 1496 std::unique_ptr<CFX_DIBitmap> bmp2(
1490 bmp1->TransformTo((CFX_Matrix*)&m, left, top)); 1497 bmp1->TransformTo((CFX_Matrix*)&m, left, top));
1491 m_renderDevice->SetDIBits(bmp2.get(), left, top); 1498 m_renderDevice->SetDIBits(bmp2.get(), left, top);
1492 } 1499 }
1493 return FX_ERR_Succeeded; 1500 return FWL_Error::Succeeded;
1494 } 1501 }
1495 1502
1496 FX_ERR CFX_Graphics::CalcTextInfo(const CFX_WideString& text, 1503 FWL_Error CFX_Graphics::CalcTextInfo(const CFX_WideString& text,
1497 uint32_t* charCodes, 1504 uint32_t* charCodes,
1498 FXTEXT_CHARPOS* charPos, 1505 FXTEXT_CHARPOS* charPos,
1499 CFX_RectF& rect) { 1506 CFX_RectF& rect) {
1500 std::unique_ptr<CFX_UnicodeEncoding> encoding( 1507 std::unique_ptr<CFX_UnicodeEncoding> encoding(
1501 new CFX_UnicodeEncoding(m_info.font)); 1508 new CFX_UnicodeEncoding(m_info.font));
1502 int32_t length = text.GetLength(); 1509 int32_t length = text.GetLength();
1503 FX_FLOAT penX = (FX_FLOAT)rect.left; 1510 FX_FLOAT penX = (FX_FLOAT)rect.left;
1504 FX_FLOAT penY = (FX_FLOAT)rect.top; 1511 FX_FLOAT penY = (FX_FLOAT)rect.top;
1505 FX_FLOAT left = (FX_FLOAT)(0); 1512 FX_FLOAT left = (FX_FLOAT)(0);
1506 FX_FLOAT top = (FX_FLOAT)(0); 1513 FX_FLOAT top = (FX_FLOAT)(0);
1507 charCodes[0] = text.GetAt(0); 1514 charCodes[0] = text.GetAt(0);
1508 charPos[0].m_OriginX = penX + left; 1515 charPos[0].m_OriginX = penX + left;
1509 charPos[0].m_OriginY = penY + top; 1516 charPos[0].m_OriginY = penY + top;
(...skipping 18 matching lines...) Expand all
1528 charPos[i].m_bGlyphAdjust = TRUE; 1535 charPos[i].m_bGlyphAdjust = TRUE;
1529 charPos[i].m_AdjustMatrix[0] = -1; 1536 charPos[i].m_AdjustMatrix[0] = -1;
1530 charPos[i].m_AdjustMatrix[1] = 0; 1537 charPos[i].m_AdjustMatrix[1] = 0;
1531 charPos[i].m_AdjustMatrix[2] = 0; 1538 charPos[i].m_AdjustMatrix[2] = 0;
1532 charPos[i].m_AdjustMatrix[3] = 1; 1539 charPos[i].m_AdjustMatrix[3] = 1;
1533 penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * m_info.fontSize / 1000 + 1540 penX += (FX_FLOAT)(charPos[i].m_FontCharWidth) * m_info.fontSize / 1000 +
1534 m_info.fontSpacing; 1541 m_info.fontSpacing;
1535 } 1542 }
1536 rect.width = (FX_FLOAT)penX - rect.left; 1543 rect.width = (FX_FLOAT)penX - rect.left;
1537 rect.height = rect.top + m_info.fontSize * m_info.fontHScale - rect.top; 1544 rect.height = rect.top + m_info.fontSize * m_info.fontHScale - rect.top;
1538 return FX_ERR_Succeeded; 1545 return FWL_Error::Succeeded;
1539 } 1546 }
1540 1547
1541 CFX_Graphics::TInfo::TInfo(const TInfo& info) 1548 CFX_Graphics::TInfo::TInfo(const TInfo& info)
1542 : graphState(info.graphState), 1549 : graphState(info.graphState),
1543 isAntialiasing(info.isAntialiasing), 1550 isAntialiasing(info.isAntialiasing),
1544 strokeAlignment(info.strokeAlignment), 1551 strokeAlignment(info.strokeAlignment),
1545 CTM(info.CTM), 1552 CTM(info.CTM),
1546 isActOnDash(info.isActOnDash), 1553 isActOnDash(info.isActOnDash),
1547 strokeColor(info.strokeColor), 1554 strokeColor(info.strokeColor),
1548 fillColor(info.fillColor), 1555 fillColor(info.fillColor),
1549 font(info.font), 1556 font(info.font),
1550 fontSize(info.fontSize), 1557 fontSize(info.fontSize),
1551 fontHScale(info.fontHScale), 1558 fontHScale(info.fontHScale),
1552 fontSpacing(info.fontSpacing) {} 1559 fontSpacing(info.fontSpacing) {}
1553 1560
1554 CFX_Graphics::TInfo& CFX_Graphics::TInfo::operator=(const TInfo& other) { 1561 CFX_Graphics::TInfo& CFX_Graphics::TInfo::operator=(const TInfo& other) {
1555 graphState.Copy(other.graphState); 1562 graphState.Copy(other.graphState);
1556 isAntialiasing = other.isAntialiasing; 1563 isAntialiasing = other.isAntialiasing;
1557 strokeAlignment = other.strokeAlignment; 1564 strokeAlignment = other.strokeAlignment;
1558 CTM = other.CTM; 1565 CTM = other.CTM;
1559 isActOnDash = other.isActOnDash; 1566 isActOnDash = other.isActOnDash;
1560 strokeColor = other.strokeColor; 1567 strokeColor = other.strokeColor;
1561 fillColor = other.fillColor; 1568 fillColor = other.fillColor;
1562 font = other.font; 1569 font = other.font;
1563 fontSize = other.fontSize; 1570 fontSize = other.fontSize;
1564 fontHScale = other.fontHScale; 1571 fontHScale = other.fontHScale;
1565 fontSpacing = other.fontSpacing; 1572 fontSpacing = other.fontSpacing;
1566 return *this; 1573 return *this;
1567 } 1574 }
OLDNEW
« no previous file with comments | « xfa/fxgraphics/cfx_color.cpp ('k') | xfa/fxgraphics/cfx_path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698