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/fxcodec/include/fx_codec.h" | 7 #include "core/fxcodec/include/fx_codec.h" |
8 #include "core/fxge/dib/dib_int.h" | 8 #include "core/fxge/dib/dib_int.h" |
9 #include "core/fxge/include/fx_ge.h" | 9 #include "core/fxge/include/fx_ge.h" |
10 | 10 |
(...skipping 4495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4506 } | 4506 } |
4507 const CFX_DIBitmap* pClipMask = nullptr; | 4507 const CFX_DIBitmap* pClipMask = nullptr; |
4508 FX_RECT clip_box; | 4508 FX_RECT clip_box; |
4509 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { | 4509 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { |
4510 ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); | 4510 ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); |
4511 pClipMask = pClipRgn->GetMask(); | 4511 pClipMask = pClipRgn->GetMask(); |
4512 clip_box = pClipRgn->GetBox(); | 4512 clip_box = pClipRgn->GetBox(); |
4513 } | 4513 } |
4514 CFX_ScanlineCompositor compositor; | 4514 CFX_ScanlineCompositor compositor; |
4515 if (!compositor.Init(GetFormat(), pSrcBitmap->GetFormat(), width, | 4515 if (!compositor.Init(GetFormat(), pSrcBitmap->GetFormat(), width, |
4516 pSrcBitmap->GetPalette(), 0, blend_type, | 4516 pSrcBitmap->GetPalette(), 0, blend_type, !!pClipMask, |
4517 pClipMask != nullptr, bRgbByteOrder, 0, pIccTransform)) { | 4517 bRgbByteOrder, 0, pIccTransform)) { |
4518 return FALSE; | 4518 return FALSE; |
4519 } | 4519 } |
4520 int dest_Bpp = m_bpp / 8; | 4520 int dest_Bpp = m_bpp / 8; |
4521 int src_Bpp = pSrcBitmap->GetBPP() / 8; | 4521 int src_Bpp = pSrcBitmap->GetBPP() / 8; |
4522 FX_BOOL bRgb = src_Bpp > 1 && !pSrcBitmap->IsCmykImage(); | 4522 FX_BOOL bRgb = src_Bpp > 1 && !pSrcBitmap->IsCmykImage(); |
4523 CFX_DIBitmap* pSrcAlphaMask = pSrcBitmap->m_pAlphaMask; | 4523 CFX_DIBitmap* pSrcAlphaMask = pSrcBitmap->m_pAlphaMask; |
4524 for (int row = 0; row < height; row++) { | 4524 for (int row = 0; row < height; row++) { |
4525 uint8_t* dest_scan = | 4525 uint8_t* dest_scan = |
4526 m_pBuffer + (dest_top + row) * m_Pitch + dest_left * dest_Bpp; | 4526 m_pBuffer + (dest_top + row) * m_Pitch + dest_left * dest_Bpp; |
4527 const uint8_t* src_scan = | 4527 const uint8_t* src_scan = |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4587 FX_RECT clip_box; | 4587 FX_RECT clip_box; |
4588 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { | 4588 if (pClipRgn && pClipRgn->GetType() != CFX_ClipRgn::RectI) { |
4589 ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); | 4589 ASSERT(pClipRgn->GetType() == CFX_ClipRgn::MaskF); |
4590 pClipMask = pClipRgn->GetMask(); | 4590 pClipMask = pClipRgn->GetMask(); |
4591 clip_box = pClipRgn->GetBox(); | 4591 clip_box = pClipRgn->GetBox(); |
4592 } | 4592 } |
4593 int src_bpp = pMask->GetBPP(); | 4593 int src_bpp = pMask->GetBPP(); |
4594 int Bpp = GetBPP() / 8; | 4594 int Bpp = GetBPP() / 8; |
4595 CFX_ScanlineCompositor compositor; | 4595 CFX_ScanlineCompositor compositor; |
4596 if (!compositor.Init(GetFormat(), pMask->GetFormat(), width, nullptr, color, | 4596 if (!compositor.Init(GetFormat(), pMask->GetFormat(), width, nullptr, color, |
4597 blend_type, pClipMask != nullptr, bRgbByteOrder, | 4597 blend_type, !!pClipMask, bRgbByteOrder, alpha_flag, |
4598 alpha_flag, pIccTransform)) { | 4598 pIccTransform)) { |
4599 return FALSE; | 4599 return FALSE; |
4600 } | 4600 } |
4601 for (int row = 0; row < height; row++) { | 4601 for (int row = 0; row < height; row++) { |
4602 uint8_t* dest_scan = | 4602 uint8_t* dest_scan = |
4603 m_pBuffer + (dest_top + row) * m_Pitch + dest_left * Bpp; | 4603 m_pBuffer + (dest_top + row) * m_Pitch + dest_left * Bpp; |
4604 const uint8_t* src_scan = pMask->GetScanline(src_top + row); | 4604 const uint8_t* src_scan = pMask->GetScanline(src_top + row); |
4605 uint8_t* dst_scan_extra_alpha = | 4605 uint8_t* dst_scan_extra_alpha = |
4606 m_pAlphaMask | 4606 m_pAlphaMask |
4607 ? (uint8_t*)m_pAlphaMask->GetScanline(dest_top + row) + dest_left | 4607 ? (uint8_t*)m_pAlphaMask->GetScanline(dest_top + row) + dest_left |
4608 : nullptr; | 4608 : nullptr; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4880 m_bRgbByteOrder = bRgbByteOrder; | 4880 m_bRgbByteOrder = bRgbByteOrder; |
4881 m_BlendType = blend_type; | 4881 m_BlendType = blend_type; |
4882 } | 4882 } |
4883 FX_BOOL CFX_BitmapComposer::SetInfo(int width, | 4883 FX_BOOL CFX_BitmapComposer::SetInfo(int width, |
4884 int height, | 4884 int height, |
4885 FXDIB_Format src_format, | 4885 FXDIB_Format src_format, |
4886 uint32_t* pSrcPalette) { | 4886 uint32_t* pSrcPalette) { |
4887 m_SrcFormat = src_format; | 4887 m_SrcFormat = src_format; |
4888 if (!m_Compositor.Init(m_pBitmap->GetFormat(), src_format, width, pSrcPalette, | 4888 if (!m_Compositor.Init(m_pBitmap->GetFormat(), src_format, width, pSrcPalette, |
4889 m_MaskColor, FXDIB_BLEND_NORMAL, | 4889 m_MaskColor, FXDIB_BLEND_NORMAL, |
4890 m_pClipMask != nullptr || (m_BitmapAlpha < 255), | 4890 m_pClipMask || (m_BitmapAlpha < 255), m_bRgbByteOrder, |
4891 m_bRgbByteOrder, m_AlphaFlag, m_pIccTransform)) { | 4891 m_AlphaFlag, m_pIccTransform)) { |
4892 return FALSE; | 4892 return FALSE; |
4893 } | 4893 } |
4894 if (m_bVertical) { | 4894 if (m_bVertical) { |
4895 m_pScanlineV = FX_Alloc(uint8_t, m_pBitmap->GetBPP() / 8 * width + 4); | 4895 m_pScanlineV = FX_Alloc(uint8_t, m_pBitmap->GetBPP() / 8 * width + 4); |
4896 m_pClipScanV = FX_Alloc(uint8_t, m_pBitmap->GetHeight()); | 4896 m_pClipScanV = FX_Alloc(uint8_t, m_pBitmap->GetHeight()); |
4897 if (m_pBitmap->m_pAlphaMask) { | 4897 if (m_pBitmap->m_pAlphaMask) { |
4898 m_pScanlineAlphaV = FX_Alloc(uint8_t, width + 4); | 4898 m_pScanlineAlphaV = FX_Alloc(uint8_t, width + 4); |
4899 } | 4899 } |
4900 } | 4900 } |
4901 if (m_BitmapAlpha < 255) { | 4901 if (m_BitmapAlpha < 255) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5029 } | 5029 } |
5030 src_alpha_scan = m_pScanlineAlphaV; | 5030 src_alpha_scan = m_pScanlineAlphaV; |
5031 dest_alpha_scan = dest_alpha_buf; | 5031 dest_alpha_scan = dest_alpha_buf; |
5032 if (dest_alpha_scan) { | 5032 if (dest_alpha_scan) { |
5033 for (i = 0; i < m_DestHeight; i++) { | 5033 for (i = 0; i < m_DestHeight; i++) { |
5034 *dest_alpha_scan = *src_alpha_scan++; | 5034 *dest_alpha_scan = *src_alpha_scan++; |
5035 dest_alpha_scan += y_alpha_step; | 5035 dest_alpha_scan += y_alpha_step; |
5036 } | 5036 } |
5037 } | 5037 } |
5038 } | 5038 } |
OLD | NEW |