• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2020 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 #ifndef CORE_FXGE_CFX_FILLRENDEROPTIONS_H_
6 #define CORE_FXGE_CFX_FILLRENDEROPTIONS_H_
7 
8 #include <stdint.h>
9 
10 // Represents the options for filling paths.
11 struct CFX_FillRenderOptions {
12   // FillType defines how path is filled.
13   enum class FillType : uint8_t {
14     // No filling needed.
15     kNoFill = 0,
16 
17     // Use even-odd or inverse even-odd algorithms to decide if the area needs
18     // to be filled.
19     kEvenOdd = 1,
20 
21     // Use winding or inverse winding algorithms to decide whether the area
22     // needs to be filled.
23     kWinding = 2,
24   };
25 
EvenOddOptionsCFX_FillRenderOptions26   static constexpr CFX_FillRenderOptions EvenOddOptions() {
27     return CFX_FillRenderOptions(FillType::kEvenOdd);
28   }
WindingOptionsCFX_FillRenderOptions29   static constexpr CFX_FillRenderOptions WindingOptions() {
30     return CFX_FillRenderOptions(FillType::kWinding);
31   }
32 
CFX_FillRenderOptionsCFX_FillRenderOptions33   constexpr CFX_FillRenderOptions()
34       : CFX_FillRenderOptions(FillType::kNoFill) {}
35 
36   // TODO(thestig): Switch to default member initializer for bit-fields when
37   // C++20 is available.
CFX_FillRenderOptionsCFX_FillRenderOptions38   constexpr explicit CFX_FillRenderOptions(FillType fill_type)
39       : fill_type(fill_type),
40         adjust_stroke(false),
41         aliased_path(false),
42         full_cover(false),
43         rect_aa(false),
44         stroke(false),
45         stroke_text_mode(false),
46         text_mode(false),
47         zero_area(false) {}
48 
49   bool operator==(const CFX_FillRenderOptions& other) const {
50     return fill_type == other.fill_type &&
51            adjust_stroke == other.adjust_stroke &&
52            aliased_path == other.aliased_path &&
53            full_cover == other.full_cover && rect_aa == other.rect_aa &&
54            stroke == other.stroke &&
55            stroke_text_mode == other.stroke_text_mode &&
56            text_mode == other.text_mode && zero_area == other.zero_area;
57   }
58 
59   bool operator!=(const CFX_FillRenderOptions& other) const {
60     return !(*this == other);
61   }
62 
63   // Fill type.
64   FillType fill_type;
65 
66   // Adjusted stroke rendering is enabled.
67   bool adjust_stroke : 1;
68 
69   // Whether anti aliasing is enabled for path rendering.
70   bool aliased_path : 1;
71 
72   // Fills with the sum of colors from both cover and source.
73   bool full_cover : 1;
74 
75   // Rect paths use anti-aliasing.
76   bool rect_aa : 1;
77 
78   // Path is stroke.
79   bool stroke : 1;
80 
81   // Renders text by filling strokes.
82   bool stroke_text_mode : 1;
83 
84   // Path is text.
85   bool text_mode : 1;
86 
87   // Path encloses zero area.
88   bool zero_area : 1;
89 };
90 
91 #endif  // CORE_FXGE_CFX_FILLRENDEROPTIONS_H_
92