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 #include <algorithm> | 10 #include <algorithm> |
(...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 dest_scan--; | 1454 dest_scan--; |
1455 src_scan++; | 1455 src_scan++; |
1456 } | 1456 } |
1457 } | 1457 } |
1458 } | 1458 } |
1459 return pFlipped; | 1459 return pFlipped; |
1460 } | 1460 } |
1461 | 1461 |
1462 CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { | 1462 CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { |
1463 if (pSrc->GetBuffer()) { | 1463 if (pSrc->GetBuffer()) { |
1464 m_pBitmap.reset(new CFX_DIBitmap); | 1464 m_pBitmap = WrapUnique(new CFX_DIBitmap); |
1465 if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), | 1465 if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), |
1466 pSrc->GetFormat(), pSrc->GetBuffer())) { | 1466 pSrc->GetFormat(), pSrc->GetBuffer())) { |
1467 m_pBitmap.reset(); | 1467 m_pBitmap.reset(); |
1468 return; | 1468 return; |
1469 } | 1469 } |
1470 m_pBitmap->CopyPalette(pSrc->GetPalette()); | 1470 m_pBitmap->CopyPalette(pSrc->GetPalette()); |
1471 m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask); | 1471 m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask); |
1472 } else { | 1472 } else { |
1473 m_pBitmap.reset(pSrc->Clone()); | 1473 m_pBitmap.reset(pSrc->Clone()); |
1474 } | 1474 } |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f) { | 1560 FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f) { |
1561 int dest_width = image_rect.Width(); | 1561 int dest_width = image_rect.Width(); |
1562 int dest_height = image_rect.Height(); | 1562 int dest_height = image_rect.Height(); |
1563 FX_RECT bitmap_clip = m_ClipBox; | 1563 FX_RECT bitmap_clip = m_ClipBox; |
1564 bitmap_clip.Offset(-image_rect.left, -image_rect.top); | 1564 bitmap_clip.Offset(-image_rect.left, -image_rect.top); |
1565 bitmap_clip = FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_height, | 1565 bitmap_clip = FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_height, |
1566 m_Matrix.c > 0, m_Matrix.b < 0); | 1566 m_Matrix.c > 0, m_Matrix.b < 0); |
1567 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, | 1567 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, |
1568 TRUE, m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder, | 1568 TRUE, m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder, |
1569 alpha_flag, pIccTransform, m_BlendType); | 1569 alpha_flag, pIccTransform, m_BlendType); |
1570 m_Stretcher.reset(new CFX_ImageStretcher(&m_Composer, pSource, | 1570 m_Stretcher = WrapUnique(new CFX_ImageStretcher(&m_Composer, pSource, |
1571 dest_height, dest_width, | 1571 dest_height, dest_width, |
1572 bitmap_clip, dib_flags)); | 1572 bitmap_clip, dib_flags)); |
1573 if (!m_Stretcher->Start()) | 1573 if (!m_Stretcher->Start()) |
1574 return FALSE; | 1574 return FALSE; |
1575 | 1575 |
1576 m_Status = 1; | 1576 m_Status = 1; |
1577 return TRUE; | 1577 return TRUE; |
1578 } | 1578 } |
1579 m_Status = 2; | 1579 m_Status = 2; |
1580 m_pTransformer.reset( | 1580 m_pTransformer.reset( |
1581 new CFX_ImageTransformer(pSource, &m_Matrix, dib_flags, &m_ClipBox)); | 1581 new CFX_ImageTransformer(pSource, &m_Matrix, dib_flags, &m_ClipBox)); |
1582 m_pTransformer->Start(); | 1582 m_pTransformer->Start(); |
(...skipping 10 matching lines...) Expand all Loading... |
1593 | 1593 |
1594 if (dest_width == 0 || dest_height == 0) | 1594 if (dest_width == 0 || dest_height == 0) |
1595 return FALSE; | 1595 return FALSE; |
1596 | 1596 |
1597 FX_RECT bitmap_clip = m_ClipBox; | 1597 FX_RECT bitmap_clip = m_ClipBox; |
1598 bitmap_clip.Offset(-image_rect.left, -image_rect.top); | 1598 bitmap_clip.Offset(-image_rect.left, -image_rect.top); |
1599 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, | 1599 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, |
1600 FALSE, FALSE, FALSE, m_bRgbByteOrder, alpha_flag, | 1600 FALSE, FALSE, FALSE, m_bRgbByteOrder, alpha_flag, |
1601 pIccTransform, m_BlendType); | 1601 pIccTransform, m_BlendType); |
1602 m_Status = 1; | 1602 m_Status = 1; |
1603 m_Stretcher.reset(new CFX_ImageStretcher( | 1603 m_Stretcher = WrapUnique(new CFX_ImageStretcher( |
1604 &m_Composer, pSource, dest_width, dest_height, bitmap_clip, dib_flags)); | 1604 &m_Composer, pSource, dest_width, dest_height, bitmap_clip, dib_flags)); |
1605 return m_Stretcher->Start(); | 1605 return m_Stretcher->Start(); |
1606 } | 1606 } |
1607 | 1607 |
1608 FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) { | 1608 FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) { |
1609 if (m_Status == 1) | 1609 if (m_Status == 1) |
1610 return m_Stretcher->Continue(pPause); | 1610 return m_Stretcher->Continue(pPause); |
1611 | 1611 |
1612 if (m_Status == 2) { | 1612 if (m_Status == 2) { |
1613 if (m_pTransformer->Continue(pPause)) | 1613 if (m_pTransformer->Continue(pPause)) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 if (dest_alpha_buf) { | 1673 if (dest_alpha_buf) { |
1674 FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha, | 1674 FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha, |
1675 m_pBitmap->m_pAlphaMask->GetPitch()); | 1675 m_pBitmap->m_pAlphaMask->GetPitch()); |
1676 } | 1676 } |
1677 } | 1677 } |
1678 | 1678 |
1679 FX_BOOL CFX_BitmapStorer::SetInfo(int width, | 1679 FX_BOOL CFX_BitmapStorer::SetInfo(int width, |
1680 int height, | 1680 int height, |
1681 FXDIB_Format src_format, | 1681 FXDIB_Format src_format, |
1682 uint32_t* pSrcPalette) { | 1682 uint32_t* pSrcPalette) { |
1683 m_pBitmap.reset(new CFX_DIBitmap); | 1683 m_pBitmap = WrapUnique(new CFX_DIBitmap); |
1684 if (!m_pBitmap->Create(width, height, src_format)) { | 1684 if (!m_pBitmap->Create(width, height, src_format)) { |
1685 m_pBitmap.reset(); | 1685 m_pBitmap.reset(); |
1686 return FALSE; | 1686 return FALSE; |
1687 } | 1687 } |
1688 if (pSrcPalette) | 1688 if (pSrcPalette) |
1689 m_pBitmap->CopyPalette(pSrcPalette); | 1689 m_pBitmap->CopyPalette(pSrcPalette); |
1690 return TRUE; | 1690 return TRUE; |
1691 } | 1691 } |
OLD | NEW |