summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-04 10:05:36 -0500
committerChromium commit bot <commit-bot@chromium.org>2018-01-04 16:14:31 +0000
commit72fe435e80807c91dbf8edc41d5bf3ec3c9bd9e4 (patch)
treef171ca51a643ea905908e98daf9bbe99590fdb73 /core
parenta0af75cc4d1e50bb2832dc58636043afe565b02b (diff)
downloadpdfium-72fe435e80807c91dbf8edc41d5bf3ec3c9bd9e4.tar.xz
Remove CXFA_DataData
This CL removes the CXFA_DataData base class and the functionality is moved to where it's needed. Change-Id: Ieba31aa924b9b513466144b31f0e1613923c50aa Reviewed-on: https://pdfium-review.googlesource.com/22250 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core')
-rw-r--r--core/fxge/dib/fx_dib_main.cpp51
-rw-r--r--core/fxge/fx_dib.h3
2 files changed, 54 insertions, 0 deletions
diff --git a/core/fxge/dib/fx_dib_main.cpp b/core/fxge/dib/fx_dib_main.cpp
index 3ede85c480..68e06a6c5d 100644
--- a/core/fxge/dib/fx_dib_main.cpp
+++ b/core/fxge/dib/fx_dib_main.cpp
@@ -9,6 +9,7 @@
#include <tuple>
#include <utility>
+#include "core/fxcrt/fx_extension.h"
#include "third_party/base/ptr_util.h"
const int16_t SDP_Table[513] = {
@@ -87,3 +88,53 @@ uint32_t ArgbEncode(int a, FX_COLORREF rgb) {
return FXARGB_MAKE(a, FXSYS_GetRValue(rgb), FXSYS_GetGValue(rgb),
FXSYS_GetBValue(rgb));
}
+
+FX_ARGB StringToFXARGB(const WideStringView& wsValue) {
+ uint8_t r = 0, g = 0, b = 0;
+ if (wsValue.GetLength() == 0)
+ return 0xff000000;
+
+ int cc = 0;
+ const wchar_t* str = wsValue.unterminated_c_str();
+ int len = wsValue.GetLength();
+ while (FXSYS_iswspace(str[cc]) && cc < len)
+ cc++;
+
+ if (cc >= len)
+ return 0xff000000;
+
+ while (cc < len) {
+ if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc]))
+ break;
+
+ r = r * 10 + str[cc] - '0';
+ cc++;
+ }
+ if (cc < len && str[cc] == ',') {
+ cc++;
+ while (FXSYS_iswspace(str[cc]) && cc < len)
+ cc++;
+
+ while (cc < len) {
+ if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc]))
+ break;
+
+ g = g * 10 + str[cc] - '0';
+ cc++;
+ }
+ if (cc < len && str[cc] == ',') {
+ cc++;
+ while (FXSYS_iswspace(str[cc]) && cc < len)
+ cc++;
+
+ while (cc < len) {
+ if (str[cc] == ',' || !FXSYS_isDecimalDigit(str[cc]))
+ break;
+
+ b = b * 10 + str[cc] - '0';
+ cc++;
+ }
+ }
+ }
+ return (0xff << 24) | (r << 16) | (g << 8) | b;
+}
diff --git a/core/fxge/fx_dib.h b/core/fxge/fx_dib.h
index 9a7da01467..f7626afd35 100644
--- a/core/fxge/fx_dib.h
+++ b/core/fxge/fx_dib.h
@@ -11,6 +11,7 @@
#include <utility>
#include "core/fxcrt/fx_coordinates.h"
+#include "core/fxcrt/widestring.h"
enum FXDIB_Format {
FXDIB_Invalid = 0,
@@ -94,6 +95,8 @@ inline FX_ARGB ArgbEncode(int a, int r, int g, int b) {
}
FX_ARGB ArgbEncode(int a, FX_COLORREF rgb);
+FX_ARGB StringToFXARGB(const WideStringView& view);
+
#define FXARGB_A(argb) ((uint8_t)((argb) >> 24))
#define FXARGB_R(argb) ((uint8_t)((argb) >> 16))
#define FXARGB_G(argb) ((uint8_t)((argb) >> 8))