7#include "core/fxge/dib/cfx_dibbase.h"
13#include "core/fxcrt/check.h"
14#include "core/fxcrt/check_op.h"
15#include "core/fxcrt/data_vector.h"
16#include "core/fxcrt/fx_2d_size.h"
17#include "core/fxcrt/fx_coordinates.h"
18#include "core/fxcrt/fx_memcpy_wrappers.h"
19#include "core/fxcrt/fx_memory.h"
20#include "core/fxcrt/fx_safe_types.h"
21#include "core/fxcrt/notreached.h"
22#include "core/fxcrt/span.h"
23#include "core/fxcrt/span_util.h"
24#include "core/fxcrt/stl_util.h"
25#include "core/fxcrt/zip.h"
26#include "core/fxge/agg/cfx_agg_cliprgn.h"
27#include "core/fxge/calculate_pitch.h"
28#include "core/fxge/dib/cfx_bitmapstorer.h"
29#include "core/fxge/dib/cfx_dibitmap.h"
30#include "core/fxge/dib/cfx_imagestretcher.h"
31#include "core/fxge/dib/cfx_imagetransformer.h"
35#if defined(PDF_USE_SKIA)
36void ConvertBuffer_Rgb2ArgbPremul(
37 pdfium::span<uint8_t> dest_buf,
41 const RetainPtr<
const CFX_DIBBase>& src_bitmap,
44 for (
int row = 0; row < height; ++row) {
45 auto dest_span = fxcrt::reinterpret_span<FX_BGRA_STRUCT<uint8_t>>(
46 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)));
48 src_bitmap->GetScanlineAs<FX_BGR_STRUCT<uint8_t>>(src_top + row)
50 for (
auto [input, output] : fxcrt::Zip(src_span, dest_span)) {
51 output.blue = input.blue;
52 output.green = input.green;
53 output.red = input.red;
59void ConvertBuffer_ArgbPremulToRgb(
60 pdfium::span<uint8_t> dest_buf,
64 const RetainPtr<
const CFX_DIBBase>& src_bitmap,
67 for (
int row = 0; row < height; ++row) {
68 auto dest_span = fxcrt::reinterpret_span<FX_BGR_STRUCT<uint8_t>>(
69 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)));
71 src_bitmap->GetScanlineAs<FX_BGRA_STRUCT<uint8_t>>(src_top + row)
73 for (
auto [input, output] : fxcrt::Zip(src_span, dest_span)) {
74 auto unpremultiplied_input = UnPreMultiplyColor(input);
75 output.blue = unpremultiplied_input.blue;
76 output.green = unpremultiplied_input.green;
77 output.red = unpremultiplied_input.red;
82void ConvertBuffer_ArgbPremul(pdfium::span<uint8_t> dest_buf,
86 const RetainPtr<
const CFX_DIBBase>& src_bitmap,
89 switch (src_bitmap->GetBPP()) {
92 NOTREACHED_NORETURN();
94 ConvertBuffer_Rgb2ArgbPremul(dest_buf, dest_pitch, width, height,
95 src_bitmap, src_left, src_top);
99 NOTREACHED_NORETURN();
101 NOTREACHED_NORETURN();
106void ConvertBuffer_1bppMask2Gray(pdfium::span<uint8_t> dest_buf,
113 static constexpr uint8_t kSetGray = 0xff;
114 static constexpr uint8_t kResetGray = 0x00;
115 for (
int row = 0; row < height; ++row) {
116 pdfium::span<uint8_t> dest_span =
117 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch));
118 pdfium::span<
const uint8_t> src_span =
119 pSrcBitmap->GetScanline(src_top + row);
120 fxcrt::Fill(dest_span.first(width), kResetGray);
121 uint8_t* dest_scan = dest_span.data();
122 const uint8_t* src_scan = src_span.data();
124 for (
int col = src_left; col < src_left + width; ++col) {
125 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
126 *dest_scan = kSetGray;
134void ConvertBuffer_8bppMask2Gray(pdfium::span<uint8_t> dest_buf,
141 for (
int row = 0; row < height; ++row) {
142 fxcrt::Copy(pSrcBitmap->GetScanline(src_top + row).subspan(src_left, width),
143 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)));
147void ConvertBuffer_8bppPlt2Gray(pdfium::span<uint8_t> dest_buf,
154 pdfium::span<
const uint32_t> src_palette = src->GetPaletteSpan();
156 std::array<uint8_t, 256> gray;
157 for (
auto [input, output] : fxcrt::Zip(src_palette, gray)) {
160 for (
int row = 0; row < height; ++row) {
161 auto dest_scan = dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch));
162 auto src_scan = src->GetScanline(src_top + row).subspan(src_left, width);
163 for (
auto [input, output] : fxcrt::Zip(src_scan, dest_scan)) {
164 output = gray[input];
169void ConvertBuffer_Rgb2Gray(pdfium::span<uint8_t> dest_buf,
176 const int bytes_per_pixel = pSrcBitmap->GetBPP() / 8;
177 const size_t x_offset = Fx2DSizeOrDie(src_left, bytes_per_pixel);
178 for (
int row = 0; row < height; ++row) {
180 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)).data();
181 const uint8_t* src_scan =
182 pSrcBitmap->GetScanline(src_top + row).subspan(x_offset).data();
184 for (
int col = 0; col < width; ++col) {
185 *dest_scan++ =
FXRGB2GRAY(src_scan[2], src_scan[1], src_scan[0]);
186 src_scan += bytes_per_pixel;
192void ConvertBuffer_IndexCopy(pdfium::span<uint8_t> dest_buf,
199 if (pSrcBitmap->GetBPP() == 1) {
200 for (
int row = 0; row < height; ++row) {
201 pdfium::span<uint8_t> dest_span =
202 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch));
204 fxcrt::Fill(dest_span.first(width), 255);
205 uint8_t* dest_scan = dest_span.data();
206 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row).data();
208 for (
int col = src_left; col < src_left + width; ++col) {
211 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
220 for (
int row = 0; row < height; ++row) {
222 pSrcBitmap->GetScanline(src_top + row).subspan(src_left, width),
223 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)));
229DataVector<uint32_t> ConvertBuffer_Plt2PltRgb8(
230 pdfium::span<uint8_t> dest_buf,
237 ConvertBuffer_IndexCopy(dest_buf, dest_pitch, width, height, pSrcBitmap,
239 const size_t plt_size = pSrcBitmap->GetRequiredPaletteSize();
240 pdfium::span<
const uint32_t> src_span = pSrcBitmap->GetPaletteSpan();
241 CHECK_LE(plt_size, src_span.size());
243 pdfium::span<
const uint32_t> src_palette_span = src_span.first(plt_size);
244 return DataVector<uint32_t>(src_palette_span.begin(), src_palette_span.end());
247void ConvertBuffer_1bppMask2Rgb(pdfium::span<uint8_t> dest_buf,
254 static constexpr uint8_t kSetGray = 0xff;
255 static constexpr uint8_t kResetGray = 0x00;
256 for (
int row = 0; row < height; ++row) {
258 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)).data();
259 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row).data();
261 for (
int col = src_left; col < src_left + width; ++col) {
263 (src_scan[col / 8] & (1 << (7 - col % 8))) ? kSetGray : kResetGray;
271void ConvertBuffer_8bppMask2Rgb(
FXDIB_Format dest_format,
272 pdfium::span<uint8_t> dest_buf,
280 for (
int row = 0; row < height; ++row) {
282 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)).data();
283 const uint8_t* src_scan =
284 pSrcBitmap->GetScanline(src_top + row).subspan(src_left).data();
286 for (
int col = 0; col < width; ++col) {
295void ConvertBuffer_1bppPlt2Rgb(pdfium::span<uint8_t> dest_buf,
302 pdfium::span<
const uint32_t> src_palette = pSrcBitmap->GetPaletteSpan();
303 const uint8_t dst_palette[6] = {
307 for (
int row = 0; row < height; ++row) {
309 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)).data();
310 const uint8_t* src_scan = pSrcBitmap->GetScanline(src_top + row).data();
312 for (
int col = src_left; col < src_left + width; ++col) {
313 size_t offset = (src_scan[col / 8] & (1 << (7 - col % 8))) ? 3 : 0;
314 FXSYS_memcpy(dest_scan, dst_palette + offset, 3);
322 pdfium::span<uint8_t> dest_buf,
329 pdfium::span<
const uint32_t> src_palette = pSrcBitmap->GetPaletteSpan();
331 uint8_t dst_palette[768];
333 for (
int i = 0; i < 256; ++i) {
334 dst_palette[3 * i] =
FXARGB_B(src_palette[i]);
335 dst_palette[3 * i + 1] =
FXARGB_G(src_palette[i]);
336 dst_palette[3 * i + 2] =
FXARGB_R(src_palette[i]);
340 for (
int row = 0; row < height; ++row) {
342 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)).data();
343 const uint8_t* src_scan =
344 pSrcBitmap->GetScanline(src_top + row).subspan(src_left).data();
345 for (
int col = 0; col < width; ++col) {
347 uint8_t* src_pixel = dst_palette + 3 * (*src_scan++);
355void ConvertBuffer_24bppRgb2Rgb24(
356 pdfium::span<uint8_t> dest_buf,
363 const size_t x_offset = Fx2DSizeOrDie(src_left, 3);
364 const size_t byte_count = Fx2DSizeOrDie(width, 3);
365 for (
int row = 0; row < height; ++row) {
367 pSrcBitmap->GetScanline(src_top + row).subspan(x_offset, byte_count),
368 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)));
372void ConvertBuffer_32bppRgb2Rgb24(
373 pdfium::span<uint8_t> dest_buf,
380 const size_t x_offset = Fx2DSizeOrDie(src_left, 4);
381 for (
int row = 0; row < height; ++row) {
383 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)).data();
384 const uint8_t* src_scan =
385 pSrcBitmap->GetScanline(src_top + row).subspan(x_offset).data();
387 for (
int col = 0; col < width; ++col) {
396void ConvertBuffer_Rgb2Rgb32(pdfium::span<uint8_t> dest_buf,
403 const int comps = pSrcBitmap->GetBPP() / 8;
404 const size_t x_offset = Fx2DSizeOrDie(src_left, comps);
405 for (
int row = 0; row < height; ++row) {
407 dest_buf.subspan(Fx2DSizeOrDie(row, dest_pitch)).data();
408 const uint8_t* src_scan =
409 pSrcBitmap->GetScanline(src_top + row).subspan(x_offset).data();
411 for (
int col = 0; col < width; ++col) {
420void ConvertBuffer_8bppMask(pdfium::span<uint8_t> dest_buf,
427 switch (pSrcBitmap->GetBPP()) {
429 CHECK(!pSrcBitmap->HasPalette());
430 ConvertBuffer_1bppMask2Gray(dest_buf, dest_pitch, width, height,
431 pSrcBitmap, src_left, src_top);
434 if (pSrcBitmap->HasPalette()) {
435 ConvertBuffer_8bppPlt2Gray(dest_buf, dest_pitch, width, height,
436 pSrcBitmap, src_left, src_top);
438 ConvertBuffer_8bppMask2Gray(dest_buf, dest_pitch, width, height,
439 pSrcBitmap, src_left, src_top);
444#if defined(PDF_USE_SKIA)
446 CHECK_NE(pSrcBitmap->GetFormat(), FXDIB_Format::kBgraPremul);
448 ConvertBuffer_Rgb2Gray(dest_buf, dest_pitch, width, height, pSrcBitmap,
457 pdfium::span<uint8_t> dest_buf,
464 switch (pSrcBitmap->GetBPP()) {
466 if (pSrcBitmap->HasPalette()) {
467 ConvertBuffer_1bppPlt2Rgb(dest_buf, dest_pitch, width, height,
468 pSrcBitmap, src_left, src_top);
470 ConvertBuffer_1bppMask2Rgb(dest_buf, dest_pitch, width, height,
471 pSrcBitmap, src_left, src_top);
475 if (pSrcBitmap->HasPalette()) {
476 ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width,
477 height, pSrcBitmap, src_left, src_top);
479 ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch, width,
480 height, pSrcBitmap, src_left, src_top);
484 ConvertBuffer_24bppRgb2Rgb24(dest_buf, dest_pitch, width, height,
485 pSrcBitmap, src_left, src_top);
488#if defined(PDF_USE_SKIA)
489 if (pSrcBitmap->GetFormat() == FXDIB_Format::kBgraPremul) {
490 ConvertBuffer_ArgbPremulToRgb(dest_buf, dest_pitch, width, height,
491 pSrcBitmap, src_left, src_top);
495 ConvertBuffer_32bppRgb2Rgb24(dest_buf, dest_pitch, width, height,
496 pSrcBitmap, src_left, src_top);
504 pdfium::span<uint8_t> dest_buf,
511 switch (pSrcBitmap->GetBPP()) {
513 if (pSrcBitmap->HasPalette()) {
514 ConvertBuffer_8bppPlt2Rgb(dest_format, dest_buf, dest_pitch, width,
515 height, pSrcBitmap, src_left, src_top);
517 ConvertBuffer_8bppMask2Rgb(dest_format, dest_buf, dest_pitch, width,
518 height, pSrcBitmap, src_left, src_top);
523#if defined(PDF_USE_SKIA)
525 CHECK_NE(pSrcBitmap->GetFormat(), FXDIB_Format::kBgraPremul);
527 ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width, height, pSrcBitmap,
546 return GetRequiredPaletteSize() *
sizeof(uint32_t);
549#if BUILDFLAG(IS_WIN) || defined(PDF_USE_SKIA)
550RetainPtr<
const CFX_DIBitmap> CFX_DIBBase::RealizeIfNeeded()
const {
571 auto pNewBitmap =
pdfium::MakeRetain<CFX_DIBitmap>();
575 pNewBitmap->SetPalette(GetPaletteSpan());
577 int left_shift = rect
.left % 32;
578 int right_shift = 32 - left_shift;
579 int dword_count = pNewBitmap->GetPitch() / 4;
580 for (
int row = rect
.top; row < rect
.bottom; ++row) {
581 auto src_span = GetScanlineAs<uint32_t>(row);
583 pNewBitmap->GetWritableScanlineAs<uint32_t>(row - rect
.top);
585 const uint32_t* src_scan =
586 src_span.subspan(rect
.left / 32, dword_count + 1).data();
587 uint32_t* dst_scan = dst_span.first(dword_count).data();
589 for (
int i = 0; i < dword_count; ++i) {
591 (src_scan[i] << left_shift) | (src_scan[i + 1] >> right_shift);
596 std::optional<uint32_t> copy_len = fxge::CalculatePitch8(
597 pNewBitmap->GetBPP(), 1, pNewBitmap->GetWidth());
598 if (!copy_len.has_value()) {
607 if (!offset.IsValid())
610 for (
int row = rect
.top; row < rect
.bottom; ++row) {
611 const uint8_t* src_scan =
612 GetScanline(row).subspan(offset.ValueOrDie()).data();
614 pNewBitmap->GetWritableScanline(row - rect
.top).data();
615 UNSAFE_TODO(FXSYS_memcpy(dest_scan, src_scan, copy_len.value()));
626 palette_ = {0xff000000, 0xffffffff};
628 palette_.resize(256);
629 for (
int i = 0; i < 256; ++i)
630 palette_[i] = ArgbEncode(0xff, i, i, i);
649 DCHECK((GetBPP() == 1 || GetBPP() == 8) && !IsMaskFormat());
651 return GetPaletteSpan()[index];
654 return index ? 0xffffffff : 0xff000000;
660 DCHECK((GetBPP() == 1 || GetBPP() == 8) && !IsMaskFormat());
662 palette_[index] = color;
666 DCHECK((GetBPP() == 1 || GetBPP() == 8) && !IsMaskFormat());
669 pdfium::span<
const uint32_t> palette = GetPaletteSpan();
670 for (
int i = 0; i < palsize; ++i) {
671 if (palette[i] == color)
678 return (
static_cast<uint8_t>(color) == 0xff) ? 1 : 0;
679 return static_cast<uint8_t>(color);
691 if (width == 0 || height == 0)
702 safe_src_width += width;
703 if (!safe_src_width.IsValid())
707 safe_src_height += height;
708 if (!safe_src_height.IsValid())
711 FX_RECT src_rect(src_left, src_top, safe_src_width.ValueOrDie(),
712 safe_src_height.ValueOrDie());
717 safe_x_offset -= src_left;
718 if (!safe_x_offset.IsValid())
722 safe_y_offset -= src_top;
723 if (!safe_y_offset.IsValid())
727 safe_dest_left += src_rect
.left;
728 if (!safe_dest_left.IsValid())
732 safe_dest_top += src_rect
.top;
733 if (!safe_dest_top.IsValid())
737 safe_dest_right += src_rect
.right;
738 if (!safe_dest_right.IsValid())
742 safe_dest_bottom += src_rect
.bottom;
743 if (!safe_dest_bottom.IsValid())
746 FX_RECT dest_rect(safe_dest_left.ValueOrDie(), safe_dest_top.ValueOrDie(),
747 safe_dest_right.ValueOrDie(),
748 safe_dest_bottom.ValueOrDie());
754 dest_left = dest_rect
.left;
755 dest_top = dest_rect
.top;
758 safe_new_src_left -= safe_x_offset;
759 if (!safe_new_src_left.IsValid())
761 src_left = safe_new_src_left.ValueOrDie();
764 safe_new_src_top -= safe_y_offset;
765 if (!safe_new_src_top.IsValid())
767 src_top = safe_new_src_top.ValueOrDie();
778 TakePalette(DataVector<uint32_t>(src_palette.begin(), src_palette.end()));
782 if (src_palette.empty() ||
GetBPP() > 8) {
787 palette_ = std::move(src_palette);
790 palette_.resize(pal_size);
797 auto pMask =
pdfium::MakeRetain<CFX_DIBitmap>();
803 const uint8_t* src_scan = GetScanline(row).subspan(3).data();
804 uint8_t* dest_scan = pMask->GetWritableScanline(row).data();
807 *dest_scan++ = *src_scan;
816 auto pFlipped =
pdfium::MakeRetain<CFX_DIBitmap>();
821 pFlipped->SetPalette(GetPaletteSpan());
822 const int bytes_per_pixel =
GetBPP() / 8;
826 const uint8_t* src_scan = GetScanline(row).data();
828 pFlipped->GetWritableScanline(bYFlip ?
GetHeight() - row - 1 : row)
839 const uint8_t* src_scan = GetScanline(row).data();
841 pFlipped->GetWritableScanline(bYFlip ?
GetHeight() - row - 1 : row)
845 if (src_scan[col / 8] & (1 << (7 - col % 8))) {
847 dest_scan[dest_col / 8] |= (1 << (7 - dest_col % 8));
855 if (bytes_per_pixel == 1) {
858 const uint8_t* src_scan = GetScanline(row).data();
860 pFlipped->GetWritableScanline(bYFlip ?
GetHeight() - row - 1 : row)
862 dest_scan += (
GetWidth() - 1) * bytes_per_pixel;
864 *dest_scan = *src_scan;
873 if (bytes_per_pixel == 3) {
876 const uint8_t* src_scan = GetScanline(row).data();
878 pFlipped->GetWritableScanline(bYFlip ?
GetHeight() - row - 1 : row)
880 dest_scan += (
GetWidth() - 1) * bytes_per_pixel;
894 const uint8_t* src_scan = GetScanline(row).data();
896 pFlipped->GetWritableScanline(bYFlip ?
GetHeight() - row - 1 : row)
898 dest_scan += (
GetWidth() - 1) * bytes_per_pixel;
900 const auto* src_scan32 =
reinterpret_cast<
const uint32_t*>(src_scan);
901 uint32_t* dest_scan32 =
reinterpret_cast<uint32_t*>(dest_scan);
902 *dest_scan32 = *src_scan32;
916 auto pClone =
pdfium::MakeRetain<CFX_DIBitmap>();
922 DataVector<uint32_t> pal_8bpp =
923 ConvertBuffer(dest_format, pClone->GetWritableBuffer(),
925 if (!pal_8bpp.empty()) {
926 pClone->TakePalette(
std::move(pal_8bpp));
936 auto pTransBitmap =
pdfium::MakeRetain<CFX_DIBitmap>();
937 const int result_height = dest_clip
.Height();
938 const int result_width = dest_clip
.Width();
939 if (!pTransBitmap->Create(result_width, result_height,
GetFormat()))
942 pTransBitmap->SetPalette(GetPaletteSpan());
943 const int dest_pitch = pTransBitmap->GetPitch();
944 pdfium::span<uint8_t> dest_span = pTransBitmap->GetWritableBuffer().first(
945 Fx2DSizeOrDie(dest_pitch, result_height));
946 const size_t dest_last_row_offset =
947 Fx2DSizeOrDie(dest_pitch, result_height - 1);
953 fxcrt::Fill(dest_span, 0xff);
955 dest_span = dest_span.subspan(dest_last_row_offset);
957 const int dest_step = bYFlip ? -dest_pitch : dest_pitch;
958 for (
int row = row_start; row < row_end; ++row) {
960 const uint8_t* src_scan = GetScanline(row).data();
962 (bXFlip ? dest_clip
.right - (row - row_start) - 1 : row) -
964 uint8_t* dest_scan = dest_span.data();
965 for (
int col = col_start; col < col_end; ++col) {
966 if (!(src_scan[col / 8] & (1 << (7 - col % 8)))) {
967 dest_scan[dest_col / 8] &= ~(1 << (7 - dest_col % 8));
969 dest_scan += dest_step;
976 const int bytes_per_pixel =
GetBPP() / 8;
977 int dest_step = bYFlip ? -dest_pitch : dest_pitch;
978 if (bytes_per_pixel == 3) {
982 dest_span = dest_span.subspan(dest_last_row_offset);
985 if (bytes_per_pixel == 1) {
986 for (
int row = row_start; row < row_end; ++row) {
989 (bXFlip ? dest_clip
.right - (row - row_start) - 1 : row) -
991 size_t dest_offset = Fx2DSizeOrDie(dest_col, bytes_per_pixel);
992 uint8_t* dest_scan = dest_span.subspan(dest_offset).data();
993 const uint8_t* src_scan =
994 GetScanline(row).subspan(col_start * bytes_per_pixel).data();
995 for (
int col = col_start; col < col_end; ++col) {
996 *dest_scan = *src_scan++;
997 dest_scan += dest_step;
1001 return pTransBitmap;
1004 if (bytes_per_pixel == 3) {
1005 for (
int row = row_start; row < row_end; ++row) {
1008 (bXFlip ? dest_clip
.right - (row - row_start) - 1 : row) -
1010 size_t dest_offset = Fx2DSizeOrDie(dest_col, bytes_per_pixel);
1011 uint8_t* dest_scan = dest_span.subspan(dest_offset).data();
1012 const uint8_t* src_scan =
1013 GetScanline(row).subspan(col_start * bytes_per_pixel).data();
1014 for (
int col = col_start; col < col_end; ++col) {
1016 dest_scan += 2 + dest_step;
1021 return pTransBitmap;
1025 for (
int row = row_start; row < row_end; ++row) {
1027 int dest_col = (bXFlip ? dest_clip
.right - (row - row_start) - 1 : row) -
1029 size_t dest_offset = Fx2DSizeOrDie(dest_col, bytes_per_pixel);
1030 uint8_t* dest_scan = dest_span.subspan(dest_offset).data();
1031 const uint32_t* src_scan =
1032 GetScanlineAs<uint32_t>(row).subspan(col_start).data();
1033 for (
int col = col_start; col < col_end; ++col) {
1034 uint32_t* dest_scan32 =
reinterpret_cast<uint32_t*>(dest_scan);
1035 *dest_scan32 = *src_scan++;
1036 dest_scan += dest_step;
1040 return pTransBitmap;
1045 int* result_top)
const {
1061 FX_RECT clip_rect
(0
, 0
, abs(dest_width)
, abs(dest_height)
);
1069 return ClipTo(clip_rect);
1072 CFX_BitmapStorer storer;
1074 clip_rect, options);
1084 pdfium::span<uint8_t> dest_buf,
1091 switch (dest_format) {
1098 ConvertBuffer_8bppMask(dest_buf, dest_pitch, width, height, pSrcBitmap,
1103 const int src_bpp = pSrcBitmap->GetBPP();
1104 CHECK(src_bpp == 1 || src_bpp == 8);
1105 if (pSrcBitmap->HasPalette()) {
1106 return ConvertBuffer_Plt2PltRgb8(dest_buf, dest_pitch, width, height,
1107 pSrcBitmap, src_left, src_top);
1109 ConvertBuffer_8bppMask(dest_buf, dest_pitch, width, height, pSrcBitmap,
1114 ConvertBuffer_Rgb(dest_format, dest_buf, dest_pitch, width, height,
1115 pSrcBitmap, src_left, src_top);
1120 ConvertBuffer_Argb(dest_format, dest_buf, dest_pitch, width, height,
1121 pSrcBitmap, src_left, src_top);
1124#if defined(PDF_USE_SKIA)
1125 case FXDIB_Format::kBgraPremul: {
1126 ConvertBuffer_ArgbPremul(dest_buf, dest_pitch, width, height, pSrcBitmap,
const FX_RECT & GetBox() const
RetainPtr< CFX_DIBitmap > Detach()
bool GetOverlapRect(int &dest_left, int &dest_top, int &width, int &height, int src_width, int src_height, int &src_left, int &src_top, const CFX_AggClipRgn *pClipRgn) const
int FindPalette(uint32_t color) const
virtual size_t GetEstimatedImageMemoryBurden() const
RetainPtr< CFX_DIBitmap > ClipTo(const FX_RECT &rect) const
RetainPtr< CFX_DIBitmap > Realize() const
RetainPtr< CFX_DIBitmap > SwapXY(bool bXFlip, bool bYFlip) const
void TakePalette(DataVector< uint32_t > src_palette)
virtual bool SkipToScanline(int line, PauseIndicatorIface *pPause) const
RetainPtr< CFX_DIBitmap > CloneAlphaMask() const
void SetPalette(pdfium::span< const uint32_t > src_palette)
FXDIB_Format GetFormat() const
RetainPtr< CFX_DIBitmap > TransformTo(const CFX_Matrix &mtDest, int *left, int *top) const
void SetPaletteArgb(int index, uint32_t color)
uint32_t GetPitch() const
RetainPtr< CFX_DIBitmap > ClipToInternal(const FX_RECT *pClip) const
RetainPtr< CFX_DIBitmap > ConvertTo(FXDIB_Format format) const
RetainPtr< CFX_DIBitmap > StretchTo(int dest_width, int dest_height, const FXDIB_ResampleOptions &options, const FX_RECT *pClip) const
static constexpr uint32_t kPaletteSize
size_t GetRequiredPaletteSize() const
bool IsMaskFormat() const
RetainPtr< CFX_DIBitmap > FlipImage(bool bXFlip, bool bYFlip) const
uint32_t GetPaletteArgb(int index) const
bool Continue(PauseIndicatorIface *pPause)
#define FXRGB2GRAY(r, g, b)
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
int GetCompsFromFormat(FXDIB_Format format)
UNSAFE_BUFFER_USAGE void * FXSYS_memset(void *ptr1, int val, size_t len)
UNSAFE_BUFFER_USAGE void * FXSYS_memcpy(void *ptr1, const void *ptr2, size_t len)
pdfium::CheckedNumeric< uint32_t > FX_SAFE_UINT32
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
#define NOTREACHED_NORETURN()
void Intersect(const FX_RECT &src)
constexpr FX_RECT(int l, int t, int r, int b)