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 "../../../include/fxge/fx_ge.h" | 7 #include "../../../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 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } else if (face.Find("UI Gothic") >= 0) { | 260 } else if (face.Find("UI Gothic") >= 0) { |
261 face = "MS UI Gothic"; | 261 face = "MS UI Gothic"; |
262 } else { | 262 } else { |
263 if (face.Find("HGSGothicM") >= 0 || face.Find("HGMaruGothicMPRO") >=
0) { | 263 if (face.Find("HGSGothicM") >= 0 || face.Find("HGMaruGothicMPRO") >=
0) { |
264 face = "MS PGothic"; | 264 face = "MS PGothic"; |
265 } else { | 265 } else { |
266 face = "MS Gothic"; | 266 face = "MS Gothic"; |
267 } | 267 } |
268 } | 268 } |
269 return; | 269 return; |
270 } else if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { | 270 } |
| 271 if (face.Find("Mincho") >= 0 || face.Find("\x96\xbe\x92\xa9") >= 0) { |
271 if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >
= 0) { | 272 if (face.Find("PMincho") >= 0 || face.Find("\x82\x6f\x96\xbe\x92\xa9") >
= 0) { |
272 face = "MS PMincho"; | 273 face = "MS PMincho"; |
273 } else { | 274 } else { |
274 face = "MS Mincho"; | 275 face = "MS Mincho"; |
275 } | 276 } |
276 return; | 277 return; |
277 } | 278 } |
278 if (_GetSubFontName(face)) { | 279 if (_GetSubFontName(face)) { |
279 return; | 280 return; |
280 } | 281 } |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 int alpha_flag, void* pIccTransform) | 986 int alpha_flag, void* pIccTransform) |
986 { | 987 { |
987 ASSERT(blend_type == FXDIB_BLEND_NORMAL); | 988 ASSERT(blend_type == FXDIB_BLEND_NORMAL); |
988 if (pSource->IsAlphaMask()) { | 989 if (pSource->IsAlphaMask()) { |
989 int width = pSource->GetWidth(), height = pSource->GetHeight(); | 990 int width = pSource->GetWidth(), height = pSource->GetHeight(); |
990 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha
_flag) : FXARGB_A(color); | 991 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha
_flag) : FXARGB_A(color); |
991 FX_BOOL bGDI = pSource->GetBPP() == 1 && alpha == 255; | 992 FX_BOOL bGDI = pSource->GetBPP() == 1 && alpha == 255; |
992 if (!bGDI) { | 993 if (!bGDI) { |
993 CFX_DIBitmap background; | 994 CFX_DIBitmap background; |
994 if (!background.Create(width, height, FXDIB_Rgb32) || | 995 if (!background.Create(width, height, FXDIB_Rgb32) || |
995 !GetDIBits(&background, left, top, NULL) || | 996 !GetDIBits(&background, left, top, NULL) || |
996 !background.CompositeMask(0, 0, width, height, pSource, colo
r, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { | 997 !background.CompositeMask(0, 0, width, height, pSource, color, |
| 998 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, |
| 999 alpha_flag, pIccTransform)) { |
997 return FALSE; | 1000 return FALSE; |
998 } | 1001 } |
999 FX_RECT src_rect(0, 0, width, height); | 1002 FX_RECT src_rect(0, 0, width, height); |
1000 return SetDIBits(&background, 0, &src_rect, left, top, FXDIB_BLEND_N
ORMAL, 0, NULL); | 1003 return SetDIBits(&background, 0, &src_rect, left, top, FXDIB_BLEND_N
ORMAL, 0, NULL); |
1001 } | 1004 } |
1002 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->H
eight()); | 1005 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->H
eight()); |
1003 return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRe
ct->top, width, height, | 1006 return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRe
ct->top, width, height, |
1004 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE
ND_NORMAL); | 1007 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE
ND_NORMAL); |
1005 } else { | 1008 } |
1006 int width = pSrcRect->Width(), height = pSrcRect->Height(); | 1009 int width = pSrcRect->Width(), height = pSrcRect->Height(); |
1007 if (pSource->HasAlpha()) { | 1010 if (pSource->HasAlpha()) { |
1008 CFX_DIBitmap bitmap; | 1011 CFX_DIBitmap bitmap; |
1009 if (!bitmap.Create(width, height, FXDIB_Rgb) || | 1012 if (!bitmap.Create(width, height, FXDIB_Rgb) || |
1010 !GetDIBits(&bitmap, left, top, NULL) || | 1013 !GetDIBits(&bitmap, left, top, NULL) || |
1011 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRe
ct->left, pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, FALSE, pIccTransform)) { | 1014 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left
, pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, FALSE, pIccTransform)) { |
1012 return FALSE; | 1015 return FALSE; |
1013 } | |
1014 FX_RECT src_rect(0, 0, width, height); | |
1015 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMA
L, 0, NULL); | |
1016 } | 1016 } |
1017 CFX_DIBExtractor temp(pSource); | 1017 FX_RECT src_rect(0, 0, width, height); |
1018 CFX_DIBitmap* pBitmap = temp; | 1018 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0
, NULL); |
1019 if (pBitmap) { | 1019 } |
1020 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); | 1020 CFX_DIBExtractor temp(pSource); |
1021 } | 1021 CFX_DIBitmap* pBitmap = temp; |
| 1022 if (pBitmap) { |
| 1023 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); |
1022 } | 1024 } |
1023 return FALSE; | 1025 return FALSE; |
1024 } | 1026 } |
1025 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, F
X_DWORD color, int dest_left, int dest_top, | 1027 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, F
X_DWORD color, int dest_left, int dest_top, |
1026 int dest_width, int dest_height, const FX_RECT* pClipRect, int render_fl
ags, | 1028 int dest_width, int dest_height, const FX_RECT* pClipRect, int render_fl
ags, |
1027 int alpha_flag, void* pIccTransform, int blend_type) | 1029 int alpha_flag, void* pIccTransform, int blend_type) |
1028 { | 1030 { |
1029 FX_RECT bitmap_clip = *pClipRect; | 1031 FX_RECT bitmap_clip = *pClipRect; |
1030 if (dest_width < 0) { | 1032 if (dest_width < 0) { |
1031 dest_left += dest_width; | 1033 dest_left += dest_width; |
1032 } | 1034 } |
1033 if (dest_height < 0) { | 1035 if (dest_height < 0) { |
1034 dest_top += dest_height; | 1036 dest_top += dest_height; |
1035 } | 1037 } |
1036 bitmap_clip.Offset(-dest_left, -dest_top); | 1038 bitmap_clip.Offset(-dest_left, -dest_top); |
1037 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, rende
r_flags, &bitmap_clip); | 1039 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, rende
r_flags, &bitmap_clip); |
1038 if (pStretched == NULL) { | 1040 if (pStretched == NULL) { |
1039 return TRUE; | 1041 return TRUE; |
1040 } | 1042 } |
1041 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); | 1043 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); |
1042 FX_BOOL ret = SetDIBits(pStretched, color, &src_rect, pClipRect->left, pClip
Rect->top, FXDIB_BLEND_NORMAL, alpha_flag, pIccTransform); | 1044 FX_BOOL ret = SetDIBits(pStretched, color, &src_rect, pClipRect->left, pClip
Rect->top, FXDIB_BLEND_NORMAL, alpha_flag, pIccTransform); |
1043 delete pStretched; | 1045 delete pStretched; |
1044 return ret; | 1046 return ret; |
1045 } | 1047 } |
1046 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD
color, int dest_left, int dest_top, | 1048 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD
color, int dest_left, int dest_top, |
1047 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag
s, | 1049 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag
s, |
1048 int alpha_flag, void* pIccTransform, int blend_type) | 1050 int alpha_flag, void* pIccTransform, int blend_type) |
1049 { | 1051 { |
1050 ASSERT(pSource != NULL && pClipRect != NULL); | 1052 ASSERT(pSource != NULL && pClipRect != NULL); |
1051 if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 1000
0 || dest_height < -10000) | 1053 if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 1000
0 || dest_height < -10000) { |
1052 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w
idth, dest_height, | 1054 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w
idth, dest_height, |
1053 pClipRect, flags, alpha_flag, pIccTransform
, blend_type); | 1055 pClipRect, flags, alpha_flag, pIccTransform
, blend_type); |
| 1056 } |
1054 if (pSource->IsAlphaMask()) { | 1057 if (pSource->IsAlphaMask()) { |
1055 FX_RECT image_rect; | 1058 FX_RECT image_rect; |
1056 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; | 1059 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; |
1057 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left; | 1060 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left; |
1058 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height; | 1061 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height; |
1059 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top; | 1062 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top; |
1060 FX_RECT clip_rect = image_rect; | 1063 FX_RECT clip_rect = image_rect; |
1061 clip_rect.Intersect(*pClipRect); | 1064 clip_rect.Intersect(*pClipRect); |
1062 clip_rect.Offset(-image_rect.left, -image_rect.top); | 1065 clip_rect.Offset(-image_rect.left, -image_rect.top); |
1063 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); | 1066 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); |
1064 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, f
lags, &clip_rect); | 1067 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, f
lags, &clip_rect); |
1065 if (pStretched == NULL) { | 1068 if (pStretched == NULL) { |
1066 return TRUE; | 1069 return TRUE; |
1067 } | 1070 } |
1068 CFX_DIBitmap background; | 1071 CFX_DIBitmap background; |
1069 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || | 1072 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || |
1070 !GetDIBits(&background, image_rect.left + clip_rect.left, image_
rect.top + clip_rect.top, NULL) || | 1073 !GetDIBits(&background, image_rect.left + clip_rect.left, image_rect
.top + clip_rect.top, NULL) || |
1071 !background.CompositeMask(0, 0, clip_width, clip_height, pStretc
hed, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { | 1074 !background.CompositeMask(0, 0, clip_width, clip_height, pStretched,
color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { |
1072 delete pStretched; | 1075 delete pStretched; |
1073 return FALSE; | 1076 return FALSE; |
1074 } | 1077 } |
1075 FX_RECT src_rect(0, 0, clip_width, clip_height); | 1078 FX_RECT src_rect(0, 0, clip_width, clip_height); |
1076 FX_BOOL ret = SetDIBits(&background, 0, &src_rect, image_rect.left + cli
p_rect.left, image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL, 0, NULL); | 1079 FX_BOOL ret = SetDIBits(&background, 0, &src_rect, image_rect.left + cli
p_rect.left, image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL, 0, NULL); |
1077 delete pStretched; | 1080 delete pStretched; |
1078 return ret; | 1081 return ret; |
1079 } else { | 1082 } |
1080 if (pSource->HasAlpha()) { | 1083 if (pSource->HasAlpha()) { |
1081 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->Ge
tPlatformData(); | 1084 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPla
tformData(); |
1082 if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL &
& !pSource->IsCmykImage()) { | 1085 if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL && !p
Source->IsCmykImage()) { |
1083 CFX_DIBExtractor temp(pSource); | 1086 CFX_DIBExtractor temp(pSource); |
1084 CFX_DIBitmap* pBitmap = temp; | 1087 CFX_DIBitmap* pBitmap = temp; |
1085 if (pBitmap == NULL) { | 1088 if (pBitmap == NULL) { |
1086 return FALSE; | 1089 return FALSE; |
1087 } | |
1088 return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, des
t_left, dest_top, dest_width, dest_height, pClipRect, flags); | |
1089 } | 1090 } |
1090 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, de
st_width, dest_height, | 1091 return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, dest_le
ft, dest_top, dest_width, dest_height, pClipRect, flags); |
1091 pClipRect, flags, alpha_flag, pIccTrans
form, blend_type); | |
1092 } | 1092 } |
1093 CFX_DIBExtractor temp(pSource); | 1093 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w
idth, dest_height, |
1094 CFX_DIBitmap* pBitmap = temp; | 1094 pClipRect, flags, alpha_flag, pIccTransform
, blend_type); |
1095 if (pBitmap) { | 1095 } |
1096 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, d
est_height, flags, pIccTransform); | 1096 CFX_DIBExtractor temp(pSource); |
1097 } | 1097 CFX_DIBitmap* pBitmap = temp; |
| 1098 if (pBitmap) { |
| 1099 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_
height, flags, pIccTransform); |
1098 } | 1100 } |
1099 return FALSE; | 1101 return FALSE; |
1100 } | 1102 } |
1101 #define GET_PS_FEATURESETTING 4121 | 1103 #define GET_PS_FEATURESETTING 4121 |
1102 #define FEATURESETTING_PSLEVEL 2 | 1104 #define FEATURESETTING_PSLEVEL 2 |
1103 int GetPSLevel(HDC hDC) | 1105 int GetPSLevel(HDC hDC) |
1104 { | 1106 { |
1105 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); | 1107 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); |
1106 if (device_type != DT_RASPRINTER) { | 1108 if (device_type != DT_RASPRINTER) { |
1107 return 0; | 1109 return 0; |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 SelectObject(m_hDC, m_hOldBitmap); | 1209 SelectObject(m_hDC, m_hOldBitmap); |
1208 DeleteDC(m_hDC); | 1210 DeleteDC(m_hDC); |
1209 } | 1211 } |
1210 if (m_hBitmap) { | 1212 if (m_hBitmap) { |
1211 DeleteObject(m_hBitmap); | 1213 DeleteObject(m_hBitmap); |
1212 } | 1214 } |
1213 delete GetBitmap(); | 1215 delete GetBitmap(); |
1214 } | 1216 } |
1215 | 1217 |
1216 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ | 1218 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ |
OLD | NEW |