OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include <crtdbg.h> | 7 #include <crtdbg.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 312 } |
313 ++np; | 313 ++np; |
314 } | 314 } |
315 } | 315 } |
316 } | 316 } |
317 } | 317 } |
318 return np; | 318 return np; |
319 } | 319 } |
320 #endif // _SKIA_SUPPORT_ | 320 #endif // _SKIA_SUPPORT_ |
321 | 321 |
322 FX_BOOL MatrixNoScaled(const CFX_Matrix* pMatrix) { | 322 bool MatrixNoScaled(const CFX_Matrix* pMatrix) { |
323 return pMatrix->GetA() == 1.0f && pMatrix->GetB() == 0 && | 323 return pMatrix->GetA() == 1.0f && pMatrix->GetB() == 0 && |
324 pMatrix->GetC() == 0 && pMatrix->GetD() == 1.0f; | 324 pMatrix->GetC() == 0 && pMatrix->GetD() == 1.0f; |
325 } | 325 } |
326 | 326 |
327 class CFX_Win32FallbackFontInfo final : public CFX_FolderFontInfo { | 327 class CFX_Win32FallbackFontInfo final : public CFX_FolderFontInfo { |
328 public: | 328 public: |
329 CFX_Win32FallbackFontInfo() {} | 329 CFX_Win32FallbackFontInfo() {} |
330 ~CFX_Win32FallbackFontInfo() override {} | 330 ~CFX_Win32FallbackFontInfo() override {} |
331 | 331 |
332 // CFX_FolderFontInfo: | 332 // CFX_FolderFontInfo: |
333 void* MapFont(int weight, | 333 void* MapFont(int weight, |
334 FX_BOOL bItalic, | 334 bool bItalic, |
335 int charset, | 335 int charset, |
336 int pitch_family, | 336 int pitch_family, |
337 const FX_CHAR* family, | 337 const FX_CHAR* family, |
338 int& iExact) override; | 338 int& iExact) override; |
339 }; | 339 }; |
340 | 340 |
341 class CFX_Win32FontInfo final : public IFX_SystemFontInfo { | 341 class CFX_Win32FontInfo final : public IFX_SystemFontInfo { |
342 public: | 342 public: |
343 CFX_Win32FontInfo(); | 343 CFX_Win32FontInfo(); |
344 ~CFX_Win32FontInfo() override; | 344 ~CFX_Win32FontInfo() override; |
345 | 345 |
346 // IFX_SystemFontInfo | 346 // IFX_SystemFontInfo |
347 FX_BOOL EnumFontList(CFX_FontMapper* pMapper) override; | 347 bool EnumFontList(CFX_FontMapper* pMapper) override; |
348 void* MapFont(int weight, | 348 void* MapFont(int weight, |
349 FX_BOOL bItalic, | 349 bool bItalic, |
350 int charset, | 350 int charset, |
351 int pitch_family, | 351 int pitch_family, |
352 const FX_CHAR* face, | 352 const FX_CHAR* face, |
353 int& iExact) override; | 353 int& iExact) override; |
354 void* GetFont(const FX_CHAR* face) override { return nullptr; } | 354 void* GetFont(const FX_CHAR* face) override { return nullptr; } |
355 uint32_t GetFontData(void* hFont, | 355 uint32_t GetFontData(void* hFont, |
356 uint32_t table, | 356 uint32_t table, |
357 uint8_t* buffer, | 357 uint8_t* buffer, |
358 uint32_t size) override; | 358 uint32_t size) override; |
359 FX_BOOL GetFaceName(void* hFont, CFX_ByteString& name) override; | 359 bool GetFaceName(void* hFont, CFX_ByteString& name) override; |
360 FX_BOOL GetFontCharset(void* hFont, int& charset) override; | 360 bool GetFontCharset(void* hFont, int& charset) override; |
361 void DeleteFont(void* hFont) override; | 361 void DeleteFont(void* hFont) override; |
362 | 362 |
363 FX_BOOL IsOpenTypeFromDiv(const LOGFONTA* plf); | 363 bool IsOpenTypeFromDiv(const LOGFONTA* plf); |
364 FX_BOOL IsSupportFontFormDiv(const LOGFONTA* plf); | 364 bool IsSupportFontFormDiv(const LOGFONTA* plf); |
365 void AddInstalledFont(const LOGFONTA* plf, uint32_t FontType); | 365 void AddInstalledFont(const LOGFONTA* plf, uint32_t FontType); |
366 void GetGBPreference(CFX_ByteString& face, int weight, int picth_family); | 366 void GetGBPreference(CFX_ByteString& face, int weight, int picth_family); |
367 void GetJapanesePreference(CFX_ByteString& face, | 367 void GetJapanesePreference(CFX_ByteString& face, |
368 int weight, | 368 int weight, |
369 int picth_family); | 369 int picth_family); |
370 CFX_ByteString FindFont(const CFX_ByteString& name); | 370 CFX_ByteString FindFont(const CFX_ByteString& name); |
371 | 371 |
372 HDC m_hDC; | 372 HDC m_hDC; |
373 CFX_FontMapper* m_pMapper; | 373 CFX_FontMapper* m_pMapper; |
374 CFX_ByteString m_LastFamily; | 374 CFX_ByteString m_LastFamily; |
375 CFX_ByteString m_KaiTi, m_FangSong; | 375 CFX_ByteString m_KaiTi, m_FangSong; |
376 }; | 376 }; |
377 | 377 |
378 int CALLBACK FontEnumProc(const LOGFONTA* plf, | 378 int CALLBACK FontEnumProc(const LOGFONTA* plf, |
379 const TEXTMETRICA* lpntme, | 379 const TEXTMETRICA* lpntme, |
380 uint32_t FontType, | 380 uint32_t FontType, |
381 LPARAM lParam) { | 381 LPARAM lParam) { |
382 CFX_Win32FontInfo* pFontInfo = reinterpret_cast<CFX_Win32FontInfo*>(lParam); | 382 CFX_Win32FontInfo* pFontInfo = reinterpret_cast<CFX_Win32FontInfo*>(lParam); |
383 pFontInfo->AddInstalledFont(plf, FontType); | 383 pFontInfo->AddInstalledFont(plf, FontType); |
384 return 1; | 384 return 1; |
385 } | 385 } |
386 | 386 |
387 CFX_Win32FontInfo::CFX_Win32FontInfo() : m_hDC(CreateCompatibleDC(nullptr)) {} | 387 CFX_Win32FontInfo::CFX_Win32FontInfo() : m_hDC(CreateCompatibleDC(nullptr)) {} |
388 | 388 |
389 CFX_Win32FontInfo::~CFX_Win32FontInfo() { | 389 CFX_Win32FontInfo::~CFX_Win32FontInfo() { |
390 DeleteDC(m_hDC); | 390 DeleteDC(m_hDC); |
391 } | 391 } |
392 | 392 |
393 FX_BOOL CFX_Win32FontInfo::IsOpenTypeFromDiv(const LOGFONTA* plf) { | 393 bool CFX_Win32FontInfo::IsOpenTypeFromDiv(const LOGFONTA* plf) { |
394 HFONT hFont = CreateFontIndirectA(plf); | 394 HFONT hFont = CreateFontIndirectA(plf); |
395 FX_BOOL ret = FALSE; | 395 bool ret = false; |
396 uint32_t font_size = GetFontData(hFont, 0, nullptr, 0); | 396 uint32_t font_size = GetFontData(hFont, 0, nullptr, 0); |
397 if (font_size != GDI_ERROR && font_size >= sizeof(uint32_t)) { | 397 if (font_size != GDI_ERROR && font_size >= sizeof(uint32_t)) { |
398 uint32_t lVersion = 0; | 398 uint32_t lVersion = 0; |
399 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(uint32_t)); | 399 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(uint32_t)); |
400 lVersion = (((uint32_t)(uint8_t)(lVersion)) << 24) | | 400 lVersion = (((uint32_t)(uint8_t)(lVersion)) << 24) | |
401 ((uint32_t)((uint8_t)(lVersion >> 8))) << 16 | | 401 ((uint32_t)((uint8_t)(lVersion >> 8))) << 16 | |
402 ((uint32_t)((uint8_t)(lVersion >> 16))) << 8 | | 402 ((uint32_t)((uint8_t)(lVersion >> 16))) << 8 | |
403 ((uint8_t)(lVersion >> 24)); | 403 ((uint8_t)(lVersion >> 24)); |
404 if (lVersion == FXBSTR_ID('O', 'T', 'T', 'O') || lVersion == 0x00010000 || | 404 if (lVersion == FXBSTR_ID('O', 'T', 'T', 'O') || lVersion == 0x00010000 || |
405 lVersion == FXBSTR_ID('t', 't', 'c', 'f') || | 405 lVersion == FXBSTR_ID('t', 't', 'c', 'f') || |
406 lVersion == FXBSTR_ID('t', 'r', 'u', 'e') || lVersion == 0x00020000) { | 406 lVersion == FXBSTR_ID('t', 'r', 'u', 'e') || lVersion == 0x00020000) { |
407 ret = TRUE; | 407 ret = true; |
408 } | 408 } |
409 } | 409 } |
410 DeleteFont(hFont); | 410 DeleteFont(hFont); |
411 return ret; | 411 return ret; |
412 } | 412 } |
413 | 413 |
414 FX_BOOL CFX_Win32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf) { | 414 bool CFX_Win32FontInfo::IsSupportFontFormDiv(const LOGFONTA* plf) { |
415 HFONT hFont = CreateFontIndirectA(plf); | 415 HFONT hFont = CreateFontIndirectA(plf); |
416 FX_BOOL ret = FALSE; | 416 bool ret = false; |
417 uint32_t font_size = GetFontData(hFont, 0, nullptr, 0); | 417 uint32_t font_size = GetFontData(hFont, 0, nullptr, 0); |
418 if (font_size != GDI_ERROR && font_size >= sizeof(uint32_t)) { | 418 if (font_size != GDI_ERROR && font_size >= sizeof(uint32_t)) { |
419 uint32_t lVersion = 0; | 419 uint32_t lVersion = 0; |
420 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(uint32_t)); | 420 GetFontData(hFont, 0, (uint8_t*)(&lVersion), sizeof(uint32_t)); |
421 lVersion = (((uint32_t)(uint8_t)(lVersion)) << 24) | | 421 lVersion = (((uint32_t)(uint8_t)(lVersion)) << 24) | |
422 ((uint32_t)((uint8_t)(lVersion >> 8))) << 16 | | 422 ((uint32_t)((uint8_t)(lVersion >> 8))) << 16 | |
423 ((uint32_t)((uint8_t)(lVersion >> 16))) << 8 | | 423 ((uint32_t)((uint8_t)(lVersion >> 16))) << 8 | |
424 ((uint8_t)(lVersion >> 24)); | 424 ((uint8_t)(lVersion >> 24)); |
425 if (lVersion == FXBSTR_ID('O', 'T', 'T', 'O') || lVersion == 0x00010000 || | 425 if (lVersion == FXBSTR_ID('O', 'T', 'T', 'O') || lVersion == 0x00010000 || |
426 lVersion == FXBSTR_ID('t', 't', 'c', 'f') || | 426 lVersion == FXBSTR_ID('t', 't', 'c', 'f') || |
427 lVersion == FXBSTR_ID('t', 'r', 'u', 'e') || lVersion == 0x00020000 || | 427 lVersion == FXBSTR_ID('t', 'r', 'u', 'e') || lVersion == 0x00020000 || |
428 (lVersion & 0xFFFF0000) == FXBSTR_ID(0x80, 0x01, 0x00, 0x00) || | 428 (lVersion & 0xFFFF0000) == FXBSTR_ID(0x80, 0x01, 0x00, 0x00) || |
429 (lVersion & 0xFFFF0000) == FXBSTR_ID('%', '!', 0, 0)) { | 429 (lVersion & 0xFFFF0000) == FXBSTR_ID('%', '!', 0, 0)) { |
430 ret = TRUE; | 430 ret = true; |
431 } | 431 } |
432 } | 432 } |
433 DeleteFont(hFont); | 433 DeleteFont(hFont); |
434 return ret; | 434 return ret; |
435 } | 435 } |
436 | 436 |
437 void CFX_Win32FontInfo::AddInstalledFont(const LOGFONTA* plf, | 437 void CFX_Win32FontInfo::AddInstalledFont(const LOGFONTA* plf, |
438 uint32_t FontType) { | 438 uint32_t FontType) { |
439 CFX_ByteString name(plf->lfFaceName); | 439 CFX_ByteString name(plf->lfFaceName); |
440 if (name[0] == '@') | 440 if (name[0] == '@') |
441 return; | 441 return; |
442 | 442 |
443 if (name == m_LastFamily) { | 443 if (name == m_LastFamily) { |
444 m_pMapper->AddInstalledFont(name, plf->lfCharSet); | 444 m_pMapper->AddInstalledFont(name, plf->lfCharSet); |
445 return; | 445 return; |
446 } | 446 } |
447 if (!(FontType & TRUETYPE_FONTTYPE)) { | 447 if (!(FontType & TRUETYPE_FONTTYPE)) { |
448 if (!(FontType & DEVICE_FONTTYPE) || !IsSupportFontFormDiv(plf)) | 448 if (!(FontType & DEVICE_FONTTYPE) || !IsSupportFontFormDiv(plf)) |
449 return; | 449 return; |
450 } | 450 } |
451 | 451 |
452 m_pMapper->AddInstalledFont(name, plf->lfCharSet); | 452 m_pMapper->AddInstalledFont(name, plf->lfCharSet); |
453 m_LastFamily = name; | 453 m_LastFamily = name; |
454 } | 454 } |
455 | 455 |
456 FX_BOOL CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper) { | 456 bool CFX_Win32FontInfo::EnumFontList(CFX_FontMapper* pMapper) { |
457 m_pMapper = pMapper; | 457 m_pMapper = pMapper; |
458 LOGFONTA lf; | 458 LOGFONTA lf; |
459 FXSYS_memset(&lf, 0, sizeof(LOGFONTA)); | 459 FXSYS_memset(&lf, 0, sizeof(LOGFONTA)); |
460 lf.lfCharSet = FXFONT_DEFAULT_CHARSET; | 460 lf.lfCharSet = FXFONT_DEFAULT_CHARSET; |
461 lf.lfFaceName[0] = 0; | 461 lf.lfFaceName[0] = 0; |
462 lf.lfPitchAndFamily = 0; | 462 lf.lfPitchAndFamily = 0; |
463 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t) this, | 463 EnumFontFamiliesExA(m_hDC, &lf, (FONTENUMPROCA)FontEnumProc, (uintptr_t) this, |
464 0); | 464 0); |
465 return TRUE; | 465 return true; |
466 } | 466 } |
467 | 467 |
468 CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) { | 468 CFX_ByteString CFX_Win32FontInfo::FindFont(const CFX_ByteString& name) { |
469 if (!m_pMapper) | 469 if (!m_pMapper) |
470 return name; | 470 return name; |
471 | 471 |
472 for (size_t i = 0; i < m_pMapper->m_InstalledTTFonts.size(); ++i) { | 472 for (size_t i = 0; i < m_pMapper->m_InstalledTTFonts.size(); ++i) { |
473 CFX_ByteString thisname = m_pMapper->m_InstalledTTFonts[i]; | 473 CFX_ByteString thisname = m_pMapper->m_InstalledTTFonts[i]; |
474 if (thisname.Left(name.GetLength()) == name) | 474 if (thisname.Left(name.GetLength()) == name) |
475 return m_pMapper->m_InstalledTTFonts[i]; | 475 return m_pMapper->m_InstalledTTFonts[i]; |
476 } | 476 } |
477 for (size_t i = 0; i < m_pMapper->m_LocalizedTTFonts.size(); ++i) { | 477 for (size_t i = 0; i < m_pMapper->m_LocalizedTTFonts.size(); ++i) { |
478 CFX_ByteString thisname = m_pMapper->m_LocalizedTTFonts[i].first; | 478 CFX_ByteString thisname = m_pMapper->m_LocalizedTTFonts[i].first; |
479 if (thisname.Left(name.GetLength()) == name) | 479 if (thisname.Left(name.GetLength()) == name) |
480 return m_pMapper->m_LocalizedTTFonts[i].second; | 480 return m_pMapper->m_LocalizedTTFonts[i].second; |
481 } | 481 } |
482 return CFX_ByteString(); | 482 return CFX_ByteString(); |
483 } | 483 } |
484 | 484 |
485 void* CFX_Win32FallbackFontInfo::MapFont(int weight, | 485 void* CFX_Win32FallbackFontInfo::MapFont(int weight, |
486 FX_BOOL bItalic, | 486 bool bItalic, |
487 int charset, | 487 int charset, |
488 int pitch_family, | 488 int pitch_family, |
489 const FX_CHAR* cstr_face, | 489 const FX_CHAR* cstr_face, |
490 int& iExact) { | 490 int& iExact) { |
491 void* font = GetSubstFont(cstr_face); | 491 void* font = GetSubstFont(cstr_face); |
492 if (font) { | 492 if (font) { |
493 iExact = 1; | 493 iExact = 1; |
494 return font; | 494 return font; |
495 } | 495 } |
496 FX_BOOL bCJK = TRUE; | 496 bool bCJK = true; |
497 switch (charset) { | 497 switch (charset) { |
498 case FXFONT_SHIFTJIS_CHARSET: | 498 case FXFONT_SHIFTJIS_CHARSET: |
499 case FXFONT_GB2312_CHARSET: | 499 case FXFONT_GB2312_CHARSET: |
500 case FXFONT_CHINESEBIG5_CHARSET: | 500 case FXFONT_CHINESEBIG5_CHARSET: |
501 case FXFONT_HANGUL_CHARSET: | 501 case FXFONT_HANGUL_CHARSET: |
502 default: | 502 default: |
503 bCJK = FALSE; | 503 bCJK = false; |
504 break; | 504 break; |
505 } | 505 } |
506 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); | 506 return FindFont(weight, bItalic, charset, pitch_family, cstr_face, !bCJK); |
507 } | 507 } |
508 | 508 |
509 void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face, | 509 void CFX_Win32FontInfo::GetGBPreference(CFX_ByteString& face, |
510 int weight, | 510 int weight, |
511 int picth_family) { | 511 int picth_family) { |
512 if (face.Find("KaiTi") >= 0 || face.Find("\xbf\xac") >= 0) { | 512 if (face.Find("KaiTi") >= 0 || face.Find("\xbf\xac") >= 0) { |
513 if (m_KaiTi.IsEmpty()) { | 513 if (m_KaiTi.IsEmpty()) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 return; | 568 return; |
569 | 569 |
570 if (!(picth_family & FF_ROMAN) && weight > 400) { | 570 if (!(picth_family & FF_ROMAN) && weight > 400) { |
571 face = "MS PGothic"; | 571 face = "MS PGothic"; |
572 } else { | 572 } else { |
573 face = "MS PMincho"; | 573 face = "MS PMincho"; |
574 } | 574 } |
575 } | 575 } |
576 | 576 |
577 void* CFX_Win32FontInfo::MapFont(int weight, | 577 void* CFX_Win32FontInfo::MapFont(int weight, |
578 FX_BOOL bItalic, | 578 bool bItalic, |
579 int charset, | 579 int charset, |
580 int pitch_family, | 580 int pitch_family, |
581 const FX_CHAR* cstr_face, | 581 const FX_CHAR* cstr_face, |
582 int& iExact) { | 582 int& iExact) { |
583 CFX_ByteString face = cstr_face; | 583 CFX_ByteString face = cstr_face; |
584 int iBaseFont; | 584 int iBaseFont; |
585 for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) | 585 for (iBaseFont = 0; iBaseFont < 12; iBaseFont++) |
586 if (face == CFX_ByteStringC(g_Base14Substs[iBaseFont].m_pName)) { | 586 if (face == CFX_ByteStringC(g_Base14Substs[iBaseFont].m_pName)) { |
587 face = g_Base14Substs[iBaseFont].m_pWinName; | 587 face = g_Base14Substs[iBaseFont].m_pWinName; |
588 weight = g_Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL; | 588 weight = g_Base14Substs[iBaseFont].m_bBold ? FW_BOLD : FW_NORMAL; |
589 bItalic = g_Base14Substs[iBaseFont].m_bItalic; | 589 bItalic = g_Base14Substs[iBaseFont].m_bItalic; |
590 iExact = TRUE; | 590 iExact = true; |
591 break; | 591 break; |
592 } | 592 } |
593 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { | 593 if (charset == FXFONT_ANSI_CHARSET || charset == FXFONT_SYMBOL_CHARSET) { |
594 charset = FXFONT_DEFAULT_CHARSET; | 594 charset = FXFONT_DEFAULT_CHARSET; |
595 } | 595 } |
596 int subst_pitch_family = pitch_family; | 596 int subst_pitch_family = pitch_family; |
597 switch (charset) { | 597 switch (charset) { |
598 case FXFONT_SHIFTJIS_CHARSET: | 598 case FXFONT_SHIFTJIS_CHARSET: |
599 subst_pitch_family = FF_ROMAN; | 599 subst_pitch_family = FF_ROMAN; |
600 break; | 600 break; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); | 665 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); |
666 table = FXDWORD_GET_MSBFIRST(reinterpret_cast<uint8_t*>(&table)); | 666 table = FXDWORD_GET_MSBFIRST(reinterpret_cast<uint8_t*>(&table)); |
667 size = ::GetFontData(m_hDC, table, 0, buffer, size); | 667 size = ::GetFontData(m_hDC, table, 0, buffer, size); |
668 ::SelectObject(m_hDC, hOldFont); | 668 ::SelectObject(m_hDC, hOldFont); |
669 if (size == GDI_ERROR) { | 669 if (size == GDI_ERROR) { |
670 return 0; | 670 return 0; |
671 } | 671 } |
672 return size; | 672 return size; |
673 } | 673 } |
674 | 674 |
675 FX_BOOL CFX_Win32FontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { | 675 bool CFX_Win32FontInfo::GetFaceName(void* hFont, CFX_ByteString& name) { |
676 char facebuf[100]; | 676 char facebuf[100]; |
677 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); | 677 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); |
678 int ret = ::GetTextFaceA(m_hDC, 100, facebuf); | 678 int ret = ::GetTextFaceA(m_hDC, 100, facebuf); |
679 ::SelectObject(m_hDC, hOldFont); | 679 ::SelectObject(m_hDC, hOldFont); |
680 if (ret == 0) { | 680 if (ret == 0) { |
681 return FALSE; | 681 return false; |
682 } | 682 } |
683 name = facebuf; | 683 name = facebuf; |
684 return TRUE; | 684 return true; |
685 } | 685 } |
686 | 686 |
687 FX_BOOL CFX_Win32FontInfo::GetFontCharset(void* hFont, int& charset) { | 687 bool CFX_Win32FontInfo::GetFontCharset(void* hFont, int& charset) { |
688 TEXTMETRIC tm; | 688 TEXTMETRIC tm; |
689 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); | 689 HFONT hOldFont = (HFONT)::SelectObject(m_hDC, (HFONT)hFont); |
690 ::GetTextMetrics(m_hDC, &tm); | 690 ::GetTextMetrics(m_hDC, &tm); |
691 ::SelectObject(m_hDC, hOldFont); | 691 ::SelectObject(m_hDC, hOldFont); |
692 charset = tm.tmCharSet; | 692 charset = tm.tmCharSet; |
693 return TRUE; | 693 return true; |
694 } | 694 } |
695 | 695 |
696 } // namespace | 696 } // namespace |
697 | 697 |
698 std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault( | 698 std::unique_ptr<IFX_SystemFontInfo> IFX_SystemFontInfo::CreateDefault( |
699 const char** pUnused) { | 699 const char** pUnused) { |
700 if (IsGDIEnabled()) | 700 if (IsGDIEnabled()) |
701 return std::unique_ptr<IFX_SystemFontInfo>(new CFX_Win32FontInfo); | 701 return std::unique_ptr<IFX_SystemFontInfo>(new CFX_Win32FontInfo); |
702 | 702 |
703 // Select the fallback font information class if GDI is disabled. | 703 // Select the fallback font information class if GDI is disabled. |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 void CGdiDeviceDriver::SaveState() { | 780 void CGdiDeviceDriver::SaveState() { |
781 SaveDC(m_hDC); | 781 SaveDC(m_hDC); |
782 } | 782 } |
783 | 783 |
784 void CGdiDeviceDriver::RestoreState(bool bKeepSaved) { | 784 void CGdiDeviceDriver::RestoreState(bool bKeepSaved) { |
785 RestoreDC(m_hDC, -1); | 785 RestoreDC(m_hDC, -1); |
786 if (bKeepSaved) | 786 if (bKeepSaved) |
787 SaveDC(m_hDC); | 787 SaveDC(m_hDC); |
788 } | 788 } |
789 | 789 |
790 FX_BOOL CGdiDeviceDriver::GDI_SetDIBits(CFX_DIBitmap* pBitmap1, | 790 bool CGdiDeviceDriver::GDI_SetDIBits(CFX_DIBitmap* pBitmap1, |
791 const FX_RECT* pSrcRect, | 791 const FX_RECT* pSrcRect, |
792 int left, | 792 int left, |
793 int top) { | 793 int top) { |
794 if (m_DeviceClass == FXDC_PRINTER) { | 794 if (m_DeviceClass == FXDC_PRINTER) { |
795 std::unique_ptr<CFX_DIBitmap> pBitmap(pBitmap1->FlipImage(FALSE, TRUE)); | 795 std::unique_ptr<CFX_DIBitmap> pBitmap(pBitmap1->FlipImage(false, true)); |
796 if (!pBitmap) | 796 if (!pBitmap) |
797 return FALSE; | 797 return false; |
798 | 798 |
799 if (pBitmap->IsCmykImage() && !pBitmap->ConvertFormat(FXDIB_Rgb)) | 799 if (pBitmap->IsCmykImage() && !pBitmap->ConvertFormat(FXDIB_Rgb)) |
800 return FALSE; | 800 return false; |
801 | 801 |
802 int width = pSrcRect->Width(), height = pSrcRect->Height(); | 802 int width = pSrcRect->Width(), height = pSrcRect->Height(); |
803 LPBYTE pBuffer = pBitmap->GetBuffer(); | 803 LPBYTE pBuffer = pBitmap->GetBuffer(); |
804 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap.get()); | 804 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap.get()); |
805 ((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1; | 805 ((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1; |
806 FX_RECT dst_rect(0, 0, width, height); | 806 FX_RECT dst_rect(0, 0, width, height); |
807 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); | 807 dst_rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); |
808 int dst_width = dst_rect.Width(); | 808 int dst_width = dst_rect.Width(); |
809 int dst_height = dst_rect.Height(); | 809 int dst_height = dst_rect.Height(); |
810 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height, 0, 0, dst_width, | 810 ::StretchDIBits(m_hDC, left, top, dst_width, dst_height, 0, 0, dst_width, |
811 dst_height, pBuffer, (BITMAPINFO*)info.c_str(), | 811 dst_height, pBuffer, (BITMAPINFO*)info.c_str(), |
812 DIB_RGB_COLORS, SRCCOPY); | 812 DIB_RGB_COLORS, SRCCOPY); |
813 } else { | 813 } else { |
814 CFX_DIBitmap* pBitmap = pBitmap1; | 814 CFX_DIBitmap* pBitmap = pBitmap1; |
815 if (pBitmap->IsCmykImage()) { | 815 if (pBitmap->IsCmykImage()) { |
816 pBitmap = pBitmap->CloneConvert(FXDIB_Rgb); | 816 pBitmap = pBitmap->CloneConvert(FXDIB_Rgb); |
817 if (!pBitmap) | 817 if (!pBitmap) |
818 return FALSE; | 818 return false; |
819 } | 819 } |
820 int width = pSrcRect->Width(), height = pSrcRect->Height(); | 820 int width = pSrcRect->Width(), height = pSrcRect->Height(); |
821 LPBYTE pBuffer = pBitmap->GetBuffer(); | 821 LPBYTE pBuffer = pBitmap->GetBuffer(); |
822 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); | 822 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); |
823 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, | 823 ::SetDIBitsToDevice(m_hDC, left, top, width, height, pSrcRect->left, |
824 pBitmap->GetHeight() - pSrcRect->bottom, 0, | 824 pBitmap->GetHeight() - pSrcRect->bottom, 0, |
825 pBitmap->GetHeight(), pBuffer, | 825 pBitmap->GetHeight(), pBuffer, |
826 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); | 826 (BITMAPINFO*)info.c_str(), DIB_RGB_COLORS); |
827 if (pBitmap != pBitmap1) { | 827 if (pBitmap != pBitmap1) { |
828 delete pBitmap; | 828 delete pBitmap; |
829 } | 829 } |
830 } | 830 } |
831 return TRUE; | 831 return true; |
832 } | 832 } |
833 | 833 |
834 FX_BOOL CGdiDeviceDriver::GDI_StretchDIBits(CFX_DIBitmap* pBitmap1, | 834 bool CGdiDeviceDriver::GDI_StretchDIBits(CFX_DIBitmap* pBitmap1, |
835 int dest_left, | 835 int dest_left, |
836 int dest_top, | 836 int dest_top, |
837 int dest_width, | 837 int dest_width, |
838 int dest_height, | 838 int dest_height, |
839 uint32_t flags) { | 839 uint32_t flags) { |
840 CFX_DIBitmap* pBitmap = pBitmap1; | 840 CFX_DIBitmap* pBitmap = pBitmap1; |
841 if (!pBitmap || dest_width == 0 || dest_height == 0) | 841 if (!pBitmap || dest_width == 0 || dest_height == 0) |
842 return FALSE; | 842 return false; |
843 | 843 |
844 if (pBitmap->IsCmykImage() && !pBitmap->ConvertFormat(FXDIB_Rgb)) | 844 if (pBitmap->IsCmykImage() && !pBitmap->ConvertFormat(FXDIB_Rgb)) |
845 return FALSE; | 845 return false; |
846 | 846 |
847 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); | 847 CFX_ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap); |
848 if ((int64_t)abs(dest_width) * abs(dest_height) < | 848 if ((int64_t)abs(dest_width) * abs(dest_height) < |
849 (int64_t)pBitmap1->GetWidth() * pBitmap1->GetHeight() * 4 || | 849 (int64_t)pBitmap1->GetWidth() * pBitmap1->GetHeight() * 4 || |
850 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { | 850 (flags & FXDIB_INTERPOL) || (flags & FXDIB_BICUBIC_INTERPOL)) { |
851 SetStretchBltMode(m_hDC, HALFTONE); | 851 SetStretchBltMode(m_hDC, HALFTONE); |
852 } else { | 852 } else { |
853 SetStretchBltMode(m_hDC, COLORONCOLOR); | 853 SetStretchBltMode(m_hDC, COLORONCOLOR); |
854 } | 854 } |
855 CFX_DIBitmap* pToStrechBitmap = pBitmap; | 855 CFX_DIBitmap* pToStrechBitmap = pBitmap; |
856 bool del = false; | 856 bool del = false; |
857 if (m_DeviceClass == FXDC_PRINTER && | 857 if (m_DeviceClass == FXDC_PRINTER && |
858 ((int64_t)pBitmap->GetWidth() * pBitmap->GetHeight() > | 858 ((int64_t)pBitmap->GetWidth() * pBitmap->GetHeight() > |
859 (int64_t)abs(dest_width) * abs(dest_height))) { | 859 (int64_t)abs(dest_width) * abs(dest_height))) { |
860 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); | 860 pToStrechBitmap = pBitmap->StretchTo(dest_width, dest_height); |
861 del = true; | 861 del = true; |
862 } | 862 } |
863 CFX_ByteString toStrechBitmapInfo = | 863 CFX_ByteString toStrechBitmapInfo = |
864 CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap); | 864 CFX_WindowsDIB::GetBitmapInfo(pToStrechBitmap); |
865 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0, | 865 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0, |
866 pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeight(), | 866 pToStrechBitmap->GetWidth(), pToStrechBitmap->GetHeight(), |
867 pToStrechBitmap->GetBuffer(), | 867 pToStrechBitmap->GetBuffer(), |
868 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, | 868 (BITMAPINFO*)toStrechBitmapInfo.c_str(), DIB_RGB_COLORS, |
869 SRCCOPY); | 869 SRCCOPY); |
870 if (del) | 870 if (del) |
871 delete pToStrechBitmap; | 871 delete pToStrechBitmap; |
872 return TRUE; | 872 return true; |
873 } | 873 } |
874 | 874 |
875 FX_BOOL CGdiDeviceDriver::GDI_StretchBitMask(CFX_DIBitmap* pBitmap1, | 875 bool CGdiDeviceDriver::GDI_StretchBitMask(CFX_DIBitmap* pBitmap1, |
876 int dest_left, | 876 int dest_left, |
877 int dest_top, | 877 int dest_top, |
878 int dest_width, | 878 int dest_width, |
879 int dest_height, | 879 int dest_height, |
880 uint32_t bitmap_color, | 880 uint32_t bitmap_color, |
881 uint32_t flags) { | 881 uint32_t flags) { |
882 CFX_DIBitmap* pBitmap = pBitmap1; | 882 CFX_DIBitmap* pBitmap = pBitmap1; |
883 if (!pBitmap || dest_width == 0 || dest_height == 0) | 883 if (!pBitmap || dest_width == 0 || dest_height == 0) |
884 return FALSE; | 884 return false; |
885 | 885 |
886 int width = pBitmap->GetWidth(), height = pBitmap->GetHeight(); | 886 int width = pBitmap->GetWidth(), height = pBitmap->GetHeight(); |
887 struct { | 887 struct { |
888 BITMAPINFOHEADER bmiHeader; | 888 BITMAPINFOHEADER bmiHeader; |
889 uint32_t bmiColors[2]; | 889 uint32_t bmiColors[2]; |
890 } bmi; | 890 } bmi; |
891 FXSYS_memset(&bmi.bmiHeader, 0, sizeof(BITMAPINFOHEADER)); | 891 FXSYS_memset(&bmi.bmiHeader, 0, sizeof(BITMAPINFOHEADER)); |
892 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); | 892 bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
893 bmi.bmiHeader.biBitCount = 1; | 893 bmi.bmiHeader.biBitCount = 1; |
894 bmi.bmiHeader.biCompression = BI_RGB; | 894 bmi.bmiHeader.biCompression = BI_RGB; |
(...skipping 27 matching lines...) Expand all Loading... |
922 // http://msdn.microsoft.com/en-us/library/aa932106.aspx, the ROP3 code is | 922 // http://msdn.microsoft.com/en-us/library/aa932106.aspx, the ROP3 code is |
923 // 0xB8074A | 923 // 0xB8074A |
924 | 924 |
925 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0, | 925 ::StretchDIBits(m_hDC, dest_left, dest_top, dest_width, dest_height, 0, 0, |
926 width, height, pBitmap->GetBuffer(), (BITMAPINFO*)&bmi, | 926 width, height, pBitmap->GetBuffer(), (BITMAPINFO*)&bmi, |
927 DIB_RGB_COLORS, 0xB8074A); | 927 DIB_RGB_COLORS, 0xB8074A); |
928 | 928 |
929 SelectObject(m_hDC, hOld); | 929 SelectObject(m_hDC, hOld); |
930 DeleteObject(hPattern); | 930 DeleteObject(hPattern); |
931 | 931 |
932 return TRUE; | 932 return true; |
933 } | 933 } |
934 | 934 |
935 FX_BOOL CGdiDeviceDriver::GetClipBox(FX_RECT* pRect) { | 935 bool CGdiDeviceDriver::GetClipBox(FX_RECT* pRect) { |
936 return !!(::GetClipBox(m_hDC, (RECT*)pRect)); | 936 return !!(::GetClipBox(m_hDC, (RECT*)pRect)); |
937 } | 937 } |
938 | 938 |
939 void* CGdiDeviceDriver::GetPlatformSurface() const { | 939 void* CGdiDeviceDriver::GetPlatformSurface() const { |
940 return (void*)m_hDC; | 940 return (void*)m_hDC; |
941 } | 941 } |
942 | 942 |
943 void CGdiDeviceDriver::DrawLine(FX_FLOAT x1, | 943 void CGdiDeviceDriver::DrawLine(FX_FLOAT x1, |
944 FX_FLOAT y1, | 944 FX_FLOAT y1, |
945 FX_FLOAT x2, | 945 FX_FLOAT x2, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 } | 979 } |
980 } | 980 } |
981 if (pMatrix) { | 981 if (pMatrix) { |
982 pMatrix->Transform(x1, y1); | 982 pMatrix->Transform(x1, y1); |
983 pMatrix->Transform(x2, y2); | 983 pMatrix->Transform(x2, y2); |
984 } | 984 } |
985 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); | 985 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); |
986 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); | 986 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); |
987 } | 987 } |
988 | 988 |
989 FX_BOOL CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, | 989 bool CGdiDeviceDriver::DrawPath(const CFX_PathData* pPathData, |
990 const CFX_Matrix* pMatrix, | 990 const CFX_Matrix* pMatrix, |
991 const CFX_GraphStateData* pGraphState, | 991 const CFX_GraphStateData* pGraphState, |
992 uint32_t fill_color, | 992 uint32_t fill_color, |
993 uint32_t stroke_color, | 993 uint32_t stroke_color, |
994 int fill_mode, | 994 int fill_mode, |
995 int blend_type) { | 995 int blend_type) { |
996 if (blend_type != FXDIB_BLEND_NORMAL) | 996 if (blend_type != FXDIB_BLEND_NORMAL) |
997 return FALSE; | 997 return false; |
998 | 998 |
999 CWin32Platform* pPlatform = | 999 CWin32Platform* pPlatform = |
1000 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); | 1000 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); |
1001 if (!(pGraphState || stroke_color == 0) && | 1001 if (!(pGraphState || stroke_color == 0) && |
1002 !pPlatform->m_GdiplusExt.IsAvailable()) { | 1002 !pPlatform->m_GdiplusExt.IsAvailable()) { |
1003 CFX_FloatRect bbox_f = pPathData->GetBoundingBox(); | 1003 CFX_FloatRect bbox_f = pPathData->GetBoundingBox(); |
1004 if (pMatrix) { | 1004 if (pMatrix) { |
1005 bbox_f.Transform(pMatrix); | 1005 bbox_f.Transform(pMatrix); |
1006 } | 1006 } |
1007 FX_RECT bbox = bbox_f.GetInnerRect(); | 1007 FX_RECT bbox = bbox_f.GetInnerRect(); |
1008 if (bbox.Width() <= 0) { | 1008 if (bbox.Width() <= 0) { |
1009 return DrawCosmeticLine( | 1009 return DrawCosmeticLine( |
1010 (FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.left), | 1010 (FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), (FX_FLOAT)(bbox.left), |
1011 (FX_FLOAT)(bbox.bottom + 1), fill_color, FXDIB_BLEND_NORMAL); | 1011 (FX_FLOAT)(bbox.bottom + 1), fill_color, FXDIB_BLEND_NORMAL); |
1012 } | 1012 } |
1013 if (bbox.Height() <= 0) { | 1013 if (bbox.Height() <= 0) { |
1014 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), | 1014 return DrawCosmeticLine((FX_FLOAT)(bbox.left), (FX_FLOAT)(bbox.top), |
1015 (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), | 1015 (FX_FLOAT)(bbox.right + 1), (FX_FLOAT)(bbox.top), |
1016 fill_color, FXDIB_BLEND_NORMAL); | 1016 fill_color, FXDIB_BLEND_NORMAL); |
1017 } | 1017 } |
1018 } | 1018 } |
1019 int fill_alpha = FXARGB_A(fill_color); | 1019 int fill_alpha = FXARGB_A(fill_color); |
1020 int stroke_alpha = FXARGB_A(stroke_color); | 1020 int stroke_alpha = FXARGB_A(stroke_color); |
1021 FX_BOOL bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) || | 1021 bool bDrawAlpha = (fill_alpha > 0 && fill_alpha < 255) || |
1022 (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState); | 1022 (stroke_alpha > 0 && stroke_alpha < 255 && pGraphState); |
1023 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha) | 1023 if (!pPlatform->m_GdiplusExt.IsAvailable() && bDrawAlpha) |
1024 return FALSE; | 1024 return false; |
1025 | 1025 |
1026 if (pPlatform->m_GdiplusExt.IsAvailable()) { | 1026 if (pPlatform->m_GdiplusExt.IsAvailable()) { |
1027 if (bDrawAlpha || | 1027 if (bDrawAlpha || |
1028 ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFILL_FULLCOVER)) || | 1028 ((m_DeviceClass != FXDC_PRINTER && !(fill_mode & FXFILL_FULLCOVER)) || |
1029 (pGraphState && pGraphState->m_DashCount))) { | 1029 (pGraphState && pGraphState->m_DashCount))) { |
1030 if (!((!pMatrix || MatrixNoScaled(pMatrix)) && pGraphState && | 1030 if (!((!pMatrix || MatrixNoScaled(pMatrix)) && pGraphState && |
1031 pGraphState->m_LineWidth == 1.f && | 1031 pGraphState->m_LineWidth == 1.f && |
1032 (pPathData->GetPointCount() == 5 || | 1032 (pPathData->GetPointCount() == 5 || |
1033 pPathData->GetPointCount() == 4) && | 1033 pPathData->GetPointCount() == 4) && |
1034 pPathData->IsRect())) { | 1034 pPathData->IsRect())) { |
1035 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, | 1035 if (pPlatform->m_GdiplusExt.DrawPath(m_hDC, pPathData, pMatrix, |
1036 pGraphState, fill_color, | 1036 pGraphState, fill_color, |
1037 stroke_color, fill_mode)) { | 1037 stroke_color, fill_mode)) { |
1038 return TRUE; | 1038 return true; |
1039 } | 1039 } |
1040 } | 1040 } |
1041 } | 1041 } |
1042 } | 1042 } |
1043 int old_fill_mode = fill_mode; | 1043 int old_fill_mode = fill_mode; |
1044 fill_mode &= 3; | 1044 fill_mode &= 3; |
1045 HPEN hPen = nullptr; | 1045 HPEN hPen = nullptr; |
1046 HBRUSH hBrush = nullptr; | 1046 HBRUSH hBrush = nullptr; |
1047 if (pGraphState && stroke_alpha) { | 1047 if (pGraphState && stroke_alpha) { |
1048 SetMiterLimit(m_hDC, pGraphState->m_MiterLimit, nullptr); | 1048 SetMiterLimit(m_hDC, pGraphState->m_MiterLimit, nullptr); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 } | 1080 } |
1081 } | 1081 } |
1082 if (hPen) { | 1082 if (hPen) { |
1083 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1083 hPen = (HPEN)SelectObject(m_hDC, hPen); |
1084 DeleteObject(hPen); | 1084 DeleteObject(hPen); |
1085 } | 1085 } |
1086 if (hBrush) { | 1086 if (hBrush) { |
1087 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); | 1087 hBrush = (HBRUSH)SelectObject(m_hDC, hBrush); |
1088 DeleteObject(hBrush); | 1088 DeleteObject(hBrush); |
1089 } | 1089 } |
1090 return TRUE; | 1090 return true; |
1091 } | 1091 } |
1092 | 1092 |
1093 FX_BOOL CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, | 1093 bool CGdiDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, |
1094 uint32_t fill_color, | 1094 uint32_t fill_color, |
1095 int blend_type) { | 1095 int blend_type) { |
1096 if (blend_type != FXDIB_BLEND_NORMAL) | 1096 if (blend_type != FXDIB_BLEND_NORMAL) |
1097 return FALSE; | 1097 return false; |
1098 | 1098 |
1099 int alpha; | 1099 int alpha; |
1100 FX_COLORREF rgb; | 1100 FX_COLORREF rgb; |
1101 ArgbDecode(fill_color, alpha, rgb); | 1101 ArgbDecode(fill_color, alpha, rgb); |
1102 if (alpha == 0) | 1102 if (alpha == 0) |
1103 return TRUE; | 1103 return true; |
1104 | 1104 |
1105 if (alpha < 255) | 1105 if (alpha < 255) |
1106 return FALSE; | 1106 return false; |
1107 | 1107 |
1108 HBRUSH hBrush = CreateSolidBrush(rgb); | 1108 HBRUSH hBrush = CreateSolidBrush(rgb); |
1109 ::FillRect(m_hDC, (RECT*)pRect, hBrush); | 1109 ::FillRect(m_hDC, (RECT*)pRect, hBrush); |
1110 DeleteObject(hBrush); | 1110 DeleteObject(hBrush); |
1111 return TRUE; | 1111 return true; |
1112 } | 1112 } |
1113 | 1113 |
1114 FX_BOOL CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, | 1114 bool CGdiDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, |
1115 const CFX_Matrix* pMatrix, | 1115 const CFX_Matrix* pMatrix, |
1116 int fill_mode) { | 1116 int fill_mode) { |
1117 if (pPathData->GetPointCount() == 5) { | 1117 if (pPathData->GetPointCount() == 5) { |
1118 CFX_FloatRect rectf; | 1118 CFX_FloatRect rectf; |
1119 if (pPathData->IsRect(pMatrix, &rectf)) { | 1119 if (pPathData->IsRect(pMatrix, &rectf)) { |
1120 FX_RECT rect = rectf.GetOuterRect(); | 1120 FX_RECT rect = rectf.GetOuterRect(); |
1121 IntersectClipRect(m_hDC, rect.left, rect.top, rect.right, rect.bottom); | 1121 IntersectClipRect(m_hDC, rect.left, rect.top, rect.right, rect.bottom); |
1122 return TRUE; | 1122 return true; |
1123 } | 1123 } |
1124 } | 1124 } |
1125 SetPathToDC(m_hDC, pPathData, pMatrix); | 1125 SetPathToDC(m_hDC, pPathData, pMatrix); |
1126 SetPolyFillMode(m_hDC, fill_mode & 3); | 1126 SetPolyFillMode(m_hDC, fill_mode & 3); |
1127 SelectClipPath(m_hDC, RGN_AND); | 1127 SelectClipPath(m_hDC, RGN_AND); |
1128 return TRUE; | 1128 return true; |
1129 } | 1129 } |
1130 | 1130 |
1131 FX_BOOL CGdiDeviceDriver::SetClip_PathStroke( | 1131 bool CGdiDeviceDriver::SetClip_PathStroke( |
1132 const CFX_PathData* pPathData, | 1132 const CFX_PathData* pPathData, |
1133 const CFX_Matrix* pMatrix, | 1133 const CFX_Matrix* pMatrix, |
1134 const CFX_GraphStateData* pGraphState) { | 1134 const CFX_GraphStateData* pGraphState) { |
1135 HPEN hPen = CreatePen(pGraphState, pMatrix, 0xff000000); | 1135 HPEN hPen = CreatePen(pGraphState, pMatrix, 0xff000000); |
1136 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1136 hPen = (HPEN)SelectObject(m_hDC, hPen); |
1137 SetPathToDC(m_hDC, pPathData, pMatrix); | 1137 SetPathToDC(m_hDC, pPathData, pMatrix); |
1138 WidenPath(m_hDC); | 1138 WidenPath(m_hDC); |
1139 SetPolyFillMode(m_hDC, WINDING); | 1139 SetPolyFillMode(m_hDC, WINDING); |
1140 FX_BOOL ret = !!SelectClipPath(m_hDC, RGN_AND); | 1140 bool ret = !!SelectClipPath(m_hDC, RGN_AND); |
1141 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1141 hPen = (HPEN)SelectObject(m_hDC, hPen); |
1142 DeleteObject(hPen); | 1142 DeleteObject(hPen); |
1143 return ret; | 1143 return ret; |
1144 } | 1144 } |
1145 | 1145 |
1146 FX_BOOL CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, | 1146 bool CGdiDeviceDriver::DrawCosmeticLine(FX_FLOAT x1, |
1147 FX_FLOAT y1, | 1147 FX_FLOAT y1, |
1148 FX_FLOAT x2, | 1148 FX_FLOAT x2, |
1149 FX_FLOAT y2, | 1149 FX_FLOAT y2, |
1150 uint32_t color, | 1150 uint32_t color, |
1151 int blend_type) { | 1151 int blend_type) { |
1152 if (blend_type != FXDIB_BLEND_NORMAL) | 1152 if (blend_type != FXDIB_BLEND_NORMAL) |
1153 return FALSE; | 1153 return false; |
1154 | 1154 |
1155 int a; | 1155 int a; |
1156 FX_COLORREF rgb; | 1156 FX_COLORREF rgb; |
1157 ArgbDecode(color, a, rgb); | 1157 ArgbDecode(color, a, rgb); |
1158 if (a == 0) | 1158 if (a == 0) |
1159 return TRUE; | 1159 return true; |
1160 | 1160 |
1161 HPEN hPen = CreatePen(PS_SOLID, 1, rgb); | 1161 HPEN hPen = CreatePen(PS_SOLID, 1, rgb); |
1162 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1162 hPen = (HPEN)SelectObject(m_hDC, hPen); |
1163 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); | 1163 MoveToEx(m_hDC, FXSYS_round(x1), FXSYS_round(y1), nullptr); |
1164 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); | 1164 LineTo(m_hDC, FXSYS_round(x2), FXSYS_round(y2)); |
1165 hPen = (HPEN)SelectObject(m_hDC, hPen); | 1165 hPen = (HPEN)SelectObject(m_hDC, hPen); |
1166 DeleteObject(hPen); | 1166 DeleteObject(hPen); |
1167 return TRUE; | 1167 return true; |
1168 } | 1168 } |
1169 | 1169 |
1170 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) | 1170 CGdiDisplayDriver::CGdiDisplayDriver(HDC hDC) |
1171 : CGdiDeviceDriver(hDC, FXDC_DISPLAY) { | 1171 : CGdiDeviceDriver(hDC, FXDC_DISPLAY) { |
1172 CWin32Platform* pPlatform = | 1172 CWin32Platform* pPlatform = |
1173 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); | 1173 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); |
1174 if (pPlatform->m_GdiplusExt.IsAvailable()) { | 1174 if (pPlatform->m_GdiplusExt.IsAvailable()) { |
1175 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE; | 1175 m_RenderCaps |= FXRC_ALPHA_PATH | FXRC_ALPHA_IMAGE; |
1176 } | 1176 } |
1177 } | 1177 } |
1178 | 1178 |
1179 CGdiDisplayDriver::~CGdiDisplayDriver() {} | 1179 CGdiDisplayDriver::~CGdiDisplayDriver() {} |
1180 | 1180 |
1181 FX_BOOL CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { | 1181 bool CGdiDisplayDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { |
1182 FX_BOOL ret = FALSE; | 1182 bool ret = false; |
1183 int width = pBitmap->GetWidth(); | 1183 int width = pBitmap->GetWidth(); |
1184 int height = pBitmap->GetHeight(); | 1184 int height = pBitmap->GetHeight(); |
1185 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height); | 1185 HBITMAP hbmp = CreateCompatibleBitmap(m_hDC, width, height); |
1186 HDC hDCMemory = CreateCompatibleDC(m_hDC); | 1186 HDC hDCMemory = CreateCompatibleDC(m_hDC); |
1187 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp); | 1187 HBITMAP holdbmp = (HBITMAP)SelectObject(hDCMemory, hbmp); |
1188 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY); | 1188 BitBlt(hDCMemory, 0, 0, width, height, m_hDC, left, top, SRCCOPY); |
1189 SelectObject(hDCMemory, holdbmp); | 1189 SelectObject(hDCMemory, holdbmp); |
1190 BITMAPINFO bmi; | 1190 BITMAPINFO bmi; |
1191 FXSYS_memset(&bmi, 0, sizeof bmi); | 1191 FXSYS_memset(&bmi, 0, sizeof bmi); |
1192 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader; | 1192 bmi.bmiHeader.biSize = sizeof bmi.bmiHeader; |
1193 bmi.bmiHeader.biBitCount = pBitmap->GetBPP(); | 1193 bmi.bmiHeader.biBitCount = pBitmap->GetBPP(); |
1194 bmi.bmiHeader.biHeight = -height; | 1194 bmi.bmiHeader.biHeight = -height; |
1195 bmi.bmiHeader.biPlanes = 1; | 1195 bmi.bmiHeader.biPlanes = 1; |
1196 bmi.bmiHeader.biWidth = width; | 1196 bmi.bmiHeader.biWidth = width; |
1197 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage()) { | 1197 if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage()) { |
1198 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi, | 1198 ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi, |
1199 DIB_RGB_COLORS) == height; | 1199 DIB_RGB_COLORS) == height; |
1200 } else { | 1200 } else { |
1201 CFX_DIBitmap bitmap; | 1201 CFX_DIBitmap bitmap; |
1202 if (bitmap.Create(width, height, FXDIB_Rgb)) { | 1202 if (bitmap.Create(width, height, FXDIB_Rgb)) { |
1203 bmi.bmiHeader.biBitCount = 24; | 1203 bmi.bmiHeader.biBitCount = 24; |
1204 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, | 1204 ::GetDIBits(hDCMemory, hbmp, 0, height, bitmap.GetBuffer(), &bmi, |
1205 DIB_RGB_COLORS); | 1205 DIB_RGB_COLORS); |
1206 ret = pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0); | 1206 ret = pBitmap->TransferBitmap(0, 0, width, height, &bitmap, 0, 0); |
1207 } else { | 1207 } else { |
1208 ret = FALSE; | 1208 ret = false; |
1209 } | 1209 } |
1210 } | 1210 } |
1211 if (pBitmap->HasAlpha() && ret) | 1211 if (pBitmap->HasAlpha() && ret) |
1212 pBitmap->LoadChannel(FXDIB_Alpha, 0xff); | 1212 pBitmap->LoadChannel(FXDIB_Alpha, 0xff); |
1213 | 1213 |
1214 DeleteObject(hbmp); | 1214 DeleteObject(hbmp); |
1215 DeleteObject(hDCMemory); | 1215 DeleteObject(hDCMemory); |
1216 return ret; | 1216 return ret; |
1217 } | 1217 } |
1218 | 1218 |
1219 FX_BOOL CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, | 1219 bool CGdiDisplayDriver::SetDIBits(const CFX_DIBSource* pSource, |
1220 uint32_t color, | 1220 uint32_t color, |
1221 const FX_RECT* pSrcRect, | 1221 const FX_RECT* pSrcRect, |
1222 int left, | 1222 int left, |
1223 int top, | 1223 int top, |
1224 int blend_type) { | 1224 int blend_type) { |
1225 ASSERT(blend_type == FXDIB_BLEND_NORMAL); | 1225 ASSERT(blend_type == FXDIB_BLEND_NORMAL); |
1226 if (pSource->IsAlphaMask()) { | 1226 if (pSource->IsAlphaMask()) { |
1227 int width = pSource->GetWidth(), height = pSource->GetHeight(); | 1227 int width = pSource->GetWidth(), height = pSource->GetHeight(); |
1228 int alpha = FXARGB_A(color); | 1228 int alpha = FXARGB_A(color); |
1229 if (pSource->GetBPP() != 1 || alpha != 255) { | 1229 if (pSource->GetBPP() != 1 || alpha != 255) { |
1230 CFX_DIBitmap background; | 1230 CFX_DIBitmap background; |
1231 if (!background.Create(width, height, FXDIB_Rgb32) || | 1231 if (!background.Create(width, height, FXDIB_Rgb32) || |
1232 !GetDIBits(&background, left, top) || | 1232 !GetDIBits(&background, left, top) || |
1233 !background.CompositeMask(0, 0, width, height, pSource, color, 0, 0, | 1233 !background.CompositeMask(0, 0, width, height, pSource, color, 0, 0, |
1234 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, | 1234 FXDIB_BLEND_NORMAL, nullptr, false, 0, |
1235 nullptr)) { | 1235 nullptr)) { |
1236 return FALSE; | 1236 return false; |
1237 } | 1237 } |
1238 FX_RECT src_rect(0, 0, width, height); | 1238 FX_RECT src_rect(0, 0, width, height); |
1239 return SetDIBits(&background, 0, &src_rect, left, top, | 1239 return SetDIBits(&background, 0, &src_rect, left, top, |
1240 FXDIB_BLEND_NORMAL); | 1240 FXDIB_BLEND_NORMAL); |
1241 } | 1241 } |
1242 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), | 1242 FX_RECT clip_rect(left, top, left + pSrcRect->Width(), |
1243 top + pSrcRect->Height()); | 1243 top + pSrcRect->Height()); |
1244 return StretchDIBits(pSource, color, left - pSrcRect->left, | 1244 return StretchDIBits(pSource, color, left - pSrcRect->left, |
1245 top - pSrcRect->top, width, height, &clip_rect, 0, | 1245 top - pSrcRect->top, width, height, &clip_rect, 0, |
1246 FXDIB_BLEND_NORMAL); | 1246 FXDIB_BLEND_NORMAL); |
1247 } | 1247 } |
1248 int width = pSrcRect->Width(), height = pSrcRect->Height(); | 1248 int width = pSrcRect->Width(), height = pSrcRect->Height(); |
1249 if (pSource->HasAlpha()) { | 1249 if (pSource->HasAlpha()) { |
1250 CFX_DIBitmap bitmap; | 1250 CFX_DIBitmap bitmap; |
1251 if (!bitmap.Create(width, height, FXDIB_Rgb) || | 1251 if (!bitmap.Create(width, height, FXDIB_Rgb) || |
1252 !GetDIBits(&bitmap, left, top) || | 1252 !GetDIBits(&bitmap, left, top) || |
1253 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, | 1253 !bitmap.CompositeBitmap(0, 0, width, height, pSource, pSrcRect->left, |
1254 pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, | 1254 pSrcRect->top, FXDIB_BLEND_NORMAL, nullptr, |
1255 FALSE, nullptr)) { | 1255 false, nullptr)) { |
1256 return FALSE; | 1256 return false; |
1257 } | 1257 } |
1258 FX_RECT src_rect(0, 0, width, height); | 1258 FX_RECT src_rect(0, 0, width, height); |
1259 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); | 1259 return SetDIBits(&bitmap, 0, &src_rect, left, top, FXDIB_BLEND_NORMAL); |
1260 } | 1260 } |
1261 CFX_DIBExtractor temp(pSource); | 1261 CFX_DIBExtractor temp(pSource); |
1262 CFX_DIBitmap* pBitmap = temp.GetBitmap(); | 1262 CFX_DIBitmap* pBitmap = temp.GetBitmap(); |
1263 if (!pBitmap) | 1263 if (!pBitmap) |
1264 return FALSE; | 1264 return false; |
1265 return GDI_SetDIBits(pBitmap, pSrcRect, left, top); | 1265 return GDI_SetDIBits(pBitmap, pSrcRect, left, top); |
1266 } | 1266 } |
1267 | 1267 |
1268 FX_BOOL CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, | 1268 bool CGdiDisplayDriver::UseFoxitStretchEngine(const CFX_DIBSource* pSource, |
1269 uint32_t color, | 1269 uint32_t color, |
1270 int dest_left, | 1270 int dest_left, |
1271 int dest_top, | 1271 int dest_top, |
1272 int dest_width, | 1272 int dest_width, |
1273 int dest_height, | 1273 int dest_height, |
1274 const FX_RECT* pClipRect, | 1274 const FX_RECT* pClipRect, |
1275 int render_flags) { | 1275 int render_flags) { |
1276 FX_RECT bitmap_clip = *pClipRect; | 1276 FX_RECT bitmap_clip = *pClipRect; |
1277 if (dest_width < 0) | 1277 if (dest_width < 0) |
1278 dest_left += dest_width; | 1278 dest_left += dest_width; |
1279 | 1279 |
1280 if (dest_height < 0) | 1280 if (dest_height < 0) |
1281 dest_top += dest_height; | 1281 dest_top += dest_height; |
1282 | 1282 |
1283 bitmap_clip.Offset(-dest_left, -dest_top); | 1283 bitmap_clip.Offset(-dest_left, -dest_top); |
1284 std::unique_ptr<CFX_DIBitmap> pStretched( | 1284 std::unique_ptr<CFX_DIBitmap> pStretched( |
1285 pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip)); | 1285 pSource->StretchTo(dest_width, dest_height, render_flags, &bitmap_clip)); |
1286 if (!pStretched) | 1286 if (!pStretched) |
1287 return TRUE; | 1287 return true; |
1288 | 1288 |
1289 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); | 1289 FX_RECT src_rect(0, 0, pStretched->GetWidth(), pStretched->GetHeight()); |
1290 return SetDIBits(pStretched.get(), color, &src_rect, pClipRect->left, | 1290 return SetDIBits(pStretched.get(), color, &src_rect, pClipRect->left, |
1291 pClipRect->top, FXDIB_BLEND_NORMAL); | 1291 pClipRect->top, FXDIB_BLEND_NORMAL); |
1292 } | 1292 } |
1293 | 1293 |
1294 FX_BOOL CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, | 1294 bool CGdiDisplayDriver::StretchDIBits(const CFX_DIBSource* pSource, |
1295 uint32_t color, | 1295 uint32_t color, |
1296 int dest_left, | 1296 int dest_left, |
1297 int dest_top, | 1297 int dest_top, |
1298 int dest_width, | 1298 int dest_width, |
1299 int dest_height, | 1299 int dest_height, |
1300 const FX_RECT* pClipRect, | 1300 const FX_RECT* pClipRect, |
1301 uint32_t flags, | 1301 uint32_t flags, |
1302 int blend_type) { | 1302 int blend_type) { |
1303 ASSERT(pSource && pClipRect); | 1303 ASSERT(pSource && pClipRect); |
1304 if (flags || dest_width > 10000 || dest_width < -10000 || | 1304 if (flags || dest_width > 10000 || dest_width < -10000 || |
1305 dest_height > 10000 || dest_height < -10000) { | 1305 dest_height > 10000 || dest_height < -10000) { |
1306 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, | 1306 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, |
1307 dest_width, dest_height, pClipRect, flags); | 1307 dest_width, dest_height, pClipRect, flags); |
1308 } | 1308 } |
1309 if (pSource->IsAlphaMask()) { | 1309 if (pSource->IsAlphaMask()) { |
1310 FX_RECT image_rect; | 1310 FX_RECT image_rect; |
1311 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; | 1311 image_rect.left = dest_width > 0 ? dest_left : dest_left + dest_width; |
1312 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left; | 1312 image_rect.right = dest_width > 0 ? dest_left + dest_width : dest_left; |
1313 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height; | 1313 image_rect.top = dest_height > 0 ? dest_top : dest_top + dest_height; |
1314 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top; | 1314 image_rect.bottom = dest_height > 0 ? dest_top + dest_height : dest_top; |
1315 FX_RECT clip_rect = image_rect; | 1315 FX_RECT clip_rect = image_rect; |
1316 clip_rect.Intersect(*pClipRect); | 1316 clip_rect.Intersect(*pClipRect); |
1317 clip_rect.Offset(-image_rect.left, -image_rect.top); | 1317 clip_rect.Offset(-image_rect.left, -image_rect.top); |
1318 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); | 1318 int clip_width = clip_rect.Width(), clip_height = clip_rect.Height(); |
1319 std::unique_ptr<CFX_DIBitmap> pStretched( | 1319 std::unique_ptr<CFX_DIBitmap> pStretched( |
1320 pSource->StretchTo(dest_width, dest_height, flags, &clip_rect)); | 1320 pSource->StretchTo(dest_width, dest_height, flags, &clip_rect)); |
1321 if (!pStretched) | 1321 if (!pStretched) |
1322 return TRUE; | 1322 return true; |
1323 | 1323 |
1324 CFX_DIBitmap background; | 1324 CFX_DIBitmap background; |
1325 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || | 1325 if (!background.Create(clip_width, clip_height, FXDIB_Rgb32) || |
1326 !GetDIBits(&background, image_rect.left + clip_rect.left, | 1326 !GetDIBits(&background, image_rect.left + clip_rect.left, |
1327 image_rect.top + clip_rect.top) || | 1327 image_rect.top + clip_rect.top) || |
1328 !background.CompositeMask( | 1328 !background.CompositeMask( |
1329 0, 0, clip_width, clip_height, pStretched.get(), color, 0, 0, | 1329 0, 0, clip_width, clip_height, pStretched.get(), color, 0, 0, |
1330 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, nullptr)) { | 1330 FXDIB_BLEND_NORMAL, nullptr, false, 0, nullptr)) { |
1331 return FALSE; | 1331 return false; |
1332 } | 1332 } |
1333 | 1333 |
1334 FX_RECT src_rect(0, 0, clip_width, clip_height); | 1334 FX_RECT src_rect(0, 0, clip_width, clip_height); |
1335 return SetDIBits(&background, 0, &src_rect, | 1335 return SetDIBits(&background, 0, &src_rect, |
1336 image_rect.left + clip_rect.left, | 1336 image_rect.left + clip_rect.left, |
1337 image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL); | 1337 image_rect.top + clip_rect.top, FXDIB_BLEND_NORMAL); |
1338 } | 1338 } |
1339 if (pSource->HasAlpha()) { | 1339 if (pSource->HasAlpha()) { |
1340 CWin32Platform* pPlatform = | 1340 CWin32Platform* pPlatform = |
1341 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); | 1341 (CWin32Platform*)CFX_GEModule::Get()->GetPlatformData(); |
1342 if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) { | 1342 if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) { |
1343 CFX_DIBExtractor temp(pSource); | 1343 CFX_DIBExtractor temp(pSource); |
1344 CFX_DIBitmap* pBitmap = temp.GetBitmap(); | 1344 CFX_DIBitmap* pBitmap = temp.GetBitmap(); |
1345 if (!pBitmap) | 1345 if (!pBitmap) |
1346 return FALSE; | 1346 return false; |
1347 return pPlatform->m_GdiplusExt.StretchDIBits( | 1347 return pPlatform->m_GdiplusExt.StretchDIBits( |
1348 m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, | 1348 m_hDC, pBitmap, dest_left, dest_top, dest_width, dest_height, |
1349 pClipRect, flags); | 1349 pClipRect, flags); |
1350 } | 1350 } |
1351 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, | 1351 return UseFoxitStretchEngine(pSource, color, dest_left, dest_top, |
1352 dest_width, dest_height, pClipRect, flags); | 1352 dest_width, dest_height, pClipRect, flags); |
1353 } | 1353 } |
1354 CFX_DIBExtractor temp(pSource); | 1354 CFX_DIBExtractor temp(pSource); |
1355 CFX_DIBitmap* pBitmap = temp.GetBitmap(); | 1355 CFX_DIBitmap* pBitmap = temp.GetBitmap(); |
1356 if (!pBitmap) | 1356 if (!pBitmap) |
1357 return FALSE; | 1357 return false; |
1358 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, | 1358 return GDI_StretchDIBits(pBitmap, dest_left, dest_top, dest_width, |
1359 dest_height, flags); | 1359 dest_height, flags); |
1360 } | 1360 } |
1361 | 1361 |
1362 FX_BOOL CGdiDisplayDriver::StartDIBits(const CFX_DIBSource* pBitmap, | 1362 bool CGdiDisplayDriver::StartDIBits(const CFX_DIBSource* pBitmap, |
1363 int bitmap_alpha, | 1363 int bitmap_alpha, |
1364 uint32_t color, | 1364 uint32_t color, |
1365 const CFX_Matrix* pMatrix, | 1365 const CFX_Matrix* pMatrix, |
1366 uint32_t render_flags, | 1366 uint32_t render_flags, |
1367 void*& handle, | 1367 void*& handle, |
1368 int blend_type) { | 1368 int blend_type) { |
1369 return FALSE; | 1369 return false; |
1370 } | 1370 } |
1371 | 1371 |
1372 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) { | 1372 CFX_WindowsDevice::CFX_WindowsDevice(HDC hDC) { |
1373 SetDeviceDriver(pdfium::WrapUnique(CreateDriver(hDC))); | 1373 SetDeviceDriver(pdfium::WrapUnique(CreateDriver(hDC))); |
1374 } | 1374 } |
1375 | 1375 |
1376 CFX_WindowsDevice::~CFX_WindowsDevice() {} | 1376 CFX_WindowsDevice::~CFX_WindowsDevice() {} |
1377 | 1377 |
1378 HDC CFX_WindowsDevice::GetDC() const { | 1378 HDC CFX_WindowsDevice::GetDC() const { |
1379 IFX_RenderDeviceDriver* pRDD = GetDeviceDriver(); | 1379 IFX_RenderDeviceDriver* pRDD = GetDeviceDriver(); |
1380 return pRDD ? reinterpret_cast<HDC>(pRDD->GetPlatformSurface()) : nullptr; | 1380 return pRDD ? reinterpret_cast<HDC>(pRDD->GetPlatformSurface()) : nullptr; |
1381 } | 1381 } |
1382 | 1382 |
1383 // static | 1383 // static |
1384 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC) { | 1384 IFX_RenderDeviceDriver* CFX_WindowsDevice::CreateDriver(HDC hDC) { |
1385 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); | 1385 int device_type = ::GetDeviceCaps(hDC, TECHNOLOGY); |
1386 int obj_type = ::GetObjectType(hDC); | 1386 int obj_type = ::GetObjectType(hDC); |
1387 bool use_printer = device_type == DT_RASPRINTER || | 1387 bool use_printer = device_type == DT_RASPRINTER || |
1388 device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC; | 1388 device_type == DT_PLOTTER || obj_type == OBJ_ENHMETADC; |
1389 if (use_printer) | 1389 if (use_printer) |
1390 return new CGdiPrinterDriver(hDC); | 1390 return new CGdiPrinterDriver(hDC); |
1391 return new CGdiDisplayDriver(hDC); | 1391 return new CGdiDisplayDriver(hDC); |
1392 } | 1392 } |
OLD | NEW |