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 #include <utility> | 10 #include <utility> |
(...skipping 1584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1595 *pRect = m_pClipRgn->GetBox(); | 1595 *pRect = m_pClipRgn->GetBox(); |
1596 return true; | 1596 return true; |
1597 } | 1597 } |
1598 | 1598 |
1599 bool CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { | 1599 bool CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { |
1600 if (!m_pBitmap || !m_pBitmap->GetBuffer()) | 1600 if (!m_pBitmap || !m_pBitmap->GetBuffer()) |
1601 return true; | 1601 return true; |
1602 | 1602 |
1603 FX_RECT rect(left, top, left + pBitmap->GetWidth(), | 1603 FX_RECT rect(left, top, left + pBitmap->GetWidth(), |
1604 top + pBitmap->GetHeight()); | 1604 top + pBitmap->GetHeight()); |
1605 CFX_DIBitmap* pBack = nullptr; | 1605 std::unique_ptr<CFX_DIBitmap> pBack; |
1606 if (m_pOriDevice) { | 1606 if (m_pOriDevice) { |
1607 pBack = m_pOriDevice->Clone(&rect); | 1607 pBack = m_pOriDevice->Clone(&rect); |
1608 if (!pBack) | 1608 if (!pBack) |
1609 return true; | 1609 return true; |
1610 | 1610 |
1611 pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(), | 1611 pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(), |
1612 m_pBitmap, 0, 0); | 1612 m_pBitmap, 0, 0); |
1613 } else { | 1613 } else { |
1614 pBack = m_pBitmap->Clone(&rect); | 1614 pBack = m_pBitmap->Clone(&rect); |
1615 if (!pBack) | 1615 if (!pBack) |
1616 return true; | 1616 return true; |
1617 } | 1617 } |
1618 | 1618 |
1619 bool bRet = true; | |
1620 left = std::min(left, 0); | 1619 left = std::min(left, 0); |
1621 top = std::min(top, 0); | 1620 top = std::min(top, 0); |
1622 if (m_bRgbByteOrder) { | 1621 if (m_bRgbByteOrder) { |
1623 RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(), | 1622 RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(), |
1624 pBack, left, top); | 1623 pBack.get(), left, top); |
1625 } else { | 1624 return true; |
1626 bRet = pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack, | |
1627 left, top); | |
1628 } | 1625 } |
1629 delete pBack; | 1626 return pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack.get(), |
1630 return bRet; | 1627 left, top); |
1631 } | 1628 } |
1632 | 1629 |
1633 CFX_DIBitmap* CFX_AggDeviceDriver::GetBackDrop() { | 1630 CFX_DIBitmap* CFX_AggDeviceDriver::GetBackDrop() { |
1634 return m_pOriDevice; | 1631 return m_pOriDevice; |
1635 } | 1632 } |
1636 | 1633 |
1637 bool CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, | 1634 bool CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, |
1638 uint32_t argb, | 1635 uint32_t argb, |
1639 const FX_RECT* pSrcRect, | 1636 const FX_RECT* pSrcRect, |
1640 int left, | 1637 int left, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1751 pOriDevice, false)); | 1748 pOriDevice, false)); |
1752 return true; | 1749 return true; |
1753 } | 1750 } |
1754 | 1751 |
1755 CFX_FxgeDevice::~CFX_FxgeDevice() { | 1752 CFX_FxgeDevice::~CFX_FxgeDevice() { |
1756 if (m_bOwnedBitmap) { | 1753 if (m_bOwnedBitmap) { |
1757 delete GetBitmap(); | 1754 delete GetBitmap(); |
1758 } | 1755 } |
1759 } | 1756 } |
1760 #endif | 1757 #endif |
OLD | NEW |