John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1 | // 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 4 | |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 7 | #include "fpdfsdk/pdfwindow/PWL_Utils.h" |
Lei Zhang | 375a864 | 2016-01-11 11:59:17 -0800 | [diff] [blame] | 8 | |
| 9 | #include <algorithm> |
Dan Sinclair | 85c8e7f | 2016-11-21 13:50:32 -0500 | [diff] [blame] | 10 | #include <memory> |
Lei Zhang | 375a864 | 2016-01-11 11:59:17 -0800 | [diff] [blame] | 11 | |
dsinclair | 1727aee | 2016-09-29 13:12:56 -0700 | [diff] [blame] | 12 | #include "core/fpdfdoc/cpvt_word.h" |
dsinclair | 74a34fc | 2016-09-29 16:41:42 -0700 | [diff] [blame] | 13 | #include "core/fxge/cfx_graphstatedata.h" |
| 14 | #include "core/fxge/cfx_pathdata.h" |
| 15 | #include "core/fxge/cfx_renderdevice.h" |
dsinclair | 0bb385b | 2016-09-29 17:03:59 -0700 | [diff] [blame] | 16 | #include "fpdfsdk/fxedit/fxet_edit.h" |
dan sinclair | 89e904b | 2016-03-23 19:29:15 -0400 | [diff] [blame] | 17 | #include "fpdfsdk/pdfwindow/PWL_Icon.h" |
| 18 | #include "fpdfsdk/pdfwindow/PWL_Wnd.h" |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 19 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 20 | CFX_ByteString CPWL_Utils::GetAppStreamFromArray(const CPWL_PathData* pPathData, |
| 21 | int32_t nCount) { |
| 22 | CFX_ByteTextBuf csAP; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 23 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 24 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 37 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 38 | i += 2; |
| 39 | break; |
| 40 | default: |
| 41 | break; |
| 42 | } |
| 43 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 44 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 45 | return csAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 46 | } |
| 47 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 48 | void CPWL_Utils::GetPathDataFromArray(CFX_PathData& path, |
| 49 | const CPWL_PathData* pPathData, |
| 50 | int32_t nCount) { |
| 51 | path.SetPointCount(nCount); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 52 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 53 | 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 Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 57 | FXPT_TYPE::MoveTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 58 | break; |
| 59 | case PWLPT_LINETO: |
| 60 | path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 61 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 62 | break; |
| 63 | case PWLPT_BEZIERTO: |
| 64 | path.SetPoint(i, pPathData[i].point.x, pPathData[i].point.y, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 65 | FXPT_TYPE::BezierTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 66 | break; |
| 67 | default: |
| 68 | break; |
| 69 | } |
| 70 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 71 | } |
| 72 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 73 | CFX_FloatRect CPWL_Utils::MaxRect(const CFX_FloatRect& rect1, |
| 74 | const CFX_FloatRect& rect2) { |
| 75 | CFX_FloatRect rcRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 76 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 77 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 81 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 82 | return rcRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 85 | CFX_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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 90 | } |
| 91 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 92 | bool CPWL_Utils::ContainsRect(const CFX_FloatRect& rcParent, |
| 93 | const CFX_FloatRect& rcChild) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 94 | return rcChild.left >= rcParent.left && rcChild.bottom >= rcParent.bottom && |
| 95 | rcChild.right <= rcParent.right && rcChild.top <= rcParent.top; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 96 | } |
| 97 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 98 | bool CPWL_Utils::IntersectRect(const CFX_FloatRect& rect1, |
| 99 | const CFX_FloatRect& rect2) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 100 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 104 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 105 | return left < right && bottom < top; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 108 | CFX_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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 112 | } |
| 113 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 114 | CPVT_WordRange CPWL_Utils::OverlapWordRange(const CPVT_WordRange& wr1, |
| 115 | const CPVT_WordRange& wr2) { |
| 116 | CPVT_WordRange wrRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 117 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 118 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 124 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 125 | if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) { |
| 126 | wrRet.BeginPos = wr2.BeginPos; |
| 127 | } else { |
| 128 | wrRet.BeginPos = wr1.BeginPos; |
| 129 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 130 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 131 | if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) { |
| 132 | wrRet.EndPos = wr1.EndPos; |
| 133 | } else { |
| 134 | wrRet.EndPos = wr2.EndPos; |
| 135 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 136 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 137 | return wrRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 138 | } |
| 139 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 140 | CFX_ByteString CPWL_Utils::GetAP_Check(const CFX_FloatRect& crBBox) { |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 141 | const FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 142 | const FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 143 | |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 144 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 160 | |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 161 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 166 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 167 | |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 168 | CFX_ByteTextBuf csAP; |
| 169 | csAP << pts[0][0].x << " " << pts[0][0].y << " m\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 170 | |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 171 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 173 | |
Lei Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 174 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 178 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 179 | 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 Zhang | c2fb35f | 2016-01-05 16:46:58 -0800 | [diff] [blame] | 183 | << pts[nNext][0].y << " c\n"; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 184 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 185 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 186 | return csAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 189 | CFX_ByteString CPWL_Utils::GetAP_Circle(const CFX_FloatRect& crBBox) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 190 | CFX_ByteTextBuf csAP; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 191 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 192 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 193 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 194 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 195 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 199 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 200 | csAP << pt1.x << " " << pt1.y << " m\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 201 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 202 | FX_FLOAT px = pt2.x - pt1.x; |
| 203 | FX_FLOAT py = pt2.y - pt1.y; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 204 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 205 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 208 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 209 | px = pt3.x - pt2.x; |
| 210 | py = pt2.y - pt3.y; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 211 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 212 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 214 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 215 | px = pt3.x - pt4.x; |
| 216 | py = pt3.y - pt4.y; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 217 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 218 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 221 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 222 | px = pt4.x - pt1.x; |
| 223 | py = pt1.y - pt4.y; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 224 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 225 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 227 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 228 | return csAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 229 | } |
| 230 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 231 | CFX_ByteString CPWL_Utils::GetAP_Cross(const CFX_FloatRect& crBBox) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 232 | CFX_ByteTextBuf csAP; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 233 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 234 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 238 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 239 | return csAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 240 | } |
| 241 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 242 | CFX_ByteString CPWL_Utils::GetAP_Diamond(const CFX_FloatRect& crBBox) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 243 | CFX_ByteTextBuf csAP; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 244 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 245 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 246 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 247 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 248 | 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 252 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 253 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 258 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 259 | return csAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 262 | CFX_ByteString CPWL_Utils::GetAP_Square(const CFX_FloatRect& crBBox) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 263 | CFX_ByteTextBuf csAP; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 264 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 265 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 270 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 271 | return csAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 274 | CFX_ByteString CPWL_Utils::GetAP_Star(const CFX_FloatRect& crBBox) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 275 | CFX_ByteTextBuf csAP; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 276 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 277 | FX_FLOAT fRadius = |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 278 | (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 279 | CFX_PointF ptCenter = CFX_PointF((crBBox.left + crBBox.right) / 2.0f, |
| 280 | (crBBox.top + crBBox.bottom) / 2.0f); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 281 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 282 | FX_FLOAT px[5], py[5]; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 283 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 284 | FX_FLOAT fAngel = FX_PI / 10.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 285 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 286 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 289 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 290 | fAngel += FX_PI * 2 / 5.0f; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 291 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 292 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 293 | csAP << px[0] << " " << py[0] << " m\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 294 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 295 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 302 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 303 | return csAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 304 | } |
| 305 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 306 | CFX_ByteString CPWL_Utils::GetAP_HalfCircle(const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 307 | FX_FLOAT fRotate) { |
| 308 | CFX_ByteTextBuf csAP; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 309 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 310 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 311 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 312 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 313 | CFX_PointF pt1(-fWidth / 2, 0); |
| 314 | CFX_PointF pt2(0, fHeight / 2); |
| 315 | CFX_PointF pt3(fWidth / 2, 0); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 316 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 317 | FX_FLOAT px, py; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 318 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 319 | csAP << cos(fRotate) << " " << sin(fRotate) << " " << -sin(fRotate) << " " |
| 320 | << cos(fRotate) << " " << crBBox.left + fWidth / 2 << " " |
| 321 | << crBBox.bottom + fHeight / 2 << " cm\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 322 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 323 | csAP << pt1.x << " " << pt1.y << " m\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 324 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 325 | px = pt2.x - pt1.x; |
| 326 | py = pt2.y - pt1.y; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 327 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 328 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 331 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 332 | px = pt3.x - pt2.x; |
| 333 | py = pt2.y - pt3.y; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 334 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 335 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 337 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 338 | return csAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 339 | } |
| 340 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 341 | CFX_FloatRect CPWL_Utils::InflateRect(const CFX_FloatRect& rcRect, |
| 342 | FX_FLOAT fSize) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 343 | if (rcRect.IsEmpty()) |
| 344 | return rcRect; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 345 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 346 | CFX_FloatRect rcNew(rcRect.left - fSize, rcRect.bottom - fSize, |
| 347 | rcRect.right + fSize, rcRect.top + fSize); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 348 | rcNew.Normalize(); |
| 349 | return rcNew; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 350 | } |
| 351 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 352 | CFX_FloatRect CPWL_Utils::DeflateRect(const CFX_FloatRect& rcRect, |
| 353 | FX_FLOAT fSize) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 354 | if (rcRect.IsEmpty()) |
| 355 | return rcRect; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 356 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 357 | CFX_FloatRect rcNew(rcRect.left + fSize, rcRect.bottom + fSize, |
| 358 | rcRect.right - fSize, rcRect.top - fSize); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 359 | rcNew.Normalize(); |
| 360 | return rcNew; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 361 | } |
| 362 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 363 | CFX_FloatRect CPWL_Utils::ScaleRect(const CFX_FloatRect& rcRect, |
| 364 | FX_FLOAT fScale) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 365 | FX_FLOAT fHalfWidth = (rcRect.right - rcRect.left) / 2.0f; |
| 366 | FX_FLOAT fHalfHeight = (rcRect.top - rcRect.bottom) / 2.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 367 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 368 | CFX_PointF ptCenter = CFX_PointF((rcRect.left + rcRect.right) / 2, |
| 369 | (rcRect.top + rcRect.bottom) / 2); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 370 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 371 | return CFX_FloatRect( |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 372 | ptCenter.x - fHalfWidth * fScale, ptCenter.y - fHalfHeight * fScale, |
| 373 | ptCenter.x + fHalfWidth * fScale, ptCenter.y + fHalfHeight * fScale); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 374 | } |
| 375 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 376 | CFX_ByteString CPWL_Utils::GetRectFillAppStream(const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 377 | const CPWL_Color& color) { |
| 378 | CFX_ByteTextBuf sAppStream; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 379 | CFX_ByteString sColor = GetColorAppStream(color, true); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 380 | 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 386 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 387 | return sAppStream.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 388 | } |
| 389 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 390 | CFX_ByteString CPWL_Utils::GetCircleFillAppStream(const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 391 | const CPWL_Color& color) { |
| 392 | CFX_ByteTextBuf sAppStream; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 393 | CFX_ByteString sColor = GetColorAppStream(color, true); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 394 | if (sColor.GetLength() > 0) { |
| 395 | sAppStream << "q\n" << sColor << CPWL_Utils::GetAP_Circle(rect) << "f\nQ\n"; |
| 396 | } |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 397 | return sAppStream.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 398 | } |
| 399 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 400 | CFX_FloatRect CPWL_Utils::GetCenterSquare(const CFX_FloatRect& rect) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 401 | FX_FLOAT fWidth = rect.right - rect.left; |
| 402 | FX_FLOAT fHeight = rect.top - rect.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 403 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 404 | FX_FLOAT fCenterX = (rect.left + rect.right) / 2.0f; |
| 405 | FX_FLOAT fCenterY = (rect.top + rect.bottom) / 2.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 406 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 407 | FX_FLOAT fRadius = (fWidth > fHeight) ? fHeight / 2 : fWidth / 2; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 408 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 409 | return CFX_FloatRect(fCenterX - fRadius, fCenterY - fRadius, |
| 410 | fCenterX + fRadius, fCenterY + fRadius); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 411 | } |
| 412 | |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 413 | CFX_ByteString CPWL_Utils::GetEditAppStream(CFX_Edit* pEdit, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 414 | const CFX_PointF& ptOffset, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 415 | const CPVT_WordRange* pRange, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 416 | bool bContinuous, |
Tom Sepez | 62a70f9 | 2016-03-21 15:00:20 -0700 | [diff] [blame] | 417 | uint16_t SubWord) { |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 418 | return CFX_Edit::GetEditAppearanceStream(pEdit, ptOffset, pRange, bContinuous, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 419 | SubWord); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 420 | } |
| 421 | |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 422 | CFX_ByteString CPWL_Utils::GetEditSelAppStream(CFX_Edit* pEdit, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 423 | const CFX_PointF& ptOffset, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 424 | const CPVT_WordRange* pRange) { |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 425 | return CFX_Edit::GetSelectAppearanceStream(pEdit, ptOffset, pRange); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 426 | } |
| 427 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 428 | CFX_ByteString CPWL_Utils::GetTextAppStream(const CFX_FloatRect& rcBBox, |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 429 | IPVT_FontMap* pFontMap, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 430 | const CFX_WideString& sText, |
| 431 | int32_t nAlignmentH, |
| 432 | int32_t nAlignmentV, |
| 433 | FX_FLOAT fFontSize, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 434 | bool bMultiLine, |
| 435 | bool bAutoReturn, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 436 | const CPWL_Color& crText) { |
| 437 | CFX_ByteTextBuf sRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 438 | |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 439 | std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 440 | pEdit->SetFontMap(pFontMap); |
| 441 | pEdit->SetPlateRect(rcBBox); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 442 | pEdit->SetAlignmentH(nAlignmentH, true); |
| 443 | pEdit->SetAlignmentV(nAlignmentV, true); |
| 444 | pEdit->SetMultiLine(bMultiLine, true); |
| 445 | pEdit->SetAutoReturn(bAutoReturn, true); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 446 | if (IsFloatZero(fFontSize)) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 447 | pEdit->SetAutoFontSize(true, true); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 448 | else |
| 449 | pEdit->SetFontSize(fFontSize); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 450 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 451 | pEdit->Initialize(); |
tsepez | 067990c | 2016-09-13 06:46:40 -0700 | [diff] [blame] | 452 | pEdit->SetText(sText); |
Tom Sepez | 4f7bc04 | 2015-04-27 12:06:58 -0700 | [diff] [blame] | 453 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 454 | CFX_ByteString sEdit = |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 455 | CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, 0.0f)); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 456 | if (sEdit.GetLength() > 0) |
| 457 | sRet << "BT\n" << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 458 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 459 | return sRet.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 460 | } |
| 461 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 462 | CFX_ByteString CPWL_Utils::GetPushButtonAppStream(const CFX_FloatRect& rcBBox, |
dsinclair | c7a7349 | 2016-04-05 12:01:42 -0700 | [diff] [blame] | 463 | IPVT_FontMap* pFontMap, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 464 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 471 | |
dsinclair | e35af1e | 2016-07-13 11:26:20 -0700 | [diff] [blame] | 472 | std::unique_ptr<CFX_Edit> pEdit(new CFX_Edit); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 473 | pEdit->SetFontMap(pFontMap); |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 474 | pEdit->SetAlignmentH(1, true); |
| 475 | pEdit->SetAlignmentV(1, true); |
| 476 | pEdit->SetMultiLine(false, true); |
| 477 | pEdit->SetAutoReturn(false, true); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 478 | if (IsFloatZero(fFontSize)) |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 479 | pEdit->SetAutoFontSize(true, true); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 480 | else |
| 481 | pEdit->SetFontSize(fFontSize); |
Tom Sepez | 4f7bc04 | 2015-04-27 12:06:58 -0700 | [diff] [blame] | 482 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 483 | pEdit->Initialize(); |
tsepez | 067990c | 2016-09-13 06:46:40 -0700 | [diff] [blame] | 484 | pEdit->SetText(sLabel); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 485 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 486 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 493 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 494 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 498 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 499 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 509 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 510 | 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 Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 524 | rcLabel = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right, |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 525 | rcBBox.bottom + fHeight); |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 526 | rcIcon = CFX_FloatRect(rcBBox.left, rcLabel.top, rcBBox.right, |
| 527 | rcBBox.top); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 528 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 529 | } |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 530 | } else { |
| 531 | rcLabel = rcBBox; |
| 532 | rcIcon = CFX_FloatRect(0, 0, 0, 0); |
| 533 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 534 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 535 | break; |
| 536 | case PPBL_LABELTOPICONBOTTOM: |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 537 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 538 | 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 Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 554 | rcBBox.right, rcBBox.top); |
| 555 | rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcBBox.right, |
| 556 | rcLabel.bottom); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 557 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 558 | } |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 559 | } else { |
| 560 | rcLabel = rcBBox; |
| 561 | rcIcon = CFX_FloatRect(0, 0, 0, 0); |
| 562 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 563 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 564 | break; |
| 565 | case PPBL_ICONLEFTLABELRIGHT: |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 566 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 567 | if (pIconStream) { |
| 568 | if (IsFloatZero(fFontSize)) { |
| 569 | fWidth = rcBBox.right - rcBBox.left; |
| 570 | rcLabel = CFX_FloatRect(rcBBox.right - fWidth * fAutoFontScale, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 571 | rcBBox.bottom, rcBBox.right, rcBBox.top); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 572 | rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left, |
| 573 | rcBBox.top); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 574 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 575 | 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 Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 580 | rcIcon = CFX_FloatRect(rcBBox.left, rcBBox.bottom, rcLabel.left, |
| 581 | rcBBox.top); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 582 | } else { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 583 | rcLabel = rcBBox; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 584 | rcIcon = CFX_FloatRect(0, 0, 0, 0); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 585 | } |
| 586 | } |
| 587 | } else { |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 588 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 599 | } |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 600 | } else { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 601 | rcLabel = rcBBox; |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 602 | rcIcon = CFX_FloatRect(0, 0, 0, 0); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 603 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 604 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 605 | break; |
| 606 | case PPBL_LABELLEFTICONRIGHT: |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 607 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 608 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 616 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 617 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 653 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 654 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 655 | CFX_ByteTextBuf sAppStream, sTemp; |
| 656 | |
| 657 | if (!rcIcon.IsEmpty()) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 658 | Icon.Move(rcIcon, false, false); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 659 | sTemp << Icon.GetImageAppStream(); |
| 660 | } |
| 661 | |
| 662 | Icon.Destroy(); |
| 663 | |
| 664 | if (!rcLabel.IsEmpty()) { |
| 665 | pEdit->SetPlateRect(rcLabel); |
| 666 | CFX_ByteString sEdit = |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 667 | CPWL_Utils::GetEditAppStream(pEdit.get(), CFX_PointF(0.0f, 0.0f)); |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 668 | if (sEdit.GetLength() > 0) { |
| 669 | sTemp << "BT\n" |
| 670 | << CPWL_Utils::GetColorAppStream(crText) << sEdit << "ET\n"; |
| 671 | } |
| 672 | } |
| 673 | |
thestig | 732f6a0 | 2016-05-12 10:41:56 -0700 | [diff] [blame] | 674 | 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 | } |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 681 | return sAppStream.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 682 | } |
| 683 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 684 | CFX_ByteString CPWL_Utils::GetColorAppStream(const CPWL_Color& color, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 685 | const bool& bFillOrStroke) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 686 | CFX_ByteTextBuf sColorStream; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 687 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 688 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 704 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 705 | return sColorStream.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 706 | } |
| 707 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 708 | CFX_ByteString CPWL_Utils::GetBorderAppStream(const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 709 | FX_FLOAT fWidth, |
| 710 | const CPWL_Color& color, |
| 711 | const CPWL_Color& crLeftTop, |
| 712 | const CPWL_Color& crRightBottom, |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 713 | BorderStyle nStyle, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 714 | const CPWL_Dash& dash) { |
| 715 | CFX_ByteTextBuf sAppStream; |
| 716 | CFX_ByteString sColor; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 717 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 718 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 722 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 723 | if (fWidth > 0.0f) { |
| 724 | FX_FLOAT fHalfWidth = fWidth / 2.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 725 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 726 | sAppStream << "q\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 727 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 728 | switch (nStyle) { |
| 729 | default: |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 730 | case BorderStyle::SOLID: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 731 | sColor = CPWL_Utils::GetColorAppStream(color, true); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 732 | 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; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 742 | case BorderStyle::DASH: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 743 | sColor = CPWL_Utils::GetColorAppStream(color, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 744 | 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; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 761 | case BorderStyle::BEVELED: |
| 762 | case BorderStyle::INSET: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 763 | sColor = CPWL_Utils::GetColorAppStream(crLeftTop, true); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 764 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 779 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 780 | sColor = CPWL_Utils::GetColorAppStream(crRightBottom, true); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 781 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 796 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 797 | sColor = CPWL_Utils::GetColorAppStream(color, true); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 798 | 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; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 807 | case BorderStyle::UNDERLINE: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 808 | sColor = CPWL_Utils::GetColorAppStream(color, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 809 | 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 817 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 818 | sAppStream << "Q\n"; |
| 819 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 820 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 821 | return sAppStream.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 822 | } |
| 823 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 824 | CFX_ByteString CPWL_Utils::GetCircleBorderAppStream( |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 825 | const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 826 | FX_FLOAT fWidth, |
| 827 | const CPWL_Color& color, |
| 828 | const CPWL_Color& crLeftTop, |
| 829 | const CPWL_Color& crRightBottom, |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 830 | BorderStyle nStyle, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 831 | const CPWL_Dash& dash) { |
| 832 | CFX_ByteTextBuf sAppStream; |
| 833 | CFX_ByteString sColor; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 834 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 835 | if (fWidth > 0.0f) { |
| 836 | sAppStream << "q\n"; |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 837 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 838 | switch (nStyle) { |
| 839 | default: |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 840 | case BorderStyle::SOLID: |
| 841 | case BorderStyle::UNDERLINE: { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 842 | sColor = CPWL_Utils::GetColorAppStream(color, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 843 | 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; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 850 | case BorderStyle::DASH: { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 851 | sColor = CPWL_Utils::GetColorAppStream(color, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 852 | 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; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 861 | case BorderStyle::BEVELED: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 862 | FX_FLOAT fHalfWidth = fWidth / 2.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 863 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 864 | sColor = CPWL_Utils::GetColorAppStream(color, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 865 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 869 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 870 | sColor = CPWL_Utils::GetColorAppStream(crLeftTop, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 871 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 875 | FX_PI / 4.0f) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 876 | << " S\nQ\n"; |
| 877 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 878 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 879 | sColor = CPWL_Utils::GetColorAppStream(crRightBottom, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 880 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 884 | FX_PI * 5 / 4.0f) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 885 | << " S\nQ\n"; |
| 886 | } |
| 887 | } break; |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 888 | case BorderStyle::INSET: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 889 | FX_FLOAT fHalfWidth = fWidth / 2.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 890 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 891 | sColor = CPWL_Utils::GetColorAppStream(color, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 892 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 896 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 897 | sColor = CPWL_Utils::GetColorAppStream(crLeftTop, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 898 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 902 | FX_PI / 4.0f) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 903 | << " S\nQ\n"; |
| 904 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 905 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 906 | sColor = CPWL_Utils::GetColorAppStream(crRightBottom, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 907 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 911 | FX_PI * 5 / 4.0f) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 912 | << " S\nQ\n"; |
| 913 | } |
| 914 | } break; |
| 915 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 916 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 917 | sAppStream << "Q\n"; |
| 918 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 919 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 920 | return sAppStream.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 921 | } |
| 922 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 923 | CPWL_Color CPWL_Utils::SubstractColor(const CPWL_Color& sColor, |
| 924 | FX_FLOAT fColorSub) { |
| 925 | CPWL_Color sRet; |
| 926 | sRet.nColorType = sColor.nColorType; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 927 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 928 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 944 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 945 | return sRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 946 | } |
| 947 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 948 | CPWL_Color CPWL_Utils::DevideColor(const CPWL_Color& sColor, |
| 949 | FX_FLOAT fColorDevide) { |
| 950 | CPWL_Color sRet; |
| 951 | sRet.nColorType = sColor.nColorType; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 952 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 953 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 970 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 971 | return sRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 972 | } |
| 973 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 974 | CFX_ByteString CPWL_Utils::GetAppStream_Check(const CFX_FloatRect& rcBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 975 | const CPWL_Color& crText) { |
| 976 | CFX_ByteTextBuf sAP; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 977 | sAP << "q\n" |
| 978 | << CPWL_Utils::GetColorAppStream(crText, true) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 979 | << CPWL_Utils::GetAP_Check(rcBBox) << "f\nQ\n"; |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 980 | return sAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 981 | } |
| 982 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 983 | CFX_ByteString CPWL_Utils::GetAppStream_Circle(const CFX_FloatRect& rcBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 984 | const CPWL_Color& crText) { |
| 985 | CFX_ByteTextBuf sAP; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 986 | sAP << "q\n" |
| 987 | << CPWL_Utils::GetColorAppStream(crText, true) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 988 | << CPWL_Utils::GetAP_Circle(rcBBox) << "f\nQ\n"; |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 989 | return sAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 990 | } |
| 991 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 992 | CFX_ByteString CPWL_Utils::GetAppStream_Cross(const CFX_FloatRect& rcBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 993 | const CPWL_Color& crText) { |
| 994 | CFX_ByteTextBuf sAP; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 995 | sAP << "q\n" |
| 996 | << CPWL_Utils::GetColorAppStream(crText, false) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 997 | << CPWL_Utils::GetAP_Cross(rcBBox) << "S\nQ\n"; |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 998 | return sAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 999 | } |
| 1000 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1001 | CFX_ByteString CPWL_Utils::GetAppStream_Diamond(const CFX_FloatRect& rcBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1002 | const CPWL_Color& crText) { |
| 1003 | CFX_ByteTextBuf sAP; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 1004 | sAP << "q\n1 w\n" |
| 1005 | << CPWL_Utils::GetColorAppStream(crText, true) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1006 | << CPWL_Utils::GetAP_Diamond(rcBBox) << "f\nQ\n"; |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 1007 | return sAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1008 | } |
| 1009 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1010 | CFX_ByteString CPWL_Utils::GetAppStream_Square(const CFX_FloatRect& rcBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1011 | const CPWL_Color& crText) { |
| 1012 | CFX_ByteTextBuf sAP; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 1013 | sAP << "q\n" |
| 1014 | << CPWL_Utils::GetColorAppStream(crText, true) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1015 | << CPWL_Utils::GetAP_Square(rcBBox) << "f\nQ\n"; |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 1016 | return sAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1017 | } |
| 1018 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1019 | CFX_ByteString CPWL_Utils::GetAppStream_Star(const CFX_FloatRect& rcBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1020 | const CPWL_Color& crText) { |
| 1021 | CFX_ByteTextBuf sAP; |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 1022 | sAP << "q\n" |
| 1023 | << CPWL_Utils::GetColorAppStream(crText, true) |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1024 | << CPWL_Utils::GetAP_Star(rcBBox) << "f\nQ\n"; |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 1025 | return sAP.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1026 | } |
| 1027 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1028 | CFX_ByteString CPWL_Utils::GetCheckBoxAppStream(const CFX_FloatRect& rcBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1029 | int32_t nStyle, |
| 1030 | const CPWL_Color& crText) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1031 | CFX_FloatRect rcCenter = GetCenterSquare(rcBBox); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1032 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1047 | } |
| 1048 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1049 | CFX_ByteString CPWL_Utils::GetRadioButtonAppStream(const CFX_FloatRect& rcBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1050 | int32_t nStyle, |
| 1051 | const CPWL_Color& crText) { |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1052 | CFX_FloatRect rcCenter = GetCenterSquare(rcBBox); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1053 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1068 | } |
| 1069 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1070 | CFX_ByteString CPWL_Utils::GetDropButtonAppStream(const CFX_FloatRect& rcBBox) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1071 | CFX_ByteTextBuf sAppStream; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1072 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1073 | if (!rcBBox.IsEmpty()) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 1074 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1079 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1083 | |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 1084 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1090 | << "Q\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1091 | |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 1092 | CFX_PointF ptCenter = CFX_PointF((rcBBox.left + rcBBox.right) / 2, |
| 1093 | (rcBBox.top + rcBBox.bottom) / 2); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1094 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1105 | |
tsepez | 71a452f | 2016-05-13 17:51:27 -0700 | [diff] [blame] | 1106 | return sAppStream.MakeString(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1107 | } |
| 1108 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1109 | void 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 Zhang | 375a864 | 2016-01-11 11:59:17 -0800 | [diff] [blame] | 1117 | dGray = 1.0f - std::min(1.0f, 0.3f * dC + 0.59f * dM + 0.11f * dY + dK); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1118 | } |
| 1119 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1120 | void 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1131 | } |
| 1132 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1133 | void 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1142 | } |
| 1143 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1144 | void 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1151 | } |
| 1152 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1153 | void 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 Zhang | 375a864 | 2016-01-11 11:59:17 -0800 | [diff] [blame] | 1163 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1166 | } |
| 1167 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1168 | void 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1177 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1178 | dC = 1.0f - dR; |
| 1179 | dM = 1.0f - dG; |
| 1180 | dY = 1.0f - dB; |
Lei Zhang | 375a864 | 2016-01-11 11:59:17 -0800 | [diff] [blame] | 1181 | dK = std::min(dC, std::min(dM, dY)); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1182 | } |
| 1183 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1184 | void 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1206 | } |
| 1207 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1208 | FX_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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1214 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1215 | PWLColorToARGB(color, nAlpha, dRed, dGreen, dBlue); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1216 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1217 | return ArgbEncode(nAlpha, (int32_t)(dRed * 255), (int32_t)(dGreen * 255), |
| 1218 | (int32_t)(dBlue * 255)); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1219 | } |
| 1220 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1221 | void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 1222 | CFX_Matrix* pUser2Device, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1223 | const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1224 | const FX_COLORREF& color) { |
| 1225 | CFX_PathData path; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1226 | CFX_FloatRect rcTemp(rect); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1227 | path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top); |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1228 | pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_WINDING); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1229 | } |
| 1230 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1231 | void CPWL_Utils::DrawFillArea(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 1232 | CFX_Matrix* pUser2Device, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 1233 | const CFX_PointF* pPts, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1234 | int32_t nCount, |
| 1235 | const FX_COLORREF& color) { |
| 1236 | CFX_PathData path; |
| 1237 | path.SetPointCount(nCount); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1238 | |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1239 | path.SetPoint(0, pPts[0].x, pPts[0].y, FXPT_TYPE::MoveTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1240 | for (int32_t i = 1; i < nCount; i++) |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1241 | path.SetPoint(i, pPts[i].x, pPts[i].y, FXPT_TYPE::LineTo, false); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1242 | |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1243 | pDevice->DrawPath(&path, pUser2Device, nullptr, color, 0, FXFILL_ALTERNATE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1244 | } |
| 1245 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1246 | void CPWL_Utils::DrawStrokeRect(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 1247 | CFX_Matrix* pUser2Device, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1248 | const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1249 | const FX_COLORREF& color, |
| 1250 | FX_FLOAT fWidth) { |
| 1251 | CFX_PathData path; |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1252 | CFX_FloatRect rcTemp(rect); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1253 | path.AppendRect(rcTemp.left, rcTemp.bottom, rcTemp.right, rcTemp.top); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 1254 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1255 | CFX_GraphStateData gsd; |
| 1256 | gsd.m_LineWidth = fWidth; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1257 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1258 | pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1259 | } |
| 1260 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1261 | void CPWL_Utils::DrawStrokeLine(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 1262 | CFX_Matrix* pUser2Device, |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 1263 | const CFX_PointF& ptMoveTo, |
| 1264 | const CFX_PointF& ptLineTo, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1265 | const FX_COLORREF& color, |
| 1266 | FX_FLOAT fWidth) { |
| 1267 | CFX_PathData path; |
| 1268 | path.SetPointCount(2); |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1269 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1271 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1272 | CFX_GraphStateData gsd; |
| 1273 | gsd.m_LineWidth = fWidth; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1274 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1275 | pDevice->DrawPath(&path, pUser2Device, &gsd, 0, color, FXFILL_ALTERNATE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1276 | } |
| 1277 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1278 | void CPWL_Utils::DrawFillRect(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 1279 | CFX_Matrix* pUser2Device, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1280 | const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1281 | const CPWL_Color& color, |
| 1282 | int32_t nTransparancy) { |
| 1283 | CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rect, |
| 1284 | PWLColorToFXColor(color, nTransparancy)); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1285 | } |
| 1286 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1287 | void CPWL_Utils::DrawShadow(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 1288 | CFX_Matrix* pUser2Device, |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 1289 | bool bVertical, |
| 1290 | bool bHorizontal, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1291 | CFX_FloatRect rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1292 | int32_t nTransparancy, |
| 1293 | int32_t nStartGray, |
| 1294 | int32_t nEndGray) { |
| 1295 | FX_FLOAT fStepGray = 1.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1296 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1297 | if (bVertical) { |
| 1298 | fStepGray = (nEndGray - nStartGray) / rect.Height(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1299 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1300 | 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 Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 1303 | pDevice, pUser2Device, CFX_PointF(rect.left, fy), |
| 1304 | CFX_PointF(rect.right, fy), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1305 | ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f); |
| 1306 | } |
| 1307 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1308 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1309 | if (bHorizontal) { |
| 1310 | fStepGray = (nEndGray - nStartGray) / rect.Width(); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1311 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1312 | 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 Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 1315 | pDevice, pUser2Device, CFX_PointF(fx, rect.bottom), |
| 1316 | CFX_PointF(fx, rect.top), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1317 | ArgbEncode(nTransparancy, nGray, nGray, nGray), 1.5f); |
| 1318 | } |
| 1319 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1320 | } |
| 1321 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1322 | void CPWL_Utils::DrawBorder(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 1323 | CFX_Matrix* pUser2Device, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1324 | const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1325 | FX_FLOAT fWidth, |
| 1326 | const CPWL_Color& color, |
| 1327 | const CPWL_Color& crLeftTop, |
| 1328 | const CPWL_Color& crRightBottom, |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 1329 | BorderStyle nStyle, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1330 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1335 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1336 | if (fWidth > 0.0f) { |
| 1337 | FX_FLOAT fHalfWidth = fWidth / 2.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1338 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1339 | switch (nStyle) { |
| 1340 | default: |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 1341 | case BorderStyle::SOLID: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1342 | CFX_PathData path; |
| 1343 | path.AppendRect(fLeft, fBottom, fRight, fTop); |
| 1344 | path.AppendRect(fLeft + fWidth, fBottom + fWidth, fRight - fWidth, |
| 1345 | fTop - fWidth); |
thestig | 1cd352e | 2016-06-07 17:53:06 -0700 | [diff] [blame] | 1346 | pDevice->DrawPath(&path, pUser2Device, nullptr, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1347 | PWLColorToFXColor(color, nTransparancy), 0, |
| 1348 | FXFILL_ALTERNATE); |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 1349 | break; |
| 1350 | } |
| 1351 | case BorderStyle::DASH: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1352 | CFX_PathData path; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1353 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1354 | path.SetPointCount(5); |
| 1355 | path.SetPoint(0, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1356 | FXPT_TYPE::MoveTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1357 | path.SetPoint(1, fLeft + fWidth / 2.0f, fTop - fWidth / 2.0f, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1358 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1359 | path.SetPoint(2, fRight - fWidth / 2.0f, fTop - fWidth / 2.0f, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1360 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1361 | path.SetPoint(3, fRight - fWidth / 2.0f, fBottom + fWidth / 2.0f, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1362 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1363 | path.SetPoint(4, fLeft + fWidth / 2.0f, fBottom + fWidth / 2.0f, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1364 | FXPT_TYPE::LineTo, false); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1365 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1366 | 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 1371 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1372 | gsd.m_LineWidth = fWidth; |
| 1373 | pDevice->DrawPath(&path, pUser2Device, &gsd, 0, |
| 1374 | PWLColorToFXColor(color, nTransparancy), |
| 1375 | FXFILL_WINDING); |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 1376 | break; |
| 1377 | } |
| 1378 | case BorderStyle::BEVELED: |
| 1379 | case BorderStyle::INSET: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1380 | CFX_GraphStateData gsd; |
| 1381 | gsd.m_LineWidth = fHalfWidth; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1382 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1383 | CFX_PathData pathLT; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1384 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1385 | pathLT.SetPointCount(7); |
| 1386 | pathLT.SetPoint(0, fLeft + fHalfWidth, fBottom + fHalfWidth, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1387 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1392 | pathLT.SetPoint(3, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1393 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1394 | pathLT.SetPoint(4, fLeft + fHalfWidth * 2, fTop - fHalfWidth * 2, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1395 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1396 | pathLT.SetPoint(5, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1397 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1398 | pathLT.SetPoint(6, fLeft + fHalfWidth, fBottom + fHalfWidth, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1399 | FXPT_TYPE::LineTo, false); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1400 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1401 | pDevice->DrawPath(&pathLT, pUser2Device, &gsd, |
| 1402 | PWLColorToFXColor(crLeftTop, nTransparancy), 0, |
| 1403 | FXFILL_ALTERNATE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1404 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1405 | CFX_PathData pathRB; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1406 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1407 | pathRB.SetPointCount(7); |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1408 | pathRB.SetPoint(0, fRight - fHalfWidth, fTop - fHalfWidth, |
| 1409 | FXPT_TYPE::MoveTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1410 | pathRB.SetPoint(1, fRight - fHalfWidth, fBottom + fHalfWidth, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1411 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1412 | pathRB.SetPoint(2, fLeft + fHalfWidth, fBottom + fHalfWidth, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1413 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1414 | pathRB.SetPoint(3, fLeft + fHalfWidth * 2, fBottom + fHalfWidth * 2, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1415 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1416 | pathRB.SetPoint(4, fRight - fHalfWidth * 2, fBottom + fHalfWidth * 2, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1417 | FXPT_TYPE::LineTo, false); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1418 | pathRB.SetPoint(5, fRight - fHalfWidth * 2, fTop - fHalfWidth * 2, |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1419 | FXPT_TYPE::LineTo, false); |
| 1420 | pathRB.SetPoint(6, fRight - fHalfWidth, fTop - fHalfWidth, |
| 1421 | FXPT_TYPE::LineTo, false); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1422 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1423 | pDevice->DrawPath(&pathRB, pUser2Device, &gsd, |
| 1424 | PWLColorToFXColor(crRightBottom, nTransparancy), 0, |
| 1425 | FXFILL_ALTERNATE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1426 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1427 | CFX_PathData path; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1428 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1429 | path.AppendRect(fLeft, fBottom, fRight, fTop); |
| 1430 | path.AppendRect(fLeft + fHalfWidth, fBottom + fHalfWidth, |
| 1431 | fRight - fHalfWidth, fTop - fHalfWidth); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1432 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1433 | pDevice->DrawPath(&path, pUser2Device, &gsd, |
| 1434 | PWLColorToFXColor(color, nTransparancy), 0, |
| 1435 | FXFILL_ALTERNATE); |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 1436 | break; |
| 1437 | } |
| 1438 | case BorderStyle::UNDERLINE: { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1439 | CFX_PathData path; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1440 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1441 | path.SetPointCount(2); |
Nicolas Pena | 79365f7 | 2017-02-07 14:21:36 -0500 | [diff] [blame] | 1442 | 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 1445 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1446 | CFX_GraphStateData gsd; |
| 1447 | gsd.m_LineWidth = fWidth; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1448 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1449 | pDevice->DrawPath(&path, pUser2Device, &gsd, 0, |
| 1450 | PWLColorToFXColor(color, nTransparancy), |
| 1451 | FXFILL_ALTERNATE); |
dsinclair | 92cb5e5 | 2016-05-16 11:38:28 -0700 | [diff] [blame] | 1452 | break; |
| 1453 | } |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1454 | } |
| 1455 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1456 | } |
| 1457 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 1458 | bool CPWL_Utils::IsBlackOrWhite(const CPWL_Color& color) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1459 | switch (color.nColorType) { |
| 1460 | case COLORTYPE_TRANSPARENT: |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 1461 | return false; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1462 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1470 | |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 1471 | return true; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1472 | } |
| 1473 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1474 | CPWL_Color CPWL_Utils::GetReverseColor(const CPWL_Color& color) { |
| 1475 | CPWL_Color crRet = color; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1476 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1477 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1493 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1494 | return crRet; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1495 | } |
| 1496 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1497 | CFX_ByteString CPWL_Utils::GetIconAppStream(int32_t nType, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1498 | const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1499 | const CPWL_Color& crFill, |
| 1500 | const CPWL_Color& crStroke) { |
tsepez | 4cf5515 | 2016-11-02 14:37:54 -0700 | [diff] [blame] | 1501 | CFX_ByteString sAppStream = CPWL_Utils::GetColorAppStream(crStroke, false); |
| 1502 | sAppStream += CPWL_Utils::GetColorAppStream(crFill, true); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1503 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1504 | CFX_ByteString sPath; |
| 1505 | CFX_PathData path; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1506 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1507 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1569 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1570 | sAppStream += sPath; |
| 1571 | if (crStroke.nColorType != COLORTYPE_TRANSPARENT) |
| 1572 | sAppStream += "B*\n"; |
| 1573 | else |
| 1574 | sAppStream += "f*\n"; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1575 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1576 | return sAppStream; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1577 | } |
| 1578 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1579 | void CPWL_Utils::DrawIconAppStream(CFX_RenderDevice* pDevice, |
Tom Sepez | 60d909e | 2015-12-10 15:34:55 -0800 | [diff] [blame] | 1580 | CFX_Matrix* pUser2Device, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1581 | int32_t nType, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1582 | const CFX_FloatRect& rect, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1583 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1588 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1589 | CFX_ByteString sPath; |
| 1590 | CFX_PathData path; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1591 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1592 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1656 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1657 | pDevice->DrawPath( |
| 1658 | &path, pUser2Device, &gsd, PWLColorToFXColor(crFill, nTransparancy), |
| 1659 | PWLColorToFXColor(crStroke, nTransparancy), FXFILL_ALTERNATE); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1660 | } |
| 1661 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1662 | void CPWL_Utils::GetGraphics_Checkmark(CFX_ByteString& sPathData, |
| 1663 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1664 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1665 | const PWL_PATH_TYPE type) { |
| 1666 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 1667 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1668 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1669 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1674 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1678 | PWLPT_BEZIERTO), |
| 1679 | CPWL_PathData( |
| 1680 | CPWL_Point(crBBox.left + fWidth / 4.5f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1681 | FX_BEZIER * (fWidth / 5.0f - fWidth / 4.5f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1682 | crBBox.bottom + fHeight / 16.0f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1683 | FX_BEZIER * (fHeight / 5.0f - fHeight / 16.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1684 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1689 | FX_BEZIER * (fWidth / 4.4f - fWidth / 4.5f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1690 | crBBox.bottom + fHeight / 16.0f - |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1691 | FX_BEZIER * fHeight / 16.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1692 | PWLPT_BEZIERTO), |
| 1693 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 3.0f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1694 | FX_BEZIER * (fWidth / 4.0f - fWidth / 3.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1695 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1700 | FX_BEZIER * fWidth * (1 / 7.0f + 2 / 15.0f), |
| 1701 | crBBox.bottom + FX_BEZIER * fHeight * 4 / 5.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1702 | PWLPT_BEZIERTO), |
| 1703 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 14 / 15.0f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1704 | FX_BEZIER * fWidth * (1 / 7.0f - 7 / 15.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1705 | crBBox.bottom + fHeight * 15 / 16.0f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1706 | FX_BEZIER * (fHeight * 4 / 5.0f - |
| 1707 | fHeight * 15 / 16.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1708 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1715 | FX_BEZIER * (fWidth * 7 / 15.0f - fWidth * 14 / 15.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1716 | crBBox.bottom + fHeight * 15 / 16.0f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1717 | FX_BEZIER * (fHeight * 8 / 7.0f - fHeight * 15 / 16.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1718 | PWLPT_BEZIERTO), |
| 1719 | CPWL_PathData( |
| 1720 | CPWL_Point(crBBox.left + fWidth / 3.6f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1721 | FX_BEZIER * (fWidth / 3.4f - fWidth / 3.6f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1722 | crBBox.bottom + fHeight / 3.5f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1723 | FX_BEZIER * (fHeight / 3.5f - fHeight / 3.5f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1724 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1731 | FX_BEZIER * (fHeight / 4.0f - fHeight / 3.5f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1732 | PWLPT_BEZIERTO), |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1733 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1739 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 15.0f, |
| 1740 | crBBox.bottom + fHeight * 2 / 5.0f), |
| 1741 | PWLPT_BEZIERTO)}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1742 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1743 | if (type == PWLPT_STREAM) |
| 1744 | sPathData = GetAppStreamFromArray(PathArray, 16); |
| 1745 | else |
| 1746 | GetPathDataFromArray(path, PathArray, 16); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1747 | } |
| 1748 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1749 | void CPWL_Utils::GetGraphics_Circle(CFX_ByteString& sPathData, |
| 1750 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1751 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1752 | const PWL_PATH_TYPE type) { |
| 1753 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 1754 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1755 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1756 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1763 | FX_BEZIER * (fHeight * 14 / 15.0f - fHeight / 2.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1764 | PWLPT_BEZIERTO), |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1765 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1769 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1774 | FX_BEZIER * (fWidth * 14 / 15.0f - fWidth / 2.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1775 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1780 | FX_BEZIER * (fHeight * 14 / 15.0f - fHeight / 2.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1781 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1788 | FX_BEZIER * (fHeight / 2.0f - fHeight / 15.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1789 | PWLPT_BEZIERTO), |
| 1790 | CPWL_PathData( |
| 1791 | CPWL_Point(crBBox.left + fWidth / 2.0f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1792 | FX_BEZIER * (fWidth * 14 / 15.0f - fWidth / 2.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1793 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1798 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1802 | CPWL_PathData( |
| 1803 | CPWL_Point(crBBox.left + fWidth / 15.0f, |
| 1804 | crBBox.bottom + fHeight / 2.0f - |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1805 | FX_BEZIER * (fHeight / 2.0f - fHeight / 15.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1806 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1816 | FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1817 | PWLPT_BEZIERTO), |
| 1818 | CPWL_PathData( |
| 1819 | CPWL_Point(crBBox.left + fWidth / 2.0f - |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1820 | FX_BEZIER * (fWidth / 2.0f - fWidth * 3 / 15.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1821 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1828 | FX_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1829 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1834 | FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1835 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1842 | FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1843 | PWLPT_BEZIERTO), |
| 1844 | CPWL_PathData( |
| 1845 | CPWL_Point(crBBox.left + fWidth / 2.0f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1846 | FX_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1847 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1854 | FX_BEZIER * (fWidth * 4 / 5.0f - fWidth / 2.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1855 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1860 | FX_BEZIER * (fHeight * 4 / 5.0f - fHeight / 2.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1861 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1865 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1866 | if (type == PWLPT_STREAM) |
| 1867 | sPathData = GetAppStreamFromArray(PathArray, 26); |
| 1868 | else |
| 1869 | GetPathDataFromArray(path, PathArray, 26); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1870 | } |
| 1871 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1872 | void CPWL_Utils::GetGraphics_Comment(CFX_ByteString& sPathData, |
| 1873 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1874 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1875 | const PWL_PATH_TYPE type) { |
| 1876 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 1877 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1878 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1879 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1886 | FX_BEZIER * (fHeight / 6.0f - fHeight / 10.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1887 | PWLPT_BEZIERTO), |
| 1888 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 2 / 15.0f - |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1889 | FX_BEZIER * fWidth / 15.0f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1890 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1899 | FX_BEZIER * fWidth / 15.0f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1900 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1905 | FX_BEZIER * (fHeight / 6.0f - fHeight / 10.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1906 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1915 | FX_BEZIER * fHeight / 15.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1916 | PWLPT_BEZIERTO), |
| 1917 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 2 / 15.0f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1918 | FX_BEZIER * fWidth / 15.0f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1919 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1929 | FX_BEZIER * fHeight * 2 / 15.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1930 | PWLPT_BEZIERTO), |
| 1931 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth * 5 / 15.0f - |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1932 | FX_BEZIER * fWidth * 2 / 15.0f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1933 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1939 | FX_BEZIER * fWidth / 30.0f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1940 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1944 | FX_BEZIER * fHeight * 2 / 15.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1945 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1953 | FX_BEZIER * fWidth / 15.0f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1954 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 1958 | FX_BEZIER * fHeight / 15.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1959 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1984 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1985 | if (type == PWLPT_STREAM) |
| 1986 | sPathData = GetAppStreamFromArray(PathArray, 30); |
| 1987 | else |
| 1988 | GetPathDataFromArray(path, PathArray, 30); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1989 | } |
| 1990 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1991 | void CPWL_Utils::GetGraphics_Cross(CFX_ByteString& sPathData, |
| 1992 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 1993 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1994 | const PWL_PATH_TYPE type) { |
| 1995 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 1996 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 1997 | CPWL_Point center_point(crBBox.left + fWidth / 2, |
| 1998 | crBBox.bottom + fHeight / 2); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 1999 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2000 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2041 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2042 | if (type == PWLPT_STREAM) |
| 2043 | sPathData = GetAppStreamFromArray(PathArray, 13); |
| 2044 | else |
| 2045 | GetPathDataFromArray(path, PathArray, 13); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2046 | } |
| 2047 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2048 | void CPWL_Utils::GetGraphics_Help(CFX_ByteString& sPathData, |
| 2049 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2050 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2051 | const PWL_PATH_TYPE type) { |
| 2052 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2053 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2054 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2055 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2062 | FX_BEZIER * (fHeight / 60.0f - fHeight / 2.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2063 | PWLPT_BEZIERTO), |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2064 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2068 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2072 | FX_BEZIER * fWidth * 29 / 60.0f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2073 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2078 | FX_BEZIER * (fHeight / 60.0f - fHeight / 2.0f)), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2079 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2085 | FX_BEZIER * fHeight * 29 / 60.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2086 | PWLPT_BEZIERTO), |
| 2087 | CPWL_PathData(CPWL_Point(crBBox.left + fWidth / 2.0f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2088 | FX_BEZIER * fWidth * 29 / 60.0f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2089 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2095 | FX_BEZIER * fWidth * 29 / 60.0f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2096 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2100 | FX_BEZIER * fHeight * 29 / 60.0f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2101 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2110 | FX_BEZIER * fHeight * 0.23f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2111 | PWLPT_BEZIERTO), |
| 2112 | CPWL_PathData( |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2113 | CPWL_Point(crBBox.left + fWidth * 0.5f - FX_BEZIER * fWidth * 0.23f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2114 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2120 | CPWL_Point(crBBox.left + fWidth * 0.5f + FX_BEZIER * fWidth * 0.23f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2121 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2125 | FX_BEZIER * fHeight * 0.23f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2126 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2193 | FX_BEZIER * fHeight * 0.13f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2194 | PWLPT_BEZIERTO), |
| 2195 | CPWL_PathData( |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2196 | CPWL_Point(crBBox.left + fWidth * 0.5f + FX_BEZIER * fWidth * 0.13f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2197 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2203 | CPWL_Point(crBBox.left + fWidth * 0.5f - FX_BEZIER * fWidth * 0.13f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2204 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2208 | FX_BEZIER * fHeight * 0.13f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2209 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2229 | FX_BEZIER * fHeight * 0.055f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2230 | PWLPT_BEZIERTO), |
| 2231 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f - |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2232 | FX_BEZIER * fWidth * 0.095f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2233 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2239 | FX_BEZIER * fWidth * 0.065f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2240 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2244 | FX_BEZIER * fHeight * 0.055f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2245 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2251 | FX_BEZIER * fHeight * 0.055f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2252 | PWLPT_BEZIERTO), |
| 2253 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.505f + |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2254 | FX_BEZIER * fWidth * 0.065f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2255 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2261 | FX_BEZIER * fWidth * 0.065f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2262 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2266 | FX_BEZIER * fHeight * 0.055f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2267 | PWLPT_BEZIERTO), |
| 2268 | CPWL_PathData(CPWL_Point(crBBox.right - fWidth * 0.56f, |
| 2269 | crBBox.bottom + fHeight * 0.13f), |
| 2270 | PWLPT_BEZIERTO)}; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2271 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2272 | if (type == PWLPT_STREAM) |
| 2273 | sPathData = GetAppStreamFromArray(PathArray, 59); |
| 2274 | else |
| 2275 | GetPathDataFromArray(path, PathArray, 59); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2276 | } |
| 2277 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2278 | void CPWL_Utils::GetGraphics_InsertText(CFX_ByteString& sPathData, |
| 2279 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2280 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2281 | const PWL_PATH_TYPE type) { |
| 2282 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2283 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2284 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2285 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2298 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2299 | if (type == PWLPT_STREAM) |
| 2300 | sPathData = GetAppStreamFromArray(PathArray, 4); |
| 2301 | else |
| 2302 | GetPathDataFromArray(path, PathArray, 4); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2303 | } |
| 2304 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2305 | void CPWL_Utils::GetGraphics_Key(CFX_ByteString& sPathData, |
| 2306 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2307 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2308 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2318 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2319 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2429 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2430 | if (type == PWLPT_STREAM) |
| 2431 | sPathData = GetAppStreamFromArray(PathArray, 28); |
| 2432 | else |
| 2433 | GetPathDataFromArray(path, PathArray, 28); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2434 | } |
| 2435 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2436 | void CPWL_Utils::GetGraphics_NewParagraph(CFX_ByteString& sPathData, |
| 2437 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2438 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2439 | const PWL_PATH_TYPE type) { |
| 2440 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2441 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2442 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2443 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2533 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2534 | if (type == PWLPT_STREAM) |
| 2535 | sPathData = GetAppStreamFromArray(PathArray, 28); |
| 2536 | else |
| 2537 | GetPathDataFromArray(path, PathArray, 28); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2538 | } |
| 2539 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2540 | void CPWL_Utils::GetGraphics_TextNote(CFX_ByteString& sPathData, |
| 2541 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2542 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2543 | const PWL_PATH_TYPE type) { |
| 2544 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2545 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2546 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2547 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2599 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2600 | if (type == PWLPT_STREAM) |
| 2601 | sPathData = GetAppStreamFromArray(PathArray, 17); |
| 2602 | else |
| 2603 | GetPathDataFromArray(path, PathArray, 17); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2604 | } |
| 2605 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2606 | void CPWL_Utils::GetGraphics_Paragraph(CFX_ByteString& sPathData, |
| 2607 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2608 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2609 | const PWL_PATH_TYPE type) { |
| 2610 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2611 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2612 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2613 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2650 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2651 | if (type == PWLPT_STREAM) |
| 2652 | sPathData = GetAppStreamFromArray(PathArray, 12); |
| 2653 | else |
| 2654 | GetPathDataFromArray(path, PathArray, 12); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2655 | } |
| 2656 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2657 | void CPWL_Utils::GetGraphics_RightArrow(CFX_ByteString& sPathData, |
| 2658 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2659 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2660 | const PWL_PATH_TYPE type) { |
| 2661 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2662 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2663 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2664 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2695 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2696 | if (type == PWLPT_STREAM) |
| 2697 | sPathData = GetAppStreamFromArray(PathArray, 10); |
| 2698 | else |
| 2699 | GetPathDataFromArray(path, PathArray, 10); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2700 | } |
| 2701 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2702 | void CPWL_Utils::GetGraphics_RightPointer(CFX_ByteString& sPathData, |
| 2703 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2704 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2705 | const PWL_PATH_TYPE type) { |
| 2706 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2707 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2708 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2709 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2725 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2726 | if (type == PWLPT_STREAM) |
| 2727 | sPathData = GetAppStreamFromArray(PathArray, 5); |
| 2728 | else |
| 2729 | GetPathDataFromArray(path, PathArray, 5); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2730 | } |
| 2731 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2732 | void CPWL_Utils::GetGraphics_Star(CFX_ByteString& sPathData, |
| 2733 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2734 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2735 | const PWL_PATH_TYPE type) { |
| 2736 | FX_FLOAT fLongRadius = |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2737 | (crBBox.top - crBBox.bottom) / (1 + (FX_FLOAT)cos(FX_PI / 5.0f)); |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2738 | fLongRadius = fLongRadius * 0.7f; |
| 2739 | FX_FLOAT fShortRadius = fLongRadius * 0.55f; |
Dan Sinclair | f528eee | 2017-02-14 11:52:07 -0500 | [diff] [blame^] | 2740 | CFX_PointF ptCenter = CFX_PointF((crBBox.left + crBBox.right) / 2.0f, |
| 2741 | (crBBox.top + crBBox.bottom) / 2.0f); |
Lei Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 2742 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2743 | FX_FLOAT px1[5], py1[5]; |
| 2744 | FX_FLOAT px2[5], py2[5]; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2745 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2746 | FX_FLOAT fAngel = FX_PI / 10.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2747 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2748 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2751 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2752 | fAngel += FX_PI * 2 / 5.0f; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2753 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2754 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2755 | fAngel = FX_PI / 5.0f + FX_PI / 10.0f; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2756 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2757 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2760 | |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 2761 | fAngel += FX_PI * 2 / 5.0f; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2762 | } |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2763 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2764 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2767 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2768 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2774 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2775 | PathArray[10] = CPWL_PathData(CPWL_Point(px1[0], py1[0]), PWLPT_LINETO); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2776 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2777 | if (type == PWLPT_STREAM) |
| 2778 | sPathData = GetAppStreamFromArray(PathArray, 11); |
| 2779 | else |
| 2780 | GetPathDataFromArray(path, PathArray, 11); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2781 | } |
| 2782 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2783 | void CPWL_Utils::GetGraphics_UpArrow(CFX_ByteString& sPathData, |
| 2784 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2785 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2786 | const PWL_PATH_TYPE type) { |
| 2787 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2788 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2789 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2790 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2815 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2816 | if (type == PWLPT_STREAM) |
| 2817 | sPathData = GetAppStreamFromArray(PathArray, 8); |
| 2818 | else |
| 2819 | GetPathDataFromArray(path, PathArray, 8); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2820 | } |
| 2821 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2822 | void CPWL_Utils::GetGraphics_UpLeftArrow(CFX_ByteString& sPathData, |
| 2823 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2824 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2825 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2834 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2835 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2870 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2871 | if (type == PWLPT_STREAM) |
| 2872 | sPathData = GetAppStreamFromArray(PathArray, 8); |
| 2873 | else |
| 2874 | GetPathDataFromArray(path, PathArray, 8); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2875 | } |
| 2876 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2877 | void CPWL_Utils::GetGraphics_Graph(CFX_ByteString& sPathData, |
| 2878 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2879 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2880 | const PWL_PATH_TYPE type) { |
| 2881 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2882 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2883 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2884 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2900 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2901 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2916 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2917 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2932 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2933 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2948 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2949 | if (type == PWLPT_STREAM) |
| 2950 | sPathData = GetAppStreamFromArray(PathArray, 20); |
| 2951 | else |
| 2952 | GetPathDataFromArray(path, PathArray, 20); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2953 | } |
| 2954 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2955 | void CPWL_Utils::GetGraphics_Paperclip(CFX_ByteString& sPathData, |
| 2956 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 2957 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2958 | const PWL_PATH_TYPE type) { |
| 2959 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 2960 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2961 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2962 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 2980 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2981 | 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 Zhang | a6d9f0e | 2015-06-13 00:48:38 -0700 | [diff] [blame] | 2995 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 2996 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3012 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3013 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3029 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3030 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3046 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3047 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3061 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3062 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3076 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3077 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3091 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3092 | if (type == PWLPT_STREAM) |
| 3093 | sPathData = GetAppStreamFromArray(PathArray, 33); |
| 3094 | else |
| 3095 | GetPathDataFromArray(path, PathArray, 33); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3096 | } |
| 3097 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3098 | void CPWL_Utils::GetGraphics_Attachment(CFX_ByteString& sPathData, |
| 3099 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 3100 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3101 | const PWL_PATH_TYPE type) { |
| 3102 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 3103 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3104 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3105 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3124 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3125 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3140 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3141 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3155 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3156 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3170 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3171 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3180 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3181 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3187 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3188 | if (type == PWLPT_STREAM) |
| 3189 | sPathData = GetAppStreamFromArray(PathArray, 24); |
| 3190 | else |
| 3191 | GetPathDataFromArray(path, PathArray, 24); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3192 | } |
| 3193 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3194 | void CPWL_Utils::GetGraphics_Tag(CFX_ByteString& sPathData, |
| 3195 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 3196 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3197 | const PWL_PATH_TYPE type) { |
| 3198 | FX_FLOAT fWidth = crBBox.right - crBBox.left; |
| 3199 | FX_FLOAT fHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3200 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3201 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3238 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3239 | if (type == PWLPT_STREAM) |
| 3240 | sPathData = GetAppStreamFromArray(PathArray, 12); |
| 3241 | else |
| 3242 | GetPathDataFromArray(path, PathArray, 12); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3243 | } |
| 3244 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3245 | void CPWL_Utils::GetGraphics_Foxit(CFX_ByteString& sPathData, |
| 3246 | CFX_PathData& path, |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 3247 | const CFX_FloatRect& crBBox, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3248 | const PWL_PATH_TYPE type) { |
| 3249 | FX_FLOAT fOutWidth = crBBox.right - crBBox.left; |
| 3250 | FX_FLOAT fOutHeight = crBBox.top - crBBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3251 | |
Tom Sepez | 281a9ea | 2016-02-26 14:24:28 -0800 | [diff] [blame] | 3252 | CFX_FloatRect crInBox = crBBox; |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3253 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3257 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3258 | FX_FLOAT fWidth = crInBox.right - crInBox.left; |
| 3259 | FX_FLOAT fHeight = crInBox.top - crInBox.bottom; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3260 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3261 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 3266 | crInBox.top - FX_BEZIER * fHeight * 0.4f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3267 | PWLPT_BEZIERTO), |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 3268 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3272 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3275 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3276 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 3281 | crInBox.top - FX_BEZIER * fHeight * 0.7f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3282 | PWLPT_BEZIERTO), |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 3283 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3287 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 3291 | CPWL_PathData(CPWL_Point(crInBox.left + FX_BEZIER * fWidth * 0.60f, |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3292 | crInBox.top - fHeight * 0.55f), |
| 3293 | PWLPT_BEZIERTO), |
| 3294 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 3295 | crInBox.top - FX_BEZIER * fHeight * 0.55f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3296 | PWLPT_BEZIERTO), |
| 3297 | CPWL_PathData(CPWL_Point(crInBox.left + fWidth * 0.60f, crInBox.top), |
| 3298 | PWLPT_BEZIERTO), |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3299 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3300 | 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 Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 3303 | crInBox.top - FX_BEZIER * fHeight * 0.85f), |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3304 | PWLPT_BEZIERTO), |
Tom Sepez | a30b7e8 | 2016-02-12 15:58:50 -0800 | [diff] [blame] | 3305 | 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 Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3309 | 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-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3317 | |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3318 | if (type == PWLPT_STREAM) |
| 3319 | sPathData = GetAppStreamFromArray(PathArray, 23); |
| 3320 | else |
| 3321 | GetPathDataFromArray(path, PathArray, 23); |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3322 | } |
| 3323 | |
jaepark | cba85ab | 2016-09-08 18:09:59 -0700 | [diff] [blame] | 3324 | void CPWL_Color::ConvertColorType(int32_t nConvertColorType) { |
| 3325 | if (nColorType == nConvertColorType) |
| 3326 | return; |
| 3327 | |
| 3328 | switch (nColorType) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3329 | case COLORTYPE_TRANSPARENT: |
| 3330 | break; |
| 3331 | case COLORTYPE_GRAY: |
jaepark | cba85ab | 2016-09-08 18:09:59 -0700 | [diff] [blame] | 3332 | switch (nConvertColorType) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3333 | 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: |
jaepark | cba85ab | 2016-09-08 18:09:59 -0700 | [diff] [blame] | 3343 | switch (nConvertColorType) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3344 | 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: |
jaepark | cba85ab | 2016-09-08 18:09:59 -0700 | [diff] [blame] | 3354 | switch (nConvertColorType) { |
Nico Weber | 9d8ec5a | 2015-08-04 13:00:21 -0700 | [diff] [blame] | 3355 | 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 | } |
jaepark | cba85ab | 2016-09-08 18:09:59 -0700 | [diff] [blame] | 3366 | nColorType = nConvertColorType; |
John Abd-El-Malek | 3f3b45c | 2014-05-23 17:28:10 -0700 | [diff] [blame] | 3367 | } |