• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2016 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_FPDFAPI_PAGE_CPDF_PATTERN_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_PATTERN_H_
9 
10 #include "core/fpdfapi/parser/cpdf_object.h"
11 #include "core/fxcrt/fx_coordinates.h"
12 #include "core/fxcrt/observed_ptr.h"
13 #include "core/fxcrt/retain_ptr.h"
14 #include "core/fxcrt/unowned_ptr.h"
15 
16 class CPDF_Document;
17 class CPDF_ShadingPattern;
18 class CPDF_TilingPattern;
19 
20 class CPDF_Pattern : public Retainable, public Observable {
21  public:
22   // Values used in PDFs. Do not change.
23   enum PatternType { kTiling = 1, kShading = 2 };
24 
25   ~CPDF_Pattern() override;
26 
27   virtual CPDF_TilingPattern* AsTilingPattern();
28   virtual CPDF_ShadingPattern* AsShadingPattern();
29 
pattern_to_form()30   const CFX_Matrix& pattern_to_form() const { return m_Pattern2Form; }
31 
32  protected:
33   CPDF_Pattern(CPDF_Document* pDoc,
34                RetainPtr<CPDF_Object> pObj,
35                const CFX_Matrix& parentMatrix);
36 
37   // All the getters that return pointers return non-NULL pointers.
document()38   CPDF_Document* document() const { return m_pDocument; }
pattern_obj()39   RetainPtr<CPDF_Object> pattern_obj() const { return m_pPatternObj; }
parent_matrix()40   const CFX_Matrix& parent_matrix() const { return m_ParentMatrix; }
41 
42   void SetPatternToFormMatrix();
43 
44  private:
45   UnownedPtr<CPDF_Document> const m_pDocument;
46   RetainPtr<CPDF_Object> const m_pPatternObj;
47   CFX_Matrix m_Pattern2Form;
48   const CFX_Matrix m_ParentMatrix;
49 };
50 
51 #endif  // CORE_FPDFAPI_PAGE_CPDF_PATTERN_H_
52