OLD | NEW |
1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/fxge/include/cfx_renderdevice.h" | 7 #include "core/fxge/include/cfx_renderdevice.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_safe_types.h" | 9 #include "core/fxcrt/include/fx_safe_types.h" |
10 #include "core/fxge/include/cfx_autofontcache.h" | 10 #include "core/fxge/include/cfx_autofontcache.h" |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 m_RenderCaps = m_pDeviceDriver->GetDeviceCaps(FXDC_RENDER_CAPS); | 372 m_RenderCaps = m_pDeviceDriver->GetDeviceCaps(FXDC_RENDER_CAPS); |
373 m_DeviceClass = m_pDeviceDriver->GetDeviceCaps(FXDC_DEVICE_CLASS); | 373 m_DeviceClass = m_pDeviceDriver->GetDeviceCaps(FXDC_DEVICE_CLASS); |
374 if (!m_pDeviceDriver->GetClipBox(&m_ClipBox)) { | 374 if (!m_pDeviceDriver->GetClipBox(&m_ClipBox)) { |
375 m_ClipBox.left = 0; | 375 m_ClipBox.left = 0; |
376 m_ClipBox.top = 0; | 376 m_ClipBox.top = 0; |
377 m_ClipBox.right = m_Width; | 377 m_ClipBox.right = m_Width; |
378 m_ClipBox.bottom = m_Height; | 378 m_ClipBox.bottom = m_Height; |
379 } | 379 } |
380 } | 380 } |
381 | 381 |
382 FX_BOOL CFX_RenderDevice::StartRendering() { | |
383 return m_pDeviceDriver->StartRendering(); | |
384 } | |
385 | |
386 void CFX_RenderDevice::EndRendering() { | |
387 m_pDeviceDriver->EndRendering(); | |
388 } | |
389 | |
390 void CFX_RenderDevice::SaveState() { | 382 void CFX_RenderDevice::SaveState() { |
391 m_pDeviceDriver->SaveState(); | 383 m_pDeviceDriver->SaveState(); |
392 } | 384 } |
393 | 385 |
394 void CFX_RenderDevice::RestoreState(bool bKeepSaved) { | 386 void CFX_RenderDevice::RestoreState(bool bKeepSaved) { |
395 m_pDeviceDriver->RestoreState(bKeepSaved); | 387 m_pDeviceDriver->RestoreState(bKeepSaved); |
396 UpdateClipBox(); | 388 UpdateClipBox(); |
397 } | 389 } |
398 | 390 |
399 int CFX_RenderDevice::GetDeviceCaps(int caps_id) const { | 391 int CFX_RenderDevice::GetDeviceCaps(int caps_id) const { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 pObject2Device->Transform(pPoints[0].m_PointX, pPoints[0].m_PointY, x1, | 474 pObject2Device->Transform(pPoints[0].m_PointX, pPoints[0].m_PointY, x1, |
483 y1); | 475 y1); |
484 pObject2Device->Transform(pPoints[1].m_PointX, pPoints[1].m_PointY, x2, | 476 pObject2Device->Transform(pPoints[1].m_PointX, pPoints[1].m_PointY, x2, |
485 y2); | 477 y2); |
486 } else { | 478 } else { |
487 x1 = pPoints[0].m_PointX; | 479 x1 = pPoints[0].m_PointX; |
488 y1 = pPoints[0].m_PointY; | 480 y1 = pPoints[0].m_PointY; |
489 x2 = pPoints[1].m_PointX; | 481 x2 = pPoints[1].m_PointX; |
490 y2 = pPoints[1].m_PointY; | 482 y2 = pPoints[1].m_PointY; |
491 } | 483 } |
492 DrawCosmeticLineWithFillModeAndBlend(x1, y1, x2, y2, fill_color, fill_mode, | 484 DrawCosmeticLine(x1, y1, x2, y2, fill_color, fill_mode, blend_type); |
493 blend_type); | |
494 return TRUE; | 485 return TRUE; |
495 } | 486 } |
496 if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && | 487 if ((pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) && |
497 stroke_alpha == 0) { | 488 stroke_alpha == 0) { |
498 CFX_FloatRect rect_f; | 489 CFX_FloatRect rect_f; |
499 if (!(fill_mode & FXFILL_RECT_AA) && | 490 if (!(fill_mode & FXFILL_RECT_AA) && |
500 pPathData->IsRect(pObject2Device, &rect_f)) { | 491 pPathData->IsRect(pObject2Device, &rect_f)) { |
501 FX_RECT rect_i = rect_f.GetOuterRect(); | 492 FX_RECT rect_i = rect_f.GetOuterRect(); |
502 | 493 |
503 // Depending on the top/bottom, left/right values of the rect it's | 494 // Depending on the top/bottom, left/right values of the rect it's |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
656 if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, | 647 if (!bitmap.CompositeRect(0, 0, pRect->Width(), pRect->Height(), fill_color, |
657 0, nullptr)) { | 648 0, nullptr)) { |
658 return FALSE; | 649 return FALSE; |
659 } | 650 } |
660 FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); | 651 FX_RECT src_rect(0, 0, pRect->Width(), pRect->Height()); |
661 m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, | 652 m_pDeviceDriver->SetDIBits(&bitmap, 0, &src_rect, pRect->left, pRect->top, |
662 FXDIB_BLEND_NORMAL); | 653 FXDIB_BLEND_NORMAL); |
663 return TRUE; | 654 return TRUE; |
664 } | 655 } |
665 | 656 |
666 FX_BOOL CFX_RenderDevice::DrawCosmeticLineWithFillModeAndBlend(FX_FLOAT x1, | 657 FX_BOOL CFX_RenderDevice::DrawCosmeticLine(FX_FLOAT x1, |
667 FX_FLOAT y1, | 658 FX_FLOAT y1, |
668 FX_FLOAT x2, | 659 FX_FLOAT x2, |
669 FX_FLOAT y2, | 660 FX_FLOAT y2, |
670 uint32_t color, | 661 uint32_t color, |
671 int fill_mode, | 662 int fill_mode, |
672 int blend_type) { | 663 int blend_type) { |
673 if ((color >= 0xff000000) && | 664 if ((color >= 0xff000000) && |
674 m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, blend_type)) { | 665 m_pDeviceDriver->DrawCosmeticLine(x1, y1, x2, y2, color, blend_type)) { |
675 return TRUE; | 666 return TRUE; |
676 } | 667 } |
677 CFX_GraphStateData graph_state; | 668 CFX_GraphStateData graph_state; |
678 CFX_PathData path; | 669 CFX_PathData path; |
679 path.SetPointCount(2); | 670 path.SetPointCount(2); |
680 path.SetPoint(0, x1, y1, FXPT_MOVETO); | 671 path.SetPoint(0, x1, y1, FXPT_MOVETO); |
681 path.SetPoint(1, x2, y2, FXPT_LINETO); | 672 path.SetPoint(1, x2, y2, FXPT_LINETO); |
682 return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color, | 673 return m_pDeviceDriver->DrawPath(&path, nullptr, &graph_state, 0, color, |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 text2Device = *pText2Device; | 855 text2Device = *pText2Device; |
865 } | 856 } |
866 char2device.Scale(font_size, -font_size); | 857 char2device.Scale(font_size, -font_size); |
867 if (FXSYS_fabs(char2device.a) + FXSYS_fabs(char2device.b) > 50 * 1.0f || | 858 if (FXSYS_fabs(char2device.a) + FXSYS_fabs(char2device.b) > 50 * 1.0f || |
868 ((m_DeviceClass == FXDC_PRINTER) && | 859 ((m_DeviceClass == FXDC_PRINTER) && |
869 !(text_flags & FXTEXT_PRINTIMAGETEXT))) { | 860 !(text_flags & FXTEXT_PRINTIMAGETEXT))) { |
870 if (pFont->GetFace() || | 861 if (pFont->GetFace() || |
871 (pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) { | 862 (pFont->GetSubstFont()->m_SubstFlags & FXFONT_SUBST_GLYPHPATH)) { |
872 int nPathFlags = | 863 int nPathFlags = |
873 (text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NOPATHSMOOTH; | 864 (text_flags & FXTEXT_NOSMOOTH) == 0 ? 0 : FXFILL_NOPATHSMOOTH; |
874 return DrawTextPathWithFlags(nChars, pCharPos, pFont, pCache, font_size, | 865 return DrawTextPath(nChars, pCharPos, pFont, pCache, font_size, |
875 pText2Device, nullptr, nullptr, fill_color, | 866 pText2Device, nullptr, nullptr, fill_color, 0, |
876 0, nullptr, nPathFlags); | 867 nullptr, nPathFlags); |
877 } | 868 } |
878 } | 869 } |
879 int anti_alias = FXFT_RENDER_MODE_MONO; | 870 int anti_alias = FXFT_RENDER_MODE_MONO; |
880 bool bNormal = false; | 871 bool bNormal = false; |
881 if ((text_flags & FXTEXT_NOSMOOTH) == 0) { | 872 if ((text_flags & FXTEXT_NOSMOOTH) == 0) { |
882 if (m_DeviceClass == FXDC_DISPLAY && m_bpp > 1) { | 873 if (m_DeviceClass == FXDC_DISPLAY && m_bpp > 1) { |
883 if (!CFX_GEModule::Get()->GetFontMgr()->FTLibrarySupportsHinting()) { | 874 if (!CFX_GEModule::Get()->GetFontMgr()->FTLibrarySupportsHinting()) { |
884 // Some Freetype implementations (like the one packaged with Fedora) do | 875 // Some Freetype implementations (like the one packaged with Fedora) do |
885 // not support hinting due to patents 6219025, 6239783, 6307566, | 876 // not support hinting due to patents 6219025, 6239783, 6307566, |
886 // 6225973, 6243070, 6393145, 6421054, 6282327, and 6624828; the latest | 877 // 6225973, 6243070, 6393145, 6421054, 6282327, and 6624828; the latest |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1047 top.ValueOrDie(), start_col, end_col, bNormal, | 1038 top.ValueOrDie(), start_col, end_col, bNormal, |
1048 bBGRStripe, x_subpixel, a, r, g, b); | 1039 bBGRStripe, x_subpixel, a, r, g, b); |
1049 } | 1040 } |
1050 if (bitmap.IsAlphaMask()) | 1041 if (bitmap.IsAlphaMask()) |
1051 SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); | 1042 SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); |
1052 else | 1043 else |
1053 SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); | 1044 SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); |
1054 return TRUE; | 1045 return TRUE; |
1055 } | 1046 } |
1056 | 1047 |
1057 FX_BOOL CFX_RenderDevice::DrawTextPathWithFlags( | 1048 FX_BOOL CFX_RenderDevice::DrawTextPath(int nChars, |
1058 int nChars, | 1049 const FXTEXT_CHARPOS* pCharPos, |
1059 const FXTEXT_CHARPOS* pCharPos, | 1050 CFX_Font* pFont, |
1060 CFX_Font* pFont, | 1051 CFX_FontCache* pCache, |
1061 CFX_FontCache* pCache, | 1052 FX_FLOAT font_size, |
1062 FX_FLOAT font_size, | 1053 const CFX_Matrix* pText2User, |
1063 const CFX_Matrix* pText2User, | 1054 const CFX_Matrix* pUser2Device, |
1064 const CFX_Matrix* pUser2Device, | 1055 const CFX_GraphStateData* pGraphState, |
1065 const CFX_GraphStateData* pGraphState, | 1056 uint32_t fill_color, |
1066 uint32_t fill_color, | 1057 FX_ARGB stroke_color, |
1067 FX_ARGB stroke_color, | 1058 CFX_PathData* pClippingPath, |
1068 CFX_PathData* pClippingPath, | 1059 int nFlag) { |
1069 int nFlag) { | |
1070 if (!pCache) | 1060 if (!pCache) |
1071 pCache = CFX_GEModule::Get()->GetFontCache(); | 1061 pCache = CFX_GEModule::Get()->GetFontCache(); |
1072 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); | 1062 CFX_FaceCache* pFaceCache = pCache->GetCachedFace(pFont); |
1073 CFX_AutoFontCache autoFontCache(pCache, pFont); | 1063 CFX_AutoFontCache autoFontCache(pCache, pFont); |
1074 for (int iChar = 0; iChar < nChars; iChar++) { | 1064 for (int iChar = 0; iChar < nChars; iChar++) { |
1075 const FXTEXT_CHARPOS& charpos = pCharPos[iChar]; | 1065 const FXTEXT_CHARPOS& charpos = pCharPos[iChar]; |
1076 CFX_Matrix matrix; | 1066 CFX_Matrix matrix; |
1077 if (charpos.m_bGlyphAdjust) { | 1067 if (charpos.m_bGlyphAdjust) { |
1078 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], | 1068 matrix.Set(charpos.m_AdjustMatrix[0], charpos.m_AdjustMatrix[1], |
1079 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); | 1069 charpos.m_AdjustMatrix[2], charpos.m_AdjustMatrix[3], 0, 0); |
(...skipping 16 matching lines...) Expand all Loading... |
1096 fill_color, stroke_color, fill_mode, | 1086 fill_color, stroke_color, fill_mode, |
1097 FXDIB_BLEND_NORMAL)) { | 1087 FXDIB_BLEND_NORMAL)) { |
1098 return FALSE; | 1088 return FALSE; |
1099 } | 1089 } |
1100 } | 1090 } |
1101 if (pClippingPath) | 1091 if (pClippingPath) |
1102 pClippingPath->Append(&TransformedPath, pUser2Device); | 1092 pClippingPath->Append(&TransformedPath, pUser2Device); |
1103 } | 1093 } |
1104 return TRUE; | 1094 return TRUE; |
1105 } | 1095 } |
OLD | NEW |