| 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 <limits> | 7 #include <limits> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "core/fxcodec/include/fx_codec.h" | 10 #include "core/fxcodec/include/fx_codec.h" |
| 11 #include "core/fxcrt/include/fx_safe_types.h" |
| 11 #include "core/fxge/ge/fx_text_int.h" | 12 #include "core/fxge/ge/fx_text_int.h" |
| 12 #include "core/fxge/include/cfx_fontmgr.h" | 13 #include "core/fxge/include/cfx_fontmgr.h" |
| 13 #include "core/fxge/include/cfx_gemodule.h" | 14 #include "core/fxge/include/cfx_gemodule.h" |
| 14 #include "core/fxge/include/cfx_pathdata.h" | 15 #include "core/fxge/include/cfx_pathdata.h" |
| 15 #include "core/fxge/include/fx_freetype.h" | 16 #include "core/fxge/include/fx_freetype.h" |
| 16 #include "core/fxge/include/ifx_renderdevicedriver.h" | 17 #include "core/fxge/include/ifx_renderdevicedriver.h" |
| 17 | 18 |
| 18 #ifdef _SKIA_SUPPORT_ | 19 #ifdef _SKIA_SUPPORT_ |
| 19 #include "third_party/skia/include/core/SkStream.h" | 20 #include "third_party/skia/include/core/SkStream.h" |
| 20 #include "third_party/skia/include/core/SkTypeface.h" | 21 #include "third_party/skia/include/core/SkTypeface.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 51 int anti_alias, | 52 int anti_alias, |
| 52 FX_FLOAT retinaScaleX, | 53 FX_FLOAT retinaScaleX, |
| 53 FX_FLOAT retinaScaleY) { | 54 FX_FLOAT retinaScaleY) { |
| 54 FX_RECT rect(0, 0, 0, 0); | 55 FX_RECT rect(0, 0, 0, 0); |
| 55 bool bStarted = false; | 56 bool bStarted = false; |
| 56 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { | 57 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { |
| 57 const CFX_GlyphBitmap* pGlyph = glyph.m_pGlyph; | 58 const CFX_GlyphBitmap* pGlyph = glyph.m_pGlyph; |
| 58 if (!pGlyph) | 59 if (!pGlyph) |
| 59 continue; | 60 continue; |
| 60 | 61 |
| 61 int char_left = glyph.m_OriginX + pGlyph->m_Left; | 62 FX_SAFE_INT32 char_left = glyph.m_OriginX; |
| 62 int char_width = (int)(pGlyph->m_Bitmap.GetWidth() / retinaScaleX); | 63 char_left += pGlyph->m_Left; |
| 63 if (anti_alias == FXFT_RENDER_MODE_LCD) { | 64 if (!char_left.IsValid()) |
| 65 continue; |
| 66 |
| 67 FX_SAFE_INT32 char_width = pGlyph->m_Bitmap.GetWidth(); |
| 68 char_width /= retinaScaleX; |
| 69 if (anti_alias == FXFT_RENDER_MODE_LCD) |
| 64 char_width /= 3; | 70 char_width /= 3; |
| 71 if (!char_width.IsValid()) |
| 72 continue; |
| 73 |
| 74 FX_SAFE_INT32 char_right = char_left + char_width; |
| 75 if (!char_right.IsValid()) |
| 76 continue; |
| 77 |
| 78 FX_SAFE_INT32 char_top = glyph.m_OriginY; |
| 79 char_top -= pGlyph->m_Top; |
| 80 if (!char_top.IsValid()) |
| 81 continue; |
| 82 |
| 83 FX_SAFE_INT32 char_height = pGlyph->m_Bitmap.GetHeight(); |
| 84 char_height /= retinaScaleY; |
| 85 if (!char_height.IsValid()) |
| 86 continue; |
| 87 |
| 88 FX_SAFE_INT32 char_bottom = char_top + char_height; |
| 89 if (!char_bottom.IsValid()) |
| 90 continue; |
| 91 |
| 92 if (bStarted) { |
| 93 rect.left = std::min(rect.left, char_left.ValueOrDie()); |
| 94 rect.right = std::max(rect.right, char_right.ValueOrDie()); |
| 95 rect.top = std::min(rect.top, char_top.ValueOrDie()); |
| 96 rect.bottom = std::max(rect.bottom, char_bottom.ValueOrDie()); |
| 97 continue; |
| 65 } | 98 } |
| 66 int char_right = char_left + char_width; | 99 |
| 67 int char_top = glyph.m_OriginY - pGlyph->m_Top; | 100 rect.left = char_left.ValueOrDie(); |
| 68 int char_bottom = | 101 rect.right = char_right.ValueOrDie(); |
| 69 char_top + (int)(pGlyph->m_Bitmap.GetHeight() / retinaScaleY); | 102 rect.top = char_top.ValueOrDie(); |
| 70 if (!bStarted) { | 103 rect.bottom = char_bottom.ValueOrDie(); |
| 71 rect.left = char_left; | 104 bStarted = true; |
| 72 rect.right = char_right; | |
| 73 rect.top = char_top; | |
| 74 rect.bottom = char_bottom; | |
| 75 bStarted = true; | |
| 76 } else { | |
| 77 rect.left = std::min(rect.left, char_left); | |
| 78 rect.right = std::max(rect.right, char_right); | |
| 79 rect.top = std::min(rect.top, char_top); | |
| 80 rect.bottom = std::max(rect.bottom, char_bottom); | |
| 81 } | |
| 82 } | 105 } |
| 83 return rect; | 106 return rect; |
| 84 } | 107 } |
| 85 | 108 |
| 86 CFX_FontCache::CFX_FontCache() {} | 109 CFX_FontCache::CFX_FontCache() {} |
| 87 | 110 |
| 88 CFX_FontCache::~CFX_FontCache() { | 111 CFX_FontCache::~CFX_FontCache() { |
| 89 FreeCache(TRUE); | 112 FreeCache(TRUE); |
| 90 } | 113 } |
| 91 | 114 |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 817 void _CFX_UniqueKeyGen::Generate(int count, ...) { | 840 void _CFX_UniqueKeyGen::Generate(int count, ...) { |
| 818 va_list argList; | 841 va_list argList; |
| 819 va_start(argList, count); | 842 va_start(argList, count); |
| 820 for (int i = 0; i < count; i++) { | 843 for (int i = 0; i < count; i++) { |
| 821 int p = va_arg(argList, int); | 844 int p = va_arg(argList, int); |
| 822 ((uint32_t*)m_Key)[i] = p; | 845 ((uint32_t*)m_Key)[i] = p; |
| 823 } | 846 } |
| 824 va_end(argList); | 847 va_end(argList); |
| 825 m_KeyLen = count * sizeof(uint32_t); | 848 m_KeyLen = count * sizeof(uint32_t); |
| 826 } | 849 } |
| OLD | NEW |