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 <memory> | 7 #include <memory> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "core/fxcodec/fx_codec.h" | 10 #include "core/fxcodec/fx_codec.h" |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 774 return ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width, height, | 774 return ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width, height, |
| 775 pSrcBitmap, src_left, src_top); | 775 pSrcBitmap, src_left, src_top); |
| 776 } | 776 } |
| 777 return false; | 777 return false; |
| 778 } | 778 } |
| 779 default: | 779 default: |
| 780 return false; | 780 return false; |
| 781 } | 781 } |
| 782 } | 782 } |
| 783 | 783 |
| 784 CFX_DIBitmap* CFX_DIBSource::CloneConvert(FXDIB_Format dest_format) const { | 784 std::unique_ptr<CFX_DIBitmap> CFX_DIBSource::CloneConvert( |
| 785 FXDIB_Format dest_format) const { | |
| 785 if (dest_format == GetFormat()) | 786 if (dest_format == GetFormat()) |
| 786 return Clone(nullptr); | 787 return Clone(nullptr); |
| 787 | 788 |
| 788 std::unique_ptr<CFX_DIBitmap> pClone(new CFX_DIBitmap); | 789 std::unique_ptr<CFX_DIBitmap> pClone(new CFX_DIBitmap); |
|
npm
2016/12/05 20:37:23
nit: MakeUnique
Tom Sepez
2016/12/05 21:38:13
yes!! Thanks!! Done.
| |
| 789 if (!pClone->Create(m_Width, m_Height, dest_format)) | 790 if (!pClone->Create(m_Width, m_Height, dest_format)) |
| 790 return nullptr; | 791 return nullptr; |
| 791 | 792 |
| 792 CFX_DIBitmap* pSrcAlpha = nullptr; | 793 CFX_DIBitmap* pSrcAlpha = nullptr; |
| 793 if (HasAlpha()) { | 794 if (HasAlpha()) { |
| 794 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask; | 795 pSrcAlpha = (GetFormat() == FXDIB_Argb) ? GetAlphaMask() : m_pAlphaMask; |
| 795 if (!pSrcAlpha) | 796 if (!pSrcAlpha) |
| 796 return nullptr; | 797 return nullptr; |
| 797 } | 798 } |
| 798 | 799 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 812 if (!ret) | 813 if (!ret) |
| 813 return nullptr; | 814 return nullptr; |
| 814 | 815 |
| 815 std::unique_ptr<uint32_t, FxFreeDeleter> pal_8bpp; | 816 std::unique_ptr<uint32_t, FxFreeDeleter> pal_8bpp; |
| 816 if (!ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(), | 817 if (!ConvertBuffer(dest_format, pClone->GetBuffer(), pClone->GetPitch(), |
| 817 m_Width, m_Height, this, 0, 0, &pal_8bpp)) { | 818 m_Width, m_Height, this, 0, 0, &pal_8bpp)) { |
| 818 return nullptr; | 819 return nullptr; |
| 819 } | 820 } |
| 820 if (pal_8bpp) | 821 if (pal_8bpp) |
| 821 pClone->CopyPalette(pal_8bpp.get()); | 822 pClone->CopyPalette(pal_8bpp.get()); |
| 822 return pClone.release(); | 823 |
| 824 return pClone; | |
| 823 } | 825 } |
| 824 | 826 |
| 825 bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) { | 827 bool CFX_DIBitmap::ConvertFormat(FXDIB_Format dest_format) { |
| 826 FXDIB_Format src_format = GetFormat(); | 828 FXDIB_Format src_format = GetFormat(); |
| 827 if (dest_format == src_format) | 829 if (dest_format == src_format) |
| 828 return true; | 830 return true; |
| 829 | 831 |
| 830 if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb && | 832 if (dest_format == FXDIB_8bppMask && src_format == FXDIB_8bppRgb && |
| 831 !m_pPalette) { | 833 !m_pPalette) { |
| 832 m_AlphaFlag = 1; | 834 m_AlphaFlag = 1; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 898 m_pPalette = std::move(pal_8bpp); | 900 m_pPalette = std::move(pal_8bpp); |
| 899 if (!m_bExtBuf) | 901 if (!m_bExtBuf) |
| 900 FX_Free(m_pBuffer); | 902 FX_Free(m_pBuffer); |
| 901 m_bExtBuf = false; | 903 m_bExtBuf = false; |
| 902 m_pBuffer = dest_buf; | 904 m_pBuffer = dest_buf; |
| 903 m_bpp = (uint8_t)dest_format; | 905 m_bpp = (uint8_t)dest_format; |
| 904 m_AlphaFlag = (uint8_t)(dest_format >> 8); | 906 m_AlphaFlag = (uint8_t)(dest_format >> 8); |
| 905 m_Pitch = dest_pitch; | 907 m_Pitch = dest_pitch; |
| 906 return true; | 908 return true; |
| 907 } | 909 } |
| OLD | NEW |