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 "../../../foxitlib.h" | 7 #include "../../../foxitlib.h" |
8 #include "fde_gedevice.h" | 8 #include "fde_gedevice.h" |
9 #include "fde_geobject.h" | 9 #include "fde_geobject.h" |
10 #include "fde_devbasic.h" | 10 #include "fde_devbasic.h" |
11 #ifndef _FDEPLUS | 11 #ifndef _FDEPLUS |
12 #ifdef _cplusplus | 12 #ifdef _cplusplus |
13 exten "C" { | 13 exten "C" { |
14 #endif | 14 #endif |
15 FX_BOOL FDE_GetStockHatchMask(FX_INT32 iHatchStyle, CFX_DIBitmap & hatchMask
) | 15 FX_BOOL FDE_GetStockHatchMask(int32_t iHatchStyle, CFX_DIBitmap & hatchMask) |
16 { | 16 { |
17 FDE_LPCHATCHDATA pData = FDE_DEVGetHatchData(iHatchStyle); | 17 FDE_LPCHATCHDATA pData = FDE_DEVGetHatchData(iHatchStyle); |
18 if (!pData) { | 18 if (!pData) { |
19 return FALSE; | 19 return FALSE; |
20 } | 20 } |
21 hatchMask.Create(pData->iWidth, pData->iHeight, FXDIB_1bppMask); | 21 hatchMask.Create(pData->iWidth, pData->iHeight, FXDIB_1bppMask); |
22 FXSYS_memcpy(hatchMask.GetBuffer(), pData->MaskBits, hatchMask.GetPitch(
) * pData->iHeight); | 22 FXSYS_memcpy(hatchMask.GetBuffer(), pData->MaskBits, hatchMask.GetPitch(
) * pData->iHeight); |
23 return TRUE; | 23 return TRUE; |
24 } | 24 } |
25 #ifdef _cplusplus | 25 #ifdef _cplusplus |
(...skipping 30 matching lines...) Expand all Loading... |
56 } | 56 } |
57 CFDE_FxgeDevice::~CFDE_FxgeDevice() | 57 CFDE_FxgeDevice::~CFDE_FxgeDevice() |
58 { | 58 { |
59 if (m_pCharPos != NULL) { | 59 if (m_pCharPos != NULL) { |
60 FDE_Free(m_pCharPos); | 60 FDE_Free(m_pCharPos); |
61 } | 61 } |
62 if (m_bOwnerDevice && m_pDevice) { | 62 if (m_bOwnerDevice && m_pDevice) { |
63 delete m_pDevice; | 63 delete m_pDevice; |
64 } | 64 } |
65 } | 65 } |
66 FX_INT32 CFDE_FxgeDevice::GetWidth() const | 66 int32_t CFDE_FxgeDevice::GetWidth() const |
67 { | 67 { |
68 return m_pDevice->GetWidth(); | 68 return m_pDevice->GetWidth(); |
69 } | 69 } |
70 FX_INT32 CFDE_FxgeDevice::GetHeight() const | 70 int32_t CFDE_FxgeDevice::GetHeight() const |
71 { | 71 { |
72 return m_pDevice->GetHeight(); | 72 return m_pDevice->GetHeight(); |
73 } | 73 } |
74 FDE_HDEVICESTATE CFDE_FxgeDevice::SaveState() | 74 FDE_HDEVICESTATE CFDE_FxgeDevice::SaveState() |
75 { | 75 { |
76 m_pDevice->SaveState(); | 76 m_pDevice->SaveState(); |
77 return NULL; | 77 return NULL; |
78 } | 78 } |
79 void CFDE_FxgeDevice::RestoreState(FDE_HDEVICESTATE hState) | 79 void CFDE_FxgeDevice::RestoreState(FDE_HDEVICESTATE hState) |
80 { | 80 { |
81 m_pDevice->RestoreState(); | 81 m_pDevice->RestoreState(); |
82 const FX_RECT &rt = m_pDevice->GetClipBox(); | 82 const FX_RECT &rt = m_pDevice->GetClipBox(); |
83 m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), (FX_
FLOAT)rt.Height()); | 83 m_rtClip.Set((FX_FLOAT)rt.left, (FX_FLOAT)rt.top, (FX_FLOAT)rt.Width(), (FX_
FLOAT)rt.Height()); |
84 } | 84 } |
85 FX_BOOL CFDE_FxgeDevice::SetClipRect(const CFX_RectF &rtClip) | 85 FX_BOOL CFDE_FxgeDevice::SetClipRect(const CFX_RectF &rtClip) |
86 { | 86 { |
87 m_rtClip = rtClip; | 87 m_rtClip = rtClip; |
88 FX_RECT rt((FX_INT32)FXSYS_floor(rtClip.left), (FX_INT32)FXSYS_floor(rtClip.
top), | 88 FX_RECT rt((int32_t)FXSYS_floor(rtClip.left), (int32_t)FXSYS_floor(rtClip.to
p), |
89 (FX_INT32)FXSYS_ceil(rtClip.right()), (FX_INT32)FXSYS_ceil(rtClip
.bottom())); | 89 (int32_t)FXSYS_ceil(rtClip.right()), (int32_t)FXSYS_ceil(rtClip.b
ottom())); |
90 return m_pDevice->SetClip_Rect(&rt); | 90 return m_pDevice->SetClip_Rect(&rt); |
91 } | 91 } |
92 const CFX_RectF& CFDE_FxgeDevice::GetClipRect() | 92 const CFX_RectF& CFDE_FxgeDevice::GetClipRect() |
93 { | 93 { |
94 return m_rtClip; | 94 return m_rtClip; |
95 } | 95 } |
96 FX_BOOL CFDE_FxgeDevice::SetClipPath(const IFDE_Path *pClip) | 96 FX_BOOL CFDE_FxgeDevice::SetClipPath(const IFDE_Path *pClip) |
97 { | 97 { |
98 return FALSE; | 98 return FALSE; |
99 } | 99 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 dib2fxdev.f = dstRect.bottom(); | 133 dib2fxdev.f = dstRect.bottom(); |
134 if (pDevMatrix) { | 134 if (pDevMatrix) { |
135 dib2fxdev.Concat(*pDevMatrix); | 135 dib2fxdev.Concat(*pDevMatrix); |
136 } | 136 } |
137 FX_LPVOID handle = NULL; | 137 FX_LPVOID handle = NULL; |
138 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_AffineMatrix*)&dib2fxdev, 0,
handle); | 138 m_pDevice->StartDIBits(pDib, 255, 0, (const CFX_AffineMatrix*)&dib2fxdev, 0,
handle); |
139 while (m_pDevice->ContinueDIBits(handle, NULL)) { } | 139 while (m_pDevice->ContinueDIBits(handle, NULL)) { } |
140 m_pDevice->CancelDIBits(handle); | 140 m_pDevice->CancelDIBits(handle); |
141 return handle != NULL; | 141 return handle != NULL; |
142 } | 142 } |
143 FX_BOOL CFDE_FxgeDevice::DrawString(IFDE_Brush *pBrush, IFX_Font *pFont, const F
XTEXT_CHARPOS *pCharPos, FX_INT32 iCount, FX_FLOAT fFontSize, const CFX_Matrix *
pMatrix) | 143 FX_BOOL CFDE_FxgeDevice::DrawString(IFDE_Brush *pBrush, IFX_Font *pFont, const F
XTEXT_CHARPOS *pCharPos, int32_t iCount, FX_FLOAT fFontSize, const CFX_Matrix *p
Matrix) |
144 { | 144 { |
145 FXSYS_assert(pBrush != NULL && pFont != NULL && pCharPos != NULL && iCount >
0); | 145 FXSYS_assert(pBrush != NULL && pFont != NULL && pCharPos != NULL && iCount >
0); |
146 CFX_FontCache *pCache = CFX_GEModule::Get()->GetFontCache(); | 146 CFX_FontCache *pCache = CFX_GEModule::Get()->GetFontCache(); |
147 CFX_Font *pFxFont = (CFX_Font*)pFont->GetDevFont(); | 147 CFX_Font *pFxFont = (CFX_Font*)pFont->GetDevFont(); |
148 switch (pBrush->GetType()) { | 148 switch (pBrush->GetType()) { |
149 case FDE_BRUSHTYPE_Solid: { | 149 case FDE_BRUSHTYPE_Solid: { |
150 FX_ARGB argb = ((IFDE_SolidBrush*)pBrush)->GetColor(); | 150 FX_ARGB argb = ((IFDE_SolidBrush*)pBrush)->GetColor(); |
151 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && !pFxF
ont->IsItalic()) { | 151 if ((pFont->GetFontStyles() & FX_FONTSTYLE_Italic) != 0 && !pFxF
ont->IsItalic()) { |
152 FXTEXT_CHARPOS *pCP = (FXTEXT_CHARPOS*)pCharPos; | 152 FXTEXT_CHARPOS *pCP = (FXTEXT_CHARPOS*)pCharPos; |
153 FX_FLOAT *pAM; | 153 FX_FLOAT *pAM; |
154 for (FX_INT32 i = 0; i < iCount; ++i) { | 154 for (int32_t i = 0; i < iCount; ++i) { |
155 static const FX_FLOAT mc = 0.267949f; | 155 static const FX_FLOAT mc = 0.267949f; |
156 pAM = pCP->m_AdjustMatrix; | 156 pAM = pCP->m_AdjustMatrix; |
157 pAM[2] = mc * pAM[0] + pAM[2]; | 157 pAM[2] = mc * pAM[0] + pAM[2]; |
158 pAM[3] = mc * pAM[1] + pAM[3]; | 158 pAM[3] = mc * pAM[1] + pAM[3]; |
159 pCP ++; | 159 pCP ++; |
160 } | 160 } |
161 } | 161 } |
162 FXTEXT_CHARPOS *pCP = (FXTEXT_CHARPOS*)pCharPos; | 162 FXTEXT_CHARPOS *pCP = (FXTEXT_CHARPOS*)pCharPos; |
163 IFX_Font *pCurFont = NULL; | 163 IFX_Font *pCurFont = NULL; |
164 IFX_Font *pSTFont = NULL; | 164 IFX_Font *pSTFont = NULL; |
165 FXTEXT_CHARPOS *pCurCP = NULL; | 165 FXTEXT_CHARPOS *pCurCP = NULL; |
166 FX_INT32 iCurCount = 0; | 166 int32_t iCurCount = 0; |
167 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 167 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
168 FX_DWORD dwFontStyle = pFont->GetFontStyles(); | 168 FX_DWORD dwFontStyle = pFont->GetFontStyles(); |
169 CFX_Font FxFont; | 169 CFX_Font FxFont; |
170 CFX_SubstFont SubstFxFont; | 170 CFX_SubstFont SubstFxFont; |
171 FxFont.m_pSubstFont = &SubstFxFont; | 171 FxFont.m_pSubstFont = &SubstFxFont; |
172 SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 4
00; | 172 SubstFxFont.m_Weight = dwFontStyle & FX_FONTSTYLE_Bold ? 700 : 4
00; |
173 SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; | 173 SubstFxFont.m_WeightCJK = SubstFxFont.m_Weight; |
174 SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ?
-12 : 0; | 174 SubstFxFont.m_ItalicAngle = dwFontStyle & FX_FONTSTYLE_Italic ?
-12 : 0; |
175 SubstFxFont.m_bItlicCJK = dwFontStyle & FX_FONTSTYLE_Italic ? TR
UE : FALSE; | 175 SubstFxFont.m_bItlicCJK = dwFontStyle & FX_FONTSTYLE_Italic ? TR
UE : FALSE; |
176 #endif | 176 #endif |
177 for (FX_INT32 i = 0; i < iCount; ++i) { | 177 for (int32_t i = 0; i < iCount; ++i) { |
178 pSTFont = pFont->GetSubstFont((FX_INT32)pCP->m_GlyphIndex); | 178 pSTFont = pFont->GetSubstFont((int32_t)pCP->m_GlyphIndex); |
179 pCP->m_GlyphIndex &= 0x00FFFFFF; | 179 pCP->m_GlyphIndex &= 0x00FFFFFF; |
180 pCP->m_bFontStyle = FALSE; | 180 pCP->m_bFontStyle = FALSE; |
181 if (pCurFont != pSTFont) { | 181 if (pCurFont != pSTFont) { |
182 if (pCurFont != NULL) { | 182 if (pCurFont != NULL) { |
183 pFxFont = (CFX_Font*)pCurFont->GetDevFont(); | 183 pFxFont = (CFX_Font*)pCurFont->GetDevFont(); |
184 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 184 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
185 FxFont.m_Face = pFxFont->m_Face; | 185 FxFont.m_Face = pFxFont->m_Face; |
186 m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont
, pCache, -fFontSize, (const CFX_AffineMatrix*)pMatrix, argb, FXTEXT_CLEARTYPE); | 186 m_pDevice->DrawNormalText(iCurCount, pCurCP, &FxFont
, pCache, -fFontSize, (const CFX_AffineMatrix*)pMatrix, argb, FXTEXT_CLEARTYPE); |
187 #else | 187 #else |
188 m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont
, pCache, -fFontSize, (const CFX_AffineMatrix*)pMatrix, argb, FXTEXT_CLEARTYPE); | 188 m_pDevice->DrawNormalText(iCurCount, pCurCP, pFxFont
, pCache, -fFontSize, (const CFX_AffineMatrix*)pMatrix, argb, FXTEXT_CLEARTYPE); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 dashArray.Add(1); | 333 dashArray.Add(1); |
334 dashArray.Add(1); | 334 dashArray.Add(1); |
335 dashArray.Add(1); | 335 dashArray.Add(1); |
336 dashArray.Add(1); | 336 dashArray.Add(1); |
337 dashArray.Add(1); | 337 dashArray.Add(1); |
338 break; | 338 break; |
339 case FDE_DASHSTYLE_Customized: | 339 case FDE_DASHSTYLE_Customized: |
340 pPen->GetDashArray(dashArray); | 340 pPen->GetDashArray(dashArray); |
341 break; | 341 break; |
342 } | 342 } |
343 FX_INT32 iDashCount = dashArray.GetSize(); | 343 int32_t iDashCount = dashArray.GetSize(); |
344 if (iDashCount > 0) { | 344 if (iDashCount > 0) { |
345 graphState.SetDashCount(iDashCount); | 345 graphState.SetDashCount(iDashCount); |
346 for (FX_INT32 i = 0; i < iDashCount; ++i) { | 346 for (int32_t i = 0; i < iDashCount; ++i) { |
347 graphState.m_DashArray[i] = dashArray[i] * fPenWidth; | 347 graphState.m_DashArray[i] = dashArray[i] * fPenWidth; |
348 } | 348 } |
349 } | 349 } |
350 return TRUE; | 350 return TRUE; |
351 } | 351 } |
352 typedef FX_BOOL (CFDE_FxgeDevice::*pfFillPath)(IFDE_Brush *pBrush, const CFX_Pat
hData *pPath, const CFX_Matrix *pMatrix); | 352 typedef FX_BOOL (CFDE_FxgeDevice::*pfFillPath)(IFDE_Brush *pBrush, const CFX_Pat
hData *pPath, const CFX_Matrix *pMatrix); |
353 static const pfFillPath gs_FillPath[] = { | 353 static const pfFillPath gs_FillPath[] = { |
354 &CFDE_FxgeDevice::FillSolidPath, | 354 &CFDE_FxgeDevice::FillSolidPath, |
355 &CFDE_FxgeDevice::FillHatchPath, | 355 &CFDE_FxgeDevice::FillHatchPath, |
356 &CFDE_FxgeDevice::FillTexturePath, | 356 &CFDE_FxgeDevice::FillTexturePath, |
357 &CFDE_FxgeDevice::FillLinearGradientPath, | 357 &CFDE_FxgeDevice::FillLinearGradientPath, |
358 }; | 358 }; |
359 FX_BOOL CFDE_FxgeDevice::FillPath(IFDE_Brush *pBrush, const IFDE_Path *pPath, co
nst CFX_Matrix *pMatrix) | 359 FX_BOOL CFDE_FxgeDevice::FillPath(IFDE_Brush *pBrush, const IFDE_Path *pPath, co
nst CFX_Matrix *pMatrix) |
360 { | 360 { |
361 CFDE_Path *pGePath = (CFDE_Path*)pPath; | 361 CFDE_Path *pGePath = (CFDE_Path*)pPath; |
362 if (pGePath == NULL) { | 362 if (pGePath == NULL) { |
363 return FALSE; | 363 return FALSE; |
364 } | 364 } |
365 if (pBrush == NULL) { | 365 if (pBrush == NULL) { |
366 return FALSE; | 366 return FALSE; |
367 } | 367 } |
368 FX_INT32 iType = pBrush->GetType(); | 368 int32_t iType = pBrush->GetType(); |
369 if (iType < 0 || iType > FDE_BRUSHTYPE_MAX) { | 369 if (iType < 0 || iType > FDE_BRUSHTYPE_MAX) { |
370 return FALSE; | 370 return FALSE; |
371 } | 371 } |
372 return (this->*gs_FillPath[iType])(pBrush, &pGePath->m_Path, pMatrix); | 372 return (this->*gs_FillPath[iType])(pBrush, &pGePath->m_Path, pMatrix); |
373 } | 373 } |
374 FX_BOOL CFDE_FxgeDevice::FillSolidPath(IFDE_Brush *pBrush, const CFX_PathData *p
Path, const CFX_Matrix *pMatrix) | 374 FX_BOOL CFDE_FxgeDevice::FillSolidPath(IFDE_Brush *pBrush, const CFX_PathData *p
Path, const CFX_Matrix *pMatrix) |
375 { | 375 { |
376 FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Solid); | 376 FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Solid); |
377 IFDE_SolidBrush *pSolidBrush = (IFDE_SolidBrush*)pBrush; | 377 IFDE_SolidBrush *pSolidBrush = (IFDE_SolidBrush*)pBrush; |
378 return m_pDevice->DrawPath(pPath, (const CFX_AffineMatrix*)pMatrix, NULL, pS
olidBrush->GetColor(), 0, FXFILL_WINDING); | 378 return m_pDevice->DrawPath(pPath, (const CFX_AffineMatrix*)pMatrix, NULL, pS
olidBrush->GetColor(), 0, FXFILL_WINDING); |
379 } | 379 } |
380 FX_BOOL CFDE_FxgeDevice::FillHatchPath(IFDE_Brush *pBrush, const CFX_PathData *p
Path, const CFX_Matrix *pMatrix) | 380 FX_BOOL CFDE_FxgeDevice::FillHatchPath(IFDE_Brush *pBrush, const CFX_PathData *p
Path, const CFX_Matrix *pMatrix) |
381 { | 381 { |
382 FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Hatch); | 382 FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Hatch); |
383 IFDE_HatchBrush *pHatchBrush = (IFDE_HatchBrush*)pBrush; | 383 IFDE_HatchBrush *pHatchBrush = (IFDE_HatchBrush*)pBrush; |
384 FX_INT32 iStyle = pHatchBrush->GetHatchStyle(); | 384 int32_t iStyle = pHatchBrush->GetHatchStyle(); |
385 if (iStyle < FDE_HATCHSTYLE_Min || iStyle > FDE_HATCHSTYLE_Max) { | 385 if (iStyle < FDE_HATCHSTYLE_Min || iStyle > FDE_HATCHSTYLE_Max) { |
386 return FALSE; | 386 return FALSE; |
387 } | 387 } |
388 CFX_DIBitmap mask; | 388 CFX_DIBitmap mask; |
389 if (!FDE_GetStockHatchMask(iStyle, mask)) { | 389 if (!FDE_GetStockHatchMask(iStyle, mask)) { |
390 return FALSE; | 390 return FALSE; |
391 } | 391 } |
392 FX_ARGB dwForeColor = pHatchBrush->GetColor(TRUE); | 392 FX_ARGB dwForeColor = pHatchBrush->GetColor(TRUE); |
393 FX_ARGB dwBackColor = pHatchBrush->GetColor(FALSE); | 393 FX_ARGB dwBackColor = pHatchBrush->GetColor(FALSE); |
394 CFX_FloatRect rectf = pPath->GetBoundingBox(); | 394 CFX_FloatRect rectf = pPath->GetBoundingBox(); |
395 if (pMatrix) { | 395 if (pMatrix) { |
396 rectf.Transform((const CFX_AffineMatrix*)pMatrix); | 396 rectf.Transform((const CFX_AffineMatrix*)pMatrix); |
397 } | 397 } |
398 FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), | 398 FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), |
399 FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); | 399 FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); |
400 m_pDevice->SaveState(); | 400 m_pDevice->SaveState(); |
401 m_pDevice->StartRendering(); | 401 m_pDevice->StartRendering(); |
402 m_pDevice->SetClip_PathFill(pPath, (const CFX_AffineMatrix*)pMatrix, FXFILL_
WINDING); | 402 m_pDevice->SetClip_PathFill(pPath, (const CFX_AffineMatrix*)pMatrix, FXFILL_
WINDING); |
403 m_pDevice->FillRect(&rect, dwBackColor); | 403 m_pDevice->FillRect(&rect, dwBackColor); |
404 for (FX_INT32 j = rect.bottom; j < rect.top; j += mask.GetHeight()) | 404 for (int32_t j = rect.bottom; j < rect.top; j += mask.GetHeight()) |
405 for (FX_INT32 i = rect.left; i < rect.right; i += mask.GetWidth()) { | 405 for (int32_t i = rect.left; i < rect.right; i += mask.GetWidth()) { |
406 m_pDevice->SetBitMask(&mask, i, j, dwForeColor); | 406 m_pDevice->SetBitMask(&mask, i, j, dwForeColor); |
407 } | 407 } |
408 m_pDevice->EndRendering(); | 408 m_pDevice->EndRendering(); |
409 m_pDevice->RestoreState(); | 409 m_pDevice->RestoreState(); |
410 return TRUE; | 410 return TRUE; |
411 } | 411 } |
412 FX_BOOL CFDE_FxgeDevice::FillTexturePath(IFDE_Brush *pBrush, const CFX_PathData
*pPath, const CFX_Matrix *pMatrix) | 412 FX_BOOL CFDE_FxgeDevice::FillTexturePath(IFDE_Brush *pBrush, const CFX_PathData
*pPath, const CFX_Matrix *pMatrix) |
413 { | 413 { |
414 FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Texture); | 414 FXSYS_assert(pPath && pBrush && pBrush->GetType() == FDE_BRUSHTYPE_Texture); |
415 IFDE_TextureBrush *pTextureBrush = (IFDE_TextureBrush*)pBrush; | 415 IFDE_TextureBrush *pTextureBrush = (IFDE_TextureBrush*)pBrush; |
416 IFDE_Image *pImage = (IFDE_Image*)pTextureBrush->GetImage(); | 416 IFDE_Image *pImage = (IFDE_Image*)pTextureBrush->GetImage(); |
417 if (pImage == NULL) { | 417 if (pImage == NULL) { |
418 return FALSE; | 418 return FALSE; |
419 } | 419 } |
420 CFX_Size size; | 420 CFX_Size size; |
421 size.Set(pImage->GetImageWidth(), pImage->GetImageHeight()); | 421 size.Set(pImage->GetImageWidth(), pImage->GetImageHeight()); |
422 CFX_DIBitmap bmp; | 422 CFX_DIBitmap bmp; |
423 bmp.Create(size.x, size.y, FXDIB_Argb); | 423 bmp.Create(size.x, size.y, FXDIB_Argb); |
424 if (!pImage->StartLoadImage(&bmp, 0, 0, size.x, size.y, 0, 0, size.x, size.y
)) { | 424 if (!pImage->StartLoadImage(&bmp, 0, 0, size.x, size.y, 0, 0, size.x, size.y
)) { |
425 return FALSE; | 425 return FALSE; |
426 } | 426 } |
427 if (pImage->DoLoadImage() < 100) { | 427 if (pImage->DoLoadImage() < 100) { |
428 return FALSE; | 428 return FALSE; |
429 } | 429 } |
430 pImage->StopLoadImage(); | 430 pImage->StopLoadImage(); |
431 return WrapTexture(pTextureBrush->GetWrapMode(), &bmp, pPath, pMatrix); | 431 return WrapTexture(pTextureBrush->GetWrapMode(), &bmp, pPath, pMatrix); |
432 } | 432 } |
433 FX_BOOL CFDE_FxgeDevice::WrapTexture(FX_INT32 iWrapMode, const CFX_DIBitmap *pBi
tmap, const CFX_PathData *pPath, const CFX_Matrix *pMatrix) | 433 FX_BOOL CFDE_FxgeDevice::WrapTexture(int32_t iWrapMode, const CFX_DIBitmap *pBit
map, const CFX_PathData *pPath, const CFX_Matrix *pMatrix) |
434 { | 434 { |
435 CFX_FloatRect rectf = pPath->GetBoundingBox(); | 435 CFX_FloatRect rectf = pPath->GetBoundingBox(); |
436 if (pMatrix) { | 436 if (pMatrix) { |
437 rectf.Transform((const CFX_AffineMatrix*)pMatrix); | 437 rectf.Transform((const CFX_AffineMatrix*)pMatrix); |
438 } | 438 } |
439 FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), | 439 FX_RECT rect(FXSYS_round(rectf.left), FXSYS_round(rectf.top), |
440 FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); | 440 FXSYS_round(rectf.right), FXSYS_round(rectf.bottom)); |
441 rect.Normalize(); | 441 rect.Normalize(); |
442 if (rect.IsEmpty()) { | 442 if (rect.IsEmpty()) { |
443 return FALSE; | 443 return FALSE; |
444 } | 444 } |
445 m_pDevice->SaveState(); | 445 m_pDevice->SaveState(); |
446 m_pDevice->StartRendering(); | 446 m_pDevice->StartRendering(); |
447 m_pDevice->SetClip_PathFill(pPath, (const CFX_AffineMatrix*)pMatrix, FXFILL_
WINDING); | 447 m_pDevice->SetClip_PathFill(pPath, (const CFX_AffineMatrix*)pMatrix, FXFILL_
WINDING); |
448 switch (iWrapMode) { | 448 switch (iWrapMode) { |
449 case FDE_WRAPMODE_Tile: | 449 case FDE_WRAPMODE_Tile: |
450 case FDE_WRAPMODE_TileFlipX: | 450 case FDE_WRAPMODE_TileFlipX: |
451 case FDE_WRAPMODE_TileFlipY: | 451 case FDE_WRAPMODE_TileFlipY: |
452 case FDE_WRAPMODE_TileFlipXY: { | 452 case FDE_WRAPMODE_TileFlipXY: { |
453 FX_BOOL bFlipX = iWrapMode == FDE_WRAPMODE_TileFlipXY || iWrapMo
de == FDE_WRAPMODE_TileFlipX; | 453 FX_BOOL bFlipX = iWrapMode == FDE_WRAPMODE_TileFlipXY || iWrapMo
de == FDE_WRAPMODE_TileFlipX; |
454 FX_BOOL bFlipY = iWrapMode == FDE_WRAPMODE_TileFlipXY || iWrapMo
de == FDE_WRAPMODE_TileFlipY; | 454 FX_BOOL bFlipY = iWrapMode == FDE_WRAPMODE_TileFlipXY || iWrapMo
de == FDE_WRAPMODE_TileFlipY; |
455 const CFX_DIBitmap *pFlip[2][2]; | 455 const CFX_DIBitmap *pFlip[2][2]; |
456 pFlip[0][0] = pBitmap; | 456 pFlip[0][0] = pBitmap; |
457 pFlip[0][1] = bFlipX ? pBitmap->FlipImage(TRUE, FALSE) : pBitmap
; | 457 pFlip[0][1] = bFlipX ? pBitmap->FlipImage(TRUE, FALSE) : pBitmap
; |
458 pFlip[1][0] = bFlipY ? pBitmap->FlipImage(FALSE, TRUE) : pBitmap
; | 458 pFlip[1][0] = bFlipY ? pBitmap->FlipImage(FALSE, TRUE) : pBitmap
; |
459 pFlip[1][1] = (bFlipX || bFlipY) ? pBitmap->FlipImage(bFlipX, bF
lipY) : pBitmap; | 459 pFlip[1][1] = (bFlipX || bFlipY) ? pBitmap->FlipImage(bFlipX, bF
lipY) : pBitmap; |
460 FX_INT32 iCounterY = 0; | 460 int32_t iCounterY = 0; |
461 for (FX_INT32 j = rect.top; j < rect.bottom; j += pBitmap->GetHe
ight()) { | 461 for (int32_t j = rect.top; j < rect.bottom; j += pBitmap->GetHei
ght()) { |
462 FX_INT32 indexY = iCounterY++ % 2; | 462 int32_t indexY = iCounterY++ % 2; |
463 FX_INT32 iCounterX = 0; | 463 int32_t iCounterX = 0; |
464 for (FX_INT32 i = rect.left; i < rect.right; i += pBitmap->G
etWidth()) { | 464 for (int32_t i = rect.left; i < rect.right; i += pBitmap->Ge
tWidth()) { |
465 FX_INT32 indexX = iCounterX++ % 2; | 465 int32_t indexX = iCounterX++ % 2; |
466 m_pDevice->SetDIBits(pFlip[indexY][indexX], i, j); | 466 m_pDevice->SetDIBits(pFlip[indexY][indexX], i, j); |
467 } | 467 } |
468 } | 468 } |
469 if (pFlip[0][1] != pFlip[0][0]) { | 469 if (pFlip[0][1] != pFlip[0][0]) { |
470 delete pFlip[0][1]; | 470 delete pFlip[0][1]; |
471 } | 471 } |
472 if (pFlip[1][0] != pFlip[0][0]) { | 472 if (pFlip[1][0] != pFlip[0][0]) { |
473 delete pFlip[1][0]; | 473 delete pFlip[1][0]; |
474 } | 474 } |
475 if (pFlip[1][1] != pFlip[0][0]) { | 475 if (pFlip[1][1] != pFlip[0][0]) { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 FX_FLOAT b0 = FXARGB_B(cr0); | 509 FX_FLOAT b0 = FXARGB_B(cr0); |
510 FX_FLOAT da = (FXARGB_A(cr1) - a0) / fSteps; | 510 FX_FLOAT da = (FXARGB_A(cr1) - a0) / fSteps; |
511 FX_FLOAT dr = (FXARGB_R(cr1) - r0) / fSteps; | 511 FX_FLOAT dr = (FXARGB_R(cr1) - r0) / fSteps; |
512 FX_FLOAT dg = (FXARGB_G(cr1) - g0) / fSteps; | 512 FX_FLOAT dg = (FXARGB_G(cr1) - g0) / fSteps; |
513 FX_FLOAT db = (FXARGB_B(cr1) - b0) / fSteps; | 513 FX_FLOAT db = (FXARGB_B(cr1) - b0) / fSteps; |
514 CFX_DIBitmap bmp; | 514 CFX_DIBitmap bmp; |
515 bmp.Create(FXSYS_round(FXSYS_fabs(fDiagonal.x)), FXSYS_round(FXSYS_fabs(fDia
gonal.y)), FXDIB_Argb); | 515 bmp.Create(FXSYS_round(FXSYS_fabs(fDiagonal.x)), FXSYS_round(FXSYS_fabs(fDia
gonal.y)), FXDIB_Argb); |
516 CFX_FxgeDevice dev; | 516 CFX_FxgeDevice dev; |
517 dev.Attach(&bmp); | 517 dev.Attach(&bmp); |
518 pt1 = pt0; | 518 pt1 = pt0; |
519 FX_INT32 iSteps = FXSYS_round(FXSYS_ceil(fSteps)); | 519 int32_t iSteps = FXSYS_round(FXSYS_ceil(fSteps)); |
520 while (--iSteps >= 0) { | 520 while (--iSteps >= 0) { |
521 cr0 = ArgbEncode(FXSYS_round(a0), FXSYS_round(r0), FXSYS_round(g0), FXSY
S_round(b0)); | 521 cr0 = ArgbEncode(FXSYS_round(a0), FXSYS_round(r0), FXSYS_round(g0), FXSY
S_round(b0)); |
522 dev.DrawCosmeticLine(pt0.x, pt0.y, pt1.x, pt1.y, cr0); | 522 dev.DrawCosmeticLine(pt0.x, pt0.y, pt1.x, pt1.y, cr0); |
523 pt1.x += dx; | 523 pt1.x += dx; |
524 pt0.y += dy; | 524 pt0.y += dy; |
525 a0 += da; | 525 a0 += da; |
526 r0 += dr; | 526 r0 += dr; |
527 g0 += dg; | 527 g0 += dg; |
528 b0 += db; | 528 b0 += db; |
529 } | 529 } |
530 return WrapTexture(pLinearBrush->GetWrapMode(), &bmp, pPath, pMatrix); | 530 return WrapTexture(pLinearBrush->GetWrapMode(), &bmp, pPath, pMatrix); |
531 } | 531 } |
532 #endif | 532 #endif |
OLD | NEW |