diff options
author | npm <npm@chromium.org> | 2016-12-02 14:01:36 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-12-02 14:01:36 -0800 |
commit | 4bed2af0c049bf499dcdb1327a47d40b4c0db92d (patch) | |
tree | 04239e723c4d27c02d3edd78e3e93012d517ba6e /core | |
parent | 0527ec571a8842b84f5161dc67f8da439e65eb12 (diff) | |
download | pdfium-4bed2af0c049bf499dcdb1327a47d40b4c0db92d.tar.xz |
Rename fpdf_render_image and fpdf_render_textchromium/2942chromium/2941chromium/2940
Review-Url: https://codereview.chromium.org/2551593002
Diffstat (limited to 'core')
-rw-r--r-- | core/fpdfapi/render/cpdf_dibtransferfunc.cpp (renamed from core/fpdfapi/render/fpdf_render_image.cpp) | 60 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_dibtransferfunc.h | 37 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_textrenderer.cpp (renamed from core/fpdfapi/render/fpdf_render_text.cpp) | 42 | ||||
-rw-r--r-- | core/fpdfapi/render/cpdf_transferfunc.cpp | 2 | ||||
-rw-r--r-- | core/fpdfapi/render/render_int.h | 30 |
5 files changed, 69 insertions, 102 deletions
diff --git a/core/fpdfapi/render/fpdf_render_image.cpp b/core/fpdfapi/render/cpdf_dibtransferfunc.cpp index da5eda2020..41575fc8c2 100644 --- a/core/fpdfapi/render/fpdf_render_image.cpp +++ b/core/fpdfapi/render/cpdf_dibtransferfunc.cpp @@ -1,47 +1,29 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2016 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fpdfapi/render/render_int.h" +#include "core/fpdfapi/render/cpdf_dibtransferfunc.h" -#include <memory> -#include <utility> #include <vector> -#include "core/fpdfapi/page/cpdf_docpagedata.h" -#include "core/fpdfapi/page/cpdf_form.h" -#include "core/fpdfapi/page/cpdf_image.h" -#include "core/fpdfapi/page/cpdf_imageobject.h" -#include "core/fpdfapi/page/cpdf_page.h" -#include "core/fpdfapi/page/cpdf_shadingpattern.h" -#include "core/fpdfapi/page/cpdf_tilingpattern.h" -#include "core/fpdfapi/page/pageint.h" -#include "core/fpdfapi/parser/cpdf_array.h" #include "core/fpdfapi/parser/cpdf_dictionary.h" -#include "core/fpdfapi/parser/cpdf_document.h" -#include "core/fpdfapi/render/cpdf_pagerendercache.h" -#include "core/fpdfapi/render/cpdf_rendercontext.h" -#include "core/fpdfapi/render/cpdf_renderoptions.h" -#include "core/fpdfapi/render/cpdf_renderstatus.h" #include "core/fpdfapi/render/cpdf_transferfunc.h" -#include "core/fpdfdoc/cpdf_occontext.h" -#include "core/fxcodec/fx_codec.h" -#include "core/fxcrt/fx_safe_types.h" -#include "core/fxge/cfx_fxgedevice.h" -#include "core/fxge/cfx_pathdata.h" -#ifdef _SKIA_SUPPORT_ -#include "core/fxge/skia/fx_skia_device.h" -#endif +CPDF_DIBTransferFunc::CPDF_DIBTransferFunc( + const CPDF_TransferFunc* pTransferFunc) { + m_RampR = pTransferFunc->m_Samples; + m_RampG = &pTransferFunc->m_Samples[256]; + m_RampB = &pTransferFunc->m_Samples[512]; +} CPDF_DIBTransferFunc::~CPDF_DIBTransferFunc() {} FXDIB_Format CPDF_DIBTransferFunc::GetDestFormat() { - if (m_pSrc->IsAlphaMask()) { + if (m_pSrc->IsAlphaMask()) return FXDIB_8bppMask; - } + #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ return (m_pSrc->HasAlpha()) ? FXDIB_Argb : FXDIB_Rgb32; #else @@ -53,13 +35,6 @@ FX_ARGB* CPDF_DIBTransferFunc::GetDestPalette() { return nullptr; } -CPDF_DIBTransferFunc::CPDF_DIBTransferFunc( - const CPDF_TransferFunc* pTransferFunc) { - m_RampR = pTransferFunc->m_Samples; - m_RampG = &pTransferFunc->m_Samples[256]; - m_RampB = &pTransferFunc->m_Samples[512]; -} - void CPDF_DIBTransferFunc::TranslateScanline( const uint8_t* src_buf, std::vector<uint8_t>* dest_buf) const { @@ -125,9 +100,8 @@ void CPDF_DIBTransferFunc::TranslateScanline( } case FXDIB_8bppMask: { int index = 0; - for (int i = 0; i < m_Width; i++) { + for (int i = 0; i < m_Width; i++) (*dest_buf)[index++] = m_RampR[*(src_buf++)]; - } break; } case FXDIB_Rgb: { @@ -171,9 +145,8 @@ void CPDF_DIBTransferFunc::TranslateDownSamples(uint8_t* dest_buf, int pixels, int Bpp) const { if (Bpp == 8) { - for (int i = 0; i < pixels; i++) { + for (int i = 0; i < pixels; i++) *dest_buf++ = m_RampR[*(src_buf++)]; - } } else if (Bpp == 24) { for (int i = 0; i < pixels; i++) { *dest_buf++ = m_RampB[*(src_buf++)]; @@ -203,12 +176,3 @@ void CPDF_DIBTransferFunc::TranslateDownSamples(uint8_t* dest_buf, #endif } } - -CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( - const uint8_t* src_buf, - uint32_t src_size, - int width, - int height, - int nComps, - int bpc, - const CPDF_Dictionary* pParams); diff --git a/core/fpdfapi/render/cpdf_dibtransferfunc.h b/core/fpdfapi/render/cpdf_dibtransferfunc.h new file mode 100644 index 0000000000..d290c00d8a --- /dev/null +++ b/core/fpdfapi/render/cpdf_dibtransferfunc.h @@ -0,0 +1,37 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef CORE_FPDFAPI_RENDER_CPDF_DIBTRANSFERFUNC_H_ +#define CORE_FPDFAPI_RENDER_CPDF_DIBTRANSFERFUNC_H_ + +#include <vector> + +#include "core/fxge/fx_dib.h" + +class CPDF_TransferFunc; + +class CPDF_DIBTransferFunc : public CFX_FilteredDIB { + public: + explicit CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFunc); + ~CPDF_DIBTransferFunc() override; + + // CFX_FilteredDIB + FXDIB_Format GetDestFormat() override; + FX_ARGB* GetDestPalette() override; + void TranslateScanline(const uint8_t* src_buf, + std::vector<uint8_t>* dest_buf) const override; + void TranslateDownSamples(uint8_t* dest_buf, + const uint8_t* src_buf, + int pixels, + int Bpp) const override; + + private: + const uint8_t* m_RampR; + const uint8_t* m_RampG; + const uint8_t* m_RampB; +}; + +#endif // CORE_FPDFAPI_RENDER_CPDF_DIBTRANSFERFUNC_H_ diff --git a/core/fpdfapi/render/fpdf_render_text.cpp b/core/fpdfapi/render/cpdf_textrenderer.cpp index 1a749bcd21..9cb8ce933e 100644 --- a/core/fpdfapi/render/fpdf_render_text.cpp +++ b/core/fpdfapi/render/cpdf_textrenderer.cpp @@ -1,38 +1,19 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2016 PDFium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com -#include "core/fpdfapi/render/render_int.h" +#include "core/fpdfapi/render/cpdf_textrenderer.h" #include <vector> -#include "core/fpdfapi/font/cpdf_cidfont.h" #include "core/fpdfapi/font/cpdf_font.h" -#include "core/fpdfapi/font/cpdf_type3char.h" -#include "core/fpdfapi/font/cpdf_type3font.h" -#include "core/fpdfapi/page/cpdf_docpagedata.h" -#include "core/fpdfapi/page/cpdf_form.h" -#include "core/fpdfapi/page/cpdf_imageobject.h" -#include "core/fpdfapi/page/cpdf_pageobject.h" -#include "core/fpdfapi/page/cpdf_pathobject.h" -#include "core/fpdfapi/page/cpdf_textobject.h" -#include "core/fpdfapi/parser/cpdf_dictionary.h" -#include "core/fpdfapi/parser/cpdf_document.h" #include "core/fpdfapi/render/cpdf_charposlist.h" -#include "core/fpdfapi/render/cpdf_docrenderdata.h" #include "core/fpdfapi/render/cpdf_renderoptions.h" -#include "core/fpdfapi/render/cpdf_renderstatus.h" -#include "core/fpdfapi/render/cpdf_textrenderer.h" -#include "core/fpdfapi/render/cpdf_type3cache.h" -#include "core/fxge/cfx_facecache.h" -#include "core/fxge/cfx_fxgedevice.h" -#include "core/fxge/cfx_gemodule.h" #include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" -#include "third_party/base/numerics/safe_math.h" // static bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, @@ -52,6 +33,7 @@ bool CPDF_TextRenderer::DrawTextPath(CFX_RenderDevice* pDevice, CharPosList.Load(nChars, pCharCodes, pCharPos, pFont, font_size); if (CharPosList.m_nChars == 0) return true; + bool bDraw = true; int32_t fontPosition = CharPosList.m_pCharPos[0].m_FallbackFontPosition; uint32_t startIndex = 0; @@ -159,28 +141,22 @@ bool CPDF_TextRenderer::DrawNormalText(CFX_RenderDevice* pDevice, uint32_t dwFlags = pOptions->m_Flags; if (dwFlags & RENDER_CLEARTYPE) { FXGE_flags |= FXTEXT_CLEARTYPE; - if (dwFlags & RENDER_BGR_STRIPE) { + if (dwFlags & RENDER_BGR_STRIPE) FXGE_flags |= FXTEXT_BGR_STRIPE; - } } - if (dwFlags & RENDER_NOTEXTSMOOTH) { + if (dwFlags & RENDER_NOTEXTSMOOTH) FXGE_flags |= FXTEXT_NOSMOOTH; - } - if (dwFlags & RENDER_PRINTGRAPHICTEXT) { + if (dwFlags & RENDER_PRINTGRAPHICTEXT) FXGE_flags |= FXTEXT_PRINTGRAPHICTEXT; - } - if (dwFlags & RENDER_NO_NATIVETEXT) { + if (dwFlags & RENDER_NO_NATIVETEXT) FXGE_flags |= FXTEXT_NO_NATIVETEXT; - } - if (dwFlags & RENDER_PRINTIMAGETEXT) { + if (dwFlags & RENDER_PRINTIMAGETEXT) FXGE_flags |= FXTEXT_PRINTIMAGETEXT; - } } else { FXGE_flags = FXTEXT_CLEARTYPE; } - if (pFont->IsCIDFont()) { + if (pFont->IsCIDFont()) FXGE_flags |= FXFONT_CIDFONT; - } bool bDraw = true; int32_t fontPosition = CharPosList.m_pCharPos[0].m_FallbackFontPosition; uint32_t startIndex = 0; diff --git a/core/fpdfapi/render/cpdf_transferfunc.cpp b/core/fpdfapi/render/cpdf_transferfunc.cpp index a2cee3992d..be4836d20a 100644 --- a/core/fpdfapi/render/cpdf_transferfunc.cpp +++ b/core/fpdfapi/render/cpdf_transferfunc.cpp @@ -7,7 +7,7 @@ #include "core/fpdfapi/render/cpdf_transferfunc.h" #include "core/fpdfapi/parser/cpdf_document.h" -#include "core/fpdfapi/render/render_int.h" +#include "core/fpdfapi/render/cpdf_dibtransferfunc.h" CPDF_TransferFunc::CPDF_TransferFunc(CPDF_Document* pDoc) : m_pPDFDoc(pDoc) {} diff --git a/core/fpdfapi/render/render_int.h b/core/fpdfapi/render/render_int.h index ca827368bc..5d04fa77bb 100644 --- a/core/fpdfapi/render/render_int.h +++ b/core/fpdfapi/render/render_int.h @@ -56,6 +56,8 @@ typedef struct { int m_ColorKeyMax; } DIB_COMP_DATA; +#define FPDF_HUGE_IMAGE_SIZE 60000000 + class CPDF_DIBSource : public CFX_DIBSource { public: CPDF_DIBSource(); @@ -173,25 +175,13 @@ class CPDF_DIBSource : public CFX_DIBSource { int m_Status; }; -#define FPDF_HUGE_IMAGE_SIZE 60000000 -class CPDF_DIBTransferFunc : public CFX_FilteredDIB { - public: - explicit CPDF_DIBTransferFunc(const CPDF_TransferFunc* pTransferFunc); - ~CPDF_DIBTransferFunc() override; - - // CFX_FilteredDIB - FXDIB_Format GetDestFormat() override; - FX_ARGB* GetDestPalette() override; - void TranslateScanline(const uint8_t* src_buf, - std::vector<uint8_t>* dest_buf) const override; - void TranslateDownSamples(uint8_t* dest_buf, - const uint8_t* src_buf, - int pixels, - int Bpp) const override; - - const uint8_t* m_RampR; - const uint8_t* m_RampG; - const uint8_t* m_RampB; -}; +CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder( + const uint8_t* src_buf, + uint32_t src_size, + int width, + int height, + int nComps, + int bpc, + const CPDF_Dictionary* pParams); #endif // CORE_FPDFAPI_RENDER_RENDER_INT_H_ |