summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2018-05-08 19:06:38 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-08 19:06:38 +0000
commitfdd0ef61e79aa1ca7c0859b8ff45740b6fb96bc2 (patch)
tree791fcf5b16bf322b6e95d792463a3dd9d6518e8d
parentb7c41498ac1f09debe0b12efe1312a22246a18b0 (diff)
downloadpdfium-fdd0ef61e79aa1ca7c0859b8ff45740b6fb96bc2.tar.xz
Add constants for PDF 1.7 spec, table 7.2 and 7.3.
Add constants/transparency.h. The header lists constants from chapter 7 of the PDF spec. BUG=pdfium:1049 Change-Id: I66bd6fceb24807eec9c308e2e47cec3f2f836ffb Reviewed-on: https://pdfium-review.googlesource.com/32177 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
-rw-r--r--BUILD.gn1
-rw-r--r--constants/transparency.h38
-rw-r--r--core/fpdfapi/page/cpdf_generalstate.cpp38
3 files changed, 59 insertions, 18 deletions
diff --git a/BUILD.gn b/BUILD.gn
index fc7c0eed8b..874a8f7d81 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -300,6 +300,7 @@ visibility = [
source_set("constants") {
sources = [
"constants/stream_dict_common.h",
+ "constants/transparency.h",
]
}
diff --git a/constants/transparency.h b/constants/transparency.h
new file mode 100644
index 0000000000..6ae79c949d
--- /dev/null
+++ b/constants/transparency.h
@@ -0,0 +1,38 @@
+// Copyright 2018 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.
+
+#ifndef CONSTANTS_TRANSPARENCY_H_
+#define CONSTANTS_TRANSPARENCY_H_
+
+namespace pdfium {
+namespace transparency {
+
+// PDF 1.7 spec, table 7.2.
+// Standard separable blend modes.
+
+constexpr char kNormal[] = "Normal";
+constexpr char kMultiply[] = "Multiply";
+constexpr char kScreen[] = "Screen";
+constexpr char kOverlay[] = "Overlay";
+constexpr char kDarken[] = "Darken";
+constexpr char kLighten[] = "Lighten";
+constexpr char kColorDodge[] = "ColorDodge";
+constexpr char kColorBurn[] = "ColorBurn";
+constexpr char kHardLight[] = "HardLight";
+constexpr char kSoftLight[] = "SoftLight";
+constexpr char kDifference[] = "Difference";
+constexpr char kExclusion[] = "Exclusion";
+
+// PDF 1.7 spec, table 7.3.
+// Standard nonseparable blend modes.
+
+constexpr char kHue[] = "Hue";
+constexpr char kSaturation[] = "Saturation";
+constexpr char kColor[] = "Color";
+constexpr char kLuminosity[] = "Luminosity";
+
+} // namespace transparency
+} // namespace pdfium
+
+#endif // CONSTANTS_TRANSPARENCY_H_
diff --git a/core/fpdfapi/page/cpdf_generalstate.cpp b/core/fpdfapi/page/cpdf_generalstate.cpp
index 845cedd496..a5b718bfff 100644
--- a/core/fpdfapi/page/cpdf_generalstate.cpp
+++ b/core/fpdfapi/page/cpdf_generalstate.cpp
@@ -6,6 +6,7 @@
#include "core/fpdfapi/page/cpdf_generalstate.h"
+#include "constants/transparency.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/render/cpdf_dibsource.h"
#include "core/fpdfapi/render/cpdf_docrenderdata.h"
@@ -78,42 +79,43 @@ CPDF_GeneralState::~CPDF_GeneralState() {}
void CPDF_GeneralState::SetRenderIntent(const ByteString& ri) {
m_Ref.GetPrivateCopy()->m_RenderIntent = RI_StringToId(ri);
}
+
ByteString CPDF_GeneralState::GetBlendMode() const {
switch (GetBlendType()) {
case FXDIB_BLEND_NORMAL:
- return ByteString("Normal");
+ return ByteString(pdfium::transparency::kNormal);
case FXDIB_BLEND_MULTIPLY:
- return ByteString("Multiply");
+ return ByteString(pdfium::transparency::kMultiply);
case FXDIB_BLEND_SCREEN:
- return ByteString("Screen");
+ return ByteString(pdfium::transparency::kScreen);
case FXDIB_BLEND_OVERLAY:
- return ByteString("Overlay");
+ return ByteString(pdfium::transparency::kOverlay);
case FXDIB_BLEND_DARKEN:
- return ByteString("Darken");
+ return ByteString(pdfium::transparency::kDarken);
case FXDIB_BLEND_LIGHTEN:
- return ByteString("Lighten");
+ return ByteString(pdfium::transparency::kLighten);
case FXDIB_BLEND_COLORDODGE:
- return ByteString("ColorDodge");
+ return ByteString(pdfium::transparency::kColorDodge);
case FXDIB_BLEND_COLORBURN:
- return ByteString("ColorBurn");
+ return ByteString(pdfium::transparency::kColorBurn);
case FXDIB_BLEND_HARDLIGHT:
- return ByteString("HardLight");
+ return ByteString(pdfium::transparency::kHardLight);
case FXDIB_BLEND_SOFTLIGHT:
- return ByteString("SoftLight");
+ return ByteString(pdfium::transparency::kSoftLight);
case FXDIB_BLEND_DIFFERENCE:
- return ByteString("Difference");
+ return ByteString(pdfium::transparency::kDifference);
case FXDIB_BLEND_EXCLUSION:
- return ByteString("Exclusion");
+ return ByteString(pdfium::transparency::kExclusion);
case FXDIB_BLEND_HUE:
- return ByteString("Hue");
+ return ByteString(pdfium::transparency::kHue);
case FXDIB_BLEND_SATURATION:
- return ByteString("Saturation");
+ return ByteString(pdfium::transparency::kSaturation);
case FXDIB_BLEND_COLOR:
- return ByteString("Color");
+ return ByteString(pdfium::transparency::kColor);
case FXDIB_BLEND_LUMINOSITY:
- return ByteString("Luminosity");
+ return ByteString(pdfium::transparency::kLuminosity);
}
- return ByteString("Normal");
+ return ByteString(pdfium::transparency::kNormal);
}
int CPDF_GeneralState::GetBlendType() const {
@@ -258,7 +260,7 @@ CFX_Matrix* CPDF_GeneralState::GetMutableMatrix() {
}
CPDF_GeneralState::StateData::StateData()
- : m_BlendMode("Normal"),
+ : m_BlendMode(pdfium::transparency::kNormal),
m_BlendType(0),
m_pSoftMask(nullptr),
m_StrokeAlpha(1.0),