| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "core/include/fxge/fx_ge.h" | 7 #include "core/include/fxge/fx_ge.h" |
| 8 | 8 |
| 9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ | 9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_DESKTOP_ |
| 10 #include <crtdbg.h> | 10 #include <crtdbg.h> |
| (...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 return TRUE; | 674 return TRUE; |
| 675 } | 675 } |
| 676 FX_BOOL CGdiDeviceDriver::GetClipBox(FX_RECT* pRect) { | 676 FX_BOOL CGdiDeviceDriver::GetClipBox(FX_RECT* pRect) { |
| 677 return ::GetClipBox(m_hDC, (RECT*)pRect); | 677 return ::GetClipBox(m_hDC, (RECT*)pRect); |
| 678 } | 678 } |
| 679 FX_BOOL CGdiDeviceDriver::SetClipRgn(void* hRgn) { | 679 FX_BOOL CGdiDeviceDriver::SetClipRgn(void* hRgn) { |
| 680 ::SelectClipRgn(m_hDC, (HRGN)hRgn); | 680 ::SelectClipRgn(m_hDC, (HRGN)hRgn); |
| 681 return TRUE; | 681 return TRUE; |
| 682 } | 682 } |
| 683 static HPEN _CreatePen(const CFX_GraphStateData* pGraphState, | 683 static HPEN _CreatePen(const CFX_GraphStateData* pGraphState, |
| 684 const CFX_AffineMatrix* pMatrix, | 684 const CFX_Matrix* pMatrix, |
| 685 FX_DWORD argb) { | 685 FX_DWORD argb) { |
| 686 FX_FLOAT width; | 686 FX_FLOAT width; |
| 687 FX_FLOAT scale = 1.f; | 687 FX_FLOAT scale = 1.f; |
| 688 if (pMatrix) | 688 if (pMatrix) |
| 689 scale = FXSYS_fabs(pMatrix->a) > FXSYS_fabs(pMatrix->b) | 689 scale = FXSYS_fabs(pMatrix->a) > FXSYS_fabs(pMatrix->b) |
| 690 ? FXSYS_fabs(pMatrix->a) | 690 ? FXSYS_fabs(pMatrix->a) |
| 691 : FXSYS_fabs(pMatrix->b); | 691 : FXSYS_fabs(pMatrix->b); |
| 692 if (pGraphState) { | 692 if (pGraphState) { |
| 693 width = scale * pGraphState->m_LineWidth; | 693 width = scale * pGraphState->m_LineWidth; |
| 694 } else { | 694 } else { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 return hPen; | 750 return hPen; |
| 751 } | 751 } |
| 752 static HBRUSH _CreateBrush(FX_DWORD argb) { | 752 static HBRUSH _CreateBrush(FX_DWORD argb) { |
| 753 int a; | 753 int a; |
| 754 FX_COLORREF rgb; | 754 FX_COLORREF rgb; |
| 755 ArgbDecode(argb, a, rgb); | 755 ArgbDecode(argb, a, rgb); |
| 756 return CreateSolidBrush(rgb); | 756 return CreateSolidBrush(rgb); |
| 757 } | 757 } |
| 758 static void _SetPathToDC(HDC hDC, | 758 static void _SetPathToDC(HDC hDC, |
| 759 const CFX_PathData* pPathData, | 759 const CFX_PathData* pPathData, |
| 760 const CFX_AffineMatrix* pMatrix) { | 760 const CFX_Matrix* pMatrix) { |
| 761 BeginPath(hDC); | 761 BeginPath(hDC); |
| 762 int nPoints = pPathData->GetPointCount(); | 762 int nPoints = pPathData->GetPointCount(); |
| 763 FX_PATHPOINT* pPoints = pPathData->GetPoints(); | 763 FX_PATHPOINT* pPoints = pPathData->GetPoints(); |
| 764 for (int i = 0; i < nPoints; i++) { | 764 for (int i = 0; i < nPoints; i++) { |
| 765 FX_FLOAT posx = pPoints[i].m_PointX, posy = pPoints[i].m_PointY; | 765 FX_FLOAT posx = pPoints[i].m_PointX, posy = pPoints[i].m_PointY; |
| 766 if (pMatrix) { | 766 if (pMatrix) { |
| 767 pMatrix->Transform(posx, posy); | 767 pMatrix->Transform(posx, posy); |
| 768 } | 768 } |
| 769 int screen_x = FXSYS_round(posx), screen_y = FXSYS_round(posy); | 769 int screen_x = FXSYS_round(posx), screen_y = FXSYS_round(posy); |
| 770 int point_type = pPoints[i].m_Flag & FXPT_TYPE; | 770 int point_type = pPoints[i].m_Flag & FXPT_TYPE; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 } else { | 828 } else { |
| 829 x1 = x[0]; | 829 x1 = x[0]; |
| 830 y1 = y[0]; | 830 y1 = y[0]; |
| 831 x2 = x[np - 1]; | 831 x2 = x[np - 1]; |
| 832 y2 = y[np - 1]; | 832 y2 = y[np - 1]; |
| 833 } | 833 } |
| 834 } | 834 } |
| 835 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL); | 835 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL); |
| 836 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); | 836 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); |
| 837 } | 837 } |
| 838 static FX_BOOL _MatrixNoScaled(const CFX_AffineMatrix* pMatrix) { | 838 static FX_BOOL _MatrixNoScaled(const CFX_Matrix* pMatrix) { |
| 839 return pMatrix->GetA() == 1.0f && pMatrix->GetB() == 0 && | 839 return pMatrix->GetA() == 1.0f && pMatrix->GetB() == 0 && |
| 840 pMatrix->GetC() == 0 && pMatrix->GetD() == 1.0f; | 840 pMatrix->GetC() == 0 && pMatrix->GetD() == 1.0f; |
| 841 } | 841 } |
| 842 FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, | 842 FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, |
| 843 const CFX_AffineMatrix* pMatrix, | 843 const CFX_Matrix* pMatrix, |
| 844 const CFX_GraphStateData* pGraphState, | 844 const CFX_GraphStateData* pGraphState, |
| 845 FX_DWORD fill_color, | 845 FX_DWORD fill_color, |
| 846 FX_DWORD stroke_color, | 846 FX_DWORD stroke_color, |
| 847 int fill_mode, | 847 int fill_mode, |
| 848 int alpha_flag, | 848 int alpha_flag, |
| 849 void* pIccTransform, | 849 void* pIccTransform, |
| 850 int blend_type) { | 850 int blend_type) { |
| 851 if (blend_type != FXDIB_BLEND_NORMAL) { | 851 if (blend_type != FXDIB_BLEND_NORMAL) { |
| 852 return FALSE; | 852 return FALSE; |
| 853 } | 853 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 } | 968 } |
| 969 if (alpha < 255) { | 969 if (alpha < 255) { |
| 970 return FALSE; | 970 return FALSE; |
| 971 } | 971 } |
| 972 HBRUSH hBrush = CreateSolidBrush(rgb); | 972 HBRUSH hBrush = CreateSolidBrush(rgb); |
| 973 ::FillRect(m_hDC, (RECT*)pRect, hBrush); | 973 ::FillRect(m_hDC, (RECT*)pRect, hBrush); |
| 974 DeleteObject(hBrush); | 974 DeleteObject(hBrush); |
| 975 return TRUE; | 975 return TRUE; |
| 976 } | 976 } |
| 977 FX_BOOL CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, | 977 FX_BOOL CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, |
| 978 const CFX_AffineMatrix* pMatrix, | 978 const CFX_Matrix* pMatrix, |
| 979 int fill_mode) { | 979 int fill_mode) { |
| 980 if (pPathData->GetPointCount() == 5) { | 980 if (pPathData->GetPointCount() == 5) { |
| 981 CFX_FloatRect rectf; | 981 CFX_FloatRect rectf; |
| 982 if (pPathData->IsRect(pMatrix, &rectf)) { | 982 if (pPathData->IsRect(pMatrix, &rectf)) { |
| 983 FX_RECT rect = rectf.GetOutterRect(); | 983 FX_RECT rect = rectf.GetOutterRect(); |
| 984 IntersectClipRect(m_hDC, rect.left, rect.top, rect.right, rect.bottom); | 984 IntersectClipRect(m_hDC, rect.left, rect.top, rect.right, rect.bottom); |
| 985 return TRUE; | 985 return TRUE; |
| 986 } | 986 } |
| 987 } | 987 } |
| 988 _SetPathToDC(m_hDC, pPathData, pMatrix); | 988 _SetPathToDC(m_hDC, pPathData, pMatrix); |
| 989 SetPolyFillMode(m_hDC, fill_mode & 3); | 989 SetPolyFillMode(m_hDC, fill_mode & 3); |
| 990 SelectClipPath(m_hDC, RGN_AND); | 990 SelectClipPath(m_hDC, RGN_AND); |
| 991 return TRUE; | 991 return TRUE; |
| 992 } | 992 } |
| 993 FX_BOOL CGdiDeviceDriver::SetClip_PathStroke( | 993 FX_BOOL CGdiDeviceDriver::SetClip_PathStroke( |
| 994 const CFX_PathData* pPathData, | 994 const CFX_PathData* pPathData, |
| 995 const CFX_AffineMatrix* pMatrix, | 995 const CFX_Matrix* pMatrix, |
| 996 const CFX_GraphStateData* pGraphState) { | 996 const CFX_GraphStateData* pGraphState) { |
| 997 HPEN hPen = _CreatePen(pGraphState, pMatrix, 0xff000000); | 997 HPEN hPen = _CreatePen(pGraphState, pMatrix, 0xff000000); |
| 998 hPen = (HPEN)SelectObject(m_hDC, hPen); | 998 hPen = (HPEN)SelectObject(m_hDC, hPen); |
| 999 _SetPathToDC(m_hDC, pPathData, pMatrix); | 999 _SetPathToDC(m_hDC, pPathData, pMatrix); |
| 1000 WidenPath(m_hDC); | 1000 WidenPath(m_hDC); |
| 1001 SetPolyFillMode(m_hDC, WINDING); | 1001 SetPolyFillMode(m_hDC, WINDING); |
| 1002 FX_BOOL ret = SelectClipPath(m_hDC, RGN_AND); | 1002 FX_BOOL ret = SelectClipPath(m_hDC, RGN_AND); |
| 1003 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1003 hPen = (HPEN)SelectObject(m_hDC, hPen); |
| 1004 DeleteObject(hPen); | 1004 DeleteObject(hPen); |
| 1005 return ret; | 1005 return ret; |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1356 SelectObject(m_hDC, m_hOldBitmap); | 1356 SelectObject(m_hDC, m_hOldBitmap); |
| 1357 DeleteDC(m_hDC); | 1357 DeleteDC(m_hDC); |
| 1358 } | 1358 } |
| 1359 if (m_hBitmap) { | 1359 if (m_hBitmap) { |
| 1360 DeleteObject(m_hBitmap); | 1360 DeleteObject(m_hBitmap); |
| 1361 } | 1361 } |
| 1362 delete GetBitmap(); | 1362 delete GetBitmap(); |
| 1363 } | 1363 } |
| 1364 | 1364 |
| 1365 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ | 1365 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ |
| OLD | NEW |