• 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_RENDER_CPDF_RENDEROPTIONS_H_
8 #define CORE_FPDFAPI_RENDER_CPDF_RENDEROPTIONS_H_
9 
10 #include <stdint.h>
11 
12 #include "core/fpdfapi/page/cpdf_occontext.h"
13 #include "core/fpdfapi/page/cpdf_pageobject.h"
14 #include "core/fxcrt/retain_ptr.h"
15 #include "core/fxge/dib/fx_dib.h"
16 
17 class CPDF_Dictionary;
18 
19 class CPDF_RenderOptions {
20  public:
21   enum Type : uint8_t { kNormal = 0, kGray, kAlpha, kForcedColor };
22 
23   enum RenderType : uint8_t { kFill = 0, kStroke };
24 
25   struct Options {
26     Options();
27     Options(const Options& rhs);
28     Options& operator=(const Options& rhs);
29 
30     bool bClearType = false;
31     bool bNoNativeText = false;
32     bool bForceHalftone = false;
33     bool bRectAA = false;
34     bool bBreakForMasks = false;
35     bool bNoTextSmooth = false;
36     bool bNoPathSmooth = false;
37     bool bNoImageSmooth = false;
38     bool bLimitedImageCache = false;
39     bool bConvertFillToStroke = false;
40   };
41 
42   struct ColorScheme {
43     FX_ARGB path_fill_color;
44     FX_ARGB path_stroke_color;
45     FX_ARGB text_fill_color;
46     FX_ARGB text_stroke_color;
47   };
48 
49   CPDF_RenderOptions();
50   CPDF_RenderOptions(const CPDF_RenderOptions& rhs);
51   ~CPDF_RenderOptions();
52 
53   FX_ARGB TranslateColor(FX_ARGB argb) const;
54   FX_ARGB TranslateObjectColor(FX_ARGB argb,
55                                CPDF_PageObject::Type object_type,
56                                RenderType render_type) const;
57 
SetColorScheme(const ColorScheme & color_scheme)58   void SetColorScheme(const ColorScheme& color_scheme) {
59     m_ColorScheme = color_scheme;
60   }
61 
SetColorMode(Type mode)62   void SetColorMode(Type mode) { m_ColorMode = mode; }
ColorModeIs(Type mode)63   bool ColorModeIs(Type mode) const { return m_ColorMode == mode; }
64 
GetOptions()65   const Options& GetOptions() const { return m_Options; }
GetOptions()66   Options& GetOptions() { return m_Options; }
67 
68   uint32_t GetCacheSizeLimit() const;
69   bool CheckOCGDictVisible(const CPDF_Dictionary* pOC) const;
70   bool CheckPageObjectVisible(const CPDF_PageObject* pPageObj) const;
71 
SetDrawAnnots(bool draw)72   void SetDrawAnnots(bool draw) { m_bDrawAnnots = draw; }
GetDrawAnnots()73   bool GetDrawAnnots() const { return m_bDrawAnnots; }
74 
SetOCContext(RetainPtr<CPDF_OCContext> context)75   void SetOCContext(RetainPtr<CPDF_OCContext> context) {
76     m_pOCContext = context;
77   }
78 
79  private:
80   Type m_ColorMode = kNormal;
81   bool m_bDrawAnnots = false;
82   Options m_Options;
83   ColorScheme m_ColorScheme = {};
84   RetainPtr<CPDF_OCContext> m_pOCContext;
85 };
86 
87 #endif  // CORE_FPDFAPI_RENDER_CPDF_RENDEROPTIONS_H_
88