• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2017 The PDFium Authors
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 #ifndef CORE_FXGE_DIB_CFX_IMAGETRANSFORMER_H_
8 #define CORE_FXGE_DIB_CFX_IMAGETRANSFORMER_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_coordinates.h"
13 #include "core/fxcrt/retain_ptr.h"
14 #include "core/fxge/dib/cfx_bitmapstorer.h"
15 
16 class CFX_DIBBase;
17 class CFX_DIBitmap;
18 class CFX_ImageStretcher;
19 class PauseIndicatorIface;
20 
21 class CFX_ImageTransformer {
22  public:
23   struct BilinearData {
24     int res_x;
25     int res_y;
26     int src_col_l;
27     int src_row_l;
28     int src_col_r;
29     int src_row_r;
30     int row_offset_l;
31     int row_offset_r;
32   };
33 
34   struct CalcData {
35     CFX_DIBitmap* bitmap;
36     const CFX_Matrix& matrix;
37     const uint8_t* buf;
38     uint32_t pitch;
39   };
40 
41   CFX_ImageTransformer(const RetainPtr<const CFX_DIBBase>& pSrc,
42                        const CFX_Matrix& matrix,
43                        const FXDIB_ResampleOptions& options,
44                        const FX_RECT* pClip);
45   ~CFX_ImageTransformer();
46 
47   bool Continue(PauseIndicatorIface* pPause);
48 
result()49   const FX_RECT& result() const { return m_result; }
50   RetainPtr<CFX_DIBitmap> DetachBitmap();
51 
52  private:
53   enum StretchType {
54     kNone,
55     kNormal,
56     kRotate,
57     kOther,
58   };
59 
60   void ContinueRotate(PauseIndicatorIface* pPause);
61   void ContinueOther(PauseIndicatorIface* pPause);
62 
63   void CalcAlpha(const CalcData& calc_data);
64   void CalcMono(const CalcData& calc_data);
65   void CalcColor(const CalcData& calc_data, FXDIB_Format format, int Bpp);
66 
67   RetainPtr<const CFX_DIBBase> const m_pSrc;
68   const CFX_Matrix m_matrix;
69   FX_RECT m_StretchClip;
70   FX_RECT m_result;
71   CFX_Matrix m_dest2stretch;
72   std::unique_ptr<CFX_ImageStretcher> m_Stretcher;
73   CFX_BitmapStorer m_Storer;
74   const FXDIB_ResampleOptions m_ResampleOptions;
75   StretchType m_type = kNone;
76 };
77 
78 #endif  // CORE_FXGE_DIB_CFX_IMAGETRANSFORMER_H_
79