blob: d4e31bcf73d4164d3826127a99e457a78e15cbaf [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
dan sinclair89e904b2016-03-23 19:29:15 -04007#include "fpdfsdk/pdfwindow/PWL_Utils.h"
Lei Zhang375a8642016-01-11 11:59:17 -08008
9#include <algorithm>
Dan Sinclair85c8e7f2016-11-21 13:50:32 -050010#include <memory>
Lei Zhang375a8642016-01-11 11:59:17 -080011
dsinclair1727aee2016-09-29 13:12:56 -070012#include "core/fpdfdoc/cpvt_word.h"
dsinclair74a34fc2016-09-29 16:41:42 -070013#include "core/fxge/cfx_graphstatedata.h"
14#include "core/fxge/cfx_pathdata.h"
15#include "core/fxge/cfx_renderdevice.h"
dsinclair0bb385b2016-09-29 17:03:59 -070016#include "fpdfsdk/fxedit/fxet_edit.h"
dan sinclair89e904b2016-03-23 19:29:15 -040017#include "fpdfsdk/pdfwindow/PWL_Icon.h"
18#include "fpdfsdk/pdfwindow/PWL_Wnd.h"
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070019
Nico Weber9d8ec5a2015-08-04 13:00:21 -070020CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData,
21 int32_t nCount) {
22 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070023
Nico Weber9d8ec5a2015-08-04 13:00:21 -070024 for (int32_t i = 0; i < nCount; i++) {
25 switch (pPathData[i].type) {
26 case PWLPT_MOVETO:
27 csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " m\n";
28 break;
29 case PWLPT_LINETO:
30 csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " l\n";
31 break;
32 case PWLPT_BEZIERTO:
33 csAP << pPathData[i].point.x << " " << pPathData[i].point.y << " "
34 << pPathData[i + 1].point.x << " " << pPathData[i + 1].point.y
35 << " " << pPathData[i + 2].point.x << " "
36 << pPathData[i + 2].point.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070037
Nico Weber9d8ec5a2015-08-04 13:00:21 -070038 i += 2;
39 break;
40 default:
41 break;
42 }
43 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070044
tsepez71a452f2016-05-13 17:51:27 -070045 return csAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070046}
47
Nico Weber9d8ec5a2015-08-04 13:00:21 -070048void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path,
49 const CPWL_PathData* pPathData,
50 int32_t nCount) {
51 path.SetPointCount(nCount);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070052
Nico Weber9d8ec5a2015-08-04 13:00:21 -070053 for (int32_t i = 0; i < nCount; i++) {
54 switch (pPathData[i].type) {
55 case PWLPT_MOVETO:
56 path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
Nicolas Pena79365f72017-02-07 14:21:36 -050057 FXPT_TYPE::MoveTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070058 break;
59 case PWLPT_LINETO:
60 path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
Nicolas Pena79365f72017-02-07 14:21:36 -050061 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070062 break;
63 case PWLPT_BEZIERTO:
64 path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y,
Nicolas Pena79365f72017-02-07 14:21:36 -050065 FXPT_TYPE::BezierTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -070066 break;
67 default:
68 break;
69 }
70 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070071}
72
Tom Sepez281a9ea2016-02-26 14:24:28 -080073CFX_FloatRect CPWL_Utils::MaxRect(const CFX_FloatRect& rect1,
74 const CFX_FloatRect& rect2) {
75 CFX_FloatRect rcRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070076
Nico Weber9d8ec5a2015-08-04 13:00:21 -070077 rcRet.left = PWL_MIN(rect1.left, rect2.left);
78 rcRet.bottom = PWL_MIN(rect1.bottom, rect2.bottom);
79 rcRet.right = PWL_MAX(rect1.right, rect2.right);
80 rcRet.top = PWL_MAX(rect1.top, rect2.top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070081
Nico Weber9d8ec5a2015-08-04 13:00:21 -070082 return rcRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070083}
84
Tom Sepez281a9ea2016-02-26 14:24:28 -080085CFX_FloatRect CPWL_Utils::OffsetRect(const CFX_FloatRect& rect,
86 FX_FLOAT x,
87 FX_FLOAT y) {
88 return CFX_FloatRect(rect.left + x, rect.bottom + y, rect.right + x,
89 rect.top + y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070090}
91
tsepez4cf55152016-11-02 14:37:54 -070092bool CPWL_Utils::ContainsRect(const CFX_FloatRect& rcParent,
93 const CFX_FloatRect& rcChild) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -070094 return rcChild.left >= rcParent.left && rcChild.bottom >= rcParent.bottom &&
95 rcChild.right <= rcParent.right && rcChild.top <= rcParent.top;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070096}
97
tsepez4cf55152016-11-02 14:37:54 -070098bool CPWL_Utils::IntersectRect(const CFX_FloatRect& rect1,
99 const CFX_FloatRect& rect2) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700100 FX_FLOAT left = rect1.left > rect2.left ? rect1.left : rect2.left;
101 FX_FLOAT right = rect1.right < rect2.right ? rect1.right : rect2.right;
102 FX_FLOAT bottom = rect1.bottom > rect2.bottom ? rect1.bottom : rect2.bottom;
103 FX_FLOAT top = rect1.top < rect2.top ? rect1.top : rect2.top;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700104
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700105 return left < right && bottom < top;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700106}
107
Dan Sinclairf528eee2017-02-14 11:52:07 -0500108CFX_PointF CPWL_Utils::OffsetPoint(const CFX_PointF& point,
109 FX_FLOAT x,
110 FX_FLOAT y) {
111 return CFX_PointF(point.x + x, point.y + y);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700112}
113
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700114CPVT_WordRange CPWL_Utils::OverlapWordRange(const CPVT_WordRange& wr1,
115 const CPVT_WordRange& wr2) {
116 CPVT_WordRange wrRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700117
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700118 if (wr2.EndPos.WordCmp(wr1.BeginPos) < 0 ||
119 wr2.BeginPos.WordCmp(wr1.EndPos) > 0)
120 return wrRet;
121 if (wr1.EndPos.WordCmp(wr2.BeginPos) < 0 ||
122 wr1.BeginPos.WordCmp(wr2.EndPos) > 0)
123 return wrRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700124
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700125 if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) {
126 wrRet.BeginPos = wr2.BeginPos;
127 } else {
128 wrRet.BeginPos = wr1.BeginPos;
129 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700130
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700131 if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) {
132 wrRet.EndPos = wr1.EndPos;
133 } else {
134 wrRet.EndPos = wr2.EndPos;
135 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700136
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700137 return wrRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700138}
139
Tom Sepez281a9ea2016-02-26 14:24:28 -0800140CFX_ByteString CPWL_Utils::GetAP_Check(const CFX_FloatRect& crBBox) {
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800141 const FX_FLOAT fWidth = crBBox.right - crBBox.left;
142 const FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700143
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800144 CPWL_Point pts[8][3] = {{CPWL_Point(0.28f, 0.52f), CPWL_Point(0.27f, 0.48f),
145 CPWL_Point(0.29f, 0.40f)},
146 {CPWL_Point(0.30f, 0.33f), CPWL_Point(0.31f, 0.29f),
147 CPWL_Point(0.31f, 0.28f)},
148 {CPWL_Point(0.39f, 0.28f), CPWL_Point(0.49f, 0.29f),
149 CPWL_Point(0.77f, 0.67f)},
150 {CPWL_Point(0.76f, 0.68f), CPWL_Point(0.78f, 0.69f),
151 CPWL_Point(0.76f, 0.75f)},
152 {CPWL_Point(0.76f, 0.75f), CPWL_Point(0.73f, 0.80f),
153 CPWL_Point(0.68f, 0.75f)},
154 {CPWL_Point(0.68f, 0.74f), CPWL_Point(0.68f, 0.74f),
155 CPWL_Point(0.44f, 0.47f)},
156 {CPWL_Point(0.43f, 0.47f), CPWL_Point(0.40f, 0.47f),
157 CPWL_Point(0.41f, 0.58f)},
158 {CPWL_Point(0.40f, 0.60f), CPWL_Point(0.28f, 0.66f),
159 CPWL_Point(0.30f, 0.56f)}};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700160
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800161 for (size_t i = 0; i < FX_ArraySize(pts); ++i) {
162 for (size_t j = 0; j < FX_ArraySize(pts[0]); ++j) {
163 pts[i][j].x = pts[i][j].x * fWidth + crBBox.left;
164 pts[i][j].y *= pts[i][j].y * fHeight + crBBox.bottom;
165 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700166 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700167
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800168 CFX_ByteTextBuf csAP;
169 csAP << pts[0][0].x << " " << pts[0][0].y << " m\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700170
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800171 for (size_t i = 0; i < FX_ArraySize(pts); ++i) {
172 size_t nNext = i < FX_ArraySize(pts) - 1 ? i + 1 : 0;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700173
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800174 FX_FLOAT px1 = pts[i][1].x - pts[i][0].x;
175 FX_FLOAT py1 = pts[i][1].y - pts[i][0].y;
176 FX_FLOAT px2 = pts[i][2].x - pts[nNext][0].x;
177 FX_FLOAT py2 = pts[i][2].y - pts[nNext][0].y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700178
Tom Sepeza30b7e82016-02-12 15:58:50 -0800179 csAP << pts[i][0].x + px1 * FX_BEZIER << " "
180 << pts[i][0].y + py1 * FX_BEZIER << " "
181 << pts[nNext][0].x + px2 * FX_BEZIER << " "
182 << pts[nNext][0].y + py2 * FX_BEZIER << " " << pts[nNext][0].x << " "
Lei Zhangc2fb35f2016-01-05 16:46:58 -0800183 << pts[nNext][0].y << " c\n";
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700184 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700185
tsepez71a452f2016-05-13 17:51:27 -0700186 return csAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700187}
188
Tom Sepez281a9ea2016-02-26 14:24:28 -0800189CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700190 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700191
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700192 FX_FLOAT fWidth = crBBox.right - crBBox.left;
193 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700194
Dan Sinclairf528eee2017-02-14 11:52:07 -0500195 CFX_PointF pt1(crBBox.left, crBBox.bottom + fHeight / 2);
196 CFX_PointF pt2(crBBox.left + fWidth / 2, crBBox.top);
197 CFX_PointF pt3(crBBox.right, crBBox.bottom + fHeight / 2);
198 CFX_PointF pt4(crBBox.left + fWidth / 2, crBBox.bottom);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700199
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700200 csAP << pt1.x << " " << pt1.y << " m\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700201
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700202 FX_FLOAT px = pt2.x - pt1.x;
203 FX_FLOAT py = pt2.y - pt1.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700204
Tom Sepeza30b7e82016-02-12 15:58:50 -0800205 csAP << pt1.x << " " << pt1.y + py * FX_BEZIER << " "
206 << pt2.x - px * FX_BEZIER << " " << pt2.y << " " << pt2.x << " " << pt2.y
207 << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700208
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700209 px = pt3.x - pt2.x;
210 py = pt2.y - pt3.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700211
Tom Sepeza30b7e82016-02-12 15:58:50 -0800212 csAP << pt2.x + px * FX_BEZIER << " " << pt2.y << " " << pt3.x << " "
213 << pt3.y + py * FX_BEZIER << " " << pt3.x << " " << pt3.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700214
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700215 px = pt3.x - pt4.x;
216 py = pt3.y - pt4.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700217
Tom Sepeza30b7e82016-02-12 15:58:50 -0800218 csAP << pt3.x << " " << pt3.y - py * FX_BEZIER << " "
219 << pt4.x + px * FX_BEZIER << " " << pt4.y << " " << pt4.x << " " << pt4.y
220 << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700221
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700222 px = pt4.x - pt1.x;
223 py = pt1.y - pt4.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700224
Tom Sepeza30b7e82016-02-12 15:58:50 -0800225 csAP << pt4.x - px * FX_BEZIER << " " << pt4.y << " " << pt1.x << " "
226 << pt1.y - py * FX_BEZIER << " " << pt1.x << " " << pt1.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700227
tsepez71a452f2016-05-13 17:51:27 -0700228 return csAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700229}
230
Tom Sepez281a9ea2016-02-26 14:24:28 -0800231CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700232 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700233
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700234 csAP << crBBox.left << " " << crBBox.top << " m\n";
235 csAP << crBBox.right << " " << crBBox.bottom << " l\n";
236 csAP << crBBox.left << " " << crBBox.bottom << " m\n";
237 csAP << crBBox.right << " " << crBBox.top << " l\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700238
tsepez71a452f2016-05-13 17:51:27 -0700239 return csAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700240}
241
Tom Sepez281a9ea2016-02-26 14:24:28 -0800242CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700243 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700244
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700245 FX_FLOAT fWidth = crBBox.right - crBBox.left;
246 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700247
Dan Sinclairf528eee2017-02-14 11:52:07 -0500248 CFX_PointF pt1(crBBox.left, crBBox.bottom + fHeight / 2);
249 CFX_PointF pt2(crBBox.left + fWidth / 2, crBBox.top);
250 CFX_PointF pt3(crBBox.right, crBBox.bottom + fHeight / 2);
251 CFX_PointF pt4(crBBox.left + fWidth / 2, crBBox.bottom);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700252
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700253 csAP << pt1.x << " " << pt1.y << " m\n";
254 csAP << pt2.x << " " << pt2.y << " l\n";
255 csAP << pt3.x << " " << pt3.y << " l\n";
256 csAP << pt4.x << " " << pt4.y << " l\n";
257 csAP << pt1.x << " " << pt1.y << " l\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700258
tsepez71a452f2016-05-13 17:51:27 -0700259 return csAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700260}
261
Tom Sepez281a9ea2016-02-26 14:24:28 -0800262CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700263 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700264
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700265 csAP << crBBox.left << " " << crBBox.top << " m\n";
266 csAP << crBBox.right << " " << crBBox.top << " l\n";
267 csAP << crBBox.right << " " << crBBox.bottom << " l\n";
268 csAP << crBBox.left << " " << crBBox.bottom << " l\n";
269 csAP << crBBox.left << " " << crBBox.top << " l\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700270
tsepez71a452f2016-05-13 17:51:27 -0700271 return csAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700272}
273
Tom Sepez281a9ea2016-02-26 14:24:28 -0800274CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700275 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700276
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700277 FX_FLOAT fRadius =
Tom Sepeza30b7e82016-02-12 15:58:50 -0800278 (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f));
Dan Sinclairf528eee2017-02-14 11:52:07 -0500279 CFX_PointF ptCenter = CFX_PointF((crBBox.left + crBBox.right) / 2.0f,
280 (crBBox.top + crBBox.bottom) / 2.0f);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700281
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700282 FX_FLOAT px[5], py[5];
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700283
Tom Sepeza30b7e82016-02-12 15:58:50 -0800284 FX_FLOAT fAngel = FX_PI / 10.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700285
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700286 for (int32_t i = 0; i < 5; i++) {
287 px[i] = ptCenter.x + fRadius * (FX_FLOAT)cos(fAngel);
288 py[i] = ptCenter.y + fRadius * (FX_FLOAT)sin(fAngel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700289
Tom Sepeza30b7e82016-02-12 15:58:50 -0800290 fAngel += FX_PI * 2 / 5.0f;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700291 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700292
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700293 csAP << px[0] << " " << py[0] << " m\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700294
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700295 int32_t nNext = 0;
296 for (int32_t j = 0; j < 5; j++) {
297 nNext += 2;
298 if (nNext >= 5)
299 nNext -= 5;
300 csAP << px[nNext] << " " << py[nNext] << " l\n";
301 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700302
tsepez71a452f2016-05-13 17:51:27 -0700303 return csAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700304}
305
Tom Sepez281a9ea2016-02-26 14:24:28 -0800306CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700307 FX_FLOAT fRotate) {
308 CFX_ByteTextBuf csAP;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700309
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700310 FX_FLOAT fWidth = crBBox.right - crBBox.left;
311 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700312
Dan Sinclairf528eee2017-02-14 11:52:07 -0500313 CFX_PointF pt1(-fWidth / 2, 0);
314 CFX_PointF pt2(0, fHeight / 2);
315 CFX_PointF pt3(fWidth / 2, 0);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700316
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700317 FX_FLOAT px, py;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700318
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700319 csAP << cos(fRotate) << " " << sin(fRotate) << " " << -sin(fRotate) << " "
320 << cos(fRotate) << " " << crBBox.left + fWidth / 2 << " "
321 << crBBox.bottom + fHeight / 2 << " cm\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700322
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700323 csAP << pt1.x << " " << pt1.y << " m\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700324
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700325 px = pt2.x - pt1.x;
326 py = pt2.y - pt1.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700327
Tom Sepeza30b7e82016-02-12 15:58:50 -0800328 csAP << pt1.x << " " << pt1.y + py * FX_BEZIER << " "
329 << pt2.x - px * FX_BEZIER << " " << pt2.y << " " << pt2.x << " " << pt2.y
330 << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700331
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700332 px = pt3.x - pt2.x;
333 py = pt2.y - pt3.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700334
Tom Sepeza30b7e82016-02-12 15:58:50 -0800335 csAP << pt2.x + px * FX_BEZIER << " " << pt2.y << " " << pt3.x << " "
336 << pt3.y + py * FX_BEZIER << " " << pt3.x << " " << pt3.y << " c\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700337
tsepez71a452f2016-05-13 17:51:27 -0700338 return csAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700339}
340
Tom Sepez281a9ea2016-02-26 14:24:28 -0800341CFX_FloatRect CPWL_Utils::InflateRect(const CFX_FloatRect& rcRect,
342 FX_FLOAT fSize) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700343 if (rcRect.IsEmpty())
344 return rcRect;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700345
Tom Sepez281a9ea2016-02-26 14:24:28 -0800346 CFX_FloatRect rcNew(rcRect.left - fSize, rcRect.bottom - fSize,
347 rcRect.right + fSize, rcRect.top + fSize);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700348 rcNew.Normalize();
349 return rcNew;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700350}
351
Tom Sepez281a9ea2016-02-26 14:24:28 -0800352CFX_FloatRect CPWL_Utils::DeflateRect(const CFX_FloatRect& rcRect,
353 FX_FLOAT fSize) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700354 if (rcRect.IsEmpty())
355 return rcRect;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700356
Tom Sepez281a9ea2016-02-26 14:24:28 -0800357 CFX_FloatRect rcNew(rcRect.left + fSize, rcRect.bottom + fSize,
358 rcRect.right - fSize, rcRect.top - fSize);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700359 rcNew.Normalize();
360 return rcNew;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700361}
362
Tom Sepez281a9ea2016-02-26 14:24:28 -0800363CFX_FloatRect CPWL_Utils::ScaleRect(const CFX_FloatRect& rcRect,
364 FX_FLOAT fScale) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700365 FX_FLOAT fHalfWidth = (rcRect.right - rcRect.left) / 2.0f;
366 FX_FLOAT fHalfHeight = (rcRect.top - rcRect.bottom) / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700367
Dan Sinclairf528eee2017-02-14 11:52:07 -0500368 CFX_PointF ptCenter = CFX_PointF((rcRect.left + rcRect.right) / 2,
369 (rcRect.top + rcRect.bottom) / 2);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700370
Tom Sepez281a9ea2016-02-26 14:24:28 -0800371 return CFX_FloatRect(
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700372 ptCenter.x - fHalfWidth * fScale, ptCenter.y - fHalfHeight * fScale,
373 ptCenter.x + fHalfWidth * fScale, ptCenter.y + fHalfHeight * fScale);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700374}
375
Tom Sepez281a9ea2016-02-26 14:24:28 -0800376CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700377 const CPWL_Color& color) {
378 CFX_ByteTextBuf sAppStream;
tsepez4cf55152016-11-02 14:37:54 -0700379 CFX_ByteString sColor = GetColorAppStream(color, true);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700380 if (sColor.GetLength() > 0) {
381 sAppStream << "q\n" << sColor;
382 sAppStream << rect.left << " " << rect.bottom << " "
383 << rect.right - rect.left << " " << rect.top - rect.bottom
384 << " re f\nQ\n";
385 }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700386
tsepez71a452f2016-05-13 17:51:27 -0700387 return sAppStream.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700388}
389
Tom Sepez281a9ea2016-02-26 14:24:28 -0800390CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700391 const CPWL_Color& color) {
392 CFX_ByteTextBuf sAppStream;
tsepez4cf55152016-11-02 14:37:54 -0700393 CFX_ByteString sColor = GetColorAppStream(color, true);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700394 if (sColor.GetLength() > 0) {
395 sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n";
396 }
tsepez71a452f2016-05-13 17:51:27 -0700397 return sAppStream.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700398}
399
Tom Sepez281a9ea2016-02-26 14:24:28 -0800400CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700401 FX_FLOAT fWidth = rect.right - rect.left;
402 FX_FLOAT fHeight = rect.top - rect.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700403
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700404 FX_FLOAT fCenterX = (rect.left + rect.right) / 2.0f;
405 FX_FLOAT fCenterY = (rect.top + rect.bottom) / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700406
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700407 FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700408
Tom Sepez281a9ea2016-02-26 14:24:28 -0800409 return CFX_FloatRect(fCenterX - fRadius, fCenterY - fRadius,
410 fCenterX + fRadius, fCenterY + fRadius);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700411}
412
dsinclaire35af1e2016-07-13 11:26:20 -0700413CFX_ByteString CPWL_Utils::GetEditAppStream(CFX_Edit* pEdit,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500414 const CFX_PointF& ptOffset,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700415 const CPVT_WordRange* pRange,
tsepez4cf55152016-11-02 14:37:54 -0700416 bool bContinuous,
Tom Sepez62a70f92016-03-21 15:00:20 -0700417 uint16_t SubWord) {
dsinclaire35af1e2016-07-13 11:26:20 -0700418 return CFX_Edit::GetEditAppearanceStream(pEdit, ptOffset, pRange, bContinuous,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700419 SubWord);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700420}
421
dsinclaire35af1e2016-07-13 11:26:20 -0700422CFX_ByteString CPWL_Utils::GetEditSelAppStream(CFX_Edit* pEdit,
Dan Sinclairf528eee2017-02-14 11:52:07 -0500423 const CFX_PointF& ptOffset,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700424 const CPVT_WordRange* pRange) {
dsinclaire35af1e2016-07-13 11:26:20 -0700425 return CFX_Edit::GetSelectAppearanceStream(pEdit, ptOffset, pRange);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700426}
427
Tom Sepez281a9ea2016-02-26 14:24:28 -0800428CFX_ByteString CPWL_Utils::GetTextAppStream(const CFX_FloatRect& rcBBox,
dsinclairc7a73492016-04-05 12:01:42 -0700429 IPVT_FontMap* pFontMap,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700430 const CFX_WideString& sText,
431 int32_t nAlignmentH,
432 int32_t nAlignmentV,
433 FX_FLOAT fFontSize,
tsepez4cf55152016-11-02 14:37:54 -0700434 bool bMultiLine,
435 bool bAutoReturn,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700436 const CPWL_Color& crText) {
437 CFX_ByteTextBuf sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700438
dsinclaire35af1e2016-07-13 11:26:20 -0700439 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit);
thestig732f6a02016-05-12 10:41:56 -0700440 pEdit->SetFontMap(pFontMap);
441 pEdit->SetPlateRect(rcBBox);
tsepez4cf55152016-11-02 14:37:54 -0700442 pEdit->SetAlignmentH(nAlignmentH, true);
443 pEdit->SetAlignmentV(nAlignmentV, true);
444 pEdit->SetMultiLine(bMultiLine, true);
445 pEdit->SetAutoReturn(bAutoReturn, true);
thestig732f6a02016-05-12 10:41:56 -0700446 if (IsFloatZero(fFontSize))
tsepez4cf55152016-11-02 14:37:54 -0700447 pEdit->SetAutoFontSize(true, true);
thestig732f6a02016-05-12 10:41:56 -0700448 else
449 pEdit->SetFontSize(fFontSize);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700450
thestig732f6a02016-05-12 10:41:56 -0700451 pEdit->Initialize();
tsepez067990c2016-09-13 06:46:40 -0700452 pEdit->SetText(sText);
Tom Sepez4f7bc042015-04-27 12:06:58 -0700453
thestig732f6a02016-05-12 10:41:56 -0700454 CFX_ByteString sEdit =
Dan Sinclairf528eee2017-02-14 11:52:07 -0500455 CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, 0.0f));
thestig732f6a02016-05-12 10:41:56 -0700456 if (sEdit.GetLength() > 0)
457 sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700458
tsepez71a452f2016-05-13 17:51:27 -0700459 return sRet.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700460}
461
Tom Sepez281a9ea2016-02-26 14:24:28 -0800462CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox,
dsinclairc7a73492016-04-05 12:01:42 -0700463 IPVT_FontMap* pFontMap,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700464 CPDF_Stream* pIconStream,
465 CPDF_IconFit& IconFit,
466 const CFX_WideString& sLabel,
467 const CPWL_Color& crText,
468 FX_FLOAT fFontSize,
469 int32_t nLayOut) {
470 const FX_FLOAT fAutoFontScale = 1.0f / 3.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700471
dsinclaire35af1e2016-07-13 11:26:20 -0700472 std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit);
thestig732f6a02016-05-12 10:41:56 -0700473 pEdit->SetFontMap(pFontMap);
tsepez4cf55152016-11-02 14:37:54 -0700474 pEdit->SetAlignmentH(1, true);
475 pEdit->SetAlignmentV(1, true);
476 pEdit->SetMultiLine(false, true);
477 pEdit->SetAutoReturn(false, true);
thestig732f6a02016-05-12 10:41:56 -0700478 if (IsFloatZero(fFontSize))
tsepez4cf55152016-11-02 14:37:54 -0700479 pEdit->SetAutoFontSize(true, true);
thestig732f6a02016-05-12 10:41:56 -0700480 else
481 pEdit->SetFontSize(fFontSize);
Tom Sepez4f7bc042015-04-27 12:06:58 -0700482
thestig732f6a02016-05-12 10:41:56 -0700483 pEdit->Initialize();
tsepez067990c2016-09-13 06:46:40 -0700484 pEdit->SetText(sLabel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700485
thestig732f6a02016-05-12 10:41:56 -0700486 CFX_FloatRect rcLabelContent = pEdit->GetContentRect();
487 CPWL_Icon Icon;
488 PWL_CREATEPARAM cp;
489 cp.dwFlags = PWS_VISIBLE;
490 Icon.Create(cp);
491 Icon.SetIconFit(&IconFit);
492 Icon.SetPDFStream(pIconStream);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700493
thestig732f6a02016-05-12 10:41:56 -0700494 CFX_FloatRect rcLabel = CFX_FloatRect(0, 0, 0, 0);
495 CFX_FloatRect rcIcon = CFX_FloatRect(0, 0, 0, 0);
496 FX_FLOAT fWidth = 0.0f;
497 FX_FLOAT fHeight = 0.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700498
thestig732f6a02016-05-12 10:41:56 -0700499 switch (nLayOut) {
500 case PPBL_LABEL:
501 rcLabel = rcBBox;
502 rcIcon = CFX_FloatRect(0, 0, 0, 0);
503 break;
504 case PPBL_ICON:
505 rcIcon = rcBBox;
506 rcLabel = CFX_FloatRect(0, 0, 0, 0);
507 break;
508 case PPBL_ICONTOPLABELBOTTOM:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700509
thestig732f6a02016-05-12 10:41:56 -0700510 if (pIconStream) {
511 if (IsFloatZero(fFontSize)) {
512 fHeight = rcBBox.top - rcBBox.bottom;
513 rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
514 rcBBox.bottom + fHeight * fAutoFontScale);
515 rcIcon =
516 CFX_FloatRect(rcBBox.left, rcLabel.top, rcBBox.right, rcBBox.top);
517 } else {
518 fHeight = rcLabelContent.Height();
519
520 if (rcBBox.bottom + fHeight > rcBBox.top) {
521 rcIcon = CFX_FloatRect(0, 0, 0, 0);
522 rcLabel = rcBBox;
523 } else {
Tom Sepez281a9ea2016-02-26 14:24:28 -0800524 rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
thestig732f6a02016-05-12 10:41:56 -0700525 rcBBox.bottom + fHeight);
Tom Sepez281a9ea2016-02-26 14:24:28 -0800526 rcIcon = CFX_FloatRect(rcBBox.left, rcLabel.top, rcBBox.right,
527 rcBBox.top);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700528 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700529 }
thestig732f6a02016-05-12 10:41:56 -0700530 } else {
531 rcLabel = rcBBox;
532 rcIcon = CFX_FloatRect(0, 0, 0, 0);
533 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700534
thestig732f6a02016-05-12 10:41:56 -0700535 break;
536 case PPBL_LABELTOPICONBOTTOM:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700537
thestig732f6a02016-05-12 10:41:56 -0700538 if (pIconStream) {
539 if (IsFloatZero(fFontSize)) {
540 fHeight = rcBBox.top - rcBBox.bottom;
541 rcLabel =
542 CFX_FloatRect(rcBBox.left, rcBBox.top - fHeight * fAutoFontScale,
543 rcBBox.right, rcBBox.top);
544 rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
545 rcLabel.bottom);
546 } else {
547 fHeight = rcLabelContent.Height();
548
549 if (rcBBox.bottom + fHeight > rcBBox.top) {
550 rcIcon = CFX_FloatRect(0, 0, 0, 0);
551 rcLabel = rcBBox;
552 } else {
553 rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.top - fHeight,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800554 rcBBox.right, rcBBox.top);
555 rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right,
556 rcLabel.bottom);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700557 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700558 }
thestig732f6a02016-05-12 10:41:56 -0700559 } else {
560 rcLabel = rcBBox;
561 rcIcon = CFX_FloatRect(0, 0, 0, 0);
562 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700563
thestig732f6a02016-05-12 10:41:56 -0700564 break;
565 case PPBL_ICONLEFTLABELRIGHT:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700566
thestig732f6a02016-05-12 10:41:56 -0700567 if (pIconStream) {
568 if (IsFloatZero(fFontSize)) {
569 fWidth = rcBBox.right - rcBBox.left;
570 rcLabel = CFX_FloatRect(rcBBox.right - fWidth * fAutoFontScale,
Tom Sepez281a9ea2016-02-26 14:24:28 -0800571 rcBBox.bottom, rcBBox.right, rcBBox.top);
thestig732f6a02016-05-12 10:41:56 -0700572 rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
573 rcBBox.top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700574
thestig732f6a02016-05-12 10:41:56 -0700575 if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
576 } else {
577 if (rcLabelContent.Width() < fWidth) {
578 rcLabel = CFX_FloatRect(rcBBox.right - rcLabelContent.Width(),
579 rcBBox.bottom, rcBBox.right, rcBBox.top);
Tom Sepez281a9ea2016-02-26 14:24:28 -0800580 rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
581 rcBBox.top);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700582 } else {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700583 rcLabel = rcBBox;
Tom Sepez281a9ea2016-02-26 14:24:28 -0800584 rcIcon = CFX_FloatRect(0, 0, 0, 0);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700585 }
586 }
587 } else {
thestig732f6a02016-05-12 10:41:56 -0700588 fWidth = rcLabelContent.Width();
589
590 if (rcBBox.left + fWidth > rcBBox.right) {
591 rcLabel = rcBBox;
592 rcIcon = CFX_FloatRect(0, 0, 0, 0);
593 } else {
594 rcLabel = CFX_FloatRect(rcBBox.right - fWidth, rcBBox.bottom,
595 rcBBox.right, rcBBox.top);
596 rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left,
597 rcBBox.top);
598 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700599 }
thestig732f6a02016-05-12 10:41:56 -0700600 } else {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700601 rcLabel = rcBBox;
thestig732f6a02016-05-12 10:41:56 -0700602 rcIcon = CFX_FloatRect(0, 0, 0, 0);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700603 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700604
thestig732f6a02016-05-12 10:41:56 -0700605 break;
606 case PPBL_LABELLEFTICONRIGHT:
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700607
thestig732f6a02016-05-12 10:41:56 -0700608 if (pIconStream) {
609 if (IsFloatZero(fFontSize)) {
610 fWidth = rcBBox.right - rcBBox.left;
611 rcLabel =
612 CFX_FloatRect(rcBBox.left, rcBBox.bottom,
613 rcBBox.left + fWidth * fAutoFontScale, rcBBox.top);
614 rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
615 rcBBox.top);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700616
thestig732f6a02016-05-12 10:41:56 -0700617 if (rcLabelContent.Width() < fWidth * fAutoFontScale) {
618 } else {
619 if (rcLabelContent.Width() < fWidth) {
620 rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
621 rcBBox.left + rcLabelContent.Width(),
622 rcBBox.top);
623 rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
624 rcBBox.top);
625 } else {
626 rcLabel = rcBBox;
627 rcIcon = CFX_FloatRect(0, 0, 0, 0);
628 }
629 }
630 } else {
631 fWidth = rcLabelContent.Width();
632
633 if (rcBBox.left + fWidth > rcBBox.right) {
634 rcLabel = rcBBox;
635 rcIcon = CFX_FloatRect(0, 0, 0, 0);
636 } else {
637 rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom,
638 rcBBox.left + fWidth, rcBBox.top);
639 rcIcon = CFX_FloatRect(rcLabel.right, rcBBox.bottom, rcBBox.right,
640 rcBBox.top);
641 }
642 }
643 } else {
644 rcLabel = rcBBox;
645 rcIcon = CFX_FloatRect(0, 0, 0, 0);
646 }
647
648 break;
649 case PPBL_LABELOVERICON:
650 rcLabel = rcBBox;
651 rcIcon = rcBBox;
652 break;
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700653 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700654
thestig732f6a02016-05-12 10:41:56 -0700655 CFX_ByteTextBuf sAppStream, sTemp;
656
657 if (!rcIcon.IsEmpty()) {
tsepez4cf55152016-11-02 14:37:54 -0700658 Icon.Move(rcIcon, false, false);
thestig732f6a02016-05-12 10:41:56 -0700659 sTemp << Icon.GetImageAppStream();
660 }
661
662 Icon.Destroy();
663
664 if (!rcLabel.IsEmpty()) {
665 pEdit->SetPlateRect(rcLabel);
666 CFX_ByteString sEdit =
Dan Sinclairf528eee2017-02-14 11:52:07 -0500667 CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, 0.0f));
thestig732f6a02016-05-12 10:41:56 -0700668 if (sEdit.GetLength() > 0) {
669 sTemp << "BT\n"
670 << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n";
671 }
672 }
673
thestig732f6a02016-05-12 10:41:56 -0700674 if (sTemp.GetSize() > 0) {
675 sAppStream << "q\n"
676 << rcBBox.left << " " << rcBBox.bottom << " "
677 << rcBBox.right - rcBBox.left << " "
678 << rcBBox.top - rcBBox.bottom << " re W n\n";
679 sAppStream << sTemp << "Q\n";
680 }
tsepez71a452f2016-05-13 17:51:27 -0700681 return sAppStream.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700682}
683
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700684CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color,
tsepez4cf55152016-11-02 14:37:54 -0700685 const bool& bFillOrStroke) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700686 CFX_ByteTextBuf sColorStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700687
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700688 switch (color.nColorType) {
689 case COLORTYPE_RGB:
690 sColorStream << color.fColor1 << " " << color.fColor2 << " "
691 << color.fColor3 << " " << (bFillOrStroke ? "rg" : "RG")
692 << "\n";
693 break;
694 case COLORTYPE_GRAY:
695 sColorStream << color.fColor1 << " " << (bFillOrStroke ? "g" : "G")
696 << "\n";
697 break;
698 case COLORTYPE_CMYK:
699 sColorStream << color.fColor1 << " " << color.fColor2 << " "
700 << color.fColor3 << " " << color.fColor4 << " "
701 << (bFillOrStroke ? "k" : "K") << "\n";
702 break;
703 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700704
tsepez71a452f2016-05-13 17:51:27 -0700705 return sColorStream.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700706}
707
Tom Sepez281a9ea2016-02-26 14:24:28 -0800708CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700709 FX_FLOAT fWidth,
710 const CPWL_Color& color,
711 const CPWL_Color& crLeftTop,
712 const CPWL_Color& crRightBottom,
dsinclair92cb5e52016-05-16 11:38:28 -0700713 BorderStyle nStyle,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700714 const CPWL_Dash& dash) {
715 CFX_ByteTextBuf sAppStream;
716 CFX_ByteString sColor;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700717
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700718 FX_FLOAT fLeft = rect.left;
719 FX_FLOAT fRight = rect.right;
720 FX_FLOAT fTop = rect.top;
721 FX_FLOAT fBottom = rect.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700722
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700723 if (fWidth > 0.0f) {
724 FX_FLOAT fHalfWidth = fWidth / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700725
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700726 sAppStream << "q\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700727
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700728 switch (nStyle) {
729 default:
dsinclair92cb5e52016-05-16 11:38:28 -0700730 case BorderStyle::SOLID:
tsepez4cf55152016-11-02 14:37:54 -0700731 sColor = CPWL_Utils::GetColorAppStream(color, true);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700732 if (sColor.GetLength() > 0) {
733 sAppStream << sColor;
734 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
735 << fTop - fBottom << " re\n";
736 sAppStream << fLeft + fWidth << " " << fBottom + fWidth << " "
737 << fRight - fLeft - fWidth * 2 << " "
738 << fTop - fBottom - fWidth * 2 << " re\n";
739 sAppStream << "f*\n";
740 }
741 break;
dsinclair92cb5e52016-05-16 11:38:28 -0700742 case BorderStyle::DASH:
tsepez4cf55152016-11-02 14:37:54 -0700743 sColor = CPWL_Utils::GetColorAppStream(color, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700744 if (sColor.GetLength() > 0) {
745 sAppStream << sColor;
746 sAppStream << fWidth << " w"
747 << " [" << dash.nDash << " " << dash.nGap << "] "
748 << dash.nPhase << " d\n";
749 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
750 << " m\n";
751 sAppStream << fLeft + fWidth / 2 << " " << fTop - fWidth / 2
752 << " l\n";
753 sAppStream << fRight - fWidth / 2 << " " << fTop - fWidth / 2
754 << " l\n";
755 sAppStream << fRight - fWidth / 2 << " " << fBottom + fWidth / 2
756 << " l\n";
757 sAppStream << fLeft + fWidth / 2 << " " << fBottom + fWidth / 2
758 << " l S\n";
759 }
760 break;
dsinclair92cb5e52016-05-16 11:38:28 -0700761 case BorderStyle::BEVELED:
762 case BorderStyle::INSET:
tsepez4cf55152016-11-02 14:37:54 -0700763 sColor = CPWL_Utils::GetColorAppStream(crLeftTop, true);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700764 if (sColor.GetLength() > 0) {
765 sAppStream << sColor;
766 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
767 << " m\n";
768 sAppStream << fLeft + fHalfWidth << " " << fTop - fHalfWidth
769 << " l\n";
770 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
771 << " l\n";
772 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
773 << " l\n";
774 sAppStream << fLeft + fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
775 << " l\n";
776 sAppStream << fLeft + fHalfWidth * 2 << " "
777 << fBottom + fHalfWidth * 2 << " l f\n";
778 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700779
tsepez4cf55152016-11-02 14:37:54 -0700780 sColor = CPWL_Utils::GetColorAppStream(crRightBottom, true);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700781 if (sColor.GetLength() > 0) {
782 sAppStream << sColor;
783 sAppStream << fRight - fHalfWidth << " " << fTop - fHalfWidth
784 << " m\n";
785 sAppStream << fRight - fHalfWidth << " " << fBottom + fHalfWidth
786 << " l\n";
787 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth
788 << " l\n";
789 sAppStream << fLeft + fHalfWidth * 2 << " "
790 << fBottom + fHalfWidth * 2 << " l\n";
791 sAppStream << fRight - fHalfWidth * 2 << " "
792 << fBottom + fHalfWidth * 2 << " l\n";
793 sAppStream << fRight - fHalfWidth * 2 << " " << fTop - fHalfWidth * 2
794 << " l f\n";
795 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700796
tsepez4cf55152016-11-02 14:37:54 -0700797 sColor = CPWL_Utils::GetColorAppStream(color, true);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700798 if (sColor.GetLength() > 0) {
799 sAppStream << sColor;
800 sAppStream << fLeft << " " << fBottom << " " << fRight - fLeft << " "
801 << fTop - fBottom << " re\n";
802 sAppStream << fLeft + fHalfWidth << " " << fBottom + fHalfWidth << " "
803 << fRight - fLeft - fHalfWidth * 2 << " "
804 << fTop - fBottom - fHalfWidth * 2 << " re f*\n";
805 }
806 break;
dsinclair92cb5e52016-05-16 11:38:28 -0700807 case BorderStyle::UNDERLINE:
tsepez4cf55152016-11-02 14:37:54 -0700808 sColor = CPWL_Utils::GetColorAppStream(color, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700809 if (sColor.GetLength() > 0) {
810 sAppStream << sColor;
811 sAppStream << fWidth << " w\n";
812 sAppStream << fLeft << " " << fBottom + fWidth / 2 << " m\n";
813 sAppStream << fRight << " " << fBottom + fWidth / 2 << " l S\n";
814 }
815 break;
816 }
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700817
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700818 sAppStream << "Q\n";
819 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700820
tsepez71a452f2016-05-13 17:51:27 -0700821 return sAppStream.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700822}
823
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700824CFX_ByteString CPWL_Utils::GetCircleBorderAppStream(
Tom Sepez281a9ea2016-02-26 14:24:28 -0800825 const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700826 FX_FLOAT fWidth,
827 const CPWL_Color& color,
828 const CPWL_Color& crLeftTop,
829 const CPWL_Color& crRightBottom,
dsinclair92cb5e52016-05-16 11:38:28 -0700830 BorderStyle nStyle,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700831 const CPWL_Dash& dash) {
832 CFX_ByteTextBuf sAppStream;
833 CFX_ByteString sColor;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700834
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700835 if (fWidth > 0.0f) {
836 sAppStream << "q\n";
Lei Zhanga6d9f0e2015-06-13 00:48:38 -0700837
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700838 switch (nStyle) {
839 default:
dsinclair92cb5e52016-05-16 11:38:28 -0700840 case BorderStyle::SOLID:
841 case BorderStyle::UNDERLINE: {
tsepez4cf55152016-11-02 14:37:54 -0700842 sColor = CPWL_Utils::GetColorAppStream(color, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700843 if (sColor.GetLength() > 0) {
844 sAppStream << "q\n" << fWidth << " w\n" << sColor
845 << CPWL_Utils::GetAP_Circle(
846 CPWL_Utils::DeflateRect(rect, fWidth / 2.0f))
847 << " S\nQ\n";
848 }
849 } break;
dsinclair92cb5e52016-05-16 11:38:28 -0700850 case BorderStyle::DASH: {
tsepez4cf55152016-11-02 14:37:54 -0700851 sColor = CPWL_Utils::GetColorAppStream(color, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700852 if (sColor.GetLength() > 0) {
853 sAppStream << "q\n" << fWidth << " w\n"
854 << "[" << dash.nDash << " " << dash.nGap << "] "
855 << dash.nPhase << " d\n" << sColor
856 << CPWL_Utils::GetAP_Circle(
857 CPWL_Utils::DeflateRect(rect, fWidth / 2.0f))
858 << " S\nQ\n";
859 }
860 } break;
dsinclair92cb5e52016-05-16 11:38:28 -0700861 case BorderStyle::BEVELED: {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700862 FX_FLOAT fHalfWidth = fWidth / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700863
tsepez4cf55152016-11-02 14:37:54 -0700864 sColor = CPWL_Utils::GetColorAppStream(color, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700865 if (sColor.GetLength() > 0) {
866 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
867 << CPWL_Utils::GetAP_Circle(rect) << " S\nQ\n";
868 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700869
tsepez4cf55152016-11-02 14:37:54 -0700870 sColor = CPWL_Utils::GetColorAppStream(crLeftTop, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700871 if (sColor.GetLength() > 0) {
872 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
873 << CPWL_Utils::GetAP_HalfCircle(
874 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
Tom Sepeza30b7e82016-02-12 15:58:50 -0800875 FX_PI / 4.0f)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700876 << " S\nQ\n";
877 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700878
tsepez4cf55152016-11-02 14:37:54 -0700879 sColor = CPWL_Utils::GetColorAppStream(crRightBottom, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700880 if (sColor.GetLength() > 0) {
881 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
882 << CPWL_Utils::GetAP_HalfCircle(
883 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
Tom Sepeza30b7e82016-02-12 15:58:50 -0800884 FX_PI * 5 / 4.0f)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700885 << " S\nQ\n";
886 }
887 } break;
dsinclair92cb5e52016-05-16 11:38:28 -0700888 case BorderStyle::INSET: {
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700889 FX_FLOAT fHalfWidth = fWidth / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700890
tsepez4cf55152016-11-02 14:37:54 -0700891 sColor = CPWL_Utils::GetColorAppStream(color, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700892 if (sColor.GetLength() > 0) {
893 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
894 << CPWL_Utils::GetAP_Circle(rect) << " S\nQ\n";
895 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700896
tsepez4cf55152016-11-02 14:37:54 -0700897 sColor = CPWL_Utils::GetColorAppStream(crLeftTop, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700898 if (sColor.GetLength() > 0) {
899 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
900 << CPWL_Utils::GetAP_HalfCircle(
901 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
Tom Sepeza30b7e82016-02-12 15:58:50 -0800902 FX_PI / 4.0f)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700903 << " S\nQ\n";
904 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700905
tsepez4cf55152016-11-02 14:37:54 -0700906 sColor = CPWL_Utils::GetColorAppStream(crRightBottom, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700907 if (sColor.GetLength() > 0) {
908 sAppStream << "q\n" << fHalfWidth << " w\n" << sColor
909 << CPWL_Utils::GetAP_HalfCircle(
910 CPWL_Utils::DeflateRect(rect, fHalfWidth * 0.75f),
Tom Sepeza30b7e82016-02-12 15:58:50 -0800911 FX_PI * 5 / 4.0f)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700912 << " S\nQ\n";
913 }
914 } break;
915 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700916
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700917 sAppStream << "Q\n";
918 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700919
tsepez71a452f2016-05-13 17:51:27 -0700920 return sAppStream.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700921}
922
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700923CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor,
924 FX_FLOAT fColorSub) {
925 CPWL_Color sRet;
926 sRet.nColorType = sColor.nColorType;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700927
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700928 switch (sColor.nColorType) {
929 case COLORTYPE_TRANSPARENT:
930 sRet.nColorType = COLORTYPE_RGB;
931 sRet.fColor1 = PWL_MAX(1 - fColorSub, 0.0f);
932 sRet.fColor2 = PWL_MAX(1 - fColorSub, 0.0f);
933 sRet.fColor3 = PWL_MAX(1 - fColorSub, 0.0f);
934 break;
935 case COLORTYPE_RGB:
936 case COLORTYPE_GRAY:
937 case COLORTYPE_CMYK:
938 sRet.fColor1 = PWL_MAX(sColor.fColor1 - fColorSub, 0.0f);
939 sRet.fColor2 = PWL_MAX(sColor.fColor2 - fColorSub, 0.0f);
940 sRet.fColor3 = PWL_MAX(sColor.fColor3 - fColorSub, 0.0f);
941 sRet.fColor4 = PWL_MAX(sColor.fColor4 - fColorSub, 0.0f);
942 break;
943 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700944
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700945 return sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700946}
947
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700948CPWL_Color CPWL_Utils::DevideColor(const CPWL_Color& sColor,
949 FX_FLOAT fColorDevide) {
950 CPWL_Color sRet;
951 sRet.nColorType = sColor.nColorType;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700952
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700953 switch (sColor.nColorType) {
954 case COLORTYPE_TRANSPARENT:
955 sRet.nColorType = COLORTYPE_RGB;
956 sRet.fColor1 = 1 / fColorDevide;
957 sRet.fColor2 = 1 / fColorDevide;
958 sRet.fColor3 = 1 / fColorDevide;
959 break;
960 case COLORTYPE_RGB:
961 case COLORTYPE_GRAY:
962 case COLORTYPE_CMYK:
963 sRet = sColor;
964 sRet.fColor1 /= fColorDevide;
965 sRet.fColor2 /= fColorDevide;
966 sRet.fColor3 /= fColorDevide;
967 sRet.fColor4 /= fColorDevide;
968 break;
969 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700970
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700971 return sRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700972}
973
Tom Sepez281a9ea2016-02-26 14:24:28 -0800974CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700975 const CPWL_Color& crText) {
976 CFX_ByteTextBuf sAP;
tsepez4cf55152016-11-02 14:37:54 -0700977 sAP << "q\n"
978 << CPWL_Utils::GetColorAppStream(crText, true)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700979 << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n";
tsepez71a452f2016-05-13 17:51:27 -0700980 return sAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700981}
982
Tom Sepez281a9ea2016-02-26 14:24:28 -0800983CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700984 const CPWL_Color& crText) {
985 CFX_ByteTextBuf sAP;
tsepez4cf55152016-11-02 14:37:54 -0700986 sAP << "q\n"
987 << CPWL_Utils::GetColorAppStream(crText, true)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700988 << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n";
tsepez71a452f2016-05-13 17:51:27 -0700989 return sAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700990}
991
Tom Sepez281a9ea2016-02-26 14:24:28 -0800992CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700993 const CPWL_Color& crText) {
994 CFX_ByteTextBuf sAP;
tsepez4cf55152016-11-02 14:37:54 -0700995 sAP << "q\n"
996 << CPWL_Utils::GetColorAppStream(crText, false)
Nico Weber9d8ec5a2015-08-04 13:00:21 -0700997 << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n";
tsepez71a452f2016-05-13 17:51:27 -0700998 return sAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700999}
1000
Tom Sepez281a9ea2016-02-26 14:24:28 -08001001CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001002 const CPWL_Color& crText) {
1003 CFX_ByteTextBuf sAP;
tsepez4cf55152016-11-02 14:37:54 -07001004 sAP << "q\n1 w\n"
1005 << CPWL_Utils::GetColorAppStream(crText, true)
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001006 << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n";
tsepez71a452f2016-05-13 17:51:27 -07001007 return sAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001008}
1009
Tom Sepez281a9ea2016-02-26 14:24:28 -08001010CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001011 const CPWL_Color& crText) {
1012 CFX_ByteTextBuf sAP;
tsepez4cf55152016-11-02 14:37:54 -07001013 sAP << "q\n"
1014 << CPWL_Utils::GetColorAppStream(crText, true)
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001015 << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n";
tsepez71a452f2016-05-13 17:51:27 -07001016 return sAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001017}
1018
Tom Sepez281a9ea2016-02-26 14:24:28 -08001019CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001020 const CPWL_Color& crText) {
1021 CFX_ByteTextBuf sAP;
tsepez4cf55152016-11-02 14:37:54 -07001022 sAP << "q\n"
1023 << CPWL_Utils::GetColorAppStream(crText, true)
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001024 << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n";
tsepez71a452f2016-05-13 17:51:27 -07001025 return sAP.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001026}
1027
Tom Sepez281a9ea2016-02-26 14:24:28 -08001028CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001029 int32_t nStyle,
1030 const CPWL_Color& crText) {
Tom Sepez281a9ea2016-02-26 14:24:28 -08001031 CFX_FloatRect rcCenter = GetCenterSquare(rcBBox);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001032 switch (nStyle) {
1033 default:
1034 case PCS_CHECK:
1035 return GetAppStream_Check(rcCenter, crText);
1036 case PCS_CIRCLE:
1037 return GetAppStream_Circle(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1038 case PCS_CROSS:
1039 return GetAppStream_Cross(rcCenter, crText);
1040 case PCS_DIAMOND:
1041 return GetAppStream_Diamond(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1042 case PCS_SQUARE:
1043 return GetAppStream_Square(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1044 case PCS_STAR:
1045 return GetAppStream_Star(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1046 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001047}
1048
Tom Sepez281a9ea2016-02-26 14:24:28 -08001049CFX_ByteString CPWL_Utils::GetRadioButtonAppStream(const CFX_FloatRect& rcBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001050 int32_t nStyle,
1051 const CPWL_Color& crText) {
Tom Sepez281a9ea2016-02-26 14:24:28 -08001052 CFX_FloatRect rcCenter = GetCenterSquare(rcBBox);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001053 switch (nStyle) {
1054 default:
1055 case PCS_CHECK:
1056 return GetAppStream_Check(rcCenter, crText);
1057 case PCS_CIRCLE:
1058 return GetAppStream_Circle(ScaleRect(rcCenter, 1.0f / 2.0f), crText);
1059 case PCS_CROSS:
1060 return GetAppStream_Cross(rcCenter, crText);
1061 case PCS_DIAMOND:
1062 return GetAppStream_Diamond(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1063 case PCS_SQUARE:
1064 return GetAppStream_Square(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1065 case PCS_STAR:
1066 return GetAppStream_Star(ScaleRect(rcCenter, 2.0f / 3.0f), crText);
1067 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001068}
1069
Tom Sepez281a9ea2016-02-26 14:24:28 -08001070CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001071 CFX_ByteTextBuf sAppStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001072
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001073 if (!rcBBox.IsEmpty()) {
tsepez4cf55152016-11-02 14:37:54 -07001074 sAppStream << "q\n"
1075 << CPWL_Utils::GetColorAppStream(
1076 CPWL_Color(COLORTYPE_RGB, 220.0f / 255.0f,
1077 220.0f / 255.0f, 220.0f / 255.0f),
1078 true);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001079 sAppStream << rcBBox.left << " " << rcBBox.bottom << " "
1080 << rcBBox.right - rcBBox.left << " "
1081 << rcBBox.top - rcBBox.bottom << " re f\n";
1082 sAppStream << "Q\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001083
dsinclair92cb5e52016-05-16 11:38:28 -07001084 sAppStream << "q\n"
1085 << CPWL_Utils::GetBorderAppStream(
1086 rcBBox, 2, CPWL_Color(COLORTYPE_GRAY, 0),
1087 CPWL_Color(COLORTYPE_GRAY, 1),
1088 CPWL_Color(COLORTYPE_GRAY, 0.5), BorderStyle::BEVELED,
1089 CPWL_Dash(3, 0, 0))
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001090 << "Q\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001091
Dan Sinclairf528eee2017-02-14 11:52:07 -05001092 CFX_PointF ptCenter = CFX_PointF((rcBBox.left + rcBBox.right) / 2,
1093 (rcBBox.top + rcBBox.bottom) / 2);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001094 if (IsFloatBigger(rcBBox.right - rcBBox.left, 6) &&
1095 IsFloatBigger(rcBBox.top - rcBBox.bottom, 6)) {
1096 sAppStream << "q\n"
1097 << " 0 g\n";
1098 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " m\n";
1099 sAppStream << ptCenter.x + 3 << " " << ptCenter.y + 1.5f << " l\n";
1100 sAppStream << ptCenter.x << " " << ptCenter.y - 1.5f << " l\n";
1101 sAppStream << ptCenter.x - 3 << " " << ptCenter.y + 1.5f << " l f\n";
1102 sAppStream << "Q\n";
1103 }
1104 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001105
tsepez71a452f2016-05-13 17:51:27 -07001106 return sAppStream.MakeString();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001107}
1108
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001109void CPWL_Utils::ConvertCMYK2GRAY(FX_FLOAT dC,
1110 FX_FLOAT dM,
1111 FX_FLOAT dY,
1112 FX_FLOAT dK,
1113 FX_FLOAT& dGray) {
1114 if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 ||
1115 dK > 1)
1116 return;
Lei Zhang375a8642016-01-11 11:59:17 -08001117 dGray = 1.0f - std::min(1.0f, 0.3f * dC + 0.59f * dM + 0.11f * dY + dK);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001118}
1119
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001120void CPWL_Utils::ConvertGRAY2CMYK(FX_FLOAT dGray,
1121 FX_FLOAT& dC,
1122 FX_FLOAT& dM,
1123 FX_FLOAT& dY,
1124 FX_FLOAT& dK) {
1125 if (dGray < 0 || dGray > 1)
1126 return;
1127 dC = 0.0f;
1128 dM = 0.0f;
1129 dY = 0.0f;
1130 dK = 1.0f - dGray;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001131}
1132
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001133void CPWL_Utils::ConvertGRAY2RGB(FX_FLOAT dGray,
1134 FX_FLOAT& dR,
1135 FX_FLOAT& dG,
1136 FX_FLOAT& dB) {
1137 if (dGray < 0 || dGray > 1)
1138 return;
1139 dR = dGray;
1140 dG = dGray;
1141 dB = dGray;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001142}
1143
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001144void CPWL_Utils::ConvertRGB2GRAY(FX_FLOAT dR,
1145 FX_FLOAT dG,
1146 FX_FLOAT dB,
1147 FX_FLOAT& dGray) {
1148 if (dR < 0 || dR > 1 || dG < 0 || dG > 0 || dB < 0 || dB > 1)
1149 return;
1150 dGray = 0.3f * dR + 0.59f * dG + 0.11f * dB;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001151}
1152
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001153void CPWL_Utils::ConvertCMYK2RGB(FX_FLOAT dC,
1154 FX_FLOAT dM,
1155 FX_FLOAT dY,
1156 FX_FLOAT dK,
1157 FX_FLOAT& dR,
1158 FX_FLOAT& dG,
1159 FX_FLOAT& dB) {
1160 if (dC < 0 || dC > 1 || dM < 0 || dM > 1 || dY < 0 || dY > 1 || dK < 0 ||
1161 dK > 1)
1162 return;
Lei Zhang375a8642016-01-11 11:59:17 -08001163 dR = 1.0f - std::min(1.0f, dC + dK);
1164 dG = 1.0f - std::min(1.0f, dM + dK);
1165 dB = 1.0f - std::min(1.0f, dY + dK);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001166}
1167
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001168void CPWL_Utils::ConvertRGB2CMYK(FX_FLOAT dR,
1169 FX_FLOAT dG,
1170 FX_FLOAT dB,
1171 FX_FLOAT& dC,
1172 FX_FLOAT& dM,
1173 FX_FLOAT& dY,
1174 FX_FLOAT& dK) {
1175 if (dR < 0 || dR > 1 || dG < 0 || dG > 1 || dB < 0 || dB > 1)
1176 return;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001177
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001178 dC = 1.0f - dR;
1179 dM = 1.0f - dG;
1180 dY = 1.0f - dB;
Lei Zhang375a8642016-01-11 11:59:17 -08001181 dK = std::min(dC, std::min(dM, dY));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001182}
1183
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001184void CPWL_Utils::PWLColorToARGB(const CPWL_Color& color,
1185 int32_t& alpha,
1186 FX_FLOAT& red,
1187 FX_FLOAT& green,
1188 FX_FLOAT& blue) {
1189 switch (color.nColorType) {
1190 case COLORTYPE_TRANSPARENT: {
1191 alpha = 0;
1192 } break;
1193 case COLORTYPE_GRAY: {
1194 ConvertGRAY2RGB(color.fColor1, red, green, blue);
1195 } break;
1196 case COLORTYPE_RGB: {
1197 red = color.fColor1;
1198 green = color.fColor2;
1199 blue = color.fColor3;
1200 } break;
1201 case COLORTYPE_CMYK: {
1202 ConvertCMYK2RGB(color.fColor1, color.fColor2, color.fColor3,
1203 color.fColor4, red, green, blue);
1204 } break;
1205 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001206}
1207
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001208FX_COLORREF CPWL_Utils::PWLColorToFXColor(const CPWL_Color& color,
1209 int32_t nTransparancy) {
1210 int32_t nAlpha = nTransparancy;
1211 FX_FLOAT dRed = 0;
1212 FX_FLOAT dGreen = 0;
1213 FX_FLOAT dBlue = 0;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001214
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001215 PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001216
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001217 return ArgbEncode(nAlpha, (int32_t)(dRed * 255), (int32_t)(dGreen * 255),
1218 (int32_t)(dBlue * 255));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001219}
1220
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001221void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001222 CFX_Matrix* pUser2Device,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001223 const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001224 const FX_COLORREF& color) {
1225 CFX_PathData path;
Tom Sepez281a9ea2016-02-26 14:24:28 -08001226 CFX_FloatRect rcTemp(rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001227 path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top);
thestig1cd352e2016-06-07 17:53:06 -07001228 pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_WINDING);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001229}
1230
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001231void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001232 CFX_Matrix* pUser2Device,
Dan Sinclairf528eee2017-02-14 11:52:07 -05001233 const CFX_PointF* pPts,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001234 int32_t nCount,
1235 const FX_COLORREF& color) {
1236 CFX_PathData path;
1237 path.SetPointCount(nCount);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001238
Nicolas Pena79365f72017-02-07 14:21:36 -05001239 path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_TYPE::MoveTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001240 for (int32_t i = 1; i < nCount; i++)
Nicolas Pena79365f72017-02-07 14:21:36 -05001241 path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_TYPE::LineTo, false);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001242
thestig1cd352e2016-06-07 17:53:06 -07001243 pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001244}
1245
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001246void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001247 CFX_Matrix* pUser2Device,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001248 const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001249 const FX_COLORREF& color,
1250 FX_FLOAT fWidth) {
1251 CFX_PathData path;
Tom Sepez281a9ea2016-02-26 14:24:28 -08001252 CFX_FloatRect rcTemp(rect);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001253 path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07001254
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001255 CFX_GraphStateData gsd;
1256 gsd.m_LineWidth = fWidth;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001257
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001258 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001259}
1260
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001261void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001262 CFX_Matrix* pUser2Device,
Dan Sinclairf528eee2017-02-14 11:52:07 -05001263 const CFX_PointF& ptMoveTo,
1264 const CFX_PointF& ptLineTo,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001265 const FX_COLORREF& color,
1266 FX_FLOAT fWidth) {
1267 CFX_PathData path;
1268 path.SetPointCount(2);
Nicolas Pena79365f72017-02-07 14:21:36 -05001269 path.SetPoint(0, ptMoveTo.x, ptMoveTo.y, FXPT_TYPE::MoveTo, false);
1270 path.SetPoint(1, ptLineTo.x, ptLineTo.y, FXPT_TYPE::LineTo, false);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001271
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001272 CFX_GraphStateData gsd;
1273 gsd.m_LineWidth = fWidth;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001274
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001275 pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001276}
1277
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001278void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001279 CFX_Matrix* pUser2Device,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001280 const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001281 const CPWL_Color& color,
1282 int32_t nTransparancy) {
1283 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rect,
1284 PWLColorToFXColor(color, nTransparancy));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001285}
1286
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001287void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001288 CFX_Matrix* pUser2Device,
tsepez4cf55152016-11-02 14:37:54 -07001289 bool bVertical,
1290 bool bHorizontal,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001291 CFX_FloatRect rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001292 int32_t nTransparancy,
1293 int32_t nStartGray,
1294 int32_t nEndGray) {
1295 FX_FLOAT fStepGray = 1.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001296
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001297 if (bVertical) {
1298 fStepGray = (nEndGray - nStartGray) / rect.Height();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001299
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001300 for (FX_FLOAT fy = rect.bottom + 0.5f; fy <= rect.top - 0.5f; fy += 1.0f) {
1301 int32_t nGray = nStartGray + (int32_t)(fStepGray * (fy - rect.bottom));
1302 CPWL_Utils::DrawStrokeLine(
Dan Sinclairf528eee2017-02-14 11:52:07 -05001303 pDevice, pUser2Device, CFX_PointF(rect.left, fy),
1304 CFX_PointF(rect.right, fy),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001305 ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
1306 }
1307 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001308
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001309 if (bHorizontal) {
1310 fStepGray = (nEndGray - nStartGray) / rect.Width();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001311
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001312 for (FX_FLOAT fx = rect.left + 0.5f; fx <= rect.right - 0.5f; fx += 1.0f) {
1313 int32_t nGray = nStartGray + (int32_t)(fStepGray * (fx - rect.left));
1314 CPWL_Utils::DrawStrokeLine(
Dan Sinclairf528eee2017-02-14 11:52:07 -05001315 pDevice, pUser2Device, CFX_PointF(fx, rect.bottom),
1316 CFX_PointF(fx, rect.top),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001317 ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f);
1318 }
1319 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001320}
1321
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001322void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001323 CFX_Matrix* pUser2Device,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001324 const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001325 FX_FLOAT fWidth,
1326 const CPWL_Color& color,
1327 const CPWL_Color& crLeftTop,
1328 const CPWL_Color& crRightBottom,
dsinclair92cb5e52016-05-16 11:38:28 -07001329 BorderStyle nStyle,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001330 int32_t nTransparancy) {
1331 FX_FLOAT fLeft = rect.left;
1332 FX_FLOAT fRight = rect.right;
1333 FX_FLOAT fTop = rect.top;
1334 FX_FLOAT fBottom = rect.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001335
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001336 if (fWidth > 0.0f) {
1337 FX_FLOAT fHalfWidth = fWidth / 2.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001338
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001339 switch (nStyle) {
1340 default:
dsinclair92cb5e52016-05-16 11:38:28 -07001341 case BorderStyle::SOLID: {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001342 CFX_PathData path;
1343 path.AppendRect(fLeft, fBottom, fRight, fTop);
1344 path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth,
1345 fTop - fWidth);
thestig1cd352e2016-06-07 17:53:06 -07001346 pDevice->DrawPath(&path, pUser2Device, nullptr,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001347 PWLColorToFXColor(color, nTransparancy), 0,
1348 FXFILL_ALTERNATE);
dsinclair92cb5e52016-05-16 11:38:28 -07001349 break;
1350 }
1351 case BorderStyle::DASH: {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001352 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001353
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001354 path.SetPointCount(5);
1355 path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
Nicolas Pena79365f72017-02-07 14:21:36 -05001356 FXPT_TYPE::MoveTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001357 path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f,
Nicolas Pena79365f72017-02-07 14:21:36 -05001358 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001359 path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f,
Nicolas Pena79365f72017-02-07 14:21:36 -05001360 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001361 path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f,
Nicolas Pena79365f72017-02-07 14:21:36 -05001362 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001363 path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f,
Nicolas Pena79365f72017-02-07 14:21:36 -05001364 FXPT_TYPE::LineTo, false);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001365
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001366 CFX_GraphStateData gsd;
1367 gsd.SetDashCount(2);
1368 gsd.m_DashArray[0] = 3.0f;
1369 gsd.m_DashArray[1] = 3.0f;
1370 gsd.m_DashPhase = 0;
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07001371
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001372 gsd.m_LineWidth = fWidth;
1373 pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
1374 PWLColorToFXColor(color, nTransparancy),
1375 FXFILL_WINDING);
dsinclair92cb5e52016-05-16 11:38:28 -07001376 break;
1377 }
1378 case BorderStyle::BEVELED:
1379 case BorderStyle::INSET: {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001380 CFX_GraphStateData gsd;
1381 gsd.m_LineWidth = fHalfWidth;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001382
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001383 CFX_PathData pathLT;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001384
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001385 pathLT.SetPointCount(7);
1386 pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth,
Nicolas Pena79365f72017-02-07 14:21:36 -05001387 FXPT_TYPE::MoveTo, false);
1388 pathLT.SetPoint(1, fLeft + fHalfWidth, fTop - fHalfWidth,
1389 FXPT_TYPE::LineTo, false);
1390 pathLT.SetPoint(2, fRight - fHalfWidth, fTop - fHalfWidth,
1391 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001392 pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
Nicolas Pena79365f72017-02-07 14:21:36 -05001393 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001394 pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2,
Nicolas Pena79365f72017-02-07 14:21:36 -05001395 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001396 pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
Nicolas Pena79365f72017-02-07 14:21:36 -05001397 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001398 pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth,
Nicolas Pena79365f72017-02-07 14:21:36 -05001399 FXPT_TYPE::LineTo, false);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001400
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001401 pDevice->DrawPath(&pathLT, pUser2Device, &gsd,
1402 PWLColorToFXColor(crLeftTop, nTransparancy), 0,
1403 FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001404
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001405 CFX_PathData pathRB;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001406
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001407 pathRB.SetPointCount(7);
Nicolas Pena79365f72017-02-07 14:21:36 -05001408 pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth,
1409 FXPT_TYPE::MoveTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001410 pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth,
Nicolas Pena79365f72017-02-07 14:21:36 -05001411 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001412 pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth,
Nicolas Pena79365f72017-02-07 14:21:36 -05001413 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001414 pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2,
Nicolas Pena79365f72017-02-07 14:21:36 -05001415 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001416 pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2,
Nicolas Pena79365f72017-02-07 14:21:36 -05001417 FXPT_TYPE::LineTo, false);
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001418 pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2,
Nicolas Pena79365f72017-02-07 14:21:36 -05001419 FXPT_TYPE::LineTo, false);
1420 pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth,
1421 FXPT_TYPE::LineTo, false);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001422
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001423 pDevice->DrawPath(&pathRB, pUser2Device, &gsd,
1424 PWLColorToFXColor(crRightBottom, nTransparancy), 0,
1425 FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001426
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001427 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001428
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001429 path.AppendRect(fLeft, fBottom, fRight, fTop);
1430 path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth,
1431 fRight - fHalfWidth, fTop - fHalfWidth);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001432
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001433 pDevice->DrawPath(&path, pUser2Device, &gsd,
1434 PWLColorToFXColor(color, nTransparancy), 0,
1435 FXFILL_ALTERNATE);
dsinclair92cb5e52016-05-16 11:38:28 -07001436 break;
1437 }
1438 case BorderStyle::UNDERLINE: {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001439 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001440
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001441 path.SetPointCount(2);
Nicolas Pena79365f72017-02-07 14:21:36 -05001442 path.SetPoint(0, fLeft, fBottom + fWidth / 2, FXPT_TYPE::MoveTo, false);
1443 path.SetPoint(1, fRight, fBottom + fWidth / 2, FXPT_TYPE::LineTo,
1444 false);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07001445
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001446 CFX_GraphStateData gsd;
1447 gsd.m_LineWidth = fWidth;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001448
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001449 pDevice->DrawPath(&path, pUser2Device, &gsd, 0,
1450 PWLColorToFXColor(color, nTransparancy),
1451 FXFILL_ALTERNATE);
dsinclair92cb5e52016-05-16 11:38:28 -07001452 break;
1453 }
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001454 }
1455 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001456}
1457
tsepez4cf55152016-11-02 14:37:54 -07001458bool CPWL_Utils::IsBlackOrWhite(const CPWL_Color& color) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001459 switch (color.nColorType) {
1460 case COLORTYPE_TRANSPARENT:
tsepez4cf55152016-11-02 14:37:54 -07001461 return false;
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001462 case COLORTYPE_GRAY:
1463 return color.fColor1 < 0.5f;
1464 case COLORTYPE_RGB:
1465 return color.fColor1 + color.fColor2 + color.fColor3 < 1.5f;
1466 case COLORTYPE_CMYK:
1467 return color.fColor1 + color.fColor2 + color.fColor3 + color.fColor4 >
1468 2.0f;
1469 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001470
tsepez4cf55152016-11-02 14:37:54 -07001471 return true;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001472}
1473
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001474CPWL_Color CPWL_Utils::GetReverseColor(const CPWL_Color& color) {
1475 CPWL_Color crRet = color;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001476
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001477 switch (color.nColorType) {
1478 case COLORTYPE_GRAY:
1479 crRet.fColor1 = 1.0f - crRet.fColor1;
1480 break;
1481 case COLORTYPE_RGB:
1482 crRet.fColor1 = 1.0f - crRet.fColor1;
1483 crRet.fColor2 = 1.0f - crRet.fColor2;
1484 crRet.fColor3 = 1.0f - crRet.fColor3;
1485 break;
1486 case COLORTYPE_CMYK:
1487 crRet.fColor1 = 1.0f - crRet.fColor1;
1488 crRet.fColor2 = 1.0f - crRet.fColor2;
1489 crRet.fColor3 = 1.0f - crRet.fColor3;
1490 crRet.fColor4 = 1.0f - crRet.fColor4;
1491 break;
1492 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001493
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001494 return crRet;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001495}
1496
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001497CFX_ByteString CPWL_Utils::GetIconAppStream(int32_t nType,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001498 const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001499 const CPWL_Color& crFill,
1500 const CPWL_Color& crStroke) {
tsepez4cf55152016-11-02 14:37:54 -07001501 CFX_ByteString sAppStream = CPWL_Utils::GetColorAppStream(crStroke, false);
1502 sAppStream += CPWL_Utils::GetColorAppStream(crFill, true);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001503
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001504 CFX_ByteString sPath;
1505 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001506
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001507 switch (nType) {
1508 case PWL_ICONTYPE_CHECKMARK:
1509 GetGraphics_Checkmark(sPath, path, rect, PWLPT_STREAM);
1510 break;
1511 case PWL_ICONTYPE_CIRCLE:
1512 GetGraphics_Circle(sPath, path, rect, PWLPT_STREAM);
1513 break;
1514 case PWL_ICONTYPE_COMMENT:
1515 GetGraphics_Comment(sPath, path, rect, PWLPT_STREAM);
1516 break;
1517 case PWL_ICONTYPE_CROSS:
1518 GetGraphics_Cross(sPath, path, rect, PWLPT_STREAM);
1519 break;
1520 case PWL_ICONTYPE_HELP:
1521 GetGraphics_Help(sPath, path, rect, PWLPT_STREAM);
1522 break;
1523 case PWL_ICONTYPE_INSERTTEXT:
1524 GetGraphics_InsertText(sPath, path, rect, PWLPT_STREAM);
1525 break;
1526 case PWL_ICONTYPE_KEY:
1527 GetGraphics_Key(sPath, path, rect, PWLPT_STREAM);
1528 break;
1529 case PWL_ICONTYPE_NEWPARAGRAPH:
1530 GetGraphics_NewParagraph(sPath, path, rect, PWLPT_STREAM);
1531 break;
1532 case PWL_ICONTYPE_TEXTNOTE:
1533 GetGraphics_TextNote(sPath, path, rect, PWLPT_STREAM);
1534 break;
1535 case PWL_ICONTYPE_PARAGRAPH:
1536 GetGraphics_Paragraph(sPath, path, rect, PWLPT_STREAM);
1537 break;
1538 case PWL_ICONTYPE_RIGHTARROW:
1539 GetGraphics_RightArrow(sPath, path, rect, PWLPT_STREAM);
1540 break;
1541 case PWL_ICONTYPE_RIGHTPOINTER:
1542 GetGraphics_RightPointer(sPath, path, rect, PWLPT_STREAM);
1543 break;
1544 case PWL_ICONTYPE_STAR:
1545 GetGraphics_Star(sPath, path, rect, PWLPT_STREAM);
1546 break;
1547 case PWL_ICONTYPE_UPARROW:
1548 GetGraphics_UpArrow(sPath, path, rect, PWLPT_STREAM);
1549 break;
1550 case PWL_ICONTYPE_UPLEFTARROW:
1551 GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_STREAM);
1552 break;
1553 case PWL_ICONTYPE_GRAPH:
1554 GetGraphics_Graph(sPath, path, rect, PWLPT_STREAM);
1555 break;
1556 case PWL_ICONTYPE_PAPERCLIP:
1557 GetGraphics_Paperclip(sPath, path, rect, PWLPT_STREAM);
1558 break;
1559 case PWL_ICONTYPE_ATTACHMENT:
1560 GetGraphics_Attachment(sPath, path, rect, PWLPT_STREAM);
1561 break;
1562 case PWL_ICONTYPE_TAG:
1563 GetGraphics_Tag(sPath, path, rect, PWLPT_STREAM);
1564 break;
1565 case PWL_ICONTYPE_FOXIT:
1566 GetGraphics_Foxit(sPath, path, rect, PWLPT_STREAM);
1567 break;
1568 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001569
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001570 sAppStream += sPath;
1571 if (crStroke.nColorType != COLORTYPE_TRANSPARENT)
1572 sAppStream += "B*\n";
1573 else
1574 sAppStream += "f*\n";
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001575
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001576 return sAppStream;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001577}
1578
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001579void CPWL_Utils::DrawIconAppStream(CFX_RenderDevice* pDevice,
Tom Sepez60d909e2015-12-10 15:34:55 -08001580 CFX_Matrix* pUser2Device,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001581 int32_t nType,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001582 const CFX_FloatRect& rect,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001583 const CPWL_Color& crFill,
1584 const CPWL_Color& crStroke,
1585 const int32_t nTransparancy) {
1586 CFX_GraphStateData gsd;
1587 gsd.m_LineWidth = 1.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001588
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001589 CFX_ByteString sPath;
1590 CFX_PathData path;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001591
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001592 switch (nType) {
1593 case PWL_ICONTYPE_CHECKMARK:
1594 GetGraphics_Checkmark(sPath, path, rect, PWLPT_PATHDATA);
1595 break;
1596 case PWL_ICONTYPE_CIRCLE:
1597 GetGraphics_Circle(sPath, path, rect, PWLPT_PATHDATA);
1598 break;
1599 case PWL_ICONTYPE_COMMENT:
1600 GetGraphics_Comment(sPath, path, rect, PWLPT_PATHDATA);
1601 break;
1602 case PWL_ICONTYPE_CROSS:
1603 GetGraphics_Cross(sPath, path, rect, PWLPT_PATHDATA);
1604 break;
1605 case PWL_ICONTYPE_HELP:
1606 GetGraphics_Help(sPath, path, rect, PWLPT_PATHDATA);
1607 break;
1608 case PWL_ICONTYPE_INSERTTEXT:
1609 GetGraphics_InsertText(sPath, path, rect, PWLPT_PATHDATA);
1610 break;
1611 case PWL_ICONTYPE_KEY:
1612 GetGraphics_Key(sPath, path, rect, PWLPT_PATHDATA);
1613 break;
1614 case PWL_ICONTYPE_NEWPARAGRAPH:
1615 GetGraphics_NewParagraph(sPath, path, rect, PWLPT_PATHDATA);
1616 break;
1617 case PWL_ICONTYPE_TEXTNOTE:
1618 GetGraphics_TextNote(sPath, path, rect, PWLPT_PATHDATA);
1619 break;
1620 case PWL_ICONTYPE_PARAGRAPH:
1621 GetGraphics_Paragraph(sPath, path, rect, PWLPT_PATHDATA);
1622 break;
1623 case PWL_ICONTYPE_RIGHTARROW:
1624 GetGraphics_RightArrow(sPath, path, rect, PWLPT_PATHDATA);
1625 break;
1626 case PWL_ICONTYPE_RIGHTPOINTER:
1627 GetGraphics_RightPointer(sPath, path, rect, PWLPT_PATHDATA);
1628 break;
1629 case PWL_ICONTYPE_STAR:
1630 GetGraphics_Star(sPath, path, rect, PWLPT_PATHDATA);
1631 break;
1632 case PWL_ICONTYPE_UPARROW:
1633 GetGraphics_UpArrow(sPath, path, rect, PWLPT_PATHDATA);
1634 break;
1635 case PWL_ICONTYPE_UPLEFTARROW:
1636 GetGraphics_UpLeftArrow(sPath, path, rect, PWLPT_PATHDATA);
1637 break;
1638 case PWL_ICONTYPE_GRAPH:
1639 GetGraphics_Graph(sPath, path, rect, PWLPT_PATHDATA);
1640 break;
1641 case PWL_ICONTYPE_PAPERCLIP:
1642 GetGraphics_Paperclip(sPath, path, rect, PWLPT_PATHDATA);
1643 break;
1644 case PWL_ICONTYPE_ATTACHMENT:
1645 GetGraphics_Attachment(sPath, path, rect, PWLPT_PATHDATA);
1646 break;
1647 case PWL_ICONTYPE_TAG:
1648 GetGraphics_Tag(sPath, path, rect, PWLPT_PATHDATA);
1649 break;
1650 case PWL_ICONTYPE_FOXIT:
1651 GetGraphics_Foxit(sPath, path, rect, PWLPT_PATHDATA);
1652 break;
1653 default:
1654 return;
1655 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001656
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001657 pDevice->DrawPath(
1658 &path, pUser2Device, &gsd, PWLColorToFXColor(crFill, nTransparancy),
1659 PWLColorToFXColor(crStroke, nTransparancy), FXFILL_ALTERNATE);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001660}
1661
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001662void CPWL_Utils::GetGraphics_Checkmark(CFX_ByteString& sPathData,
1663 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001664 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001665 const PWL_PATH_TYPE type) {
1666 FX_FLOAT fWidth = crBBox.right - crBBox.left;
1667 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001668
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001669 CPWL_PathData PathArray[] = {
1670 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
1671 crBBox.bottom + fHeight * 2 / 5.0f),
1672 PWLPT_MOVETO),
1673 CPWL_PathData(
Tom Sepeza30b7e82016-02-12 15:58:50 -08001674 CPWL_Point(crBBox.left + fWidth / 15.0f +
1675 FX_BEZIER * (fWidth / 7.0f - fWidth / 15.0f),
1676 crBBox.bottom + fHeight * 2 / 5.0f +
1677 FX_BEZIER * (fHeight * 2 / 7.0f - fHeight * 2 / 5.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001678 PWLPT_BEZIERTO),
1679 CPWL_PathData(
1680 CPWL_Point(crBBox.left + fWidth / 4.5f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001681 FX_BEZIER * (fWidth / 5.0f - fWidth / 4.5f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001682 crBBox.bottom + fHeight / 16.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001683 FX_BEZIER * (fHeight / 5.0f - fHeight / 16.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001684 PWLPT_BEZIERTO),
1685 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f,
1686 crBBox.bottom + fHeight / 16.0f),
1687 PWLPT_BEZIERTO),
1688 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 4.5f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001689 FX_BEZIER * (fWidth / 4.4f - fWidth / 4.5f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001690 crBBox.bottom + fHeight / 16.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001691 FX_BEZIER * fHeight / 16.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001692 PWLPT_BEZIERTO),
1693 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001694 FX_BEZIER * (fWidth / 4.0f - fWidth / 3.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001695 crBBox.bottom),
1696 PWLPT_BEZIERTO),
1697 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f, crBBox.bottom),
1698 PWLPT_BEZIERTO),
1699 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001700 FX_BEZIER * fWidth * (1 / 7.0f + 2 / 15.0f),
1701 crBBox.bottom + FX_BEZIER * fHeight * 4 / 5.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001702 PWLPT_BEZIERTO),
1703 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001704 FX_BEZIER * fWidth * (1 / 7.0f - 7 / 15.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001705 crBBox.bottom + fHeight * 15 / 16.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001706 FX_BEZIER * (fHeight * 4 / 5.0f -
1707 fHeight * 15 / 16.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001708 PWLPT_BEZIERTO),
1709 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f,
1710 crBBox.bottom + fHeight * 15 / 16.0f),
1711 PWLPT_BEZIERTO),
1712 CPWL_PathData(
1713 CPWL_Point(
1714 crBBox.left + fWidth * 14 / 15.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001715 FX_BEZIER * (fWidth * 7 / 15.0f - fWidth * 14 / 15.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001716 crBBox.bottom + fHeight * 15 / 16.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001717 FX_BEZIER * (fHeight * 8 / 7.0f - fHeight * 15 / 16.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001718 PWLPT_BEZIERTO),
1719 CPWL_PathData(
1720 CPWL_Point(crBBox.left + fWidth / 3.6f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001721 FX_BEZIER * (fWidth / 3.4f - fWidth / 3.6f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001722 crBBox.bottom + fHeight / 3.5f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001723 FX_BEZIER * (fHeight / 3.5f - fHeight / 3.5f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001724 PWLPT_BEZIERTO),
1725 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.6f,
1726 crBBox.bottom + fHeight / 3.5f),
1727 PWLPT_BEZIERTO),
1728 CPWL_PathData(
1729 CPWL_Point(crBBox.left + fWidth / 3.6f,
1730 crBBox.bottom + fHeight / 3.5f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001731 FX_BEZIER * (fHeight / 4.0f - fHeight / 3.5f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001732 PWLPT_BEZIERTO),
Tom Sepeza30b7e82016-02-12 15:58:50 -08001733 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f +
1734 FX_BEZIER * (fWidth / 3.5f - fWidth / 15.0f),
1735 crBBox.bottom + fHeight * 2 / 5.0f +
1736 FX_BEZIER * (fHeight * 3.5f / 5.0f -
1737 fHeight * 2 / 5.0f)),
1738 PWLPT_BEZIERTO),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001739 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
1740 crBBox.bottom + fHeight * 2 / 5.0f),
1741 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001742
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001743 if (type == PWLPT_STREAM)
1744 sPathData = GetAppStreamFromArray(PathArray, 16);
1745 else
1746 GetPathDataFromArray(path, PathArray, 16);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001747}
1748
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001749void CPWL_Utils::GetGraphics_Circle(CFX_ByteString& sPathData,
1750 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001751 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001752 const PWL_PATH_TYPE type) {
1753 FX_FLOAT fWidth = crBBox.right - crBBox.left;
1754 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001755
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001756 CPWL_PathData PathArray[] = {
1757 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
1758 crBBox.bottom + fHeight / 2.0f),
1759 PWLPT_MOVETO),
1760 CPWL_PathData(
1761 CPWL_Point(crBBox.left + fWidth / 15.0f,
1762 crBBox.bottom + fHeight / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001763 FX_BEZIER * (fHeight * 14 / 15.0f - fHeight / 2.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001764 PWLPT_BEZIERTO),
Tom Sepeza30b7e82016-02-12 15:58:50 -08001765 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f -
1766 FX_BEZIER * (fWidth / 2.0f - fWidth / 15.0f),
1767 crBBox.top - fHeight / 15.0f),
1768 PWLPT_BEZIERTO),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001769 CPWL_PathData(
1770 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
1771 PWLPT_BEZIERTO),
1772 CPWL_PathData(
1773 CPWL_Point(crBBox.left + fWidth / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001774 FX_BEZIER * (fWidth * 14 / 15.0f - fWidth / 2.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001775 crBBox.top - fHeight / 15.0f),
1776 PWLPT_BEZIERTO),
1777 CPWL_PathData(
1778 CPWL_Point(crBBox.right - fWidth / 15.0f,
1779 crBBox.bottom + fHeight / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001780 FX_BEZIER * (fHeight * 14 / 15.0f - fHeight / 2.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001781 PWLPT_BEZIERTO),
1782 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
1783 crBBox.bottom + fHeight / 2.0f),
1784 PWLPT_BEZIERTO),
1785 CPWL_PathData(
1786 CPWL_Point(crBBox.right - fWidth / 15.0f,
1787 crBBox.bottom + fHeight / 2.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001788 FX_BEZIER * (fHeight / 2.0f - fHeight / 15.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001789 PWLPT_BEZIERTO),
1790 CPWL_PathData(
1791 CPWL_Point(crBBox.left + fWidth / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001792 FX_BEZIER * (fWidth * 14 / 15.0f - fWidth / 2.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001793 crBBox.bottom + fHeight / 15.0f),
1794 PWLPT_BEZIERTO),
1795 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
1796 crBBox.bottom + fHeight / 15.0f),
1797 PWLPT_BEZIERTO),
Tom Sepeza30b7e82016-02-12 15:58:50 -08001798 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f -
1799 FX_BEZIER * (fWidth / 2.0f - fWidth / 15.0f),
1800 crBBox.bottom + fHeight / 15.0f),
1801 PWLPT_BEZIERTO),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001802 CPWL_PathData(
1803 CPWL_Point(crBBox.left + fWidth / 15.0f,
1804 crBBox.bottom + fHeight / 2.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001805 FX_BEZIER * (fHeight / 2.0f - fHeight / 15.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001806 PWLPT_BEZIERTO),
1807 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
1808 crBBox.bottom + fHeight / 2.0f),
1809 PWLPT_BEZIERTO),
1810 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
1811 crBBox.bottom + fHeight / 2.0f),
1812 PWLPT_MOVETO),
1813 CPWL_PathData(
1814 CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
1815 crBBox.bottom + fHeight / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001816 FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001817 PWLPT_BEZIERTO),
1818 CPWL_PathData(
1819 CPWL_Point(crBBox.left + fWidth / 2.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001820 FX_BEZIER * (fWidth / 2.0f - fWidth * 3 / 15.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001821 crBBox.top - fHeight * 3 / 15.0f),
1822 PWLPT_BEZIERTO),
1823 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
1824 crBBox.top - fHeight * 3 / 15.0f),
1825 PWLPT_BEZIERTO),
1826 CPWL_PathData(
1827 CPWL_Point(crBBox.left + fWidth / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001828 FX_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001829 crBBox.top - fHeight * 3 / 15.0f),
1830 PWLPT_BEZIERTO),
1831 CPWL_PathData(
1832 CPWL_Point(crBBox.right - fWidth * 3 / 15.0f,
1833 crBBox.bottom + fHeight / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001834 FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001835 PWLPT_BEZIERTO),
1836 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 15.0f,
1837 crBBox.bottom + fHeight / 2.0f),
1838 PWLPT_BEZIERTO),
1839 CPWL_PathData(
1840 CPWL_Point(crBBox.right - fWidth * 3 / 15.0f,
1841 crBBox.bottom + fHeight / 2.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001842 FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001843 PWLPT_BEZIERTO),
1844 CPWL_PathData(
1845 CPWL_Point(crBBox.left + fWidth / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001846 FX_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001847 crBBox.bottom + fHeight * 3 / 15.0f),
1848 PWLPT_BEZIERTO),
1849 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
1850 crBBox.bottom + fHeight * 3 / 15.0f),
1851 PWLPT_BEZIERTO),
1852 CPWL_PathData(
1853 CPWL_Point(crBBox.left + fWidth / 2.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001854 FX_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001855 crBBox.bottom + fHeight * 3 / 15.0f),
1856 PWLPT_BEZIERTO),
1857 CPWL_PathData(
1858 CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
1859 crBBox.bottom + fHeight / 2.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001860 FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001861 PWLPT_BEZIERTO),
1862 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 3 / 15.0f,
1863 crBBox.bottom + fHeight / 2.0f),
1864 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001865
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001866 if (type == PWLPT_STREAM)
1867 sPathData = GetAppStreamFromArray(PathArray, 26);
1868 else
1869 GetPathDataFromArray(path, PathArray, 26);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001870}
1871
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001872void CPWL_Utils::GetGraphics_Comment(CFX_ByteString& sPathData,
1873 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001874 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001875 const PWL_PATH_TYPE type) {
1876 FX_FLOAT fWidth = crBBox.right - crBBox.left;
1877 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001878
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001879 CPWL_PathData PathArray[] = {
1880 CPWL_PathData(
1881 CPWL_Point(crBBox.left + fWidth / 15.0f, crBBox.top - fHeight / 6.0f),
1882 PWLPT_MOVETO),
1883 CPWL_PathData(
1884 CPWL_Point(crBBox.left + fWidth / 15.0f,
1885 crBBox.top - fHeight / 6.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001886 FX_BEZIER * (fHeight / 6.0f - fHeight / 10.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001887 PWLPT_BEZIERTO),
1888 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001889 FX_BEZIER * fWidth / 15.0f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001890 crBBox.top - fHeight / 10.0f),
1891 PWLPT_BEZIERTO),
1892 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
1893 crBBox.top - fHeight / 10.0f),
1894 PWLPT_BEZIERTO),
1895 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
1896 crBBox.top - fHeight / 10.0f),
1897 PWLPT_LINETO),
1898 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001899 FX_BEZIER * fWidth / 15.0f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001900 crBBox.top - fHeight / 10.0f),
1901 PWLPT_BEZIERTO),
1902 CPWL_PathData(
1903 CPWL_Point(crBBox.right - fWidth / 15.0f,
1904 crBBox.top - fHeight / 6 +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001905 FX_BEZIER * (fHeight / 6.0f - fHeight / 10.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001906 PWLPT_BEZIERTO),
1907 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
1908 crBBox.top - fHeight / 6.0f),
1909 PWLPT_BEZIERTO),
1910 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
1911 crBBox.bottom + fHeight / 3.0f),
1912 PWLPT_LINETO),
1913 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
1914 crBBox.bottom + fHeight * 4 / 15.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001915 FX_BEZIER * fHeight / 15.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001916 PWLPT_BEZIERTO),
1917 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001918 FX_BEZIER * fWidth / 15.0f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001919 crBBox.bottom + fHeight * 4 / 15.0f),
1920 PWLPT_BEZIERTO),
1921 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
1922 crBBox.bottom + fHeight * 4 / 15.0f),
1923 PWLPT_BEZIERTO),
1924 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f,
1925 crBBox.bottom + fHeight * 4 / 15.0f),
1926 PWLPT_LINETO),
1927 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f,
1928 crBBox.bottom + fHeight * 2 / 15 +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001929 FX_BEZIER * fHeight * 2 / 15.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001930 PWLPT_BEZIERTO),
1931 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001932 FX_BEZIER * fWidth * 2 / 15.0f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001933 crBBox.bottom + fHeight * 2 / 15.0f),
1934 PWLPT_BEZIERTO),
1935 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 6 / 30.0f,
1936 crBBox.bottom + fHeight * 2 / 15.0f),
1937 PWLPT_BEZIERTO),
1938 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 30.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001939 FX_BEZIER * fWidth / 30.0f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001940 crBBox.bottom + fHeight * 2 / 15.0f),
1941 PWLPT_BEZIERTO),
1942 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 30.0f,
1943 crBBox.bottom + fHeight * 2 / 15.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08001944 FX_BEZIER * fHeight * 2 / 15.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001945 PWLPT_BEZIERTO),
1946 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 30.0f,
1947 crBBox.bottom + fHeight * 4 / 15.0f),
1948 PWLPT_BEZIERTO),
1949 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
1950 crBBox.bottom + fHeight * 4 / 15.0f),
1951 PWLPT_LINETO),
1952 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001953 FX_BEZIER * fWidth / 15.0f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001954 crBBox.bottom + fHeight * 4 / 15.0f),
1955 PWLPT_BEZIERTO),
1956 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
1957 crBBox.bottom + fHeight / 3.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08001958 FX_BEZIER * fHeight / 15.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001959 PWLPT_BEZIERTO),
1960 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f,
1961 crBBox.bottom + fHeight / 3.0f),
1962 PWLPT_BEZIERTO),
1963 CPWL_PathData(
1964 CPWL_Point(crBBox.left + fWidth / 15.0f, crBBox.top - fHeight / 6.0f),
1965 PWLPT_LINETO),
1966 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
1967 crBBox.top - fHeight * 8 / 30.0f),
1968 PWLPT_MOVETO),
1969 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
1970 crBBox.top - fHeight * 8 / 30.0f),
1971 PWLPT_LINETO),
1972 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15,
1973 crBBox.top - fHeight * 25 / 60.0f),
1974 PWLPT_MOVETO),
1975 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f,
1976 crBBox.top - fHeight * 25 / 60.0f),
1977 PWLPT_LINETO),
1978 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f,
1979 crBBox.top - fHeight * 17 / 30.0f),
1980 PWLPT_MOVETO),
1981 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 4 / 15.0f,
1982 crBBox.top - fHeight * 17 / 30.0f),
1983 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001984
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001985 if (type == PWLPT_STREAM)
1986 sPathData = GetAppStreamFromArray(PathArray, 30);
1987 else
1988 GetPathDataFromArray(path, PathArray, 30);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001989}
1990
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001991void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData,
1992 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08001993 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001994 const PWL_PATH_TYPE type) {
1995 FX_FLOAT fWidth = crBBox.right - crBBox.left;
1996 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
Nico Weber9d8ec5a2015-08-04 13:00:21 -07001997 CPWL_Point center_point(crBBox.left + fWidth / 2,
1998 crBBox.bottom + fHeight / 2);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001999
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002000 CPWL_PathData PathArray[] = {
2001 CPWL_PathData(
2002 CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f),
2003 PWLPT_MOVETO),
2004 CPWL_PathData(
2005 CPWL_Point(center_point.x + fWidth * 0.3f,
2006 center_point.y + fHeight / 10.0f + fWidth * 0.3f),
2007 PWLPT_LINETO),
2008 CPWL_PathData(CPWL_Point(center_point.x + fWidth / 10.0f + fWidth * 0.3f,
2009 center_point.y + fHeight * 0.3f),
2010 PWLPT_LINETO),
2011 CPWL_PathData(CPWL_Point(center_point.x + fWidth / 10.0f, center_point.y),
2012 PWLPT_LINETO),
2013 CPWL_PathData(CPWL_Point(center_point.x + fWidth / 10.0f + fWidth * 0.3f,
2014 center_point.y - fHeight * 0.3f),
2015 PWLPT_LINETO),
2016 CPWL_PathData(
2017 CPWL_Point(center_point.x + fWidth * 0.3f,
2018 center_point.y - fHeight / 10.0f - fHeight * 0.3f),
2019 PWLPT_LINETO),
2020 CPWL_PathData(
2021 CPWL_Point(center_point.x, center_point.y - fHeight / 10.0f),
2022 PWLPT_LINETO),
2023 CPWL_PathData(CPWL_Point(center_point.x - fWidth * 0.3f,
2024 center_point.y - fHeight / 10 - fHeight * 0.3f),
2025 PWLPT_LINETO),
2026 CPWL_PathData(CPWL_Point(center_point.x - fWidth / 10.0f - fWidth * 0.3f,
2027 center_point.y - fHeight * 0.3f),
2028 PWLPT_LINETO),
2029 CPWL_PathData(CPWL_Point(center_point.x - fWidth / 10, center_point.y),
2030 PWLPT_LINETO),
2031 CPWL_PathData(CPWL_Point(center_point.x - fWidth / 10 - fWidth * 0.3f,
2032 center_point.y + fHeight * 0.3f),
2033 PWLPT_LINETO),
2034 CPWL_PathData(
2035 CPWL_Point(center_point.x - fWidth * 0.3f,
2036 center_point.y + fHeight / 10.0f + fHeight * 0.3f),
2037 PWLPT_LINETO),
2038 CPWL_PathData(
2039 CPWL_Point(center_point.x, center_point.y + fHeight / 10.0f),
2040 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002041
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002042 if (type == PWLPT_STREAM)
2043 sPathData = GetAppStreamFromArray(PathArray, 13);
2044 else
2045 GetPathDataFromArray(path, PathArray, 13);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002046}
2047
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002048void CPWL_Utils::GetGraphics_Help(CFX_ByteString& sPathData,
2049 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002050 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002051 const PWL_PATH_TYPE type) {
2052 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2053 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002054
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002055 CPWL_PathData PathArray[] = {
2056 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60.0f,
2057 crBBox.bottom + fHeight / 2.0f),
2058 PWLPT_MOVETO),
2059 CPWL_PathData(
2060 CPWL_Point(crBBox.left + fWidth / 60.0f,
2061 crBBox.bottom + fHeight / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002062 FX_BEZIER * (fHeight / 60.0f - fHeight / 2.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002063 PWLPT_BEZIERTO),
Tom Sepeza30b7e82016-02-12 15:58:50 -08002064 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f -
2065 FX_BEZIER * (fWidth / 2.0f - fWidth / 60.0f),
2066 crBBox.bottom + fHeight / 60.0f),
2067 PWLPT_BEZIERTO),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002068 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2069 crBBox.bottom + fHeight / 60.0f),
2070 PWLPT_BEZIERTO),
2071 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002072 FX_BEZIER * fWidth * 29 / 60.0f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002073 crBBox.bottom + fHeight / 60.0f),
2074 PWLPT_BEZIERTO),
2075 CPWL_PathData(
2076 CPWL_Point(crBBox.right - fWidth / 60.0f,
2077 crBBox.bottom + fHeight / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002078 FX_BEZIER * (fHeight / 60.0f - fHeight / 2.0f)),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002079 PWLPT_BEZIERTO),
2080 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 60.0f,
2081 crBBox.bottom + fHeight / 2.0f),
2082 PWLPT_BEZIERTO),
2083 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 60.0f,
2084 crBBox.bottom + fHeight / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002085 FX_BEZIER * fHeight * 29 / 60.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002086 PWLPT_BEZIERTO),
2087 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002088 FX_BEZIER * fWidth * 29 / 60.0f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002089 crBBox.top - fHeight / 60.0f),
2090 PWLPT_BEZIERTO),
2091 CPWL_PathData(
2092 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 60.0f),
2093 PWLPT_BEZIERTO),
2094 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08002095 FX_BEZIER * fWidth * 29 / 60.0f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002096 crBBox.top - fHeight / 60.0f),
2097 PWLPT_BEZIERTO),
2098 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60.0f,
2099 crBBox.bottom + fHeight / 2.0f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002100 FX_BEZIER * fHeight * 29 / 60.0f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002101 PWLPT_BEZIERTO),
2102 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60.0f,
2103 crBBox.bottom + fHeight / 2.0f),
2104 PWLPT_BEZIERTO),
2105 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.27f,
2106 crBBox.top - fHeight * 0.36f),
2107 PWLPT_MOVETO),
2108 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.27f,
2109 crBBox.top - fHeight * 0.36f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002110 FX_BEZIER * fHeight * 0.23f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002111 PWLPT_BEZIERTO),
2112 CPWL_PathData(
Tom Sepeza30b7e82016-02-12 15:58:50 -08002113 CPWL_Point(crBBox.left + fWidth * 0.5f - FX_BEZIER * fWidth * 0.23f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002114 crBBox.bottom + fHeight * 0.87f),
2115 PWLPT_BEZIERTO),
2116 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
2117 crBBox.bottom + fHeight * 0.87f),
2118 PWLPT_BEZIERTO),
2119 CPWL_PathData(
Tom Sepeza30b7e82016-02-12 15:58:50 -08002120 CPWL_Point(crBBox.left + fWidth * 0.5f + FX_BEZIER * fWidth * 0.23f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002121 crBBox.bottom + fHeight * 0.87f),
2122 PWLPT_BEZIERTO),
2123 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.27f,
2124 crBBox.top - fHeight * 0.36f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002125 FX_BEZIER * fHeight * 0.23f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002126 PWLPT_BEZIERTO),
2127 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.27f,
2128 crBBox.top - fHeight * 0.36f),
2129 PWLPT_BEZIERTO),
2130 CPWL_PathData(
2131 CPWL_Point(crBBox.right - fWidth * 0.27f - fWidth * 0.08f * 0.2f,
2132 crBBox.top - fHeight * 0.36f - fHeight * 0.15f * 0.7f),
2133 PWLPT_BEZIERTO),
2134 CPWL_PathData(
2135 CPWL_Point(crBBox.right - fWidth * 0.35f + fWidth * 0.08f * 0.2f,
2136 crBBox.top - fHeight * 0.51f + fHeight * 0.15f * 0.2f),
2137 PWLPT_BEZIERTO),
2138 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.35f,
2139 crBBox.top - fHeight * 0.51f),
2140 PWLPT_BEZIERTO),
2141 CPWL_PathData(
2142 CPWL_Point(crBBox.right - fWidth * 0.35f - fWidth * 0.1f * 0.5f,
2143 crBBox.top - fHeight * 0.51f - fHeight * 0.15f * 0.3f),
2144 PWLPT_BEZIERTO),
2145 CPWL_PathData(
2146 CPWL_Point(crBBox.right - fWidth * 0.45f - fWidth * 0.1f * 0.5f,
2147 crBBox.top - fHeight * 0.68f + fHeight * 0.15f * 0.5f),
2148 PWLPT_BEZIERTO),
2149 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.45f,
2150 crBBox.top - fHeight * 0.68f),
2151 PWLPT_BEZIERTO),
2152 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.45f,
2153 crBBox.bottom + fHeight * 0.30f),
2154 PWLPT_LINETO),
2155 CPWL_PathData(
2156 CPWL_Point(crBBox.right - fWidth * 0.45f,
2157 crBBox.bottom + fHeight * 0.30f - fWidth * 0.1f * 0.7f),
2158 PWLPT_BEZIERTO),
2159 CPWL_PathData(
2160 CPWL_Point(crBBox.right - fWidth * 0.55f,
2161 crBBox.bottom + fHeight * 0.30f - fWidth * 0.1f * 0.7f),
2162 PWLPT_BEZIERTO),
2163 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.55f,
2164 crBBox.bottom + fHeight * 0.30f),
2165 PWLPT_BEZIERTO),
2166 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.55f,
2167 crBBox.top - fHeight * 0.66f),
2168 PWLPT_LINETO),
2169 CPWL_PathData(
2170 CPWL_Point(crBBox.right - fWidth * 0.55f - fWidth * 0.1f * 0.05f,
2171 crBBox.top - fHeight * 0.66f + fHeight * 0.18f * 0.5f),
2172 PWLPT_BEZIERTO),
2173 CPWL_PathData(
2174 CPWL_Point(crBBox.right - fWidth * 0.45f - fWidth * 0.1f * 0.05f,
2175 crBBox.top - fHeight * 0.48f - fHeight * 0.18f * 0.3f),
2176 PWLPT_BEZIERTO),
2177 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.45f,
2178 crBBox.top - fHeight * 0.48f),
2179 PWLPT_BEZIERTO),
2180 CPWL_PathData(
2181 CPWL_Point(crBBox.right - fWidth * 0.45f + fWidth * 0.08f * 0.2f,
2182 crBBox.top - fHeight * 0.48f + fHeight * 0.18f * 0.2f),
2183 PWLPT_BEZIERTO),
2184 CPWL_PathData(
2185 CPWL_Point(crBBox.right - fWidth * 0.37f - fWidth * 0.08f * 0.2f,
2186 crBBox.top - fHeight * 0.36f - fHeight * 0.18f * 0.7f),
2187 PWLPT_BEZIERTO),
2188 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.37f,
2189 crBBox.top - fHeight * 0.36f),
2190 PWLPT_BEZIERTO),
2191 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.37f,
2192 crBBox.top - fHeight * 0.36f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002193 FX_BEZIER * fHeight * 0.13f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002194 PWLPT_BEZIERTO),
2195 CPWL_PathData(
Tom Sepeza30b7e82016-02-12 15:58:50 -08002196 CPWL_Point(crBBox.left + fWidth * 0.5f + FX_BEZIER * fWidth * 0.13f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002197 crBBox.bottom + fHeight * 0.77f),
2198 PWLPT_BEZIERTO),
2199 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
2200 crBBox.bottom + fHeight * 0.77f),
2201 PWLPT_BEZIERTO),
2202 CPWL_PathData(
Tom Sepeza30b7e82016-02-12 15:58:50 -08002203 CPWL_Point(crBBox.left + fWidth * 0.5f - FX_BEZIER * fWidth * 0.13f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002204 crBBox.bottom + fHeight * 0.77f),
2205 PWLPT_BEZIERTO),
2206 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.37f,
2207 crBBox.top - fHeight * 0.36f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002208 FX_BEZIER * fHeight * 0.13f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002209 PWLPT_BEZIERTO),
2210 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.37f,
2211 crBBox.top - fHeight * 0.36f),
2212 PWLPT_BEZIERTO),
2213 CPWL_PathData(
2214 CPWL_Point(crBBox.left + fWidth * 0.37f,
2215 crBBox.top - fHeight * 0.36f - fWidth * 0.1f * 0.6f),
2216 PWLPT_BEZIERTO),
2217 CPWL_PathData(
2218 CPWL_Point(crBBox.left + fWidth * 0.27f,
2219 crBBox.top - fHeight * 0.36f - fWidth * 0.1f * 0.6f),
2220 PWLPT_BEZIERTO),
2221 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.27f,
2222 crBBox.top - fHeight * 0.36f),
2223 PWLPT_BEZIERTO),
2224 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
2225 crBBox.bottom + fHeight * 0.13f),
2226 PWLPT_MOVETO),
2227 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
2228 crBBox.bottom + fHeight * 0.13f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002229 FX_BEZIER * fHeight * 0.055f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002230 PWLPT_BEZIERTO),
2231 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08002232 FX_BEZIER * fWidth * 0.095f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002233 crBBox.bottom + fHeight * 0.185f),
2234 PWLPT_BEZIERTO),
2235 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f,
2236 crBBox.bottom + fHeight * 0.185f),
2237 PWLPT_BEZIERTO),
2238 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002239 FX_BEZIER * fWidth * 0.065f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002240 crBBox.bottom + fHeight * 0.185f),
2241 PWLPT_BEZIERTO),
2242 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.44f,
2243 crBBox.bottom + fHeight * 0.13f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002244 FX_BEZIER * fHeight * 0.055f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002245 PWLPT_BEZIERTO),
2246 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.44f,
2247 crBBox.bottom + fHeight * 0.13f),
2248 PWLPT_BEZIERTO),
2249 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.44f,
2250 crBBox.bottom + fHeight * 0.13f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08002251 FX_BEZIER * fHeight * 0.055f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002252 PWLPT_BEZIERTO),
2253 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f +
Tom Sepeza30b7e82016-02-12 15:58:50 -08002254 FX_BEZIER * fWidth * 0.065f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002255 crBBox.bottom + fHeight * 0.075f),
2256 PWLPT_BEZIERTO),
2257 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f,
2258 crBBox.bottom + fHeight * 0.075f),
2259 PWLPT_BEZIERTO),
2260 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08002261 FX_BEZIER * fWidth * 0.065f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002262 crBBox.bottom + fHeight * 0.075f),
2263 PWLPT_BEZIERTO),
2264 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
2265 crBBox.bottom + fHeight * 0.13f -
Tom Sepeza30b7e82016-02-12 15:58:50 -08002266 FX_BEZIER * fHeight * 0.055f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002267 PWLPT_BEZIERTO),
2268 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f,
2269 crBBox.bottom + fHeight * 0.13f),
2270 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002271
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002272 if (type == PWLPT_STREAM)
2273 sPathData = GetAppStreamFromArray(PathArray, 59);
2274 else
2275 GetPathDataFromArray(path, PathArray, 59);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002276}
2277
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002278void CPWL_Utils::GetGraphics_InsertText(CFX_ByteString& sPathData,
2279 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002280 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002281 const PWL_PATH_TYPE type) {
2282 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2283 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002284
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002285 CPWL_PathData PathArray[] = {
2286 CPWL_PathData(
2287 CPWL_Point(crBBox.left + fWidth / 10, crBBox.bottom + fHeight / 10),
2288 PWLPT_MOVETO),
2289 CPWL_PathData(
2290 CPWL_Point(crBBox.left + fWidth / 2, crBBox.top - fHeight * 2 / 15),
2291 PWLPT_LINETO),
2292 CPWL_PathData(
2293 CPWL_Point(crBBox.right - fWidth / 10, crBBox.bottom + fHeight / 10),
2294 PWLPT_LINETO),
2295 CPWL_PathData(
2296 CPWL_Point(crBBox.left + fWidth / 10, crBBox.bottom + fHeight / 10),
2297 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002298
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002299 if (type == PWLPT_STREAM)
2300 sPathData = GetAppStreamFromArray(PathArray, 4);
2301 else
2302 GetPathDataFromArray(path, PathArray, 4);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002303}
2304
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002305void CPWL_Utils::GetGraphics_Key(CFX_ByteString& sPathData,
2306 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002307 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002308 const PWL_PATH_TYPE type) {
2309 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2310 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
2311 FX_FLOAT k = -fHeight / fWidth;
2312 CPWL_Point tail;
2313 CPWL_Point CicleCenter;
2314 tail.x = crBBox.left + fWidth * 0.9f;
2315 tail.y = k * (tail.x - crBBox.right) + crBBox.bottom;
2316 CicleCenter.x = crBBox.left + fWidth * 0.15f;
2317 CicleCenter.y = k * (CicleCenter.x - crBBox.right) + crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002318
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002319 CPWL_PathData PathArray[] = {
2320 CPWL_PathData(
2321 CPWL_Point(tail.x + fWidth / 30.0f, -fWidth / 30.0f / k + tail.y),
2322 PWLPT_MOVETO),
2323 CPWL_PathData(CPWL_Point(tail.x + fWidth / 30.0f - fWidth * 0.18f,
2324 -k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2325 PWLPT_LINETO),
2326 CPWL_PathData(
2327 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f + fWidth * 0.07f,
2328 -fWidth * 0.07f / k - k * fWidth * 0.18f -
2329 fWidth / 30 / k + tail.y),
2330 PWLPT_LINETO),
2331 CPWL_PathData(
2332 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 +
2333 fWidth * 0.07f,
2334 -fWidth * 0.07f / k - k * fWidth / 20 -
2335 k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2336 PWLPT_LINETO),
2337 CPWL_PathData(
2338 CPWL_Point(
2339 tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20,
2340 -k * fWidth / 20 - k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2341 PWLPT_LINETO),
2342 CPWL_PathData(
2343 CPWL_Point(
2344 tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 - fWidth / 15,
2345 -k * fWidth / 15 - k * fWidth / 20 - k * fWidth * 0.18f -
2346 fWidth / 30 / k + tail.y),
2347 PWLPT_LINETO),
2348 CPWL_PathData(
2349 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 -
2350 fWidth / 15 + fWidth * 0.07f,
2351 -fWidth * 0.07f / k - k * fWidth / 15 - k * fWidth / 20 -
2352 k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2353 PWLPT_LINETO),
2354 CPWL_PathData(
2355 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 -
2356 fWidth / 15 - fWidth / 20 + fWidth * 0.07f,
2357 -fWidth * 0.07f / k + -k * fWidth / 20 + -k * fWidth / 15 -
2358 k * fWidth / 20 - k * fWidth * 0.18f -
2359 fWidth / 30 / k + tail.y),
2360 PWLPT_LINETO),
2361 CPWL_PathData(
2362 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.18f - fWidth / 20 -
2363 fWidth / 15 - fWidth / 20,
2364 -k * fWidth / 20 + -k * fWidth / 15 - k * fWidth / 20 -
2365 k * fWidth * 0.18f - fWidth / 30 / k + tail.y),
2366 PWLPT_LINETO),
2367 CPWL_PathData(CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.45f,
2368 -k * fWidth * 0.45f - fWidth / 30 / k + tail.y),
2369 PWLPT_LINETO),
2370 CPWL_PathData(
2371 CPWL_Point(tail.x + fWidth / 30 - fWidth * 0.45f + fWidth * 0.2f,
2372 -fWidth * 0.4f / k - k * fWidth * 0.45f - fWidth / 30 / k +
2373 tail.y),
2374 PWLPT_BEZIERTO),
2375 CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.2f,
2376 -fWidth * 0.1f / k + CicleCenter.y),
2377 PWLPT_BEZIERTO),
2378 CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO),
2379 CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth / 60.0f,
2380 -k * fWidth / 60 + CicleCenter.y),
2381 PWLPT_BEZIERTO),
2382 CPWL_PathData(CPWL_Point(CicleCenter.x - fWidth / 60,
2383 -k * fWidth / 60 + CicleCenter.y),
2384 PWLPT_BEZIERTO),
2385 CPWL_PathData(CPWL_Point(CicleCenter.x, CicleCenter.y), PWLPT_BEZIERTO),
2386 CPWL_PathData(
2387 CPWL_Point(CicleCenter.x - fWidth * 0.22f,
2388 fWidth * 0.35f / k + CicleCenter.y - fHeight * 0.05f),
2389 PWLPT_BEZIERTO),
2390 CPWL_PathData(
2391 CPWL_Point(tail.x - fWidth / 30 - fWidth * 0.45f - fWidth * 0.18f,
2392 fWidth * 0.05f / k - k * fWidth * 0.45f + fWidth / 30 / k +
2393 tail.y - fHeight * 0.05f),
2394 PWLPT_BEZIERTO),
2395 CPWL_PathData(
2396 CPWL_Point(tail.x - fWidth / 30.0f - fWidth * 0.45f,
2397 -k * fWidth * 0.45f + fWidth / 30.0f / k + tail.y),
2398 PWLPT_BEZIERTO),
2399 CPWL_PathData(
2400 CPWL_Point(tail.x - fWidth / 30.0f, fWidth / 30.0f / k + tail.y),
2401 PWLPT_LINETO),
2402 CPWL_PathData(CPWL_Point(tail.x + fWidth / 30, -fWidth / 30 / k + tail.y),
2403 PWLPT_LINETO),
2404 CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.08f,
2405 k * fWidth * 0.08f + CicleCenter.y),
2406 PWLPT_MOVETO),
2407 CPWL_PathData(
2408 CPWL_Point(CicleCenter.x + fWidth * 0.08f + fWidth * 0.1f,
2409 -fWidth * 0.1f / k + k * fWidth * 0.08f + CicleCenter.y),
2410 PWLPT_BEZIERTO),
2411 CPWL_PathData(
2412 CPWL_Point(CicleCenter.x + fWidth * 0.22f + fWidth * 0.1f,
2413 k * fWidth * 0.22f + CicleCenter.y - fWidth * 0.1f / k),
2414 PWLPT_BEZIERTO),
2415 CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.22f,
2416 k * fWidth * 0.22f + CicleCenter.y),
2417 PWLPT_BEZIERTO),
2418 CPWL_PathData(
2419 CPWL_Point(CicleCenter.x + fWidth * 0.22f - fWidth * 0.1f,
2420 fWidth * 0.1f / k + k * fWidth * 0.22f + CicleCenter.y),
2421 PWLPT_BEZIERTO),
2422 CPWL_PathData(
2423 CPWL_Point(CicleCenter.x + fWidth * 0.08f - fWidth * 0.1f,
2424 fWidth * 0.1f / k + k * fWidth * 0.08f + CicleCenter.y),
2425 PWLPT_BEZIERTO),
2426 CPWL_PathData(CPWL_Point(CicleCenter.x + fWidth * 0.08f,
2427 k * fWidth * 0.08f + CicleCenter.y),
2428 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002429
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002430 if (type == PWLPT_STREAM)
2431 sPathData = GetAppStreamFromArray(PathArray, 28);
2432 else
2433 GetPathDataFromArray(path, PathArray, 28);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002434}
2435
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002436void CPWL_Utils::GetGraphics_NewParagraph(CFX_ByteString& sPathData,
2437 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002438 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002439 const PWL_PATH_TYPE type) {
2440 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2441 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002442
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002443 CPWL_PathData PathArray[] = {
2444 CPWL_PathData(
2445 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 20.0f),
2446 PWLPT_MOVETO),
2447 CPWL_PathData(
2448 CPWL_Point(crBBox.left + fWidth / 10.0f, crBBox.top - fHeight / 2.0f),
2449 PWLPT_LINETO),
2450 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2451 crBBox.top - fHeight / 2.0f),
2452 PWLPT_LINETO),
2453 CPWL_PathData(
2454 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 20.0f),
2455 PWLPT_LINETO),
2456 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.12f,
2457 crBBox.top - fHeight * 17 / 30.0f),
2458 PWLPT_MOVETO),
2459 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.12f,
2460 crBBox.bottom + fHeight / 10.0f),
2461 PWLPT_LINETO),
2462 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.22f,
2463 crBBox.bottom + fHeight / 10.0f),
2464 PWLPT_LINETO),
2465 CPWL_PathData(
2466 CPWL_Point(crBBox.left + fWidth * 0.22f,
2467 crBBox.top - fHeight * 17 / 30.0f - fWidth * 0.14f),
2468 PWLPT_LINETO),
2469 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.38f,
2470 crBBox.bottom + fHeight / 10.0f),
2471 PWLPT_LINETO),
2472 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.48f,
2473 crBBox.bottom + fHeight / 10.0f),
2474 PWLPT_LINETO),
2475 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.48f,
2476 crBBox.top - fHeight * 17 / 30.0f),
2477 PWLPT_LINETO),
2478 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.38f,
2479 crBBox.top - fHeight * 17 / 30.0f),
2480 PWLPT_LINETO),
2481 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.38f,
2482 crBBox.bottom + fWidth * 0.24f),
2483 PWLPT_LINETO),
2484 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.22f,
2485 crBBox.top - fHeight * 17 / 30.0f),
2486 PWLPT_LINETO),
2487 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.12f,
2488 crBBox.top - fHeight * 17 / 30.0f),
2489 PWLPT_LINETO),
2490 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
2491 crBBox.bottom + fHeight / 10.0f),
2492 PWLPT_MOVETO),
2493 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2494 crBBox.bottom + fHeight / 10.0f),
2495 PWLPT_LINETO),
2496 CPWL_PathData(
2497 CPWL_Point(crBBox.left + fWidth * 0.7f,
2498 crBBox.bottom + fHeight / 10.0f + fHeight / 7.0f),
2499 PWLPT_LINETO),
2500 CPWL_PathData(
2501 CPWL_Point(crBBox.left + fWidth * 0.97f,
2502 crBBox.bottom + fHeight / 10.0f + fHeight / 7.0f),
2503 PWLPT_BEZIERTO),
2504 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.97f,
2505 crBBox.top - fHeight * 17 / 30.0f),
2506 PWLPT_BEZIERTO),
2507 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2508 crBBox.top - fHeight * 17 / 30.0f),
2509 PWLPT_BEZIERTO),
2510 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
2511 crBBox.top - fHeight * 17 / 30.0f),
2512 PWLPT_LINETO),
2513 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
2514 crBBox.bottom + fHeight / 10.0f),
2515 PWLPT_LINETO),
2516 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2517 crBBox.bottom + fHeight / 7 + fHeight * 0.18f),
2518 PWLPT_MOVETO),
2519 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.85f,
2520 crBBox.bottom + fHeight / 7 + fHeight * 0.18f),
2521 PWLPT_BEZIERTO),
2522 CPWL_PathData(
2523 CPWL_Point(crBBox.left + fWidth * 0.85f,
2524 crBBox.top - fHeight * 17 / 30.0f - fHeight * 0.08f),
2525 PWLPT_BEZIERTO),
2526 CPWL_PathData(
2527 CPWL_Point(crBBox.left + fWidth * 0.7f,
2528 crBBox.top - fHeight * 17 / 30.0f - fHeight * 0.08f),
2529 PWLPT_BEZIERTO),
2530 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2531 crBBox.bottom + fHeight / 7 + fHeight * 0.18f),
2532 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002533
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002534 if (type == PWLPT_STREAM)
2535 sPathData = GetAppStreamFromArray(PathArray, 28);
2536 else
2537 GetPathDataFromArray(path, PathArray, 28);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002538}
2539
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002540void CPWL_Utils::GetGraphics_TextNote(CFX_ByteString& sPathData,
2541 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002542 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002543 const PWL_PATH_TYPE type) {
2544 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2545 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002546
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002547 CPWL_PathData PathArray[] = {
2548 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2549 crBBox.bottom + fHeight / 15.0f),
2550 PWLPT_MOVETO),
2551 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 7 / 10.0f,
2552 crBBox.bottom + fHeight * 4 / 15.0f),
2553 PWLPT_LINETO),
2554 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2555 crBBox.bottom + fHeight * 4 / 15.0f),
2556 PWLPT_LINETO),
2557 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2558 crBBox.top - fHeight / 15.0f),
2559 PWLPT_LINETO),
2560 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 10.0f,
2561 crBBox.top - fHeight / 15.0f),
2562 PWLPT_LINETO),
2563 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 10.0f,
2564 crBBox.bottom + fHeight / 15.0f),
2565 PWLPT_LINETO),
2566 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2567 crBBox.bottom + fHeight / 15.0f),
2568 PWLPT_LINETO),
2569 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2570 crBBox.bottom + fHeight * 4 / 15.0f),
2571 PWLPT_LINETO),
2572 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2573 crBBox.bottom + fHeight / 15.0f),
2574 PWLPT_LINETO),
2575 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2576 crBBox.bottom + fHeight * 4 / 15.0f),
2577 PWLPT_LINETO),
2578 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2579 crBBox.bottom + fHeight * 4 / 15.0f),
2580 PWLPT_LINETO),
2581 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 5.0f,
2582 crBBox.top - fHeight * 4 / 15.0f),
2583 PWLPT_MOVETO),
2584 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 5.0f,
2585 crBBox.top - fHeight * 4 / 15.0f),
2586 PWLPT_LINETO),
2587 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 5.0f,
2588 crBBox.top - fHeight * 7 / 15.0f),
2589 PWLPT_MOVETO),
2590 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 5.0f,
2591 crBBox.top - fHeight * 7 / 15.0f),
2592 PWLPT_LINETO),
2593 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 5.0f,
2594 crBBox.top - fHeight * 10 / 15.0f),
2595 PWLPT_MOVETO),
2596 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 3 / 10.0f,
2597 crBBox.top - fHeight * 10 / 15.0f),
2598 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002599
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002600 if (type == PWLPT_STREAM)
2601 sPathData = GetAppStreamFromArray(PathArray, 17);
2602 else
2603 GetPathDataFromArray(path, PathArray, 17);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002604}
2605
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002606void CPWL_Utils::GetGraphics_Paragraph(CFX_ByteString& sPathData,
2607 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002608 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002609 const PWL_PATH_TYPE type) {
2610 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2611 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002612
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002613 CPWL_PathData PathArray[] = {
2614 CPWL_PathData(
2615 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
2616 PWLPT_MOVETO),
2617 CPWL_PathData(
2618 CPWL_Point(crBBox.left + fWidth * 0.7f, crBBox.top - fHeight / 15.0f),
2619 PWLPT_LINETO),
2620 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2621 crBBox.bottom + fHeight / 15.0f),
2622 PWLPT_LINETO),
2623 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.634f,
2624 crBBox.bottom + fHeight / 15.0f),
2625 PWLPT_LINETO),
2626 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.634f,
2627 crBBox.top - fHeight * 2 / 15.0f),
2628 PWLPT_LINETO),
2629 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.566f,
2630 crBBox.top - fHeight * 2 / 15.0f),
2631 PWLPT_LINETO),
2632 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.566f,
2633 crBBox.bottom + fHeight / 15.0f),
2634 PWLPT_LINETO),
2635 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2636 crBBox.bottom + fHeight / 15.0f),
2637 PWLPT_LINETO),
2638 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2639 crBBox.top - fHeight / 15.0f - fHeight * 0.4f),
2640 PWLPT_LINETO),
2641 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.2f,
2642 crBBox.top - fHeight / 15.0f - fHeight * 0.4f),
2643 PWLPT_BEZIERTO),
2644 CPWL_PathData(
2645 CPWL_Point(crBBox.left + fWidth * 0.2f, crBBox.top - fHeight / 15.0f),
2646 PWLPT_BEZIERTO),
2647 CPWL_PathData(
2648 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
2649 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002650
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002651 if (type == PWLPT_STREAM)
2652 sPathData = GetAppStreamFromArray(PathArray, 12);
2653 else
2654 GetPathDataFromArray(path, PathArray, 12);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002655}
2656
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002657void CPWL_Utils::GetGraphics_RightArrow(CFX_ByteString& sPathData,
2658 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002659 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002660 const PWL_PATH_TYPE type) {
2661 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2662 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002663
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002664 CPWL_PathData PathArray[] = {
2665 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
2666 crBBox.top - fHeight / 2.0f),
2667 PWLPT_MOVETO),
2668 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f + fWidth / 8.0f,
2669 crBBox.bottom + fHeight / 5.0f),
2670 PWLPT_LINETO),
2671 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f,
2672 crBBox.bottom + fHeight / 5.0f),
2673 PWLPT_LINETO),
2674 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f - fWidth * 0.15f,
2675 crBBox.top - fHeight / 2.0f - fWidth / 25.0f),
2676 PWLPT_LINETO),
2677 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.1f,
2678 crBBox.top - fHeight / 2.0f - fWidth / 25.0f),
2679 PWLPT_LINETO),
2680 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.1f,
2681 crBBox.top - fHeight / 2.0f + fWidth / 25.0f),
2682 PWLPT_LINETO),
2683 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f - fWidth * 0.15f,
2684 crBBox.top - fHeight / 2.0f + fWidth / 25.0f),
2685 PWLPT_LINETO),
2686 CPWL_PathData(
2687 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 5.0f),
2688 PWLPT_LINETO),
2689 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f + fWidth / 8.0f,
2690 crBBox.top - fHeight / 5.0f),
2691 PWLPT_LINETO),
2692 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15.0f,
2693 crBBox.top - fHeight / 2.0f),
2694 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002695
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002696 if (type == PWLPT_STREAM)
2697 sPathData = GetAppStreamFromArray(PathArray, 10);
2698 else
2699 GetPathDataFromArray(path, PathArray, 10);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002700}
2701
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002702void CPWL_Utils::GetGraphics_RightPointer(CFX_ByteString& sPathData,
2703 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002704 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002705 const PWL_PATH_TYPE type) {
2706 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2707 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002708
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002709 CPWL_PathData PathArray[] = {
2710 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30.0f,
2711 crBBox.top - fHeight / 2.0f),
2712 PWLPT_MOVETO),
2713 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 30.0f,
2714 crBBox.bottom + fHeight / 6.0f),
2715 PWLPT_LINETO),
2716 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 4 / 15.0f,
2717 crBBox.top - fHeight / 2.0f),
2718 PWLPT_LINETO),
2719 CPWL_PathData(
2720 CPWL_Point(crBBox.left + fWidth / 30.0f, crBBox.top - fHeight / 6.0f),
2721 PWLPT_LINETO),
2722 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30.0f,
2723 crBBox.top - fHeight / 2.0f),
2724 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002725
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002726 if (type == PWLPT_STREAM)
2727 sPathData = GetAppStreamFromArray(PathArray, 5);
2728 else
2729 GetPathDataFromArray(path, PathArray, 5);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002730}
2731
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002732void CPWL_Utils::GetGraphics_Star(CFX_ByteString& sPathData,
2733 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002734 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002735 const PWL_PATH_TYPE type) {
2736 FX_FLOAT fLongRadius =
Tom Sepeza30b7e82016-02-12 15:58:50 -08002737 (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f));
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002738 fLongRadius = fLongRadius * 0.7f;
2739 FX_FLOAT fShortRadius = fLongRadius * 0.55f;
Dan Sinclairf528eee2017-02-14 11:52:07 -05002740 CFX_PointF ptCenter = CFX_PointF((crBBox.left + crBBox.right) / 2.0f,
2741 (crBBox.top + crBBox.bottom) / 2.0f);
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07002742
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002743 FX_FLOAT px1[5], py1[5];
2744 FX_FLOAT px2[5], py2[5];
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002745
Tom Sepeza30b7e82016-02-12 15:58:50 -08002746 FX_FLOAT fAngel = FX_PI / 10.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002747
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002748 for (int32_t i = 0; i < 5; i++) {
2749 px1[i] = ptCenter.x + fLongRadius * (FX_FLOAT)cos(fAngel);
2750 py1[i] = ptCenter.y + fLongRadius * (FX_FLOAT)sin(fAngel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002751
Tom Sepeza30b7e82016-02-12 15:58:50 -08002752 fAngel += FX_PI * 2 / 5.0f;
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002753 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002754
Tom Sepeza30b7e82016-02-12 15:58:50 -08002755 fAngel = FX_PI / 5.0f + FX_PI / 10.0f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002756
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002757 for (int32_t j = 0; j < 5; j++) {
2758 px2[j] = ptCenter.x + fShortRadius * (FX_FLOAT)cos(fAngel);
2759 py2[j] = ptCenter.y + fShortRadius * (FX_FLOAT)sin(fAngel);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002760
Tom Sepeza30b7e82016-02-12 15:58:50 -08002761 fAngel += FX_PI * 2 / 5.0f;
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002762 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002763
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002764 CPWL_PathData PathArray[11];
2765 PathArray[0] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_MOVETO);
2766 PathArray[1] = CPWL_PathData(CPWL_Point(px2[0], py2[0]), PWLPT_LINETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002767
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002768 for (int32_t k = 0; k < 4; k++) {
2769 PathArray[(k + 1) * 2] =
2770 CPWL_PathData(CPWL_Point(px1[k + 1], py1[k + 1]), PWLPT_LINETO);
2771 PathArray[(k + 1) * 2 + 1] =
2772 CPWL_PathData(CPWL_Point(px2[k + 1], py2[k + 1]), PWLPT_LINETO);
2773 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002774
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002775 PathArray[10] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_LINETO);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002776
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002777 if (type == PWLPT_STREAM)
2778 sPathData = GetAppStreamFromArray(PathArray, 11);
2779 else
2780 GetPathDataFromArray(path, PathArray, 11);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002781}
2782
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002783void CPWL_Utils::GetGraphics_UpArrow(CFX_ByteString& sPathData,
2784 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002785 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002786 const PWL_PATH_TYPE type) {
2787 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2788 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002789
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002790 CPWL_PathData PathArray[] = {
2791 CPWL_PathData(
2792 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
2793 PWLPT_MOVETO),
2794 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 10.0f,
2795 crBBox.top - fWidth * 3 / 5.0f),
2796 PWLPT_LINETO),
2797 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
2798 crBBox.top - fWidth * 3 / 5.0f),
2799 PWLPT_LINETO),
2800 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
2801 crBBox.bottom + fHeight / 15.0f),
2802 PWLPT_LINETO),
2803 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
2804 crBBox.bottom + fHeight / 15.0f),
2805 PWLPT_LINETO),
2806 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
2807 crBBox.top - fWidth * 3 / 5.0f),
2808 PWLPT_LINETO),
2809 CPWL_PathData(
2810 CPWL_Point(crBBox.left + fWidth / 10, crBBox.top - fWidth * 3 / 5.0f),
2811 PWLPT_LINETO),
2812 CPWL_PathData(
2813 CPWL_Point(crBBox.left + fWidth / 2.0f, crBBox.top - fHeight / 15.0f),
2814 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002815
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002816 if (type == PWLPT_STREAM)
2817 sPathData = GetAppStreamFromArray(PathArray, 8);
2818 else
2819 GetPathDataFromArray(path, PathArray, 8);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002820}
2821
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002822void CPWL_Utils::GetGraphics_UpLeftArrow(CFX_ByteString& sPathData,
2823 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002824 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002825 const PWL_PATH_TYPE type) {
2826 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2827 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
2828 CPWL_Point leftup(crBBox.left, crBBox.top);
2829 CPWL_Point rightdown(crBBox.right, crBBox.bottom);
2830 FX_FLOAT k = -fHeight / fWidth;
2831 CPWL_Point tail;
2832 tail.x = crBBox.left + fWidth * 4 / 5.0f;
2833 tail.y = k * (tail.x - crBBox.right) + rightdown.y;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002834
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002835 CPWL_PathData PathArray[] = {
2836 CPWL_PathData(
2837 CPWL_Point(
2838 crBBox.left + fWidth / 20.0f,
2839 k * (crBBox.left + fWidth / 20.0f - rightdown.x) + rightdown.y),
2840 PWLPT_MOVETO),
2841 CPWL_PathData(CPWL_Point(fHeight * 17 / 60.0f / k + tail.x +
2842 fWidth / 10.0f + fWidth / 5.0f,
2843 -fWidth / 5.0f / k + tail.y -
2844 fWidth / 10.0f / k + fHeight * 17 / 60.0f),
2845 PWLPT_LINETO),
2846 CPWL_PathData(
2847 CPWL_Point(fHeight * 17 / 60.0f / k + tail.x + fWidth / 10.0f,
2848 tail.y - fWidth / 10.0f / k + fHeight * 17 / 60.0f),
2849 PWLPT_LINETO),
2850 CPWL_PathData(
2851 CPWL_Point(tail.x + fWidth / 10.0f, tail.y - fWidth / 10.0f / k),
2852 PWLPT_LINETO),
2853 CPWL_PathData(
2854 CPWL_Point(tail.x - fWidth / 10.0f, tail.y + fWidth / 10.0f / k),
2855 PWLPT_LINETO),
2856 CPWL_PathData(
2857 CPWL_Point(fHeight * 17 / 60.0f / k + tail.x - fWidth / 10.0f,
2858 tail.y + fWidth / 10.0f / k + fHeight * 17 / 60.0f),
2859 PWLPT_LINETO),
2860 CPWL_PathData(CPWL_Point(fHeight * 17 / 60.0f / k + tail.x -
2861 fWidth / 10.0f - fWidth / 5.0f,
2862 fWidth / 5.0f / k + tail.y + fWidth / 10.0f / k +
2863 fHeight * 17 / 60.0f),
2864 PWLPT_LINETO),
2865 CPWL_PathData(
2866 CPWL_Point(
2867 crBBox.left + fWidth / 20.0f,
2868 k * (crBBox.left + fWidth / 20.0f - rightdown.x) + rightdown.y),
2869 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002870
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002871 if (type == PWLPT_STREAM)
2872 sPathData = GetAppStreamFromArray(PathArray, 8);
2873 else
2874 GetPathDataFromArray(path, PathArray, 8);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002875}
2876
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002877void CPWL_Utils::GetGraphics_Graph(CFX_ByteString& sPathData,
2878 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002879 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002880 const PWL_PATH_TYPE type) {
2881 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2882 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002883
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002884 CPWL_PathData PathArray[] = {
2885 CPWL_PathData(
2886 CPWL_Point(crBBox.left + fWidth * 0.05f, crBBox.top - fWidth * 0.15f),
2887 PWLPT_MOVETO),
2888 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.25f,
2889 crBBox.top - fHeight * 0.15f),
2890 PWLPT_LINETO),
2891 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
2892 crBBox.bottom + fHeight * 0.08f),
2893 PWLPT_LINETO),
2894 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.05f,
2895 crBBox.bottom + fHeight * 0.08f),
2896 PWLPT_LINETO),
2897 CPWL_PathData(
2898 CPWL_Point(crBBox.left + fWidth * 0.05f, crBBox.top - fWidth * 0.15f),
2899 PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002900
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002901 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
2902 crBBox.top - fWidth * 0.45f),
2903 PWLPT_MOVETO),
2904 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.475f,
2905 crBBox.top - fWidth * 0.45f),
2906 PWLPT_LINETO),
2907 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.475f,
2908 crBBox.bottom + fHeight * 0.08f),
2909 PWLPT_LINETO),
2910 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
2911 crBBox.bottom + fHeight * 0.08f),
2912 PWLPT_LINETO),
2913 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.275f,
2914 crBBox.top - fWidth * 0.45f),
2915 PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002916
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002917 CPWL_PathData(
2918 CPWL_Point(crBBox.left + fWidth * 0.5f, crBBox.top - fHeight * 0.05f),
2919 PWLPT_MOVETO),
2920 CPWL_PathData(
2921 CPWL_Point(crBBox.left + fWidth * 0.7f, crBBox.top - fHeight * 0.05f),
2922 PWLPT_LINETO),
2923 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.7f,
2924 crBBox.bottom + fHeight * 0.08f),
2925 PWLPT_LINETO),
2926 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
2927 crBBox.bottom + fHeight * 0.08f),
2928 PWLPT_LINETO),
2929 CPWL_PathData(
2930 CPWL_Point(crBBox.left + fWidth * 0.5f, crBBox.top - fHeight * 0.05f),
2931 PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002932
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002933 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.725f,
2934 crBBox.top - fWidth * 0.35f),
2935 PWLPT_MOVETO),
2936 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.925f,
2937 crBBox.top - fWidth * 0.35f),
2938 PWLPT_LINETO),
2939 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.925f,
2940 crBBox.bottom + fHeight * 0.08f),
2941 PWLPT_LINETO),
2942 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.725f,
2943 crBBox.bottom + fHeight * 0.08f),
2944 PWLPT_LINETO),
2945 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.725f,
2946 crBBox.top - fWidth * 0.35f),
2947 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002948
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002949 if (type == PWLPT_STREAM)
2950 sPathData = GetAppStreamFromArray(PathArray, 20);
2951 else
2952 GetPathDataFromArray(path, PathArray, 20);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002953}
2954
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002955void CPWL_Utils::GetGraphics_Paperclip(CFX_ByteString& sPathData,
2956 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08002957 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002958 const PWL_PATH_TYPE type) {
2959 FX_FLOAT fWidth = crBBox.right - crBBox.left;
2960 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002961
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002962 CPWL_PathData PathArray[] = {
2963 CPWL_PathData(
2964 CPWL_Point(crBBox.left + fWidth / 60, crBBox.top - fHeight * 0.25f),
2965 PWLPT_MOVETO),
2966 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60,
2967 crBBox.bottom + fHeight * 0.25f),
2968 PWLPT_LINETO),
2969 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60,
2970 crBBox.bottom + fHeight * 0.25f -
2971 fWidth * 57 / 60.0f * 0.35f),
2972 PWLPT_BEZIERTO),
2973 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30,
2974 crBBox.bottom + fHeight * 0.25f -
2975 fWidth * 57 / 60.0f * 0.35f),
2976 PWLPT_BEZIERTO),
2977 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30,
2978 crBBox.bottom + fHeight * 0.25f),
2979 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07002980
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002981 CPWL_PathData(
2982 CPWL_Point(crBBox.right - fWidth / 30, crBBox.top - fHeight * 0.33f),
2983 PWLPT_LINETO),
2984 CPWL_PathData(
2985 CPWL_Point(crBBox.right - fWidth / 30,
2986 crBBox.top - fHeight * 0.33f + fHeight / 15 * 0.5f),
2987 PWLPT_BEZIERTO),
2988 CPWL_PathData(
2989 CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
2990 crBBox.top - fHeight * 0.33f + fHeight / 15 * 0.5f),
2991 PWLPT_BEZIERTO),
2992 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
2993 crBBox.top - fHeight * 0.33f),
2994 PWLPT_BEZIERTO),
Lei Zhanga6d9f0e2015-06-13 00:48:38 -07002995
Nico Weber9d8ec5a2015-08-04 13:00:21 -07002996 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
2997 crBBox.bottom + fHeight * 0.2f),
2998 PWLPT_LINETO),
2999 CPWL_PathData(
3000 CPWL_Point(crBBox.right - fWidth / 30 - fWidth * 0.12f,
3001 crBBox.bottom + fHeight * 0.2f -
3002 (fWidth * 57 / 60.0f - fWidth * 0.24f) * 0.25f),
3003 PWLPT_BEZIERTO),
3004 CPWL_PathData(
3005 CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
3006 crBBox.bottom + fHeight * 0.2f -
3007 (fWidth * 57 / 60.0f - fWidth * 0.24f) * 0.25f),
3008 PWLPT_BEZIERTO),
3009 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
3010 crBBox.bottom + fHeight * 0.2f),
3011 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003012
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003013 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
3014 crBBox.top - fHeight * 0.2f),
3015 PWLPT_LINETO),
3016 CPWL_PathData(
3017 CPWL_Point(crBBox.left + fWidth / 60 + fWidth * 0.12f,
3018 crBBox.top - fHeight * 0.2f +
3019 (fWidth * 11 / 12.0f - fWidth * 0.36f) * 0.25f),
3020 PWLPT_BEZIERTO),
3021 CPWL_PathData(
3022 CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
3023 crBBox.top - fHeight * 0.2f +
3024 (fWidth * 11 / 12.0f - fWidth * 0.36f) * 0.25f),
3025 PWLPT_BEZIERTO),
3026 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
3027 crBBox.top - fHeight * 0.2f),
3028 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003029
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003030 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
3031 crBBox.bottom + fHeight * 0.25f),
3032 PWLPT_LINETO),
3033 CPWL_PathData(
3034 CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.24f,
3035 crBBox.bottom + fHeight * 0.25f -
3036 (fWidth * 14 / 15.0f - fWidth * 0.53f) * 0.25f),
3037 PWLPT_BEZIERTO),
3038 CPWL_PathData(
3039 CPWL_Point(crBBox.left + fWidth * 0.29f,
3040 crBBox.bottom + fHeight * 0.25f -
3041 (fWidth * 14 / 15.0f - fWidth * 0.53f) * 0.25f),
3042 PWLPT_BEZIERTO),
3043 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.29f,
3044 crBBox.bottom + fHeight * 0.25f),
3045 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003046
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003047 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.29f,
3048 crBBox.top - fHeight * 0.33f),
3049 PWLPT_LINETO),
3050 CPWL_PathData(
3051 CPWL_Point(crBBox.left + fWidth * 0.29f,
3052 crBBox.top - fHeight * 0.33f + fWidth * 0.12f * 0.35f),
3053 PWLPT_BEZIERTO),
3054 CPWL_PathData(
3055 CPWL_Point(crBBox.left + fWidth * 0.17f,
3056 crBBox.top - fHeight * 0.33f + fWidth * 0.12f * 0.35f),
3057 PWLPT_BEZIERTO),
3058 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.17f,
3059 crBBox.top - fHeight * 0.33f),
3060 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003061
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003062 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.17f,
3063 crBBox.bottom + fHeight * 0.3f),
3064 PWLPT_LINETO),
3065 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.17f,
3066 crBBox.bottom + fHeight * 0.3f -
3067 fWidth * (14 / 15.0f - 0.29f) * 0.35f),
3068 PWLPT_BEZIERTO),
3069 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
3070 crBBox.bottom + fHeight * 0.3f -
3071 fWidth * (14 / 15.0f - 0.29f) * 0.35f),
3072 PWLPT_BEZIERTO),
3073 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
3074 crBBox.bottom + fHeight * 0.3f),
3075 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003076
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003077 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
3078 crBBox.top - fHeight * 0.25f),
3079 PWLPT_LINETO),
3080 CPWL_PathData(CPWL_Point(crBBox.right - fWidth / 15 - fWidth * 0.12f,
3081 crBBox.top - fHeight * 0.25f +
3082 fWidth * 0.35f * (11 / 12.0f - 0.12f)),
3083 PWLPT_BEZIERTO),
3084 CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 60,
3085 crBBox.top - fHeight * 0.25f +
3086 fWidth * 0.35f * (11 / 12.0f - 0.12f)),
3087 PWLPT_BEZIERTO),
3088 CPWL_PathData(
3089 CPWL_Point(crBBox.left + fWidth / 60, crBBox.top - fHeight * 0.25f),
3090 PWLPT_BEZIERTO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003091
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003092 if (type == PWLPT_STREAM)
3093 sPathData = GetAppStreamFromArray(PathArray, 33);
3094 else
3095 GetPathDataFromArray(path, PathArray, 33);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003096}
3097
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003098void CPWL_Utils::GetGraphics_Attachment(CFX_ByteString& sPathData,
3099 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08003100 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003101 const PWL_PATH_TYPE type) {
3102 FX_FLOAT fWidth = crBBox.right - crBBox.left;
3103 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003104
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003105 CPWL_PathData PathArray[] = {
3106 CPWL_PathData(
3107 CPWL_Point(crBBox.left + fWidth * 0.25f, crBBox.top - fHeight * 0.1f),
3108 PWLPT_MOVETO),
3109 CPWL_PathData(
3110 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.23f),
3111 PWLPT_LINETO),
3112 CPWL_PathData(
3113 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
3114 PWLPT_LINETO),
3115 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
3116 crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
3117 PWLPT_BEZIERTO),
3118 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
3119 crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
3120 PWLPT_BEZIERTO),
3121 CPWL_PathData(
3122 CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.5f),
3123 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003124
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003125 CPWL_PathData(
3126 CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.23f),
3127 PWLPT_LINETO),
3128 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.25f,
3129 crBBox.top - fHeight * 0.1f),
3130 PWLPT_LINETO),
3131 CPWL_PathData(
3132 CPWL_Point(crBBox.left + fWidth * 0.25f, crBBox.top - fHeight * 0.1f),
3133 PWLPT_LINETO),
3134 CPWL_PathData(
3135 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.23f),
3136 PWLPT_LINETO),
3137 CPWL_PathData(
3138 CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.23f),
3139 PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003140
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003141 CPWL_PathData(
3142 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
3143 PWLPT_MOVETO),
3144 CPWL_PathData(
3145 CPWL_Point(crBBox.left + fWidth * 0.4f - fWidth * 0.25f * 0.4f,
3146 crBBox.top - fHeight * 0.5f),
3147 PWLPT_BEZIERTO),
3148 CPWL_PathData(
3149 CPWL_Point(crBBox.left + fWidth * 0.15f,
3150 crBBox.top - fHeight * 0.65f + fHeight * 0.15f * 0.4f),
3151 PWLPT_BEZIERTO),
3152 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.15f,
3153 crBBox.top - fHeight * 0.65f),
3154 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003155
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003156 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.15f,
3157 crBBox.top - fHeight * 0.65f),
3158 PWLPT_LINETO),
3159 CPWL_PathData(
3160 CPWL_Point(crBBox.right - fWidth * 0.15f,
3161 crBBox.top - fHeight * 0.65f + fHeight * 0.15f * 0.4f),
3162 PWLPT_BEZIERTO),
3163 CPWL_PathData(
3164 CPWL_Point(crBBox.left + fWidth * 0.6f + fWidth * 0.25f * 0.4f,
3165 crBBox.top - fHeight * 0.5f),
3166 PWLPT_BEZIERTO),
3167 CPWL_PathData(
3168 CPWL_Point(crBBox.left + fWidth * 0.6f, crBBox.top - fHeight * 0.5f),
3169 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003170
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003171 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.6f,
3172 crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
3173 PWLPT_BEZIERTO),
3174 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.4f,
3175 crBBox.top - fHeight * 0.5f + fWidth * 0.04f),
3176 PWLPT_BEZIERTO),
3177 CPWL_PathData(
3178 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
3179 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003180
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003181 CPWL_PathData(
3182 CPWL_Point(crBBox.left + fWidth * 0.5f, crBBox.top - fHeight * 0.65f),
3183 PWLPT_MOVETO),
3184 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.5f,
3185 crBBox.bottom + fHeight * 0.1f),
3186 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003187
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003188 if (type == PWLPT_STREAM)
3189 sPathData = GetAppStreamFromArray(PathArray, 24);
3190 else
3191 GetPathDataFromArray(path, PathArray, 24);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003192}
3193
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003194void CPWL_Utils::GetGraphics_Tag(CFX_ByteString& sPathData,
3195 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08003196 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003197 const PWL_PATH_TYPE type) {
3198 FX_FLOAT fWidth = crBBox.right - crBBox.left;
3199 FX_FLOAT fHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003200
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003201 CPWL_PathData PathArray[] = {
3202 CPWL_PathData(
3203 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.1f),
3204 PWLPT_MOVETO),
3205 CPWL_PathData(
3206 CPWL_Point(crBBox.left + fWidth * 0.1f, crBBox.top - fHeight * 0.5f),
3207 PWLPT_LINETO),
3208 CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 0.3f,
3209 crBBox.bottom + fHeight * 0.1f),
3210 PWLPT_LINETO),
3211 CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.1f,
3212 crBBox.bottom + fHeight * 0.1f),
3213 PWLPT_LINETO),
3214 CPWL_PathData(
3215 CPWL_Point(crBBox.right - fWidth * 0.1f, crBBox.top - fHeight * 0.1f),
3216 PWLPT_LINETO),
3217 CPWL_PathData(
3218 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.1f),
3219 PWLPT_LINETO),
3220 CPWL_PathData(
3221 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.3f),
3222 PWLPT_MOVETO),
3223 CPWL_PathData(
3224 CPWL_Point(crBBox.right - fWidth * 0.2f, crBBox.top - fHeight * 0.3f),
3225 PWLPT_LINETO),
3226 CPWL_PathData(
3227 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.5f),
3228 PWLPT_MOVETO),
3229 CPWL_PathData(
3230 CPWL_Point(crBBox.right - fWidth * 0.2f, crBBox.top - fHeight * 0.5f),
3231 PWLPT_LINETO),
3232 CPWL_PathData(
3233 CPWL_Point(crBBox.left + fWidth * 0.4f, crBBox.top - fHeight * 0.7f),
3234 PWLPT_MOVETO),
3235 CPWL_PathData(
3236 CPWL_Point(crBBox.right - fWidth * 0.2f, crBBox.top - fHeight * 0.7f),
3237 PWLPT_LINETO)};
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003238
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003239 if (type == PWLPT_STREAM)
3240 sPathData = GetAppStreamFromArray(PathArray, 12);
3241 else
3242 GetPathDataFromArray(path, PathArray, 12);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003243}
3244
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003245void CPWL_Utils::GetGraphics_Foxit(CFX_ByteString& sPathData,
3246 CFX_PathData& path,
Tom Sepez281a9ea2016-02-26 14:24:28 -08003247 const CFX_FloatRect& crBBox,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003248 const PWL_PATH_TYPE type) {
3249 FX_FLOAT fOutWidth = crBBox.right - crBBox.left;
3250 FX_FLOAT fOutHeight = crBBox.top - crBBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003251
Tom Sepez281a9ea2016-02-26 14:24:28 -08003252 CFX_FloatRect crInBox = crBBox;
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003253 crInBox.left = crBBox.left + fOutWidth * 0.08f;
3254 crInBox.right = crBBox.right - fOutWidth * 0.08f;
3255 crInBox.top = crBBox.top - fOutHeight * 0.08f;
3256 crInBox.bottom = crBBox.bottom + fOutHeight * 0.08f;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003257
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003258 FX_FLOAT fWidth = crInBox.right - crInBox.left;
3259 FX_FLOAT fHeight = crInBox.top - crInBox.bottom;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003260
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003261 CPWL_PathData PathArray[] = {
3262 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_MOVETO),
3263 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.45f, crInBox.top),
3264 PWLPT_LINETO),
3265 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.45f,
Tom Sepeza30b7e82016-02-12 15:58:50 -08003266 crInBox.top - FX_BEZIER * fHeight * 0.4f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003267 PWLPT_BEZIERTO),
Tom Sepeza30b7e82016-02-12 15:58:50 -08003268 CPWL_PathData(
3269 CPWL_Point(crInBox.left + fWidth * 0.45f - FX_BEZIER * fWidth * 0.45f,
3270 crInBox.top - fHeight * 0.4f),
3271 PWLPT_BEZIERTO),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003272 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.4f),
3273 PWLPT_BEZIERTO),
3274 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top), PWLPT_LINETO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003275
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003276 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top),
3277 PWLPT_MOVETO),
3278 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.75f, crInBox.top),
3279 PWLPT_LINETO),
3280 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.75f,
Tom Sepeza30b7e82016-02-12 15:58:50 -08003281 crInBox.top - FX_BEZIER * fHeight * 0.7f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003282 PWLPT_BEZIERTO),
Tom Sepeza30b7e82016-02-12 15:58:50 -08003283 CPWL_PathData(
3284 CPWL_Point(crInBox.left + fWidth * 0.75f - FX_BEZIER * fWidth * 0.75f,
3285 crInBox.top - fHeight * 0.7f),
3286 PWLPT_BEZIERTO),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003287 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.7f),
3288 PWLPT_BEZIERTO),
3289 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.55f),
3290 PWLPT_LINETO),
Tom Sepeza30b7e82016-02-12 15:58:50 -08003291 CPWL_PathData(CPWL_Point(crInBox.left + FX_BEZIER * fWidth * 0.60f,
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003292 crInBox.top - fHeight * 0.55f),
3293 PWLPT_BEZIERTO),
3294 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f,
Tom Sepeza30b7e82016-02-12 15:58:50 -08003295 crInBox.top - FX_BEZIER * fHeight * 0.55f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003296 PWLPT_BEZIERTO),
3297 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top),
3298 PWLPT_BEZIERTO),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003299
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003300 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f, crInBox.top),
3301 PWLPT_MOVETO),
3302 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f,
Tom Sepeza30b7e82016-02-12 15:58:50 -08003303 crInBox.top - FX_BEZIER * fHeight * 0.85f),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003304 PWLPT_BEZIERTO),
Tom Sepeza30b7e82016-02-12 15:58:50 -08003305 CPWL_PathData(
3306 CPWL_Point(crInBox.left + fWidth * 0.90f - FX_BEZIER * fWidth * 0.90f,
3307 crInBox.top - fHeight * 0.85f),
3308 PWLPT_BEZIERTO),
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003309 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.top - fHeight * 0.85f),
3310 PWLPT_BEZIERTO),
3311 CPWL_PathData(CPWL_Point(crInBox.left, crInBox.bottom), PWLPT_LINETO),
3312 CPWL_PathData(CPWL_Point(crInBox.right, crInBox.bottom), PWLPT_LINETO),
3313 CPWL_PathData(CPWL_Point(crInBox.right, crInBox.top), PWLPT_LINETO),
3314 CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.90f, crInBox.top),
3315 PWLPT_LINETO),
3316 };
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003317
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003318 if (type == PWLPT_STREAM)
3319 sPathData = GetAppStreamFromArray(PathArray, 23);
3320 else
3321 GetPathDataFromArray(path, PathArray, 23);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003322}
3323
jaeparkcba85ab2016-09-08 18:09:59 -07003324void CPWL_Color::ConvertColorType(int32_t nConvertColorType) {
3325 if (nColorType == nConvertColorType)
3326 return;
3327
3328 switch (nColorType) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003329 case COLORTYPE_TRANSPARENT:
3330 break;
3331 case COLORTYPE_GRAY:
jaeparkcba85ab2016-09-08 18:09:59 -07003332 switch (nConvertColorType) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003333 case COLORTYPE_RGB:
3334 CPWL_Utils::ConvertGRAY2RGB(fColor1, fColor1, fColor2, fColor3);
3335 break;
3336 case COLORTYPE_CMYK:
3337 CPWL_Utils::ConvertGRAY2CMYK(fColor1, fColor1, fColor2, fColor3,
3338 fColor4);
3339 break;
3340 }
3341 break;
3342 case COLORTYPE_RGB:
jaeparkcba85ab2016-09-08 18:09:59 -07003343 switch (nConvertColorType) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003344 case COLORTYPE_GRAY:
3345 CPWL_Utils::ConvertRGB2GRAY(fColor1, fColor2, fColor3, fColor1);
3346 break;
3347 case COLORTYPE_CMYK:
3348 CPWL_Utils::ConvertRGB2CMYK(fColor1, fColor2, fColor3, fColor1,
3349 fColor2, fColor3, fColor4);
3350 break;
3351 }
3352 break;
3353 case COLORTYPE_CMYK:
jaeparkcba85ab2016-09-08 18:09:59 -07003354 switch (nConvertColorType) {
Nico Weber9d8ec5a2015-08-04 13:00:21 -07003355 case COLORTYPE_GRAY:
3356 CPWL_Utils::ConvertCMYK2GRAY(fColor1, fColor2, fColor3, fColor4,
3357 fColor1);
3358 break;
3359 case COLORTYPE_RGB:
3360 CPWL_Utils::ConvertCMYK2RGB(fColor1, fColor2, fColor3, fColor4,
3361 fColor1, fColor2, fColor3);
3362 break;
3363 }
3364 break;
3365 }
jaeparkcba85ab2016-09-08 18:09:59 -07003366 nColorType = nConvertColorType;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07003367}