summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/cpdf_renderoptions.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-07-13 14:53:28 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-13 19:34:45 +0000
commitf55e72e0476e5f5699b887099f213982e207afd0 (patch)
tree5108b56962094fb7588f4f860fc3bb9c9f00e3c3 /core/fpdfapi/render/cpdf_renderoptions.cpp
parent7f55a5410f665cfdbb5796d6d9a5387a5f6fa2eb (diff)
downloadpdfium-f55e72e0476e5f5699b887099f213982e207afd0.tar.xz
Cleanup CPDF_RenderOptions colour members.
This CL removes the fore/back colours in favour of just using the colours inline and converts the m_ColorMode to an enum. Change-Id: I1796e200d5c470680126af8625d45fc3062a1042 Reviewed-on: https://pdfium-review.googlesource.com/7751 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fpdfapi/render/cpdf_renderoptions.cpp')
-rw-r--r--core/fpdfapi/render/cpdf_renderoptions.cpp31
1 files changed, 4 insertions, 27 deletions
diff --git a/core/fpdfapi/render/cpdf_renderoptions.cpp b/core/fpdfapi/render/cpdf_renderoptions.cpp
index b452405c3d..7916243cba 100644
--- a/core/fpdfapi/render/cpdf_renderoptions.cpp
+++ b/core/fpdfapi/render/cpdf_renderoptions.cpp
@@ -7,15 +7,13 @@
#include "core/fpdfapi/render/cpdf_renderoptions.h"
CPDF_RenderOptions::CPDF_RenderOptions()
- : m_ColorMode(RENDER_COLOR_NORMAL),
+ : 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_BackColor(rhs.m_BackColor),
- m_ForeColor(rhs.m_ForeColor),
m_Flags(rhs.m_Flags),
m_dwLimitCacheSize(rhs.m_dwLimitCacheSize),
m_bDrawAnnots(rhs.m_bDrawAnnots),
@@ -24,10 +22,9 @@ CPDF_RenderOptions::CPDF_RenderOptions(const CPDF_RenderOptions& rhs)
CPDF_RenderOptions::~CPDF_RenderOptions() {}
FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const {
- if (m_ColorMode == RENDER_COLOR_NORMAL)
+ if (m_ColorMode == kNormal)
return argb;
-
- if (m_ColorMode == RENDER_COLOR_ALPHA)
+ if (m_ColorMode == kAlpha)
return argb;
int a;
@@ -36,25 +33,5 @@ FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const {
int b;
std::tie(a, r, g, b) = ArgbDecode(argb);
int gray = FXRGB2GRAY(r, g, b);
- if (m_ColorMode == RENDER_COLOR_TWOCOLOR) {
- int color = (r - gray) * (r - gray) + (g - gray) * (g - gray) +
- (b - gray) * (b - gray);
- if (gray < 35 && color < 20)
- return ArgbEncode(a, m_ForeColor);
-
- if (gray > 221 && color < 20)
- return ArgbEncode(a, m_BackColor);
-
- return argb;
- }
- int fr = FXSYS_GetRValue(m_ForeColor);
- int fg = FXSYS_GetGValue(m_ForeColor);
- int fb = FXSYS_GetBValue(m_ForeColor);
- int br = FXSYS_GetRValue(m_BackColor);
- int bg = FXSYS_GetGValue(m_BackColor);
- int bb = FXSYS_GetBValue(m_BackColor);
- r = (br - fr) * gray / 255 + fr;
- g = (bg - fg) * gray / 255 + fg;
- b = (bb - fb) * gray / 255 + fb;
- return ArgbEncode(a, r, g, b);
+ return ArgbEncode(a, gray, gray, gray);
}