xref: /aosp_15_r20/external/pdfium/core/fpdfapi/page/cpdf_pathobject.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_PATHOBJECT_H_
8 #define CORE_FPDFAPI_PAGE_CPDF_PATHOBJECT_H_
9 
10 #include <stdint.h>
11 
12 #include "core/fpdfapi/page/cpdf_pageobject.h"
13 #include "core/fpdfapi/page/cpdf_path.h"
14 #include "core/fxcrt/fx_coordinates.h"
15 #include "core/fxge/cfx_fillrenderoptions.h"
16 
17 class CPDF_PathObject final : public CPDF_PageObject {
18  public:
19   explicit CPDF_PathObject(int32_t content_stream);
20   CPDF_PathObject();
21   ~CPDF_PathObject() override;
22 
23   // CPDF_PageObject
24   Type GetType() const override;
25   void Transform(const CFX_Matrix& matrix) override;
26   bool IsPath() const override;
27   CPDF_PathObject* AsPath() override;
28   const CPDF_PathObject* AsPath() const override;
29 
30   void CalcBoundingBox();
31 
stroke()32   bool stroke() const { return m_bStroke; }
set_stroke(bool stroke)33   void set_stroke(bool stroke) { m_bStroke = stroke; }
34 
35   // Layering, avoid caller knowledge of CFX_FillRenderOptions::FillType values.
has_no_filltype()36   bool has_no_filltype() const {
37     return m_FillType == CFX_FillRenderOptions::FillType::kNoFill;
38   }
has_winding_filltype()39   bool has_winding_filltype() const {
40     return m_FillType == CFX_FillRenderOptions::FillType::kWinding;
41   }
has_alternate_filltype()42   bool has_alternate_filltype() const {
43     return m_FillType == CFX_FillRenderOptions::FillType::kEvenOdd;
44   }
set_no_filltype()45   void set_no_filltype() {
46     m_FillType = CFX_FillRenderOptions::FillType::kNoFill;
47   }
set_winding_filltype()48   void set_winding_filltype() {
49     m_FillType = CFX_FillRenderOptions::FillType::kWinding;
50   }
set_alternate_filltype()51   void set_alternate_filltype() {
52     m_FillType = CFX_FillRenderOptions::FillType::kEvenOdd;
53   }
54 
filltype()55   CFX_FillRenderOptions::FillType filltype() const { return m_FillType; }
set_filltype(CFX_FillRenderOptions::FillType fill_type)56   void set_filltype(CFX_FillRenderOptions::FillType fill_type) {
57     m_FillType = fill_type;
58   }
59 
path()60   CPDF_Path& path() { return m_Path; }
path()61   const CPDF_Path& path() const { return m_Path; }
62 
matrix()63   const CFX_Matrix& matrix() const { return m_Matrix; }
64   void SetPathMatrix(const CFX_Matrix& matrix);
65 
66  private:
67   bool m_bStroke = false;
68   CFX_FillRenderOptions::FillType m_FillType =
69       CFX_FillRenderOptions::FillType::kNoFill;
70   CPDF_Path m_Path;
71   CFX_Matrix m_Matrix;
72 };
73 
74 #endif  // CORE_FPDFAPI_PAGE_CPDF_PATHOBJECT_H_
75