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