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

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

Issue 1258093002: FX Bool considered harmful, part 3 (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 4 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/win32/dwrite_int.h ('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>
11 11
12 #include "../../../include/fxcodec/fx_codec.h" 12 #include "../../../include/fxcodec/fx_codec.h"
13 #include "../../../include/fxge/fx_freetype.h" 13 #include "../../../include/fxge/fx_freetype.h"
14 #include "../../../include/fxge/fx_ge_win32.h" 14 #include "../../../include/fxge/fx_ge_win32.h"
15 #include "../agg/include/fx_agg_driver.h" 15 #include "../agg/include/fx_agg_driver.h"
16 #include "../dib/dib_int.h" 16 #include "../dib/dib_int.h"
17 #include "../ge/text_int.h" 17 #include "../ge/text_int.h"
18 #include "dwrite_int.h" 18 #include "dwrite_int.h"
19 #include "win32_int.h" 19 #include "win32_int.h"
20 20
21 class CWin32FontInfo final : public IFX_SystemFontInfo 21 class CWin32FontInfo final : public IFX_SystemFontInfo
22 { 22 {
23 public: 23 public:
24 CWin32FontInfo(); 24 CWin32FontInfo();
25 ~CWin32FontInfo(); 25 ~CWin32FontInfo();
26 virtual void Release(); 26 virtual void Release();
27 virtual» FX_BOOL»» EnumFontList(CFX_FontMapper* pMapper); 27 virtual» bool» » EnumFontList(CFX_FontMapper* pMapper);
28 virtual void*» » MapFont(int weight, FX_BOOL bItalic, int charset , int pitch_family, const FX_CHAR* face, FX_BOOL& bExact); 28 virtual void*» » MapFont(int weight, bool bItalic, int charset, i nt pitch_family, const FX_CHAR* face, bool& bExact);
29 virtual void* GetFont(const FX_CHAR* face) 29 virtual void* GetFont(const FX_CHAR* face)
30 { 30 {
31 return NULL; 31 return NULL;
32 } 32 }
33 virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, uint8_t* buffer , FX_DWORD size); 33 virtual FX_DWORD GetFontData(void* hFont, FX_DWORD table, uint8_t* buffer , FX_DWORD size);
34 virtual void DeleteFont(void* hFont); 34 virtual void DeleteFont(void* hFont);
35 virtual» FX_BOOL»» GetFaceName(void* hFont, CFX_ByteString& name); 35 virtual» bool» » GetFaceName(void* hFont, CFX_ByteString& name);
36 virtual FX_BOOL» » GetFontCharset(void* hFont, int& charset); 36 virtual bool» » GetFontCharset(void* hFont, int& charset);
37 FX_BOOL» » » » IsOpenTypeFromDiv(const LOGFONTA *plf); 37 bool» » » » IsOpenTypeFromDiv(const LOGFONTA *plf);
38 FX_BOOL» » » » IsSupportFontFormDiv(const LOGFONTA* plf ); 38 bool» » » » IsSupportFontFormDiv(const LOGFONTA* plf );
39 void AddInstalledFont(const LOGFONTA *plf, FX _DWORD FontType); 39 void AddInstalledFont(const LOGFONTA *plf, FX _DWORD FontType);
40 void GetGBPreference(CFX_ByteString& face, in t weight, int picth_family); 40 void GetGBPreference(CFX_ByteString& face, in t weight, int picth_family);
41 void GetJapanesePreference(CFX_ByteString& fa ce, int weight, int picth_family); 41 void GetJapanesePreference(CFX_ByteString& fa ce, int weight, int picth_family);
42 CFX_ByteString FindFont(const CFX_ByteString& name); 42 CFX_ByteString FindFont(const CFX_ByteString& name);
43 HDC m_hDC; 43 HDC m_hDC;
44 CFX_FontMapper* m_pMapper; 44 CFX_FontMapper* m_pMapper;
45 CFX_ByteString m_LastFamily; 45 CFX_ByteString m_LastFamily;
46 CFX_ByteString m_KaiTi, m_FangSong; 46 CFX_ByteString m_KaiTi, m_FangSong;
47 }; 47 };
48 CWin32FontInfo::CWin32FontInfo() 48 CWin32FontInfo::CWin32FontInfo()
49 { 49 {
50 m_hDC = CreateCompatibleDC(NULL); 50 m_hDC = CreateCompatibleDC(NULL);
51 } 51 }
52 CWin32FontInfo::~CWin32FontInfo() 52 CWin32FontInfo::~CWin32FontInfo()
53 { 53 {
54 m_pMapper = NULL; 54 m_pMapper = NULL;
55 } 55 }
56 void CWin32FontInfo::Release() 56 void CWin32FontInfo::Release()
57 { 57 {
58 DeleteDC(m_hDC); 58 DeleteDC(m_hDC);
59 delete this; 59 delete this;
60 } 60 }
61 #define TT_MAKE_TAG(x1, x2, x3, x4) (((FX_DWORD)x1<<24)|((FX_DWORD)x2<<16)|((FX_ DWORD)x3<<8)|(FX_DWORD)x4) 61 #define TT_MAKE_TAG(x1, x2, x3, x4) (((FX_DWORD)x1<<24)|((FX_DWORD)x2<<16)|((FX_ DWORD)x3<<8)|(FX_DWORD)x4)
62 FX_BOOL CWin32FontInfo::IsOpenTypeFromDiv(const LOGFONTA *plf) 62 bool CWin32FontInfo::IsOpenTypeFromDiv(const LOGFONTA *plf)
63 { 63 {
64 HFONT hFont = CreateFontIndirectA(plf); 64 HFONT hFont = CreateFontIndirectA(plf);
65 FX_BOOL ret = FALSE; 65 bool ret = false;
66 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0); 66 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0);
67 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) { 67 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) {
68 FX_DWORD lVersion = 0; 68 FX_DWORD lVersion = 0;
69 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD)); 69 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD));
70 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_ t)(lVersion >> 8))) << 16 | 70 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_ t)(lVersion >> 8))) << 16 |
71 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe rsion >> 24)); 71 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe rsion >> 24));
72 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') || 72 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') ||
73 lVersion == 0x00010000 || 73 lVersion == 0x00010000 ||
74 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') || 74 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') ||
75 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') || 75 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') ||
76 lVersion == 0x00020000) { 76 lVersion == 0x00020000) {
77 ret = TRUE; 77 ret = true;
78 } 78 }
79 } 79 }
80 DeleteFont(hFont); 80 DeleteFont(hFont);
81 return ret; 81 return ret;
82 } 82 }
83 FX_BOOL CWin32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf) 83 bool CWin32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf)
84 { 84 {
85 HFONT hFont = CreateFontIndirectA(plf); 85 HFONT hFont = CreateFontIndirectA(plf);
86 FX_BOOL ret = FALSE; 86 bool ret = false;
87 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0); 87 FX_DWORD font_size = GetFontData(hFont, 0, NULL, 0);
88 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) { 88 if (font_size != GDI_ERROR && font_size >= sizeof(FX_DWORD)) {
89 FX_DWORD lVersion = 0; 89 FX_DWORD lVersion = 0;
90 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD)); 90 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(FX_DWORD));
91 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_ t)(lVersion >> 8))) << 16 | 91 lVersion = (((FX_DWORD)(uint8_t)(lVersion)) << 24) | ((FX_DWORD)((uint8_ t)(lVersion >> 8))) << 16 |
92 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe rsion >> 24)); 92 ((FX_DWORD)((uint8_t)(lVersion >> 16))) << 8 | ((uint8_t)(lVe rsion >> 24));
93 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') || 93 if (lVersion == TT_MAKE_TAG('O', 'T', 'T', 'O') ||
94 lVersion == 0x00010000 || 94 lVersion == 0x00010000 ||
95 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') || 95 lVersion == TT_MAKE_TAG('t', 't', 'c', 'f') ||
96 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') || 96 lVersion == TT_MAKE_TAG('t', 'r', 'u', 'e') ||
97 lVersion == 0x00020000) { 97 lVersion == 0x00020000) {
98 ret = TRUE; 98 ret = true;
99 } else if ((lVersion & 0xFFFF0000) == TT_MAKE_TAG(0x80, 0x01, 0x00, 0x00 ) || 99 } else if ((lVersion & 0xFFFF0000) == TT_MAKE_TAG(0x80, 0x01, 0x00, 0x00 ) ||
100 (lVersion & 0xFFFF0000) == TT_MAKE_TAG('%', '!', 0, 0)) { 100 (lVersion & 0xFFFF0000) == TT_MAKE_TAG('%', '!', 0, 0)) {
101 ret = TRUE; 101 ret = true;
102 } 102 }
103 } 103 }
104 DeleteFont(hFont); 104 DeleteFont(hFont);
105 return ret; 105 return ret;
106 } 106 }
107 void CWin32FontInfo::AddInstalledFont(const LOGFONTA *plf, FX_DWORD FontType) 107 void CWin32FontInfo::AddInstalledFont(const LOGFONTA *plf, FX_DWORD FontType)
108 { 108 {
109 CFX_ByteString name(plf->lfFaceName, -1); 109 CFX_ByteString name(plf->lfFaceName, -1);
110 if (name[0] == '@') { 110 if (name[0] == '@') {
111 return; 111 return;
(...skipping 20 matching lines...) Expand all
132 LPARAM lParam 132 LPARAM lParam
133 ) 133 )
134 { 134 {
135 CWin32FontInfo* pFontInfo = (CWin32FontInfo*)lParam; 135 CWin32FontInfo* pFontInfo = (CWin32FontInfo*)lParam;
136 if (pFontInfo->m_pMapper->GetFontEnumerator()) { 136 if (pFontInfo->m_pMapper->GetFontEnumerator()) {
137 pFontInfo->m_pMapper->GetFontEnumerator()->HitFont(); 137 pFontInfo->m_pMapper->GetFontEnumerator()->HitFont();
138 } 138 }
139 pFontInfo->AddInstalledFont(plf, FontType); 139 pFontInfo->AddInstalledFont(plf, FontType);
140 return 1; 140 return 1;
141 } 141 }
142 FX_BOOL CWin32FontInfo::EnumFontList(CFX_FontMapper* pMapper) 142 bool CWin32FontInfo::EnumFontList(CFX_FontMapper* pMapper)
143 { 143 {
144 m_pMapper = pMapper; 144 m_pMapper = pMapper;
145 LOGFONTA lf; 145 LOGFONTA lf;
146 FXSYS_memset(&lf, 0, sizeof(LOGFONTA)); 146 FXSYS_memset(&lf, 0, sizeof(LOGFONTA));
147 lf.lfCharSet = DEFAULT_CHARSET; 147 lf.lfCharSet = DEFAULT_CHARSET;
148 lf.lfFaceName[0] = 0; 148 lf.lfFaceName[0] = 0;
149 lf.lfPitchAndFamily = 0; 149 lf.lfPitchAndFamily = 0;
150 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t)this , 0); 150 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t)this , 0);
151 if (pMapper->GetFontEnumerator()) { 151 if (pMapper->GetFontEnumerator()) {
152 pMapper->GetFontEnumerator()->Finish(); 152 pMapper->GetFontEnumerator()->Finish();
153 } 153 }
154 return TRUE; 154 return true;
155 } 155 }
156 static const struct { 156 static const struct {
157 const FX_CHAR* m_pFaceName; 157 const FX_CHAR* m_pFaceName;
158 const FX_CHAR* m_pVariantName; 158 const FX_CHAR* m_pVariantName;
159 } 159 }
160 VariantNames[] = { 160 VariantNames[] = {
161 {"DFKai-SB", "\x19\x6A\x77\x69\xD4\x9A"}, 161 {"DFKai-SB", "\x19\x6A\x77\x69\xD4\x9A"},
162 }; 162 };
163 static const struct { 163 static const struct {
164 const FX_CHAR* m_pName; 164 const FX_CHAR* m_pName;
165 const FX_CHAR* m_pWinName; 165 const FX_CHAR* m_pWinName;
166 FX_BOOL» » m_bBold; 166 bool» » m_bBold;
167 FX_BOOL» » m_bItalic; 167 bool» » m_bItalic;
168 } 168 }
169 Base14Substs[] = { 169 Base14Substs[] = {
170 {"Courier", "Courier New", FALSE, FALSE}, 170 {"Courier", "Courier New", false, false},
171 {"Courier-Bold", "Courier New", TRUE, FALSE}, 171 {"Courier-Bold", "Courier New", true, false},
172 {"Courier-BoldOblique", "Courier New", TRUE, TRUE}, 172 {"Courier-BoldOblique", "Courier New", true, true},
173 {"Courier-Oblique", "Courier New", FALSE, TRUE}, 173 {"Courier-Oblique", "Courier New", false, true},
174 {"Helvetica", "Arial", FALSE, FALSE}, 174 {"Helvetica", "Arial", false, false},
175 {"Helvetica-Bold", "Arial", TRUE, FALSE}, 175 {"Helvetica-Bold", "Arial", true, false},
176 {"Helvetica-BoldOblique", "Arial", TRUE, TRUE}, 176 {"Helvetica-BoldOblique", "Arial", true, true},
177 {"Helvetica-Oblique", "Arial", FALSE, TRUE}, 177 {"Helvetica-Oblique", "Arial", false, true},
178 {"Times-Roman", "Times New Roman", FALSE, FALSE}, 178 {"Times-Roman", "Times New Roman", false, false},
179 {"Times-Bold", "Times New Roman", TRUE, FALSE}, 179 {"Times-Bold", "Times New Roman", true, false},
180 {"Times-BoldItalic", "Times New Roman", TRUE, TRUE}, 180 {"Times-BoldItalic", "Times New Roman", true, true},
181 {"Times-Italic", "Times New Roman", FALSE, TRUE}, 181 {"Times-Italic", "Times New Roman", false, true},
182 }; 182 };
183 CFX_ByteString CWin32FontInfo::FindFont(const CFX_ByteString& name) 183 CFX_ByteString CWin32FontInfo::FindFont(const CFX_ByteString& name)
184 { 184 {
185 if (m_pMapper == NULL) { 185 if (m_pMapper == NULL) {
186 return name; 186 return name;
187 } 187 }
188 int nFonts = m_pMapper->m_InstalledTTFonts.GetSize(); 188 int nFonts = m_pMapper->m_InstalledTTFonts.GetSize();
189 for (int i = 0; i < nFonts; i ++) { 189 for (int i = 0; i < nFonts; i ++) {
190 CFX_ByteString thisname = m_pMapper->m_InstalledTTFonts[i]; 190 CFX_ByteString thisname = m_pMapper->m_InstalledTTFonts[i];
191 if (thisname[0] == ' ') { 191 if (thisname[0] == ' ') {
(...skipping 13 matching lines...) Expand all
205 const _FontNameMap g_JpFontNameMap[] = { 205 const _FontNameMap g_JpFontNameMap[] = {
206 {"MS Mincho", "Heiseimin-W3"}, 206 {"MS Mincho", "Heiseimin-W3"},
207 {"MS Gothic", "Jun101-Light"}, 207 {"MS Gothic", "Jun101-Light"},
208 }; 208 };
209 extern "C" { 209 extern "C" {
210 static int compareString(const void* key, const void* element) 210 static int compareString(const void* key, const void* element)
211 { 211 {
212 return FXSYS_stricmp((const FX_CHAR*)key, ((_FontNameMap*)element)->m_pS rcFontName); 212 return FXSYS_stricmp((const FX_CHAR*)key, ((_FontNameMap*)element)->m_pS rcFontName);
213 } 213 }
214 } 214 }
215 FX_BOOL _GetSubFontName(CFX_ByteString& name) 215 bool _GetSubFontName(CFX_ByteString& name)
216 { 216 {
217 int size = sizeof g_JpFontNameMap; 217 int size = sizeof g_JpFontNameMap;
218 void* pFontnameMap = (void*)g_JpFontNameMap; 218 void* pFontnameMap = (void*)g_JpFontNameMap;
219 _FontNameMap* found = (_FontNameMap*)FXSYS_bsearch(name.c_str(), pFontnameMa p, 219 _FontNameMap* found = (_FontNameMap*)FXSYS_bsearch(name.c_str(), pFontnameMa p,
220 size / sizeof (_FontNameMap), sizeof (_FontNameMap), c ompareString); 220 size / sizeof (_FontNameMap), sizeof (_FontNameMap), c ompareString);
221 if (found == NULL) { 221 if (found == NULL) {
222 return FALSE; 222 return false;
223 } 223 }
224 name = found->m_pSubFontName; 224 name = found->m_pSubFontName;
225 return TRUE; 225 return true;
226 } 226 }
227 void CWin32FontInfo::GetGBPreference(CFX_ByteString& face, int weight, int picth _family) 227 void CWin32FontInfo::GetGBPreference(CFX_ByteString& face, int weight, int picth _family)
228 { 228 {
229 if (face.Find("KaiTi") >= 0 || face.Find("\xbf\xac") >= 0) { 229 if (face.Find("KaiTi") >= 0 || face.Find("\xbf\xac") >= 0) {
230 if (m_KaiTi.IsEmpty()) { 230 if (m_KaiTi.IsEmpty()) {
231 m_KaiTi = FindFont("KaiTi"); 231 m_KaiTi = FindFont("KaiTi");
232 if (m_KaiTi.IsEmpty()) { 232 if (m_KaiTi.IsEmpty()) {
233 m_KaiTi = "SimSun"; 233 m_KaiTi = "SimSun";
234 } 234 }
235 } 235 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 } 278 }
279 if (_GetSubFontName(face)) { 279 if (_GetSubFontName(face)) {
280 return; 280 return;
281 } 281 }
282 if (!(picth_family & FF_ROMAN) && weight > 400) { 282 if (!(picth_family & FF_ROMAN) && weight > 400) {
283 face = "MS PGothic"; 283 face = "MS PGothic";
284 } else { 284 } else {
285 face = "MS PMincho"; 285 face = "MS PMincho";
286 } 286 }
287 } 287 }
288 void* CWin32FontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitc h_family, const FX_CHAR* cstr_face, FX_BOOL& bExact) 288 void* CWin32FontInfo::MapFont(int weight, bool bItalic, int charset, int pitch_f amily, const FX_CHAR* cstr_face, bool& bExact)
289 { 289 {
290 CFX_ByteString face = cstr_face; 290 CFX_ByteString face = cstr_face;
291 int iBaseFont; 291 int iBaseFont;
292 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++) 292 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++)
293 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { 293 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
294 face = Base14Substs[iBaseFont].m_pWinName; 294 face = Base14Substs[iBaseFont].m_pWinName;
295 weight = Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL; 295 weight = Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL;
296 bItalic = Base14Substs[iBaseFont].m_bItalic; 296 bItalic = Base14Substs[iBaseFont].m_bItalic;
297 bExact = TRUE; 297 bExact = true;
298 break; 298 break;
299 } 299 }
300 if (charset == ANSI_CHARSET || charset == SYMBOL_CHARSET) { 300 if (charset == ANSI_CHARSET || charset == SYMBOL_CHARSET) {
301 charset = DEFAULT_CHARSET; 301 charset = DEFAULT_CHARSET;
302 } 302 }
303 int subst_pitch_family = pitch_family; 303 int subst_pitch_family = pitch_family;
304 switch (charset) { 304 switch (charset) {
305 case SHIFTJIS_CHARSET: 305 case SHIFTJIS_CHARSET:
306 subst_pitch_family = FF_ROMAN; 306 subst_pitch_family = FF_ROMAN;
307 break; 307 break;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 { 366 {
367 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 367 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
368 table = FXDWORD_FROM_MSBFIRST(table); 368 table = FXDWORD_FROM_MSBFIRST(table);
369 size = ::GetFontData(m_hDC, table, 0, buffer, size); 369 size = ::GetFontData(m_hDC, table, 0, buffer, size);
370 ::SelectObject(m_hDC, hOldFont); 370 ::SelectObject(m_hDC, hOldFont);
371 if (size == GDI_ERROR) { 371 if (size == GDI_ERROR) {
372 return 0; 372 return 0;
373 } 373 }
374 return size; 374 return size;
375 } 375 }
376 FX_BOOL CWin32FontInfo::GetFaceName(void* hFont, CFX_ByteString& name) 376 bool CWin32FontInfo::GetFaceName(void* hFont, CFX_ByteString& name)
377 { 377 {
378 char facebuf[100]; 378 char facebuf[100];
379 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 379 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
380 int ret = ::GetTextFaceA(m_hDC, 100, facebuf); 380 int ret = ::GetTextFaceA(m_hDC, 100, facebuf);
381 ::SelectObject(m_hDC, hOldFont); 381 ::SelectObject(m_hDC, hOldFont);
382 if (ret == 0) { 382 if (ret == 0) {
383 return FALSE; 383 return false;
384 } 384 }
385 name = facebuf; 385 name = facebuf;
386 return TRUE; 386 return true;
387 } 387 }
388 FX_BOOL CWin32FontInfo::GetFontCharset(void* hFont, int& charset) 388 bool CWin32FontInfo::GetFontCharset(void* hFont, int& charset)
389 { 389 {
390 TEXTMETRIC tm; 390 TEXTMETRIC tm;
391 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 391 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
392 ::GetTextMetrics(m_hDC, &tm); 392 ::GetTextMetrics(m_hDC, &tm);
393 ::SelectObject(m_hDC, hOldFont); 393 ::SelectObject(m_hDC, hOldFont);
394 charset = tm.tmCharSet; 394 charset = tm.tmCharSet;
395 return TRUE; 395 return true;
396 } 396 }
397 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() 397 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()
398 { 398 {
399 return new CWin32FontInfo; 399 return new CWin32FontInfo;
400 } 400 }
401 void CFX_GEModule::InitPlatform() 401 void CFX_GEModule::InitPlatform()
402 { 402 {
403 CWin32Platform* pPlatformData = new CWin32Platform; 403 CWin32Platform* pPlatformData = new CWin32Platform;
404 OSVERSIONINFO ver; 404 OSVERSIONINFO ver;
405 ver.dwOSVersionInfoSize = sizeof(ver); 405 ver.dwOSVersionInfoSize = sizeof(ver);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 459 }
460 void* CGdiDeviceDriver::GetClipRgn() 460 void* CGdiDeviceDriver::GetClipRgn()
461 { 461 {
462 HRGN hClipRgn = CreateRectRgn(0, 0, 1, 1); 462 HRGN hClipRgn = CreateRectRgn(0, 0, 1, 1);
463 if (::GetClipRgn(m_hDC, hClipRgn) == 0) { 463 if (::GetClipRgn(m_hDC, hClipRgn) == 0) {
464 DeleteObject(hClipRgn); 464 DeleteObject(hClipRgn);
465 hClipRgn = NULL; 465 hClipRgn = NULL;
466 } 466 }
467 return (void*)hClipRgn; 467 return (void*)hClipRgn;
468 } 468 }
469 FX_BOOL CGdiDeviceDriver::GDI_SetDIBits(const CFX_DIBitmap* pBitmap1, const FX_R ECT* pSrcRect, int left, int top, void* pIccTransform) 469 bool CGdiDeviceDriver::GDI_SetDIBits(const CFX_DIBitmap* pBitmap1, const FX_RECT * pSrcRect, int left, int top, void* pIccTransform)
470 { 470 {
471 if (m_DeviceClass == FXDC_PRINTER) { 471 if (m_DeviceClass == FXDC_PRINTER) {
472 CFX_DIBitmap* pBitmap = pBitmap1->FlipImage(FALSE, TRUE); 472 CFX_DIBitmap* pBitmap = pBitmap1->FlipImage(false, true);
473 if (pBitmap == NULL) { 473 if (pBitmap == NULL) {
474 return FALSE; 474 return false;
475 } 475 }
476 if ((pBitmap->IsCmykImage() || pIccTransform) && 476 if ((pBitmap->IsCmykImage() || pIccTransform) &&
477 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { 477 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) {
478 return FALSE; 478 return false;
479 } 479 }
480 int width = pSrcRect->Width(), height = pSrcRect->Height(); 480 int width = pSrcRect->Width(), height = pSrcRect->Height();
481 int pitch = pBitmap->GetPitch(); 481 int pitch = pBitmap->GetPitch();
482 LPBYTE pBuffer = pBitmap->GetBuffer(); 482 LPBYTE pBuffer = pBitmap->GetBuffer();
483 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); 483 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
484 ((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1; 484 ((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1;
485 FX_RECT dst_rect(0, 0, width, height); 485 FX_RECT dst_rect(0, 0, width, height);
486 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); 486 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
487 int dst_width = dst_rect.Width(); 487 int dst_width = dst_rect.Width();
488 int dst_height = dst_rect.Height(); 488 int dst_height = dst_rect.Height();
489 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height, 489 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height,
490 0, 0, dst_width, dst_height, pBuffer, (BITMAPINFO*)info.c_str(), DIB _RGB_COLORS, SRCCOPY); 490 0, 0, dst_width, dst_height, pBuffer, (BITMAPINFO*)info.c_str(), DIB _RGB_COLORS, SRCCOPY);
491 delete pBitmap; 491 delete pBitmap;
492 } else { 492 } else {
493 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; 493 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
494 if ((pBitmap->IsCmykImage() || pIccTransform) && 494 if ((pBitmap->IsCmykImage() || pIccTransform) &&
495 (pBitmap = pBitmap->CloneConvert(FXDIB_Rgb, NULL, pIccTransform) ) == NULL) { 495 (pBitmap = pBitmap->CloneConvert(FXDIB_Rgb, NULL, pIccTransform) ) == NULL) {
496 return FALSE; 496 return false;
497 } 497 }
498 int width = pSrcRect->Width(), height = pSrcRect->Height(); 498 int width = pSrcRect->Width(), height = pSrcRect->Height();
499 int pitch = pBitmap->GetPitch(); 499 int pitch = pBitmap->GetPitch();
500 LPBYTE pBuffer = pBitmap->GetBuffer(); 500 LPBYTE pBuffer = pBitmap->GetBuffer();
501 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); 501 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
502 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, pBi tmap->GetHeight() - pSrcRect->bottom, 502 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, pBi tmap->GetHeight() - pSrcRect->bottom,
503 0, pBitmap->GetHeight(), pBuffer, (BITMAPINFO*)info.c_str(), DIB_RGB _COLORS); 503 0, pBitmap->GetHeight(), pBuffer, (BITMAPINFO*)info.c_str(), DIB_RGB _COLORS);
504 if (pBitmap != pBitmap1) { 504 if (pBitmap != pBitmap1) {
505 delete pBitmap; 505 delete pBitmap;
506 } 506 }
507 } 507 }
508 return TRUE; 508 return true;
509 } 509 }
510 FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1, int de st_left, int dest_top, 510 bool CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1, int dest_ left, int dest_top,
511 int dest_width, int dest_height, FX_DWORD flags, void* pIccTransform) 511 int dest_width, int dest_height, FX_DWORD flags, void* pIccTransform)
512 { 512 {
513 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; 513 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
514 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) { 514 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
515 return FALSE; 515 return false;
516 } 516 }
517 if ((pBitmap->IsCmykImage() || pIccTransform) && 517 if ((pBitmap->IsCmykImage() || pIccTransform) &&
518 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { 518 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) {
519 return FALSE; 519 return false;
520 } 520 }
521 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); 521 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
522 if ((int64_t)abs(dest_width) * abs(dest_height) < (int64_t)pBitmap1->GetWidt h() * pBitmap1->GetHeight() * 4 || 522 if ((int64_t)abs(dest_width) * abs(dest_height) < (int64_t)pBitmap1->GetWidt h() * pBitmap1->GetHeight() * 4 ||
523 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { 523 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) {
524 SetStretchBltMode(m_hDC, HALFTONE); 524 SetStretchBltMode(m_hDC, HALFTONE);
525 } else { 525 } else {
526 SetStretchBltMode(m_hDC, COLORONCOLOR); 526 SetStretchBltMode(m_hDC, COLORONCOLOR);
527 } 527 }
528 CFX_DIBitmap* pToStrechBitmap = pBitmap; 528 CFX_DIBitmap* pToStrechBitmap = pBitmap;
529 bool del = false; 529 bool del = false;
530 if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap ->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) { 530 if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap ->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) {
531 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); 531 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height);
532 del = true; 532 del = true;
533 } 533 }
534 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB itmap); 534 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB itmap);
535 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 535 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height,
536 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh t(), pToStrechBitmap->GetBuffer(), 536 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh t(), pToStrechBitmap->GetBuffer(),
537 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRC COPY); 537 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRC COPY);
538 if (del) { 538 if (del) {
539 delete pToStrechBitmap; 539 delete pToStrechBitmap;
540 } 540 }
541 return TRUE; 541 return true;
542 } 542 }
543 FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1, int d est_left, int dest_top, 543 bool CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1, int dest _left, int dest_top,
544 int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags, 544 int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags,
545 int alpha_flag, void* pIccTransform) 545 int alpha_flag, void* pIccTransform)
546 { 546 {
547 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; 547 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
548 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) { 548 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
549 return FALSE; 549 return false;
550 } 550 }
551 _Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24), pIccTransfor m); 551 _Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24), pIccTransfor m);
552 int width = pBitmap->GetWidth(), height = pBitmap->GetHeight(); 552 int width = pBitmap->GetWidth(), height = pBitmap->GetHeight();
553 struct { 553 struct {
554 BITMAPINFOHEADER bmiHeader; 554 BITMAPINFOHEADER bmiHeader;
555 FX_DWORD bmiColors[2]; 555 FX_DWORD bmiColors[2];
556 } bmi; 556 } bmi;
557 FXSYS_memset(&bmi.bmiHeader, 0, sizeof (BITMAPINFOHEADER)); 557 FXSYS_memset(&bmi.bmiHeader, 0, sizeof (BITMAPINFOHEADER));
558 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 558 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
559 bmi.bmiHeader.biBitCount = 1; 559 bmi.bmiHeader.biBitCount = 1;
(...skipping 25 matching lines...) Expand all
585 * 1 1 1 1 585 * 1 1 1 1
586 */ 586 */
587 // The boolen codes is B8. Based on http://msdn.microsoft.com/en-us/library/ aa932106.aspx, the ROP3 code is 0xB8074A 587 // The boolen codes is B8. Based on http://msdn.microsoft.com/en-us/library/ aa932106.aspx, the ROP3 code is 0xB8074A
588 588
589 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 589 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height,
590 0, 0, width, height, pBitmap->GetBuffer(), (BITMAPINFO*)&bmi , DIB_RGB_COLORS, 0xB8074A); 590 0, 0, width, height, pBitmap->GetBuffer(), (BITMAPINFO*)&bmi , DIB_RGB_COLORS, 0xB8074A);
591 591
592 SelectObject(m_hDC, hOld); 592 SelectObject(m_hDC, hOld);
593 DeleteObject(hPattern); 593 DeleteObject(hPattern);
594 594
595 return TRUE; 595 return true;
596 } 596 }
597 BOOL CGdiDeviceDriver::GetClipBox(FX_RECT* pRect) 597 BOOL CGdiDeviceDriver::GetClipBox(FX_RECT* pRect)
598 { 598 {
599 return ::GetClipBox(m_hDC, (RECT*)pRect); 599 return ::GetClipBox(m_hDC, (RECT*)pRect);
600 } 600 }
601 FX_BOOL CGdiDeviceDriver::SetClipRgn(void* hRgn) 601 bool CGdiDeviceDriver::SetClipRgn(void* hRgn)
602 { 602 {
603 ::SelectClipRgn(m_hDC, (HRGN)hRgn); 603 ::SelectClipRgn(m_hDC, (HRGN)hRgn);
604 return TRUE; 604 return true;
605 } 605 }
606 static HPEN _CreatePen(const CFX_GraphStateData* pGraphState, const CFX_AffineMa trix* pMatrix, FX_DWORD argb) 606 static HPEN _CreatePen(const CFX_GraphStateData* pGraphState, const CFX_AffineMa trix* pMatrix, FX_DWORD argb)
607 { 607 {
608 FX_FLOAT width; 608 FX_FLOAT width;
609 FX_FLOAT scale = 1.f; 609 FX_FLOAT scale = 1.f;
610 if (pMatrix) 610 if (pMatrix)
611 scale = FXSYS_fabs(pMatrix->a) > FXSYS_fabs(pMatrix->b) ? 611 scale = FXSYS_fabs(pMatrix->a) > FXSYS_fabs(pMatrix->b) ?
612 FXSYS_fabs(pMatrix->a) : FXSYS_fabs(pMatrix->b); 612 FXSYS_fabs(pMatrix->a) : FXSYS_fabs(pMatrix->b);
613 if (pGraphState) { 613 if (pGraphState) {
614 width = scale * pGraphState->m_LineWidth; 614 width = scale * pGraphState->m_LineWidth;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 } else { 742 } else {
743 x1 = x[0]; 743 x1 = x[0];
744 y1 = y[0]; 744 y1 = y[0];
745 x2 = x[np - 1]; 745 x2 = x[np - 1];
746 y2 = y[np - 1]; 746 y2 = y[np - 1];
747 } 747 }
748 } 748 }
749 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL); 749 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL);
750 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); 750 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2));
751 } 751 }
752 static FX_BOOL _MatrixNoScaled(const CFX_AffineMatrix* pMatrix) 752 static bool _MatrixNoScaled(const CFX_AffineMatrix* pMatrix)
753 { 753 {
754 return pMatrix->GetA() == 1.0f && pMatrix->GetB() == 0 && pMatrix->GetC() == 0 && pMatrix->GetD() == 1.0f; 754 return pMatrix->GetA() == 1.0f && pMatrix->GetB() == 0 && pMatrix->GetC() == 0 && pMatrix->GetD() == 1.0f;
755 } 755 }
756 FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, 756 bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
757 const CFX_AffineMatrix* pMatrix, 757 const CFX_AffineMatrix* pMatrix,
758 const CFX_GraphStateData* pGraphState, 758 const CFX_GraphStateData* pGraphState,
759 FX_DWORD fill_color, 759 FX_DWORD fill_color,
760 FX_DWORD stroke_color, 760 FX_DWORD stroke_color,
761 int fill_mode, 761 int fill_mode,
762 int alpha_flag, 762 int alpha_flag,
763 void* pIccTransform, 763 void* pIccTransform,
764 int blend_type 764 int blend_type
765 ) 765 )
766 { 766 {
767 if (blend_type != FXDIB_BLEND_NORMAL) { 767 if (blend_type != FXDIB_BLEND_NORMAL) {
768 return FALSE; 768 return false;
769 } 769 }
770 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); 770 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform);
771 _Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform); 771 _Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform);
772 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor mData(); 772 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor mData();
773 if ((pGraphState == NULL || stroke_color == 0) && !pPlatform->m_GdiplusExt.I sAvailable()) { 773 if ((pGraphState == NULL || stroke_color == 0) && !pPlatform->m_GdiplusExt.I sAvailable()) {
774 CFX_FloatRect bbox_f = pPathData->GetBoundingBox(); 774 CFX_FloatRect bbox_f = pPathData->GetBoundingBox();
775 if (pMatrix) { 775 if (pMatrix) {
776 bbox_f.Transform(pMatrix); 776 bbox_f.Transform(pMatrix);
777 } 777 }
778 FX_RECT bbox = bbox_f.GetInnerRect(); 778 FX_RECT bbox = bbox_f.GetInnerRect();
779 if (bbox.Width() <= 0) { 779 if (bbox.Width() <= 0) {
780 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.bottom + 1), fill_color, 780 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.bottom + 1), fill_color,
781 alpha_flag, pIccTransform, FXDIB_BLEND_NORMA L); 781 alpha_flag, pIccTransform, FXDIB_BLEND_NORMA L);
782 } else if (bbox.Height() <= 0) { 782 } else if (bbox.Height() <= 0) {
783 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), fill_color, 783 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), fill_color,
784 alpha_flag, pIccTransform, FXDIB_BLEND_NORMA L); 784 alpha_flag, pIccTransform, FXDIB_BLEND_NORMA L);
785 } 785 }
786 } 786 }
787 int fill_alpha = FXARGB_A(fill_color); 787 int fill_alpha = FXARGB_A(fill_color);
788 int stroke_alpha = FXARGB_A(stroke_color); 788 int stroke_alpha = FXARGB_A(stroke_color);
789 FX_BOOL bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) || (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState); 789 bool bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) || (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState);
790 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha) { 790 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha) {
791 return FALSE; 791 return false;
792 } 792 }
793 if (pPlatform->m_GdiplusExt.IsAvailable()) { 793 if (pPlatform->m_GdiplusExt.IsAvailable()) {
794 if (bDrawAlpha || ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFIL L_FULLCOVER)) || (pGraphState && pGraphState->m_DashCount))) { 794 if (bDrawAlpha || ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFIL L_FULLCOVER)) || (pGraphState && pGraphState->m_DashCount))) {
795 if ( !((NULL == pMatrix || _MatrixNoScaled(pMatrix)) && 795 if ( !((NULL == pMatrix || _MatrixNoScaled(pMatrix)) &&
796 pGraphState && pGraphState->m_LineWidth == 1.f && 796 pGraphState && pGraphState->m_LineWidth == 1.f &&
797 (pPathData->GetPointCount() == 5 || pPathData->GetPointCount () == 4) && 797 (pPathData->GetPointCount() == 5 || pPathData->GetPointCount () == 4) &&
798 pPathData->IsRect()) ) { 798 pPathData->IsRect()) ) {
799 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, pGraphState, fill_color, stroke_color, fill_mode)) { 799 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, pGraphState, fill_color, stroke_color, fill_mode)) {
800 return TRUE; 800 return true;
801 } 801 }
802 } 802 }
803 } 803 }
804 } 804 }
805 int old_fill_mode = fill_mode; 805 int old_fill_mode = fill_mode;
806 fill_mode &= 3; 806 fill_mode &= 3;
807 HPEN hPen = NULL; 807 HPEN hPen = NULL;
808 HBRUSH hBrush = NULL; 808 HBRUSH hBrush = NULL;
809 if (pGraphState && stroke_alpha) { 809 if (pGraphState && stroke_alpha) {
810 SetMiterLimit(m_hDC, pGraphState->m_MiterLimit, NULL); 810 SetMiterLimit(m_hDC, pGraphState->m_MiterLimit, NULL);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 } 845 }
846 } 846 }
847 if (hPen) { 847 if (hPen) {
848 hPen = (HPEN)SelectObject(m_hDC, hPen); 848 hPen = (HPEN)SelectObject(m_hDC, hPen);
849 DeleteObject(hPen); 849 DeleteObject(hPen);
850 } 850 }
851 if (hBrush) { 851 if (hBrush) {
852 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); 852 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush);
853 DeleteObject(hBrush); 853 DeleteObject(hBrush);
854 } 854 }
855 return TRUE; 855 return true;
856 } 856 }
857 FX_BOOL CGdiDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, in t alpha_flag, void* pIccTransform, int blend_type) 857 bool CGdiDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, int a lpha_flag, void* pIccTransform, int blend_type)
858 { 858 {
859 if (blend_type != FXDIB_BLEND_NORMAL) { 859 if (blend_type != FXDIB_BLEND_NORMAL) {
860 return FALSE; 860 return false;
861 } 861 }
862 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); 862 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform);
863 int alpha; 863 int alpha;
864 FX_COLORREF rgb; 864 FX_COLORREF rgb;
865 ArgbDecode(fill_color, alpha, rgb); 865 ArgbDecode(fill_color, alpha, rgb);
866 if (alpha == 0) { 866 if (alpha == 0) {
867 return TRUE; 867 return true;
868 } 868 }
869 if (alpha < 255) { 869 if (alpha < 255) {
870 return FALSE; 870 return false;
871 } 871 }
872 HBRUSH hBrush = CreateSolidBrush(rgb); 872 HBRUSH hBrush = CreateSolidBrush(rgb);
873 ::FillRect(m_hDC, (RECT*)pRect, hBrush); 873 ::FillRect(m_hDC, (RECT*)pRect, hBrush);
874 DeleteObject(hBrush); 874 DeleteObject(hBrush);
875 return TRUE; 875 return true;
876 } 876 }
877 FX_BOOL CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, 877 bool CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData,
878 const CFX_AffineMatrix* pMatrix, 878 const CFX_AffineMatrix* pMatrix,
879 int fill_mode 879 int fill_mode
880 ) 880 )
881 { 881 {
882 if (pPathData->GetPointCount() == 5) { 882 if (pPathData->GetPointCount() == 5) {
883 CFX_FloatRect rectf; 883 CFX_FloatRect rectf;
884 if (pPathData->IsRect(pMatrix, &rectf)) { 884 if (pPathData->IsRect(pMatrix, &rectf)) {
885 FX_RECT rect = rectf.GetOutterRect(); 885 FX_RECT rect = rectf.GetOutterRect();
886 IntersectClipRect(m_hDC, rect.left, rect.top, rect.right, rect.botto m); 886 IntersectClipRect(m_hDC, rect.left, rect.top, rect.right, rect.botto m);
887 return TRUE; 887 return true;
888 } 888 }
889 } 889 }
890 _SetPathToDC(m_hDC, pPathData, pMatrix); 890 _SetPathToDC(m_hDC, pPathData, pMatrix);
891 SetPolyFillMode(m_hDC, fill_mode & 3); 891 SetPolyFillMode(m_hDC, fill_mode & 3);
892 SelectClipPath(m_hDC, RGN_AND); 892 SelectClipPath(m_hDC, RGN_AND);
893 return TRUE; 893 return true;
894 } 894 }
895 FX_BOOL CGdiDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData, 895 bool CGdiDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData,
896 const CFX_AffineMatrix* pMatrix, 896 const CFX_AffineMatrix* pMatrix,
897 const CFX_GraphStateData* pGraphState 897 const CFX_GraphStateData* pGraphState
898 ) 898 )
899 { 899 {
900 HPEN hPen = _CreatePen(pGraphState, pMatrix, 0xff000000); 900 HPEN hPen = _CreatePen(pGraphState, pMatrix, 0xff000000);
901 hPen = (HPEN)SelectObject(m_hDC, hPen); 901 hPen = (HPEN)SelectObject(m_hDC, hPen);
902 _SetPathToDC(m_hDC, pPathData, pMatrix); 902 _SetPathToDC(m_hDC, pPathData, pMatrix);
903 WidenPath(m_hDC); 903 WidenPath(m_hDC);
904 SetPolyFillMode(m_hDC, WINDING); 904 SetPolyFillMode(m_hDC, WINDING);
905 FX_BOOL ret = SelectClipPath(m_hDC, RGN_AND); 905 bool ret = SelectClipPath(m_hDC, RGN_AND);
906 hPen = (HPEN)SelectObject(m_hDC, hPen); 906 hPen = (HPEN)SelectObject(m_hDC, hPen);
907 DeleteObject(hPen); 907 DeleteObject(hPen);
908 return ret; 908 return ret;
909 } 909 }
910 FX_BOOL CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2 , FX_FLOAT y2, FX_DWORD color, 910 bool CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, F X_FLOAT y2, FX_DWORD color,
911 int alpha_flag, void* pIccTransform, int blend_type) 911 int alpha_flag, void* pIccTransform, int blend_type)
912 { 912 {
913 if (blend_type != FXDIB_BLEND_NORMAL) { 913 if (blend_type != FXDIB_BLEND_NORMAL) {
914 return FALSE; 914 return false;
915 } 915 }
916 _Color2Argb(color, color, alpha_flag | (1 << 24), pIccTransform); 916 _Color2Argb(color, color, alpha_flag | (1 << 24), pIccTransform);
917 int a; 917 int a;
918 FX_COLORREF rgb; 918 FX_COLORREF rgb;
919 ArgbDecode(color, a, rgb); 919 ArgbDecode(color, a, rgb);
920 if (a == 0) { 920 if (a == 0) {
921 return TRUE; 921 return true;
922 } 922 }
923 HPEN hPen = CreatePen(PS_SOLID, 1, rgb); 923 HPEN hPen = CreatePen(PS_SOLID, 1, rgb);
924 hPen = (HPEN)SelectObject(m_hDC, hPen); 924 hPen = (HPEN)SelectObject(m_hDC, hPen);
925 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL); 925 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL);
926 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); 926 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2));
927 hPen = (HPEN)SelectObject(m_hDC, hPen); 927 hPen = (HPEN)SelectObject(m_hDC, hPen);
928 DeleteObject(hPen); 928 DeleteObject(hPen);
929 return TRUE; 929 return true;
930 } 930 }
931 FX_BOOL CGdiDeviceDriver::DeleteDeviceRgn(void* pRgn) 931 bool CGdiDeviceDriver::DeleteDeviceRgn(void* pRgn)
932 { 932 {
933 DeleteObject((HGDIOBJ)pRgn); 933 DeleteObject((HGDIOBJ)pRgn);
934 return TRUE; 934 return true;
935 } 935 }
936 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) : CGdiDeviceDriver(hDC, FXDC_DISPL AY) 936 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) : CGdiDeviceDriver(hDC, FXDC_DISPL AY)
937 { 937 {
938 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor mData(); 938 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor mData();
939 if (pPlatform->m_GdiplusExt.IsAvailable()) { 939 if (pPlatform->m_GdiplusExt.IsAvailable()) {
940 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE; 940 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE;
941 } 941 }
942 } 942 }
943 FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, v oid* pIccTransform, FX_BOOL bDEdge) 943 bool CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void * pIccTransform, bool bDEdge)
944 { 944 {
945 FX_BOOL ret = FALSE; 945 bool ret = false;
946 int width = pBitmap->GetWidth(); 946 int width = pBitmap->GetWidth();
947 int height = pBitmap->GetHeight(); 947 int height = pBitmap->GetHeight();
948 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height); 948 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height);
949 HDC hDCMemory = CreateCompatibleDC(m_hDC); 949 HDC hDCMemory = CreateCompatibleDC(m_hDC);
950 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp); 950 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp);
951 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY); 951 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY);
952 SelectObject(hDCMemory, holdbmp); 952 SelectObject(hDCMemory, holdbmp);
953 BITMAPINFO bmi; 953 BITMAPINFO bmi;
954 FXSYS_memset(&bmi, 0, sizeof bmi); 954 FXSYS_memset(&bmi, 0, sizeof bmi);
955 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader; 955 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader;
956 bmi.bmiHeader.biBitCount = pBitmap->GetBPP(); 956 bmi.bmiHeader.biBitCount = pBitmap->GetBPP();
957 bmi.bmiHeader.biHeight = -height; 957 bmi.bmiHeader.biHeight = -height;
958 bmi.bmiHeader.biPlanes = 1; 958 bmi.bmiHeader.biPlanes = 1;
959 bmi.bmiHeader.biWidth = width; 959 bmi.bmiHeader.biWidth = width;
960 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec Module()->GetIccModule()) { 960 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec Module()->GetIccModule()) {
961 pIccTransform = NULL; 961 pIccTransform = NULL;
962 } 962 }
963 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && pIccTransform == NUL L) { 963 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && pIccTransform == NUL L) {
964 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi , DIB_RGB_COLORS) == height; 964 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi , DIB_RGB_COLORS) == height;
965 } else { 965 } else {
966 CFX_DIBitmap bitmap; 966 CFX_DIBitmap bitmap;
967 if (bitmap.Create(width, height, FXDIB_Rgb)) { 967 if (bitmap.Create(width, height, FXDIB_Rgb)) {
968 bmi.bmiHeader.biBitCount = 24; 968 bmi.bmiHeader.biBitCount = 24;
969 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, DI B_RGB_COLORS); 969 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, DI B_RGB_COLORS);
970 ret = pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0, pI ccTransform); 970 ret = pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0, pI ccTransform);
971 } else { 971 } else {
972 ret = FALSE; 972 ret = false;
973 } 973 }
974 } 974 }
975 if (pBitmap->HasAlpha() && ret) { 975 if (pBitmap->HasAlpha() && ret) {
976 pBitmap->LoadChannel(FXDIB_Alpha, 0xff); 976 pBitmap->LoadChannel(FXDIB_Alpha, 0xff);
977 } 977 }
978 DeleteObject(hbmp); 978 DeleteObject(hbmp);
979 DeleteObject(hDCMemory); 979 DeleteObject(hDCMemory);
980 return ret; 980 return ret;
981 } 981 }
982 FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD colo r, const FX_RECT* pSrcRect, int left, int top, int blend_type, 982 bool CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD color, const FX_RECT* pSrcRect, int left, int top, int blend_type,
983 int alpha_flag, void* pIccTransform) 983 int alpha_flag, void* pIccTransform)
984 { 984 {
985 ASSERT(blend_type == FXDIB_BLEND_NORMAL); 985 ASSERT(blend_type == FXDIB_BLEND_NORMAL);
986 if (pSource->IsAlphaMask()) { 986 if (pSource->IsAlphaMask()) {
987 int width = pSource->GetWidth(), height = pSource->GetHeight(); 987 int width = pSource->GetWidth(), height = pSource->GetHeight();
988 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);
989 FX_BOOL bGDI = pSource->GetBPP() == 1 && alpha == 255; 989 bool bGDI = pSource->GetBPP() == 1 && alpha == 255;
990 if (!bGDI) { 990 if (!bGDI) {
991 CFX_DIBitmap background; 991 CFX_DIBitmap background;
992 if (!background.Create(width, height, FXDIB_Rgb32) || 992 if (!background.Create(width, height, FXDIB_Rgb32) ||
993 !GetDIBits(&background, left, top, NULL) || 993 !GetDIBits(&background, left, top, NULL) ||
994 !background.CompositeMask(0, 0, width, height, pSource, color, 994 !background.CompositeMask(0, 0, width, height, pSource, color,
995 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, 995 0, 0, FXDIB_BLEND_NORMAL, NULL, false,
996 alpha_flag, pIccTransform)) { 996 alpha_flag, pIccTransform)) {
997 return FALSE; 997 return false;
998 } 998 }
999 FX_RECT src_rect(0, 0, width, height); 999 FX_RECT src_rect(0, 0, width, height);
1000 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);
1001 } 1001 }
1002 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());
1003 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,
1004 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE ND_NORMAL); 1004 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE ND_NORMAL);
1005 } 1005 }
1006 int width = pSrcRect->Width(), height = pSrcRect->Height(); 1006 int width = pSrcRect->Width(), height = pSrcRect->Height();
1007 if (pSource->HasAlpha()) { 1007 if (pSource->HasAlpha()) {
1008 CFX_DIBitmap bitmap; 1008 CFX_DIBitmap bitmap;
1009 if (!bitmap.Create(width, height, FXDIB_Rgb) || 1009 if (!bitmap.Create(width, height, FXDIB_Rgb) ||
1010 !GetDIBits(&bitmap, left, top, NULL) || 1010 !GetDIBits(&bitmap, left, top, NULL) ||
1011 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->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)) {
1012 return FALSE; 1012 return false;
1013 } 1013 }
1014 FX_RECT src_rect(0, 0, width, height); 1014 FX_RECT src_rect(0, 0, width, height);
1015 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0 , NULL); 1015 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL, 0 , NULL);
1016 } 1016 }
1017 CFX_DIBExtractor temp(pSource); 1017 CFX_DIBExtractor temp(pSource);
1018 CFX_DIBitmap* pBitmap = temp; 1018 CFX_DIBitmap* pBitmap = temp;
1019 if (pBitmap) { 1019 if (pBitmap) {
1020 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); 1020 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform);
1021 } 1021 }
1022 return FALSE; 1022 return false;
1023 } 1023 }
1024 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, F X_DWORD color, int dest_left, int dest_top, 1024 bool CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, FX_D WORD color, int dest_left, int dest_top,
1025 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,
1026 int alpha_flag, void* pIccTransform, int blend_type) 1026 int alpha_flag, void* pIccTransform, int blend_type)
1027 { 1027 {
1028 FX_RECT bitmap_clip = *pClipRect; 1028 FX_RECT bitmap_clip = *pClipRect;
1029 if (dest_width < 0) { 1029 if (dest_width < 0) {
1030 dest_left += dest_width; 1030 dest_left += dest_width;
1031 } 1031 }
1032 if (dest_height < 0) { 1032 if (dest_height < 0) {
1033 dest_top += dest_height; 1033 dest_top += dest_height;
1034 } 1034 }
1035 bitmap_clip.Offset(-dest_left, -dest_top); 1035 bitmap_clip.Offset(-dest_left, -dest_top);
1036 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);
1037 if (pStretched == NULL) { 1037 if (pStretched == NULL) {
1038 return TRUE; 1038 return true;
1039 } 1039 }
1040 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); 1040 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight());
1041 FX_BOOL ret = SetDIBits(pStretched, color, &src_rect, pClipRect->left, pClip Rect->top, FXDIB_BLEND_NORMAL, alpha_flag, pIccTransform); 1041 bool ret = SetDIBits(pStretched, color, &src_rect, pClipRect->left, pClipRec t->top, FXDIB_BLEND_NORMAL, alpha_flag, pIccTransform);
1042 delete pStretched; 1042 delete pStretched;
1043 return ret; 1043 return ret;
1044 } 1044 }
1045 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD color, int dest_left, int dest_top, 1045 bool CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD col or, int dest_left, int dest_top,
1046 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,
1047 int alpha_flag, void* pIccTransform, int blend_type) 1047 int alpha_flag, void* pIccTransform, int blend_type)
1048 { 1048 {
1049 ASSERT(pSource != NULL && pClipRect != NULL); 1049 ASSERT(pSource != NULL && pClipRect != NULL);
1050 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) {
1051 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,
1052 pClipRect, flags, alpha_flag, pIccTransform , blend_type); 1052 pClipRect, flags, alpha_flag, pIccTransform , blend_type);
1053 } 1053 }
1054 if (pSource->IsAlphaMask()) { 1054 if (pSource->IsAlphaMask()) {
1055 FX_RECT image_rect; 1055 FX_RECT image_rect;
1056 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;
1057 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;
1058 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;
1059 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;
1060 FX_RECT clip_rect = image_rect; 1060 FX_RECT clip_rect = image_rect;
1061 clip_rect.Intersect(*pClipRect); 1061 clip_rect.Intersect(*pClipRect);
1062 clip_rect.Offset(-image_rect.left, -image_rect.top); 1062 clip_rect.Offset(-image_rect.left, -image_rect.top);
1063 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); 1063 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); 1064 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, f lags, &clip_rect);
1065 if (pStretched == NULL) { 1065 if (pStretched == NULL) {
1066 return TRUE; 1066 return true;
1067 } 1067 }
1068 CFX_DIBitmap background; 1068 CFX_DIBitmap background;
1069 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || 1069 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) || 1070 !GetDIBits(&background, image_rect.left + clip_rect.left, image_rect .top + clip_rect.top, NULL) ||
1071 !background.CompositeMask(0, 0, clip_width, clip_height, pStretched, 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)) {
1072 delete pStretched; 1072 delete pStretched;
1073 return FALSE; 1073 return false;
1074 } 1074 }
1075 FX_RECT src_rect(0, 0, clip_width, clip_height); 1075 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); 1076 bool ret = SetDIBits(&background, 0, &src_rect, image_rect.left + clip_r ect.left, image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL, 0, NULL);
1077 delete pStretched; 1077 delete pStretched;
1078 return ret; 1078 return ret;
1079 } 1079 }
1080 if (pSource->HasAlpha()) { 1080 if (pSource->HasAlpha()) {
1081 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPla tformData(); 1081 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPla tformData();
1082 if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL && !p Source->IsCmykImage()) { 1082 if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL && !p Source->IsCmykImage()) {
1083 CFX_DIBExtractor temp(pSource); 1083 CFX_DIBExtractor temp(pSource);
1084 CFX_DIBitmap* pBitmap = temp; 1084 CFX_DIBitmap* pBitmap = temp;
1085 if (pBitmap == NULL) { 1085 if (pBitmap == NULL) {
1086 return FALSE; 1086 return false;
1087 } 1087 }
1088 return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, dest_le ft, dest_top, dest_width, dest_height, pClipRect, flags); 1088 return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, dest_le ft, dest_top, dest_width, dest_height, pClipRect, flags);
1089 } 1089 }
1090 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w idth, dest_height, 1090 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w idth, dest_height,
1091 pClipRect, flags, alpha_flag, pIccTransform , blend_type); 1091 pClipRect, flags, alpha_flag, pIccTransform , blend_type);
1092 } 1092 }
1093 CFX_DIBExtractor temp(pSource); 1093 CFX_DIBExtractor temp(pSource);
1094 CFX_DIBitmap* pBitmap = temp; 1094 CFX_DIBitmap* pBitmap = temp;
1095 if (pBitmap) { 1095 if (pBitmap) {
1096 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_ height, flags, pIccTransform); 1096 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, dest_ height, flags, pIccTransform);
1097 } 1097 }
1098 return FALSE; 1098 return false;
1099 } 1099 }
1100 #define GET_PS_FEATURESETTING 4121 1100 #define GET_PS_FEATURESETTING 4121
1101 #define FEATURESETTING_PSLEVEL 2 1101 #define FEATURESETTING_PSLEVEL 2
1102 int GetPSLevel(HDC hDC) 1102 int GetPSLevel(HDC hDC)
1103 { 1103 {
1104 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); 1104 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY);
1105 if (device_type != DT_RASPRINTER) { 1105 if (device_type != DT_RASPRINTER) {
1106 return 0; 1106 return 0;
1107 } 1107 }
1108 FX_DWORD esc = GET_PS_FEATURESETTING; 1108 FX_DWORD esc = GET_PS_FEATURESETTING;
(...skipping 18 matching lines...) Expand all
1127 esc = GET_PS_FEATURESETTING; 1127 esc = GET_PS_FEATURESETTING;
1128 if (ExtEscape(hDC, QUERYESCSUPPORT, sizeof esc, (char*)&esc, 0, NULL)) { 1128 if (ExtEscape(hDC, QUERYESCSUPPORT, sizeof esc, (char*)&esc, 0, NULL)) {
1129 int param = FEATURESETTING_PSLEVEL; 1129 int param = FEATURESETTING_PSLEVEL;
1130 if (ExtEscape(hDC, GET_PS_FEATURESETTING, sizeof(int), (char*)&param, si zeof(int), (char*)&param) > 0) { 1130 if (ExtEscape(hDC, GET_PS_FEATURESETTING, sizeof(int), (char*)&param, si zeof(int), (char*)&param) > 0) {
1131 return param; 1131 return param;
1132 } 1132 }
1133 } 1133 }
1134 return 2; 1134 return 2;
1135 } 1135 }
1136 int CFX_WindowsDevice::m_psLevel = 2; 1136 int CFX_WindowsDevice::m_psLevel = 2;
1137 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC, FX_BOOL bCmykOutput, FX_BOOL bForc ePSOutput, int psLevel) 1137 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC, bool bCmykOutput, bool bForcePSOut put, int psLevel)
1138 { 1138 {
1139 m_bForcePSOutput = bForcePSOutput; 1139 m_bForcePSOutput = bForcePSOutput;
1140 m_psLevel = psLevel; 1140 m_psLevel = psLevel;
1141 if (bForcePSOutput) { 1141 if (bForcePSOutput) {
1142 IFX_RenderDeviceDriver* pDriver = new CPSPrinterDriver; 1142 IFX_RenderDeviceDriver* pDriver = new CPSPrinterDriver;
1143 ((CPSPrinterDriver*)pDriver)->Init(hDC, psLevel, bCmykOutput); 1143 ((CPSPrinterDriver*)pDriver)->Init(hDC, psLevel, bCmykOutput);
1144 SetDeviceDriver(pDriver); 1144 SetDeviceDriver(pDriver);
1145 return; 1145 return;
1146 } 1146 }
1147 SetDeviceDriver(CreateDriver(hDC, bCmykOutput)); 1147 SetDeviceDriver(CreateDriver(hDC, bCmykOutput));
1148 } 1148 }
1149 HDC CFX_WindowsDevice::GetDC() const 1149 HDC CFX_WindowsDevice::GetDC() const
1150 { 1150 {
1151 IFX_RenderDeviceDriver *pRDD = GetDeviceDriver(); 1151 IFX_RenderDeviceDriver *pRDD = GetDeviceDriver();
1152 if (!pRDD) { 1152 if (!pRDD) {
1153 return NULL; 1153 return NULL;
1154 } 1154 }
1155 return (HDC)pRDD->GetPlatformSurface(); 1155 return (HDC)pRDD->GetPlatformSurface();
1156 } 1156 }
1157 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC, FX_BOOL bCmykOu tput) 1157 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC, bool bCmykOutpu t)
1158 { 1158 {
1159 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); 1159 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY);
1160 int obj_type = ::GetObjectType(hDC); 1160 int obj_type = ::GetObjectType(hDC);
1161 int device_class; 1161 int device_class;
1162 if (device_type == DT_RASPRINTER || device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC) { 1162 if (device_type == DT_RASPRINTER || device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC) {
1163 device_class = FXDC_PRINTER; 1163 device_class = FXDC_PRINTER;
1164 } else { 1164 } else {
1165 device_class = FXDC_DISPLAY; 1165 device_class = FXDC_DISPLAY;
1166 } 1166 }
1167 if (device_class == FXDC_PRINTER) { 1167 if (device_class == FXDC_PRINTER) {
(...skipping 29 matching lines...) Expand all
1197 SelectObject(m_hDC, m_hOldBitmap); 1197 SelectObject(m_hDC, m_hOldBitmap);
1198 DeleteDC(m_hDC); 1198 DeleteDC(m_hDC);
1199 } 1199 }
1200 if (m_hBitmap) { 1200 if (m_hBitmap) {
1201 DeleteObject(m_hBitmap); 1201 DeleteObject(m_hBitmap);
1202 } 1202 }
1203 delete GetBitmap(); 1203 delete GetBitmap();
1204 } 1204 }
1205 1205
1206 #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/win32/dwrite_int.h ('k') | core/src/fxge/win32/fx_win32_dib.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698