xref: /aosp_15_r20/external/pdfium/core/fpdfapi/page/cpdf_pattern.h (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
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   virtual CPDF_TilingPattern* AsTilingPattern();
26   virtual CPDF_ShadingPattern* AsShadingPattern();
27 
pattern_to_form()28   const CFX_Matrix& pattern_to_form() const { return m_Pattern2Form; }
29 
30  protected:
31   CPDF_Pattern(CPDF_Document* pDoc,
32                RetainPtr<CPDF_Object> pObj,
33                const CFX_Matrix& parentMatrix);
34   ~CPDF_Pattern() override;
35 
36   // All the getters that return pointers return non-NULL pointers.
document()37   CPDF_Document* document() const { return m_pDocument; }
pattern_obj()38   RetainPtr<CPDF_Object> pattern_obj() const { return m_pPatternObj; }
parent_matrix()39   const CFX_Matrix& parent_matrix() const { return m_ParentMatrix; }
40 
41   void SetPatternToFormMatrix();
42 
43  private:
44   UnownedPtr<CPDF_Document> const m_pDocument;
45   RetainPtr<CPDF_Object> const m_pPatternObj;
46   CFX_Matrix m_Pattern2Form;
47   const CFX_Matrix m_ParentMatrix;
48 };
49 
50 #endif  // CORE_FPDFAPI_PAGE_CPDF_PATTERN_H_
51