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/fx_dib.h" | 7 #include "core/fxge/fx_dib.h" |
8 | 8 |
9 #include <limits.h> | 9 #include <limits.h> |
10 #include <algorithm> | 10 #include <algorithm> |
11 | 11 |
12 #include "core/fxcodec/fx_codec.h" | 12 #include "core/fxcodec/fx_codec.h" |
13 #include "core/fxge/cfx_gemodule.h" | 13 #include "core/fxge/cfx_gemodule.h" |
14 #include "core/fxge/dib/dib_int.h" | 14 #include "core/fxge/dib/dib_int.h" |
15 #include "core/fxge/ge/cfx_cliprgn.h" | 15 #include "core/fxge/ge/cfx_cliprgn.h" |
| 16 #include "third_party/base/ptr_util.h" |
16 | 17 |
17 void CmykDecode(uint32_t cmyk, int& c, int& m, int& y, int& k) { | 18 void CmykDecode(uint32_t cmyk, int& c, int& m, int& y, int& k) { |
18 c = FXSYS_GetCValue(cmyk); | 19 c = FXSYS_GetCValue(cmyk); |
19 m = FXSYS_GetMValue(cmyk); | 20 m = FXSYS_GetMValue(cmyk); |
20 y = FXSYS_GetYValue(cmyk); | 21 y = FXSYS_GetYValue(cmyk); |
21 k = FXSYS_GetKValue(cmyk); | 22 k = FXSYS_GetKValue(cmyk); |
22 } | 23 } |
23 | 24 |
24 void ArgbDecode(uint32_t argb, int& a, int& r, int& g, int& b) { | 25 void ArgbDecode(uint32_t argb, int& a, int& r, int& g, int& b) { |
25 a = FXARGB_A(argb); | 26 a = FXARGB_A(argb); |
(...skipping 1428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1454 dest_scan--; | 1455 dest_scan--; |
1455 src_scan++; | 1456 src_scan++; |
1456 } | 1457 } |
1457 } | 1458 } |
1458 } | 1459 } |
1459 return pFlipped; | 1460 return pFlipped; |
1460 } | 1461 } |
1461 | 1462 |
1462 CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { | 1463 CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { |
1463 if (pSrc->GetBuffer()) { | 1464 if (pSrc->GetBuffer()) { |
1464 m_pBitmap = WrapUnique(new CFX_DIBitmap); | 1465 m_pBitmap = pdfium::MakeUnique<CFX_DIBitmap>(); |
1465 if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), | 1466 if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), |
1466 pSrc->GetFormat(), pSrc->GetBuffer())) { | 1467 pSrc->GetFormat(), pSrc->GetBuffer())) { |
1467 m_pBitmap.reset(); | 1468 m_pBitmap.reset(); |
1468 return; | 1469 return; |
1469 } | 1470 } |
1470 m_pBitmap->CopyPalette(pSrc->GetPalette()); | 1471 m_pBitmap->CopyPalette(pSrc->GetPalette()); |
1471 m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask); | 1472 m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask); |
1472 } else { | 1473 } else { |
1473 m_pBitmap.reset(pSrc->Clone()); | 1474 m_pBitmap.reset(pSrc->Clone()); |
1474 } | 1475 } |
(...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) { | 1561 FXSYS_fabs(m_Matrix.a) < 0.5f && FXSYS_fabs(m_Matrix.d) < 0.5f) { |
1561 int dest_width = image_rect.Width(); | 1562 int dest_width = image_rect.Width(); |
1562 int dest_height = image_rect.Height(); | 1563 int dest_height = image_rect.Height(); |
1563 FX_RECT bitmap_clip = m_ClipBox; | 1564 FX_RECT bitmap_clip = m_ClipBox; |
1564 bitmap_clip.Offset(-image_rect.left, -image_rect.top); | 1565 bitmap_clip.Offset(-image_rect.left, -image_rect.top); |
1565 bitmap_clip = FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_height, | 1566 bitmap_clip = FXDIB_SwapClipBox(bitmap_clip, dest_width, dest_height, |
1566 m_Matrix.c > 0, m_Matrix.b < 0); | 1567 m_Matrix.c > 0, m_Matrix.b < 0); |
1567 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, | 1568 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, |
1568 TRUE, m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder, | 1569 TRUE, m_Matrix.c > 0, m_Matrix.b < 0, m_bRgbByteOrder, |
1569 alpha_flag, pIccTransform, m_BlendType); | 1570 alpha_flag, pIccTransform, m_BlendType); |
1570 m_Stretcher = WrapUnique(new CFX_ImageStretcher(&m_Composer, pSource, | 1571 m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>( |
1571 dest_height, dest_width, | 1572 &m_Composer, pSource, dest_height, dest_width, bitmap_clip, |
1572 bitmap_clip, dib_flags)); | 1573 dib_flags); |
1573 if (!m_Stretcher->Start()) | 1574 if (!m_Stretcher->Start()) |
1574 return FALSE; | 1575 return FALSE; |
1575 | 1576 |
1576 m_Status = 1; | 1577 m_Status = 1; |
1577 return TRUE; | 1578 return TRUE; |
1578 } | 1579 } |
1579 m_Status = 2; | 1580 m_Status = 2; |
1580 m_pTransformer.reset( | 1581 m_pTransformer.reset( |
1581 new CFX_ImageTransformer(pSource, &m_Matrix, dib_flags, &m_ClipBox)); | 1582 new CFX_ImageTransformer(pSource, &m_Matrix, dib_flags, &m_ClipBox)); |
1582 m_pTransformer->Start(); | 1583 m_pTransformer->Start(); |
(...skipping 10 matching lines...) Expand all Loading... |
1593 | 1594 |
1594 if (dest_width == 0 || dest_height == 0) | 1595 if (dest_width == 0 || dest_height == 0) |
1595 return FALSE; | 1596 return FALSE; |
1596 | 1597 |
1597 FX_RECT bitmap_clip = m_ClipBox; | 1598 FX_RECT bitmap_clip = m_ClipBox; |
1598 bitmap_clip.Offset(-image_rect.left, -image_rect.top); | 1599 bitmap_clip.Offset(-image_rect.left, -image_rect.top); |
1599 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, | 1600 m_Composer.Compose(pDevice, pClipRgn, bitmap_alpha, mask_color, m_ClipBox, |
1600 FALSE, FALSE, FALSE, m_bRgbByteOrder, alpha_flag, | 1601 FALSE, FALSE, FALSE, m_bRgbByteOrder, alpha_flag, |
1601 pIccTransform, m_BlendType); | 1602 pIccTransform, m_BlendType); |
1602 m_Status = 1; | 1603 m_Status = 1; |
1603 m_Stretcher = WrapUnique(new CFX_ImageStretcher( | 1604 m_Stretcher = pdfium::MakeUnique<CFX_ImageStretcher>( |
1604 &m_Composer, pSource, dest_width, dest_height, bitmap_clip, dib_flags)); | 1605 &m_Composer, pSource, dest_width, dest_height, bitmap_clip, dib_flags); |
1605 return m_Stretcher->Start(); | 1606 return m_Stretcher->Start(); |
1606 } | 1607 } |
1607 | 1608 |
1608 FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) { | 1609 FX_BOOL CFX_ImageRenderer::Continue(IFX_Pause* pPause) { |
1609 if (m_Status == 1) | 1610 if (m_Status == 1) |
1610 return m_Stretcher->Continue(pPause); | 1611 return m_Stretcher->Continue(pPause); |
1611 | 1612 |
1612 if (m_Status == 2) { | 1613 if (m_Status == 2) { |
1613 if (m_pTransformer->Continue(pPause)) | 1614 if (m_pTransformer->Continue(pPause)) |
1614 return TRUE; | 1615 return TRUE; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 if (dest_alpha_buf) { | 1674 if (dest_alpha_buf) { |
1674 FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha, | 1675 FXSYS_memcpy(dest_alpha_buf, scan_extra_alpha, |
1675 m_pBitmap->m_pAlphaMask->GetPitch()); | 1676 m_pBitmap->m_pAlphaMask->GetPitch()); |
1676 } | 1677 } |
1677 } | 1678 } |
1678 | 1679 |
1679 FX_BOOL CFX_BitmapStorer::SetInfo(int width, | 1680 FX_BOOL CFX_BitmapStorer::SetInfo(int width, |
1680 int height, | 1681 int height, |
1681 FXDIB_Format src_format, | 1682 FXDIB_Format src_format, |
1682 uint32_t* pSrcPalette) { | 1683 uint32_t* pSrcPalette) { |
1683 m_pBitmap = WrapUnique(new CFX_DIBitmap); | 1684 m_pBitmap = pdfium::MakeUnique<CFX_DIBitmap>(); |
1684 if (!m_pBitmap->Create(width, height, src_format)) { | 1685 if (!m_pBitmap->Create(width, height, src_format)) { |
1685 m_pBitmap.reset(); | 1686 m_pBitmap.reset(); |
1686 return FALSE; | 1687 return FALSE; |
1687 } | 1688 } |
1688 if (pSrcPalette) | 1689 if (pSrcPalette) |
1689 m_pBitmap->CopyPalette(pSrcPalette); | 1690 m_pBitmap->CopyPalette(pSrcPalette); |
1690 return TRUE; | 1691 return TRUE; |
1691 } | 1692 } |
OLD | NEW |