| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fde/fde_gedevice.h" | 7 #include "xfa/fde/fde_gedevice.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| 11 #include "core/fxge/cfx_gemodule.h" | 11 #include "core/fxge/cfx_gemodule.h" |
| 12 #include "core/fxge/cfx_graphstatedata.h" | 12 #include "core/fxge/cfx_graphstatedata.h" |
| 13 #include "core/fxge/cfx_renderdevice.h" | 13 #include "core/fxge/cfx_renderdevice.h" |
| 14 #include "core/fxge/cfx_substfont.h" | 14 #include "core/fxge/cfx_substfont.h" |
| 15 #include "xfa/fde/cfde_path.h" | 15 #include "xfa/fde/cfde_path.h" |
| 16 #include "xfa/fde/fde_object.h" | 16 #include "xfa/fde/fde_object.h" |
| 17 #include "xfa/fgas/font/fgas_font.h" | 17 #include "xfa/fgas/font/fgas_font.h" |
| 18 #include "xfa/fgas/font/fgas_gefont.h" | 18 #include "xfa/fgas/font/fgas_gefont.h" |
| 19 | 19 |
| 20 CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice, | 20 CFDE_RenderDevice::CFDE_RenderDevice(CFX_RenderDevice* pDevice, |
| 21 FX_BOOL bOwnerDevice) | 21 bool bOwnerDevice) |
| 22 : m_pDevice(pDevice), | 22 : m_pDevice(pDevice), m_bOwnerDevice(bOwnerDevice), m_iCharCount(0) { |
| 23 m_bOwnerDevice(bOwnerDevice), | |
| 24 m_iCharCount(0) { | |
| 25 ASSERT(pDevice); | 23 ASSERT(pDevice); |
| 26 | 24 |
| 27 FX_RECT rt = m_pDevice->GetClipBox(); | 25 FX_RECT rt = m_pDevice->GetClipBox(); |
| 28 m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), | 26 m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), |
| 29 (FX_FLOAT)rt.Height()); | 27 (FX_FLOAT)rt.Height()); |
| 30 } | 28 } |
| 31 | 29 |
| 32 CFDE_RenderDevice::~CFDE_RenderDevice() { | 30 CFDE_RenderDevice::~CFDE_RenderDevice() { |
| 33 if (m_bOwnerDevice) | 31 if (m_bOwnerDevice) |
| 34 delete m_pDevice; | 32 delete m_pDevice; |
| 35 } | 33 } |
| 36 int32_t CFDE_RenderDevice::GetWidth() const { | 34 int32_t CFDE_RenderDevice::GetWidth() const { |
| 37 return m_pDevice->GetWidth(); | 35 return m_pDevice->GetWidth(); |
| 38 } | 36 } |
| 39 int32_t CFDE_RenderDevice::GetHeight() const { | 37 int32_t CFDE_RenderDevice::GetHeight() const { |
| 40 return m_pDevice->GetHeight(); | 38 return m_pDevice->GetHeight(); |
| 41 } | 39 } |
| 42 void CFDE_RenderDevice::SaveState() { | 40 void CFDE_RenderDevice::SaveState() { |
| 43 m_pDevice->SaveState(); | 41 m_pDevice->SaveState(); |
| 44 } | 42 } |
| 45 void CFDE_RenderDevice::RestoreState() { | 43 void CFDE_RenderDevice::RestoreState() { |
| 46 m_pDevice->RestoreState(false); | 44 m_pDevice->RestoreState(false); |
| 47 const FX_RECT& rt = m_pDevice->GetClipBox(); | 45 const FX_RECT& rt = m_pDevice->GetClipBox(); |
| 48 m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), | 46 m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), |
| 49 (FX_FLOAT)rt.Height()); | 47 (FX_FLOAT)rt.Height()); |
| 50 } | 48 } |
| 51 FX_BOOL CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) { | 49 bool CFDE_RenderDevice::SetClipRect(const CFX_RectF& rtClip) { |
| 52 m_rtClip = rtClip; | 50 m_rtClip = rtClip; |
| 53 return m_pDevice->SetClip_Rect(FX_RECT((int32_t)FXSYS_floor(rtClip.left), | 51 return m_pDevice->SetClip_Rect(FX_RECT((int32_t)FXSYS_floor(rtClip.left), |
| 54 (int32_t)FXSYS_floor(rtClip.top), | 52 (int32_t)FXSYS_floor(rtClip.top), |
| 55 (int32_t)FXSYS_ceil(rtClip.right()), | 53 (int32_t)FXSYS_ceil(rtClip.right()), |
| 56 (int32_t)FXSYS_ceil(rtClip.bottom()))); | 54 (int32_t)FXSYS_ceil(rtClip.bottom()))); |
| 57 } | 55 } |
| 58 const CFX_RectF& CFDE_RenderDevice::GetClipRect() { | 56 const CFX_RectF& CFDE_RenderDevice::GetClipRect() { |
| 59 return m_rtClip; | 57 return m_rtClip; |
| 60 } | 58 } |
| 61 FX_BOOL CFDE_RenderDevice::SetClipPath(const CFDE_Path* pClip) { | 59 bool CFDE_RenderDevice::SetClipPath(const CFDE_Path* pClip) { |
| 62 return FALSE; | 60 return false; |
| 63 } | 61 } |
| 64 CFDE_Path* CFDE_RenderDevice::GetClipPath() const { | 62 CFDE_Path* CFDE_RenderDevice::GetClipPath() const { |
| 65 return nullptr; | 63 return nullptr; |
| 66 } | 64 } |
| 67 FX_FLOAT CFDE_RenderDevice::GetDpiX() const { | 65 FX_FLOAT CFDE_RenderDevice::GetDpiX() const { |
| 68 return 96; | 66 return 96; |
| 69 } | 67 } |
| 70 FX_FLOAT CFDE_RenderDevice::GetDpiY() const { | 68 FX_FLOAT CFDE_RenderDevice::GetDpiY() const { |
| 71 return 96; | 69 return 96; |
| 72 } | 70 } |
| 73 FX_BOOL CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib, | 71 bool CFDE_RenderDevice::DrawImage(CFX_DIBSource* pDib, |
| 74 const CFX_RectF* pSrcRect, | 72 const CFX_RectF* pSrcRect, |
| 75 const CFX_RectF& dstRect, | 73 const CFX_RectF& dstRect, |
| 76 const CFX_Matrix* pImgMatrix, | 74 const CFX_Matrix* pImgMatrix, |
| 77 const CFX_Matrix* pDevMatrix) { | 75 const CFX_Matrix* pDevMatrix) { |
| 78 CFX_RectF srcRect; | 76 CFX_RectF srcRect; |
| 79 if (pSrcRect) { | 77 if (pSrcRect) { |
| 80 srcRect = *pSrcRect; | 78 srcRect = *pSrcRect; |
| 81 } else { | 79 } else { |
| 82 srcRect.Set(0, 0, (FX_FLOAT)pDib->GetWidth(), (FX_FLOAT)pDib->GetHeight()); | 80 srcRect.Set(0, 0, (FX_FLOAT)pDib->GetWidth(), (FX_FLOAT)pDib->GetHeight()); |
| 83 } | 81 } |
| 84 if (srcRect.IsEmpty()) { | 82 if (srcRect.IsEmpty()) { |
| 85 return FALSE; | 83 return false; |
| 86 } | 84 } |
| 87 CFX_Matrix dib2fxdev; | 85 CFX_Matrix dib2fxdev; |
| 88 if (pImgMatrix) { | 86 if (pImgMatrix) { |
| 89 dib2fxdev = *pImgMatrix; | 87 dib2fxdev = *pImgMatrix; |
| 90 } else { | 88 } else { |
| 91 dib2fxdev.SetIdentity(); | 89 dib2fxdev.SetIdentity(); |
| 92 } | 90 } |
| 93 dib2fxdev.a = dstRect.width; | 91 dib2fxdev.a = dstRect.width; |
| 94 dib2fxdev.d = -dstRect.height; | 92 dib2fxdev.d = -dstRect.height; |
| 95 dib2fxdev.e = dstRect.left; | 93 dib2fxdev.e = dstRect.left; |
| 96 dib2fxdev.f = dstRect.bottom(); | 94 dib2fxdev.f = dstRect.bottom(); |
| 97 if (pDevMatrix) { | 95 if (pDevMatrix) { |
| 98 dib2fxdev.Concat(*pDevMatrix); | 96 dib2fxdev.Concat(*pDevMatrix); |
| 99 } | 97 } |
| 100 void* handle = nullptr; | 98 void* handle = nullptr; |
| 101 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0, | 99 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_Matrix*)&dib2fxdev, 0, |
| 102 handle); | 100 handle); |
| 103 while (m_pDevice->ContinueDIBits(handle, nullptr)) { | 101 while (m_pDevice->ContinueDIBits(handle, nullptr)) { |
| 104 } | 102 } |
| 105 m_pDevice->CancelDIBits(handle); | 103 m_pDevice->CancelDIBits(handle); |
| 106 return !!handle; | 104 return !!handle; |
| 107 } | 105 } |
| 108 FX_BOOL CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, | 106 bool CFDE_RenderDevice::DrawString(CFDE_Brush* pBrush, |
| 109 CFGAS_GEFont* pFont, | 107 CFGAS_GEFont* pFont, |
| 110 const FXTEXT_CHARPOS* pCharPos, | 108 const FXTEXT_CHARPOS* pCharPos, |
| 111 int32_t iCount, | 109 int32_t iCount, |
| 112 FX_FLOAT fFontSize, | 110 FX_FLOAT fFontSize, |
| 113 const CFX_Matrix* pMatrix) { | 111 const CFX_Matrix* pMatrix) { |
| 114 ASSERT(pBrush && pFont && pCharPos && iCount > 0); | 112 ASSERT(pBrush && pFont && pCharPos && iCount > 0); |
| 115 CFX_Font* pFxFont = pFont->GetDevFont(); | 113 CFX_Font* pFxFont = pFont->GetDevFont(); |
| 116 FX_ARGB argb = pBrush->GetColor(); | 114 FX_ARGB argb = pBrush->GetColor(); |
| 117 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && | 115 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && |
| 118 !pFxFont->IsItalic()) { | 116 !pFxFont->IsItalic()) { |
| 119 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; | 117 FXTEXT_CHARPOS* pCP = (FXTEXT_CHARPOS*)pCharPos; |
| 120 FX_FLOAT* pAM; | 118 FX_FLOAT* pAM; |
| 121 for (int32_t i = 0; i < iCount; ++i) { | 119 for (int32_t i = 0; i < iCount; ++i) { |
| 122 static const FX_FLOAT mc = 0.267949f; | 120 static const FX_FLOAT mc = 0.267949f; |
| 123 pAM = pCP->m_AdjustMatrix; | 121 pAM = pCP->m_AdjustMatrix; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 iCurCount = 1; | 164 iCurCount = 1; |
| 167 } else { | 165 } else { |
| 168 iCurCount++; | 166 iCurCount++; |
| 169 } | 167 } |
| 170 pCP++; | 168 pCP++; |
| 171 } | 169 } |
| 172 if (pCurFont && iCurCount) { | 170 if (pCurFont && iCurCount) { |
| 173 pFxFont = pCurFont->GetDevFont(); | 171 pFxFont = pCurFont->GetDevFont(); |
| 174 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 172 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 175 FxFont.SetFace(pFxFont->GetFace()); | 173 FxFont.SetFace(pFxFont->GetFace()); |
| 176 FX_BOOL bRet = m_pDevice->DrawNormalText( | 174 bool bRet = m_pDevice->DrawNormalText( |
| 177 iCurCount, pCurCP, &FxFont, -fFontSize, (const CFX_Matrix*)pMatrix, | 175 iCurCount, pCurCP, &FxFont, -fFontSize, (const CFX_Matrix*)pMatrix, |
| 178 argb, FXTEXT_CLEARTYPE); | 176 argb, FXTEXT_CLEARTYPE); |
| 179 FxFont.SetFace(nullptr); | 177 FxFont.SetFace(nullptr); |
| 180 return bRet; | 178 return bRet; |
| 181 #else | 179 #else |
| 182 return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize, | 180 return m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont, -fFontSize, |
| 183 (const CFX_Matrix*)pMatrix, argb, | 181 (const CFX_Matrix*)pMatrix, argb, |
| 184 FXTEXT_CLEARTYPE); | 182 FXTEXT_CLEARTYPE); |
| 185 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 183 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 186 } | 184 } |
| 187 | 185 |
| 188 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 186 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 189 FxFont.SetFace(nullptr); | 187 FxFont.SetFace(nullptr); |
| 190 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 188 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
| 191 | 189 |
| 192 return TRUE; | 190 return true; |
| 193 } | 191 } |
| 194 | 192 |
| 195 FX_BOOL CFDE_RenderDevice::DrawBezier(CFDE_Pen* pPen, | 193 bool CFDE_RenderDevice::DrawBezier(CFDE_Pen* pPen, |
| 196 FX_FLOAT fPenWidth, | 194 FX_FLOAT fPenWidth, |
| 197 const CFX_PointF& pt1, | 195 const CFX_PointF& pt1, |
| 198 const CFX_PointF& pt2, | 196 const CFX_PointF& pt2, |
| 199 const CFX_PointF& pt3, | 197 const CFX_PointF& pt3, |
| 200 const CFX_PointF& pt4, | 198 const CFX_PointF& pt4, |
| 201 const CFX_Matrix* pMatrix) { | 199 const CFX_Matrix* pMatrix) { |
| 202 CFX_PointsF points; | 200 CFX_PointsF points; |
| 203 points.Add(pt1); | 201 points.Add(pt1); |
| 204 points.Add(pt2); | 202 points.Add(pt2); |
| 205 points.Add(pt3); | 203 points.Add(pt3); |
| 206 points.Add(pt4); | 204 points.Add(pt4); |
| 207 CFDE_Path path; | 205 CFDE_Path path; |
| 208 path.AddBezier(points); | 206 path.AddBezier(points); |
| 209 return DrawPath(pPen, fPenWidth, &path, pMatrix); | 207 return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 210 } | 208 } |
| 211 FX_BOOL CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen, | 209 bool CFDE_RenderDevice::DrawCurve(CFDE_Pen* pPen, |
| 212 FX_FLOAT fPenWidth, | 210 FX_FLOAT fPenWidth, |
| 213 const CFX_PointsF& points, | 211 const CFX_PointsF& points, |
| 214 FX_BOOL bClosed, | 212 bool bClosed, |
| 215 FX_FLOAT fTension, | 213 FX_FLOAT fTension, |
| 216 const CFX_Matrix* pMatrix) { | 214 const CFX_Matrix* pMatrix) { |
| 217 CFDE_Path path; | 215 CFDE_Path path; |
| 218 path.AddCurve(points, bClosed, fTension); | 216 path.AddCurve(points, bClosed, fTension); |
| 219 return DrawPath(pPen, fPenWidth, &path, pMatrix); | 217 return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 220 } | 218 } |
| 221 FX_BOOL CFDE_RenderDevice::DrawEllipse(CFDE_Pen* pPen, | 219 bool CFDE_RenderDevice::DrawEllipse(CFDE_Pen* pPen, |
| 222 FX_FLOAT fPenWidth, | 220 FX_FLOAT fPenWidth, |
| 223 const CFX_RectF& rect, | 221 const CFX_RectF& rect, |
| 224 const CFX_Matrix* pMatrix) { | 222 const CFX_Matrix* pMatrix) { |
| 225 CFDE_Path path; | 223 CFDE_Path path; |
| 226 path.AddEllipse(rect); | 224 path.AddEllipse(rect); |
| 227 return DrawPath(pPen, fPenWidth, &path, pMatrix); | 225 return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 228 } | 226 } |
| 229 FX_BOOL CFDE_RenderDevice::DrawLines(CFDE_Pen* pPen, | 227 bool CFDE_RenderDevice::DrawLines(CFDE_Pen* pPen, |
| 230 FX_FLOAT fPenWidth, | 228 FX_FLOAT fPenWidth, |
| 231 const CFX_PointsF& points, | 229 const CFX_PointsF& points, |
| 232 const CFX_Matrix* pMatrix) { | 230 const CFX_Matrix* pMatrix) { |
| 233 CFDE_Path path; | 231 CFDE_Path path; |
| 234 path.AddLines(points); | 232 path.AddLines(points); |
| 235 return DrawPath(pPen, fPenWidth, &path, pMatrix); | 233 return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 236 } | 234 } |
| 237 FX_BOOL CFDE_RenderDevice::DrawLine(CFDE_Pen* pPen, | 235 bool CFDE_RenderDevice::DrawLine(CFDE_Pen* pPen, |
| 238 FX_FLOAT fPenWidth, | 236 FX_FLOAT fPenWidth, |
| 239 const CFX_PointF& pt1, | 237 const CFX_PointF& pt1, |
| 240 const CFX_PointF& pt2, | 238 const CFX_PointF& pt2, |
| 241 const CFX_Matrix* pMatrix) { | 239 const CFX_Matrix* pMatrix) { |
| 242 CFDE_Path path; | 240 CFDE_Path path; |
| 243 path.AddLine(pt1, pt2); | 241 path.AddLine(pt1, pt2); |
| 244 return DrawPath(pPen, fPenWidth, &path, pMatrix); | 242 return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 245 } | 243 } |
| 246 FX_BOOL CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen, | 244 bool CFDE_RenderDevice::DrawPath(CFDE_Pen* pPen, |
| 247 FX_FLOAT fPenWidth, | 245 FX_FLOAT fPenWidth, |
| 248 const CFDE_Path* pPath, | 246 const CFDE_Path* pPath, |
| 249 const CFX_Matrix* pMatrix) { | 247 const CFX_Matrix* pMatrix) { |
| 250 CFDE_Path* pGePath = (CFDE_Path*)pPath; | 248 CFDE_Path* pGePath = (CFDE_Path*)pPath; |
| 251 if (!pGePath) | 249 if (!pGePath) |
| 252 return FALSE; | 250 return false; |
| 253 | 251 |
| 254 CFX_GraphStateData graphState; | 252 CFX_GraphStateData graphState; |
| 255 if (!CreatePen(pPen, fPenWidth, graphState)) { | 253 if (!CreatePen(pPen, fPenWidth, graphState)) { |
| 256 return FALSE; | 254 return false; |
| 257 } | 255 } |
| 258 return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix, | 256 return m_pDevice->DrawPath(&pGePath->m_Path, (const CFX_Matrix*)pMatrix, |
| 259 &graphState, 0, pPen->GetColor(), 0); | 257 &graphState, 0, pPen->GetColor(), 0); |
| 260 } | 258 } |
| 261 FX_BOOL CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen, | 259 bool CFDE_RenderDevice::DrawPolygon(CFDE_Pen* pPen, |
| 262 FX_FLOAT fPenWidth, | 260 FX_FLOAT fPenWidth, |
| 263 const CFX_PointsF& points, | 261 const CFX_PointsF& points, |
| 264 const CFX_Matrix* pMatrix) { | 262 const CFX_Matrix* pMatrix) { |
| 265 CFDE_Path path; | 263 CFDE_Path path; |
| 266 path.AddPolygon(points); | 264 path.AddPolygon(points); |
| 267 return DrawPath(pPen, fPenWidth, &path, pMatrix); | 265 return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 268 } | 266 } |
| 269 FX_BOOL CFDE_RenderDevice::DrawRectangle(CFDE_Pen* pPen, | 267 bool CFDE_RenderDevice::DrawRectangle(CFDE_Pen* pPen, |
| 270 FX_FLOAT fPenWidth, | 268 FX_FLOAT fPenWidth, |
| 271 const CFX_RectF& rect, | 269 const CFX_RectF& rect, |
| 272 const CFX_Matrix* pMatrix) { | 270 const CFX_Matrix* pMatrix) { |
| 273 CFDE_Path path; | 271 CFDE_Path path; |
| 274 path.AddRectangle(rect); | 272 path.AddRectangle(rect); |
| 275 return DrawPath(pPen, fPenWidth, &path, pMatrix); | 273 return DrawPath(pPen, fPenWidth, &path, pMatrix); |
| 276 } | 274 } |
| 277 FX_BOOL CFDE_RenderDevice::FillClosedCurve(CFDE_Brush* pBrush, | 275 bool CFDE_RenderDevice::FillClosedCurve(CFDE_Brush* pBrush, |
| 278 const CFX_PointsF& points, | 276 const CFX_PointsF& points, |
| 279 FX_FLOAT fTension, | 277 FX_FLOAT fTension, |
| 280 const CFX_Matrix* pMatrix) { | 278 const CFX_Matrix* pMatrix) { |
| 281 CFDE_Path path; | 279 CFDE_Path path; |
| 282 path.AddCurve(points, TRUE, fTension); | 280 path.AddCurve(points, true, fTension); |
| 283 return FillPath(pBrush, &path, pMatrix); | 281 return FillPath(pBrush, &path, pMatrix); |
| 284 } | 282 } |
| 285 FX_BOOL CFDE_RenderDevice::FillEllipse(CFDE_Brush* pBrush, | 283 bool CFDE_RenderDevice::FillEllipse(CFDE_Brush* pBrush, |
| 286 const CFX_RectF& rect, | 284 const CFX_RectF& rect, |
| 287 const CFX_Matrix* pMatrix) { | 285 const CFX_Matrix* pMatrix) { |
| 288 CFDE_Path path; | 286 CFDE_Path path; |
| 289 path.AddEllipse(rect); | 287 path.AddEllipse(rect); |
| 290 return FillPath(pBrush, &path, pMatrix); | 288 return FillPath(pBrush, &path, pMatrix); |
| 291 } | 289 } |
| 292 FX_BOOL CFDE_RenderDevice::FillPolygon(CFDE_Brush* pBrush, | 290 bool CFDE_RenderDevice::FillPolygon(CFDE_Brush* pBrush, |
| 293 const CFX_PointsF& points, | 291 const CFX_PointsF& points, |
| 294 const CFX_Matrix* pMatrix) { | 292 const CFX_Matrix* pMatrix) { |
| 295 CFDE_Path path; | 293 CFDE_Path path; |
| 296 path.AddPolygon(points); | 294 path.AddPolygon(points); |
| 297 return FillPath(pBrush, &path, pMatrix); | 295 return FillPath(pBrush, &path, pMatrix); |
| 298 } | 296 } |
| 299 FX_BOOL CFDE_RenderDevice::FillRectangle(CFDE_Brush* pBrush, | 297 bool CFDE_RenderDevice::FillRectangle(CFDE_Brush* pBrush, |
| 300 const CFX_RectF& rect, | 298 const CFX_RectF& rect, |
| 301 const CFX_Matrix* pMatrix) { | 299 const CFX_Matrix* pMatrix) { |
| 302 CFDE_Path path; | 300 CFDE_Path path; |
| 303 path.AddRectangle(rect); | 301 path.AddRectangle(rect); |
| 304 return FillPath(pBrush, &path, pMatrix); | 302 return FillPath(pBrush, &path, pMatrix); |
| 305 } | 303 } |
| 306 FX_BOOL CFDE_RenderDevice::CreatePen(CFDE_Pen* pPen, | 304 bool CFDE_RenderDevice::CreatePen(CFDE_Pen* pPen, |
| 307 FX_FLOAT fPenWidth, | 305 FX_FLOAT fPenWidth, |
| 308 CFX_GraphStateData& graphState) { | 306 CFX_GraphStateData& graphState) { |
| 309 if (!pPen) | 307 if (!pPen) |
| 310 return FALSE; | 308 return false; |
| 311 | 309 |
| 312 graphState.m_LineCap = CFX_GraphStateData::LineCapButt; | 310 graphState.m_LineCap = CFX_GraphStateData::LineCapButt; |
| 313 graphState.m_LineJoin = CFX_GraphStateData::LineJoinMiter; | 311 graphState.m_LineJoin = CFX_GraphStateData::LineJoinMiter; |
| 314 graphState.m_LineWidth = fPenWidth; | 312 graphState.m_LineWidth = fPenWidth; |
| 315 graphState.m_MiterLimit = 10; | 313 graphState.m_MiterLimit = 10; |
| 316 graphState.m_DashPhase = 0; | 314 graphState.m_DashPhase = 0; |
| 317 return TRUE; | 315 return true; |
| 318 } | 316 } |
| 319 | 317 |
| 320 FX_BOOL CFDE_RenderDevice::FillPath(CFDE_Brush* pBrush, | 318 bool CFDE_RenderDevice::FillPath(CFDE_Brush* pBrush, |
| 321 const CFDE_Path* pPath, | 319 const CFDE_Path* pPath, |
| 322 const CFX_Matrix* pMatrix) { | 320 const CFX_Matrix* pMatrix) { |
| 323 CFDE_Path* pGePath = (CFDE_Path*)pPath; | 321 CFDE_Path* pGePath = (CFDE_Path*)pPath; |
| 324 if (!pGePath) | 322 if (!pGePath) |
| 325 return FALSE; | 323 return false; |
| 326 if (!pBrush) | 324 if (!pBrush) |
| 327 return FALSE; | 325 return false; |
| 328 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, | 326 return m_pDevice->DrawPath(&pGePath->m_Path, pMatrix, nullptr, |
| 329 pBrush->GetColor(), 0, FXFILL_WINDING); | 327 pBrush->GetColor(), 0, FXFILL_WINDING); |
| 330 } | 328 } |
| 331 | 329 |
| OLD | NEW |