summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_page/include
diff options
context:
space:
mode:
authordan sinclair <dsinclair@chromium.org>2016-03-23 19:21:44 -0400
committerdan sinclair <dsinclair@chromium.org>2016-03-23 19:21:44 -0400
commit61b2fc718910a5ab2a75ec5026b239ff33bccfdc (patch)
tree4031f4cea10dac3d77969035e66fc17235cb1d3d /core/fpdfapi/fpdf_page/include
parent46a8a2041868c5df6883647226dab1482e2bf4c2 (diff)
downloadpdfium-61b2fc718910a5ab2a75ec5026b239ff33bccfdc.tar.xz
Split core/include/fpdfapi/fpdf_resource.h
This CL splits apart the core/include/fpdfapi/fpdf_resource.h file and places the classes into individual files. R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1824033002 .
Diffstat (limited to 'core/fpdfapi/fpdf_page/include')
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_color.h47
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_colorspace.h122
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_formobject.h2
-rw-r--r--core/fpdfapi/fpdf_page/include/cpdf_image.h98
4 files changed, 268 insertions, 1 deletions
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_color.h b/core/fpdfapi/fpdf_page/include/cpdf_color.h
new file mode 100644
index 0000000000..9e20684d83
--- /dev/null
+++ b/core/fpdfapi/fpdf_page/include/cpdf_color.h
@@ -0,0 +1,47 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLOR_H_
+#define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLOR_H_
+
+#include "core/fpdfapi/fpdf_page/include/cpdf_colorspace.h"
+#include "core/fxcrt/include/fx_system.h"
+
+class CPDF_Pattern;
+
+class CPDF_Color {
+ public:
+ CPDF_Color() : m_pCS(nullptr), m_pBuffer(nullptr) {}
+ explicit CPDF_Color(int family);
+ ~CPDF_Color();
+
+ FX_BOOL IsNull() const { return !m_pBuffer; }
+ FX_BOOL IsEqual(const CPDF_Color& other) const;
+ FX_BOOL IsPattern() const {
+ return m_pCS && m_pCS->GetFamily() == PDFCS_PATTERN;
+ }
+
+ void Copy(const CPDF_Color* pSrc);
+
+ void SetColorSpace(CPDF_ColorSpace* pCS);
+ void SetValue(FX_FLOAT* comp);
+ void SetValue(CPDF_Pattern* pPattern, FX_FLOAT* comp, int ncomps);
+
+ FX_BOOL GetRGB(int& R, int& G, int& B) const;
+ CPDF_Pattern* GetPattern() const;
+ CPDF_ColorSpace* GetPatternCS() const;
+ FX_FLOAT* GetPatternColor() const;
+
+ CPDF_ColorSpace* m_pCS;
+
+ protected:
+ void ReleaseBuffer();
+ void ReleaseColorSpace();
+
+ FX_FLOAT* m_pBuffer;
+};
+
+#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLOR_H_
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h b/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
new file mode 100644
index 0000000000..afdd71dc4d
--- /dev/null
+++ b/core/fpdfapi/fpdf_page/include/cpdf_colorspace.h
@@ -0,0 +1,122 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_
+#define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_
+
+#include "core/fxcrt/include/fx_string.h"
+#include "core/fxcrt/include/fx_system.h"
+
+#define PDFCS_DEVICEGRAY 1
+#define PDFCS_DEVICERGB 2
+#define PDFCS_DEVICECMYK 3
+#define PDFCS_CALGRAY 4
+#define PDFCS_CALRGB 5
+#define PDFCS_LAB 6
+#define PDFCS_ICCBASED 7
+#define PDFCS_SEPARATION 8
+#define PDFCS_DEVICEN 9
+#define PDFCS_INDEXED 10
+#define PDFCS_PATTERN 11
+
+class CPDF_Array;
+class CPDF_Document;
+class CPDF_Object;
+
+class CPDF_ColorSpace {
+ public:
+ static CPDF_ColorSpace* GetStockCS(int Family);
+ static CPDF_ColorSpace* Load(CPDF_Document* pDoc, CPDF_Object* pCSObj);
+ static CPDF_ColorSpace* ColorspaceFromName(const CFX_ByteString& name);
+
+ void ReleaseCS();
+
+ int GetBufSize() const;
+ FX_FLOAT* CreateBuf();
+ void GetDefaultColor(FX_FLOAT* buf) const;
+ FX_DWORD CountComponents() const { return m_nComponents; }
+ int GetFamily() const { return m_Family; }
+ virtual void GetDefaultValue(int iComponent,
+ FX_FLOAT& value,
+ FX_FLOAT& min,
+ FX_FLOAT& max) const {
+ value = 0;
+ min = 0;
+ max = 1.0f;
+ }
+
+ FX_BOOL sRGB() const;
+ virtual FX_BOOL GetRGB(FX_FLOAT* pBuf,
+ FX_FLOAT& R,
+ FX_FLOAT& G,
+ FX_FLOAT& B) const = 0;
+ virtual FX_BOOL SetRGB(FX_FLOAT* pBuf,
+ FX_FLOAT R,
+ FX_FLOAT G,
+ FX_FLOAT B) const {
+ return FALSE;
+ }
+
+ FX_BOOL GetCMYK(FX_FLOAT* pBuf,
+ FX_FLOAT& c,
+ FX_FLOAT& m,
+ FX_FLOAT& y,
+ FX_FLOAT& k) const;
+ FX_BOOL SetCMYK(FX_FLOAT* pBuf,
+ FX_FLOAT c,
+ FX_FLOAT m,
+ FX_FLOAT y,
+ FX_FLOAT k) const;
+
+ virtual void TranslateImageLine(uint8_t* dest_buf,
+ const uint8_t* src_buf,
+ int pixels,
+ int image_width,
+ int image_height,
+ FX_BOOL bTransMask = FALSE) const;
+
+ CPDF_Array*& GetArray() { return m_pArray; }
+ int GetMaxIndex() const;
+ virtual CPDF_ColorSpace* GetBaseCS() const { return NULL; }
+
+ virtual void EnableStdConversion(FX_BOOL bEnabled);
+
+ CPDF_Document* const m_pDocument;
+
+ protected:
+ CPDF_ColorSpace(CPDF_Document* pDoc, int family, FX_DWORD nComponents)
+ : m_pDocument(pDoc),
+ m_Family(family),
+ m_nComponents(nComponents),
+ m_pArray(nullptr),
+ m_dwStdConversion(0) {}
+ virtual ~CPDF_ColorSpace() {}
+
+ virtual FX_BOOL v_Load(CPDF_Document* pDoc, CPDF_Array* pArray) {
+ return TRUE;
+ }
+ virtual FX_BOOL v_GetCMYK(FX_FLOAT* pBuf,
+ FX_FLOAT& c,
+ FX_FLOAT& m,
+ FX_FLOAT& y,
+ FX_FLOAT& k) const {
+ return FALSE;
+ }
+ virtual FX_BOOL v_SetCMYK(FX_FLOAT* pBuf,
+ FX_FLOAT c,
+ FX_FLOAT m,
+ FX_FLOAT y,
+ FX_FLOAT k) const {
+ return FALSE;
+ }
+
+ int m_Family;
+ FX_DWORD m_nComponents;
+ CPDF_Array* m_pArray;
+ FX_DWORD m_dwStdConversion;
+};
+
+#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_COLORSPACE_H_
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_formobject.h b/core/fpdfapi/fpdf_page/include/cpdf_formobject.h
index 234cd73328..b12d68c312 100644
--- a/core/fpdfapi/fpdf_page/include/cpdf_formobject.h
+++ b/core/fpdfapi/fpdf_page/include/cpdf_formobject.h
@@ -10,7 +10,7 @@
#include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h"
#include "core/fxcrt/include/fx_coordinates.h"
-class Form;
+class CPDF_Form;
class CPDF_FormObject : public CPDF_PageObject {
public:
diff --git a/core/fpdfapi/fpdf_page/include/cpdf_image.h b/core/fpdfapi/fpdf_page/include/cpdf_image.h
new file mode 100644
index 0000000000..048b86d171
--- /dev/null
+++ b/core/fpdfapi/fpdf_page/include/cpdf_image.h
@@ -0,0 +1,98 @@
+// Copyright 2016 PDFium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+
+#ifndef CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_IMAGE_H_
+#define CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_IMAGE_H_
+
+#include "core/fpdfapi/fpdf_parser/include/cpdf_stream.h"
+#include "core/fxcrt/include/fx_system.h"
+
+#define PDF_IMAGE_NO_COMPRESS 0x0000
+#define PDF_IMAGE_LOSSY_COMPRESS 0x0001
+#define PDF_IMAGE_LOSSLESS_COMPRESS 0x0002
+#define PDF_IMAGE_MASK_LOSSY_COMPRESS 0x0004
+#define PDF_IMAGE_MASK_LOSSLESS_COMPRESS 0x0008
+
+class CFX_DIBitmap;
+class CFX_DIBSource;
+class CPDF_Dictionay;
+class CPDF_Document;
+class CPDF_Page;
+class IFX_FileRead;
+class IFX_FileWrite;
+class IFX_Pause;
+
+class CPDF_Image {
+ public:
+ explicit CPDF_Image(CPDF_Document* pDoc);
+ ~CPDF_Image();
+
+ FX_BOOL LoadImageF(CPDF_Stream* pImageStream, FX_BOOL bInline);
+
+ void Release();
+
+ CPDF_Image* Clone();
+
+ CPDF_Dictionary* GetInlineDict() const { return m_pInlineDict; }
+ CPDF_Stream* GetStream() const { return m_pStream; }
+ CPDF_Dictionary* GetDict() const {
+ return m_pStream ? m_pStream->GetDict() : NULL;
+ }
+ CPDF_Dictionary* GetOC() const { return m_pOC; }
+ CPDF_Document* GetDocument() const { return m_pDocument; }
+
+ int32_t GetPixelHeight() const { return m_Height; }
+ int32_t GetPixelWidth() const { return m_Width; }
+
+ FX_BOOL IsInline() { return m_bInline; }
+ FX_BOOL IsMask() const { return m_bIsMask; }
+ FX_BOOL IsInterpol() const { return m_bInterpolate; }
+
+ CFX_DIBSource* LoadDIBSource(CFX_DIBSource** ppMask = NULL,
+ FX_DWORD* pMatteColor = NULL,
+ FX_BOOL bStdCS = FALSE,
+ FX_DWORD GroupFamily = 0,
+ FX_BOOL bLoadMask = FALSE) const;
+
+ void SetInlineDict(CPDF_Dictionary* pDict) { m_pInlineDict = pDict; }
+ void SetImage(const CFX_DIBitmap* pDIBitmap,
+ int32_t iCompress,
+ IFX_FileWrite* pFileWrite = NULL,
+ IFX_FileRead* pFileRead = NULL,
+ const CFX_DIBitmap* pMask = NULL);
+ void SetJpegImage(uint8_t* pImageData, FX_DWORD size);
+ void SetJpegImage(IFX_FileRead* pFile);
+
+ void ResetCache(CPDF_Page* pPage, const CFX_DIBitmap* pDIBitmap);
+
+ FX_BOOL StartLoadDIBSource(CPDF_Dictionary* pFormResource,
+ CPDF_Dictionary* pPageResource,
+ FX_BOOL bStdCS = FALSE,
+ FX_DWORD GroupFamily = 0,
+ FX_BOOL bLoadMask = FALSE);
+ FX_BOOL Continue(IFX_Pause* pPause);
+ CFX_DIBSource* DetachBitmap();
+ CFX_DIBSource* DetachMask();
+
+ CFX_DIBSource* m_pDIBSource;
+ CFX_DIBSource* m_pMask;
+ FX_DWORD m_MatteColor;
+
+ private:
+ CPDF_Dictionary* InitJPEG(uint8_t* pData, FX_DWORD size);
+
+ CPDF_Stream* m_pStream;
+ FX_BOOL m_bInline;
+ CPDF_Dictionary* m_pInlineDict;
+ int32_t m_Height;
+ int32_t m_Width;
+ FX_BOOL m_bIsMask;
+ FX_BOOL m_bInterpolate;
+ CPDF_Document* m_pDocument;
+ CPDF_Dictionary* m_pOC;
+};
+
+#endif // CORE_FPDFAPI_FPDF_PAGE_INCLUDE_CPDF_IMAGE_H_