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

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

Issue 2303553002: Make CPDF_GeneralState have a CPDF_GeneralStateData (Closed)
Patch Set: Move functions .cpp file Created 4 years, 3 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
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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 if (!pResBitmap) 218 if (!pResBitmap)
219 return nullptr; 219 return nullptr;
220 220
221 CFX_GlyphBitmap* pGlyph = new CFX_GlyphBitmap; 221 CFX_GlyphBitmap* pGlyph = new CFX_GlyphBitmap;
222 pGlyph->m_Left = left; 222 pGlyph->m_Left = left;
223 pGlyph->m_Top = -top; 223 pGlyph->m_Top = -top;
224 pGlyph->m_Bitmap.TakeOver(pResBitmap.get()); 224 pGlyph->m_Bitmap.TakeOver(pResBitmap.get());
225 return pGlyph; 225 return pGlyph;
226 } 226 }
227 227
228 FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj, 228 FX_BOOL CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
229 const CFX_Matrix* pObj2Device, 229 const CFX_Matrix* pObj2Device,
230 CFX_PathData* pClippingPath) { 230 CFX_PathData* pClippingPath) {
231 if (textobj->m_nChars == 0) 231 if (textobj->m_nChars == 0)
232 return TRUE; 232 return TRUE;
233 233
234 const TextRenderingMode text_render_mode = textobj->m_TextState.GetTextMode(); 234 const TextRenderingMode text_render_mode = textobj->m_TextState.GetTextMode();
235 if (text_render_mode == TextRenderingMode::MODE_INVISIBLE) 235 if (text_render_mode == TextRenderingMode::MODE_INVISIBLE)
236 return TRUE; 236 return TRUE;
237 237
238 CPDF_Font* pFont = textobj->m_TextState.GetFont(); 238 CPDF_Font* pFont = textobj->m_TextState.GetFont();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 device_matrix.Copy(ctm); 314 device_matrix.Copy(ctm);
315 device_matrix.Concat(*pObj2Device); 315 device_matrix.Concat(*pObj2Device);
316 pDeviceMatrix = &device_matrix; 316 pDeviceMatrix = &device_matrix;
317 } 317 }
318 } 318 }
319 int flag = 0; 319 int flag = 0;
320 if (bStroke && bFill) { 320 if (bStroke && bFill) {
321 flag |= FX_FILL_STROKE; 321 flag |= FX_FILL_STROKE;
322 flag |= FX_STROKE_TEXT_MODE; 322 flag |= FX_STROKE_TEXT_MODE;
323 } 323 }
324 const CPDF_GeneralStateData* pGeneralData = 324 if (textobj->m_GeneralState.GetStrokeAdjust())
325 static_cast<const CPDF_PageObject*>(textobj)
326 ->m_GeneralState.GetObject();
327 if (pGeneralData && pGeneralData->m_StrokeAdjust) {
328 flag |= FX_STROKE_ADJUST; 325 flag |= FX_STROKE_ADJUST;
329 } 326 if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH)
330 if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH) {
331 flag |= FXFILL_NOPATHSMOOTH; 327 flag |= FXFILL_NOPATHSMOOTH;
332 }
333 return CPDF_TextRenderer::DrawTextPath( 328 return CPDF_TextRenderer::DrawTextPath(
334 m_pDevice, textobj->m_nChars, textobj->m_pCharCodes, 329 m_pDevice, textobj->m_nChars, textobj->m_pCharCodes,
335 textobj->m_pCharPos, pFont, font_size, &text_matrix, pDeviceMatrix, 330 textobj->m_pCharPos, pFont, font_size, &text_matrix, pDeviceMatrix,
336 textobj->m_GraphState.GetObject(), fill_argb, stroke_argb, 331 textobj->m_GraphState.GetObject(), fill_argb, stroke_argb,
337 pClippingPath, flag); 332 pClippingPath, flag);
338 } 333 }
339 text_matrix.Concat(*pObj2Device); 334 text_matrix.Concat(*pObj2Device);
340 return CPDF_TextRenderer::DrawNormalText( 335 return CPDF_TextRenderer::DrawNormalText(
341 m_pDevice, textobj->m_nChars, textobj->m_pCharCodes, textobj->m_pCharPos, 336 m_pDevice, textobj->m_nChars, textobj->m_pCharCodes, textobj->m_pCharPos,
342 pFont, font_size, &text_matrix, fill_argb, &m_Options); 337 pFont, font_size, &text_matrix, fill_argb, &m_Options);
(...skipping 21 matching lines...) Expand all
364 ~CPDF_RefType3Cache() { 359 ~CPDF_RefType3Cache() {
365 while (m_dwCount--) { 360 while (m_dwCount--) {
366 ReleaseCachedType3(m_pType3Font); 361 ReleaseCachedType3(m_pType3Font);
367 } 362 }
368 } 363 }
369 uint32_t m_dwCount; 364 uint32_t m_dwCount;
370 CPDF_Type3Font* const m_pType3Font; 365 CPDF_Type3Font* const m_pType3Font;
371 }; 366 };
372 367
373 // TODO(npm): Font fallback for type 3 fonts? (Completely separate code!!) 368 // TODO(npm): Font fallback for type 3 fonts? (Completely separate code!!)
374 FX_BOOL CPDF_RenderStatus::ProcessType3Text(const CPDF_TextObject* textobj, 369 FX_BOOL CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
375 const CFX_Matrix* pObj2Device) { 370 const CFX_Matrix* pObj2Device) {
376 CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->AsType3Font(); 371 CPDF_Type3Font* pType3Font = textobj->m_TextState.GetFont()->AsType3Font();
377 for (int i = 0; i < m_Type3FontCache.GetSize(); ++i) { 372 for (int i = 0; i < m_Type3FontCache.GetSize(); ++i) {
378 if (m_Type3FontCache.GetAt(i) == pType3Font) 373 if (m_Type3FontCache.GetAt(i) == pType3Font)
379 return TRUE; 374 return TRUE;
380 } 375 }
381 376
382 CFX_Matrix dCTM = m_pDevice->GetCTM(); 377 CFX_Matrix dCTM = m_pDevice->GetCTM();
383 FX_FLOAT sa = FXSYS_fabs(dCTM.a); 378 FX_FLOAT sa = FXSYS_fabs(dCTM.a);
384 FX_FLOAT sd = FXSYS_fabs(dCTM.d); 379 FX_FLOAT sd = FXSYS_fabs(dCTM.d);
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX, 859 matrix.Concat(font_size, 0, 0, font_size, charpos.m_OriginX,
865 charpos.m_OriginY); 860 charpos.m_OriginY);
866 path.m_Path.Emplace()->Append(pPath, &matrix); 861 path.m_Path.Emplace()->Append(pPath, &matrix);
867 path.m_Matrix = *pTextMatrix; 862 path.m_Matrix = *pTextMatrix;
868 path.m_bStroke = bStroke; 863 path.m_bStroke = bStroke;
869 path.m_FillType = bFill ? FXFILL_WINDING : 0; 864 path.m_FillType = bFill ? FXFILL_WINDING : 0;
870 path.CalcBoundingBox(); 865 path.CalcBoundingBox();
871 ProcessPath(&path, pObj2Device); 866 ProcessPath(&path, pObj2Device);
872 } 867 }
873 } 868 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698