summaryrefslogtreecommitdiff
path: root/core/fxge/cfx_color.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxge/cfx_color.h')
-rw-r--r--core/fxge/cfx_color.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/core/fxge/cfx_color.h b/core/fxge/cfx_color.h
new file mode 100644
index 0000000000..b92c0bcc28
--- /dev/null
+++ b/core/fxge/cfx_color.h
@@ -0,0 +1,57 @@
+// Copyright 2017 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
+
+#ifndef CORE_FXGE_CFX_COLOR_H_
+#define CORE_FXGE_CFX_COLOR_H_
+
+#include "core/fpdfdoc/cpdf_formcontrol.h"
+#include "core/fxge/fx_dib.h"
+
+struct CFX_Color {
+ explicit CFX_Color(FX_COLORREF ref)
+ : CFX_Color(FXARGB_R(ref), FXARGB_G(ref), FXARGB_B(ref)) {}
+
+ CFX_Color(int32_t type = COLORTYPE_TRANSPARENT,
+ float color1 = 0.0f,
+ float color2 = 0.0f,
+ float color3 = 0.0f,
+ float color4 = 0.0f)
+ : nColorType(type),
+ fColor1(color1),
+ fColor2(color2),
+ fColor3(color3),
+ fColor4(color4) {}
+
+ CFX_Color(int32_t r, int32_t g, int32_t b)
+ : nColorType(COLORTYPE_RGB),
+ fColor1(r / 255.0f),
+ fColor2(g / 255.0f),
+ fColor3(b / 255.0f),
+ fColor4(0) {}
+
+ CFX_Color operator/(float fColorDivide) const;
+ CFX_Color operator-(float fColorSub) const;
+
+ CFX_Color ConvertColorType(int32_t other_nColorType) const;
+
+ FX_COLORREF ToFXColor(int32_t nTransparency) const;
+
+ void Reset() {
+ nColorType = COLORTYPE_TRANSPARENT;
+ fColor1 = 0.0f;
+ fColor2 = 0.0f;
+ fColor3 = 0.0f;
+ fColor4 = 0.0f;
+ }
+
+ int32_t nColorType;
+ float fColor1;
+ float fColor2;
+ float fColor3;
+ float fColor4;
+};
+
+#endif // CORE_FXGE_CFX_COLOR_H_