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 #include "core/fpdfapi/render/cpdf_renderoptions.h"
8 
9 namespace {
10 
11 constexpr uint32_t kCacheSizeLimitBytes = 100 * 1024 * 1024;
12 
13 }  // namespace
14 
15 CPDF_RenderOptions::Options::Options() = default;
16 
17 CPDF_RenderOptions::Options::Options(const CPDF_RenderOptions::Options& rhs) =
18     default;
19 
CPDF_RenderOptions()20 CPDF_RenderOptions::CPDF_RenderOptions() {
21   // TODO(thestig): Make constexpr to initialize |m_Options| once C++14 is
22   // available.
23   m_Options.bClearType = true;
24 }
25 
26 CPDF_RenderOptions::CPDF_RenderOptions(const CPDF_RenderOptions& rhs) = default;
27 
28 CPDF_RenderOptions::~CPDF_RenderOptions() = default;
29 
TranslateColor(FX_ARGB argb) const30 FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const {
31   if (ColorModeIs(kNormal))
32     return argb;
33   if (ColorModeIs(kAlpha))
34     return argb;
35 
36   int a;
37   int r;
38   int g;
39   int b;
40   std::tie(a, r, g, b) = ArgbDecode(argb);
41   int gray = FXRGB2GRAY(r, g, b);
42   return ArgbEncode(a, gray, gray, gray);
43 }
44 
GetCacheSizeLimit() const45 uint32_t CPDF_RenderOptions::GetCacheSizeLimit() const {
46   return kCacheSizeLimitBytes;
47 }
48