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 "core/fxge/agg/fx_agg_driver.h" | 7 #include "core/fxge/agg/fx_agg_driver.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 491 } |
492 return flags; | 492 return flags; |
493 } | 493 } |
494 } | 494 } |
495 return 0; | 495 return 0; |
496 } | 496 } |
497 | 497 |
498 void CFX_AggDeviceDriver::SaveState() { | 498 void CFX_AggDeviceDriver::SaveState() { |
499 std::unique_ptr<CFX_ClipRgn> pClip; | 499 std::unique_ptr<CFX_ClipRgn> pClip; |
500 if (m_pClipRgn) | 500 if (m_pClipRgn) |
501 pClip.reset(new CFX_ClipRgn(*m_pClipRgn)); | 501 pClip = WrapUnique(new CFX_ClipRgn(*m_pClipRgn)); |
502 m_StateStack.push_back(std::move(pClip)); | 502 m_StateStack.push_back(std::move(pClip)); |
503 } | 503 } |
504 | 504 |
505 void CFX_AggDeviceDriver::RestoreState(bool bKeepSaved) { | 505 void CFX_AggDeviceDriver::RestoreState(bool bKeepSaved) { |
506 m_pClipRgn.reset(); | 506 m_pClipRgn.reset(); |
507 | 507 |
508 if (m_StateStack.empty()) | 508 if (m_StateStack.empty()) |
509 return; | 509 return; |
510 | 510 |
511 if (bKeepSaved) { | 511 if (bKeepSaved) { |
512 if (m_StateStack.back()) | 512 if (m_StateStack.back()) |
513 m_pClipRgn.reset(new CFX_ClipRgn(*m_StateStack.back())); | 513 m_pClipRgn = WrapUnique(new CFX_ClipRgn(*m_StateStack.back())); |
514 } else { | 514 } else { |
515 m_pClipRgn = std::move(m_StateStack.back()); | 515 m_pClipRgn = std::move(m_StateStack.back()); |
516 m_StateStack.pop_back(); | 516 m_StateStack.pop_back(); |
517 } | 517 } |
518 } | 518 } |
519 | 519 |
520 void CFX_AggDeviceDriver::SetClipMask(agg::rasterizer_scanline_aa& rasterizer) { | 520 void CFX_AggDeviceDriver::SetClipMask(agg::rasterizer_scanline_aa& rasterizer) { |
521 FX_RECT path_rect(rasterizer.min_x(), rasterizer.min_y(), | 521 FX_RECT path_rect(rasterizer.min_x(), rasterizer.min_y(), |
522 rasterizer.max_x() + 1, rasterizer.max_y() + 1); | 522 rasterizer.max_x() + 1, rasterizer.max_y() + 1); |
523 path_rect.Intersect(m_pClipRgn->GetBox()); | 523 path_rect.Intersect(m_pClipRgn->GetBox()); |
(...skipping 13 matching lines...) Expand all Loading... |
537 agg::render_scanlines(rasterizer, scanline, final_render, | 537 agg::render_scanlines(rasterizer, scanline, final_render, |
538 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); | 538 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); |
539 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); | 539 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); |
540 } | 540 } |
541 | 541 |
542 FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, | 542 FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, |
543 const CFX_Matrix* pObject2Device, | 543 const CFX_Matrix* pObject2Device, |
544 int fill_mode) { | 544 int fill_mode) { |
545 m_FillFlags = fill_mode; | 545 m_FillFlags = fill_mode; |
546 if (!m_pClipRgn) { | 546 if (!m_pClipRgn) { |
547 m_pClipRgn.reset(new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), | 547 m_pClipRgn = WrapUnique(new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), |
548 GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 548 GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
549 } | 549 } |
550 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { | 550 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { |
551 CFX_FloatRect rectf; | 551 CFX_FloatRect rectf; |
552 if (pPathData->IsRect(pObject2Device, &rectf)) { | 552 if (pPathData->IsRect(pObject2Device, &rectf)) { |
553 rectf.Intersect( | 553 rectf.Intersect( |
554 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), | 554 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), |
555 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 555 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
556 FX_RECT rect = rectf.GetOuterRect(); | 556 FX_RECT rect = rectf.GetOuterRect(); |
557 m_pClipRgn->IntersectRect(rect); | 557 m_pClipRgn->IntersectRect(rect); |
558 return TRUE; | 558 return TRUE; |
(...skipping 11 matching lines...) Expand all Loading... |
570 : agg::fill_even_odd); | 570 : agg::fill_even_odd); |
571 SetClipMask(rasterizer); | 571 SetClipMask(rasterizer); |
572 return TRUE; | 572 return TRUE; |
573 } | 573 } |
574 | 574 |
575 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke( | 575 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke( |
576 const CFX_PathData* pPathData, | 576 const CFX_PathData* pPathData, |
577 const CFX_Matrix* pObject2Device, | 577 const CFX_Matrix* pObject2Device, |
578 const CFX_GraphStateData* pGraphState) { | 578 const CFX_GraphStateData* pGraphState) { |
579 if (!m_pClipRgn) { | 579 if (!m_pClipRgn) { |
580 m_pClipRgn.reset(new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), | 580 m_pClipRgn = WrapUnique(new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), |
581 GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 581 GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
582 } | 582 } |
583 CAgg_PathData path_data; | 583 CAgg_PathData path_data; |
584 path_data.BuildPath(pPathData, nullptr); | 584 path_data.BuildPath(pPathData, nullptr); |
585 agg::rasterizer_scanline_aa rasterizer; | 585 agg::rasterizer_scanline_aa rasterizer; |
586 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), | 586 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), |
587 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 587 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
588 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, | 588 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, |
589 pGraphState); | 589 pGraphState); |
590 rasterizer.filling_rule(agg::fill_non_zero); | 590 rasterizer.filling_rule(agg::fill_non_zero); |
591 SetClipMask(rasterizer); | 591 SetClipMask(rasterizer); |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 WrapUnique(new CFX_AggDeviceDriver(pBitmap, FALSE, pOriDevice, FALSE))); | 1755 WrapUnique(new CFX_AggDeviceDriver(pBitmap, FALSE, pOriDevice, FALSE))); |
1756 return true; | 1756 return true; |
1757 } | 1757 } |
1758 | 1758 |
1759 CFX_FxgeDevice::~CFX_FxgeDevice() { | 1759 CFX_FxgeDevice::~CFX_FxgeDevice() { |
1760 if (m_bOwnedBitmap) { | 1760 if (m_bOwnedBitmap) { |
1761 delete GetBitmap(); | 1761 delete GetBitmap(); |
1762 } | 1762 } |
1763 } | 1763 } |
1764 #endif | 1764 #endif |
OLD | NEW |