| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #ifndef CORE_FXGE_INCLUDE_FX_DIB_H_ | 7 #ifndef CORE_FXGE_INCLUDE_FX_DIB_H_ |
| 8 #define CORE_FXGE_INCLUDE_FX_DIB_H_ | 8 #define CORE_FXGE_INCLUDE_FX_DIB_H_ |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 FXDIB_8bppRgba = 0x208, | 22 FXDIB_8bppRgba = 0x208, |
| 23 FXDIB_8bppCmyk = 0x408, | 23 FXDIB_8bppCmyk = 0x408, |
| 24 FXDIB_8bppCmyka = 0x608, | 24 FXDIB_8bppCmyka = 0x608, |
| 25 FXDIB_Rgb = 0x018, | 25 FXDIB_Rgb = 0x018, |
| 26 FXDIB_Rgba = 0x218, | 26 FXDIB_Rgba = 0x218, |
| 27 FXDIB_Rgb32 = 0x020, | 27 FXDIB_Rgb32 = 0x020, |
| 28 FXDIB_Argb = 0x220, | 28 FXDIB_Argb = 0x220, |
| 29 FXDIB_Cmyk = 0x420, | 29 FXDIB_Cmyk = 0x420, |
| 30 FXDIB_Cmyka = 0x620, | 30 FXDIB_Cmyka = 0x620, |
| 31 }; | 31 }; |
| 32 |
| 32 enum FXDIB_Channel { | 33 enum FXDIB_Channel { |
| 33 FXDIB_Red = 1, | 34 FXDIB_Red = 1, |
| 34 FXDIB_Green, | 35 FXDIB_Green, |
| 35 FXDIB_Blue, | 36 FXDIB_Blue, |
| 36 FXDIB_Cyan, | 37 FXDIB_Cyan, |
| 37 FXDIB_Magenta, | 38 FXDIB_Magenta, |
| 38 FXDIB_Yellow, | 39 FXDIB_Yellow, |
| 39 FXDIB_Black, | 40 FXDIB_Black, |
| 40 FXDIB_Alpha | 41 FXDIB_Alpha |
| 41 }; | 42 }; |
| 43 |
| 42 #define FXDIB_DOWNSAMPLE 0x04 | 44 #define FXDIB_DOWNSAMPLE 0x04 |
| 43 #define FXDIB_INTERPOL 0x20 | 45 #define FXDIB_INTERPOL 0x20 |
| 44 #define FXDIB_BICUBIC_INTERPOL 0x80 | 46 #define FXDIB_BICUBIC_INTERPOL 0x80 |
| 45 #define FXDIB_NOSMOOTH 0x100 | 47 #define FXDIB_NOSMOOTH 0x100 |
| 46 #define FXDIB_BLEND_NORMAL 0 | 48 #define FXDIB_BLEND_NORMAL 0 |
| 47 #define FXDIB_BLEND_MULTIPLY 1 | 49 #define FXDIB_BLEND_MULTIPLY 1 |
| 48 #define FXDIB_BLEND_SCREEN 2 | 50 #define FXDIB_BLEND_SCREEN 2 |
| 49 #define FXDIB_BLEND_OVERLAY 3 | 51 #define FXDIB_BLEND_OVERLAY 3 |
| 50 #define FXDIB_BLEND_DARKEN 4 | 52 #define FXDIB_BLEND_DARKEN 4 |
| 51 #define FXDIB_BLEND_LIGHTEN 5 | 53 #define FXDIB_BLEND_LIGHTEN 5 |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 *((uint8_t*)(dest) + 2) = *((uint8_t*)(src)) | 148 *((uint8_t*)(dest) + 2) = *((uint8_t*)(src)) |
| 147 #define FXARGB_TODIB(argb) (argb) | 149 #define FXARGB_TODIB(argb) (argb) |
| 148 #define FXCMYK_TODIB(cmyk) \ | 150 #define FXCMYK_TODIB(cmyk) \ |
| 149 ((uint8_t)((cmyk) >> 24) | ((uint8_t)((cmyk) >> 16)) << 8 | \ | 151 ((uint8_t)((cmyk) >> 24) | ((uint8_t)((cmyk) >> 16)) << 8 | \ |
| 150 ((uint8_t)((cmyk) >> 8)) << 16 | ((uint8_t)(cmyk) << 24)) | 152 ((uint8_t)((cmyk) >> 8)) << 16 | ((uint8_t)(cmyk) << 24)) |
| 151 #define FXARGB_TOBGRORDERDIB(argb) \ | 153 #define FXARGB_TOBGRORDERDIB(argb) \ |
| 152 ((uint8_t)(argb >> 16) | ((uint8_t)(argb >> 8)) << 8 | \ | 154 ((uint8_t)(argb >> 16) | ((uint8_t)(argb >> 8)) << 8 | \ |
| 153 ((uint8_t)(argb)) << 16 | ((uint8_t)(argb >> 24) << 24)) | 155 ((uint8_t)(argb)) << 16 | ((uint8_t)(argb >> 24) << 24)) |
| 154 #define FXGETFLAG_COLORTYPE(flag) (uint8_t)((flag) >> 8) | 156 #define FXGETFLAG_COLORTYPE(flag) (uint8_t)((flag) >> 8) |
| 155 #define FXGETFLAG_ALPHA_FILL(flag) (uint8_t)(flag) | 157 #define FXGETFLAG_ALPHA_FILL(flag) (uint8_t)(flag) |
| 156 #define FXGETFLAG_ALPHA_STROKE(flag) (uint8_t)((flag) >> 16) | 158 |
| 159 FX_BOOL ConvertBuffer(FXDIB_Format dest_format, |
| 160 uint8_t* dest_buf, |
| 161 int dest_pitch, |
| 162 int width, |
| 163 int height, |
| 164 const CFX_DIBSource* pSrcBitmap, |
| 165 int src_left, |
| 166 int src_top, |
| 167 uint32_t*& pal); |
| 157 | 168 |
| 158 class CFX_DIBSource { | 169 class CFX_DIBSource { |
| 159 public: | 170 public: |
| 160 virtual ~CFX_DIBSource(); | 171 virtual ~CFX_DIBSource(); |
| 161 | 172 |
| 162 int GetWidth() const { return m_Width; } | 173 int GetWidth() const { return m_Width; } |
| 163 int GetHeight() const { return m_Height; } | 174 int GetHeight() const { return m_Height; } |
| 164 | 175 |
| 165 FXDIB_Format GetFormat() const { | 176 FXDIB_Format GetFormat() const { |
| 166 return (FXDIB_Format)(m_AlphaFlag * 0x100 + m_bpp); | 177 return (FXDIB_Format)(m_AlphaFlag * 0x100 + m_bpp); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 197 | 208 |
| 198 void SetPaletteEntry(int index, uint32_t color); | 209 void SetPaletteEntry(int index, uint32_t color); |
| 199 uint32_t GetPaletteArgb(int index) const { return GetPaletteEntry(index); } | 210 uint32_t GetPaletteArgb(int index) const { return GetPaletteEntry(index); } |
| 200 void SetPaletteArgb(int index, uint32_t color) { | 211 void SetPaletteArgb(int index, uint32_t color) { |
| 201 SetPaletteEntry(index, color); | 212 SetPaletteEntry(index, color); |
| 202 } | 213 } |
| 203 | 214 |
| 204 void CopyPalette(const uint32_t* pSrcPal, uint32_t size = 256); | 215 void CopyPalette(const uint32_t* pSrcPal, uint32_t size = 256); |
| 205 | 216 |
| 206 CFX_DIBitmap* Clone(const FX_RECT* pClip = nullptr) const; | 217 CFX_DIBitmap* Clone(const FX_RECT* pClip = nullptr) const; |
| 207 CFX_DIBitmap* CloneConvert(FXDIB_Format format, | 218 CFX_DIBitmap* CloneConvert(FXDIB_Format format) const; |
| 208 const FX_RECT* pClip = nullptr, | |
| 209 void* pIccTransform = nullptr) const; | |
| 210 | 219 |
| 211 CFX_DIBitmap* StretchTo(int dest_width, | 220 CFX_DIBitmap* StretchTo(int dest_width, |
| 212 int dest_height, | 221 int dest_height, |
| 213 uint32_t flags = 0, | 222 uint32_t flags = 0, |
| 214 const FX_RECT* pClip = nullptr) const; | 223 const FX_RECT* pClip = nullptr) const; |
| 215 CFX_DIBitmap* TransformTo(const CFX_Matrix* pMatrix, | 224 CFX_DIBitmap* TransformTo(const CFX_Matrix* pMatrix, |
| 216 int& left, | 225 int& left, |
| 217 int& top, | 226 int& top, |
| 218 uint32_t flags = 0, | 227 uint32_t flags = 0, |
| 219 const FX_RECT* pClip = nullptr) const; | 228 const FX_RECT* pClip = nullptr) const; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 void DownSampleScanline(int line, | 285 void DownSampleScanline(int line, |
| 277 uint8_t* dest_scan, | 286 uint8_t* dest_scan, |
| 278 int dest_bpp, | 287 int dest_bpp, |
| 279 int dest_width, | 288 int dest_width, |
| 280 FX_BOOL bFlipX, | 289 FX_BOOL bFlipX, |
| 281 int clip_left, | 290 int clip_left, |
| 282 int clip_width) const override; | 291 int clip_width) const override; |
| 283 | 292 |
| 284 void TakeOver(CFX_DIBitmap* pSrcBitmap); | 293 void TakeOver(CFX_DIBitmap* pSrcBitmap); |
| 285 | 294 |
| 286 FX_BOOL ConvertFormat(FXDIB_Format format, void* pIccTransform = nullptr); | 295 FX_BOOL ConvertFormat(FXDIB_Format format); |
| 287 | 296 |
| 288 void Clear(uint32_t color); | 297 void Clear(uint32_t color); |
| 289 | 298 |
| 290 uint32_t GetPixel(int x, int y) const; | 299 uint32_t GetPixel(int x, int y) const; |
| 291 | 300 |
| 292 void SetPixel(int x, int y, uint32_t color); | 301 void SetPixel(int x, int y, uint32_t color); |
| 293 | 302 |
| 294 FX_BOOL LoadChannel(FXDIB_Channel destChannel, | 303 FX_BOOL LoadChannel(FXDIB_Channel destChannel, |
| 295 const CFX_DIBSource* pSrcBitmap, | 304 const CFX_DIBSource* pSrcBitmap, |
| 296 FXDIB_Channel srcChannel); | 305 FXDIB_Channel srcChannel); |
| 297 | 306 |
| 298 FX_BOOL LoadChannel(FXDIB_Channel destChannel, int value); | 307 FX_BOOL LoadChannel(FXDIB_Channel destChannel, int value); |
| 299 | 308 |
| 300 FX_BOOL MultiplyAlpha(int alpha); | 309 FX_BOOL MultiplyAlpha(int alpha); |
| 301 | 310 |
| 302 FX_BOOL MultiplyAlpha(const CFX_DIBSource* pAlphaMask); | 311 FX_BOOL MultiplyAlpha(const CFX_DIBSource* pAlphaMask); |
| 303 | 312 |
| 304 FX_BOOL TransferBitmap(int dest_left, | 313 FX_BOOL TransferBitmap(int dest_left, |
| 305 int dest_top, | 314 int dest_top, |
| 306 int width, | 315 int width, |
| 307 int height, | 316 int height, |
| 308 const CFX_DIBSource* pSrcBitmap, | 317 const CFX_DIBSource* pSrcBitmap, |
| 309 int src_left, | 318 int src_left, |
| 310 int src_top, | 319 int src_top); |
| 311 void* pIccTransform = nullptr); | |
| 312 | 320 |
| 313 FX_BOOL CompositeBitmap(int dest_left, | 321 FX_BOOL CompositeBitmap(int dest_left, |
| 314 int dest_top, | 322 int dest_top, |
| 315 int width, | 323 int width, |
| 316 int height, | 324 int height, |
| 317 const CFX_DIBSource* pSrcBitmap, | 325 const CFX_DIBSource* pSrcBitmap, |
| 318 int src_left, | 326 int src_left, |
| 319 int src_top, | 327 int src_top, |
| 320 int blend_type = FXDIB_BLEND_NORMAL, | 328 int blend_type = FXDIB_BLEND_NORMAL, |
| 321 const CFX_ClipRgn* pClipRgn = nullptr, | 329 const CFX_ClipRgn* pClipRgn = nullptr, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 | 367 |
| 360 protected: | 368 protected: |
| 361 FX_BOOL GetGrayData(void* pIccTransform = nullptr); | 369 FX_BOOL GetGrayData(void* pIccTransform = nullptr); |
| 362 | 370 |
| 363 uint8_t* m_pBuffer; | 371 uint8_t* m_pBuffer; |
| 364 FX_BOOL m_bExtBuf; | 372 FX_BOOL m_bExtBuf; |
| 365 }; | 373 }; |
| 366 | 374 |
| 367 class CFX_DIBExtractor { | 375 class CFX_DIBExtractor { |
| 368 public: | 376 public: |
| 369 CFX_DIBExtractor(const CFX_DIBSource* pSrc); | 377 explicit CFX_DIBExtractor(const CFX_DIBSource* pSrc); |
| 370 | |
| 371 ~CFX_DIBExtractor(); | 378 ~CFX_DIBExtractor(); |
| 372 | 379 |
| 373 operator CFX_DIBitmap*() { return m_pBitmap; } | 380 operator CFX_DIBitmap*() { return m_pBitmap; } |
| 374 | 381 |
| 375 private: | 382 private: |
| 376 CFX_DIBitmap* m_pBitmap; | 383 CFX_DIBitmap* m_pBitmap; |
| 377 }; | 384 }; |
| 378 | 385 |
| 379 typedef CFX_CountRef<CFX_DIBitmap> CFX_DIBitmapRef; | 386 typedef CFX_CountRef<CFX_DIBitmap> CFX_DIBitmapRef; |
| 380 class CFX_FilteredDIB : public CFX_DIBSource { | 387 class CFX_FilteredDIB : public CFX_DIBSource { |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 int m_Status; | 665 int m_Status; |
| 659 FX_RECT m_ClipBox; | 666 FX_RECT m_ClipBox; |
| 660 uint32_t m_Flags; | 667 uint32_t m_Flags; |
| 661 int m_AlphaFlag; | 668 int m_AlphaFlag; |
| 662 void* m_pIccTransform; | 669 void* m_pIccTransform; |
| 663 FX_BOOL m_bRgbByteOrder; | 670 FX_BOOL m_bRgbByteOrder; |
| 664 int m_BlendType; | 671 int m_BlendType; |
| 665 }; | 672 }; |
| 666 | 673 |
| 667 #endif // CORE_FXGE_INCLUDE_FX_DIB_H_ | 674 #endif // CORE_FXGE_INCLUDE_FX_DIB_H_ |
| OLD | NEW |