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/fxge/include/fx_ge.h" | 7 #include "core/fxge/include/fx_ge.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
746 m_Width = ::GetDeviceCaps(m_hDC, HORZRES); | 746 m_Width = ::GetDeviceCaps(m_hDC, HORZRES); |
747 m_Height = ::GetDeviceCaps(m_hDC, VERTRES); | 747 m_Height = ::GetDeviceCaps(m_hDC, VERTRES); |
748 } | 748 } |
749 if (m_DeviceClass != FXDC_DISPLAY) { | 749 if (m_DeviceClass != FXDC_DISPLAY) { |
750 m_RenderCaps = FXRC_BIT_MASK; | 750 m_RenderCaps = FXRC_BIT_MASK; |
751 } else { | 751 } else { |
752 m_RenderCaps = FXRC_GET_BITS | FXRC_BIT_MASK; | 752 m_RenderCaps = FXRC_GET_BITS | FXRC_BIT_MASK; |
753 } | 753 } |
754 } | 754 } |
755 | 755 |
| 756 CGdiDeviceDriver::~CGdiDeviceDriver() {} |
| 757 |
756 int CGdiDeviceDriver::GetDeviceCaps(int caps_id) { | 758 int CGdiDeviceDriver::GetDeviceCaps(int caps_id) { |
757 switch (caps_id) { | 759 switch (caps_id) { |
758 case FXDC_DEVICE_CLASS: | 760 case FXDC_DEVICE_CLASS: |
759 return m_DeviceClass; | 761 return m_DeviceClass; |
760 case FXDC_PIXEL_WIDTH: | 762 case FXDC_PIXEL_WIDTH: |
761 return m_Width; | 763 return m_Width; |
762 case FXDC_PIXEL_HEIGHT: | 764 case FXDC_PIXEL_HEIGHT: |
763 return m_Height; | 765 return m_Height; |
764 case FXDC_BITS_PIXEL: | 766 case FXDC_BITS_PIXEL: |
765 return m_nBitsPerPixel; | 767 return m_nBitsPerPixel; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); | 984 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); |
983 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); | 985 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); |
984 } | 986 } |
985 | 987 |
986 FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, | 988 FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, |
987 const CFX_Matrix* pMatrix, | 989 const CFX_Matrix* pMatrix, |
988 const CFX_GraphStateData* pGraphState, | 990 const CFX_GraphStateData* pGraphState, |
989 uint32_t fill_color, | 991 uint32_t fill_color, |
990 uint32_t stroke_color, | 992 uint32_t stroke_color, |
991 int fill_mode, | 993 int fill_mode, |
992 int alpha_flag, | |
993 void* pIccTransform, | |
994 int blend_type) { | 994 int blend_type) { |
995 if (blend_type != FXDIB_BLEND_NORMAL) { | 995 if (blend_type != FXDIB_BLEND_NORMAL) |
996 return FALSE; | 996 return FALSE; |
997 } | 997 |
998 Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); | 998 Color2Argb(fill_color, fill_color, 1 << 24, nullptr); |
999 Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform); | 999 Color2Argb(stroke_color, stroke_color, 0, nullptr); |
1000 CWin32Platform* pPlatform = | 1000 CWin32Platform* pPlatform = |
1001 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); | 1001 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); |
1002 if (!(pGraphState || stroke_color == 0) && | 1002 if (!(pGraphState || stroke_color == 0) && |
1003 !pPlatform->m_GdiplusExt.IsAvailable()) { | 1003 !pPlatform->m_GdiplusExt.IsAvailable()) { |
1004 CFX_FloatRect bbox_f = pPathData->GetBoundingBox(); | 1004 CFX_FloatRect bbox_f = pPathData->GetBoundingBox(); |
1005 if (pMatrix) { | 1005 if (pMatrix) { |
1006 bbox_f.Transform(pMatrix); | 1006 bbox_f.Transform(pMatrix); |
1007 } | 1007 } |
1008 FX_RECT bbox = bbox_f.GetInnerRect(); | 1008 FX_RECT bbox = bbox_f.GetInnerRect(); |
1009 if (bbox.Width() <= 0) { | 1009 if (bbox.Width() <= 0) { |
1010 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), | 1010 return DrawCosmeticLine( |
1011 (FX_FLOAT)(bbox.left), | 1011 (FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.left), |
1012 (FX_FLOAT)(bbox.bottom + 1), fill_color, | 1012 (FX_FLOAT)(bbox.bottom + 1), fill_color, FXDIB_BLEND_NORMAL); |
1013 alpha_flag, pIccTransform, FXDIB_BLEND_NORMAL); | 1013 } |
1014 } else if (bbox.Height() <= 0) { | 1014 if (bbox.Height() <= 0) { |
1015 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), | 1015 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), |
1016 (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), | 1016 (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), |
1017 fill_color, alpha_flag, pIccTransform, | 1017 fill_color, FXDIB_BLEND_NORMAL); |
1018 FXDIB_BLEND_NORMAL); | |
1019 } | 1018 } |
1020 } | 1019 } |
1021 int fill_alpha = FXARGB_A(fill_color); | 1020 int fill_alpha = FXARGB_A(fill_color); |
1022 int stroke_alpha = FXARGB_A(stroke_color); | 1021 int stroke_alpha = FXARGB_A(stroke_color); |
1023 FX_BOOL bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) || | 1022 FX_BOOL bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) || |
1024 (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState); | 1023 (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState); |
1025 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha) { | 1024 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha) |
1026 return FALSE; | 1025 return FALSE; |
1027 } | 1026 |
1028 if (pPlatform->m_GdiplusExt.IsAvailable()) { | 1027 if (pPlatform->m_GdiplusExt.IsAvailable()) { |
1029 if (bDrawAlpha || | 1028 if (bDrawAlpha || |
1030 ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFILL_FULLCOVER)) || | 1029 ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFILL_FULLCOVER)) || |
1031 (pGraphState && pGraphState->m_DashCount))) { | 1030 (pGraphState && pGraphState->m_DashCount))) { |
1032 if (!((!pMatrix || MatrixNoScaled(pMatrix)) && pGraphState && | 1031 if (!((!pMatrix || MatrixNoScaled(pMatrix)) && pGraphState && |
1033 pGraphState->m_LineWidth == 1.f && | 1032 pGraphState->m_LineWidth == 1.f && |
1034 (pPathData->GetPointCount() == 5 || | 1033 (pPathData->GetPointCount() == 5 || |
1035 pPathData->GetPointCount() == 4) && | 1034 pPathData->GetPointCount() == 4) && |
1036 pPathData->IsRect())) { | 1035 pPathData->IsRect())) { |
1037 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, | 1036 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1084 hPen = (HPEN)SelectObject(m_hDC, hPen); |
1086 DeleteObject(hPen); | 1085 DeleteObject(hPen); |
1087 } | 1086 } |
1088 if (hBrush) { | 1087 if (hBrush) { |
1089 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); | 1088 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); |
1090 DeleteObject(hBrush); | 1089 DeleteObject(hBrush); |
1091 } | 1090 } |
1092 return TRUE; | 1091 return TRUE; |
1093 } | 1092 } |
1094 | 1093 |
1095 FX_BOOL CGdiDeviceDriver::FillRect(const FX_RECT* pRect, | 1094 FX_BOOL CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, |
1096 uint32_t fill_color, | 1095 uint32_t fill_color, |
1097 int alpha_flag, | 1096 int blend_type) { |
1098 void* pIccTransform, | 1097 if (blend_type != FXDIB_BLEND_NORMAL) |
1099 int blend_type) { | |
1100 if (blend_type != FXDIB_BLEND_NORMAL) { | |
1101 return FALSE; | 1098 return FALSE; |
1102 } | 1099 |
1103 Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); | 1100 Color2Argb(fill_color, fill_color, 1 << 24, nullptr); |
1104 int alpha; | 1101 int alpha; |
1105 FX_COLORREF rgb; | 1102 FX_COLORREF rgb; |
1106 ArgbDecode(fill_color, alpha, rgb); | 1103 ArgbDecode(fill_color, alpha, rgb); |
1107 if (alpha == 0) { | 1104 if (alpha == 0) |
1108 return TRUE; | 1105 return TRUE; |
1109 } | 1106 |
1110 if (alpha < 255) { | 1107 if (alpha < 255) |
1111 return FALSE; | 1108 return FALSE; |
1112 } | 1109 |
1113 HBRUSH hBrush = CreateSolidBrush(rgb); | 1110 HBRUSH hBrush = CreateSolidBrush(rgb); |
1114 ::FillRect(m_hDC, (RECT*)pRect, hBrush); | 1111 ::FillRect(m_hDC, (RECT*)pRect, hBrush); |
1115 DeleteObject(hBrush); | 1112 DeleteObject(hBrush); |
1116 return TRUE; | 1113 return TRUE; |
1117 } | 1114 } |
1118 | 1115 |
1119 FX_BOOL CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, | 1116 FX_BOOL CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, |
1120 const CFX_Matrix* pMatrix, | 1117 const CFX_Matrix* pMatrix, |
1121 int fill_mode) { | 1118 int fill_mode) { |
1122 if (pPathData->GetPointCount() == 5) { | 1119 if (pPathData->GetPointCount() == 5) { |
(...skipping 23 matching lines...) Expand all Loading... |
1146 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1143 hPen = (HPEN)SelectObject(m_hDC, hPen); |
1147 DeleteObject(hPen); | 1144 DeleteObject(hPen); |
1148 return ret; | 1145 return ret; |
1149 } | 1146 } |
1150 | 1147 |
1151 FX_BOOL CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, | 1148 FX_BOOL CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, |
1152 FX_FLOAT y1, | 1149 FX_FLOAT y1, |
1153 FX_FLOAT x2, | 1150 FX_FLOAT x2, |
1154 FX_FLOAT y2, | 1151 FX_FLOAT y2, |
1155 uint32_t color, | 1152 uint32_t color, |
1156 int alpha_flag, | |
1157 void* pIccTransform, | |
1158 int blend_type) { | 1153 int blend_type) { |
1159 if (blend_type != FXDIB_BLEND_NORMAL) { | 1154 if (blend_type != FXDIB_BLEND_NORMAL) |
1160 return FALSE; | 1155 return FALSE; |
1161 } | 1156 |
1162 Color2Argb(color, color, alpha_flag | (1 << 24), pIccTransform); | 1157 Color2Argb(color, color, 1 << 24, nullptr); |
1163 int a; | 1158 int a; |
1164 FX_COLORREF rgb; | 1159 FX_COLORREF rgb; |
1165 ArgbDecode(color, a, rgb); | 1160 ArgbDecode(color, a, rgb); |
1166 if (a == 0) { | 1161 if (a == 0) |
1167 return TRUE; | 1162 return TRUE; |
1168 } | 1163 |
1169 HPEN hPen = CreatePen(PS_SOLID, 1, rgb); | 1164 HPEN hPen = CreatePen(PS_SOLID, 1, rgb); |
1170 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1165 hPen = (HPEN)SelectObject(m_hDC, hPen); |
1171 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); | 1166 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); |
1172 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); | 1167 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); |
1173 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1168 hPen = (HPEN)SelectObject(m_hDC, hPen); |
1174 DeleteObject(hPen); | 1169 DeleteObject(hPen); |
1175 return TRUE; | 1170 return TRUE; |
1176 } | 1171 } |
1177 | 1172 |
1178 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) | 1173 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) |
1179 : CGdiDeviceDriver(hDC, FXDC_DISPLAY) { | 1174 : CGdiDeviceDriver(hDC, FXDC_DISPLAY) { |
1180 CWin32Platform* pPlatform = | 1175 CWin32Platform* pPlatform = |
1181 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); | 1176 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); |
1182 if (pPlatform->m_GdiplusExt.IsAvailable()) { | 1177 if (pPlatform->m_GdiplusExt.IsAvailable()) { |
1183 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE; | 1178 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE; |
1184 } | 1179 } |
1185 } | 1180 } |
1186 | 1181 |
1187 FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, | 1182 CGdiDisplayDriver::~CGdiDisplayDriver() {} |
1188 int left, | 1183 |
1189 int top, | 1184 FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { |
1190 void* pIccTransform, | |
1191 FX_BOOL bDEdge) { | |
1192 FX_BOOL ret = FALSE; | 1185 FX_BOOL ret = FALSE; |
1193 int width = pBitmap->GetWidth(); | 1186 int width = pBitmap->GetWidth(); |
1194 int height = pBitmap->GetHeight(); | 1187 int height = pBitmap->GetHeight(); |
1195 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height); | 1188 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height); |
1196 HDC hDCMemory = CreateCompatibleDC(m_hDC); | 1189 HDC hDCMemory = CreateCompatibleDC(m_hDC); |
1197 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp); | 1190 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp); |
1198 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY); | 1191 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY); |
1199 SelectObject(hDCMemory, holdbmp); | 1192 SelectObject(hDCMemory, holdbmp); |
1200 BITMAPINFO bmi; | 1193 BITMAPINFO bmi; |
1201 FXSYS_memset(&bmi, 0, sizeof bmi); | 1194 FXSYS_memset(&bmi, 0, sizeof bmi); |
1202 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader; | 1195 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader; |
1203 bmi.bmiHeader.biBitCount = pBitmap->GetBPP(); | 1196 bmi.bmiHeader.biBitCount = pBitmap->GetBPP(); |
1204 bmi.bmiHeader.biHeight = -height; | 1197 bmi.bmiHeader.biHeight = -height; |
1205 bmi.bmiHeader.biPlanes = 1; | 1198 bmi.bmiHeader.biPlanes = 1; |
1206 bmi.bmiHeader.biWidth = width; | 1199 bmi.bmiHeader.biWidth = width; |
1207 if (!CFX_GEModule::Get()->GetCodecModule() || | 1200 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage()) { |
1208 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { | |
1209 pIccTransform = nullptr; | |
1210 } | |
1211 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && !pIccTransform) { | |
1212 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi, | 1201 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi, |
1213 DIB_RGB_COLORS) == height; | 1202 DIB_RGB_COLORS) == height; |
1214 } else { | 1203 } else { |
1215 CFX_DIBitmap bitmap; | 1204 CFX_DIBitmap bitmap; |
1216 if (bitmap.Create(width, height, FXDIB_Rgb)) { | 1205 if (bitmap.Create(width, height, FXDIB_Rgb)) { |
1217 bmi.bmiHeader.biBitCount = 24; | 1206 bmi.bmiHeader.biBitCount = 24; |
1218 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, | 1207 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, |
1219 DIB_RGB_COLORS); | 1208 DIB_RGB_COLORS); |
1220 ret = pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0, | 1209 ret = |
1221 pIccTransform); | 1210 pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0, nullptr); |
1222 } else { | 1211 } else { |
1223 ret = FALSE; | 1212 ret = FALSE; |
1224 } | 1213 } |
1225 } | 1214 } |
1226 if (pBitmap->HasAlpha() && ret) { | 1215 if (pBitmap->HasAlpha() && ret) |
1227 pBitmap->LoadChannel(FXDIB_Alpha, 0xff); | 1216 pBitmap->LoadChannel(FXDIB_Alpha, 0xff); |
1228 } | 1217 |
1229 DeleteObject(hbmp); | 1218 DeleteObject(hbmp); |
1230 DeleteObject(hDCMemory); | 1219 DeleteObject(hDCMemory); |
1231 return ret; | 1220 return ret; |
1232 } | 1221 } |
1233 | 1222 |
1234 FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, | 1223 FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, |
1235 uint32_t color, | 1224 uint32_t color, |
1236 const FX_RECT* pSrcRect, | 1225 const FX_RECT* pSrcRect, |
1237 int left, | 1226 int left, |
1238 int top, | 1227 int top, |
1239 int blend_type, | 1228 int blend_type) { |
1240 int alpha_flag, | |
1241 void* pIccTransform) { | |
1242 ASSERT(blend_type == FXDIB_BLEND_NORMAL); | 1229 ASSERT(blend_type == FXDIB_BLEND_NORMAL); |
1243 if (pSource->IsAlphaMask()) { | 1230 if (pSource->IsAlphaMask()) { |
1244 int width = pSource->GetWidth(), height = pSource->GetHeight(); | 1231 int width = pSource->GetWidth(), height = pSource->GetHeight(); |
1245 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) | 1232 int alpha = FXARGB_A(color); |
1246 ? FXGETFLAG_ALPHA_FILL(alpha_flag) | |
1247 : FXARGB_A(color); | |
1248 if (pSource->GetBPP() != 1 || alpha != 255) { | 1233 if (pSource->GetBPP() != 1 || alpha != 255) { |
1249 CFX_DIBitmap background; | 1234 CFX_DIBitmap background; |
1250 if (!background.Create(width, height, FXDIB_Rgb32) || | 1235 if (!background.Create(width, height, FXDIB_Rgb32) || |
1251 !GetDIBits(&background, left, top, nullptr) || | 1236 !GetDIBits(&background, left, top) || |
1252 !background.CompositeMask(0, 0, width, height, pSource, color, 0, 0, | 1237 !background.CompositeMask(0, 0, width, height, pSource, color, 0, 0, |
1253 FXDIB_BLEND_NORMAL, nullptr, FALSE, | 1238 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, |
1254 alpha_flag, pIccTransform)) { | 1239 nullptr)) { |
1255 return FALSE; | 1240 return FALSE; |
1256 } | 1241 } |
1257 FX_RECT src_rect(0, 0, width, height); | 1242 FX_RECT src_rect(0, 0, width, height); |
1258 return SetDIBits(&background, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, | 1243 return SetDIBits(&background, 0, &src_rect, left, top, |
1259 0, nullptr); | 1244 FXDIB_BLEND_NORMAL); |
1260 } | 1245 } |
1261 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), | 1246 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), |
1262 top + pSrcRect->Height()); | 1247 top + pSrcRect->Height()); |
1263 return StretchDIBits(pSource, color, left - pSrcRect->left, | 1248 return StretchDIBits(pSource, color, left - pSrcRect->left, |
1264 top - pSrcRect->top, width, height, &clip_rect, 0, | 1249 top - pSrcRect->top, width, height, &clip_rect, 0, |
1265 alpha_flag, pIccTransform, FXDIB_BLEND_NORMAL); | 1250 FXDIB_BLEND_NORMAL); |
1266 } | 1251 } |
1267 int width = pSrcRect->Width(), height = pSrcRect->Height(); | 1252 int width = pSrcRect->Width(), height = pSrcRect->Height(); |
1268 if (pSource->HasAlpha()) { | 1253 if (pSource->HasAlpha()) { |
1269 CFX_DIBitmap bitmap; | 1254 CFX_DIBitmap bitmap; |
1270 if (!bitmap.Create(width, height, FXDIB_Rgb) || | 1255 if (!bitmap.Create(width, height, FXDIB_Rgb) || |
1271 !GetDIBits(&bitmap, left, top, nullptr) || | 1256 !GetDIBits(&bitmap, left, top) || |
1272 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, | 1257 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, |
1273 pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, | 1258 pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, |
1274 FALSE, pIccTransform)) { | 1259 FALSE, nullptr)) { |
1275 return FALSE; | 1260 return FALSE; |
1276 } | 1261 } |
1277 FX_RECT src_rect(0, 0, width, height); | 1262 FX_RECT src_rect(0, 0, width, height); |
1278 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0, | 1263 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); |
1279 nullptr); | |
1280 } | 1264 } |
1281 CFX_DIBExtractor temp(pSource); | 1265 CFX_DIBExtractor temp(pSource); |
1282 CFX_DIBitmap* pBitmap = temp; | 1266 CFX_DIBitmap* pBitmap = temp; |
1283 if (pBitmap) { | 1267 if (!pBitmap) |
1284 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); | 1268 return FALSE; |
1285 } | 1269 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, nullptr); |
1286 return FALSE; | |
1287 } | 1270 } |
1288 | 1271 |
1289 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, | 1272 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, |
1290 uint32_t color, | 1273 uint32_t color, |
1291 int dest_left, | 1274 int dest_left, |
1292 int dest_top, | 1275 int dest_top, |
1293 int dest_width, | 1276 int dest_width, |
1294 int dest_height, | 1277 int dest_height, |
1295 const FX_RECT* pClipRect, | 1278 const FX_RECT* pClipRect, |
1296 int render_flags, | 1279 int render_flags) { |
1297 int alpha_flag, | |
1298 void* pIccTransform, | |
1299 int blend_type) { | |
1300 FX_RECT bitmap_clip = *pClipRect; | 1280 FX_RECT bitmap_clip = *pClipRect; |
1301 if (dest_width < 0) { | 1281 if (dest_width < 0) |
1302 dest_left += dest_width; | 1282 dest_left += dest_width; |
1303 } | 1283 |
1304 if (dest_height < 0) { | 1284 if (dest_height < 0) |
1305 dest_top += dest_height; | 1285 dest_top += dest_height; |
1306 } | 1286 |
1307 bitmap_clip.Offset(-dest_left, -dest_top); | 1287 bitmap_clip.Offset(-dest_left, -dest_top); |
1308 std::unique_ptr<CFX_DIBitmap> pStretched( | 1288 std::unique_ptr<CFX_DIBitmap> pStretched( |
1309 pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip)); | 1289 pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip)); |
1310 if (!pStretched) | 1290 if (!pStretched) |
1311 return TRUE; | 1291 return TRUE; |
1312 | 1292 |
1313 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); | 1293 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); |
1314 return SetDIBits(pStretched.get(), color, &src_rect, pClipRect->left, | 1294 return SetDIBits(pStretched.get(), color, &src_rect, pClipRect->left, |
1315 pClipRect->top, FXDIB_BLEND_NORMAL, alpha_flag, | 1295 pClipRect->top, FXDIB_BLEND_NORMAL); |
1316 pIccTransform); | |
1317 } | 1296 } |
1318 | 1297 |
1319 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, | 1298 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, |
1320 uint32_t color, | 1299 uint32_t color, |
1321 int dest_left, | 1300 int dest_left, |
1322 int dest_top, | 1301 int dest_top, |
1323 int dest_width, | 1302 int dest_width, |
1324 int dest_height, | 1303 int dest_height, |
1325 const FX_RECT* pClipRect, | 1304 const FX_RECT* pClipRect, |
1326 uint32_t flags, | 1305 uint32_t flags, |
1327 int alpha_flag, | |
1328 void* pIccTransform, | |
1329 int blend_type) { | 1306 int blend_type) { |
1330 ASSERT(pSource && pClipRect); | 1307 ASSERT(pSource && pClipRect); |
1331 if (flags || dest_width > 10000 || dest_width < -10000 || | 1308 if (flags || dest_width > 10000 || dest_width < -10000 || |
1332 dest_height > 10000 || dest_height < -10000) { | 1309 dest_height > 10000 || dest_height < -10000) { |
1333 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, | 1310 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, |
1334 dest_width, dest_height, pClipRect, flags, | 1311 dest_width, dest_height, pClipRect, flags); |
1335 alpha_flag, pIccTransform, blend_type); | |
1336 } | 1312 } |
1337 if (pSource->IsAlphaMask()) { | 1313 if (pSource->IsAlphaMask()) { |
1338 FX_RECT image_rect; | 1314 FX_RECT image_rect; |
1339 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; | 1315 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; |
1340 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left; | 1316 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left; |
1341 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height; | 1317 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height; |
1342 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top; | 1318 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top; |
1343 FX_RECT clip_rect = image_rect; | 1319 FX_RECT clip_rect = image_rect; |
1344 clip_rect.Intersect(*pClipRect); | 1320 clip_rect.Intersect(*pClipRect); |
1345 clip_rect.Offset(-image_rect.left, -image_rect.top); | 1321 clip_rect.Offset(-image_rect.left, -image_rect.top); |
1346 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); | 1322 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); |
1347 std::unique_ptr<CFX_DIBitmap> pStretched( | 1323 std::unique_ptr<CFX_DIBitmap> pStretched( |
1348 pSource->StretchTo(dest_width, dest_height, flags, &clip_rect)); | 1324 pSource->StretchTo(dest_width, dest_height, flags, &clip_rect)); |
1349 if (!pStretched) | 1325 if (!pStretched) |
1350 return TRUE; | 1326 return TRUE; |
1351 | 1327 |
1352 CFX_DIBitmap background; | 1328 CFX_DIBitmap background; |
1353 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || | 1329 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || |
1354 !GetDIBits(&background, image_rect.left + clip_rect.left, | 1330 !GetDIBits(&background, image_rect.left + clip_rect.left, |
1355 image_rect.top + clip_rect.top, nullptr) || | 1331 image_rect.top + clip_rect.top) || |
1356 !background.CompositeMask( | 1332 !background.CompositeMask( |
1357 0, 0, clip_width, clip_height, pStretched.get(), color, 0, 0, | 1333 0, 0, clip_width, clip_height, pStretched.get(), color, 0, 0, |
1358 FXDIB_BLEND_NORMAL, nullptr, FALSE, alpha_flag, pIccTransform)) { | 1334 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, nullptr)) { |
1359 return FALSE; | 1335 return FALSE; |
1360 } | 1336 } |
1361 | 1337 |
1362 FX_RECT src_rect(0, 0, clip_width, clip_height); | 1338 FX_RECT src_rect(0, 0, clip_width, clip_height); |
1363 return SetDIBits( | 1339 return SetDIBits(&background, 0, &src_rect, |
1364 &background, 0, &src_rect, image_rect.left + clip_rect.left, | 1340 image_rect.left + clip_rect.left, |
1365 image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL, 0, nullptr); | 1341 image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL); |
1366 } | 1342 } |
1367 if (pSource->HasAlpha()) { | 1343 if (pSource->HasAlpha()) { |
1368 CWin32Platform* pPlatform = | 1344 CWin32Platform* pPlatform = |
1369 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); | 1345 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); |
1370 if (pPlatform->m_GdiplusExt.IsAvailable() && !pIccTransform && | 1346 if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) { |
1371 !pSource->IsCmykImage()) { | |
1372 CFX_DIBExtractor temp(pSource); | 1347 CFX_DIBExtractor temp(pSource); |
1373 CFX_DIBitmap* pBitmap = temp; | 1348 CFX_DIBitmap* pBitmap = temp; |
1374 if (!pBitmap) | 1349 if (!pBitmap) |
1375 return FALSE; | 1350 return FALSE; |
1376 return pPlatform->m_GdiplusExt.StretchDIBits( | 1351 return pPlatform->m_GdiplusExt.StretchDIBits( |
1377 m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, | 1352 m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, |
1378 pClipRect, flags); | 1353 pClipRect, flags); |
1379 } | 1354 } |
1380 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, | 1355 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, |
1381 dest_width, dest_height, pClipRect, flags, | 1356 dest_width, dest_height, pClipRect, flags); |
1382 alpha_flag, pIccTransform, blend_type); | |
1383 } | 1357 } |
1384 CFX_DIBExtractor temp(pSource); | 1358 CFX_DIBExtractor temp(pSource); |
1385 CFX_DIBitmap* pBitmap = temp; | 1359 CFX_DIBitmap* pBitmap = temp; |
1386 if (pBitmap) { | 1360 if (!pBitmap) |
1387 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, | 1361 return FALSE; |
1388 dest_height, flags, pIccTransform); | 1362 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, |
1389 } | 1363 dest_height, flags, nullptr); |
1390 return FALSE; | |
1391 } | 1364 } |
1392 | 1365 |
1393 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) { | 1366 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) { |
1394 SetDeviceDriver(CreateDriver(hDC)); | 1367 SetDeviceDriver(CreateDriver(hDC)); |
1395 } | 1368 } |
1396 | 1369 |
1397 CFX_WindowsDevice::~CFX_WindowsDevice() {} | 1370 CFX_WindowsDevice::~CFX_WindowsDevice() {} |
1398 | 1371 |
1399 HDC CFX_WindowsDevice::GetDC() const { | 1372 HDC CFX_WindowsDevice::GetDC() const { |
1400 IFX_RenderDeviceDriver* pRDD = GetDeviceDriver(); | 1373 IFX_RenderDeviceDriver* pRDD = GetDeviceDriver(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 if (m_hDC) { | 1415 if (m_hDC) { |
1443 SelectObject(m_hDC, m_hOldBitmap); | 1416 SelectObject(m_hDC, m_hOldBitmap); |
1444 DeleteDC(m_hDC); | 1417 DeleteDC(m_hDC); |
1445 } | 1418 } |
1446 if (m_hBitmap) | 1419 if (m_hBitmap) |
1447 DeleteObject(m_hBitmap); | 1420 DeleteObject(m_hBitmap); |
1448 delete GetBitmap(); | 1421 delete GetBitmap(); |
1449 } | 1422 } |
1450 | 1423 |
1451 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ | 1424 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ |
OLD | NEW |