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

Side by Side Diff: core/src/fxge/win32/fx_win32_device.cpp

Issue 1243953004: Re-land else-after-returns (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 5 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 | « core/src/fxge/skia/fx_skia_blitter_new.cpp ('k') | core/src/fxge/win32/fx_win32_dib.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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
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 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 int alpha_flag, void* pIccTransform) 983 int alpha_flag, void* pIccTransform)
983 { 984 {
984 ASSERT(blend_type == FXDIB_BLEND_NORMAL); 985 ASSERT(blend_type == FXDIB_BLEND_NORMAL);
985 if (pSource->IsAlphaMask()) { 986 if (pSource->IsAlphaMask()) {
986 int width = pSource->GetWidth(), height = pSource->GetHeight(); 987 int width = pSource->GetWidth(), height = pSource->GetHeight();
987 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha _flag) : FXARGB_A(color); 988 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha _flag) : FXARGB_A(color);
988 FX_BOOL bGDI = pSource->GetBPP() == 1 && alpha == 255; 989 FX_BOOL bGDI = pSource->GetBPP() == 1 && alpha == 255;
989 if (!bGDI) { 990 if (!bGDI) {
990 CFX_DIBitmap background; 991 CFX_DIBitmap background;
991 if (!background.Create(width, height, FXDIB_Rgb32) || 992 if (!background.Create(width, height, FXDIB_Rgb32) ||
992 !GetDIBits(&background, left, top, NULL) || 993 !GetDIBits(&background, left, top, NULL) ||
993 !background.CompositeMask(0, 0, width, height, pSource, colo r, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { 994 !background.CompositeMask(0, 0, width, height, pSource, color,
995 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE,
996 alpha_flag, pIccTransform)) {
994 return FALSE; 997 return FALSE;
995 } 998 }
996 FX_RECT src_rect(0, 0, width, height); 999 FX_RECT src_rect(0, 0, width, height);
997 return SetDIBits(&background, 0, &src_rect, left, top, FXDIB_BLEND_N ORMAL, 0, NULL); 1000 return SetDIBits(&background, 0, &src_rect, left, top, FXDIB_BLEND_N ORMAL, 0, NULL);
998 } 1001 }
999 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->H eight()); 1002 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->H eight());
1000 return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRe ct->top, width, height, 1003 return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRe ct->top, width, height,
1001 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE ND_NORMAL); 1004 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE ND_NORMAL);
1002 } else { 1005 }
1003 int width = pSrcRect->Width(), height = pSrcRect->Height(); 1006 int width = pSrcRect->Width(), height = pSrcRect->Height();
1004 if (pSource->HasAlpha()) { 1007 if (pSource->HasAlpha()) {
1005 CFX_DIBitmap bitmap; 1008 CFX_DIBitmap bitmap;
1006 if (!bitmap.Create(width, height, FXDIB_Rgb) || 1009 if (!bitmap.Create(width, height, FXDIB_Rgb) ||
1007 !GetDIBits(&bitmap, left, top, NULL) || 1010 !GetDIBits(&bitmap, left, top, NULL) ||
1008 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRe ct->left, pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, FALSE, pIccTransform)) { 1011 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left , pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, FALSE, pIccTransform)) {
1009 return FALSE; 1012 return FALSE;
1010 }
1011 FX_RECT src_rect(0, 0, width, height);
1012 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMA L, 0, NULL);
1013 } 1013 }
1014 CFX_DIBExtractor temp(pSource); 1014 FX_RECT src_rect(0, 0, width, height);
1015 CFX_DIBitmap* pBitmap = temp; 1015 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0 , NULL);
1016 if (pBitmap) { 1016 }
1017 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); 1017 CFX_DIBExtractor temp(pSource);
1018 } 1018 CFX_DIBitmap* pBitmap = temp;
1019 if (pBitmap) {
1020 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform);
1019 } 1021 }
1020 return FALSE; 1022 return FALSE;
1021 } 1023 }
1022 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, F X_DWORD color, int dest_left, int dest_top, 1024 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, F X_DWORD color, int dest_left, int dest_top,
1023 int dest_width, int dest_height, const FX_RECT* pClipRect, int render_fl ags, 1025 int dest_width, int dest_height, const FX_RECT* pClipRect, int render_fl ags,
1024 int alpha_flag, void* pIccTransform, int blend_type) 1026 int alpha_flag, void* pIccTransform, int blend_type)
1025 { 1027 {
1026 FX_RECT bitmap_clip = *pClipRect; 1028 FX_RECT bitmap_clip = *pClipRect;
1027 if (dest_width < 0) { 1029 if (dest_width < 0) {
1028 dest_left += dest_width; 1030 dest_left += dest_width;
1029 } 1031 }
1030 if (dest_height < 0) { 1032 if (dest_height < 0) {
1031 dest_top += dest_height; 1033 dest_top += dest_height;
1032 } 1034 }
1033 bitmap_clip.Offset(-dest_left, -dest_top); 1035 bitmap_clip.Offset(-dest_left, -dest_top);
1034 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, rende r_flags, &bitmap_clip); 1036 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, rende r_flags, &bitmap_clip);
1035 if (pStretched == NULL) { 1037 if (pStretched == NULL) {
1036 return TRUE; 1038 return TRUE;
1037 } 1039 }
1038 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); 1040 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight());
1039 FX_BOOL ret = SetDIBits(pStretched, color, &src_rect, pClipRect->left, pClip Rect->top, FXDIB_BLEND_NORMAL, alpha_flag, pIccTransform); 1041 FX_BOOL ret = SetDIBits(pStretched, color, &src_rect, pClipRect->left, pClip Rect->top, FXDIB_BLEND_NORMAL, alpha_flag, pIccTransform);
1040 delete pStretched; 1042 delete pStretched;
1041 return ret; 1043 return ret;
1042 } 1044 }
1043 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD color, int dest_left, int dest_top, 1045 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD color, int dest_left, int dest_top,
1044 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag s, 1046 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag s,
1045 int alpha_flag, void* pIccTransform, int blend_type) 1047 int alpha_flag, void* pIccTransform, int blend_type)
1046 { 1048 {
1047 ASSERT(pSource != NULL && pClipRect != NULL); 1049 ASSERT(pSource != NULL && pClipRect != NULL);
1048 if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 1000 0 || dest_height < -10000) 1050 if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 1000 0 || dest_height < -10000) {
1049 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w idth, dest_height, 1051 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w idth, dest_height,
1050 pClipRect, flags, alpha_flag, pIccTransform , blend_type); 1052 pClipRect, flags, alpha_flag, pIccTransform , blend_type);
1053 }
1051 if (pSource->IsAlphaMask()) { 1054 if (pSource->IsAlphaMask()) {
1052 FX_RECT image_rect; 1055 FX_RECT image_rect;
1053 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; 1056 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width;
1054 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left; 1057 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left;
1055 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height; 1058 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height;
1056 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top; 1059 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top;
1057 FX_RECT clip_rect = image_rect; 1060 FX_RECT clip_rect = image_rect;
1058 clip_rect.Intersect(*pClipRect); 1061 clip_rect.Intersect(*pClipRect);
1059 clip_rect.Offset(-image_rect.left, -image_rect.top); 1062 clip_rect.Offset(-image_rect.left, -image_rect.top);
1060 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); 1063 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height();
1061 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, f lags, &clip_rect); 1064 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, f lags, &clip_rect);
1062 if (pStretched == NULL) { 1065 if (pStretched == NULL) {
1063 return TRUE; 1066 return TRUE;
1064 } 1067 }
1065 CFX_DIBitmap background; 1068 CFX_DIBitmap background;
1066 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || 1069 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) ||
1067 !GetDIBits(&background, image_rect.left + clip_rect.left, image_ rect.top + clip_rect.top, NULL) || 1070 !GetDIBits(&background, image_rect.left + clip_rect.left, image_rect .top + clip_rect.top, NULL) ||
1068 !background.CompositeMask(0, 0, clip_width, clip_height, pStretc hed, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { 1071 !background.CompositeMask(0, 0, clip_width, clip_height, pStretched, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) {
1069 delete pStretched; 1072 delete pStretched;
1070 return FALSE; 1073 return FALSE;
1071 } 1074 }
1072 FX_RECT src_rect(0, 0, clip_width, clip_height); 1075 FX_RECT src_rect(0, 0, clip_width, clip_height);
1073 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); 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);
1074 delete pStretched; 1077 delete pStretched;
1075 return ret; 1078 return ret;
1076 } else { 1079 }
1077 if (pSource->HasAlpha()) { 1080 if (pSource->HasAlpha()) {
1078 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->Ge tPlatformData(); 1081 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPla tformData();
1079 if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL & & !pSource->IsCmykImage()) { 1082 if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL && !p Source->IsCmykImage()) {
1080 CFX_DIBExtractor temp(pSource); 1083 CFX_DIBExtractor temp(pSource);
1081 CFX_DIBitmap* pBitmap = temp; 1084 CFX_DIBitmap* pBitmap = temp;
1082 if (pBitmap == NULL) { 1085 if (pBitmap == NULL) {
1083 return FALSE; 1086 return FALSE;
1084 }
1085 return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, des t_left, dest_top, dest_width, dest_height, pClipRect, flags);
1086 } 1087 }
1087 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, de st_width, dest_height, 1088 return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, dest_le ft, dest_top, dest_width, dest_height, pClipRect, flags);
1088 pClipRect, flags, alpha_flag, pIccTrans form, blend_type);
1089 } 1089 }
1090 CFX_DIBExtractor temp(pSource); 1090 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w idth, dest_height,
1091 CFX_DIBitmap* pBitmap = temp; 1091 pClipRect, flags, alpha_flag, pIccTransform , blend_type);
1092 if (pBitmap) { 1092 }
1093 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, d est_height, flags, pIccTransform); 1093 CFX_DIBExtractor temp(pSource);
1094 } 1094 CFX_DIBitmap* pBitmap = temp;
1095 if (pBitmap) {
1096 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_ height, flags, pIccTransform);
1095 } 1097 }
1096 return FALSE; 1098 return FALSE;
1097 } 1099 }
1098 #define GET_PS_FEATURESETTING 4121 1100 #define GET_PS_FEATURESETTING 4121
1099 #define FEATURESETTING_PSLEVEL 2 1101 #define FEATURESETTING_PSLEVEL 2
1100 int GetPSLevel(HDC hDC) 1102 int GetPSLevel(HDC hDC)
1101 { 1103 {
1102 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); 1104 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY);
1103 if (device_type != DT_RASPRINTER) { 1105 if (device_type != DT_RASPRINTER) {
1104 return 0; 1106 return 0;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1195 SelectObject(m_hDC, m_hOldBitmap); 1197 SelectObject(m_hDC, m_hOldBitmap);
1196 DeleteDC(m_hDC); 1198 DeleteDC(m_hDC);
1197 } 1199 }
1198 if (m_hBitmap) { 1200 if (m_hBitmap) {
1199 DeleteObject(m_hBitmap); 1201 DeleteObject(m_hBitmap);
1200 } 1202 }
1201 delete GetBitmap(); 1203 delete GetBitmap();
1202 } 1204 }
1203 1205
1204 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ 1206 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
OLDNEW
« no previous file with comments | « core/src/fxge/skia/fx_skia_blitter_new.cpp ('k') | core/src/fxge/win32/fx_win32_dib.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698