summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/fpdfdoc/cpdf_defaultappearance.cpp42
-rw-r--r--core/fpdfdoc/cpdf_defaultappearance.h9
-rw-r--r--core/fpdfdoc/cpvt_generateap.cpp2
3 files changed, 22 insertions, 31 deletions
diff --git a/core/fpdfdoc/cpdf_defaultappearance.cpp b/core/fpdfdoc/cpdf_defaultappearance.cpp
index 4542c59a7d..ba0679a19a 100644
--- a/core/fpdfdoc/cpdf_defaultappearance.cpp
+++ b/core/fpdfdoc/cpdf_defaultappearance.cpp
@@ -79,35 +79,29 @@ void CPDF_DefaultAppearance::GetColor(int& iColorType, float fc[4]) {
void CPDF_DefaultAppearance::GetColor(FX_ARGB& color, int& iColorType) {
color = 0;
- iColorType = CFX_Color::kTransparent;
- if (m_csDA.IsEmpty())
+ float values[4];
+ GetColor(iColorType, values);
+ if (iColorType == CFX_Color::kTransparent)
return;
- CPDF_SimpleParser syntax(m_csDA.AsStringView());
- if (syntax.FindTagParamFromStart("g", 1)) {
- iColorType = CFX_Color::kGray;
- float g = FX_atof(syntax.GetWord()) * 255 + 0.5f;
- color = ArgbEncode(255, (int)g, (int)g, (int)g);
+ if (iColorType == CFX_Color::kGray) {
+ int g = static_cast<int>(values[0] * 255 + 0.5f);
+ color = ArgbEncode(255, g, g, g);
return;
}
- if (syntax.FindTagParamFromStart("rg", 3)) {
- iColorType = CFX_Color::kRGB;
- float r = FX_atof(syntax.GetWord()) * 255 + 0.5f;
- float g = FX_atof(syntax.GetWord()) * 255 + 0.5f;
- float b = FX_atof(syntax.GetWord()) * 255 + 0.5f;
- color = ArgbEncode(255, (int)r, (int)g, (int)b);
+ if (iColorType == CFX_Color::kRGB) {
+ int r = static_cast<int>(values[0] * 255 + 0.5f);
+ int g = static_cast<int>(values[1] * 255 + 0.5f);
+ int b = static_cast<int>(values[2] * 255 + 0.5f);
+ color = ArgbEncode(255, r, g, b);
return;
}
- if (syntax.FindTagParamFromStart("k", 4)) {
- iColorType = CFX_Color::kCMYK;
- float c = FX_atof(syntax.GetWord());
- float m = FX_atof(syntax.GetWord());
- float y = FX_atof(syntax.GetWord());
- float k = FX_atof(syntax.GetWord());
- float r = 1.0f - std::min(1.0f, c + k);
- float g = 1.0f - std::min(1.0f, m + k);
- float b = 1.0f - std::min(1.0f, y + k);
- color = ArgbEncode(255, (int)(r * 255 + 0.5f), (int)(g * 255 + 0.5f),
- (int)(b * 255 + 0.5f));
+ if (iColorType == CFX_Color::kCMYK) {
+ float r = 1.0f - std::min(1.0f, values[0] + values[3]);
+ float g = 1.0f - std::min(1.0f, values[1] + values[3]);
+ float b = 1.0f - std::min(1.0f, values[2] + values[3]);
+ color = ArgbEncode(255, static_cast<int>(r * 255 + 0.5f),
+ static_cast<int>(g * 255 + 0.5f),
+ static_cast<int>(b * 255 + 0.5f));
}
}
diff --git a/core/fpdfdoc/cpdf_defaultappearance.h b/core/fpdfdoc/cpdf_defaultappearance.h
index f27856ae4e..af13a3f8bc 100644
--- a/core/fpdfdoc/cpdf_defaultappearance.h
+++ b/core/fpdfdoc/cpdf_defaultappearance.h
@@ -14,18 +14,13 @@
#include "core/fxge/fx_dib.h"
enum class BorderStyle { SOLID, DASH, BEVELED, INSET, UNDERLINE };
-enum class PaintOperation { STROKE, FILL };
class CPDF_DefaultAppearance {
public:
CPDF_DefaultAppearance() {}
explicit CPDF_DefaultAppearance(const ByteString& csDA) : m_csDA(csDA) {}
-
- CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA) {
- m_csDA = cDA.GetStr();
- }
-
- ByteString GetStr() const { return m_csDA; }
+ CPDF_DefaultAppearance(const CPDF_DefaultAppearance& cDA)
+ : m_csDA(cDA.m_csDA) {}
bool HasFont();
ByteString GetFont(float* fFontSize);
diff --git a/core/fpdfdoc/cpvt_generateap.cpp b/core/fpdfdoc/cpvt_generateap.cpp
index 1b94f7eca4..a61a2451af 100644
--- a/core/fpdfdoc/cpvt_generateap.cpp
+++ b/core/fpdfdoc/cpvt_generateap.cpp
@@ -40,6 +40,8 @@ struct CPVT_Dash {
namespace {
+enum class PaintOperation { STROKE, FILL };
+
ByteString GetPDFWordString(IPVT_FontMap* pFontMap,
int32_t nFontIndex,
uint16_t Word,