Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: core/fpdfapi/fpdf_render/fpdf_render_text.cpp

Issue 2032613003: Get rid of NULLs in core/ (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: Fix a bad merge Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp ('k') | core/fpdfapi/fpdf_render/render_int.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/fpdf_render/render_int.h" 7 #include "core/fpdfapi/fpdf_render/render_int.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 textobj->m_GraphState, fill_argb, stroke_argb, pClippingPath, flag); 321 textobj->m_GraphState, fill_argb, stroke_argb, pClippingPath, flag);
322 } 322 }
323 text_matrix.Concat(*pObj2Device); 323 text_matrix.Concat(*pObj2Device);
324 return CPDF_TextRenderer::DrawNormalText( 324 return CPDF_TextRenderer::DrawNormalText(
325 m_pDevice, textobj->m_nChars, textobj->m_pCharCodes, textobj->m_pCharPos, 325 m_pDevice, textobj->m_nChars, textobj->m_pCharCodes, textobj->m_pCharPos,
326 pFont, font_size, &text_matrix, fill_argb, &m_Options); 326 pFont, font_size, &text_matrix, fill_argb, &m_Options);
327 } 327 }
328 328
329 CPDF_Type3Cache* CPDF_RenderStatus::GetCachedType3(CPDF_Type3Font* pFont) { 329 CPDF_Type3Cache* CPDF_RenderStatus::GetCachedType3(CPDF_Type3Font* pFont) {
330 if (!pFont->m_pDocument) { 330 if (!pFont->m_pDocument) {
331 return NULL; 331 return nullptr;
332 } 332 }
333 pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict(), FALSE); 333 pFont->m_pDocument->GetPageData()->GetFont(pFont->GetFontDict(), FALSE);
334 return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont); 334 return pFont->m_pDocument->GetRenderData()->GetCachedType3(pFont);
335 } 335 }
336 static void ReleaseCachedType3(CPDF_Type3Font* pFont) { 336 static void ReleaseCachedType3(CPDF_Type3Font* pFont) {
337 if (!pFont->m_pDocument) { 337 if (!pFont->m_pDocument) {
338 return; 338 return;
339 } 339 }
340 pFont->m_pDocument->GetRenderData()->ReleaseCachedType3(pFont); 340 pFont->m_pDocument->GetRenderData()->ReleaseCachedType3(pFont);
341 pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict()); 341 pFont->m_pDocument->GetPageData()->ReleaseFont(pFont->GetFontDict());
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 glyph.m_OriginX + glyph.m_pGlyph->m_Left, 408 glyph.m_OriginX + glyph.m_pGlyph->m_Left,
409 glyph.m_OriginY - glyph.m_pGlyph->m_Top, 409 glyph.m_OriginY - glyph.m_pGlyph->m_Top,
410 fill_argb); 410 fill_argb);
411 } 411 }
412 glyphs.clear(); 412 glyphs.clear();
413 } 413 }
414 CPDF_GraphicStates* pStates = CloneObjStates(textobj, FALSE); 414 CPDF_GraphicStates* pStates = CloneObjStates(textobj, FALSE);
415 CPDF_RenderOptions Options = m_Options; 415 CPDF_RenderOptions Options = m_Options;
416 Options.m_Flags |= RENDER_FORCE_HALFTONE | RENDER_RECT_AA; 416 Options.m_Flags |= RENDER_FORCE_HALFTONE | RENDER_RECT_AA;
417 Options.m_Flags &= ~RENDER_FORCE_DOWNSAMPLE; 417 Options.m_Flags &= ~RENDER_FORCE_DOWNSAMPLE;
418 CPDF_Dictionary* pFormResource = NULL; 418 CPDF_Dictionary* pFormResource = nullptr;
419 if (pType3Char->m_pForm && pType3Char->m_pForm->m_pFormDict) { 419 if (pType3Char->m_pForm && pType3Char->m_pForm->m_pFormDict) {
420 pFormResource = 420 pFormResource =
421 pType3Char->m_pForm->m_pFormDict->GetDictBy("Resources"); 421 pType3Char->m_pForm->m_pFormDict->GetDictBy("Resources");
422 } 422 }
423 if (fill_alpha == 255) { 423 if (fill_alpha == 255) {
424 CPDF_RenderStatus status; 424 CPDF_RenderStatus status;
425 status.Initialize(m_pContext, m_pDevice, NULL, NULL, this, pStates, 425 status.Initialize(m_pContext, m_pDevice, nullptr, nullptr, this,
426 &Options, pType3Char->m_pForm->m_Transparency, 426 pStates, &Options,
427 m_bDropObjects, pFormResource, FALSE, pType3Char, 427 pType3Char->m_pForm->m_Transparency, m_bDropObjects,
428 fill_argb); 428 pFormResource, FALSE, pType3Char, fill_argb);
429 status.m_Type3FontCache.Append(m_Type3FontCache); 429 status.m_Type3FontCache.Append(m_Type3FontCache);
430 status.m_Type3FontCache.Add(pType3Font); 430 status.m_Type3FontCache.Add(pType3Font);
431 m_pDevice->SaveState(); 431 m_pDevice->SaveState();
432 status.RenderObjectList(pType3Char->m_pForm.get(), &matrix); 432 status.RenderObjectList(pType3Char->m_pForm.get(), &matrix);
433 m_pDevice->RestoreState(false); 433 m_pDevice->RestoreState(false);
434 } else { 434 } else {
435 CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox(); 435 CFX_FloatRect rect_f = pType3Char->m_pForm->CalcBoundingBox();
436 rect_f.Transform(&matrix); 436 rect_f.Transform(&matrix);
437 FX_RECT rect = rect_f.GetOutterRect(); 437 FX_RECT rect = rect_f.GetOutterRect();
438 CFX_FxgeDevice bitmap_device; 438 CFX_FxgeDevice bitmap_device;
439 if (!bitmap_device.Create((int)(rect.Width() * sa), 439 if (!bitmap_device.Create((int)(rect.Width() * sa),
440 (int)(rect.Height() * sd), FXDIB_Argb, 440 (int)(rect.Height() * sd), FXDIB_Argb,
441 nullptr)) { 441 nullptr)) {
442 return TRUE; 442 return TRUE;
443 } 443 }
444 bitmap_device.GetBitmap()->Clear(0); 444 bitmap_device.GetBitmap()->Clear(0);
445 CPDF_RenderStatus status; 445 CPDF_RenderStatus status;
446 status.Initialize(m_pContext, &bitmap_device, NULL, NULL, this, pStates, 446 status.Initialize(m_pContext, &bitmap_device, nullptr, nullptr, this,
447 &Options, pType3Char->m_pForm->m_Transparency, 447 pStates, &Options,
448 m_bDropObjects, pFormResource, FALSE, pType3Char, 448 pType3Char->m_pForm->m_Transparency, m_bDropObjects,
449 fill_argb); 449 pFormResource, FALSE, pType3Char, fill_argb);
450 status.m_Type3FontCache.Append(m_Type3FontCache); 450 status.m_Type3FontCache.Append(m_Type3FontCache);
451 status.m_Type3FontCache.Add(pType3Font); 451 status.m_Type3FontCache.Add(pType3Font);
452 matrix.TranslateI(-rect.left, -rect.top); 452 matrix.TranslateI(-rect.left, -rect.top);
453 matrix.Scale(sa, sd); 453 matrix.Scale(sa, sd);
454 status.RenderObjectList(pType3Char->m_pForm.get(), &matrix); 454 status.RenderObjectList(pType3Char->m_pForm.get(), &matrix);
455 m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.top); 455 m_pDevice->SetDIBits(bitmap_device.GetBitmap(), rect.left, rect.top);
456 } 456 }
457 delete pStates; 457 delete pStates;
458 } else if (pType3Char->m_pBitmap) { 458 } else if (pType3Char->m_pBitmap) {
459 if (device_class == FXDC_DISPLAY) { 459 if (device_class == FXDC_DISPLAY) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
520 void Load(int nChars, 520 void Load(int nChars,
521 uint32_t* pCharCodes, 521 uint32_t* pCharCodes,
522 FX_FLOAT* pCharPos, 522 FX_FLOAT* pCharPos,
523 CPDF_Font* pFont, 523 CPDF_Font* pFont,
524 FX_FLOAT font_size); 524 FX_FLOAT font_size);
525 FXTEXT_CHARPOS* m_pCharPos; 525 FXTEXT_CHARPOS* m_pCharPos;
526 uint32_t m_nChars; 526 uint32_t m_nChars;
527 }; 527 };
528 528
529 CPDF_CharPosList::CPDF_CharPosList() { 529 CPDF_CharPosList::CPDF_CharPosList() {
530 m_pCharPos = NULL; 530 m_pCharPos = nullptr;
531 } 531 }
532 532
533 CPDF_CharPosList::~CPDF_CharPosList() { 533 CPDF_CharPosList::~CPDF_CharPosList() {
534 FX_Free(m_pCharPos); 534 FX_Free(m_pCharPos);
535 } 535 }
536 536
537 void CPDF_CharPosList::Load(int nChars, 537 void CPDF_CharPosList::Load(int nChars,
538 uint32_t* pCharCodes, 538 uint32_t* pCharCodes,
539 FX_FLOAT* pCharPos, 539 FX_FLOAT* pCharPos,
540 CPDF_Font* pFont, 540 CPDF_Font* pFont,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 if (nChars == 0) { 634 if (nChars == 0) {
635 return; 635 return;
636 } 636 }
637 uint32_t charcode; 637 uint32_t charcode;
638 int offset = 0; 638 int offset = 0;
639 uint32_t* pCharCodes; 639 uint32_t* pCharCodes;
640 FX_FLOAT* pCharPos; 640 FX_FLOAT* pCharPos;
641 if (nChars == 1) { 641 if (nChars == 1) {
642 charcode = pFont->GetNextChar(str.c_str(), str.GetLength(), offset); 642 charcode = pFont->GetNextChar(str.c_str(), str.GetLength(), offset);
643 pCharCodes = (uint32_t*)(uintptr_t)charcode; 643 pCharCodes = (uint32_t*)(uintptr_t)charcode;
644 pCharPos = NULL; 644 pCharPos = nullptr;
645 } else { 645 } else {
646 pCharCodes = FX_Alloc(uint32_t, nChars); 646 pCharCodes = FX_Alloc(uint32_t, nChars);
647 pCharPos = FX_Alloc(FX_FLOAT, nChars - 1); 647 pCharPos = FX_Alloc(FX_FLOAT, nChars - 1);
648 FX_FLOAT cur_pos = 0; 648 FX_FLOAT cur_pos = 0;
649 for (int i = 0; i < nChars; i++) { 649 for (int i = 0; i < nChars; i++) {
650 pCharCodes[i] = pFont->GetNextChar(str.c_str(), str.GetLength(), offset); 650 pCharCodes[i] = pFont->GetNextChar(str.c_str(), str.GetLength(), offset);
651 if (i) { 651 if (i) {
652 pCharPos[i - 1] = cur_pos; 652 pCharPos[i - 1] = cur_pos;
653 } 653 }
654 cur_pos += pFont->GetCharWidthF(pCharCodes[i]) * font_size / 1000; 654 cur_pos += pFont->GetCharWidthF(pCharCodes[i]) * font_size / 1000;
(...skipping 28 matching lines...) Expand all
683 int nChars, 683 int nChars,
684 uint32_t* pCharCodes, 684 uint32_t* pCharCodes,
685 FX_FLOAT* pCharPos, 685 FX_FLOAT* pCharPos,
686 CPDF_Font* pFont, 686 CPDF_Font* pFont,
687 FX_FLOAT font_size, 687 FX_FLOAT font_size,
688 const CFX_Matrix* pText2Device, 688 const CFX_Matrix* pText2Device,
689 FX_ARGB fill_argb, 689 FX_ARGB fill_argb,
690 const CPDF_RenderOptions* pOptions) { 690 const CPDF_RenderOptions* pOptions) {
691 CFX_FontCache* pCache = 691 CFX_FontCache* pCache =
692 pFont->m_pDocument ? pFont->m_pDocument->GetRenderData()->GetFontCache() 692 pFont->m_pDocument ? pFont->m_pDocument->GetRenderData()->GetFontCache()
693 : NULL; 693 : nullptr;
694 CPDF_CharPosList CharPosList; 694 CPDF_CharPosList CharPosList;
695 CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size); 695 CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size);
696 int FXGE_flags = 0; 696 int FXGE_flags = 0;
697 if (pOptions) { 697 if (pOptions) {
698 uint32_t dwFlags = pOptions->m_Flags; 698 uint32_t dwFlags = pOptions->m_Flags;
699 if (dwFlags & RENDER_CLEARTYPE) { 699 if (dwFlags & RENDER_CLEARTYPE) {
700 FXGE_flags |= FXTEXT_CLEARTYPE; 700 FXGE_flags |= FXTEXT_CLEARTYPE;
701 if (dwFlags & RENDER_BGR_STRIPE) { 701 if (dwFlags & RENDER_BGR_STRIPE) {
702 FXGE_flags |= FXTEXT_BGR_STRIPE; 702 FXGE_flags |= FXTEXT_BGR_STRIPE;
703 } 703 }
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, 777 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX,
778 charpos.m_OriginY); 778 charpos.m_OriginY);
779 path.m_Path.New()->Append(pPath, &matrix); 779 path.m_Path.New()->Append(pPath, &matrix);
780 path.m_Matrix = *pTextMatrix; 780 path.m_Matrix = *pTextMatrix;
781 path.m_bStroke = bStroke; 781 path.m_bStroke = bStroke;
782 path.m_FillType = bFill ? FXFILL_WINDING : 0; 782 path.m_FillType = bFill ? FXFILL_WINDING : 0;
783 path.CalcBoundingBox(); 783 path.CalcBoundingBox();
784 ProcessPath(&path, pObj2Device); 784 ProcessPath(&path, pObj2Device);
785 } 785 }
786 } 786 }
OLDNEW
« no previous file with comments | « core/fpdfapi/fpdf_render/fpdf_render_pattern.cpp ('k') | core/fpdfapi/fpdf_render/render_int.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698