Chromium Code Reviews| 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_INCLUDE_FXCODEC_FX_CODEC_H_ | 7 #ifndef CORE_INCLUDE_FXCODEC_FX_CODEC_H_ |
| 8 #define CORE_INCLUDE_FXCODEC_FX_CODEC_H_ | 8 #define CORE_INCLUDE_FXCODEC_FX_CODEC_H_ |
| 9 | 9 |
| 10 #ifdef PDF_ENABLE_XFA | |
| 10 #include <map> | 11 #include <map> |
|
Lei Zhang
2015/11/24 23:36:04
Can we have a single #ifdef PDF_ENABLE_XFA block f
Tom Sepez
2015/11/25 18:51:45
Yep, will fix in next CL.
| |
| 12 #endif | |
| 11 #include <vector> | 13 #include <vector> |
| 12 | 14 |
| 13 #include "core/include/fxcrt/fx_basic.h" | 15 #include "core/include/fxcrt/fx_basic.h" |
| 14 #include "fx_codec_def.h" | 16 #include "fx_codec_def.h" |
| 15 #include "third_party/base/nonstd_unique_ptr.h" | 17 #include "third_party/base/nonstd_unique_ptr.h" |
| 16 | 18 |
| 19 #ifdef PDF_ENABLE_XFA | |
| 17 #include "../fxcrt/fx_coordinates.h" // For FX_RECT. | 20 #include "../fxcrt/fx_coordinates.h" // For FX_RECT. |
| 18 | 21 |
| 22 #endif | |
| 19 class CFX_DIBSource; | 23 class CFX_DIBSource; |
| 20 class CJPX_Decoder; | 24 class CJPX_Decoder; |
| 21 class CPDF_PrivateData; | 25 class CPDF_PrivateData; |
| 22 class CPDF_StreamAcc; | 26 class CPDF_StreamAcc; |
| 27 #ifndef PDF_ENABLE_XFA | |
|
Lei Zhang
2015/11/24 23:36:04
Ditto, move these to the separate block below.
Tom Sepez
2015/11/25 18:51:45
Acknowledged.
| |
| 28 class ICodec_ScanlineDecoder; | |
| 29 #endif | |
| 23 class ICodec_BasicModule; | 30 class ICodec_BasicModule; |
| 24 class ICodec_FaxModule; | 31 class ICodec_FaxModule; |
| 32 #ifdef PDF_ENABLE_XFA | |
| 25 class ICodec_FlateModule; | 33 class ICodec_FlateModule; |
| 26 class ICodec_IccModule; | 34 class ICodec_IccModule; |
| 27 class ICodec_Jbig2Encoder; | 35 class ICodec_Jbig2Encoder; |
| 28 class ICodec_Jbig2Module; | 36 class ICodec_Jbig2Module; |
| 37 #endif | |
| 29 class ICodec_JpegModule; | 38 class ICodec_JpegModule; |
| 30 class ICodec_JpxModule; | 39 class ICodec_JpxModule; |
| 40 #ifndef PDF_ENABLE_XFA | |
| 41 class ICodec_Jbig2Module; | |
| 42 class ICodec_IccModule; | |
| 43 class ICodec_FlateModule; | |
| 44 class ICodec_Jbig2Encoder; | |
| 45 #endif | |
| 31 class ICodec_ScanlineDecoder; | 46 class ICodec_ScanlineDecoder; |
| 32 | 47 |
| 48 #ifdef PDF_ENABLE_XFA | |
| 33 class ICodec_BmpModule; | 49 class ICodec_BmpModule; |
| 34 class ICodec_GifModule; | 50 class ICodec_GifModule; |
| 35 class ICodec_PngModule; | 51 class ICodec_PngModule; |
| 36 class ICodec_ProgressiveDecoder; | 52 class ICodec_ProgressiveDecoder; |
| 37 class ICodec_TiffModule; | 53 class ICodec_TiffModule; |
| 38 | 54 |
| 39 class CFX_DIBAttribute { | 55 class CFX_DIBAttribute { |
| 40 public: | 56 public: |
| 41 CFX_DIBAttribute(); | 57 CFX_DIBAttribute(); |
| 42 ~CFX_DIBAttribute(); | 58 ~CFX_DIBAttribute(); |
| 43 | 59 |
| 44 int32_t m_nXDPI; | 60 int32_t m_nXDPI; |
| 45 int32_t m_nYDPI; | 61 int32_t m_nYDPI; |
| 46 FX_FLOAT m_fAspectRatio; | 62 FX_FLOAT m_fAspectRatio; |
| 47 FX_WORD m_wDPIUnit; | 63 FX_WORD m_wDPIUnit; |
| 48 CFX_ByteString m_strAuthor; | 64 CFX_ByteString m_strAuthor; |
| 49 uint8_t m_strTime[20]; | 65 uint8_t m_strTime[20]; |
| 50 int32_t m_nGifLeft; | 66 int32_t m_nGifLeft; |
| 51 int32_t m_nGifTop; | 67 int32_t m_nGifTop; |
| 52 FX_DWORD* m_pGifLocalPalette; | 68 FX_DWORD* m_pGifLocalPalette; |
| 53 FX_DWORD m_nGifLocalPalNum; | 69 FX_DWORD m_nGifLocalPalNum; |
| 54 int32_t m_nBmpCompressType; | 70 int32_t m_nBmpCompressType; |
| 55 std::map<FX_DWORD, void*> m_Exif; | 71 std::map<FX_DWORD, void*> m_Exif; |
| 56 }; | 72 }; |
| 57 | 73 |
| 74 #endif | |
| 58 class CCodec_ModuleMgr { | 75 class CCodec_ModuleMgr { |
| 59 public: | 76 public: |
| 60 CCodec_ModuleMgr(); | 77 CCodec_ModuleMgr(); |
| 61 | 78 |
| 62 ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); } | 79 ICodec_BasicModule* GetBasicModule() const { return m_pBasicModule.get(); } |
| 63 ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); } | 80 ICodec_FaxModule* GetFaxModule() const { return m_pFaxModule.get(); } |
| 64 ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); } | 81 ICodec_JpegModule* GetJpegModule() const { return m_pJpegModule.get(); } |
| 65 ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); } | 82 ICodec_JpxModule* GetJpxModule() const { return m_pJpxModule.get(); } |
| 66 ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); } | 83 ICodec_Jbig2Module* GetJbig2Module() const { return m_pJbig2Module.get(); } |
| 67 ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); } | 84 ICodec_IccModule* GetIccModule() const { return m_pIccModule.get(); } |
| 68 ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } | 85 ICodec_FlateModule* GetFlateModule() const { return m_pFlateModule.get(); } |
| 69 | 86 |
| 87 #ifdef PDF_ENABLE_XFA | |
| 70 ICodec_ProgressiveDecoder* CreateProgressiveDecoder(); | 88 ICodec_ProgressiveDecoder* CreateProgressiveDecoder(); |
| 71 ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); } | 89 ICodec_PngModule* GetPngModule() const { return m_pPngModule.get(); } |
| 72 ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); } | 90 ICodec_GifModule* GetGifModule() const { return m_pGifModule.get(); } |
| 73 ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); } | 91 ICodec_BmpModule* GetBmpModule() const { return m_pBmpModule.get(); } |
| 74 ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); } | 92 ICodec_TiffModule* GetTiffModule() const { return m_pTiffModule.get(); } |
| 75 | 93 |
| 94 #endif | |
| 76 protected: | 95 protected: |
| 77 nonstd::unique_ptr<ICodec_BasicModule> m_pBasicModule; | 96 nonstd::unique_ptr<ICodec_BasicModule> m_pBasicModule; |
| 78 nonstd::unique_ptr<ICodec_FaxModule> m_pFaxModule; | 97 nonstd::unique_ptr<ICodec_FaxModule> m_pFaxModule; |
| 79 nonstd::unique_ptr<ICodec_JpegModule> m_pJpegModule; | 98 nonstd::unique_ptr<ICodec_JpegModule> m_pJpegModule; |
| 80 nonstd::unique_ptr<ICodec_JpxModule> m_pJpxModule; | 99 nonstd::unique_ptr<ICodec_JpxModule> m_pJpxModule; |
| 81 nonstd::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module; | 100 nonstd::unique_ptr<ICodec_Jbig2Module> m_pJbig2Module; |
| 82 nonstd::unique_ptr<ICodec_IccModule> m_pIccModule; | 101 nonstd::unique_ptr<ICodec_IccModule> m_pIccModule; |
| 83 nonstd::unique_ptr<ICodec_FlateModule> m_pFlateModule; | 102 nonstd::unique_ptr<ICodec_FlateModule> m_pFlateModule; |
| 103 #ifdef PDF_ENABLE_XFA | |
|
Lei Zhang
2015/11/24 23:36:04
blink line above, not below.
| |
| 84 | 104 |
| 85 nonstd::unique_ptr<ICodec_PngModule> m_pPngModule; | 105 nonstd::unique_ptr<ICodec_PngModule> m_pPngModule; |
| 86 nonstd::unique_ptr<ICodec_GifModule> m_pGifModule; | 106 nonstd::unique_ptr<ICodec_GifModule> m_pGifModule; |
| 87 nonstd::unique_ptr<ICodec_BmpModule> m_pBmpModule; | 107 nonstd::unique_ptr<ICodec_BmpModule> m_pBmpModule; |
| 88 nonstd::unique_ptr<ICodec_TiffModule> m_pTiffModule; | 108 nonstd::unique_ptr<ICodec_TiffModule> m_pTiffModule; |
| 109 #endif | |
| 89 }; | 110 }; |
| 90 class ICodec_BasicModule { | 111 class ICodec_BasicModule { |
| 91 public: | 112 public: |
| 92 virtual ~ICodec_BasicModule() {} | 113 virtual ~ICodec_BasicModule() {} |
| 93 virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf, | 114 virtual FX_BOOL RunLengthEncode(const uint8_t* src_buf, |
| 94 FX_DWORD src_size, | 115 FX_DWORD src_size, |
| 95 uint8_t*& dest_buf, | 116 uint8_t*& dest_buf, |
| 96 FX_DWORD& dest_size) = 0; | 117 FX_DWORD& dest_size) = 0; |
| 97 virtual FX_BOOL A85Encode(const uint8_t* src_buf, | 118 virtual FX_BOOL A85Encode(const uint8_t* src_buf, |
| 98 FX_DWORD src_size, | 119 FX_DWORD src_size, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 | 243 |
| 223 virtual void Finish(void* pContext) = 0; | 244 virtual void Finish(void* pContext) = 0; |
| 224 | 245 |
| 225 virtual void Input(void* pContext, | 246 virtual void Input(void* pContext, |
| 226 const uint8_t* src_buf, | 247 const uint8_t* src_buf, |
| 227 FX_DWORD src_size) = 0; | 248 FX_DWORD src_size) = 0; |
| 228 | 249 |
| 229 virtual int ReadHeader(void* pContext, | 250 virtual int ReadHeader(void* pContext, |
| 230 int* width, | 251 int* width, |
| 231 int* height, | 252 int* height, |
| 253 #ifndef PDF_ENABLE_XFA | |
|
Lei Zhang
2015/11/24 23:36:04
#ifdef PDF_ENABLE_XFA
... nComps,\n...pAttribute..
Tom Sepez
2015/11/25 00:12:06
Making this purely "additive" (by that I mean no "
| |
| 254 int* nComps) = 0; | |
| 255 #else | |
| 232 int* nComps, | 256 int* nComps, |
| 233 CFX_DIBAttribute* pAttribute) = 0; | 257 CFX_DIBAttribute* pAttribute) = 0; |
| 258 #endif | |
| 234 | 259 |
| 235 virtual int StartScanline(void* pContext, int down_scale) = 0; | 260 virtual int StartScanline(void* pContext, int down_scale) = 0; |
| 236 | 261 |
| 237 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0; | 262 virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) = 0; |
| 238 | 263 |
| 239 virtual FX_DWORD GetAvailInput(void* pContext, | 264 virtual FX_DWORD GetAvailInput(void* pContext, |
| 240 uint8_t** avail_buf_ptr = NULL) = 0; | 265 uint8_t** avail_buf_ptr = NULL) = 0; |
| 241 }; | 266 }; |
| 242 | 267 |
| 243 class ICodec_JpxModule { | 268 class ICodec_JpxModule { |
| 244 public: | 269 public: |
| 245 virtual ~ICodec_JpxModule() {} | 270 virtual ~ICodec_JpxModule() {} |
| 246 | 271 |
| 247 virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf, | 272 virtual CJPX_Decoder* CreateDecoder(const uint8_t* src_buf, |
| 248 FX_DWORD src_size, | 273 FX_DWORD src_size, |
| 249 bool use_colorspace) = 0; | 274 bool use_colorspace) = 0; |
| 250 | 275 |
| 251 virtual void GetImageInfo(CJPX_Decoder* pDecoder, | 276 virtual void GetImageInfo(CJPX_Decoder* pDecoder, |
| 252 FX_DWORD* width, | 277 FX_DWORD* width, |
| 253 FX_DWORD* height, | 278 FX_DWORD* height, |
| 254 FX_DWORD* components) = 0; | 279 FX_DWORD* components) = 0; |
| 255 | 280 |
| 256 virtual bool Decode(CJPX_Decoder* pDecoder, | 281 virtual bool Decode(CJPX_Decoder* pDecoder, |
| 257 uint8_t* dest_data, | 282 uint8_t* dest_data, |
| 258 int pitch, | 283 int pitch, |
| 259 const std::vector<uint8_t>& offsets) = 0; | 284 const std::vector<uint8_t>& offsets) = 0; |
| 260 | 285 |
| 261 virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0; | 286 virtual void DestroyDecoder(CJPX_Decoder* pDecoder) = 0; |
| 262 }; | 287 }; |
| 288 #ifdef PDF_ENABLE_XFA | |
| 263 class ICodec_PngModule { | 289 class ICodec_PngModule { |
| 264 public: | 290 public: |
| 265 virtual ~ICodec_PngModule() {} | 291 virtual ~ICodec_PngModule() {} |
| 266 | 292 |
| 267 virtual void* Start(void* pModule) = 0; | 293 virtual void* Start(void* pModule) = 0; |
| 268 | 294 |
| 269 virtual void Finish(void* pContext) = 0; | 295 virtual void Finish(void* pContext) = 0; |
| 270 | 296 |
| 271 virtual FX_BOOL Input(void* pContext, | 297 virtual FX_BOOL Input(void* pContext, |
| 272 const uint8_t* src_buf, | 298 const uint8_t* src_buf, |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 380 FX_DWORD& width, | 406 FX_DWORD& width, |
| 381 FX_DWORD& height, | 407 FX_DWORD& height, |
| 382 FX_DWORD& comps, | 408 FX_DWORD& comps, |
| 383 FX_DWORD& bpc, | 409 FX_DWORD& bpc, |
| 384 CFX_DIBAttribute* pAttribute) = 0; | 410 CFX_DIBAttribute* pAttribute) = 0; |
| 385 | 411 |
| 386 virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) = 0; | 412 virtual FX_BOOL Decode(void* ctx, class CFX_DIBitmap* pDIBitmap) = 0; |
| 387 | 413 |
| 388 virtual void DestroyDecoder(void* ctx) = 0; | 414 virtual void DestroyDecoder(void* ctx) = 0; |
| 389 }; | 415 }; |
| 416 #endif | |
|
Lei Zhang
2015/11/24 23:36:04
How about adding // PDF_ENABLE_XFA if the block is
| |
| 390 | 417 |
| 391 class ICodec_Jbig2Module { | 418 class ICodec_Jbig2Module { |
| 392 public: | 419 public: |
| 393 virtual ~ICodec_Jbig2Module() {} | 420 virtual ~ICodec_Jbig2Module() {} |
| 394 | 421 |
| 395 virtual void* CreateJbig2Context() = 0; | 422 virtual void* CreateJbig2Context() = 0; |
| 396 | 423 |
| 397 virtual FXCODEC_STATUS StartDecode(void* pJbig2Context, | 424 virtual FXCODEC_STATUS StartDecode(void* pJbig2Context, |
| 398 CFX_PrivateData* pPrivateData, | 425 CFX_PrivateData* pPrivateData, |
| 399 FX_DWORD width, | 426 FX_DWORD width, |
| 400 FX_DWORD height, | 427 FX_DWORD height, |
| 401 CPDF_StreamAcc* src_stream, | 428 CPDF_StreamAcc* src_stream, |
| 402 CPDF_StreamAcc* global_stream, | 429 CPDF_StreamAcc* global_stream, |
| 403 uint8_t* dest_buf, | 430 uint8_t* dest_buf, |
| 404 FX_DWORD dest_pitch, | 431 FX_DWORD dest_pitch, |
| 405 IFX_Pause* pPause) = 0; | 432 IFX_Pause* pPause) = 0; |
| 406 | 433 |
| 407 virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content, | 434 virtual FXCODEC_STATUS ContinueDecode(void* pJbig2Content, |
| 408 IFX_Pause* pPause) = 0; | 435 IFX_Pause* pPause) = 0; |
| 409 virtual void DestroyJbig2Context(void* pJbig2Content) = 0; | 436 virtual void DestroyJbig2Context(void* pJbig2Content) = 0; |
| 410 }; | 437 }; |
| 438 #ifdef PDF_ENABLE_XFA | |
| 411 class ICodec_ProgressiveDecoder { | 439 class ICodec_ProgressiveDecoder { |
| 412 public: | 440 public: |
| 413 virtual ~ICodec_ProgressiveDecoder() {} | 441 virtual ~ICodec_ProgressiveDecoder() {} |
| 414 | 442 |
| 415 virtual FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile, | 443 virtual FXCODEC_STATUS LoadImageInfo(IFX_FileRead* pFile, |
| 416 FXCODEC_IMAGE_TYPE imageType, | 444 FXCODEC_IMAGE_TYPE imageType, |
| 417 CFX_DIBAttribute* pAttribute) = 0; | 445 CFX_DIBAttribute* pAttribute) = 0; |
| 418 | 446 |
| 419 virtual FXCODEC_IMAGE_TYPE GetType() const = 0; | 447 virtual FXCODEC_IMAGE_TYPE GetType() const = 0; |
| 420 virtual int32_t GetWidth() const = 0; | 448 virtual int32_t GetWidth() const = 0; |
| 421 virtual int32_t GetHeight() const = 0; | 449 virtual int32_t GetHeight() const = 0; |
| 422 virtual int32_t GetNumComponents() const = 0; | 450 virtual int32_t GetNumComponents() const = 0; |
| 423 virtual int32_t GetBPC() const = 0; | 451 virtual int32_t GetBPC() const = 0; |
| 424 | 452 |
| 425 virtual void SetClipBox(FX_RECT* clip) = 0; | 453 virtual void SetClipBox(FX_RECT* clip) = 0; |
| 426 | 454 |
| 427 virtual FXCODEC_STATUS GetFrames(int32_t& frames, | 455 virtual FXCODEC_STATUS GetFrames(int32_t& frames, |
| 428 IFX_Pause* pPause = NULL) = 0; | 456 IFX_Pause* pPause = NULL) = 0; |
| 429 | 457 |
| 430 virtual FXCODEC_STATUS StartDecode(class CFX_DIBitmap* pDIBitmap, | 458 virtual FXCODEC_STATUS StartDecode(class CFX_DIBitmap* pDIBitmap, |
| 431 int32_t start_x, | 459 int32_t start_x, |
| 432 int32_t start_y, | 460 int32_t start_y, |
| 433 int32_t size_x, | 461 int32_t size_x, |
| 434 int32_t size_y, | 462 int32_t size_y, |
| 435 int32_t frames = 0, | 463 int32_t frames = 0, |
| 436 FX_BOOL bInterpol = TRUE) = 0; | 464 FX_BOOL bInterpol = TRUE) = 0; |
| 437 | 465 |
| 438 virtual FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = NULL) = 0; | 466 virtual FXCODEC_STATUS ContinueDecode(IFX_Pause* pPause = NULL) = 0; |
| 439 }; | 467 }; |
| 468 #endif | |
| 440 class ICodec_Jbig2Encoder { | 469 class ICodec_Jbig2Encoder { |
| 441 public: | 470 public: |
| 442 virtual ~ICodec_Jbig2Encoder() {} | 471 virtual ~ICodec_Jbig2Encoder() {} |
| 443 }; | 472 }; |
| 444 class ICodec_IccModule { | 473 class ICodec_IccModule { |
| 445 public: | 474 public: |
| 446 typedef enum { | 475 typedef enum { |
| 447 IccCS_Unknown = 0, | 476 IccCS_Unknown = 0, |
| 448 IccCS_XYZ, | 477 IccCS_XYZ, |
| 449 IccCS_Lab, | 478 IccCS_Lab, |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 530 FX_BOOL MD5ComputeID(const void* buf, FX_DWORD dwSize, uint8_t ID[16]); | 559 FX_BOOL MD5ComputeID(const void* buf, FX_DWORD dwSize, uint8_t ID[16]); |
| 531 void FaxG4Decode(const uint8_t* src_buf, | 560 void FaxG4Decode(const uint8_t* src_buf, |
| 532 FX_DWORD src_size, | 561 FX_DWORD src_size, |
| 533 int* pbitpos, | 562 int* pbitpos, |
| 534 uint8_t* dest_buf, | 563 uint8_t* dest_buf, |
| 535 int width, | 564 int width, |
| 536 int height, | 565 int height, |
| 537 int pitch); | 566 int pitch); |
| 538 | 567 |
| 539 #endif // CORE_INCLUDE_FXCODEC_FX_CODEC_H_ | 568 #endif // CORE_INCLUDE_FXCODEC_FX_CODEC_H_ |
| OLD | NEW |