• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 class CPDF_FixedMatrix : public CFX_Object
8 {
9 public:
CPDF_FixedMatrix(const CFX_AffineMatrix & src,int bits)10     CPDF_FixedMatrix(const CFX_AffineMatrix& src, int bits)
11     {
12         base = 1 << bits;
13         a = FXSYS_round(src.a * base);
14         b = FXSYS_round(src.b * base);
15         c = FXSYS_round(src.c * base);
16         d = FXSYS_round(src.d * base);
17         e = FXSYS_round(src.e * base);
18         f = FXSYS_round(src.f * base);
19     }
Transform(int x,int y,int & x1,int & y1)20     inline void	Transform(int x, int y, int& x1, int& y1)
21     {
22         x1 = (a * x + c * y + e + base / 2) / base;
23         y1 = (b * x + d * y + f + base / 2) / base;
24     }
25     int		a, b, c, d, e, f;
26     int		base;
27 };
28 #define FPDF_HUGE_IMAGE_SIZE	60000000
29 struct PixelWeight {
30     int		m_SrcStart;
31     int		m_SrcEnd;
32     int		m_Weights[1];
33 };
34 class CWeightTable : public CFX_Object
35 {
36 public:
CWeightTable()37     CWeightTable()
38     {
39         m_pWeightTables = NULL;
40     }
~CWeightTable()41     ~CWeightTable()
42     {
43         if(m_pWeightTables) {
44             FX_Free(m_pWeightTables);
45         }
46         m_pWeightTables = NULL;
47     }
48     void			Calc(int dest_len, int dest_min, int dest_max, int src_len, int src_min, int src_max, int flags);
GetPixelWeight(int pixel)49     PixelWeight*	GetPixelWeight(int pixel)
50     {
51         return (PixelWeight*)(m_pWeightTables + (pixel - m_DestMin) * m_ItemSize);
52     }
53     int				m_DestMin, m_ItemSize;
54     FX_LPBYTE		m_pWeightTables;
55 };
56 class CStretchEngine : public CFX_Object
57 {
58 public:
59     CStretchEngine(IFX_ScanlineComposer* pDestBitmap, FXDIB_Format dest_format,
60                    int dest_width, int dest_height, const FX_RECT& clip_rect,
61                    const CFX_DIBSource* pSrcBitmap, int flags);
62     ~CStretchEngine();
63     FX_BOOL		Continue(IFX_Pause* pPause);
64 public:
65     FXDIB_Format m_DestFormat;
66     int		m_DestBpp, m_SrcBpp, m_bHasAlpha;
67     IFX_ScanlineComposer*	m_pDestBitmap;
68     int		m_DestWidth, m_DestHeight;
69     FX_RECT	m_DestClip;
70     FX_LPBYTE	m_pDestScanline;
71     FX_LPBYTE   m_pDestMaskScanline;
72     FX_RECT	m_SrcClip;
73     const CFX_DIBSource*	m_pSource;
74     FX_DWORD*	m_pSrcPalette;
75     int		m_SrcWidth, m_SrcHeight;
76     int		m_SrcPitch, m_InterPitch;
77     int m_ExtraMaskPitch;
78     unsigned char*	m_pInterBuf;
79     unsigned char*	m_pExtraAlphaBuf;
80     int		m_TransMethod;
81     int 	m_Flags;
82     CWeightTable	m_WeightTable;
83     int		m_CurRow;
84     FX_BOOL	StartStretchHorz();
85     FX_BOOL	ContinueStretchHorz(IFX_Pause* pPause);
86     void	StretchVert();
87     int		m_State;
88 };
89