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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 int width, | 403 int width, |
404 int height, | 404 int height, |
405 const CFX_DIBSource* pSrcBitmap, | 405 const CFX_DIBSource* pSrcBitmap, |
406 int src_left, | 406 int src_left, |
407 int src_top, | 407 int src_top, |
408 void* pIccTransform) { | 408 void* pIccTransform) { |
409 if (!m_pBuffer) { | 409 if (!m_pBuffer) { |
410 return FALSE; | 410 return FALSE; |
411 } | 411 } |
412 GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(), | 412 GetOverlapRect(dest_left, dest_top, width, height, pSrcBitmap->GetWidth(), |
413 pSrcBitmap->GetHeight(), src_left, src_top, NULL); | 413 pSrcBitmap->GetHeight(), src_left, src_top, nullptr); |
414 if (width == 0 || height == 0) { | 414 if (width == 0 || height == 0) { |
415 return TRUE; | 415 return TRUE; |
416 } | 416 } |
417 FXDIB_Format dest_format = GetFormat(); | 417 FXDIB_Format dest_format = GetFormat(); |
418 FXDIB_Format src_format = pSrcBitmap->GetFormat(); | 418 FXDIB_Format src_format = pSrcBitmap->GetFormat(); |
419 if (dest_format == src_format && !pIccTransform) { | 419 if (dest_format == src_format && !pIccTransform) { |
420 if (GetBPP() == 1) { | 420 if (GetBPP() == 1) { |
421 for (int row = 0; row < height; row++) { | 421 for (int row = 0; row < height; row++) { |
422 uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch; | 422 uint8_t* dest_scan = m_pBuffer + (dest_top + row) * m_Pitch; |
423 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); | 423 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row); |
(...skipping 20 matching lines...) Expand all Loading... |
444 } | 444 } |
445 } else { | 445 } else { |
446 if (m_pPalette) { | 446 if (m_pPalette) { |
447 return FALSE; | 447 return FALSE; |
448 } | 448 } |
449 if (m_bpp == 8) { | 449 if (m_bpp == 8) { |
450 dest_format = FXDIB_8bppMask; | 450 dest_format = FXDIB_8bppMask; |
451 } | 451 } |
452 uint8_t* dest_buf = | 452 uint8_t* dest_buf = |
453 m_pBuffer + dest_top * m_Pitch + dest_left * GetBPP() / 8; | 453 m_pBuffer + dest_top * m_Pitch + dest_left * GetBPP() / 8; |
454 uint32_t* d_plt = NULL; | 454 uint32_t* d_plt = nullptr; |
455 if (!ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height, | 455 if (!ConvertBuffer(dest_format, dest_buf, m_Pitch, width, height, |
456 pSrcBitmap, src_left, src_top, d_plt, pIccTransform)) { | 456 pSrcBitmap, src_left, src_top, d_plt, pIccTransform)) { |
457 return FALSE; | 457 return FALSE; |
458 } | 458 } |
459 } | 459 } |
460 return TRUE; | 460 return TRUE; |
461 } | 461 } |
462 FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, | 462 FX_BOOL CFX_DIBitmap::TransferMask(int dest_left, |
463 int dest_top, | 463 int dest_top, |
464 int width, | 464 int width, |
465 int height, | 465 int height, |
466 const CFX_DIBSource* pMask, | 466 const CFX_DIBSource* pMask, |
467 uint32_t color, | 467 uint32_t color, |
468 int src_left, | 468 int src_left, |
469 int src_top, | 469 int src_top, |
470 int alpha_flag, | 470 int alpha_flag, |
471 void* pIccTransform) { | 471 void* pIccTransform) { |
472 if (!m_pBuffer) { | 472 if (!m_pBuffer) { |
473 return FALSE; | 473 return FALSE; |
474 } | 474 } |
475 ASSERT(HasAlpha() && (m_bpp >= 24)); | 475 ASSERT(HasAlpha() && (m_bpp >= 24)); |
476 ASSERT(pMask->IsAlphaMask()); | 476 ASSERT(pMask->IsAlphaMask()); |
477 if (!HasAlpha() || !pMask->IsAlphaMask() || m_bpp < 24) { | 477 if (!HasAlpha() || !pMask->IsAlphaMask() || m_bpp < 24) { |
478 return FALSE; | 478 return FALSE; |
479 } | 479 } |
480 GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), | 480 GetOverlapRect(dest_left, dest_top, width, height, pMask->GetWidth(), |
481 pMask->GetHeight(), src_left, src_top, NULL); | 481 pMask->GetHeight(), src_left, src_top, nullptr); |
482 if (width == 0 || height == 0) { | 482 if (width == 0 || height == 0) { |
483 return TRUE; | 483 return TRUE; |
484 } | 484 } |
485 int src_bpp = pMask->GetBPP(); | 485 int src_bpp = pMask->GetBPP(); |
486 int alpha; | 486 int alpha; |
487 uint32_t dst_color; | 487 uint32_t dst_color; |
488 if (alpha_flag >> 8) { | 488 if (alpha_flag >> 8) { |
489 alpha = alpha_flag & 0xff; | 489 alpha = alpha_flag & 0xff; |
490 dst_color = FXCMYK_TODIB(color); | 490 dst_color = FXCMYK_TODIB(color); |
491 } else { | 491 } else { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 *dest_alpha_pos++ = (alpha * (*src_scan++) / 255); | 564 *dest_alpha_pos++ = (alpha * (*src_scan++) / 255); |
565 } | 565 } |
566 } | 566 } |
567 } | 567 } |
568 } | 568 } |
569 return TRUE; | 569 return TRUE; |
570 } | 570 } |
571 void CFX_DIBSource::CopyPalette(const uint32_t* pSrc, uint32_t size) { | 571 void CFX_DIBSource::CopyPalette(const uint32_t* pSrc, uint32_t size) { |
572 if (!pSrc || GetBPP() > 8) { | 572 if (!pSrc || GetBPP() > 8) { |
573 FX_Free(m_pPalette); | 573 FX_Free(m_pPalette); |
574 m_pPalette = NULL; | 574 m_pPalette = nullptr; |
575 } else { | 575 } else { |
576 uint32_t pal_size = 1 << GetBPP(); | 576 uint32_t pal_size = 1 << GetBPP(); |
577 if (!m_pPalette) { | 577 if (!m_pPalette) { |
578 m_pPalette = FX_Alloc(uint32_t, pal_size); | 578 m_pPalette = FX_Alloc(uint32_t, pal_size); |
579 } | 579 } |
580 if (pal_size > size) { | 580 if (pal_size > size) { |
581 pal_size = size; | 581 pal_size = size; |
582 } | 582 } |
583 FXSYS_memcpy(m_pPalette, pSrc, pal_size * sizeof(uint32_t)); | 583 FXSYS_memcpy(m_pPalette, pSrc, pal_size * sizeof(uint32_t)); |
584 } | 584 } |
(...skipping 16 matching lines...) Expand all Loading... |
601 pal[i] = (i * 0x10101) | (alpha << 24); | 601 pal[i] = (i * 0x10101) | (alpha << 24); |
602 } | 602 } |
603 } | 603 } |
604 } | 604 } |
605 CFX_DIBitmap* CFX_DIBSource::GetAlphaMask(const FX_RECT* pClip) const { | 605 CFX_DIBitmap* CFX_DIBSource::GetAlphaMask(const FX_RECT* pClip) const { |
606 ASSERT(GetFormat() == FXDIB_Argb); | 606 ASSERT(GetFormat() == FXDIB_Argb); |
607 FX_RECT rect(0, 0, m_Width, m_Height); | 607 FX_RECT rect(0, 0, m_Width, m_Height); |
608 if (pClip) { | 608 if (pClip) { |
609 rect.Intersect(*pClip); | 609 rect.Intersect(*pClip); |
610 if (rect.IsEmpty()) { | 610 if (rect.IsEmpty()) { |
611 return NULL; | 611 return nullptr; |
612 } | 612 } |
613 } | 613 } |
614 CFX_DIBitmap* pMask = new CFX_DIBitmap; | 614 CFX_DIBitmap* pMask = new CFX_DIBitmap; |
615 if (!pMask->Create(rect.Width(), rect.Height(), FXDIB_8bppMask)) { | 615 if (!pMask->Create(rect.Width(), rect.Height(), FXDIB_8bppMask)) { |
616 delete pMask; | 616 delete pMask; |
617 return NULL; | 617 return nullptr; |
618 } | 618 } |
619 for (int row = rect.top; row < rect.bottom; row++) { | 619 for (int row = rect.top; row < rect.bottom; row++) { |
620 const uint8_t* src_scan = GetScanline(row) + rect.left * 4 + 3; | 620 const uint8_t* src_scan = GetScanline(row) + rect.left * 4 + 3; |
621 uint8_t* dest_scan = (uint8_t*)pMask->GetScanline(row - rect.top); | 621 uint8_t* dest_scan = (uint8_t*)pMask->GetScanline(row - rect.top); |
622 for (int col = rect.left; col < rect.right; col++) { | 622 for (int col = rect.left; col < rect.right; col++) { |
623 *dest_scan++ = *src_scan; | 623 *dest_scan++ = *src_scan; |
624 src_scan += 4; | 624 src_scan += 4; |
625 } | 625 } |
626 } | 626 } |
627 return pMask; | 627 return pMask; |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
753 pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height); | 753 pAlphaMask = pAlphaMask->StretchTo(m_Width, m_Height); |
754 if (!pAlphaMask) { | 754 if (!pAlphaMask) { |
755 if (pSrcClone != pSrcBitmap) { | 755 if (pSrcClone != pSrcBitmap) { |
756 delete pSrcClone; | 756 delete pSrcClone; |
757 } | 757 } |
758 return FALSE; | 758 return FALSE; |
759 } | 759 } |
760 } | 760 } |
761 } | 761 } |
762 if (pSrcClone != pSrcBitmap) { | 762 if (pSrcClone != pSrcBitmap) { |
763 pSrcClone->m_pAlphaMask = NULL; | 763 pSrcClone->m_pAlphaMask = nullptr; |
764 delete pSrcClone; | 764 delete pSrcClone; |
765 } | 765 } |
766 pSrcClone = pAlphaMask; | 766 pSrcClone = pAlphaMask; |
767 srcOffset = 0; | 767 srcOffset = 0; |
768 } else if (pSrcClone->GetWidth() != m_Width || | 768 } else if (pSrcClone->GetWidth() != m_Width || |
769 pSrcClone->GetHeight() != m_Height) { | 769 pSrcClone->GetHeight() != m_Height) { |
770 CFX_DIBitmap* pSrcMatched = pSrcClone->StretchTo(m_Width, m_Height); | 770 CFX_DIBitmap* pSrcMatched = pSrcClone->StretchTo(m_Width, m_Height); |
771 if (pSrcClone != pSrcBitmap) { | 771 if (pSrcClone != pSrcBitmap) { |
772 delete pSrcClone; | 772 delete pSrcClone; |
773 } | 773 } |
(...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 } | 1374 } |
1375 } | 1375 } |
1376 } | 1376 } |
1377 return TRUE; | 1377 return TRUE; |
1378 } | 1378 } |
1379 | 1379 |
1380 CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const { | 1380 CFX_DIBitmap* CFX_DIBSource::FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const { |
1381 CFX_DIBitmap* pFlipped = new CFX_DIBitmap; | 1381 CFX_DIBitmap* pFlipped = new CFX_DIBitmap; |
1382 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { | 1382 if (!pFlipped->Create(m_Width, m_Height, GetFormat())) { |
1383 delete pFlipped; | 1383 delete pFlipped; |
1384 return NULL; | 1384 return nullptr; |
1385 } | 1385 } |
1386 pFlipped->CopyPalette(m_pPalette); | 1386 pFlipped->CopyPalette(m_pPalette); |
1387 uint8_t* pDestBuffer = pFlipped->GetBuffer(); | 1387 uint8_t* pDestBuffer = pFlipped->GetBuffer(); |
1388 int Bpp = m_bpp / 8; | 1388 int Bpp = m_bpp / 8; |
1389 for (int row = 0; row < m_Height; row++) { | 1389 for (int row = 0; row < m_Height; row++) { |
1390 const uint8_t* src_scan = GetScanline(row); | 1390 const uint8_t* src_scan = GetScanline(row); |
1391 uint8_t* dest_scan = | 1391 uint8_t* dest_scan = |
1392 pDestBuffer + m_Pitch * (bYFlip ? (m_Height - row - 1) : row); | 1392 pDestBuffer + m_Pitch * (bYFlip ? (m_Height - row - 1) : row); |
1393 if (!bXFlip) { | 1393 if (!bXFlip) { |
1394 FXSYS_memcpy(dest_scan, src_scan, m_Pitch); | 1394 FXSYS_memcpy(dest_scan, src_scan, m_Pitch); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1442 for (int col = 0; col < m_Width; col++) { | 1442 for (int col = 0; col < m_Width; col++) { |
1443 *dest_scan = *src_scan; | 1443 *dest_scan = *src_scan; |
1444 dest_scan--; | 1444 dest_scan--; |
1445 src_scan++; | 1445 src_scan++; |
1446 } | 1446 } |
1447 } | 1447 } |
1448 } | 1448 } |
1449 return pFlipped; | 1449 return pFlipped; |
1450 } | 1450 } |
1451 CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { | 1451 CFX_DIBExtractor::CFX_DIBExtractor(const CFX_DIBSource* pSrc) { |
1452 m_pBitmap = NULL; | 1452 m_pBitmap = nullptr; |
1453 if (pSrc->GetBuffer()) { | 1453 if (pSrc->GetBuffer()) { |
1454 m_pBitmap = new CFX_DIBitmap; | 1454 m_pBitmap = new CFX_DIBitmap; |
1455 if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), | 1455 if (!m_pBitmap->Create(pSrc->GetWidth(), pSrc->GetHeight(), |
1456 pSrc->GetFormat(), pSrc->GetBuffer())) { | 1456 pSrc->GetFormat(), pSrc->GetBuffer())) { |
1457 delete m_pBitmap; | 1457 delete m_pBitmap; |
1458 m_pBitmap = NULL; | 1458 m_pBitmap = nullptr; |
1459 return; | 1459 return; |
1460 } | 1460 } |
1461 m_pBitmap->CopyPalette(pSrc->GetPalette()); | 1461 m_pBitmap->CopyPalette(pSrc->GetPalette()); |
1462 m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask); | 1462 m_pBitmap->CopyAlphaMask(pSrc->m_pAlphaMask); |
1463 } else { | 1463 } else { |
1464 m_pBitmap = pSrc->Clone(); | 1464 m_pBitmap = pSrc->Clone(); |
1465 } | 1465 } |
1466 } | 1466 } |
1467 CFX_DIBExtractor::~CFX_DIBExtractor() { | 1467 CFX_DIBExtractor::~CFX_DIBExtractor() { |
1468 delete m_pBitmap; | 1468 delete m_pBitmap; |
1469 } | 1469 } |
1470 CFX_FilteredDIB::CFX_FilteredDIB() { | 1470 CFX_FilteredDIB::CFX_FilteredDIB() { |
1471 m_pScanline = NULL; | 1471 m_pScanline = nullptr; |
1472 m_pSrc = NULL; | 1472 m_pSrc = nullptr; |
1473 } | 1473 } |
1474 CFX_FilteredDIB::~CFX_FilteredDIB() { | 1474 CFX_FilteredDIB::~CFX_FilteredDIB() { |
1475 if (m_bAutoDropSrc) { | 1475 if (m_bAutoDropSrc) { |
1476 delete m_pSrc; | 1476 delete m_pSrc; |
1477 } | 1477 } |
1478 FX_Free(m_pScanline); | 1478 FX_Free(m_pScanline); |
1479 } | 1479 } |
1480 void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc) { | 1480 void CFX_FilteredDIB::LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc) { |
1481 m_pSrc = pSrc; | 1481 m_pSrc = pSrc; |
1482 m_bAutoDropSrc = bAutoDropSrc; | 1482 m_bAutoDropSrc = bAutoDropSrc; |
(...skipping 16 matching lines...) Expand all Loading... |
1499 int dest_width, | 1499 int dest_width, |
1500 FX_BOOL bFlipX, | 1500 FX_BOOL bFlipX, |
1501 int clip_left, | 1501 int clip_left, |
1502 int clip_width) const { | 1502 int clip_width) const { |
1503 m_pSrc->DownSampleScanline(line, dest_scan, dest_bpp, dest_width, bFlipX, | 1503 m_pSrc->DownSampleScanline(line, dest_scan, dest_bpp, dest_width, bFlipX, |
1504 clip_left, clip_width); | 1504 clip_left, clip_width); |
1505 TranslateDownSamples(dest_scan, dest_scan, clip_width, dest_bpp); | 1505 TranslateDownSamples(dest_scan, dest_scan, clip_width, dest_bpp); |
1506 } | 1506 } |
1507 CFX_ImageRenderer::CFX_ImageRenderer() { | 1507 CFX_ImageRenderer::CFX_ImageRenderer() { |
1508 m_Status = 0; | 1508 m_Status = 0; |
1509 m_pTransformer = NULL; | 1509 m_pTransformer = nullptr; |
1510 m_bRgbByteOrder = FALSE; | 1510 m_bRgbByteOrder = FALSE; |
1511 m_BlendType = FXDIB_BLEND_NORMAL; | 1511 m_BlendType = FXDIB_BLEND_NORMAL; |
1512 } | 1512 } |
1513 CFX_ImageRenderer::~CFX_ImageRenderer() { | 1513 CFX_ImageRenderer::~CFX_ImageRenderer() { |
1514 delete m_pTransformer; | 1514 delete m_pTransformer; |
1515 } | 1515 } |
1516 | 1516 |
1517 FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, | 1517 FX_BOOL CFX_ImageRenderer::Start(CFX_DIBitmap* pDevice, |
1518 const CFX_ClipRgn* pClipRgn, | 1518 const CFX_ClipRgn* pClipRgn, |
1519 const CFX_DIBSource* pSource, | 1519 const CFX_DIBSource* pSource, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1673 uint32_t* pSrcPalette) { | 1673 uint32_t* pSrcPalette) { |
1674 m_pBitmap.reset(new CFX_DIBitmap); | 1674 m_pBitmap.reset(new CFX_DIBitmap); |
1675 if (!m_pBitmap->Create(width, height, src_format)) { | 1675 if (!m_pBitmap->Create(width, height, src_format)) { |
1676 m_pBitmap.reset(); | 1676 m_pBitmap.reset(); |
1677 return FALSE; | 1677 return FALSE; |
1678 } | 1678 } |
1679 if (pSrcPalette) | 1679 if (pSrcPalette) |
1680 m_pBitmap->CopyPalette(pSrcPalette); | 1680 m_pBitmap->CopyPalette(pSrcPalette); |
1681 return TRUE; | 1681 return TRUE; |
1682 } | 1682 } |
OLD | NEW |