diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-13 18:05:38 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2023-12-13 18:05:38 +0000 |
commit | e03171e52ec4232369ab3b46e11d3a0abe1eb630 (patch) | |
tree | 6a57f6a0948032e6ec387c22d8b462215e6ca1e4 /core/fxcodec/fx_codec.cpp | |
parent | 8bbfdf2fca7197a0eccfef7b6fc27c590a44e7f7 (diff) | |
parent | 326d96bf5d52fdcf790b467b13f58ba3df3e81e4 (diff) | |
download | pdfium-e03171e52ec4232369ab3b46e11d3a0abe1eb630.tar.gz |
Merge cherrypicks of ['googleplex-android-review.googlesource.com/23916086'] into udc-platform-release.android-platform-14.0.0_r8android-platform-14.0.0_r7android-platform-14.0.0_r6android-platform-14.0.0_r5android-platform-14.0.0_r4android14-platform-release
Change-Id: If925f85c6a039b56ff549fd5327795f57b9cd12c
Diffstat (limited to 'core/fxcodec/fx_codec.cpp')
-rw-r--r-- | core/fxcodec/fx_codec.cpp | 91 |
1 files changed, 6 insertions, 85 deletions
diff --git a/core/fxcodec/fx_codec.cpp b/core/fxcodec/fx_codec.cpp index 5625534ad..7181d5715 100644 --- a/core/fxcodec/fx_codec.cpp +++ b/core/fxcodec/fx_codec.cpp @@ -1,4 +1,4 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2014 The PDFium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,110 +6,31 @@ #include "core/fxcodec/fx_codec.h" -#include <algorithm> -#include <cmath> -#include <memory> #include <utility> -#include "core/fxcodec/jbig2/jbig2module.h" -#include "core/fxcodec/jpeg/jpegmodule.h" -#include "core/fxcrt/fx_extension.h" -#include "core/fxcrt/fx_safe_types.h" -#include "third_party/base/logging.h" -#include "third_party/base/ptr_util.h" +#include "core/fxge/dib/fx_dib.h" namespace fxcodec { -namespace { - -ModuleMgr* g_ModuleMgr = nullptr; - -} // namespace - -// static -void ModuleMgr::Create() { - ASSERT(!g_ModuleMgr); - g_ModuleMgr = new ModuleMgr(); -} - -// static -void ModuleMgr::Destroy() { - ASSERT(g_ModuleMgr); - delete g_ModuleMgr; - g_ModuleMgr = nullptr; -} - -// static -ModuleMgr* ModuleMgr::GetInstance() { - ASSERT(g_ModuleMgr); - return g_ModuleMgr; -} - -ModuleMgr::ModuleMgr() - : m_pJpegModule(pdfium::MakeUnique<JpegModule>()), - m_pJbig2Module(pdfium::MakeUnique<Jbig2Module>()) { -#ifdef PDF_ENABLE_XFA_BMP - SetBmpModule(pdfium::MakeUnique<BmpModule>()); -#endif - -#ifdef PDF_ENABLE_XFA_GIF - SetGifModule(pdfium::MakeUnique<GifModule>()); -#endif - -#ifdef PDF_ENABLE_XFA_PNG - SetPngModule(pdfium::MakeUnique<PngModule>()); -#endif - -#ifdef PDF_ENABLE_XFA_TIFF - SetTiffModule(pdfium::MakeUnique<TiffModule>()); -#endif -} - -ModuleMgr::~ModuleMgr() = default; - #ifdef PDF_ENABLE_XFA CFX_DIBAttribute::CFX_DIBAttribute() = default; -CFX_DIBAttribute::~CFX_DIBAttribute() { - for (const auto& pair : m_Exif) - FX_Free(pair.second); -} +CFX_DIBAttribute::~CFX_DIBAttribute() = default; #endif // PDF_ENABLE_XFA void ReverseRGB(uint8_t* pDestBuf, const uint8_t* pSrcBuf, int pixels) { if (pDestBuf == pSrcBuf) { for (int i = 0; i < pixels; i++) { - uint8_t temp = pDestBuf[2]; - pDestBuf[2] = pDestBuf[0]; - pDestBuf[0] = temp; + std::swap(pDestBuf[0], pDestBuf[2]); pDestBuf += 3; } } else { for (int i = 0; i < pixels; i++) { - *pDestBuf++ = pSrcBuf[2]; - *pDestBuf++ = pSrcBuf[1]; - *pDestBuf++ = pSrcBuf[0]; + ReverseCopy3Bytes(pDestBuf, pSrcBuf); + pDestBuf += 3; pSrcBuf += 3; } } } -FX_SAFE_UINT32 CalculatePitch8(uint32_t bpc, uint32_t components, int width) { - FX_SAFE_UINT32 pitch = bpc; - pitch *= components; - pitch *= width; - pitch += 7; - pitch /= 8; - return pitch; -} - -FX_SAFE_UINT32 CalculatePitch32(int bpp, int width) { - FX_SAFE_UINT32 pitch = bpp; - pitch *= width; - pitch += 31; - pitch /= 32; // quantized to number of 32-bit words. - pitch *= 4; // and then back to bytes, (not just /8 in one step). - return pitch; -} - } // namespace fxcodec |