| 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 30 matching lines...) Expand all Loading... |
| 41 uint32_t ArgbEncode(int a, FX_COLORREF rgb) { | 41 uint32_t ArgbEncode(int a, FX_COLORREF rgb) { |
| 42 return FXARGB_MAKE(a, FXSYS_GetRValue(rgb), FXSYS_GetGValue(rgb), | 42 return FXARGB_MAKE(a, FXSYS_GetRValue(rgb), FXSYS_GetGValue(rgb), |
| 43 FXSYS_GetBValue(rgb)); | 43 FXSYS_GetBValue(rgb)); |
| 44 } | 44 } |
| 45 | 45 |
| 46 CFX_DIBSource::CFX_DIBSource() { | 46 CFX_DIBSource::CFX_DIBSource() { |
| 47 m_bpp = 0; | 47 m_bpp = 0; |
| 48 m_AlphaFlag = 0; | 48 m_AlphaFlag = 0; |
| 49 m_Width = m_Height = 0; | 49 m_Width = m_Height = 0; |
| 50 m_Pitch = 0; | 50 m_Pitch = 0; |
| 51 m_pPalette = NULL; | 51 m_pPalette = nullptr; |
| 52 m_pAlphaMask = NULL; | 52 m_pAlphaMask = nullptr; |
| 53 } | 53 } |
| 54 | 54 |
| 55 CFX_DIBSource::~CFX_DIBSource() { | 55 CFX_DIBSource::~CFX_DIBSource() { |
| 56 FX_Free(m_pPalette); | 56 FX_Free(m_pPalette); |
| 57 delete m_pAlphaMask; | 57 delete m_pAlphaMask; |
| 58 } | 58 } |
| 59 | 59 |
| 60 uint8_t* CFX_DIBSource::GetBuffer() const { | 60 uint8_t* CFX_DIBSource::GetBuffer() const { |
| 61 return NULL; | 61 return nullptr; |
| 62 } | 62 } |
| 63 | 63 |
| 64 FX_BOOL CFX_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const { | 64 FX_BOOL CFX_DIBSource::SkipToScanline(int line, IFX_Pause* pPause) const { |
| 65 return FALSE; | 65 return FALSE; |
| 66 } | 66 } |
| 67 | 67 |
| 68 CFX_DIBitmap::CFX_DIBitmap() { | 68 CFX_DIBitmap::CFX_DIBitmap() { |
| 69 m_bExtBuf = FALSE; | 69 m_bExtBuf = FALSE; |
| 70 m_pBuffer = NULL; | 70 m_pBuffer = nullptr; |
| 71 m_pPalette = NULL; | 71 m_pPalette = nullptr; |
| 72 } | 72 } |
| 73 | 73 |
| 74 #define _MAX_OOM_LIMIT_ 12000000 | 74 #define _MAX_OOM_LIMIT_ 12000000 |
| 75 FX_BOOL CFX_DIBitmap::Create(int width, | 75 FX_BOOL CFX_DIBitmap::Create(int width, |
| 76 int height, | 76 int height, |
| 77 FXDIB_Format format, | 77 FXDIB_Format format, |
| 78 uint8_t* pBuffer, | 78 uint8_t* pBuffer, |
| 79 int pitch) { | 79 int pitch) { |
| 80 m_pBuffer = NULL; | 80 m_pBuffer = nullptr; |
| 81 m_bpp = (uint8_t)format; | 81 m_bpp = (uint8_t)format; |
| 82 m_AlphaFlag = (uint8_t)(format >> 8); | 82 m_AlphaFlag = (uint8_t)(format >> 8); |
| 83 m_Width = m_Height = m_Pitch = 0; | 83 m_Width = m_Height = m_Pitch = 0; |
| 84 if (width <= 0 || height <= 0 || pitch < 0) { | 84 if (width <= 0 || height <= 0 || pitch < 0) { |
| 85 return FALSE; | 85 return FALSE; |
| 86 } | 86 } |
| 87 if ((INT_MAX - 31) / width < (format & 0xff)) { | 87 if ((INT_MAX - 31) / width < (format & 0xff)) { |
| 88 return FALSE; | 88 return FALSE; |
| 89 } | 89 } |
| 90 if (!pitch) { | 90 if (!pitch) { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 110 } | 110 } |
| 111 m_Width = width; | 111 m_Width = width; |
| 112 m_Height = height; | 112 m_Height = height; |
| 113 m_Pitch = pitch; | 113 m_Pitch = pitch; |
| 114 if (HasAlpha() && format != FXDIB_Argb) { | 114 if (HasAlpha() && format != FXDIB_Argb) { |
| 115 FX_BOOL ret = TRUE; | 115 FX_BOOL ret = TRUE; |
| 116 ret = BuildAlphaMask(); | 116 ret = BuildAlphaMask(); |
| 117 if (!ret) { | 117 if (!ret) { |
| 118 if (!m_bExtBuf) { | 118 if (!m_bExtBuf) { |
| 119 FX_Free(m_pBuffer); | 119 FX_Free(m_pBuffer); |
| 120 m_pBuffer = NULL; | 120 m_pBuffer = nullptr; |
| 121 m_Width = m_Height = m_Pitch = 0; | 121 m_Width = m_Height = m_Pitch = 0; |
| 122 return FALSE; | 122 return FALSE; |
| 123 } | 123 } |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 return TRUE; | 126 return TRUE; |
| 127 } | 127 } |
| 128 | 128 |
| 129 FX_BOOL CFX_DIBitmap::Copy(const CFX_DIBSource* pSrc) { | 129 FX_BOOL CFX_DIBitmap::Copy(const CFX_DIBSource* pSrc) { |
| 130 if (m_pBuffer) { | 130 if (m_pBuffer) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 m_Width = pSrcBitmap->m_Width; | 174 m_Width = pSrcBitmap->m_Width; |
| 175 m_Height = pSrcBitmap->m_Height; | 175 m_Height = pSrcBitmap->m_Height; |
| 176 m_Pitch = pSrcBitmap->m_Pitch; | 176 m_Pitch = pSrcBitmap->m_Pitch; |
| 177 } | 177 } |
| 178 | 178 |
| 179 CFX_DIBitmap* CFX_DIBSource::Clone(const FX_RECT* pClip) const { | 179 CFX_DIBitmap* CFX_DIBSource::Clone(const FX_RECT* pClip) const { |
| 180 FX_RECT rect(0, 0, m_Width, m_Height); | 180 FX_RECT rect(0, 0, m_Width, m_Height); |
| 181 if (pClip) { | 181 if (pClip) { |
| 182 rect.Intersect(*pClip); | 182 rect.Intersect(*pClip); |
| 183 if (rect.IsEmpty()) { | 183 if (rect.IsEmpty()) { |
| 184 return NULL; | 184 return nullptr; |
| 185 } | 185 } |
| 186 } | 186 } |
| 187 CFX_DIBitmap* pNewBitmap = new CFX_DIBitmap; | 187 CFX_DIBitmap* pNewBitmap = new CFX_DIBitmap; |
| 188 if (!pNewBitmap->Create(rect.Width(), rect.Height(), GetFormat())) { | 188 if (!pNewBitmap->Create(rect.Width(), rect.Height(), GetFormat())) { |
| 189 delete pNewBitmap; | 189 delete pNewBitmap; |
| 190 return NULL; | 190 return nullptr; |
| 191 } | 191 } |
| 192 pNewBitmap->CopyPalette(m_pPalette); | 192 pNewBitmap->CopyPalette(m_pPalette); |
| 193 pNewBitmap->CopyAlphaMask(m_pAlphaMask, pClip); | 193 pNewBitmap->CopyAlphaMask(m_pAlphaMask, pClip); |
| 194 if (GetBPP() == 1 && rect.left % 8 != 0) { | 194 if (GetBPP() == 1 && rect.left % 8 != 0) { |
| 195 int left_shift = rect.left % 32; | 195 int left_shift = rect.left % 32; |
| 196 int right_shift = 32 - left_shift; | 196 int right_shift = 32 - left_shift; |
| 197 int dword_count = pNewBitmap->m_Pitch / 4; | 197 int dword_count = pNewBitmap->m_Pitch / 4; |
| 198 for (int row = rect.top; row < rect.bottom; row++) { | 198 for (int row = rect.top; row < rect.bottom; row++) { |
| 199 uint32_t* src_scan = (uint32_t*)GetScanline(row) + rect.left / 32; | 199 uint32_t* src_scan = (uint32_t*)GetScanline(row) + rect.left / 32; |
| 200 uint32_t* dest_scan = (uint32_t*)pNewBitmap->GetScanline(row - rect.top); | 200 uint32_t* dest_scan = (uint32_t*)pNewBitmap->GetScanline(row - rect.top); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 FX_BOOL CFX_DIBSource::BuildAlphaMask() { | 245 FX_BOOL CFX_DIBSource::BuildAlphaMask() { |
| 246 if (m_pAlphaMask) { | 246 if (m_pAlphaMask) { |
| 247 return TRUE; | 247 return TRUE; |
| 248 } | 248 } |
| 249 m_pAlphaMask = new CFX_DIBitmap; | 249 m_pAlphaMask = new CFX_DIBitmap; |
| 250 if (!m_pAlphaMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { | 250 if (!m_pAlphaMask->Create(m_Width, m_Height, FXDIB_8bppMask)) { |
| 251 delete m_pAlphaMask; | 251 delete m_pAlphaMask; |
| 252 m_pAlphaMask = NULL; | 252 m_pAlphaMask = nullptr; |
| 253 return FALSE; | 253 return FALSE; |
| 254 } | 254 } |
| 255 FXSYS_memset(m_pAlphaMask->GetBuffer(), 0xff, | 255 FXSYS_memset(m_pAlphaMask->GetBuffer(), 0xff, |
| 256 m_pAlphaMask->GetHeight() * m_pAlphaMask->GetPitch()); | 256 m_pAlphaMask->GetHeight() * m_pAlphaMask->GetPitch()); |
| 257 return TRUE; | 257 return TRUE; |
| 258 } | 258 } |
| 259 uint32_t CFX_DIBSource::GetPaletteEntry(int index) const { | 259 uint32_t CFX_DIBSource::GetPaletteEntry(int index) const { |
| 260 ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask()); | 260 ASSERT((GetBPP() == 1 || GetBPP() == 8) && !IsAlphaMask()); |
| 261 if (m_pPalette) { | 261 if (m_pPalette) { |
| 262 return m_pPalette[index]; | 262 return m_pPalette[index]; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 398 int width, | 398 int width, |
| 399 int height, | 399 int height, |
| 400 const CFX_DIBSource* pSrcBitmap, | 400 const CFX_DIBSource* pSrcBitmap, |
| 401 int src_left, | 401 int src_left, |
| 402 int src_top, | 402 int src_top, |
| 403 void* pIccTransform) { | 403 void* pIccTransform) { |
| 404 if (!m_pBuffer) { | 404 if (!m_pBuffer) { |
| 405 return FALSE; | 405 return FALSE; |
| 406 } | 406 } |
| 407 GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(), | 407 GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(), |
| 408 pSrcBitmap->GetHeight(), src_left, src_top, NULL); | 408 pSrcBitmap->GetHeight(), src_left, src_top, nullptr); |
| 409 if (width == 0 || height == 0) { | 409 if (width == 0 || height == 0) { |
| 410 return TRUE; | 410 return TRUE; |
| 411 } | 411 } |
| 412 FXDIB_Format dest_format = GetFormat(); | 412 FXDIB_Format dest_format = GetFormat(); |
| 413 FXDIB_Format src_format = pSrcBitmap->GetFormat(); | 413 FXDIB_Format src_format = pSrcBitmap->GetFormat(); |
| 414 if (dest_format == src_format && !pIccTransform) { | 414 if (dest_format == src_format && !pIccTransform) { |
| 415 if (GetBPP() == 1) { | 415 if (GetBPP() == 1) { |
| 416 for (int row = 0; row < height; row++) { | 416 for (int row = 0; row < height; row++) { |
| 417 uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch; | 417 uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch; |
| 418 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); | 418 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 439 } | 439 } |
| 440 } else { | 440 } else { |
| 441 if (m_pPalette) { | 441 if (m_pPalette) { |
| 442 return FALSE; | 442 return FALSE; |
| 443 } | 443 } |
| 444 if (m_bpp == 8) { | 444 if (m_bpp == 8) { |
| 445 dest_format = FXDIB_8bppMask; | 445 dest_format = FXDIB_8bppMask; |
| 446 } | 446 } |
| 447 uint8_t* dest_buf = | 447 uint8_t* dest_buf = |
| 448 m_pBuffer + dest_top * m_Pitch + dest_left * GetBPP() / 8; | 448 m_pBuffer + dest_top * m_Pitch + dest_left * GetBPP() / 8; |
| 449 uint32_t* d_plt = NULL; | 449 uint32_t* d_plt = nullptr; |
| 450 if (!ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height, | 450 if (!ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height, |
| 451 pSrcBitmap, src_left, src_top, d_plt, pIccTransform)) { | 451 pSrcBitmap, src_left, src_top, d_plt, pIccTransform)) { |
| 452 return FALSE; | 452 return FALSE; |
| 453 } | 453 } |
| 454 } | 454 } |
| 455 return TRUE; | 455 return TRUE; |
| 456 } | 456 } |
| 457 FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, | 457 FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, |
| 458 int dest_top, | 458 int dest_top, |
| 459 int width, | 459 int width, |
| 460 int height, | 460 int height, |
| 461 const CFX_DIBSource* pMask, | 461 const CFX_DIBSource* pMask, |
| 462 uint32_t color, | 462 uint32_t color, |
| 463 int src_left, | 463 int src_left, |
| 464 int src_top, | 464 int src_top, |
| 465 int alpha_flag, | 465 int alpha_flag, |
| 466 void* pIccTransform) { | 466 void* pIccTransform) { |
| 467 if (!m_pBuffer) { | 467 if (!m_pBuffer) { |
| 468 return FALSE; | 468 return FALSE; |
| 469 } | 469 } |
| 470 ASSERT(HasAlpha() && (m_bpp >= 24)); | 470 ASSERT(HasAlpha() && (m_bpp >= 24)); |
| 471 ASSERT(pMask->IsAlphaMask()); | 471 ASSERT(pMask->IsAlphaMask()); |
| 472 if (!HasAlpha() || !pMask->IsAlphaMask() || m_bpp < 24) { | 472 if (!HasAlpha() || !pMask->IsAlphaMask() || m_bpp < 24) { |
| 473 return FALSE; | 473 return FALSE; |
| 474 } | 474 } |
| 475 GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), | 475 GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), |
| 476 pMask->GetHeight(), src_left, src_top, NULL); | 476 pMask->GetHeight(), src_left, src_top, nullptr); |
| 477 if (width == 0 || height == 0) { | 477 if (width == 0 || height == 0) { |
| 478 return TRUE; | 478 return TRUE; |
| 479 } | 479 } |
| 480 int src_bpp = pMask->GetBPP(); | 480 int src_bpp = pMask->GetBPP(); |
| 481 int alpha; | 481 int alpha; |
| 482 uint32_t dst_color; | 482 uint32_t dst_color; |
| 483 if (alpha_flag >> 8) { | 483 if (alpha_flag >> 8) { |
| 484 alpha = alpha_flag & 0xff; | 484 alpha = alpha_flag & 0xff; |
| 485 dst_color = FXCMYK_TODIB(color); | 485 dst_color = FXCMYK_TODIB(color); |
| 486 } else { | 486 } else { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 559 *dest_alpha_pos++ = (alpha * (*src_scan++) / 255); | 559 *dest_alpha_pos++ = (alpha * (*src_scan++) / 255); |
| 560 } | 560 } |
| 561 } | 561 } |
| 562 } | 562 } |
| 563 } | 563 } |
| 564 return TRUE; | 564 return TRUE; |
| 565 } | 565 } |
| 566 void CFX_DIBSource::CopyPalette(const uint32_t* pSrc, uint32_t size) { | 566 void CFX_DIBSource::CopyPalette(const uint32_t* pSrc, uint32_t size) { |
| 567 if (!pSrc || GetBPP() > 8) { | 567 if (!pSrc || GetBPP() > 8) { |
| 568 FX_Free(m_pPalette); | 568 FX_Free(m_pPalette); |
| 569 m_pPalette = NULL; | 569 m_pPalette = nullptr; |
| 570 } else { | 570 } else { |
| 571 uint32_t pal_size = 1 << GetBPP(); | 571 uint32_t pal_size = 1 << GetBPP(); |
| 572 if (!m_pPalette) { | 572 if (!m_pPalette) { |
| 573 m_pPalette = FX_Alloc(uint32_t, pal_size); | 573 m_pPalette = FX_Alloc(uint32_t, pal_size); |
| 574 } | 574 } |
| 575 if (pal_size > size) { | 575 if (pal_size > size) { |
| 576 pal_size = size; | 576 pal_size = size; |
| 577 } | 577 } |
| 578 FXSYS_memcpy(m_pPalette, pSrc, pal_size * sizeof(uint32_t)); | 578 FXSYS_memcpy(m_pPalette, pSrc, pal_size * sizeof(uint32_t)); |
| 579 } | 579 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 596 pal[i] = (i * 0x10101) | (alpha << 24); | 596 pal[i] = (i * 0x10101) | (alpha << 24); |
| 597 } | 597 } |
| 598 } | 598 } |
| 599 } | 599 } |
| 600 CFX_DIBitmap* CFX_DIBSource::GetAlphaMask(const FX_RECT* pClip) const { | 600 CFX_DIBitmap* CFX_DIBSource::GetAlphaMask(const FX_RECT* pClip) const { |
| 601 ASSERT(GetFormat() == FXDIB_Argb); | 601 ASSERT(GetFormat() == FXDIB_Argb); |
| 602 FX_RECT rect(0, 0, m_Width, m_Height); | 602 FX_RECT rect(0, 0, m_Width, m_Height); |
| 603 if (pClip) { | 603 if (pClip) { |
| 604 rect.Intersect(*pClip); | 604 rect.Intersect(*pClip); |
| 605 if (rect.IsEmpty()) { | 605 if (rect.IsEmpty()) { |
| 606 return NULL; | 606 return nullptr; |
| 607 } | 607 } |
| 608 } | 608 } |
| 609 CFX_DIBitmap* pMask = new CFX_DIBitmap; | 609 CFX_DIBitmap* pMask = new CFX_DIBitmap; |
| 610 if (!pMask->Create(rect.Width(), rect.Height(), FXDIB_8bppMask)) { | 610 if (!pMask->Create(rect.Width(), rect.Height(), FXDIB_8bppMask)) { |
| 611 delete pMask; | 611 delete pMask; |
| 612 return NULL; | 612 return nullptr; |
| 613 } | 613 } |
| 614 for (int row = rect.top; row < rect.bottom; row++) { | 614 for (int row = rect.top; row < rect.bottom; row++) { |
| 615 const uint8_t* src_scan = GetScanline(row) + rect.left * 4 + 3; | 615 const uint8_t* src_scan = GetScanline(row) + rect.left * 4 + 3; |
| 616 uint8_t* dest_scan = (uint8_t*)pMask->GetScanline(row - rect.top); | 616 uint8_t* dest_scan = (uint8_t*)pMask->GetScanline(row - rect.top); |
| 617 for (int col = rect.left; col < rect.right; col++) { | 617 for (int col = rect.left; col < rect.right; col++) { |
| 618 *dest_scan++ = *src_scan; | 618 *dest_scan++ = *src_scan; |
| 619 src_scan += 4; | 619 src_scan += 4; |
| 620 } | 620 } |
| 621 } | 621 } |
| 622 return pMask; | 622 return pMask; |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 748 pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height); | 748 pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height); |
| 749 if (!pAlphaMask) { | 749 if (!pAlphaMask) { |
| 750 if (pSrcClone != pSrcBitmap) { | 750 if (pSrcClone != pSrcBitmap) { |
| 751 delete pSrcClone; | 751 delete pSrcClone; |
| 752 } | 752 } |
| 753 return FALSE; | 753 return FALSE; |
| 754 } | 754 } |
| 755 } | 755 } |
| 756 } | 756 } |
| 757 if (pSrcClone != pSrcBitmap) { | 757 if (pSrcClone != pSrcBitmap) { |
| 758 pSrcClone->m_pAlphaMask = NULL; | 758 pSrcClone->m_pAlphaMask = nullptr; |
| 759 delete pSrcClone; | 759 delete pSrcClone; |
| 760 } | 760 } |
| 761 pSrcClone = pAlphaMask; | 761 pSrcClone = pAlphaMask; |
| 762 srcOffset = 0; | 762 srcOffset = 0; |
| 763 } else if (pSrcClone->GetWidth() != m_Width || | 763 } else if (pSrcClone->GetWidth() != m_Width || |
| 764 pSrcClone->GetHeight() != m_Height) { | 764 pSrcClone->GetHeight() != m_Height) { |
| 765 CFX_DIBitmap* pSrcMatched = pSrcClone->StretchTo(m_Width, m_Height); | 765 CFX_DIBitmap* pSrcMatched = pSrcClone->StretchTo(m_Width, m_Height); |
| 766 if (pSrcClone != pSrcBitmap) { | 766 if (pSrcClone != pSrcBitmap) { |
| 767 delete pSrcClone; | 767 delete pSrcClone; |
| 768 } | 768 } |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1369 } | 1369 } |
| 1370 } | 1370 } |
| 1371 } | 1371 } |
| 1372 return TRUE; | 1372 return TRUE; |
| 1373 } | 1373 } |
| 1374 | 1374 |
| 1375 CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const { | 1375 CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const { |
| 1376 CFX_DIBitmap* pFlipped = new CFX_DIBitmap; | 1376 CFX_DIBitmap* pFlipped = new CFX_DIBitmap; |
| 1377 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { | 1377 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { |
| 1378 delete pFlipped; | 1378 delete pFlipped; |
| 1379 return NULL; | 1379 return nullptr; |
| 1380 } | 1380 } |
| 1381 pFlipped->CopyPalette(m_pPalette); | 1381 pFlipped->CopyPalette(m_pPalette); |
| 1382 uint8_t* pDestBuffer = pFlipped->GetBuffer(); | 1382 uint8_t* pDestBuffer = pFlipped->GetBuffer(); |
| 1383 int Bpp = m_bpp / 8; | 1383 int Bpp = m_bpp / 8; |
| 1384 for (int row = 0; row < m_Height; row++) { | 1384 for (int row = 0; row < m_Height; row++) { |
| 1385 const uint8_t* src_scan = GetScanline(row); | 1385 const uint8_t* src_scan = GetScanline(row); |
| 1386 uint8_t* dest_scan = | 1386 uint8_t* dest_scan = |
| 1387 pDestBuffer + m_Pitch * (bYFlip ? (m_Height - row - 1) : row); | 1387 pDestBuffer + m_Pitch * (bYFlip ? (m_Height - row - 1) : row); |
| 1388 if (!bXFlip) { | 1388 if (!bXFlip) { |
| 1389 FXSYS_memcpy(dest_scan, src_scan, m_Pitch); | 1389 FXSYS_memcpy(dest_scan, src_scan, m_Pitch); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1437 for (int col = 0; col < m_Width; col++) { | 1437 for (int col = 0; col < m_Width; col++) { |
| 1438 *dest_scan = *src_scan; | 1438 *dest_scan = *src_scan; |
| 1439 dest_scan--; | 1439 dest_scan--; |
| 1440 src_scan++; | 1440 src_scan++; |
| 1441 } | 1441 } |
| 1442 } | 1442 } |
| 1443 } | 1443 } |
| 1444 return pFlipped; | 1444 return pFlipped; |
| 1445 } | 1445 } |
| 1446 CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { | 1446 CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { |
| 1447 m_pBitmap = NULL; | 1447 m_pBitmap = nullptr; |
| 1448 if (pSrc->GetBuffer()) { | 1448 if (pSrc->GetBuffer()) { |
| 1449 m_pBitmap = new CFX_DIBitmap; | 1449 m_pBitmap = new CFX_DIBitmap; |
| 1450 if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), | 1450 if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), |
| 1451 pSrc->GetFormat(), pSrc->GetBuffer())) { | 1451 pSrc->GetFormat(), pSrc->GetBuffer())) { |
| 1452 delete m_pBitmap; | 1452 delete m_pBitmap; |
| 1453 m_pBitmap = NULL; | 1453 m_pBitmap = nullptr; |
| 1454 return; | 1454 return; |
| 1455 } | 1455 } |
| 1456 m_pBitmap->CopyPalette(pSrc->GetPalette()); | 1456 m_pBitmap->CopyPalette(pSrc->GetPalette()); |
| 1457 m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask); | 1457 m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask); |
| 1458 } else { | 1458 } else { |
| 1459 m_pBitmap = pSrc->Clone(); | 1459 m_pBitmap = pSrc->Clone(); |
| 1460 } | 1460 } |
| 1461 } | 1461 } |
| 1462 CFX_DIBExtractor::~CFX_DIBExtractor() { | 1462 CFX_DIBExtractor::~CFX_DIBExtractor() { |
| 1463 delete m_pBitmap; | 1463 delete m_pBitmap; |
| 1464 } | 1464 } |
| 1465 CFX_FilteredDIB::CFX_FilteredDIB() { | 1465 CFX_FilteredDIB::CFX_FilteredDIB() { |
| 1466 m_pScanline = NULL; | 1466 m_pScanline = nullptr; |
| 1467 m_pSrc = NULL; | 1467 m_pSrc = nullptr; |
| 1468 } | 1468 } |
| 1469 CFX_FilteredDIB::~CFX_FilteredDIB() { | 1469 CFX_FilteredDIB::~CFX_FilteredDIB() { |
| 1470 if (m_bAutoDropSrc) { | 1470 if (m_bAutoDropSrc) { |
| 1471 delete m_pSrc; | 1471 delete m_pSrc; |
| 1472 } | 1472 } |
| 1473 FX_Free(m_pScanline); | 1473 FX_Free(m_pScanline); |
| 1474 } | 1474 } |
| 1475 void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc) { | 1475 void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc) { |
| 1476 m_pSrc = pSrc; | 1476 m_pSrc = pSrc; |
| 1477 m_bAutoDropSrc = bAutoDropSrc; | 1477 m_bAutoDropSrc = bAutoDropSrc; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1494 int dest_width, | 1494 int dest_width, |
| 1495 FX_BOOL bFlipX, | 1495 FX_BOOL bFlipX, |
| 1496 int clip_left, | 1496 int clip_left, |
| 1497 int clip_width) const { | 1497 int clip_width) const { |
| 1498 m_pSrc->DownSampleScanline(line, dest_scan, dest_bpp, dest_width, bFlipX, | 1498 m_pSrc->DownSampleScanline(line, dest_scan, dest_bpp, dest_width, bFlipX, |
| 1499 clip_left, clip_width); | 1499 clip_left, clip_width); |
| 1500 TranslateDownSamples(dest_scan, dest_scan, clip_width, dest_bpp); | 1500 TranslateDownSamples(dest_scan, dest_scan, clip_width, dest_bpp); |
| 1501 } | 1501 } |
| 1502 CFX_ImageRenderer::CFX_ImageRenderer() { | 1502 CFX_ImageRenderer::CFX_ImageRenderer() { |
| 1503 m_Status = 0; | 1503 m_Status = 0; |
| 1504 m_pTransformer = NULL; | 1504 m_pTransformer = nullptr; |
| 1505 m_bRgbByteOrder = FALSE; | 1505 m_bRgbByteOrder = FALSE; |
| 1506 m_BlendType = FXDIB_BLEND_NORMAL; | 1506 m_BlendType = FXDIB_BLEND_NORMAL; |
| 1507 } | 1507 } |
| 1508 CFX_ImageRenderer::~CFX_ImageRenderer() { | 1508 CFX_ImageRenderer::~CFX_ImageRenderer() { |
| 1509 delete m_pTransformer; | 1509 delete m_pTransformer; |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, | 1512 FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, |
| 1513 const CFX_ClipRgn* pClipRgn, | 1513 const CFX_ClipRgn* pClipRgn, |
| 1514 const CFX_DIBSource* pSource, | 1514 const CFX_DIBSource* pSource, |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 uint32_t* pSrcPalette) { | 1668 uint32_t* pSrcPalette) { |
| 1669 m_pBitmap.reset(new CFX_DIBitmap); | 1669 m_pBitmap.reset(new CFX_DIBitmap); |
| 1670 if (!m_pBitmap->Create(width, height, src_format)) { | 1670 if (!m_pBitmap->Create(width, height, src_format)) { |
| 1671 m_pBitmap.reset(); | 1671 m_pBitmap.reset(); |
| 1672 return FALSE; | 1672 return FALSE; |
| 1673 } | 1673 } |
| 1674 if (pSrcPalette) | 1674 if (pSrcPalette) |
| 1675 m_pBitmap->CopyPalette(pSrcPalette); | 1675 m_pBitmap->CopyPalette(pSrcPalette); |
| 1676 return TRUE; | 1676 return TRUE; |
| 1677 } | 1677 } |
| OLD | NEW |