Chromium Code Reviews| 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 "core/fpdfapi/render/render_int.h" | 7 #include "core/fpdfapi/render/render_int.h" |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.top); | 268 m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.top); |
| 269 } | 269 } |
| 270 delete pStates; | 270 delete pStates; |
| 271 } else if (pType3Char->m_pBitmap) { | 271 } else if (pType3Char->m_pBitmap) { |
| 272 if (device_class == FXDC_DISPLAY) { | 272 if (device_class == FXDC_DISPLAY) { |
| 273 CPDF_Type3Cache* pCache = GetCachedType3(pType3Font); | 273 CPDF_Type3Cache* pCache = GetCachedType3(pType3Font); |
| 274 refTypeCache.m_dwCount++; | 274 refTypeCache.m_dwCount++; |
| 275 CFX_GlyphBitmap* pBitmap = pCache->LoadGlyph(charcode, &matrix, sa, sd); | 275 CFX_GlyphBitmap* pBitmap = pCache->LoadGlyph(charcode, &matrix, sa, sd); |
| 276 if (!pBitmap) | 276 if (!pBitmap) |
| 277 continue; | 277 continue; |
| 278 | |
| 279 int origin_x = FXSYS_round(matrix.e); | 278 int origin_x = FXSYS_round(matrix.e); |
| 280 int origin_y = FXSYS_round(matrix.f); | 279 int origin_y = FXSYS_round(matrix.f); |
| 281 if (glyphs.empty()) { | 280 if (glyphs.empty()) { |
| 282 m_pDevice->SetBitMask(&pBitmap->m_Bitmap, origin_x + pBitmap->m_Left, | 281 m_pDevice->SetBitMask(&pBitmap->m_Bitmap, origin_x + pBitmap->m_Left, |
| 283 origin_y - pBitmap->m_Top, fill_argb); | 282 origin_y - pBitmap->m_Top, fill_argb); |
| 284 } else { | 283 } else { |
| 285 glyphs[iChar].m_pGlyph = pBitmap; | 284 glyphs[iChar].m_pGlyph = pBitmap; |
| 286 glyphs[iChar].m_OriginX = origin_x; | 285 glyphs[iChar].m_OriginX = origin_x; |
| 287 glyphs[iChar].m_OriginY = origin_y; | 286 glyphs[iChar].m_OriginY = origin_y; |
| 288 } | 287 } |
| 289 } else { | 288 } else { |
| 290 CFX_Matrix image_matrix = pType3Char->m_ImageMatrix; | 289 CFX_Matrix image_matrix = pType3Char->m_ImageMatrix; |
| 291 image_matrix.Concat(matrix); | 290 image_matrix.Concat(matrix); |
| 292 CPDF_ImageRenderer renderer; | 291 CPDF_ImageRenderer renderer; |
| 293 if (renderer.Start(this, pType3Char->m_pBitmap.get(), fill_argb, 255, | 292 if (renderer.Start(this, pType3Char->m_pBitmap.get(), fill_argb, 255, |
| 294 &image_matrix, 0, FALSE)) { | 293 &image_matrix, 0, FALSE)) { |
| 295 renderer.Continue(nullptr); | 294 renderer.Continue(nullptr); |
| 296 } | 295 } |
| 297 if (!renderer.m_Result) | 296 if (!renderer.m_Result) |
| 298 return FALSE; | 297 return FALSE; |
| 299 } | 298 } |
| 300 } | 299 } |
| 301 } | 300 } |
| 302 | 301 |
| 303 if (glyphs.empty()) | 302 if (glyphs.empty()) |
| 304 return TRUE; | 303 return TRUE; |
| 305 | |
| 306 FX_RECT rect = FXGE_GetGlyphsBBox(glyphs, 0, sa, sd); | 304 FX_RECT rect = FXGE_GetGlyphsBBox(glyphs, 0, sa, sd); |
| 307 CFX_DIBitmap bitmap; | 305 CFX_DIBitmap bitmap; |
| 308 if (!bitmap.Create(static_cast<int>(rect.Width() * sa), | 306 if (!bitmap.Create(static_cast<int>(rect.Width() * sa), |
| 309 static_cast<int>(rect.Height() * sd), FXDIB_8bppMask)) { | 307 static_cast<int>(rect.Height() * sd), FXDIB_8bppMask)) { |
| 310 return TRUE; | 308 return TRUE; |
| 311 } | 309 } |
| 312 bitmap.Clear(0); | 310 bitmap.Clear(0); |
| 313 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { | 311 for (const FXTEXT_GLYPHPOS& glyph : glyphs) { |
| 314 if (!glyph.m_pGlyph) | 312 if (!glyph.m_pGlyph) |
| 315 continue; | 313 continue; |
| 316 | 314 |
| 317 bitmap.TransferBitmap( | 315 pdfium::base::CheckedNumeric<int> left = glyph.m_OriginX; |
|
Lei Zhang
2016/10/28 18:58:20
nit: include the header for CheckedNumeric.
npm
2016/10/28 19:26:25
Done.
| |
| 318 static_cast<int>( | 316 left += glyph.m_pGlyph->m_Left; |
| 319 (glyph.m_OriginX + glyph.m_pGlyph->m_Left - rect.left) * sa), | 317 left -= rect.left; |
| 320 static_cast<int>((glyph.m_OriginY - glyph.m_pGlyph->m_Top - rect.top) * | 318 left *= sa; |
| 321 sd), | 319 if (!left.IsValid()) |
| 322 glyph.m_pGlyph->m_Bitmap.GetWidth(), | 320 continue; |
| 323 glyph.m_pGlyph->m_Bitmap.GetHeight(), &glyph.m_pGlyph->m_Bitmap, 0, 0); | 321 |
| 322 pdfium::base::CheckedNumeric<int> top = glyph.m_OriginY; | |
| 323 top -= glyph.m_pGlyph->m_Top; | |
| 324 top -= rect.top; | |
| 325 top *= sd; | |
| 326 if (!top.IsValid()) | |
| 327 continue; | |
| 328 | |
| 329 bitmap.CompositeMask(left.ValueOrDie(), top.ValueOrDie(), | |
| 330 glyph.m_pGlyph->m_Bitmap.GetWidth(), | |
| 331 glyph.m_pGlyph->m_Bitmap.GetHeight(), | |
| 332 &glyph.m_pGlyph->m_Bitmap, fill_argb, 0, 0, | |
| 333 FXDIB_BLEND_NORMAL, nullptr, FALSE, 0, nullptr); | |
| 324 } | 334 } |
| 325 m_pDevice->SetBitMask(&bitmap, rect.left, rect.top, fill_argb); | 335 m_pDevice->SetBitMask(&bitmap, rect.left, rect.top, fill_argb); |
| 326 return TRUE; | 336 return TRUE; |
| 327 } | 337 } |
| 328 | 338 |
| 329 class CPDF_CharPosList { | 339 class CPDF_CharPosList { |
| 330 public: | 340 public: |
| 331 CPDF_CharPosList(); | 341 CPDF_CharPosList(); |
| 332 ~CPDF_CharPosList(); | 342 ~CPDF_CharPosList(); |
| 333 void Load(int nChars, | 343 void Load(int nChars, |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 639 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, | 649 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, |
| 640 charpos.m_OriginY); | 650 charpos.m_OriginY); |
| 641 path.m_Path.Append(pPath, &matrix); | 651 path.m_Path.Append(pPath, &matrix); |
| 642 path.m_Matrix = *pTextMatrix; | 652 path.m_Matrix = *pTextMatrix; |
| 643 path.m_bStroke = bStroke; | 653 path.m_bStroke = bStroke; |
| 644 path.m_FillType = bFill ? FXFILL_WINDING : 0; | 654 path.m_FillType = bFill ? FXFILL_WINDING : 0; |
| 645 path.CalcBoundingBox(); | 655 path.CalcBoundingBox(); |
| 646 ProcessPath(&path, pObj2Device); | 656 ProcessPath(&path, pObj2Device); |
| 647 } | 657 } |
| 648 } | 658 } |
| OLD | NEW |