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 <windows.h> | 10 #include <windows.h> |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 CallFunc(GdipSetInterpolationMode)(pGraphics, InterpolationModeBilinear); | 958 CallFunc(GdipSetInterpolationMode)(pGraphics, InterpolationModeBilinear); |
959 } | 959 } |
960 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); | 960 FX_RECT src_rect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); |
961 OutputImage(pGraphics, pBitmap, &src_rect, dest_left, dest_top, dest_width, | 961 OutputImage(pGraphics, pBitmap, &src_rect, dest_left, dest_top, dest_width, |
962 dest_height); | 962 dest_height); |
963 CallFunc(GdipDeleteGraphics)(pGraphics); | 963 CallFunc(GdipDeleteGraphics)(pGraphics); |
964 CallFunc(GdipDeleteGraphics)(pGraphics); | 964 CallFunc(GdipDeleteGraphics)(pGraphics); |
965 return TRUE; | 965 return TRUE; |
966 } | 966 } |
967 static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, | 967 static GpPen* _GdipCreatePen(const CFX_GraphStateData* pGraphState, |
968 const CFX_AffineMatrix* pMatrix, | 968 const CFX_Matrix* pMatrix, |
969 DWORD argb, | 969 DWORD argb, |
970 FX_BOOL bTextMode = FALSE) { | 970 FX_BOOL bTextMode = FALSE) { |
971 CGdiplusExt& GdiplusExt = | 971 CGdiplusExt& GdiplusExt = |
972 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; | 972 ((CWin32Platform*)CFX_GEModule::Get()->GetPlatformData())->m_GdiplusExt; |
973 FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f; | 973 FX_FLOAT width = pGraphState ? pGraphState->m_LineWidth : 1.0f; |
974 if (!bTextMode) { | 974 if (!bTextMode) { |
975 FX_FLOAT unit = | 975 FX_FLOAT unit = |
976 pMatrix == NULL | 976 pMatrix == NULL |
977 ? 1.0f | 977 ? 1.0f |
978 : FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2); | 978 : FXSYS_Div(1.0f, (pMatrix->GetXUnit() + pMatrix->GetYUnit()) / 2); |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 } | 1065 } |
1066 } | 1066 } |
1067 CallFunc(GdipSetPenDashOffset)(pPen, phase); | 1067 CallFunc(GdipSetPenDashOffset)(pPen, phase); |
1068 FX_Free(pDashArray); | 1068 FX_Free(pDashArray); |
1069 pDashArray = NULL; | 1069 pDashArray = NULL; |
1070 } | 1070 } |
1071 CallFunc(GdipSetPenMiterLimit)(pPen, pGraphState->m_MiterLimit); | 1071 CallFunc(GdipSetPenMiterLimit)(pPen, pGraphState->m_MiterLimit); |
1072 return pPen; | 1072 return pPen; |
1073 } | 1073 } |
1074 static FX_BOOL IsSmallTriangle(PointF* points, | 1074 static FX_BOOL IsSmallTriangle(PointF* points, |
1075 const CFX_AffineMatrix* pMatrix, | 1075 const CFX_Matrix* pMatrix, |
1076 int& v1, | 1076 int& v1, |
1077 int& v2) { | 1077 int& v2) { |
1078 int pairs[] = {1, 2, 0, 2, 0, 1}; | 1078 int pairs[] = {1, 2, 0, 2, 0, 1}; |
1079 for (int i = 0; i < 3; i++) { | 1079 for (int i = 0; i < 3; i++) { |
1080 int pair1 = pairs[i * 2]; | 1080 int pair1 = pairs[i * 2]; |
1081 int pair2 = pairs[i * 2 + 1]; | 1081 int pair2 = pairs[i * 2 + 1]; |
1082 FX_FLOAT x1 = points[pair1].X, x2 = points[pair2].X; | 1082 FX_FLOAT x1 = points[pair1].X, x2 = points[pair2].X; |
1083 FX_FLOAT y1 = points[pair1].Y, y2 = points[pair2].Y; | 1083 FX_FLOAT y1 = points[pair1].Y, y2 = points[pair2].Y; |
1084 if (pMatrix) { | 1084 if (pMatrix) { |
1085 pMatrix->Transform(x1, y1); | 1085 pMatrix->Transform(x1, y1); |
1086 pMatrix->Transform(x2, y2); | 1086 pMatrix->Transform(x2, y2); |
1087 } | 1087 } |
1088 FX_FLOAT dx = x1 - x2; | 1088 FX_FLOAT dx = x1 - x2; |
1089 FX_FLOAT dy = y1 - y2; | 1089 FX_FLOAT dy = y1 - y2; |
1090 FX_FLOAT distance_square = FXSYS_Mul(dx, dx) + FXSYS_Mul(dy, dy); | 1090 FX_FLOAT distance_square = FXSYS_Mul(dx, dx) + FXSYS_Mul(dy, dy); |
1091 if (distance_square < (1.0f * 2 + 1.0f / 4)) { | 1091 if (distance_square < (1.0f * 2 + 1.0f / 4)) { |
1092 v1 = i; | 1092 v1 = i; |
1093 v2 = pair1; | 1093 v2 = pair1; |
1094 return TRUE; | 1094 return TRUE; |
1095 } | 1095 } |
1096 } | 1096 } |
1097 return FALSE; | 1097 return FALSE; |
1098 } | 1098 } |
1099 FX_BOOL CGdiplusExt::DrawPath(HDC hDC, | 1099 FX_BOOL CGdiplusExt::DrawPath(HDC hDC, |
1100 const CFX_PathData* pPathData, | 1100 const CFX_PathData* pPathData, |
1101 const CFX_AffineMatrix* pObject2Device, | 1101 const CFX_Matrix* pObject2Device, |
1102 const CFX_GraphStateData* pGraphState, | 1102 const CFX_GraphStateData* pGraphState, |
1103 FX_DWORD fill_argb, | 1103 FX_DWORD fill_argb, |
1104 FX_DWORD stroke_argb, | 1104 FX_DWORD stroke_argb, |
1105 int fill_mode) { | 1105 int fill_mode) { |
1106 int nPoints = pPathData->GetPointCount(); | 1106 int nPoints = pPathData->GetPointCount(); |
1107 if (nPoints == 0) { | 1107 if (nPoints == 0) { |
1108 return TRUE; | 1108 return TRUE; |
1109 } | 1109 } |
1110 FX_PATHPOINT* pPoints = pPathData->GetPoints(); | 1110 FX_PATHPOINT* pPoints = pPathData->GetPoints(); |
1111 GpGraphics* pGraphics = NULL; | 1111 GpGraphics* pGraphics = NULL; |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1507 dest_pitch); | 1507 dest_pitch); |
1508 } | 1508 } |
1509 } | 1509 } |
1510 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( | 1510 CFX_DIBitmap* pDIBitmap = _FX_WindowsDIB_LoadFromBuf( |
1511 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); | 1511 pInfo->pbmi, pData, pInfo->pbmi->bmiHeader.biBitCount == 32); |
1512 FX_Free(pData); | 1512 FX_Free(pData); |
1513 FreeDIBitmap(pInfo); | 1513 FreeDIBitmap(pInfo); |
1514 return pDIBitmap; | 1514 return pDIBitmap; |
1515 } | 1515 } |
1516 #endif | 1516 #endif |
OLD | NEW |