Home | History | Annotate | Download | only in dib
      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 #ifndef CORE_FXGE_DIB_DIB_INT_H_
      8 #define CORE_FXGE_DIB_DIB_INT_H_
      9 
     10 #include <stdint.h>
     11 
     12 #include "core/fxcrt/fx_coordinates.h"
     13 #include "core/fxge/fx_dib.h"
     14 
     15 class IFX_ScanlineComposer;
     16 
     17 extern const int16_t SDP_Table[513];
     18 
     19 class CPDF_FixedMatrix {
     20  public:
     21   CPDF_FixedMatrix(const CFX_Matrix& src, int bits) {
     22     base = 1 << bits;
     23     a = FXSYS_round(src.a * base);
     24     b = FXSYS_round(src.b * base);
     25     c = FXSYS_round(src.c * base);
     26     d = FXSYS_round(src.d * base);
     27     e = FXSYS_round(src.e * base);
     28     f = FXSYS_round(src.f * base);
     29   }
     30   inline void Transform(int x, int y, int& x1, int& y1) {
     31     x1 = (a * x + c * y + e + base / 2) / base;
     32     y1 = (b * x + d * y + f + base / 2) / base;
     33   }
     34   int a, b, c, d, e, f;
     35   int base;
     36 };
     37 #define FPDF_HUGE_IMAGE_SIZE 60000000
     38 struct PixelWeight {
     39   int m_SrcStart;
     40   int m_SrcEnd;
     41   int m_Weights[1];
     42 };
     43 
     44 class CWeightTable {
     45  public:
     46   CWeightTable();
     47   ~CWeightTable();
     48 
     49   bool Calc(int dest_len,
     50             int dest_min,
     51             int dest_max,
     52             int src_len,
     53             int src_min,
     54             int src_max,
     55             int flags);
     56   PixelWeight* GetPixelWeight(int pixel) const;
     57   int* GetValueFromPixelWeight(PixelWeight* pWeight, int index) const;
     58   size_t GetPixelWeightSize() const;
     59 
     60  private:
     61   int m_DestMin;
     62   int m_ItemSize;
     63   uint8_t* m_pWeightTables;
     64   size_t m_dwWeightTablesSize;
     65 };
     66 
     67 class CStretchEngine {
     68  public:
     69   CStretchEngine(IFX_ScanlineComposer* pDestBitmap,
     70                  FXDIB_Format dest_format,
     71                  int dest_width,
     72                  int dest_height,
     73                  const FX_RECT& clip_rect,
     74                  const CFX_DIBSource* pSrcBitmap,
     75                  int flags);
     76   ~CStretchEngine();
     77 
     78   bool Continue(IFX_Pause* pPause);
     79 
     80   bool StartStretchHorz();
     81   bool ContinueStretchHorz(IFX_Pause* pPause);
     82   void StretchVert();
     83 
     84   FXDIB_Format m_DestFormat;
     85   int m_DestBpp;
     86   int m_SrcBpp;
     87   int m_bHasAlpha;
     88   IFX_ScanlineComposer* m_pDestBitmap;
     89   int m_DestWidth, m_DestHeight;
     90   FX_RECT m_DestClip;
     91   uint8_t* m_pDestScanline;
     92   uint8_t* m_pDestMaskScanline;
     93   FX_RECT m_SrcClip;
     94   const CFX_DIBSource* m_pSource;
     95   uint32_t* m_pSrcPalette;
     96   int m_SrcWidth;
     97   int m_SrcHeight;
     98   int m_SrcPitch;
     99   int m_InterPitch;
    100   int m_ExtraMaskPitch;
    101   uint8_t* m_pInterBuf;
    102   uint8_t* m_pExtraAlphaBuf;
    103   int m_TransMethod;
    104   int m_Flags;
    105   CWeightTable m_WeightTable;
    106   int m_CurRow;
    107   int m_State;
    108 };
    109 
    110 FX_RECT FXDIB_SwapClipBox(FX_RECT& clip,
    111                           int width,
    112                           int height,
    113                           bool bFlipX,
    114                           bool bFlipY);
    115 
    116 #endif  // CORE_FXGE_DIB_DIB_INT_H_
    117