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 "../../../../include/fxge/fx_ge.h" | 7 #include "../../../../include/fxge/fx_ge.h" |
8 #include "../../dib/dib_int.h" | 8 #include "../../dib/dib_int.h" |
9 #include "../../ge/text_int.h" | 9 #include "../../ge/text_int.h" |
10 #include "../../../../include/fxcodec/fx_codec.h" | 10 #include "../../../../include/fxcodec/fx_codec.h" |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 dash_stroke stroke(dash); | 180 dash_stroke stroke(dash); |
181 stroke.line_join(join); | 181 stroke.line_join(join); |
182 stroke.line_cap(cap); | 182 stroke.line_cap(cap); |
183 stroke.miter_limit(pGraphState->m_MiterLimit); | 183 stroke.miter_limit(pGraphState->m_MiterLimit); |
184 stroke.width(width); | 184 stroke.width(width); |
185 rasterizer.add_path_transformed(stroke, pObject2Device); | 185 rasterizer.add_path_transformed(stroke, pObject2Device); |
186 } | 186 } |
187 } | 187 } |
188 IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver(CFX_DIBitmap* p
Bitmap, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 188 IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver(CFX_DIBitmap* p
Bitmap, FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) |
189 { | 189 { |
190 return FX_NEW CFX_AggDeviceDriver(pBitmap, 0, bRgbByteOrder, pOriDevice, bGr
oupKnockout); | 190 return new CFX_AggDeviceDriver(pBitmap, 0, bRgbByteOrder, pOriDevice, bGroup
Knockout); |
191 } | 191 } |
192 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits,
FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 192 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, int dither_bits,
FX_BOOL bRgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) |
193 { | 193 { |
194 m_pBitmap = pBitmap; | 194 m_pBitmap = pBitmap; |
195 m_DitherBits = dither_bits; | 195 m_DitherBits = dither_bits; |
196 m_pClipRgn = NULL; | 196 m_pClipRgn = NULL; |
197 m_pPlatformBitmap = NULL; | 197 m_pPlatformBitmap = NULL; |
198 m_pPlatformGraphics = NULL; | 198 m_pPlatformGraphics = NULL; |
199 m_pDwRenderTartget = NULL; | 199 m_pDwRenderTartget = NULL; |
200 m_bRgbByteOrder = bRgbByteOrder; | 200 m_bRgbByteOrder = bRgbByteOrder; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 } | 260 } |
261 case FXDC_DITHER_BITS: | 261 case FXDC_DITHER_BITS: |
262 return m_DitherBits; | 262 return m_DitherBits; |
263 } | 263 } |
264 return 0; | 264 return 0; |
265 } | 265 } |
266 void CFX_AggDeviceDriver::SaveState() | 266 void CFX_AggDeviceDriver::SaveState() |
267 { | 267 { |
268 void* pClip = NULL; | 268 void* pClip = NULL; |
269 if (m_pClipRgn) { | 269 if (m_pClipRgn) { |
270 pClip = FX_NEW CFX_ClipRgn(*m_pClipRgn); | 270 pClip = new CFX_ClipRgn(*m_pClipRgn); |
271 if (!pClip) { | |
272 return; | |
273 } | |
274 } | 271 } |
275 m_StateStack.Add(pClip); | 272 m_StateStack.Add(pClip); |
276 } | 273 } |
277 void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) | 274 void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) |
278 { | 275 { |
279 if (m_StateStack.GetSize() == 0) { | 276 if (m_StateStack.GetSize() == 0) { |
280 if (m_pClipRgn) { | 277 if (m_pClipRgn) { |
281 delete m_pClipRgn; | 278 delete m_pClipRgn; |
282 m_pClipRgn = NULL; | 279 m_pClipRgn = NULL; |
283 } | 280 } |
284 return; | 281 return; |
285 } | 282 } |
286 CFX_ClipRgn* pSavedClip = (CFX_ClipRgn*)m_StateStack[m_StateStack.GetSize()
- 1]; | 283 CFX_ClipRgn* pSavedClip = (CFX_ClipRgn*)m_StateStack[m_StateStack.GetSize()
- 1]; |
287 if (m_pClipRgn) { | 284 if (m_pClipRgn) { |
288 delete m_pClipRgn; | 285 delete m_pClipRgn; |
289 m_pClipRgn = NULL; | 286 m_pClipRgn = NULL; |
290 } | 287 } |
291 if (bKeepSaved) { | 288 if (bKeepSaved) { |
292 if (pSavedClip) { | 289 if (pSavedClip) { |
293 m_pClipRgn = FX_NEW CFX_ClipRgn(*pSavedClip); | 290 m_pClipRgn = new CFX_ClipRgn(*pSavedClip); |
294 } | 291 } |
295 } else { | 292 } else { |
296 m_StateStack.RemoveAt(m_StateStack.GetSize() - 1); | 293 m_StateStack.RemoveAt(m_StateStack.GetSize() - 1); |
297 m_pClipRgn = pSavedClip; | 294 m_pClipRgn = pSavedClip; |
298 } | 295 } |
299 } | 296 } |
300 void CFX_AggDeviceDriver::SetClipMask(agg::rasterizer_scanline_aa& rasterizer) | 297 void CFX_AggDeviceDriver::SetClipMask(agg::rasterizer_scanline_aa& rasterizer) |
301 { | 298 { |
302 FX_RECT path_rect(rasterizer.min_x(), rasterizer.min_y(), | 299 FX_RECT path_rect(rasterizer.min_x(), rasterizer.min_y(), |
303 rasterizer.max_x() + 1, rasterizer.max_y() + 1); | 300 rasterizer.max_x() + 1, rasterizer.max_y() + 1); |
(...skipping 14 matching lines...) Expand all Loading... |
318 agg::render_scanlines(rasterizer, scanline, final_render, (m_FillFlags & FXF
ILL_NOPATHSMOOTH) != 0); | 315 agg::render_scanlines(rasterizer, scanline, final_render, (m_FillFlags & FXF
ILL_NOPATHSMOOTH) != 0); |
319 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); | 316 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); |
320 } | 317 } |
321 FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, | 318 FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, |
322 const CFX_AffineMatrix* pObject2Device, | 319 const CFX_AffineMatrix* pObject2Device, |
323 int fill_mode | 320 int fill_mode |
324 ) | 321 ) |
325 { | 322 { |
326 m_FillFlags = fill_mode; | 323 m_FillFlags = fill_mode; |
327 if (m_pClipRgn == NULL) { | 324 if (m_pClipRgn == NULL) { |
328 m_pClipRgn = FX_NEW CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDevi
ceCaps(FXDC_PIXEL_HEIGHT)); | 325 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceC
aps(FXDC_PIXEL_HEIGHT)); |
329 if (!m_pClipRgn) { | |
330 return FALSE; | |
331 } | |
332 } | 326 } |
333 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { | 327 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { |
334 CFX_FloatRect rectf; | 328 CFX_FloatRect rectf; |
335 if (pPathData->IsRect(pObject2Device, &rectf)) { | 329 if (pPathData->IsRect(pObject2Device, &rectf)) { |
336 rectf.Intersect(CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIX
EL_WIDTH), (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 330 rectf.Intersect(CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIX
EL_WIDTH), (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
337 FX_RECT rect = rectf.GetOutterRect(); | 331 FX_RECT rect = rectf.GetOutterRect(); |
338 m_pClipRgn->IntersectRect(rect); | 332 m_pClipRgn->IntersectRect(rect); |
339 return TRUE; | 333 return TRUE; |
340 } | 334 } |
341 } | 335 } |
342 CAgg_PathData path_data; | 336 CAgg_PathData path_data; |
343 path_data.BuildPath(pPathData, pObject2Device); | 337 path_data.BuildPath(pPathData, pObject2Device); |
344 path_data.m_PathData.end_poly(); | 338 path_data.m_PathData.end_poly(); |
345 agg::rasterizer_scanline_aa rasterizer; | 339 agg::rasterizer_scanline_aa rasterizer; |
346 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
(FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 340 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
(FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
347 rasterizer.add_path(path_data.m_PathData); | 341 rasterizer.add_path(path_data.m_PathData); |
348 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING ? agg::fill_non_ze
ro : agg::fill_even_odd); | 342 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING ? agg::fill_non_ze
ro : agg::fill_even_odd); |
349 SetClipMask(rasterizer); | 343 SetClipMask(rasterizer); |
350 return TRUE; | 344 return TRUE; |
351 } | 345 } |
352 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData, | 346 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke(const CFX_PathData* pPathData, |
353 const CFX_AffineMatrix* pObject2Device, | 347 const CFX_AffineMatrix* pObject2Device, |
354 const CFX_GraphStateData* pGraphState | 348 const CFX_GraphStateData* pGraphState |
355 ) | 349 ) |
356 { | 350 { |
357 if (m_pClipRgn == NULL) { | 351 if (m_pClipRgn == NULL) { |
358 m_pClipRgn = FX_NEW CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDevi
ceCaps(FXDC_PIXEL_HEIGHT)); | 352 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceC
aps(FXDC_PIXEL_HEIGHT)); |
359 if (!m_pClipRgn) { | |
360 return FALSE; | |
361 } | |
362 } | 353 } |
363 CAgg_PathData path_data; | 354 CAgg_PathData path_data; |
364 path_data.BuildPath(pPathData, NULL); | 355 path_data.BuildPath(pPathData, NULL); |
365 agg::rasterizer_scanline_aa rasterizer; | 356 agg::rasterizer_scanline_aa rasterizer; |
366 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
(FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 357 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)),
(FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
367 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, pGraphStat
e); | 358 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, pGraphStat
e); |
368 rasterizer.filling_rule(agg::fill_non_zero); | 359 rasterizer.filling_rule(agg::fill_non_zero); |
369 SetClipMask(rasterizer); | 360 SetClipMask(rasterizer); |
370 return TRUE; | 361 return TRUE; |
371 } | 362 } |
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 } | 1549 } |
1559 return TRUE; | 1550 return TRUE; |
1560 } | 1551 } |
1561 FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, int bitma
p_alpha, FX_DWORD argb, | 1552 FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, int bitma
p_alpha, FX_DWORD argb, |
1562 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, FX_LPVOID& handl
e, | 1553 const CFX_AffineMatrix* pMatrix, FX_DWORD render_flags, FX_LPVOID& handl
e, |
1563 int alpha_flag, void* pIccTransform, int blend_type) | 1554 int alpha_flag, void* pIccTransform, int blend_type) |
1564 { | 1555 { |
1565 if (m_pBitmap->GetBuffer() == NULL) { | 1556 if (m_pBitmap->GetBuffer() == NULL) { |
1566 return TRUE; | 1557 return TRUE; |
1567 } | 1558 } |
1568 CFX_ImageRenderer* pRenderer = FX_NEW CFX_ImageRenderer; | 1559 CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer; |
1569 if (!pRenderer) { | |
1570 return FALSE; | |
1571 } | |
1572 pRenderer->Start(m_pBitmap, m_pClipRgn, pSource, bitmap_alpha, argb, pMatrix
, render_flags, m_bRgbByteOrder, alpha_flag, pIccTransform); | 1560 pRenderer->Start(m_pBitmap, m_pClipRgn, pSource, bitmap_alpha, argb, pMatrix
, render_flags, m_bRgbByteOrder, alpha_flag, pIccTransform); |
1573 handle = pRenderer; | 1561 handle = pRenderer; |
1574 return TRUE; | 1562 return TRUE; |
1575 } | 1563 } |
1576 FX_BOOL CFX_AggDeviceDriver::ContinueDIBits(FX_LPVOID pHandle, IFX_Pause* pPause
) | 1564 FX_BOOL CFX_AggDeviceDriver::ContinueDIBits(FX_LPVOID pHandle, IFX_Pause* pPause
) |
1577 { | 1565 { |
1578 if (m_pBitmap->GetBuffer() == NULL) { | 1566 if (m_pBitmap->GetBuffer() == NULL) { |
1579 return TRUE; | 1567 return TRUE; |
1580 } | 1568 } |
1581 return ((CFX_ImageRenderer*)pHandle)->Continue(pPause); | 1569 return ((CFX_ImageRenderer*)pHandle)->Continue(pPause); |
1582 } | 1570 } |
1583 void CFX_AggDeviceDriver::CancelDIBits(FX_LPVOID pHandle) | 1571 void CFX_AggDeviceDriver::CancelDIBits(FX_LPVOID pHandle) |
1584 { | 1572 { |
1585 if (m_pBitmap->GetBuffer() == NULL) { | 1573 if (m_pBitmap->GetBuffer() == NULL) { |
1586 return; | 1574 return; |
1587 } | 1575 } |
1588 delete (CFX_ImageRenderer*)pHandle; | 1576 delete (CFX_ImageRenderer*)pHandle; |
1589 } | 1577 } |
1590 CFX_FxgeDevice::CFX_FxgeDevice() | 1578 CFX_FxgeDevice::CFX_FxgeDevice() |
1591 { | 1579 { |
1592 m_bOwnedBitmap = FALSE; | 1580 m_bOwnedBitmap = FALSE; |
1593 } | 1581 } |
1594 FX_BOOL CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL b
RgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) | 1582 FX_BOOL CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, int dither_bits, FX_BOOL b
RgbByteOrder, CFX_DIBitmap* pOriDevice, FX_BOOL bGroupKnockout) |
1595 { | 1583 { |
1596 if (pBitmap == NULL) { | 1584 if (pBitmap == NULL) { |
1597 return FALSE; | 1585 return FALSE; |
1598 } | 1586 } |
1599 SetBitmap(pBitmap); | 1587 SetBitmap(pBitmap); |
1600 IFX_RenderDeviceDriver* pDriver = FX_NEW CFX_AggDeviceDriver(pBitmap, dither
_bits, bRgbByteOrder, pOriDevice, bGroupKnockout); | 1588 IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(pBitmap, dither_bi
ts, bRgbByteOrder, pOriDevice, bGroupKnockout); |
1601 if (!pDriver) { | |
1602 return FALSE; | |
1603 } | |
1604 SetDeviceDriver(pDriver); | 1589 SetDeviceDriver(pDriver); |
1605 return TRUE; | 1590 return TRUE; |
1606 } | 1591 } |
1607 FX_BOOL CFX_FxgeDevice::Create(int width, int height, FXDIB_Format format, int d
ither_bits, CFX_DIBitmap* pOriDevice) | 1592 FX_BOOL CFX_FxgeDevice::Create(int width, int height, FXDIB_Format format, int d
ither_bits, CFX_DIBitmap* pOriDevice) |
1608 { | 1593 { |
1609 m_bOwnedBitmap = TRUE; | 1594 m_bOwnedBitmap = TRUE; |
1610 CFX_DIBitmap* pBitmap = FX_NEW CFX_DIBitmap; | 1595 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
1611 if (!pBitmap) { | |
1612 return FALSE; | |
1613 } | |
1614 if (!pBitmap->Create(width, height, format)) { | 1596 if (!pBitmap->Create(width, height, format)) { |
1615 delete pBitmap; | 1597 delete pBitmap; |
1616 return FALSE; | 1598 return FALSE; |
1617 } | 1599 } |
1618 SetBitmap(pBitmap); | 1600 SetBitmap(pBitmap); |
1619 IFX_RenderDeviceDriver* pDriver = FX_NEW CFX_AggDeviceDriver(pBitmap, dither
_bits, FALSE, pOriDevice, FALSE); | 1601 IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver(pBitmap, dither_bi
ts, FALSE, pOriDevice, FALSE); |
1620 if (!pDriver) { | |
1621 return FALSE; | |
1622 } | |
1623 SetDeviceDriver(pDriver); | 1602 SetDeviceDriver(pDriver); |
1624 return TRUE; | 1603 return TRUE; |
1625 } | 1604 } |
1626 CFX_FxgeDevice::~CFX_FxgeDevice() | 1605 CFX_FxgeDevice::~CFX_FxgeDevice() |
1627 { | 1606 { |
1628 if (m_bOwnedBitmap && GetBitmap()) { | 1607 if (m_bOwnedBitmap && GetBitmap()) { |
1629 delete GetBitmap(); | 1608 delete GetBitmap(); |
1630 } | 1609 } |
1631 } | 1610 } |
OLD | NEW |