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

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

Issue 2059883004: Remove default arguments from IFX_RenderDeviceDriver. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: mac Created 4 years, 6 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
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 "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
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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); 993 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr);
992 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); 994 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2));
993 } 995 }
994 996
995 FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, 997 FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
996 const CFX_Matrix* pMatrix, 998 const CFX_Matrix* pMatrix,
997 const CFX_GraphStateData* pGraphState, 999 const CFX_GraphStateData* pGraphState,
998 uint32_t fill_color, 1000 uint32_t fill_color,
999 uint32_t stroke_color, 1001 uint32_t stroke_color,
1000 int fill_mode, 1002 int fill_mode,
1001 int alpha_flag,
1002 void* pIccTransform,
1003 int blend_type) { 1003 int blend_type) {
1004 if (blend_type != FXDIB_BLEND_NORMAL) { 1004 if (blend_type != FXDIB_BLEND_NORMAL)
1005 return FALSE; 1005 return FALSE;
1006 } 1006
1007 Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); 1007 Color2Argb(fill_color, fill_color, 1 << 24, nullptr);
1008 Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform); 1008 Color2Argb(stroke_color, stroke_color, 0, nullptr);
1009 CWin32Platform* pPlatform = 1009 CWin32Platform* pPlatform =
1010 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); 1010 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
1011 if (!(pGraphState || stroke_color == 0) && 1011 if (!(pGraphState || stroke_color == 0) &&
1012 !pPlatform->m_GdiplusExt.IsAvailable()) { 1012 !pPlatform->m_GdiplusExt.IsAvailable()) {
1013 CFX_FloatRect bbox_f = pPathData->GetBoundingBox(); 1013 CFX_FloatRect bbox_f = pPathData->GetBoundingBox();
1014 if (pMatrix) { 1014 if (pMatrix) {
1015 bbox_f.Transform(pMatrix); 1015 bbox_f.Transform(pMatrix);
1016 } 1016 }
1017 FX_RECT bbox = bbox_f.GetInnerRect(); 1017 FX_RECT bbox = bbox_f.GetInnerRect();
1018 if (bbox.Width() <= 0) { 1018 if (bbox.Width() <= 0) {
1019 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), 1019 return DrawCosmeticLine(
1020 (FX_FLOAT)(bbox.left), 1020 (FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.left),
1021 (FX_FLOAT)(bbox.bottom + 1), fill_color, 1021 (FX_FLOAT)(bbox.bottom + 1), fill_color, FXDIB_BLEND_NORMAL);
1022 alpha_flag, pIccTransform, FXDIB_BLEND_NORMAL); 1022 }
1023 } else if (bbox.Height() <= 0) { 1023 if (bbox.Height() <= 0) {
1024 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), 1024 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top),
1025 (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), 1025 (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top),
1026 fill_color, alpha_flag, pIccTransform, 1026 fill_color, FXDIB_BLEND_NORMAL);
1027 FXDIB_BLEND_NORMAL);
1028 } 1027 }
1029 } 1028 }
1030 int fill_alpha = FXARGB_A(fill_color); 1029 int fill_alpha = FXARGB_A(fill_color);
1031 int stroke_alpha = FXARGB_A(stroke_color); 1030 int stroke_alpha = FXARGB_A(stroke_color);
1032 FX_BOOL bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) || 1031 FX_BOOL bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) ||
1033 (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState); 1032 (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState);
1034 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha) { 1033 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha)
1035 return FALSE; 1034 return FALSE;
1036 } 1035
1037 if (pPlatform->m_GdiplusExt.IsAvailable()) { 1036 if (pPlatform->m_GdiplusExt.IsAvailable()) {
1038 if (bDrawAlpha || 1037 if (bDrawAlpha ||
1039 ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFILL_FULLCOVER)) || 1038 ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFILL_FULLCOVER)) ||
1040 (pGraphState && pGraphState->m_DashCount))) { 1039 (pGraphState && pGraphState->m_DashCount))) {
1041 if (!((!pMatrix || MatrixNoScaled(pMatrix)) && pGraphState && 1040 if (!((!pMatrix || MatrixNoScaled(pMatrix)) && pGraphState &&
1042 pGraphState->m_LineWidth == 1.f && 1041 pGraphState->m_LineWidth == 1.f &&
1043 (pPathData->GetPointCount() == 5 || 1042 (pPathData->GetPointCount() == 5 ||
1044 pPathData->GetPointCount() == 4) && 1043 pPathData->GetPointCount() == 4) &&
1045 pPathData->IsRect())) { 1044 pPathData->IsRect())) {
1046 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, 1045 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix,
(...skipping 13 matching lines...) Expand all
1060 hPen = CreatePen(pGraphState, pMatrix, stroke_color); 1059 hPen = CreatePen(pGraphState, pMatrix, stroke_color);
1061 hPen = (HPEN)SelectObject(m_hDC, hPen); 1060 hPen = (HPEN)SelectObject(m_hDC, hPen);
1062 } 1061 }
1063 if (fill_mode && fill_alpha) { 1062 if (fill_mode && fill_alpha) {
1064 SetPolyFillMode(m_hDC, fill_mode); 1063 SetPolyFillMode(m_hDC, fill_mode);
1065 hBrush = CreateBrush(fill_color); 1064 hBrush = CreateBrush(fill_color);
1066 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); 1065 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush);
1067 } 1066 }
1068 if (pPathData->GetPointCount() == 2 && pGraphState && 1067 if (pPathData->GetPointCount() == 2 && pGraphState &&
1069 pGraphState->m_DashCount) { 1068 pGraphState->m_DashCount) {
1070 FX_FLOAT x1 = pPathData->GetPointX(0), y1 = pPathData->GetPointY(0); 1069 FX_FLOAT x1 = pPathData->GetPointX(0);
1070 FX_FLOAT y1 = pPathData->GetPointY(0);
1071 FX_FLOAT x2 = pPathData->GetPointX(1);
1072 FX_FLOAT y2 = pPathData->GetPointY(1);
1071 if (pMatrix) { 1073 if (pMatrix) {
1072 pMatrix->Transform(x1, y1); 1074 pMatrix->Transform(x1, y1);
1073 }
1074 FX_FLOAT x2 = pPathData->GetPointX(1), y2 = pPathData->GetPointY(1);
1075 if (pMatrix) {
1076 pMatrix->Transform(x2, y2); 1075 pMatrix->Transform(x2, y2);
1077 } 1076 }
1078 DrawLine(x1, y1, x2, y2); 1077 DrawLine(x1, y1, x2, y2);
1079 } else { 1078 } else {
1080 SetPathToDC(m_hDC, pPathData, pMatrix); 1079 SetPathToDC(m_hDC, pPathData, pMatrix);
1081 if (pGraphState && stroke_alpha) { 1080 if (pGraphState && stroke_alpha) {
1082 if (fill_mode && fill_alpha) { 1081 if (fill_mode && fill_alpha) {
1083 if (old_fill_mode & FX_FILL_TEXT_MODE) { 1082 if (old_fill_mode & FX_FILL_TEXT_MODE) {
1084 StrokeAndFillPath(m_hDC); 1083 StrokeAndFillPath(m_hDC);
1085 } else { 1084 } else {
(...skipping 12 matching lines...) Expand all
1098 hPen = (HPEN)SelectObject(m_hDC, hPen); 1097 hPen = (HPEN)SelectObject(m_hDC, hPen);
1099 DeleteObject(hPen); 1098 DeleteObject(hPen);
1100 } 1099 }
1101 if (hBrush) { 1100 if (hBrush) {
1102 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); 1101 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush);
1103 DeleteObject(hBrush); 1102 DeleteObject(hBrush);
1104 } 1103 }
1105 return TRUE; 1104 return TRUE;
1106 } 1105 }
1107 1106
1108 FX_BOOL CGdiDeviceDriver::FillRect(const FX_RECT* pRect, 1107 FX_BOOL CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect,
1109 uint32_t fill_color, 1108 uint32_t fill_color,
1110 int alpha_flag, 1109 int blend_type) {
1111 void* pIccTransform, 1110 if (blend_type != FXDIB_BLEND_NORMAL)
1112 int blend_type) {
1113 if (blend_type != FXDIB_BLEND_NORMAL) {
1114 return FALSE; 1111 return FALSE;
1115 } 1112
1116 Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); 1113 Color2Argb(fill_color, fill_color, 1 << 24, nullptr);
1117 int alpha; 1114 int alpha;
1118 FX_COLORREF rgb; 1115 FX_COLORREF rgb;
1119 ArgbDecode(fill_color, alpha, rgb); 1116 ArgbDecode(fill_color, alpha, rgb);
1120 if (alpha == 0) { 1117 if (alpha == 0)
1121 return TRUE; 1118 return TRUE;
1122 } 1119
1123 if (alpha < 255) { 1120 if (alpha < 255)
1124 return FALSE; 1121 return FALSE;
1125 } 1122
1126 HBRUSH hBrush = CreateSolidBrush(rgb); 1123 HBRUSH hBrush = CreateSolidBrush(rgb);
1127 ::FillRect(m_hDC, (RECT*)pRect, hBrush); 1124 ::FillRect(m_hDC, (RECT*)pRect, hBrush);
1128 DeleteObject(hBrush); 1125 DeleteObject(hBrush);
1129 return TRUE; 1126 return TRUE;
1130 } 1127 }
1131 1128
1132 FX_BOOL CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, 1129 FX_BOOL CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData,
1133 const CFX_Matrix* pMatrix, 1130 const CFX_Matrix* pMatrix,
1134 int fill_mode) { 1131 int fill_mode) {
1135 if (pPathData->GetPointCount() == 5) { 1132 if (pPathData->GetPointCount() == 5) {
(...skipping 23 matching lines...) Expand all
1159 hPen = (HPEN)SelectObject(m_hDC, hPen); 1156 hPen = (HPEN)SelectObject(m_hDC, hPen);
1160 DeleteObject(hPen); 1157 DeleteObject(hPen);
1161 return ret; 1158 return ret;
1162 } 1159 }
1163 1160
1164 FX_BOOL CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, 1161 FX_BOOL CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1,
1165 FX_FLOAT y1, 1162 FX_FLOAT y1,
1166 FX_FLOAT x2, 1163 FX_FLOAT x2,
1167 FX_FLOAT y2, 1164 FX_FLOAT y2,
1168 uint32_t color, 1165 uint32_t color,
1169 int alpha_flag,
1170 void* pIccTransform,
1171 int blend_type) { 1166 int blend_type) {
1172 if (blend_type != FXDIB_BLEND_NORMAL) { 1167 if (blend_type != FXDIB_BLEND_NORMAL)
1173 return FALSE; 1168 return FALSE;
1174 } 1169
1175 Color2Argb(color, color, alpha_flag | (1 << 24), pIccTransform); 1170 Color2Argb(color, color, 1 << 24, nullptr);
1176 int a; 1171 int a;
1177 FX_COLORREF rgb; 1172 FX_COLORREF rgb;
1178 ArgbDecode(color, a, rgb); 1173 ArgbDecode(color, a, rgb);
1179 if (a == 0) { 1174 if (a == 0)
1180 return TRUE; 1175 return TRUE;
1181 } 1176
1182 HPEN hPen = CreatePen(PS_SOLID, 1, rgb); 1177 HPEN hPen = CreatePen(PS_SOLID, 1, rgb);
1183 hPen = (HPEN)SelectObject(m_hDC, hPen); 1178 hPen = (HPEN)SelectObject(m_hDC, hPen);
1184 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); 1179 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr);
1185 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); 1180 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2));
1186 hPen = (HPEN)SelectObject(m_hDC, hPen); 1181 hPen = (HPEN)SelectObject(m_hDC, hPen);
1187 DeleteObject(hPen); 1182 DeleteObject(hPen);
1188 return TRUE; 1183 return TRUE;
1189 } 1184 }
1190 1185
1191 FX_BOOL CGdiDeviceDriver::DeleteDeviceRgn(void* pRgn) { 1186 FX_BOOL CGdiDeviceDriver::DeleteDeviceRgn(void* pRgn) {
1192 DeleteObject((HGDIOBJ)pRgn); 1187 DeleteObject((HGDIOBJ)pRgn);
1193 return TRUE; 1188 return TRUE;
1194 } 1189 }
1195 1190
1196 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) 1191 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC)
1197 : CGdiDeviceDriver(hDC, FXDC_DISPLAY) { 1192 : CGdiDeviceDriver(hDC, FXDC_DISPLAY) {
1198 CWin32Platform* pPlatform = 1193 CWin32Platform* pPlatform =
1199 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); 1194 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
1200 if (pPlatform->m_GdiplusExt.IsAvailable()) { 1195 if (pPlatform->m_GdiplusExt.IsAvailable()) {
1201 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE; 1196 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE;
1202 } 1197 }
1203 } 1198 }
1204 1199
1205 FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, 1200 CGdiDisplayDriver::~CGdiDisplayDriver() {}
1206 int left, 1201
1207 int top, 1202 FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) {
1208 void* pIccTransform,
1209 FX_BOOL bDEdge) {
1210 FX_BOOL ret = FALSE; 1203 FX_BOOL ret = FALSE;
1211 int width = pBitmap->GetWidth(); 1204 int width = pBitmap->GetWidth();
1212 int height = pBitmap->GetHeight(); 1205 int height = pBitmap->GetHeight();
1213 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height); 1206 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height);
1214 HDC hDCMemory = CreateCompatibleDC(m_hDC); 1207 HDC hDCMemory = CreateCompatibleDC(m_hDC);
1215 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp); 1208 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp);
1216 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY); 1209 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY);
1217 SelectObject(hDCMemory, holdbmp); 1210 SelectObject(hDCMemory, holdbmp);
1218 BITMAPINFO bmi; 1211 BITMAPINFO bmi;
1219 FXSYS_memset(&bmi, 0, sizeof bmi); 1212 FXSYS_memset(&bmi, 0, sizeof bmi);
1220 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader; 1213 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader;
1221 bmi.bmiHeader.biBitCount = pBitmap->GetBPP(); 1214 bmi.bmiHeader.biBitCount = pBitmap->GetBPP();
1222 bmi.bmiHeader.biHeight = -height; 1215 bmi.bmiHeader.biHeight = -height;
1223 bmi.bmiHeader.biPlanes = 1; 1216 bmi.bmiHeader.biPlanes = 1;
1224 bmi.bmiHeader.biWidth = width; 1217 bmi.bmiHeader.biWidth = width;
1225 if (!CFX_GEModule::Get()->GetCodecModule() || 1218 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage()) {
1226 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) {
1227 pIccTransform = nullptr;
1228 }
1229 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && !pIccTransform) {
1230 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi, 1219 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi,
1231 DIB_RGB_COLORS) == height; 1220 DIB_RGB_COLORS) == height;
1232 } else { 1221 } else {
1233 CFX_DIBitmap bitmap; 1222 CFX_DIBitmap bitmap;
1234 if (bitmap.Create(width, height, FXDIB_Rgb)) { 1223 if (bitmap.Create(width, height, FXDIB_Rgb)) {
1235 bmi.bmiHeader.biBitCount = 24; 1224 bmi.bmiHeader.biBitCount = 24;
1236 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, 1225 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi,
1237 DIB_RGB_COLORS); 1226 DIB_RGB_COLORS);
1238 ret = pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0, 1227 ret =
1239 pIccTransform); 1228 pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0, nullptr);
1240 } else { 1229 } else {
1241 ret = FALSE; 1230 ret = FALSE;
1242 } 1231 }
1243 } 1232 }
1244 if (pBitmap->HasAlpha() && ret) { 1233 if (pBitmap->HasAlpha() && ret)
1245 pBitmap->LoadChannel(FXDIB_Alpha, 0xff); 1234 pBitmap->LoadChannel(FXDIB_Alpha, 0xff);
1246 } 1235
1247 DeleteObject(hbmp); 1236 DeleteObject(hbmp);
1248 DeleteObject(hDCMemory); 1237 DeleteObject(hDCMemory);
1249 return ret; 1238 return ret;
1250 } 1239 }
1251 1240
1252 FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, 1241 FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource,
1253 uint32_t color, 1242 uint32_t color,
1254 const FX_RECT* pSrcRect, 1243 const FX_RECT* pSrcRect,
1255 int left, 1244 int left,
1256 int top, 1245 int top,
1257 int blend_type, 1246 int blend_type) {
1258 int alpha_flag,
1259 void* pIccTransform) {
1260 ASSERT(blend_type == FXDIB_BLEND_NORMAL); 1247 ASSERT(blend_type == FXDIB_BLEND_NORMAL);
1261 if (pSource->IsAlphaMask()) { 1248 if (pSource->IsAlphaMask()) {
1262 int width = pSource->GetWidth(), height = pSource->GetHeight(); 1249 int width = pSource->GetWidth(), height = pSource->GetHeight();
1263 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) 1250 int alpha = FXARGB_A(color);
1264 ? FXGETFLAG_ALPHA_FILL(alpha_flag)
1265 : FXARGB_A(color);
1266 if (pSource->GetBPP() != 1 || alpha != 255) { 1251 if (pSource->GetBPP() != 1 || alpha != 255) {
1267 CFX_DIBitmap background; 1252 CFX_DIBitmap background;
1268 if (!background.Create(width, height, FXDIB_Rgb32) || 1253 if (!background.Create(width, height, FXDIB_Rgb32) ||
1269 !GetDIBits(&background, left, top, nullptr) || 1254 !GetDIBits(&background, left, top) ||
1270 !background.CompositeMask(0, 0, width, height, pSource, color, 0, 0, 1255 !background.CompositeMask(0, 0, width, height, pSource, color, 0, 0,
1271 FXDIB_BLEND_NORMAL, nullptr, FALSE, 1256 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0,
1272 alpha_flag, pIccTransform)) { 1257 nullptr)) {
1273 return FALSE; 1258 return FALSE;
1274 } 1259 }
1275 FX_RECT src_rect(0, 0, width, height); 1260 FX_RECT src_rect(0, 0, width, height);
1276 return SetDIBits(&background, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 1261 return SetDIBits(&background, 0, &src_rect, left, top,
1277 0, nullptr); 1262 FXDIB_BLEND_NORMAL);
1278 } 1263 }
1279 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), 1264 FX_RECT clip_rect(left, top, left + pSrcRect->Width(),
1280 top + pSrcRect->Height()); 1265 top + pSrcRect->Height());
1281 return StretchDIBits(pSource, color, left - pSrcRect->left, 1266 return StretchDIBits(pSource, color, left - pSrcRect->left,
1282 top - pSrcRect->top, width, height, &clip_rect, 0, 1267 top - pSrcRect->top, width, height, &clip_rect, 0,
1283 alpha_flag, pIccTransform, FXDIB_BLEND_NORMAL); 1268 FXDIB_BLEND_NORMAL);
1284 } 1269 }
1285 int width = pSrcRect->Width(), height = pSrcRect->Height(); 1270 int width = pSrcRect->Width(), height = pSrcRect->Height();
1286 if (pSource->HasAlpha()) { 1271 if (pSource->HasAlpha()) {
1287 CFX_DIBitmap bitmap; 1272 CFX_DIBitmap bitmap;
1288 if (!bitmap.Create(width, height, FXDIB_Rgb) || 1273 if (!bitmap.Create(width, height, FXDIB_Rgb) ||
1289 !GetDIBits(&bitmap, left, top, nullptr) || 1274 !GetDIBits(&bitmap, left, top) ||
1290 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, 1275 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left,
1291 pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, 1276 pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr,
1292 FALSE, pIccTransform)) { 1277 FALSE, nullptr)) {
1293 return FALSE; 1278 return FALSE;
1294 } 1279 }
1295 FX_RECT src_rect(0, 0, width, height); 1280 FX_RECT src_rect(0, 0, width, height);
1296 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0, 1281 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL);
1297 nullptr);
1298 } 1282 }
1299 CFX_DIBExtractor temp(pSource); 1283 CFX_DIBExtractor temp(pSource);
1300 CFX_DIBitmap* pBitmap = temp; 1284 CFX_DIBitmap* pBitmap = temp;
1301 if (pBitmap) { 1285 if (!pBitmap)
1302 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); 1286 return FALSE;
1303 } 1287 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, nullptr);
1304 return FALSE;
1305 } 1288 }
1306 1289
1307 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, 1290 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource,
1308 uint32_t color, 1291 uint32_t color,
1309 int dest_left, 1292 int dest_left,
1310 int dest_top, 1293 int dest_top,
1311 int dest_width, 1294 int dest_width,
1312 int dest_height, 1295 int dest_height,
1313 const FX_RECT* pClipRect, 1296 const FX_RECT* pClipRect,
1314 int render_flags, 1297 int render_flags) {
1315 int alpha_flag,
1316 void* pIccTransform,
1317 int blend_type) {
1318 FX_RECT bitmap_clip = *pClipRect; 1298 FX_RECT bitmap_clip = *pClipRect;
1319 if (dest_width < 0) { 1299 if (dest_width < 0)
1320 dest_left += dest_width; 1300 dest_left += dest_width;
1321 } 1301
1322 if (dest_height < 0) { 1302 if (dest_height < 0)
1323 dest_top += dest_height; 1303 dest_top += dest_height;
1324 } 1304
1325 bitmap_clip.Offset(-dest_left, -dest_top); 1305 bitmap_clip.Offset(-dest_left, -dest_top);
1326 std::unique_ptr<CFX_DIBitmap> pStretched( 1306 std::unique_ptr<CFX_DIBitmap> pStretched(
1327 pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip)); 1307 pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip));
1328 if (!pStretched) 1308 if (!pStretched)
1329 return TRUE; 1309 return TRUE;
1330 1310
1331 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); 1311 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight());
1332 return SetDIBits(pStretched.get(), color, &src_rect, pClipRect->left, 1312 return SetDIBits(pStretched.get(), color, &src_rect, pClipRect->left,
1333 pClipRect->top, FXDIB_BLEND_NORMAL, alpha_flag, 1313 pClipRect->top, FXDIB_BLEND_NORMAL);
1334 pIccTransform);
1335 } 1314 }
1336 1315
1337 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, 1316 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource,
1338 uint32_t color, 1317 uint32_t color,
1339 int dest_left, 1318 int dest_left,
1340 int dest_top, 1319 int dest_top,
1341 int dest_width, 1320 int dest_width,
1342 int dest_height, 1321 int dest_height,
1343 const FX_RECT* pClipRect, 1322 const FX_RECT* pClipRect,
1344 uint32_t flags, 1323 uint32_t flags,
1345 int alpha_flag,
1346 void* pIccTransform,
1347 int blend_type) { 1324 int blend_type) {
1348 ASSERT(pSource && pClipRect); 1325 ASSERT(pSource && pClipRect);
1349 if (flags || dest_width > 10000 || dest_width < -10000 || 1326 if (flags || dest_width > 10000 || dest_width < -10000 ||
1350 dest_height > 10000 || dest_height < -10000) { 1327 dest_height > 10000 || dest_height < -10000) {
1351 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, 1328 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top,
1352 dest_width, dest_height, pClipRect, flags, 1329 dest_width, dest_height, pClipRect, flags);
1353 alpha_flag, pIccTransform, blend_type);
1354 } 1330 }
1355 if (pSource->IsAlphaMask()) { 1331 if (pSource->IsAlphaMask()) {
1356 FX_RECT image_rect; 1332 FX_RECT image_rect;
1357 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; 1333 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width;
1358 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left; 1334 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left;
1359 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height; 1335 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height;
1360 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top; 1336 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top;
1361 FX_RECT clip_rect = image_rect; 1337 FX_RECT clip_rect = image_rect;
1362 clip_rect.Intersect(*pClipRect); 1338 clip_rect.Intersect(*pClipRect);
1363 clip_rect.Offset(-image_rect.left, -image_rect.top); 1339 clip_rect.Offset(-image_rect.left, -image_rect.top);
1364 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); 1340 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height();
1365 std::unique_ptr<CFX_DIBitmap> pStretched( 1341 std::unique_ptr<CFX_DIBitmap> pStretched(
1366 pSource->StretchTo(dest_width, dest_height, flags, &clip_rect)); 1342 pSource->StretchTo(dest_width, dest_height, flags, &clip_rect));
1367 if (!pStretched) 1343 if (!pStretched)
1368 return TRUE; 1344 return TRUE;
1369 1345
1370 CFX_DIBitmap background; 1346 CFX_DIBitmap background;
1371 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || 1347 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) ||
1372 !GetDIBits(&background, image_rect.left + clip_rect.left, 1348 !GetDIBits(&background, image_rect.left + clip_rect.left,
1373 image_rect.top + clip_rect.top, nullptr) || 1349 image_rect.top + clip_rect.top) ||
1374 !background.CompositeMask( 1350 !background.CompositeMask(
1375 0, 0, clip_width, clip_height, pStretched.get(), color, 0, 0, 1351 0, 0, clip_width, clip_height, pStretched.get(), color, 0, 0,
1376 FXDIB_BLEND_NORMAL, nullptr, FALSE, alpha_flag, pIccTransform)) { 1352 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, nullptr)) {
1377 return FALSE; 1353 return FALSE;
1378 } 1354 }
1379 1355
1380 FX_RECT src_rect(0, 0, clip_width, clip_height); 1356 FX_RECT src_rect(0, 0, clip_width, clip_height);
1381 return SetDIBits( 1357 return SetDIBits(&background, 0, &src_rect,
1382 &background, 0, &src_rect, image_rect.left + clip_rect.left, 1358 image_rect.left + clip_rect.left,
1383 image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL, 0, nullptr); 1359 image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL);
1384 } 1360 }
1385 if (pSource->HasAlpha()) { 1361 if (pSource->HasAlpha()) {
1386 CWin32Platform* pPlatform = 1362 CWin32Platform* pPlatform =
1387 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); 1363 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData();
1388 if (pPlatform->m_GdiplusExt.IsAvailable() && !pIccTransform && 1364 if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) {
1389 !pSource->IsCmykImage()) {
1390 CFX_DIBExtractor temp(pSource); 1365 CFX_DIBExtractor temp(pSource);
1391 CFX_DIBitmap* pBitmap = temp; 1366 CFX_DIBitmap* pBitmap = temp;
1392 if (!pBitmap) 1367 if (!pBitmap)
1393 return FALSE; 1368 return FALSE;
1394 return pPlatform->m_GdiplusExt.StretchDIBits( 1369 return pPlatform->m_GdiplusExt.StretchDIBits(
1395 m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, 1370 m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height,
1396 pClipRect, flags); 1371 pClipRect, flags);
1397 } 1372 }
1398 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, 1373 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top,
1399 dest_width, dest_height, pClipRect, flags, 1374 dest_width, dest_height, pClipRect, flags);
1400 alpha_flag, pIccTransform, blend_type);
1401 } 1375 }
1402 CFX_DIBExtractor temp(pSource); 1376 CFX_DIBExtractor temp(pSource);
1403 CFX_DIBitmap* pBitmap = temp; 1377 CFX_DIBitmap* pBitmap = temp;
1404 if (pBitmap) { 1378 if (!pBitmap)
1405 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, 1379 return FALSE;
1406 dest_height, flags, pIccTransform); 1380 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width,
1407 } 1381 dest_height, flags, nullptr);
1408 return FALSE;
1409 } 1382 }
1410 1383
1411 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) { 1384 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) {
1412 SetDeviceDriver(CreateDriver(hDC)); 1385 SetDeviceDriver(CreateDriver(hDC));
1413 } 1386 }
1414 1387
1415 CFX_WindowsDevice::~CFX_WindowsDevice() {} 1388 CFX_WindowsDevice::~CFX_WindowsDevice() {}
1416 1389
1417 HDC CFX_WindowsDevice::GetDC() const { 1390 HDC CFX_WindowsDevice::GetDC() const {
1418 IFX_RenderDeviceDriver* pRDD = GetDeviceDriver(); 1391 IFX_RenderDeviceDriver* pRDD = GetDeviceDriver();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1460 if (m_hDC) { 1433 if (m_hDC) {
1461 SelectObject(m_hDC, m_hOldBitmap); 1434 SelectObject(m_hDC, m_hOldBitmap);
1462 DeleteDC(m_hDC); 1435 DeleteDC(m_hDC);
1463 } 1436 }
1464 if (m_hBitmap) 1437 if (m_hBitmap)
1465 DeleteObject(m_hBitmap); 1438 DeleteObject(m_hBitmap);
1466 delete GetBitmap(); 1439 delete GetBitmap();
1467 } 1440 }
1468 1441
1469 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ 1442 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698