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