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 struct Options { 24 Options(); 25 Options(const Options& rhs); 26 Options& operator=(const Options& rhs); 27 28 bool bClearType = false; 29 bool bNoNativeText = false; 30 bool bForceHalftone = false; 31 bool bRectAA = false; 32 bool bBreakForMasks = false; 33 bool bNoTextSmooth = false; 34 bool bNoPathSmooth = false; 35 bool bNoImageSmooth = false; 36 bool bLimitedImageCache = false; 37 bool bConvertFillToStroke = false; 38 }; 39 40 struct ColorScheme { 41 FX_ARGB path_fill_color; 42 FX_ARGB path_stroke_color; 43 FX_ARGB text_fill_color; 44 FX_ARGB text_stroke_color; 45 }; 46 47 CPDF_RenderOptions(); 48 CPDF_RenderOptions(const CPDF_RenderOptions& rhs); 49 ~CPDF_RenderOptions(); 50 51 FX_ARGB TranslateColor(FX_ARGB argb) const; 52 FX_ARGB TranslateObjectFillColor(FX_ARGB argb, 53 CPDF_PageObject::Type object_type) const; 54 FX_ARGB TranslateObjectStrokeColor(FX_ARGB argb, 55 CPDF_PageObject::Type object_type) const; 56 SetColorScheme(const ColorScheme & color_scheme)57 void SetColorScheme(const ColorScheme& color_scheme) { 58 m_ColorScheme = color_scheme; 59 } 60 SetColorMode(Type mode)61 void SetColorMode(Type mode) { m_ColorMode = mode; } ColorModeIs(Type mode)62 bool ColorModeIs(Type mode) const { return m_ColorMode == mode; } 63 GetOptions()64 const Options& GetOptions() const { return m_Options; } GetOptions()65 Options& GetOptions() { return m_Options; } 66 67 uint32_t GetCacheSizeLimit() const; 68 bool CheckOCGDictVisible(const CPDF_Dictionary* pOC) const; 69 bool CheckPageObjectVisible(const CPDF_PageObject* pPageObj) const; 70 SetDrawAnnots(bool draw)71 void SetDrawAnnots(bool draw) { m_bDrawAnnots = draw; } GetDrawAnnots()72 bool GetDrawAnnots() const { return m_bDrawAnnots; } 73 SetOCContext(RetainPtr<CPDF_OCContext> context)74 void SetOCContext(RetainPtr<CPDF_OCContext> context) { 75 m_pOCContext = context; 76 } 77 78 private: 79 Type m_ColorMode = kNormal; 80 bool m_bDrawAnnots = false; 81 Options m_Options; 82 ColorScheme m_ColorScheme = {}; 83 RetainPtr<CPDF_OCContext> m_pOCContext; 84 }; 85 86 #endif // CORE_FPDFAPI_RENDER_CPDF_RENDEROPTIONS_H_ 87