| 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/fxge/include/cfx_fxgedevice.h" | 10 #include "core/fxge/include/cfx_fxgedevice.h" |
| 10 #include "core/fxge/include/cfx_graphstatedata.h" | 11 #include "core/fxge/include/cfx_graphstatedata.h" |
| 11 #include "core/fxge/include/cfx_pathdata.h" | 12 #include "core/fxge/include/cfx_pathdata.h" |
| 12 #include "core/fxge/include/ifx_renderdevicedriver.h" | 13 #include "core/fxge/include/ifx_renderdevicedriver.h" |
| 13 | 14 |
| 14 #if defined _SKIA_SUPPORT_ | 15 #if defined _SKIA_SUPPORT_ |
| 15 #include "third_party/skia/include/core/SkTypes.h" | 16 #include "third_party/skia/include/core/SkTypes.h" |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 981 if (bitmap.m_pAlphaMask) | 982 if (bitmap.m_pAlphaMask) |
| 982 bitmap.m_pAlphaMask->Clear(0); | 983 bitmap.m_pAlphaMask->Clear(0); |
| 983 } | 984 } |
| 984 int dest_width = pixel_width; | 985 int dest_width = pixel_width; |
| 985 int a = 0; | 986 int a = 0; |
| 986 int r = 0; | 987 int r = 0; |
| 987 int g = 0; | 988 int g = 0; |
| 988 int b = 0; | 989 int b = 0; |
| 989 if (anti_alias == FXFT_RENDER_MODE_LCD) | 990 if (anti_alias == FXFT_RENDER_MODE_LCD) |
| 990 ArgbDecode(fill_color, a, r, g, b); | 991 ArgbDecode(fill_color, a, r, g, b); |
| 992 |
| 991 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { | 993 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { |
| 992 if (!glyph.m_pGlyph) | 994 if (!glyph.m_pGlyph) |
| 993 continue; | 995 continue; |
| 996 |
| 997 pdfium::base::CheckedNumeric<int> left = glyph.m_OriginX; |
| 998 left += glyph.m_pGlyph->m_Left; |
| 999 left -= pixel_left; |
| 1000 if (!left.IsValid()) |
| 1001 return FALSE; |
| 1002 |
| 1003 pdfium::base::CheckedNumeric<int> top = glyph.m_OriginY; |
| 1004 top -= glyph.m_pGlyph->m_Top; |
| 1005 top -= pixel_top; |
| 1006 if (!top.IsValid()) |
| 1007 return FALSE; |
| 1008 |
| 994 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; | 1009 const CFX_DIBitmap* pGlyph = &glyph.m_pGlyph->m_Bitmap; |
| 995 int left = glyph.m_OriginX + glyph.m_pGlyph->m_Left - pixel_left; | |
| 996 int top = glyph.m_OriginY - glyph.m_pGlyph->m_Top - pixel_top; | |
| 997 int ncols = pGlyph->GetWidth(); | 1010 int ncols = pGlyph->GetWidth(); |
| 998 int nrows = pGlyph->GetHeight(); | 1011 int nrows = pGlyph->GetHeight(); |
| 999 if (anti_alias == FXFT_RENDER_MODE_NORMAL) { | 1012 if (anti_alias == FXFT_RENDER_MODE_NORMAL) { |
| 1000 if (!bitmap.CompositeMask(left, top, ncols, nrows, pGlyph, fill_color, 0, | 1013 if (!bitmap.CompositeMask(left.ValueOrDie(), top.ValueOrDie(), ncols, |
| 1001 0, FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, | 1014 nrows, pGlyph, fill_color, 0, 0, |
| 1015 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, |
| 1002 nullptr)) { | 1016 nullptr)) { |
| 1003 return FALSE; | 1017 return FALSE; |
| 1004 } | 1018 } |
| 1005 continue; | 1019 continue; |
| 1006 } | 1020 } |
| 1007 bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE); | 1021 bool bBGRStripe = !!(text_flags & FXTEXT_BGR_STRIPE); |
| 1008 ncols /= 3; | 1022 ncols /= 3; |
| 1009 int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; | 1023 int x_subpixel = (int)(glyph.m_fOriginX * 3) % 3; |
| 1010 int start_col = std::max(left, 0); | 1024 int start_col = std::max(left.ValueOrDie(), 0); |
| 1011 int end_col = std::min(left + ncols, dest_width); | 1025 pdfium::base::CheckedNumeric<int> end_col_safe = left; |
| 1026 end_col_safe += ncols; |
| 1027 if (!end_col_safe.IsValid()) |
| 1028 return FALSE; |
| 1029 |
| 1030 int end_col = std::min(end_col_safe.ValueOrDie(), dest_width); |
| 1012 if (start_col >= end_col) | 1031 if (start_col >= end_col) |
| 1013 continue; | 1032 continue; |
| 1014 DrawNormalTextHelper(&bitmap, pGlyph, nrows, left, top, start_col, end_col, | 1033 |
| 1015 bNormal, bBGRStripe, x_subpixel, a, r, g, b); | 1034 DrawNormalTextHelper(&bitmap, pGlyph, nrows, left.ValueOrDie(), |
| 1035 top.ValueOrDie(), start_col, end_col, bNormal, |
| 1036 bBGRStripe, x_subpixel, a, r, g, b); |
| 1016 } | 1037 } |
| 1017 if (bitmap.IsAlphaMask()) | 1038 if (bitmap.IsAlphaMask()) |
| 1018 SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); | 1039 SetBitMask(&bitmap, bmp_rect.left, bmp_rect.top, fill_color); |
| 1019 else | 1040 else |
| 1020 SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); | 1041 SetDIBits(&bitmap, bmp_rect.left, bmp_rect.top); |
| 1021 return TRUE; | 1042 return TRUE; |
| 1022 } | 1043 } |
| 1023 | 1044 |
| 1024 FX_BOOL CFX_RenderDevice::DrawTextPathWithFlags( | 1045 FX_BOOL CFX_RenderDevice::DrawTextPathWithFlags( |
| 1025 int nChars, | 1046 int nChars, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 fill_color, stroke_color, fill_mode, | 1084 fill_color, stroke_color, fill_mode, |
| 1064 FXDIB_BLEND_NORMAL)) { | 1085 FXDIB_BLEND_NORMAL)) { |
| 1065 return FALSE; | 1086 return FALSE; |
| 1066 } | 1087 } |
| 1067 } | 1088 } |
| 1068 if (pClippingPath) | 1089 if (pClippingPath) |
| 1069 pClippingPath->Append(&TransformedPath, pUser2Device); | 1090 pClippingPath->Append(&TransformedPath, pUser2Device); |
| 1070 } | 1091 } |
| 1071 return TRUE; | 1092 return TRUE; |
| 1072 } | 1093 } |
| OLD | NEW |