diff options
Diffstat (limited to 'core/fxge')
-rw-r--r-- | core/fxge/apple/fx_apple_platform.cpp | 1 | ||||
-rw-r--r-- | core/fxge/apple/fx_quartz_device.cpp | 1 | ||||
-rw-r--r-- | core/fxge/dib/cfx_bitmapstorer.cpp | 1 | ||||
-rw-r--r-- | core/fxge/dib/cfx_dibitmap.cpp | 1 | ||||
-rw-r--r-- | core/fxge/dib/cfx_imagerenderer.cpp | 1 | ||||
-rw-r--r-- | core/fxge/dib/cfx_imagestretcher.cpp | 2 | ||||
-rw-r--r-- | core/fxge/dib/cfx_imagetransformer.cpp | 26 | ||||
-rw-r--r-- | core/fxge/dib/cfx_imagetransformer.h | 1 | ||||
-rw-r--r-- | core/fxge/dib/cstretchengine.cpp (renamed from core/fxge/dib/fx_dib_engine.cpp) | 35 | ||||
-rw-r--r-- | core/fxge/dib/cstretchengine.h | 81 | ||||
-rw-r--r-- | core/fxge/dib/cstretchengine_unittest.cpp (renamed from core/fxge/dib/fx_dib_engine_unittest.cpp) | 5 | ||||
-rw-r--r-- | core/fxge/dib/dib_int.h | 116 | ||||
-rw-r--r-- | core/fxge/dib/fx_dib_main.cpp | 1 | ||||
-rw-r--r-- | core/fxge/fx_dib.h | 16 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_device.cpp | 2 | ||||
-rw-r--r-- | core/fxge/win32/fx_win32_print.cpp | 2 |
16 files changed, 143 insertions, 149 deletions
diff --git a/core/fxge/apple/fx_apple_platform.cpp b/core/fxge/apple/fx_apple_platform.cpp index 3f7916f07d..818e19e7d4 100644 --- a/core/fxge/apple/fx_apple_platform.cpp +++ b/core/fxge/apple/fx_apple_platform.cpp @@ -14,7 +14,6 @@ #include "core/fxge/cfx_facecache.h" #include "core/fxge/cfx_gemodule.h" #include "core/fxge/cfx_renderdevice.h" -#include "core/fxge/dib/dib_int.h" #include "core/fxge/fx_freetype.h" #include "core/fxge/ge/cfx_cliprgn.h" #include "core/fxge/ge/fx_text_int.h" diff --git a/core/fxge/apple/fx_quartz_device.cpp b/core/fxge/apple/fx_quartz_device.cpp index ded8036047..eef0e0cd88 100644 --- a/core/fxge/apple/fx_quartz_device.cpp +++ b/core/fxge/apple/fx_quartz_device.cpp @@ -15,7 +15,6 @@ #include "core/fxge/cfx_graphstatedata.h" #include "core/fxge/cfx_pathdata.h" #include "core/fxge/cfx_renderdevice.h" -#include "core/fxge/dib/dib_int.h" #include "core/fxge/fx_freetype.h" #include "core/fxge/ge/fx_text_int.h" #include "third_party/base/ptr_util.h" diff --git a/core/fxge/dib/cfx_bitmapstorer.cpp b/core/fxge/dib/cfx_bitmapstorer.cpp index 4e1cb3bc38..1e09708098 100644 --- a/core/fxge/dib/cfx_bitmapstorer.cpp +++ b/core/fxge/dib/cfx_bitmapstorer.cpp @@ -8,7 +8,6 @@ #include <utility> -#include "core/fxge/dib/dib_int.h" #include "third_party/base/ptr_util.h" CFX_BitmapStorer::CFX_BitmapStorer() {} diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp index 6292a67870..54977a6d23 100644 --- a/core/fxge/dib/cfx_dibitmap.cpp +++ b/core/fxge/dib/cfx_dibitmap.cpp @@ -13,7 +13,6 @@ #include "core/fxcodec/fx_codec.h" #include "core/fxge/cfx_gemodule.h" #include "core/fxge/dib/cfx_scanlinecompositor.h" -#include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/cfx_cliprgn.h" #include "third_party/base/ptr_util.h" diff --git a/core/fxge/dib/cfx_imagerenderer.cpp b/core/fxge/dib/cfx_imagerenderer.cpp index 89eb48f0cb..42c92eda06 100644 --- a/core/fxge/dib/cfx_imagerenderer.cpp +++ b/core/fxge/dib/cfx_imagerenderer.cpp @@ -10,7 +10,6 @@ #include "core/fxge/dib/cfx_imagestretcher.h" #include "core/fxge/dib/cfx_imagetransformer.h" -#include "core/fxge/dib/dib_int.h" #include "core/fxge/ge/cfx_cliprgn.h" #include "third_party/base/ptr_util.h" diff --git a/core/fxge/dib/cfx_imagestretcher.cpp b/core/fxge/dib/cfx_imagestretcher.cpp index 94c107b4a3..f52a62d529 100644 --- a/core/fxge/dib/cfx_imagestretcher.cpp +++ b/core/fxge/dib/cfx_imagestretcher.cpp @@ -10,7 +10,7 @@ #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_dibsource.h" -#include "core/fxge/dib/dib_int.h" +#include "core/fxge/dib/cstretchengine.h" #include "core/fxge/fx_dib.h" #include "third_party/base/ptr_util.h" diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp index 65f6bc8ec9..c5fb467ad8 100644 --- a/core/fxge/dib/cfx_imagetransformer.cpp +++ b/core/fxge/dib/cfx_imagetransformer.cpp @@ -115,6 +115,32 @@ FXDIB_Format GetTransformedFormat(const CFX_RetainPtr<CFX_DIBSource>& pDrc) { return format; } +class CPDF_FixedMatrix { + public: + CPDF_FixedMatrix(const CFX_Matrix& src, int bits) { + base = 1 << bits; + a = FXSYS_round(src.a * base); + b = FXSYS_round(src.b * base); + c = FXSYS_round(src.c * base); + d = FXSYS_round(src.d * base); + e = FXSYS_round(src.e * base); + f = FXSYS_round(src.f * base); + } + + inline void Transform(int x, int y, int& x1, int& y1) { + x1 = (a * x + c * y + e + base / 2) / base; + y1 = (b * x + d * y + f + base / 2) / base; + } + + int a; + int b; + int c; + int d; + int e; + int f; + int base; +}; + class CFX_BilinearMatrix : public CPDF_FixedMatrix { public: CFX_BilinearMatrix(const CFX_Matrix& src, int bits) diff --git a/core/fxge/dib/cfx_imagetransformer.h b/core/fxge/dib/cfx_imagetransformer.h index 1354c9099a..52aca9792e 100644 --- a/core/fxge/dib/cfx_imagetransformer.h +++ b/core/fxge/dib/cfx_imagetransformer.h @@ -14,7 +14,6 @@ #include "core/fxge/dib/cfx_bitmapstorer.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_dibsource.h" -#include "core/fxge/dib/dib_int.h" class CFX_ImageStretcher; diff --git a/core/fxge/dib/fx_dib_engine.cpp b/core/fxge/dib/cstretchengine.cpp index 3ae0bf9031..0025331486 100644 --- a/core/fxge/dib/fx_dib_engine.cpp +++ b/core/fxge/dib/cstretchengine.cpp @@ -1,42 +1,37 @@ -// Copyright 2014 PDFium Authors. All rights reserved. +// Copyright 2017 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 <limits.h> - -#include <algorithm> +#include "core/fxge/dib/cstretchengine.h" #include "core/fxge/dib/cfx_dibitmap.h" #include "core/fxge/dib/cfx_dibsource.h" -#include "core/fxge/dib/dib_int.h" #include "core/fxge/dib/ifx_scanlinecomposer.h" #include "core/fxge/fx_dib.h" -#include "third_party/base/ptr_util.h" -#include "third_party/base/stl_util.h" -CWeightTable::CWeightTable() +CStretchEngine::CWeightTable::CWeightTable() : m_DestMin(0), m_ItemSize(0), m_pWeightTables(nullptr), m_dwWeightTablesSize(0) {} -CWeightTable::~CWeightTable() { +CStretchEngine::CWeightTable::~CWeightTable() { FX_Free(m_pWeightTables); } -size_t CWeightTable::GetPixelWeightSize() const { +size_t CStretchEngine::CWeightTable::GetPixelWeightSize() const { return m_ItemSize / sizeof(int) - 2; } -bool CWeightTable::Calc(int dest_len, - int dest_min, - int dest_max, - int src_len, - int src_min, - int src_max, - int flags) { +bool CStretchEngine::CWeightTable::Calc(int dest_len, + int dest_min, + int dest_max, + int src_len, + int src_min, + int src_max, + int flags) { FX_Free(m_pWeightTables); m_pWeightTables = nullptr; m_dwWeightTablesSize = 0; @@ -227,14 +222,14 @@ bool CWeightTable::Calc(int dest_len, return true; } -PixelWeight* CWeightTable::GetPixelWeight(int pixel) const { +PixelWeight* CStretchEngine::CWeightTable::GetPixelWeight(int pixel) const { ASSERT(pixel >= m_DestMin); return reinterpret_cast<PixelWeight*>(m_pWeightTables + (pixel - m_DestMin) * m_ItemSize); } -int* CWeightTable::GetValueFromPixelWeight(PixelWeight* pWeight, - int index) const { +int* CStretchEngine::CWeightTable::GetValueFromPixelWeight(PixelWeight* pWeight, + int index) const { if (index < pWeight->m_SrcStart) return nullptr; diff --git a/core/fxge/dib/cstretchengine.h b/core/fxge/dib/cstretchengine.h new file mode 100644 index 0000000000..0d9457fb9d --- /dev/null +++ b/core/fxge/dib/cstretchengine.h @@ -0,0 +1,81 @@ +// Copyright 2017 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_FXGE_DIB_CSTRETCHENGINE_H_ +#define CORE_FXGE_DIB_CSTRETCHENGINE_H_ + +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxge/fx_dib.h" + +class IFX_ScanlineComposer; + +class CStretchEngine { + public: + CStretchEngine(IFX_ScanlineComposer* pDestBitmap, + FXDIB_Format dest_format, + int dest_width, + int dest_height, + const FX_RECT& clip_rect, + const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap, + int flags); + ~CStretchEngine(); + + bool Continue(IFX_Pause* pPause); + + bool StartStretchHorz(); + bool ContinueStretchHorz(IFX_Pause* pPause); + void StretchVert(); + + class CWeightTable { + public: + CWeightTable(); + ~CWeightTable(); + + bool Calc(int dest_len, + int dest_min, + int dest_max, + int src_len, + int src_min, + int src_max, + int flags); + PixelWeight* GetPixelWeight(int pixel) const; + int* GetValueFromPixelWeight(PixelWeight* pWeight, int index) const; + size_t GetPixelWeightSize() const; + + private: + int m_DestMin; + int m_ItemSize; + uint8_t* m_pWeightTables; + size_t m_dwWeightTablesSize; + }; + + FXDIB_Format m_DestFormat; + int m_DestBpp; + int m_SrcBpp; + int m_bHasAlpha; + IFX_ScanlineComposer* m_pDestBitmap; + int m_DestWidth, m_DestHeight; + FX_RECT m_DestClip; + uint8_t* m_pDestScanline; + uint8_t* m_pDestMaskScanline; + FX_RECT m_SrcClip; + CFX_RetainPtr<CFX_DIBSource> m_pSource; + uint32_t* m_pSrcPalette; + int m_SrcWidth; + int m_SrcHeight; + int m_SrcPitch; + int m_InterPitch; + int m_ExtraMaskPitch; + uint8_t* m_pInterBuf; + uint8_t* m_pExtraAlphaBuf; + int m_TransMethod; + int m_Flags; + CWeightTable m_WeightTable; + int m_CurRow; + int m_State; +}; + +#endif // CORE_FXGE_DIB_CSTRETCHENGINE_H_ diff --git a/core/fxge/dib/fx_dib_engine_unittest.cpp b/core/fxge/dib/cstretchengine_unittest.cpp index 86df82442f..2c7e0342de 100644 --- a/core/fxge/dib/fx_dib_engine_unittest.cpp +++ b/core/fxge/dib/cstretchengine_unittest.cpp @@ -1,7 +1,9 @@ -// Copyright 2016 PDFium Authors. All rights reserved. +// Copyright 2017 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. +#include "core/fxge/dib/cstretchengine.h" + #include <memory> #include <utility> @@ -10,7 +12,6 @@ #include "core/fpdfapi/parser/cpdf_stream.h" #include "core/fpdfapi/render/cpdf_dibsource.h" #include "core/fxcrt/fx_memory.h" -#include "core/fxge/dib/dib_int.h" #include "core/fxge/fx_dib.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/base/ptr_util.h" diff --git a/core/fxge/dib/dib_int.h b/core/fxge/dib/dib_int.h deleted file mode 100644 index a898a479a2..0000000000 --- a/core/fxge/dib/dib_int.h +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright 2014 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_FXGE_DIB_DIB_INT_H_ -#define CORE_FXGE_DIB_DIB_INT_H_ - -#include <stdint.h> - -#include "core/fxcrt/fx_coordinates.h" -#include "core/fxge/fx_dib.h" - -class IFX_ScanlineComposer; - -extern const int16_t SDP_Table[513]; - -class CPDF_FixedMatrix { - public: - CPDF_FixedMatrix(const CFX_Matrix& src, int bits) { - base = 1 << bits; - a = FXSYS_round(src.a * base); - b = FXSYS_round(src.b * base); - c = FXSYS_round(src.c * base); - d = FXSYS_round(src.d * base); - e = FXSYS_round(src.e * base); - f = FXSYS_round(src.f * base); - } - inline void Transform(int x, int y, int& x1, int& y1) { - x1 = (a * x + c * y + e + base / 2) / base; - y1 = (b * x + d * y + f + base / 2) / base; - } - int a, b, c, d, e, f; - int base; -}; -#define FPDF_HUGE_IMAGE_SIZE 60000000 -struct PixelWeight { - int m_SrcStart; - int m_SrcEnd; - int m_Weights[1]; -}; - -class CWeightTable { - public: - CWeightTable(); - ~CWeightTable(); - - bool Calc(int dest_len, - int dest_min, - int dest_max, - int src_len, - int src_min, - int src_max, - int flags); - PixelWeight* GetPixelWeight(int pixel) const; - int* GetValueFromPixelWeight(PixelWeight* pWeight, int index) const; - size_t GetPixelWeightSize() const; - - private: - int m_DestMin; - int m_ItemSize; - uint8_t* m_pWeightTables; - size_t m_dwWeightTablesSize; -}; - -class CStretchEngine { - public: - CStretchEngine(IFX_ScanlineComposer* pDestBitmap, - FXDIB_Format dest_format, - int dest_width, - int dest_height, - const FX_RECT& clip_rect, - const CFX_RetainPtr<CFX_DIBSource>& pSrcBitmap, - int flags); - ~CStretchEngine(); - - bool Continue(IFX_Pause* pPause); - - bool StartStretchHorz(); - bool ContinueStretchHorz(IFX_Pause* pPause); - void StretchVert(); - - FXDIB_Format m_DestFormat; - int m_DestBpp; - int m_SrcBpp; - int m_bHasAlpha; - IFX_ScanlineComposer* m_pDestBitmap; - int m_DestWidth, m_DestHeight; - FX_RECT m_DestClip; - uint8_t* m_pDestScanline; - uint8_t* m_pDestMaskScanline; - FX_RECT m_SrcClip; - CFX_RetainPtr<CFX_DIBSource> m_pSource; - uint32_t* m_pSrcPalette; - int m_SrcWidth; - int m_SrcHeight; - int m_SrcPitch; - int m_InterPitch; - int m_ExtraMaskPitch; - uint8_t* m_pInterBuf; - uint8_t* m_pExtraAlphaBuf; - int m_TransMethod; - int m_Flags; - CWeightTable m_WeightTable; - int m_CurRow; - int m_State; -}; - -FX_RECT FXDIB_SwapClipBox(FX_RECT& clip, - int width, - int height, - bool bFlipX, - bool bFlipY); - -#endif // CORE_FXGE_DIB_DIB_INT_H_ diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp index 68668b92bc..97b1aa7cca 100644 --- a/core/fxge/dib/fx_dib_main.cpp +++ b/core/fxge/dib/fx_dib_main.cpp @@ -8,7 +8,6 @@ #include <utility> -#include "core/fxge/dib/dib_int.h" #include "third_party/base/ptr_util.h" const int16_t SDP_Table[513] = { diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h index cd6a0e6007..17c7c8fd0a 100644 --- a/core/fxge/fx_dib.h +++ b/core/fxge/fx_dib.h @@ -7,7 +7,7 @@ #ifndef CORE_FXGE_FX_DIB_H_ #define CORE_FXGE_FX_DIB_H_ -#include "core/fxcrt/fx_system.h" +#include "core/fxcrt/fx_coordinates.h" enum FXDIB_Format { FXDIB_Invalid = 0, @@ -27,6 +27,12 @@ enum FXDIB_Format { FXDIB_Cmyka = 0x620, }; +struct PixelWeight { + int m_SrcStart; + int m_SrcEnd; + int m_Weights[1]; +}; + typedef uint32_t FX_ARGB; typedef uint32_t FX_COLORREF; typedef uint32_t FX_CMYK; @@ -34,6 +40,8 @@ class CFX_ClipRgn; class CFX_DIBSource; class CStretchEngine; +extern const int16_t SDP_Table[513]; + #define FXDIB_DOWNSAMPLE 0x04 #define FXDIB_INTERPOL 0x20 #define FXDIB_BICUBIC_INTERPOL 0x80 @@ -113,4 +121,10 @@ FX_ARGB ArgbEncode(int a, FX_COLORREF rgb); #define FXGETFLAG_COLORTYPE(flag) (uint8_t)((flag) >> 8) #define FXGETFLAG_ALPHA_FILL(flag) (uint8_t)(flag) +FX_RECT FXDIB_SwapClipBox(FX_RECT& clip, + int width, + int height, + bool bFlipX, + bool bFlipY); + #endif // CORE_FXGE_FX_DIB_H_ diff --git a/core/fxge/win32/fx_win32_device.cpp b/core/fxge/win32/fx_win32_device.cpp index 811ca11c07..d4abcbe251 100644 --- a/core/fxge/win32/fx_win32_device.cpp +++ b/core/fxge/win32/fx_win32_device.cpp @@ -17,7 +17,7 @@ #include "core/fxge/cfx_windowsdevice.h" #include "core/fxge/dib/cfx_dibextractor.h" #include "core/fxge/dib/cfx_imagerenderer.h" -#include "core/fxge/dib/dib_int.h" +#include "core/fxge/dib/cstretchengine.h" #include "core/fxge/fx_font.h" #include "core/fxge/fx_freetype.h" #include "core/fxge/ge/cfx_folderfontinfo.h" diff --git a/core/fxge/win32/fx_win32_print.cpp b/core/fxge/win32/fx_win32_print.cpp index 084a136d4d..e5df6edd41 100644 --- a/core/fxge/win32/fx_win32_print.cpp +++ b/core/fxge/win32/fx_win32_print.cpp @@ -14,7 +14,7 @@ #include "core/fxge/cfx_windowsdevice.h" #include "core/fxge/dib/cfx_dibextractor.h" #include "core/fxge/dib/cfx_imagerenderer.h" -#include "core/fxge/dib/dib_int.h" +#include "core/fxge/dib/cstretchengine.h" #include "core/fxge/fx_freetype.h" #include "core/fxge/ge/fx_text_int.h" #include "core/fxge/win32/cpsoutput.h" |