Chromium Code Reviews| 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/include/fx_dib.h" | 7 #include "core/fxge/include/fx_dib.h" |
| 8 | 8 |
| 9 #include <limits.h> | 9 #include <limits.h> |
| 10 | 10 |
| (...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1601 FX_BOOL bRgbByteOrder, | 1601 FX_BOOL bRgbByteOrder, |
| 1602 int alpha_flag, | 1602 int alpha_flag, |
| 1603 void* pIccTransform, | 1603 void* pIccTransform, |
| 1604 int blend_type) { | 1604 int blend_type) { |
| 1605 m_Matrix = *pMatrix; | 1605 m_Matrix = *pMatrix; |
| 1606 CFX_FloatRect image_rect_f = m_Matrix.GetUnitRect(); | 1606 CFX_FloatRect image_rect_f = m_Matrix.GetUnitRect(); |
| 1607 FX_RECT image_rect = image_rect_f.GetOutterRect(); | 1607 FX_RECT image_rect = image_rect_f.GetOutterRect(); |
| 1608 m_ClipBox = pClipRgn ? pClipRgn->GetBox() : FX_RECT(0, 0, pDevice->GetWidth(), | 1608 m_ClipBox = pClipRgn ? pClipRgn->GetBox() : FX_RECT(0, 0, pDevice->GetWidth(), |
| 1609 pDevice->GetHeight()); | 1609 pDevice->GetHeight()); |
| 1610 m_ClipBox.Intersect(image_rect); | 1610 m_ClipBox.Intersect(image_rect); |
| 1611 if (m_ClipBox.IsEmpty()) { | 1611 if (m_ClipBox.IsEmpty()) |
| 1612 return FALSE; | 1612 return FALSE; |
| 1613 } | 1613 |
| 1614 m_pDevice = pDevice; | 1614 m_pDevice = pDevice; |
| 1615 m_pClipRgn = pClipRgn; | 1615 m_pClipRgn = pClipRgn; |
| 1616 m_MaskColor = mask_color; | 1616 m_MaskColor = mask_color; |
| 1617 m_BitmapAlpha = bitmap_alpha; | 1617 m_BitmapAlpha = bitmap_alpha; |
| 1618 m_Matrix = *pMatrix; | 1618 m_Matrix = *pMatrix; |
| 1619 m_Flags = dib_flags; | 1619 m_Flags = dib_flags; |
| 1620 m_AlphaFlag = alpha_flag; | 1620 m_AlphaFlag = alpha_flag; |
| 1621 m_pIccTransform = pIccTransform; | 1621 m_pIccTransform = pIccTransform; |
| 1622 m_bRgbByteOrder = bRgbByteOrder; | 1622 m_bRgbByteOrder = bRgbByteOrder; |
| 1623 m_BlendType = blend_type; | 1623 m_BlendType = blend_type; |
| 1624 FX_BOOL ret = TRUE; | 1624 |
| 1625 if ((FXSYS_fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) || | 1625 if ((FXSYS_fabs(m_Matrix.b) >= 0.5f || m_Matrix.a == 0) || |
| 1626 (FXSYS_fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0)) { | 1626 (FXSYS_fabs(m_Matrix.c) >= 0.5f || m_Matrix.d == 0)) { |
| 1627 if (FXSYS_fabs(m_Matrix.a) < FXSYS_fabs(m_Matrix.b) / 20 && | 1627 if (FXSYS_fabs(m_Matrix.a) < FXSYS_fabs(m_Matrix.b) / 20 && |
| 1628 FXSYS_fabs(m_Matrix.d) < FXSYS_fabs(m_Matrix.c) / 20 && | 1628 FXSYS_fabs(m_Matrix.d) < FXSYS_fabs(m_Matrix.c) / 20 && |
| 1629 FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f) { | 1629 FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f) { |
| 1630 int dest_width = image_rect.Width(); | 1630 int dest_width = image_rect.Width(); |
| 1631 int dest_height = image_rect.Height(); | 1631 int dest_height = image_rect.Height(); |
| 1632 FX_RECT bitmap_clip = m_ClipBox; | 1632 FX_RECT bitmap_clip = m_ClipBox; |
| 1633 bitmap_clip.Offset(-image_rect.left, -image_rect.top); | 1633 bitmap_clip.Offset(-image_rect.left, -image_rect.top); |
| 1634 bitmap_clip = FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_height, | 1634 bitmap_clip = FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_height, |
| 1635 m_Matrix.c > 0, m_Matrix.b < 0); | 1635 m_Matrix.c > 0, m_Matrix.b < 0); |
| 1636 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, | 1636 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, |
| 1637 TRUE, m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder, | 1637 TRUE, m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder, |
| 1638 alpha_flag, pIccTransform, m_BlendType); | 1638 alpha_flag, pIccTransform, m_BlendType); |
| 1639 if (!m_Stretcher.Start(&m_Composer, pSource, dest_height, dest_width, | 1639 m_Stretcher.reset(new CFX_ImageStretcher(&m_Composer, pSource, |
| 1640 bitmap_clip, dib_flags)) { | 1640 dest_height, dest_width, |
| 1641 bitmap_clip, dib_flags)); | |
| 1642 if (!m_Stretcher->Start()) | |
| 1641 return FALSE; | 1643 return FALSE; |
| 1642 } | 1644 |
| 1643 m_Status = 1; | 1645 m_Status = 1; |
| 1644 return TRUE; | 1646 return TRUE; |
| 1645 } | 1647 } |
| 1646 m_Status = 2; | 1648 m_Status = 2; |
| 1647 m_pTransformer = new CFX_ImageTransformer; | 1649 m_pTransformer = new CFX_ImageTransformer; |
| 1648 m_pTransformer->Start(pSource, &m_Matrix, dib_flags, &m_ClipBox); | 1650 m_pTransformer->Start(pSource, &m_Matrix, dib_flags, &m_ClipBox); |
|
Tom Sepez
2016/05/12 00:03:08
Looks like the same cleanup could be applied here.
Lei Zhang
2016/05/12 01:17:13
Yep, but that'll have to be another day.
| |
| 1649 return TRUE; | 1651 return TRUE; |
| 1650 } | 1652 } |
| 1653 | |
| 1651 int dest_width = image_rect.Width(); | 1654 int dest_width = image_rect.Width(); |
| 1652 if (m_Matrix.a < 0) { | 1655 if (m_Matrix.a < 0) |
| 1653 dest_width = -dest_width; | 1656 dest_width = -dest_width; |
| 1654 } | 1657 |
| 1655 int dest_height = image_rect.Height(); | 1658 int dest_height = image_rect.Height(); |
| 1656 if (m_Matrix.d > 0) { | 1659 if (m_Matrix.d > 0) |
| 1657 dest_height = -dest_height; | 1660 dest_height = -dest_height; |
| 1658 } | 1661 |
| 1659 if (dest_width == 0 || dest_height == 0) { | 1662 if (dest_width == 0 || dest_height == 0) |
| 1660 return FALSE; | 1663 return FALSE; |
| 1661 } | 1664 |
| 1662 FX_RECT bitmap_clip = m_ClipBox; | 1665 FX_RECT bitmap_clip = m_ClipBox; |
| 1663 bitmap_clip.Offset(-image_rect.left, -image_rect.top); | 1666 bitmap_clip.Offset(-image_rect.left, -image_rect.top); |
| 1664 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, | 1667 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, |
| 1665 FALSE, FALSE, FALSE, m_bRgbByteOrder, alpha_flag, | 1668 FALSE, FALSE, FALSE, m_bRgbByteOrder, alpha_flag, |
| 1666 pIccTransform, m_BlendType); | 1669 pIccTransform, m_BlendType); |
| 1667 m_Status = 1; | 1670 m_Status = 1; |
| 1668 ret = m_Stretcher.Start(&m_Composer, pSource, dest_width, dest_height, | 1671 m_Stretcher.reset(new CFX_ImageStretcher( |
| 1669 bitmap_clip, dib_flags); | 1672 &m_Composer, pSource, dest_width, dest_height, bitmap_clip, dib_flags)); |
| 1670 return ret; | 1673 return m_Stretcher->Start(); |
| 1671 } | 1674 } |
| 1675 | |
| 1672 FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) { | 1676 FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) { |
| 1673 if (m_Status == 1) { | 1677 if (m_Status == 1) |
| 1674 return m_Stretcher.Continue(pPause); | 1678 return m_Stretcher->Continue(pPause); |
| 1675 } | 1679 |
| 1676 if (m_Status == 2) { | 1680 if (m_Status == 2) { |
| 1677 if (m_pTransformer->Continue(pPause)) { | 1681 if (m_pTransformer->Continue(pPause)) { |
| 1678 return TRUE; | 1682 return TRUE; |
| 1679 } | 1683 } |
| 1680 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); | 1684 CFX_DIBitmap* pBitmap = m_pTransformer->m_Storer.Detach(); |
| 1681 if (!pBitmap) { | 1685 if (!pBitmap) { |
| 1682 return FALSE; | 1686 return FALSE; |
| 1683 } | 1687 } |
| 1684 if (!pBitmap->GetBuffer()) { | 1688 if (!pBitmap->GetBuffer()) { |
| 1685 delete pBitmap; | 1689 delete pBitmap; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1753 if (!m_pBitmap->Create(width, height, src_format)) { | 1757 if (!m_pBitmap->Create(width, height, src_format)) { |
| 1754 delete m_pBitmap; | 1758 delete m_pBitmap; |
| 1755 m_pBitmap = NULL; | 1759 m_pBitmap = NULL; |
| 1756 return FALSE; | 1760 return FALSE; |
| 1757 } | 1761 } |
| 1758 if (pSrcPalette) { | 1762 if (pSrcPalette) { |
| 1759 m_pBitmap->CopyPalette(pSrcPalette); | 1763 m_pBitmap->CopyPalette(pSrcPalette); |
| 1760 } | 1764 } |
| 1761 return TRUE; | 1765 return TRUE; |
| 1762 } | 1766 } |
| OLD | NEW |