summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-04-03 19:52:27 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-04-03 19:52:27 +0000
commit28bb2f2ffe751cf4142329e27238da52ae9f848b (patch)
tree99229667c2b702b79f24d60faea4f89457e4ff32 /core/fxge
parent4c22dd5690cdec725389055bb7c07c300a4b6fe4 (diff)
downloadpdfium-28bb2f2ffe751cf4142329e27238da52ae9f848b.tar.xz
Remove DefaultAppearance HasColor and return an optional instead
This CL converts CPDF_DefaultAppearance to return Optional<CFX_Color:Type> items instead of having a HasColor. This saves the double parse of the appearance stream. Change-Id: Ib3c136da6e2adfb559e495de1d299cce0b4ad25f Reviewed-on: https://pdfium-review.googlesource.com/29630 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxge')
-rw-r--r--core/fxge/cfx_color.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/core/fxge/cfx_color.cpp b/core/fxge/cfx_color.cpp
index 8a2f42d920..19d1d4fd24 100644
--- a/core/fxge/cfx_color.cpp
+++ b/core/fxge/cfx_color.cpp
@@ -85,17 +85,15 @@ CFX_Color CFX_Color::ParseColor(const CPDF_Array& array) {
// Static.
CFX_Color CFX_Color::ParseColor(const ByteString& str) {
CPDF_DefaultAppearance appearance(str);
- ASSERT(appearance.HasColor());
-
float values[4];
- int color_type = appearance.GetColor(values);
- if (color_type == CFX_Color::kTransparent)
+ Optional<CFX_Color::Type> color_type = appearance.GetColor(values);
+ if (!color_type || *color_type == CFX_Color::kTransparent)
return CFX_Color(CFX_Color::kTransparent);
- if (color_type == CFX_Color::kGray)
+ if (*color_type == CFX_Color::kGray)
return CFX_Color(CFX_Color::kGray, values[0]);
- if (color_type == CFX_Color::kRGB)
+ if (*color_type == CFX_Color::kRGB)
return CFX_Color(CFX_Color::kRGB, values[0], values[1], values[2]);
- if (color_type == CFX_Color::kCMYK) {
+ if (*color_type == CFX_Color::kCMYK) {
return CFX_Color(CFX_Color::kCMYK, values[0], values[1], values[2],
values[3]);
}