Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [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. |
| 4 | |
| 5 | // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | |
| 7 | #include "xfa/fde/fde_gedevice.h" |
| 8 | |
| 9 | #include <algorithm> |
| 10 | |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 11 | #include "xfa/fde/cfde_path.h" |
dsinclair | 25c223d | 2016-04-12 09:51:45 -0700 | [diff] [blame] | 12 | #include "xfa/fde/fde_object.h" |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 13 | #include "xfa/fgas/font/fgas_font.h" |
thestig | a4fdfc5 | 2016-06-07 17:33:37 -0700 | [diff] [blame^] | 14 | #include "xfa/fgas/font/fgas_gefont.h" |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 15 | |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 16 | CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice, |
| 17 | FX_BOOL bOwnerDevice) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 18 | : m_pDevice(pDevice), |
| 19 | m_bOwnerDevice(bOwnerDevice), |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 20 | m_pCharPos(nullptr), |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 21 | m_iCharCount(0) { |
dsinclair | 43854a5 | 2016-04-27 12:26:00 -0700 | [diff] [blame] | 22 | ASSERT(pDevice); |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 23 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 24 | FX_RECT rt = m_pDevice->GetClipBox(); |
| 25 | m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), |
| 26 | (FX_FLOAT)rt.Height()); |
| 27 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 28 | |
| 29 | CFDE_RenderDevice::~CFDE_RenderDevice() { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 30 | FX_Free(m_pCharPos); |
| 31 | if (m_bOwnerDevice) |
| 32 | delete m_pDevice; |
| 33 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 34 | int32_t CFDE_RenderDevice::GetWidth() const { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 35 | return m_pDevice->GetWidth(); |
| 36 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 37 | int32_t CFDE_RenderDevice::GetHeight() const { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 38 | return m_pDevice->GetHeight(); |
| 39 | } |
dsinclair | fe433f1 | 2016-06-06 12:03:31 -0700 | [diff] [blame] | 40 | void CFDE_RenderDevice::SaveState() { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 41 | m_pDevice->SaveState(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 42 | } |
dsinclair | fe433f1 | 2016-06-06 12:03:31 -0700 | [diff] [blame] | 43 | void CFDE_RenderDevice::RestoreState() { |
thestig | 41846a0 | 2016-05-26 10:45:30 -0700 | [diff] [blame] | 44 | m_pDevice->RestoreState(false); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 45 | const FX_RECT& rt = m_pDevice->GetClipBox(); |
| 46 | m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), |
| 47 | (FX_FLOAT)rt.Height()); |
| 48 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 49 | FX_BOOL CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 50 | m_rtClip = rtClip; |
| 51 | return m_pDevice->SetClip_Rect(FX_RECT((int32_t)FXSYS_floor(rtClip.left), |
| 52 | (int32_t)FXSYS_floor(rtClip.top), |
| 53 | (int32_t)FXSYS_ceil(rtClip.right()), |
| 54 | (int32_t)FXSYS_ceil(rtClip.bottom()))); |
| 55 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 56 | const CFX_RectF& CFDE_RenderDevice::GetClipRect() { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 57 | return m_rtClip; |
| 58 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 59 | FX_BOOL CFDE_RenderDevice::SetClipPath(const CFDE_Path* pClip) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 60 | return FALSE; |
| 61 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 62 | CFDE_Path* CFDE_RenderDevice::GetClipPath() const { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 63 | return NULL; |
| 64 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 65 | FX_FLOAT CFDE_RenderDevice::GetDpiX() const { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 66 | return 96; |
| 67 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 68 | FX_FLOAT CFDE_RenderDevice::GetDpiY() const { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 69 | return 96; |
| 70 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 71 | FX_BOOL CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib, |
| 72 | const CFX_RectF* pSrcRect, |
| 73 | const CFX_RectF& dstRect, |
| 74 | const CFX_Matrix* pImgMatrix, |
| 75 | const CFX_Matrix* pDevMatrix) { |
dsinclair | 43854a5 | 2016-04-27 12:26:00 -0700 | [diff] [blame] | 76 | ASSERT(pDib != NULL); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 77 | CFX_RectF srcRect; |
| 78 | if (pSrcRect) { |
| 79 | srcRect = *pSrcRect; |
| 80 | } else { |
| 81 | srcRect.Set(0, 0, (FX_FLOAT)pDib->GetWidth(), (FX_FLOAT)pDib->GetHeight()); |
| 82 | } |
| 83 | if (srcRect.IsEmpty()) { |
| 84 | return FALSE; |
| 85 | } |
| 86 | CFX_Matrix dib2fxdev; |
| 87 | if (pImgMatrix) { |
| 88 | dib2fxdev = *pImgMatrix; |
| 89 | } else { |
| 90 | dib2fxdev.SetIdentity(); |
| 91 | } |
| 92 | dib2fxdev.a = dstRect.width; |
| 93 | dib2fxdev.d = -dstRect.height; |
| 94 | dib2fxdev.e = dstRect.left; |
| 95 | dib2fxdev.f = dstRect.bottom(); |
| 96 | if (pDevMatrix) { |
| 97 | dib2fxdev.Concat(*pDevMatrix); |
| 98 | } |
| 99 | void* handle = NULL; |
| 100 | m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0, |
| 101 | handle); |
| 102 | while (m_pDevice->ContinueDIBits(handle, NULL)) { |
| 103 | } |
| 104 | m_pDevice->CancelDIBits(handle); |
| 105 | return handle != NULL; |
| 106 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 107 | FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, |
thestig | a4fdfc5 | 2016-06-07 17:33:37 -0700 | [diff] [blame^] | 108 | CFGAS_GEFont* pFont, |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 109 | const FXTEXT_CHARPOS* pCharPos, |
| 110 | int32_t iCount, |
| 111 | FX_FLOAT fFontSize, |
| 112 | const CFX_Matrix* pMatrix) { |
tsepez | 48ddd86 | 2016-06-06 10:51:58 -0700 | [diff] [blame] | 113 | ASSERT(pBrush && pFont && pCharPos && iCount > 0); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 114 | CFX_FontCache* pCache = CFX_GEModule::Get()->GetFontCache(); |
tsepez | 48ddd86 | 2016-06-06 10:51:58 -0700 | [diff] [blame] | 115 | CFX_Font* pFxFont = pFont->GetDevFont(); |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 116 | FX_ARGB argb = pBrush->GetColor(); |
| 117 | if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && |
| 118 | !pFxFont->IsItalic()) { |
| 119 | FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; |
| 120 | FX_FLOAT* pAM; |
| 121 | for (int32_t i = 0; i < iCount; ++i) { |
| 122 | static const FX_FLOAT mc = 0.267949f; |
| 123 | pAM = pCP->m_AdjustMatrix; |
| 124 | pAM[2] = mc * pAM[0] + pAM[2]; |
| 125 | pAM[3] = mc * pAM[1] + pAM[3]; |
| 126 | pCP++; |
| 127 | } |
| 128 | } |
| 129 | FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; |
thestig | a4fdfc5 | 2016-06-07 17:33:37 -0700 | [diff] [blame^] | 130 | CFGAS_GEFont* pCurFont = NULL; |
| 131 | CFGAS_GEFont* pSTFont = NULL; |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 132 | FXTEXT_CHARPOS* pCurCP = NULL; |
| 133 | int32_t iCurCount = 0; |
| 134 | |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 135 | #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 136 | uint32_t dwFontStyle = pFont->GetFontStyles(); |
| 137 | CFX_Font FxFont; |
| 138 | CFX_SubstFont SubstFxFont; |
| 139 | FxFont.SetSubstFont(&SubstFxFont); |
| 140 | SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 400; |
| 141 | SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; |
| 142 | SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ? -12 : 0; |
| 143 | SubstFxFont.m_bItlicCJK = !!(dwFontStyle & FX_FONTSTYLE_Italic); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 144 | #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 145 | |
| 146 | for (int32_t i = 0; i < iCount; ++i) { |
| 147 | pSTFont = pFont->GetSubstFont((int32_t)pCP->m_GlyphIndex); |
| 148 | pCP->m_GlyphIndex &= 0x00FFFFFF; |
| 149 | pCP->m_bFontStyle = FALSE; |
| 150 | if (pCurFont != pSTFont) { |
tsepez | 48ddd86 | 2016-06-06 10:51:58 -0700 | [diff] [blame] | 151 | if (pCurFont) { |
| 152 | pFxFont = pCurFont->GetDevFont(); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 153 | #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 154 | FxFont.SetFace(pFxFont->GetFace()); |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 155 | m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont, pCache, |
| 156 | -fFontSize, (const CFX_Matrix*)pMatrix, argb, |
| 157 | FXTEXT_CLEARTYPE); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 158 | #else |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 159 | m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, |
| 160 | -fFontSize, (const CFX_Matrix*)pMatrix, argb, |
| 161 | FXTEXT_CLEARTYPE); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 162 | #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 163 | } |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 164 | pCurFont = pSTFont; |
| 165 | pCurCP = pCP; |
| 166 | iCurCount = 1; |
| 167 | } else { |
| 168 | iCurCount++; |
| 169 | } |
| 170 | pCP++; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 171 | } |
tsepez | 48ddd86 | 2016-06-06 10:51:58 -0700 | [diff] [blame] | 172 | if (pCurFont && iCurCount) { |
| 173 | pFxFont = pCurFont->GetDevFont(); |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 174 | #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 175 | FxFont.SetFace(pFxFont->GetFace()); |
| 176 | FX_BOOL bRet = m_pDevice->DrawNormalText( |
| 177 | iCurCount, pCurCP, &FxFont, pCache, -fFontSize, |
| 178 | (const CFX_Matrix*)pMatrix, argb, FXTEXT_CLEARTYPE); |
| 179 | FxFont.SetSubstFont(nullptr); |
| 180 | FxFont.SetFace(nullptr); |
| 181 | return bRet; |
| 182 | #else |
| 183 | return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, pCache, |
| 184 | -fFontSize, (const CFX_Matrix*)pMatrix, |
| 185 | argb, FXTEXT_CLEARTYPE); |
| 186 | #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 187 | } |
| 188 | |
| 189 | #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 190 | FxFont.SetSubstFont(nullptr); |
| 191 | FxFont.SetFace(nullptr); |
| 192 | #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 193 | |
| 194 | return TRUE; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 195 | } |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 196 | |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 197 | FX_BOOL CFDE_RenderDevice::DrawBezier(CFDE_Pen* pPen, |
| 198 | FX_FLOAT fPenWidth, |
| 199 | const CFX_PointF& pt1, |
| 200 | const CFX_PointF& pt2, |
| 201 | const CFX_PointF& pt3, |
| 202 | const CFX_PointF& pt4, |
| 203 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 204 | CFX_PointsF points; |
| 205 | points.Add(pt1); |
| 206 | points.Add(pt2); |
| 207 | points.Add(pt3); |
| 208 | points.Add(pt4); |
| 209 | CFDE_Path path; |
| 210 | path.AddBezier(points); |
| 211 | return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 212 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 213 | FX_BOOL CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen, |
| 214 | FX_FLOAT fPenWidth, |
| 215 | const CFX_PointsF& points, |
| 216 | FX_BOOL bClosed, |
| 217 | FX_FLOAT fTension, |
| 218 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 219 | CFDE_Path path; |
| 220 | path.AddCurve(points, bClosed, fTension); |
| 221 | return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 222 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 223 | FX_BOOL CFDE_RenderDevice::DrawEllipse(CFDE_Pen* pPen, |
| 224 | FX_FLOAT fPenWidth, |
| 225 | const CFX_RectF& rect, |
| 226 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 227 | CFDE_Path path; |
| 228 | path.AddEllipse(rect); |
| 229 | return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 230 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 231 | FX_BOOL CFDE_RenderDevice::DrawLines(CFDE_Pen* pPen, |
| 232 | FX_FLOAT fPenWidth, |
| 233 | const CFX_PointsF& points, |
| 234 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 235 | CFDE_Path path; |
| 236 | path.AddLines(points); |
| 237 | return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 238 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 239 | FX_BOOL CFDE_RenderDevice::DrawLine(CFDE_Pen* pPen, |
| 240 | FX_FLOAT fPenWidth, |
| 241 | const CFX_PointF& pt1, |
| 242 | const CFX_PointF& pt2, |
| 243 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 244 | CFDE_Path path; |
| 245 | path.AddLine(pt1, pt2); |
| 246 | return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 247 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 248 | FX_BOOL CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen, |
| 249 | FX_FLOAT fPenWidth, |
| 250 | const CFDE_Path* pPath, |
| 251 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 252 | CFDE_Path* pGePath = (CFDE_Path*)pPath; |
| 253 | if (pGePath == NULL) { |
| 254 | return FALSE; |
| 255 | } |
| 256 | CFX_GraphStateData graphState; |
| 257 | if (!CreatePen(pPen, fPenWidth, graphState)) { |
| 258 | return FALSE; |
| 259 | } |
| 260 | return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix, |
| 261 | &graphState, 0, pPen->GetColor(), 0); |
| 262 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 263 | FX_BOOL CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen, |
| 264 | FX_FLOAT fPenWidth, |
| 265 | const CFX_PointsF& points, |
| 266 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 267 | CFDE_Path path; |
| 268 | path.AddPolygon(points); |
| 269 | return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 270 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 271 | FX_BOOL CFDE_RenderDevice::DrawRectangle(CFDE_Pen* pPen, |
| 272 | FX_FLOAT fPenWidth, |
| 273 | const CFX_RectF& rect, |
| 274 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 275 | CFDE_Path path; |
| 276 | path.AddRectangle(rect); |
| 277 | return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 278 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 279 | FX_BOOL CFDE_RenderDevice::FillClosedCurve(CFDE_Brush* pBrush, |
| 280 | const CFX_PointsF& points, |
| 281 | FX_FLOAT fTension, |
| 282 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 283 | CFDE_Path path; |
| 284 | path.AddCurve(points, TRUE, fTension); |
| 285 | return FillPath(pBrush, &path, pMatrix); |
| 286 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 287 | FX_BOOL CFDE_RenderDevice::FillEllipse(CFDE_Brush* pBrush, |
| 288 | const CFX_RectF& rect, |
| 289 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 290 | CFDE_Path path; |
| 291 | path.AddEllipse(rect); |
| 292 | return FillPath(pBrush, &path, pMatrix); |
| 293 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 294 | FX_BOOL CFDE_RenderDevice::FillPolygon(CFDE_Brush* pBrush, |
| 295 | const CFX_PointsF& points, |
| 296 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 297 | CFDE_Path path; |
| 298 | path.AddPolygon(points); |
| 299 | return FillPath(pBrush, &path, pMatrix); |
| 300 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 301 | FX_BOOL CFDE_RenderDevice::FillRectangle(CFDE_Brush* pBrush, |
| 302 | const CFX_RectF& rect, |
| 303 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 304 | CFDE_Path path; |
| 305 | path.AddRectangle(rect); |
| 306 | return FillPath(pBrush, &path, pMatrix); |
| 307 | } |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 308 | FX_BOOL CFDE_RenderDevice::CreatePen(CFDE_Pen* pPen, |
| 309 | FX_FLOAT fPenWidth, |
| 310 | CFX_GraphStateData& graphState) { |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 311 | if (!pPen) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 312 | return FALSE; |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 313 | |
| 314 | graphState.m_LineCap = CFX_GraphStateData::LineCapButt; |
| 315 | graphState.m_LineJoin = CFX_GraphStateData::LineJoinMiter; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 316 | graphState.m_LineWidth = fPenWidth; |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 317 | graphState.m_MiterLimit = 10; |
| 318 | graphState.m_DashPhase = 0; |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 319 | return TRUE; |
| 320 | } |
dsinclair | 25c223d | 2016-04-12 09:51:45 -0700 | [diff] [blame] | 321 | |
dsinclair | acd0d59 | 2016-04-21 11:06:27 -0700 | [diff] [blame] | 322 | FX_BOOL CFDE_RenderDevice::FillPath(CFDE_Brush* pBrush, |
| 323 | const CFDE_Path* pPath, |
| 324 | const CFX_Matrix* pMatrix) { |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 325 | CFDE_Path* pGePath = (CFDE_Path*)pPath; |
dsinclair | 25c223d | 2016-04-12 09:51:45 -0700 | [diff] [blame] | 326 | if (!pGePath) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 327 | return FALSE; |
dsinclair | 25c223d | 2016-04-12 09:51:45 -0700 | [diff] [blame] | 328 | if (!pBrush) |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 329 | return FALSE; |
dsinclair | a5c1323 | 2016-04-12 13:19:36 -0700 | [diff] [blame] | 330 | return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, |
| 331 | pBrush->GetColor(), 0, FXFILL_WINDING); |
Dan Sinclair | 1770c02 | 2016-03-14 14:14:16 -0400 | [diff] [blame] | 332 | } |
dsinclair | 25c223d | 2016-04-12 09:51:45 -0700 | [diff] [blame] | 333 | |