summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/cpdf_renderoptions.cpp
blob: 7916243cba578f1823b47349f7294ba4754ac53c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2016 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#include "core/fpdfapi/render/cpdf_renderoptions.h"

CPDF_RenderOptions::CPDF_RenderOptions()
    : m_ColorMode(kNormal),
      m_Flags(RENDER_CLEARTYPE),
      m_dwLimitCacheSize(1024 * 1024 * 100),
      m_bDrawAnnots(false) {}

CPDF_RenderOptions::CPDF_RenderOptions(const CPDF_RenderOptions& rhs)
    : m_ColorMode(rhs.m_ColorMode),
      m_Flags(rhs.m_Flags),
      m_dwLimitCacheSize(rhs.m_dwLimitCacheSize),
      m_bDrawAnnots(rhs.m_bDrawAnnots),
      m_pOCContext(rhs.m_pOCContext) {}

CPDF_RenderOptions::~CPDF_RenderOptions() {}

FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const {
  if (m_ColorMode == kNormal)
    return argb;
  if (m_ColorMode == kAlpha)
    return argb;

  int a;
  int r;
  int g;
  int b;
  std::tie(a, r, g, b) = ArgbDecode(argb);
  int gray = FXRGB2GRAY(r, g, b);
  return ArgbEncode(a, gray, gray, gray);
}