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

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

Issue 1252613002: FX_BOOL considered harmful. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Manual edits. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/src/fxge/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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 277 }
278 if (_GetSubFontName(face)) { 278 if (_GetSubFontName(face)) {
279 return; 279 return;
280 } 280 }
281 if (!(picth_family & FF_ROMAN) && weight > 400) { 281 if (!(picth_family & FF_ROMAN) && weight > 400) {
282 face = "MS PGothic"; 282 face = "MS PGothic";
283 } else { 283 } else {
284 face = "MS PMincho"; 284 face = "MS PMincho";
285 } 285 }
286 } 286 }
287 void* CWin32FontInfo::MapFont(int weight, FX_BOOL bItalic, int charset, int pitc h_family, const FX_CHAR* cstr_face, FX_BOOL& bExact) 287 void* CWin32FontInfo::MapFont(int weight, bool bItalic, int charset, int pitch_f amily, const FX_CHAR* cstr_face, bool& bExact)
288 { 288 {
289 CFX_ByteString face = cstr_face; 289 CFX_ByteString face = cstr_face;
290 int iBaseFont; 290 int iBaseFont;
291 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++) 291 for (iBaseFont = 0; iBaseFont < 12; iBaseFont ++)
292 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) { 292 if (face == CFX_ByteStringC(Base14Substs[iBaseFont].m_pName)) {
293 face = Base14Substs[iBaseFont].m_pWinName; 293 face = Base14Substs[iBaseFont].m_pWinName;
294 weight = Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL; 294 weight = Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL;
295 bItalic = Base14Substs[iBaseFont].m_bItalic; 295 bItalic = Base14Substs[iBaseFont].m_bItalic;
296 bExact = TRUE; 296 bExact = true;
297 break; 297 break;
298 } 298 }
299 if (charset == ANSI_CHARSET || charset == SYMBOL_CHARSET) { 299 if (charset == ANSI_CHARSET || charset == SYMBOL_CHARSET) {
300 charset = DEFAULT_CHARSET; 300 charset = DEFAULT_CHARSET;
301 } 301 }
302 int subst_pitch_family = pitch_family; 302 int subst_pitch_family = pitch_family;
303 switch (charset) { 303 switch (charset) {
304 case SHIFTJIS_CHARSET: 304 case SHIFTJIS_CHARSET:
305 subst_pitch_family = FF_ROMAN; 305 subst_pitch_family = FF_ROMAN;
306 break; 306 break;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 { 365 {
366 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 366 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
367 table = FXDWORD_FROM_MSBFIRST(table); 367 table = FXDWORD_FROM_MSBFIRST(table);
368 size = ::GetFontData(m_hDC, table, 0, buffer, size); 368 size = ::GetFontData(m_hDC, table, 0, buffer, size);
369 ::SelectObject(m_hDC, hOldFont); 369 ::SelectObject(m_hDC, hOldFont);
370 if (size == GDI_ERROR) { 370 if (size == GDI_ERROR) {
371 return 0; 371 return 0;
372 } 372 }
373 return size; 373 return size;
374 } 374 }
375 FX_BOOL CWin32FontInfo::GetFaceName(void* hFont, CFX_ByteString& name) 375 bool CWin32FontInfo::GetFaceName(void* hFont, CFX_ByteString& name)
376 { 376 {
377 char facebuf[100]; 377 char facebuf[100];
378 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 378 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
379 int ret = ::GetTextFaceA(m_hDC, 100, facebuf); 379 int ret = ::GetTextFaceA(m_hDC, 100, facebuf);
380 ::SelectObject(m_hDC, hOldFont); 380 ::SelectObject(m_hDC, hOldFont);
381 if (ret == 0) { 381 if (ret == 0) {
382 return FALSE; 382 return false;
383 } 383 }
384 name = facebuf; 384 name = facebuf;
385 return TRUE; 385 return true;
386 } 386 }
387 FX_BOOL CWin32FontInfo::GetFontCharset(void* hFont, int& charset) 387 bool CWin32FontInfo::GetFontCharset(void* hFont, int& charset)
388 { 388 {
389 TEXTMETRIC tm; 389 TEXTMETRIC tm;
390 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); 390 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont);
391 ::GetTextMetrics(m_hDC, &tm); 391 ::GetTextMetrics(m_hDC, &tm);
392 ::SelectObject(m_hDC, hOldFont); 392 ::SelectObject(m_hDC, hOldFont);
393 charset = tm.tmCharSet; 393 charset = tm.tmCharSet;
394 return TRUE; 394 return true;
395 } 395 }
396 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault() 396 IFX_SystemFontInfo* IFX_SystemFontInfo::CreateDefault()
397 { 397 {
398 return new CWin32FontInfo; 398 return new CWin32FontInfo;
399 } 399 }
400 void CFX_GEModule::InitPlatform() 400 void CFX_GEModule::InitPlatform()
401 { 401 {
402 CWin32Platform* pPlatformData = new CWin32Platform; 402 CWin32Platform* pPlatformData = new CWin32Platform;
403 OSVERSIONINFO ver; 403 OSVERSIONINFO ver;
404 ver.dwOSVersionInfoSize = sizeof(ver); 404 ver.dwOSVersionInfoSize = sizeof(ver);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 458 }
459 void* CGdiDeviceDriver::GetClipRgn() 459 void* CGdiDeviceDriver::GetClipRgn()
460 { 460 {
461 HRGN hClipRgn = CreateRectRgn(0, 0, 1, 1); 461 HRGN hClipRgn = CreateRectRgn(0, 0, 1, 1);
462 if (::GetClipRgn(m_hDC, hClipRgn) == 0) { 462 if (::GetClipRgn(m_hDC, hClipRgn) == 0) {
463 DeleteObject(hClipRgn); 463 DeleteObject(hClipRgn);
464 hClipRgn = NULL; 464 hClipRgn = NULL;
465 } 465 }
466 return (void*)hClipRgn; 466 return (void*)hClipRgn;
467 } 467 }
468 FX_BOOL CGdiDeviceDriver::GDI_SetDIBits(const CFX_DIBitmap* pBitmap1, const FX_R ECT* pSrcRect, int left, int top, void* pIccTransform) 468 bool CGdiDeviceDriver::GDI_SetDIBits(const CFX_DIBitmap* pBitmap1, const FX_RECT * pSrcRect, int left, int top, void* pIccTransform)
469 { 469 {
470 if (m_DeviceClass == FXDC_PRINTER) { 470 if (m_DeviceClass == FXDC_PRINTER) {
471 CFX_DIBitmap* pBitmap = pBitmap1->FlipImage(FALSE, TRUE); 471 CFX_DIBitmap* pBitmap = pBitmap1->FlipImage(false, true);
472 if (pBitmap == NULL) { 472 if (pBitmap == NULL) {
473 return FALSE; 473 return false;
474 } 474 }
475 if ((pBitmap->IsCmykImage() || pIccTransform) && 475 if ((pBitmap->IsCmykImage() || pIccTransform) &&
476 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { 476 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) {
477 return FALSE; 477 return false;
478 } 478 }
479 int width = pSrcRect->Width(), height = pSrcRect->Height(); 479 int width = pSrcRect->Width(), height = pSrcRect->Height();
480 int pitch = pBitmap->GetPitch(); 480 int pitch = pBitmap->GetPitch();
481 LPBYTE pBuffer = pBitmap->GetBuffer(); 481 LPBYTE pBuffer = pBitmap->GetBuffer();
482 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); 482 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
483 ((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1; 483 ((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1;
484 FX_RECT dst_rect(0, 0, width, height); 484 FX_RECT dst_rect(0, 0, width, height);
485 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); 485 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight());
486 int dst_width = dst_rect.Width(); 486 int dst_width = dst_rect.Width();
487 int dst_height = dst_rect.Height(); 487 int dst_height = dst_rect.Height();
488 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height, 488 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height,
489 0, 0, dst_width, dst_height, pBuffer, (BITMAPINFO*)info.c_str(), DIB _RGB_COLORS, SRCCOPY); 489 0, 0, dst_width, dst_height, pBuffer, (BITMAPINFO*)info.c_str(), DIB _RGB_COLORS, SRCCOPY);
490 delete pBitmap; 490 delete pBitmap;
491 } else { 491 } else {
492 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; 492 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
493 if ((pBitmap->IsCmykImage() || pIccTransform) && 493 if ((pBitmap->IsCmykImage() || pIccTransform) &&
494 (pBitmap = pBitmap->CloneConvert(FXDIB_Rgb, NULL, pIccTransform) ) == NULL) { 494 (pBitmap = pBitmap->CloneConvert(FXDIB_Rgb, NULL, pIccTransform) ) == NULL) {
495 return FALSE; 495 return false;
496 } 496 }
497 int width = pSrcRect->Width(), height = pSrcRect->Height(); 497 int width = pSrcRect->Width(), height = pSrcRect->Height();
498 int pitch = pBitmap->GetPitch(); 498 int pitch = pBitmap->GetPitch();
499 LPBYTE pBuffer = pBitmap->GetBuffer(); 499 LPBYTE pBuffer = pBitmap->GetBuffer();
500 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); 500 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
501 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, pBi tmap->GetHeight() - pSrcRect->bottom, 501 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, pBi tmap->GetHeight() - pSrcRect->bottom,
502 0, pBitmap->GetHeight(), pBuffer, (BITMAPINFO*)info.c_str(), DIB_RGB _COLORS); 502 0, pBitmap->GetHeight(), pBuffer, (BITMAPINFO*)info.c_str(), DIB_RGB _COLORS);
503 if (pBitmap != pBitmap1) { 503 if (pBitmap != pBitmap1) {
504 delete pBitmap; 504 delete pBitmap;
505 } 505 }
506 } 506 }
507 return TRUE; 507 return true;
508 } 508 }
509 FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1, int de st_left, int dest_top, 509 bool CGdiDeviceDriver::GDI_StretchDIBits(const CFX_DIBitmap* pBitmap1, int dest_ left, int dest_top,
510 int dest_width, int dest_height, FX_DWORD flags, void* pIccTransform) 510 int dest_width, int dest_height, FX_DWORD flags, void* pIccTransform)
511 { 511 {
512 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; 512 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
513 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) { 513 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
514 return FALSE; 514 return false;
515 } 515 }
516 if ((pBitmap->IsCmykImage() || pIccTransform) && 516 if ((pBitmap->IsCmykImage() || pIccTransform) &&
517 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) { 517 !pBitmap->ConvertFormat(FXDIB_Rgb, pIccTransform)) {
518 return FALSE; 518 return false;
519 } 519 }
520 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); 520 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
521 if ((int64_t)abs(dest_width) * abs(dest_height) < (int64_t)pBitmap1->GetWidt h() * pBitmap1->GetHeight() * 4 || 521 if ((int64_t)abs(dest_width) * abs(dest_height) < (int64_t)pBitmap1->GetWidt h() * pBitmap1->GetHeight() * 4 ||
522 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { 522 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) {
523 SetStretchBltMode(m_hDC, HALFTONE); 523 SetStretchBltMode(m_hDC, HALFTONE);
524 } else { 524 } else {
525 SetStretchBltMode(m_hDC, COLORONCOLOR); 525 SetStretchBltMode(m_hDC, COLORONCOLOR);
526 } 526 }
527 CFX_DIBitmap* pToStrechBitmap = pBitmap; 527 CFX_DIBitmap* pToStrechBitmap = pBitmap;
528 bool del = false; 528 bool del = false;
529 if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap ->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) { 529 if (m_DeviceClass == FXDC_PRINTER && ((int64_t)pBitmap->GetWidth() * pBitmap ->GetHeight() > (int64_t)abs(dest_width) * abs(dest_height))) {
530 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); 530 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height);
531 del = true; 531 del = true;
532 } 532 }
533 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB itmap); 533 CFX_ByteString toStrechBitmapInfo = CFX_WindowsDIB::GetBitmapInfo(pToStrechB itmap);
534 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 534 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height,
535 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh t(), pToStrechBitmap->GetBuffer(), 535 0, 0, pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeigh t(), pToStrechBitmap->GetBuffer(),
536 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRC COPY); 536 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, SRC COPY);
537 if (del) { 537 if (del) {
538 delete pToStrechBitmap; 538 delete pToStrechBitmap;
539 } 539 }
540 return TRUE; 540 return true;
541 } 541 }
542 FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1, int d est_left, int dest_top, 542 bool CGdiDeviceDriver::GDI_StretchBitMask(const CFX_DIBitmap* pBitmap1, int dest _left, int dest_top,
543 int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags, 543 int dest_width, int dest_height, FX_DWORD bitmap_color, FX_DWORD flags,
544 int alpha_flag, void* pIccTransform) 544 int alpha_flag, void* pIccTransform)
545 { 545 {
546 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1; 546 CFX_DIBitmap* pBitmap = (CFX_DIBitmap*)pBitmap1;
547 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) { 547 if (pBitmap == NULL || dest_width == 0 || dest_height == 0) {
548 return FALSE; 548 return false;
549 } 549 }
550 _Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24), pIccTransfor m); 550 _Color2Argb(bitmap_color, bitmap_color, alpha_flag | (1 << 24), pIccTransfor m);
551 int width = pBitmap->GetWidth(), height = pBitmap->GetHeight(); 551 int width = pBitmap->GetWidth(), height = pBitmap->GetHeight();
552 struct { 552 struct {
553 BITMAPINFOHEADER bmiHeader; 553 BITMAPINFOHEADER bmiHeader;
554 FX_DWORD bmiColors[2]; 554 FX_DWORD bmiColors[2];
555 } bmi; 555 } bmi;
556 FXSYS_memset(&bmi.bmiHeader, 0, sizeof (BITMAPINFOHEADER)); 556 FXSYS_memset(&bmi.bmiHeader, 0, sizeof (BITMAPINFOHEADER));
557 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); 557 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
558 bmi.bmiHeader.biBitCount = 1; 558 bmi.bmiHeader.biBitCount = 1;
(...skipping 25 matching lines...) Expand all
584 * 1 1 1 1 584 * 1 1 1 1
585 */ 585 */
586 // The boolen codes is B8. Based on http://msdn.microsoft.com/en-us/library/ aa932106.aspx, the ROP3 code is 0xB8074A 586 // The boolen codes is B8. Based on http://msdn.microsoft.com/en-us/library/ aa932106.aspx, the ROP3 code is 0xB8074A
587 587
588 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 588 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height,
589 0, 0, width, height, pBitmap->GetBuffer(), (BITMAPINFO*)&bmi , DIB_RGB_COLORS, 0xB8074A); 589 0, 0, width, height, pBitmap->GetBuffer(), (BITMAPINFO*)&bmi , DIB_RGB_COLORS, 0xB8074A);
590 590
591 SelectObject(m_hDC, hOld); 591 SelectObject(m_hDC, hOld);
592 DeleteObject(hPattern); 592 DeleteObject(hPattern);
593 593
594 return TRUE; 594 return true;
595 } 595 }
596 BOOL CGdiDeviceDriver::GetClipBox(FX_RECT* pRect) 596 BOOL CGdiDeviceDriver::GetClipBox(FX_RECT* pRect)
597 { 597 {
598 return ::GetClipBox(m_hDC, (RECT*)pRect); 598 return ::GetClipBox(m_hDC, (RECT*)pRect);
599 } 599 }
600 FX_BOOL CGdiDeviceDriver::SetClipRgn(void* hRgn) 600 bool CGdiDeviceDriver::SetClipRgn(void* hRgn)
601 { 601 {
602 ::SelectClipRgn(m_hDC, (HRGN)hRgn); 602 ::SelectClipRgn(m_hDC, (HRGN)hRgn);
603 return TRUE; 603 return true;
604 } 604 }
605 static HPEN _CreatePen(const CFX_GraphStateData* pGraphState, const CFX_AffineMa trix* pMatrix, FX_DWORD argb) 605 static HPEN _CreatePen(const CFX_GraphStateData* pGraphState, const CFX_AffineMa trix* pMatrix, FX_DWORD argb)
606 { 606 {
607 FX_FLOAT width; 607 FX_FLOAT width;
608 FX_FLOAT scale = 1.f; 608 FX_FLOAT scale = 1.f;
609 if (pMatrix) 609 if (pMatrix)
610 scale = FXSYS_fabs(pMatrix->a) > FXSYS_fabs(pMatrix->b) ? 610 scale = FXSYS_fabs(pMatrix->a) > FXSYS_fabs(pMatrix->b) ?
611 FXSYS_fabs(pMatrix->a) : FXSYS_fabs(pMatrix->b); 611 FXSYS_fabs(pMatrix->a) : FXSYS_fabs(pMatrix->b);
612 if (pGraphState) { 612 if (pGraphState) {
613 width = scale * pGraphState->m_LineWidth; 613 width = scale * pGraphState->m_LineWidth;
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 } else { 741 } else {
742 x1 = x[0]; 742 x1 = x[0];
743 y1 = y[0]; 743 y1 = y[0];
744 x2 = x[np - 1]; 744 x2 = x[np - 1];
745 y2 = y[np - 1]; 745 y2 = y[np - 1];
746 } 746 }
747 } 747 }
748 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL); 748 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL);
749 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); 749 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2));
750 } 750 }
751 static FX_BOOL _MatrixNoScaled(const CFX_AffineMatrix* pMatrix) 751 static bool _MatrixNoScaled(const CFX_AffineMatrix* pMatrix)
752 { 752 {
753 return pMatrix->GetA() == 1.0f && pMatrix->GetB() == 0 && pMatrix->GetC() == 0 && pMatrix->GetD() == 1.0f; 753 return pMatrix->GetA() == 1.0f && pMatrix->GetB() == 0 && pMatrix->GetC() == 0 && pMatrix->GetD() == 1.0f;
754 } 754 }
755 FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, 755 bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData,
756 const CFX_AffineMatrix* pMatrix, 756 const CFX_AffineMatrix* pMatrix,
757 const CFX_GraphStateData* pGraphState, 757 const CFX_GraphStateData* pGraphState,
758 FX_DWORD fill_color, 758 FX_DWORD fill_color,
759 FX_DWORD stroke_color, 759 FX_DWORD stroke_color,
760 int fill_mode, 760 int fill_mode,
761 int alpha_flag, 761 int alpha_flag,
762 void* pIccTransform, 762 void* pIccTransform,
763 int blend_type 763 int blend_type
764 ) 764 )
765 { 765 {
766 if (blend_type != FXDIB_BLEND_NORMAL) { 766 if (blend_type != FXDIB_BLEND_NORMAL) {
767 return FALSE; 767 return false;
768 } 768 }
769 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); 769 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform);
770 _Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform); 770 _Color2Argb(stroke_color, stroke_color, alpha_flag, pIccTransform);
771 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor mData(); 771 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor mData();
772 if ((pGraphState == NULL || stroke_color == 0) && !pPlatform->m_GdiplusExt.I sAvailable()) { 772 if ((pGraphState == NULL || stroke_color == 0) && !pPlatform->m_GdiplusExt.I sAvailable()) {
773 CFX_FloatRect bbox_f = pPathData->GetBoundingBox(); 773 CFX_FloatRect bbox_f = pPathData->GetBoundingBox();
774 if (pMatrix) { 774 if (pMatrix) {
775 bbox_f.Transform(pMatrix); 775 bbox_f.Transform(pMatrix);
776 } 776 }
777 FX_RECT bbox = bbox_f.GetInnerRect(); 777 FX_RECT bbox = bbox_f.GetInnerRect();
778 if (bbox.Width() <= 0) { 778 if (bbox.Width() <= 0) {
779 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.bottom + 1), fill_color, 779 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.bottom + 1), fill_color,
780 alpha_flag, pIccTransform, FXDIB_BLEND_NORMA L); 780 alpha_flag, pIccTransform, FXDIB_BLEND_NORMA L);
781 } else if (bbox.Height() <= 0) { 781 } else if (bbox.Height() <= 0) {
782 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), fill_color, 782 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), fill_color,
783 alpha_flag, pIccTransform, FXDIB_BLEND_NORMA L); 783 alpha_flag, pIccTransform, FXDIB_BLEND_NORMA L);
784 } 784 }
785 } 785 }
786 int fill_alpha = FXARGB_A(fill_color); 786 int fill_alpha = FXARGB_A(fill_color);
787 int stroke_alpha = FXARGB_A(stroke_color); 787 int stroke_alpha = FXARGB_A(stroke_color);
788 FX_BOOL bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) || (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState); 788 bool bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) || (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState);
789 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha) { 789 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha) {
790 return FALSE; 790 return false;
791 } 791 }
792 if (pPlatform->m_GdiplusExt.IsAvailable()) { 792 if (pPlatform->m_GdiplusExt.IsAvailable()) {
793 if (bDrawAlpha || ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFIL L_FULLCOVER)) || (pGraphState && pGraphState->m_DashCount))) { 793 if (bDrawAlpha || ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFIL L_FULLCOVER)) || (pGraphState && pGraphState->m_DashCount))) {
794 if ( !((NULL == pMatrix || _MatrixNoScaled(pMatrix)) && 794 if ( !((NULL == pMatrix || _MatrixNoScaled(pMatrix)) &&
795 pGraphState && pGraphState->m_LineWidth == 1.f && 795 pGraphState && pGraphState->m_LineWidth == 1.f &&
796 (pPathData->GetPointCount() == 5 || pPathData->GetPointCount () == 4) && 796 (pPathData->GetPointCount() == 5 || pPathData->GetPointCount () == 4) &&
797 pPathData->IsRect()) ) { 797 pPathData->IsRect()) ) {
798 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, pGraphState, fill_color, stroke_color, fill_mode)) { 798 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, pGraphState, fill_color, stroke_color, fill_mode)) {
799 return TRUE; 799 return true;
800 } 800 }
801 } 801 }
802 } 802 }
803 } 803 }
804 int old_fill_mode = fill_mode; 804 int old_fill_mode = fill_mode;
805 fill_mode &= 3; 805 fill_mode &= 3;
806 HPEN hPen = NULL; 806 HPEN hPen = NULL;
807 HBRUSH hBrush = NULL; 807 HBRUSH hBrush = NULL;
808 if (pGraphState && stroke_alpha) { 808 if (pGraphState && stroke_alpha) {
809 SetMiterLimit(m_hDC, pGraphState->m_MiterLimit, NULL); 809 SetMiterLimit(m_hDC, pGraphState->m_MiterLimit, NULL);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
844 } 844 }
845 } 845 }
846 if (hPen) { 846 if (hPen) {
847 hPen = (HPEN)SelectObject(m_hDC, hPen); 847 hPen = (HPEN)SelectObject(m_hDC, hPen);
848 DeleteObject(hPen); 848 DeleteObject(hPen);
849 } 849 }
850 if (hBrush) { 850 if (hBrush) {
851 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); 851 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush);
852 DeleteObject(hBrush); 852 DeleteObject(hBrush);
853 } 853 }
854 return TRUE; 854 return true;
855 } 855 }
856 FX_BOOL CGdiDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, in t alpha_flag, void* pIccTransform, int blend_type) 856 bool CGdiDeviceDriver::FillRect(const FX_RECT* pRect, FX_DWORD fill_color, int a lpha_flag, void* pIccTransform, int blend_type)
857 { 857 {
858 if (blend_type != FXDIB_BLEND_NORMAL) { 858 if (blend_type != FXDIB_BLEND_NORMAL) {
859 return FALSE; 859 return false;
860 } 860 }
861 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform); 861 _Color2Argb(fill_color, fill_color, alpha_flag | (1 << 24), pIccTransform);
862 int alpha; 862 int alpha;
863 FX_COLORREF rgb; 863 FX_COLORREF rgb;
864 ArgbDecode(fill_color, alpha, rgb); 864 ArgbDecode(fill_color, alpha, rgb);
865 if (alpha == 0) { 865 if (alpha == 0) {
866 return TRUE; 866 return true;
867 } 867 }
868 if (alpha < 255) { 868 if (alpha < 255) {
869 return FALSE; 869 return false;
870 } 870 }
871 HBRUSH hBrush = CreateSolidBrush(rgb); 871 HBRUSH hBrush = CreateSolidBrush(rgb);
872 ::FillRect(m_hDC, (RECT*)pRect, hBrush); 872 ::FillRect(m_hDC, (RECT*)pRect, hBrush);
873 DeleteObject(hBrush); 873 DeleteObject(hBrush);
874 return TRUE; 874 return true;
875 } 875 }
876 FX_BOOL CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, 876 bool CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData,
877 const CFX_AffineMatrix* pMatrix, 877 const CFX_AffineMatrix* pMatrix,
878 int fill_mode 878 int fill_mode
879 ) 879 )
880 { 880 {
881 if (pPathData->GetPointCount() == 5) { 881 if (pPathData->GetPointCount() == 5) {
882 CFX_FloatRect rectf; 882 CFX_FloatRect rectf;
883 if (pPathData->IsRect(pMatrix, &rectf)) { 883 if (pPathData->IsRect(pMatrix, &rectf)) {
884 FX_RECT rect = rectf.GetOutterRect(); 884 FX_RECT rect = rectf.GetOutterRect();
885 IntersectClipRect(m_hDC, rect.left, rect.top, rect.right, rect.botto m); 885 IntersectClipRect(m_hDC, rect.left, rect.top, rect.right, rect.botto m);
886 return TRUE; 886 return true;
887 } 887 }
888 } 888 }
889 _SetPathToDC(m_hDC, pPathData, pMatrix); 889 _SetPathToDC(m_hDC, pPathData, pMatrix);
890 SetPolyFillMode(m_hDC, fill_mode & 3); 890 SetPolyFillMode(m_hDC, fill_mode & 3);
891 SelectClipPath(m_hDC, RGN_AND); 891 SelectClipPath(m_hDC, RGN_AND);
892 return TRUE; 892 return true;
893 } 893 }
894 FX_BOOL CGdiDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData, 894 bool CGdiDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData,
895 const CFX_AffineMatrix* pMatrix, 895 const CFX_AffineMatrix* pMatrix,
896 const CFX_GraphStateData* pGraphState 896 const CFX_GraphStateData* pGraphState
897 ) 897 )
898 { 898 {
899 HPEN hPen = _CreatePen(pGraphState, pMatrix, 0xff000000); 899 HPEN hPen = _CreatePen(pGraphState, pMatrix, 0xff000000);
900 hPen = (HPEN)SelectObject(m_hDC, hPen); 900 hPen = (HPEN)SelectObject(m_hDC, hPen);
901 _SetPathToDC(m_hDC, pPathData, pMatrix); 901 _SetPathToDC(m_hDC, pPathData, pMatrix);
902 WidenPath(m_hDC); 902 WidenPath(m_hDC);
903 SetPolyFillMode(m_hDC, WINDING); 903 SetPolyFillMode(m_hDC, WINDING);
904 FX_BOOL ret = SelectClipPath(m_hDC, RGN_AND); 904 bool ret = SelectClipPath(m_hDC, RGN_AND);
905 hPen = (HPEN)SelectObject(m_hDC, hPen); 905 hPen = (HPEN)SelectObject(m_hDC, hPen);
906 DeleteObject(hPen); 906 DeleteObject(hPen);
907 return ret; 907 return ret;
908 } 908 }
909 FX_BOOL CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2 , FX_FLOAT y2, FX_DWORD color, 909 bool CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, FX_FLOAT y1, FX_FLOAT x2, F X_FLOAT y2, FX_DWORD color,
910 int alpha_flag, void* pIccTransform, int blend_type) 910 int alpha_flag, void* pIccTransform, int blend_type)
911 { 911 {
912 if (blend_type != FXDIB_BLEND_NORMAL) { 912 if (blend_type != FXDIB_BLEND_NORMAL) {
913 return FALSE; 913 return false;
914 } 914 }
915 _Color2Argb(color, color, alpha_flag | (1 << 24), pIccTransform); 915 _Color2Argb(color, color, alpha_flag | (1 << 24), pIccTransform);
916 int a; 916 int a;
917 FX_COLORREF rgb; 917 FX_COLORREF rgb;
918 ArgbDecode(color, a, rgb); 918 ArgbDecode(color, a, rgb);
919 if (a == 0) { 919 if (a == 0) {
920 return TRUE; 920 return true;
921 } 921 }
922 HPEN hPen = CreatePen(PS_SOLID, 1, rgb); 922 HPEN hPen = CreatePen(PS_SOLID, 1, rgb);
923 hPen = (HPEN)SelectObject(m_hDC, hPen); 923 hPen = (HPEN)SelectObject(m_hDC, hPen);
924 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL); 924 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), NULL);
925 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); 925 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2));
926 hPen = (HPEN)SelectObject(m_hDC, hPen); 926 hPen = (HPEN)SelectObject(m_hDC, hPen);
927 DeleteObject(hPen); 927 DeleteObject(hPen);
928 return TRUE; 928 return true;
929 } 929 }
930 FX_BOOL CGdiDeviceDriver::DeleteDeviceRgn(void* pRgn) 930 bool CGdiDeviceDriver::DeleteDeviceRgn(void* pRgn)
931 { 931 {
932 DeleteObject((HGDIOBJ)pRgn); 932 DeleteObject((HGDIOBJ)pRgn);
933 return TRUE; 933 return true;
934 } 934 }
935 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) : CGdiDeviceDriver(hDC, FXDC_DISPL AY) 935 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) : CGdiDeviceDriver(hDC, FXDC_DISPL AY)
936 { 936 {
937 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor mData(); 937 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->GetPlatfor mData();
938 if (pPlatform->m_GdiplusExt.IsAvailable()) { 938 if (pPlatform->m_GdiplusExt.IsAvailable()) {
939 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE; 939 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE;
940 } 940 }
941 } 941 }
942 FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, v oid* pIccTransform, FX_BOOL bDEdge) 942 bool CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top, void * pIccTransform, bool bDEdge)
943 { 943 {
944 FX_BOOL ret = FALSE; 944 bool ret = false;
945 int width = pBitmap->GetWidth(); 945 int width = pBitmap->GetWidth();
946 int height = pBitmap->GetHeight(); 946 int height = pBitmap->GetHeight();
947 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height); 947 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height);
948 HDC hDCMemory = CreateCompatibleDC(m_hDC); 948 HDC hDCMemory = CreateCompatibleDC(m_hDC);
949 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp); 949 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp);
950 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY); 950 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY);
951 SelectObject(hDCMemory, holdbmp); 951 SelectObject(hDCMemory, holdbmp);
952 BITMAPINFO bmi; 952 BITMAPINFO bmi;
953 FXSYS_memset(&bmi, 0, sizeof bmi); 953 FXSYS_memset(&bmi, 0, sizeof bmi);
954 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader; 954 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader;
955 bmi.bmiHeader.biBitCount = pBitmap->GetBPP(); 955 bmi.bmiHeader.biBitCount = pBitmap->GetBPP();
956 bmi.bmiHeader.biHeight = -height; 956 bmi.bmiHeader.biHeight = -height;
957 bmi.bmiHeader.biPlanes = 1; 957 bmi.bmiHeader.biPlanes = 1;
958 bmi.bmiHeader.biWidth = width; 958 bmi.bmiHeader.biWidth = width;
959 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec Module()->GetIccModule()) { 959 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec Module()->GetIccModule()) {
960 pIccTransform = NULL; 960 pIccTransform = NULL;
961 } 961 }
962 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && pIccTransform == NUL L) { 962 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage() && pIccTransform == NUL L) {
963 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi , DIB_RGB_COLORS) == height; 963 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi , DIB_RGB_COLORS) == height;
964 } else { 964 } else {
965 CFX_DIBitmap bitmap; 965 CFX_DIBitmap bitmap;
966 if (bitmap.Create(width, height, FXDIB_Rgb)) { 966 if (bitmap.Create(width, height, FXDIB_Rgb)) {
967 bmi.bmiHeader.biBitCount = 24; 967 bmi.bmiHeader.biBitCount = 24;
968 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, DI B_RGB_COLORS); 968 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, DI B_RGB_COLORS);
969 ret = pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0, pI ccTransform); 969 ret = pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0, pI ccTransform);
970 } else { 970 } else {
971 ret = FALSE; 971 ret = false;
972 } 972 }
973 } 973 }
974 if (pBitmap->HasAlpha() && ret) { 974 if (pBitmap->HasAlpha() && ret) {
975 pBitmap->LoadChannel(FXDIB_Alpha, 0xff); 975 pBitmap->LoadChannel(FXDIB_Alpha, 0xff);
976 } 976 }
977 DeleteObject(hbmp); 977 DeleteObject(hbmp);
978 DeleteObject(hDCMemory); 978 DeleteObject(hDCMemory);
979 return ret; 979 return ret;
980 } 980 }
981 FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD colo r, const FX_RECT* pSrcRect, int left, int top, int blend_type, 981 bool CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, FX_DWORD color, const FX_RECT* pSrcRect, int left, int top, int blend_type,
982 int alpha_flag, void* pIccTransform) 982 int alpha_flag, void* pIccTransform)
983 { 983 {
984 ASSERT(blend_type == FXDIB_BLEND_NORMAL); 984 ASSERT(blend_type == FXDIB_BLEND_NORMAL);
985 if (pSource->IsAlphaMask()) { 985 if (pSource->IsAlphaMask()) {
986 int width = pSource->GetWidth(), height = pSource->GetHeight(); 986 int width = pSource->GetWidth(), height = pSource->GetHeight();
987 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha _flag) : FXARGB_A(color); 987 int alpha = FXGETFLAG_COLORTYPE(alpha_flag) ? FXGETFLAG_ALPHA_FILL(alpha _flag) : FXARGB_A(color);
988 FX_BOOL bGDI = pSource->GetBPP() == 1 && alpha == 255; 988 bool bGDI = pSource->GetBPP() == 1 && alpha == 255;
989 if (!bGDI) { 989 if (!bGDI) {
990 CFX_DIBitmap background; 990 CFX_DIBitmap background;
991 if (!background.Create(width, height, FXDIB_Rgb32) || 991 if (!background.Create(width, height, FXDIB_Rgb32) ||
992 !GetDIBits(&background, left, top, NULL) || 992 !GetDIBits(&background, left, top, NULL) ||
993 !background.CompositeMask(0, 0, width, height, pSource, colo r, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { 993 !background.CompositeMask(0, 0, width, height, pSource, colo r, 0, 0, FXDIB_BLEND_NORMAL, NULL, false, alpha_flag, pIccTransform)) {
994 return FALSE; 994 return false;
995 } 995 }
996 FX_RECT src_rect(0, 0, width, height); 996 FX_RECT src_rect(0, 0, width, height);
997 return SetDIBits(&background, 0, &src_rect, left, top, FXDIB_BLEND_N ORMAL, 0, NULL); 997 return SetDIBits(&background, 0, &src_rect, left, top, FXDIB_BLEND_N ORMAL, 0, NULL);
998 } 998 }
999 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->H eight()); 999 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), top + pSrcRect->H eight());
1000 return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRe ct->top, width, height, 1000 return StretchDIBits(pSource, color, left - pSrcRect->left, top - pSrcRe ct->top, width, height,
1001 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE ND_NORMAL); 1001 &clip_rect, 0, alpha_flag, pIccTransform, FXDIB_BLE ND_NORMAL);
1002 } else { 1002 } else {
1003 int width = pSrcRect->Width(), height = pSrcRect->Height(); 1003 int width = pSrcRect->Width(), height = pSrcRect->Height();
1004 if (pSource->HasAlpha()) { 1004 if (pSource->HasAlpha()) {
1005 CFX_DIBitmap bitmap; 1005 CFX_DIBitmap bitmap;
1006 if (!bitmap.Create(width, height, FXDIB_Rgb) || 1006 if (!bitmap.Create(width, height, FXDIB_Rgb) ||
1007 !GetDIBits(&bitmap, left, top, NULL) || 1007 !GetDIBits(&bitmap, left, top, NULL) ||
1008 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRe ct->left, pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, FALSE, pIccTransform)) { 1008 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRe ct->left, pSrcRect->top, FXDIB_BLEND_NORMAL, NULL, false, pIccTransform)) {
1009 return FALSE; 1009 return false;
1010 } 1010 }
1011 FX_RECT src_rect(0, 0, width, height); 1011 FX_RECT src_rect(0, 0, width, height);
1012 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMA L, 0, NULL); 1012 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMA L, 0, NULL);
1013 } 1013 }
1014 CFX_DIBExtractor temp(pSource); 1014 CFX_DIBExtractor temp(pSource);
1015 CFX_DIBitmap* pBitmap = temp; 1015 CFX_DIBitmap* pBitmap = temp;
1016 if (pBitmap) { 1016 if (pBitmap) {
1017 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform); 1017 return GDI_SetDIBits(pBitmap, pSrcRect, left, top, pIccTransform);
1018 } 1018 }
1019 } 1019 }
1020 return FALSE; 1020 return false;
1021 } 1021 }
1022 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, F X_DWORD color, int dest_left, int dest_top, 1022 bool CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, FX_D WORD color, int dest_left, int dest_top,
1023 int dest_width, int dest_height, const FX_RECT* pClipRect, int render_fl ags, 1023 int dest_width, int dest_height, const FX_RECT* pClipRect, int render_fl ags,
1024 int alpha_flag, void* pIccTransform, int blend_type) 1024 int alpha_flag, void* pIccTransform, int blend_type)
1025 { 1025 {
1026 FX_RECT bitmap_clip = *pClipRect; 1026 FX_RECT bitmap_clip = *pClipRect;
1027 if (dest_width < 0) { 1027 if (dest_width < 0) {
1028 dest_left += dest_width; 1028 dest_left += dest_width;
1029 } 1029 }
1030 if (dest_height < 0) { 1030 if (dest_height < 0) {
1031 dest_top += dest_height; 1031 dest_top += dest_height;
1032 } 1032 }
1033 bitmap_clip.Offset(-dest_left, -dest_top); 1033 bitmap_clip.Offset(-dest_left, -dest_top);
1034 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, rende r_flags, &bitmap_clip); 1034 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, rende r_flags, &bitmap_clip);
1035 if (pStretched == NULL) { 1035 if (pStretched == NULL) {
1036 return TRUE; 1036 return true;
1037 } 1037 }
1038 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); 1038 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight());
1039 FX_BOOL ret = SetDIBits(pStretched, color, &src_rect, pClipRect->left, pClip Rect->top, FXDIB_BLEND_NORMAL, alpha_flag, pIccTransform); 1039 bool ret = SetDIBits(pStretched, color, &src_rect, pClipRect->left, pClipRec t->top, FXDIB_BLEND_NORMAL, alpha_flag, pIccTransform);
1040 delete pStretched; 1040 delete pStretched;
1041 return ret; 1041 return ret;
1042 } 1042 }
1043 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD color, int dest_left, int dest_top, 1043 bool CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, FX_DWORD col or, int dest_left, int dest_top,
1044 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag s, 1044 int dest_width, int dest_height, const FX_RECT* pClipRect, FX_DWORD flag s,
1045 int alpha_flag, void* pIccTransform, int blend_type) 1045 int alpha_flag, void* pIccTransform, int blend_type)
1046 { 1046 {
1047 ASSERT(pSource != NULL && pClipRect != NULL); 1047 ASSERT(pSource != NULL && pClipRect != NULL);
1048 if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 1000 0 || dest_height < -10000) 1048 if (flags || dest_width > 10000 || dest_width < -10000 || dest_height > 1000 0 || dest_height < -10000)
1049 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w idth, dest_height, 1049 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, dest_w idth, dest_height,
1050 pClipRect, flags, alpha_flag, pIccTransform , blend_type); 1050 pClipRect, flags, alpha_flag, pIccTransform , blend_type);
1051 if (pSource->IsAlphaMask()) { 1051 if (pSource->IsAlphaMask()) {
1052 FX_RECT image_rect; 1052 FX_RECT image_rect;
1053 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; 1053 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width;
1054 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left; 1054 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left;
1055 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height; 1055 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height;
1056 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top; 1056 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top;
1057 FX_RECT clip_rect = image_rect; 1057 FX_RECT clip_rect = image_rect;
1058 clip_rect.Intersect(*pClipRect); 1058 clip_rect.Intersect(*pClipRect);
1059 clip_rect.Offset(-image_rect.left, -image_rect.top); 1059 clip_rect.Offset(-image_rect.left, -image_rect.top);
1060 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); 1060 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height();
1061 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, f lags, &clip_rect); 1061 CFX_DIBitmap* pStretched = pSource->StretchTo(dest_width, dest_height, f lags, &clip_rect);
1062 if (pStretched == NULL) { 1062 if (pStretched == NULL) {
1063 return TRUE; 1063 return true;
1064 } 1064 }
1065 CFX_DIBitmap background; 1065 CFX_DIBitmap background;
1066 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || 1066 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) ||
1067 !GetDIBits(&background, image_rect.left + clip_rect.left, image_ rect.top + clip_rect.top, NULL) || 1067 !GetDIBits(&background, image_rect.left + clip_rect.left, image_ rect.top + clip_rect.top, NULL) ||
1068 !background.CompositeMask(0, 0, clip_width, clip_height, pStretc hed, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, FALSE, alpha_flag, pIccTransform)) { 1068 !background.CompositeMask(0, 0, clip_width, clip_height, pStretc hed, color, 0, 0, FXDIB_BLEND_NORMAL, NULL, false, alpha_flag, pIccTransform)) {
1069 delete pStretched; 1069 delete pStretched;
1070 return FALSE; 1070 return false;
1071 } 1071 }
1072 FX_RECT src_rect(0, 0, clip_width, clip_height); 1072 FX_RECT src_rect(0, 0, clip_width, clip_height);
1073 FX_BOOL ret = SetDIBits(&background, 0, &src_rect, image_rect.left + cli p_rect.left, image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL, 0, NULL); 1073 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);
1074 delete pStretched; 1074 delete pStretched;
1075 return ret; 1075 return ret;
1076 } else { 1076 } else {
1077 if (pSource->HasAlpha()) { 1077 if (pSource->HasAlpha()) {
1078 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->Ge tPlatformData(); 1078 CWin32Platform* pPlatform = (CWin32Platform*)CFX_GEModule::Get()->Ge tPlatformData();
1079 if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL & & !pSource->IsCmykImage()) { 1079 if (pPlatform->m_GdiplusExt.IsAvailable() && pIccTransform == NULL & & !pSource->IsCmykImage()) {
1080 CFX_DIBExtractor temp(pSource); 1080 CFX_DIBExtractor temp(pSource);
1081 CFX_DIBitmap* pBitmap = temp; 1081 CFX_DIBitmap* pBitmap = temp;
1082 if (pBitmap == NULL) { 1082 if (pBitmap == NULL) {
1083 return FALSE; 1083 return false;
1084 } 1084 }
1085 return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, des t_left, dest_top, dest_width, dest_height, pClipRect, flags); 1085 return pPlatform->m_GdiplusExt.StretchDIBits(m_hDC, pBitmap, des t_left, dest_top, dest_width, dest_height, pClipRect, flags);
1086 } 1086 }
1087 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, de st_width, dest_height, 1087 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, de st_width, dest_height,
1088 pClipRect, flags, alpha_flag, pIccTrans form, blend_type); 1088 pClipRect, flags, alpha_flag, pIccTrans form, blend_type);
1089 } 1089 }
1090 CFX_DIBExtractor temp(pSource); 1090 CFX_DIBExtractor temp(pSource);
1091 CFX_DIBitmap* pBitmap = temp; 1091 CFX_DIBitmap* pBitmap = temp;
1092 if (pBitmap) { 1092 if (pBitmap) {
1093 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, d est_height, flags, pIccTransform); 1093 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, d est_height, flags, pIccTransform);
1094 } 1094 }
1095 } 1095 }
1096 return FALSE; 1096 return false;
1097 } 1097 }
1098 #define GET_PS_FEATURESETTING 4121 1098 #define GET_PS_FEATURESETTING 4121
1099 #define FEATURESETTING_PSLEVEL 2 1099 #define FEATURESETTING_PSLEVEL 2
1100 int GetPSLevel(HDC hDC) 1100 int GetPSLevel(HDC hDC)
1101 { 1101 {
1102 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); 1102 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY);
1103 if (device_type != DT_RASPRINTER) { 1103 if (device_type != DT_RASPRINTER) {
1104 return 0; 1104 return 0;
1105 } 1105 }
1106 FX_DWORD esc = GET_PS_FEATURESETTING; 1106 FX_DWORD esc = GET_PS_FEATURESETTING;
(...skipping 18 matching lines...) Expand all
1125 esc = GET_PS_FEATURESETTING; 1125 esc = GET_PS_FEATURESETTING;
1126 if (ExtEscape(hDC, QUERYESCSUPPORT, sizeof esc, (char*)&esc, 0, NULL)) { 1126 if (ExtEscape(hDC, QUERYESCSUPPORT, sizeof esc, (char*)&esc, 0, NULL)) {
1127 int param = FEATURESETTING_PSLEVEL; 1127 int param = FEATURESETTING_PSLEVEL;
1128 if (ExtEscape(hDC, GET_PS_FEATURESETTING, sizeof(int), (char*)&param, si zeof(int), (char*)&param) > 0) { 1128 if (ExtEscape(hDC, GET_PS_FEATURESETTING, sizeof(int), (char*)&param, si zeof(int), (char*)&param) > 0) {
1129 return param; 1129 return param;
1130 } 1130 }
1131 } 1131 }
1132 return 2; 1132 return 2;
1133 } 1133 }
1134 int CFX_WindowsDevice::m_psLevel = 2; 1134 int CFX_WindowsDevice::m_psLevel = 2;
1135 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC, FX_BOOL bCmykOutput, FX_BOOL bForc ePSOutput, int psLevel) 1135 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC, bool bCmykOutput, bool bForcePSOut put, int psLevel)
1136 { 1136 {
1137 m_bForcePSOutput = bForcePSOutput; 1137 m_bForcePSOutput = bForcePSOutput;
1138 m_psLevel = psLevel; 1138 m_psLevel = psLevel;
1139 if (bForcePSOutput) { 1139 if (bForcePSOutput) {
1140 IFX_RenderDeviceDriver* pDriver = new CPSPrinterDriver; 1140 IFX_RenderDeviceDriver* pDriver = new CPSPrinterDriver;
1141 ((CPSPrinterDriver*)pDriver)->Init(hDC, psLevel, bCmykOutput); 1141 ((CPSPrinterDriver*)pDriver)->Init(hDC, psLevel, bCmykOutput);
1142 SetDeviceDriver(pDriver); 1142 SetDeviceDriver(pDriver);
1143 return; 1143 return;
1144 } 1144 }
1145 SetDeviceDriver(CreateDriver(hDC, bCmykOutput)); 1145 SetDeviceDriver(CreateDriver(hDC, bCmykOutput));
1146 } 1146 }
1147 HDC CFX_WindowsDevice::GetDC() const 1147 HDC CFX_WindowsDevice::GetDC() const
1148 { 1148 {
1149 IFX_RenderDeviceDriver *pRDD = GetDeviceDriver(); 1149 IFX_RenderDeviceDriver *pRDD = GetDeviceDriver();
1150 if (!pRDD) { 1150 if (!pRDD) {
1151 return NULL; 1151 return NULL;
1152 } 1152 }
1153 return (HDC)pRDD->GetPlatformSurface(); 1153 return (HDC)pRDD->GetPlatformSurface();
1154 } 1154 }
1155 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC, FX_BOOL bCmykOu tput) 1155 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC, bool bCmykOutpu t)
1156 { 1156 {
1157 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); 1157 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY);
1158 int obj_type = ::GetObjectType(hDC); 1158 int obj_type = ::GetObjectType(hDC);
1159 int device_class; 1159 int device_class;
1160 if (device_type == DT_RASPRINTER || device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC) { 1160 if (device_type == DT_RASPRINTER || device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC) {
1161 device_class = FXDC_PRINTER; 1161 device_class = FXDC_PRINTER;
1162 } else { 1162 } else {
1163 device_class = FXDC_DISPLAY; 1163 device_class = FXDC_DISPLAY;
1164 } 1164 }
1165 if (device_class == FXDC_PRINTER) { 1165 if (device_class == FXDC_PRINTER) {
(...skipping 29 matching lines...) Expand all
1195 SelectObject(m_hDC, m_hOldBitmap); 1195 SelectObject(m_hDC, m_hOldBitmap);
1196 DeleteDC(m_hDC); 1196 DeleteDC(m_hDC);
1197 } 1197 }
1198 if (m_hBitmap) { 1198 if (m_hBitmap) {
1199 DeleteObject(m_hBitmap); 1199 DeleteObject(m_hBitmap);
1200 } 1200 }
1201 delete GetBitmap(); 1201 delete GetBitmap();
1202 } 1202 }
1203 1203
1204 #endif // _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ 1204 #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