#include "core/fxge/dib/cfx_scanlinecompositor.h"
#include <algorithm>
#include "core/fxcrt/check.h"
#include "core/fxcrt/check_op.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/fx_memcpy_wrappers.h"
#include "core/fxcrt/notreached.h"
#include "core/fxcrt/span_util.h"
#include "core/fxcrt/stl_util.h"
#include "core/fxcrt/zip.h"
#include "core/fxge/dib/blend.h"
#include "core/fxge/dib/fx_dib.h"
Blend;
namespace {
uint8_t AlphaUnion(uint8_t dest, uint8_t src) { … }
int Lum(FX_RGB_STRUCT<int> color) { … }
FX_RGB_STRUCT<int> ClipColor(FX_RGB_STRUCT<int> color) { … }
FX_RGB_STRUCT<int> SetLum(FX_RGB_STRUCT<int> color, int l) { … }
int Sat(FX_RGB_STRUCT<int> color) { … }
FX_RGB_STRUCT<int> SetSat(FX_RGB_STRUCT<int> color, int s) { … }
template <typename T, typename U>
FX_RGB_STRUCT<int> RgbBlend(BlendMode blend_type,
const T& src_in,
const U& back_in) { … }
void RGB_Blend(BlendMode blend_mode,
const uint8_t* src_scan,
const uint8_t* dest_scan,
int results[3]) { … }
int GetAlpha(uint8_t src_alpha, const uint8_t* clip_scan, int col) { … }
int GetAlphaWithSrc(uint8_t src_alpha,
pdfium::span<const uint8_t> clip_scan,
pdfium::span<const uint8_t> src_scan,
size_t col) { … }
template <typename T, typename U>
void AlphaMergeToDest(const T& input, U& output, uint8_t alpha) { … }
#if defined(PDF_USE_SKIA)
template <typename T, typename U>
void AlphaMergeToDestPremul(const T& input, U& output) { … }
#endif
template <typename T, typename U>
void AlphaMergeToSource(const T& input, U& output, uint8_t alpha) { … }
void CompositePixelBgra2Mask(const FX_BGRA_STRUCT<uint8_t>& input,
uint8_t clip,
uint8_t& output) { … }
void CompositeRowBgra2Mask(pdfium::span<const FX_BGRA_STRUCT<uint8_t>> src_span,
pdfium::span<const uint8_t> clip_span,
pdfium::span<uint8_t> dest_span) { … }
void CompositeRow_Rgb2Mask(pdfium::span<uint8_t> dest_span,
int width,
pdfium::span<const uint8_t> clip_span) { … }
bool IsNonSeparableBlendMode(BlendMode mode) { … }
template <typename T>
uint8_t GetGrayWithBlend(const T& input,
uint8_t output_value,
BlendMode blend_type) { … }
void CompositePixelBgra2Gray(const FX_BGRA_STRUCT<uint8_t>& input,
uint8_t clip,
uint8_t& output,
BlendMode blend_type) { … }
void CompositeRowBgra2Gray(pdfium::span<const FX_BGRA_STRUCT<uint8_t>> src_span,
pdfium::span<const uint8_t> clip_span,
pdfium::span<uint8_t> dest_span,
BlendMode blend_type) { … }
void CompositeRow_Rgb2Gray(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int src_Bpp,
int pixel_count,
BlendMode blend_type,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_Bgr2Bgra_Blend_NoClip(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
BlendMode blend_type,
int src_Bpp) { … }
void CompositeRow_Bgr2Bgra_Blend_Clip(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
BlendMode blend_type,
int src_Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_Bgr2Bgra_NoBlend_Clip(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
int src_Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_Bgr2Bgra_NoBlend_NoClip(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
int src_Bpp) { … }
template <typename DestPixelStruct>
void CompositePixelBgra2BgrNonSeparableBlend(
const FX_BGRA_STRUCT<uint8_t>& input,
uint8_t clip,
DestPixelStruct& output,
BlendMode blend_type) { … }
template <typename DestPixelStruct>
void CompositePixelBgra2BgrBlend(const FX_BGRA_STRUCT<uint8_t>& input,
uint8_t clip,
DestPixelStruct& output,
BlendMode blend_type) { … }
template <typename DestPixelStruct>
void CompositePixelBgra2BgrNoBlend(const FX_BGRA_STRUCT<uint8_t>& input,
uint8_t clip,
DestPixelStruct& output) { … }
template <typename DestPixelStruct>
void CompositeRowBgra2Bgr(pdfium::span<const FX_BGRA_STRUCT<uint8_t>> src_span,
pdfium::span<const uint8_t> clip_span,
pdfium::span<DestPixelStruct> dest_span,
BlendMode blend_type) { … }
template <typename DestPixelStruct>
uint8_t CompositePixelBgra2BgraCommon(const FX_BGRA_STRUCT<uint8_t>& input,
uint8_t clip,
DestPixelStruct& output) { … }
template <typename DestPixelStruct>
void CompositePixelBgra2BgraNonSeparableBlend(
const FX_BGRA_STRUCT<uint8_t>& input,
uint8_t src_alpha,
DestPixelStruct& output,
BlendMode blend_type) { … }
template <typename DestPixelStruct>
void CompositePixelBgra2BgraBlend(const FX_BGRA_STRUCT<uint8_t>& input,
uint8_t src_alpha,
DestPixelStruct& output,
BlendMode blend_type) { … }
template <typename DestPixelStruct>
void CompositePixelBgra2BgraNoBlend(const FX_BGRA_STRUCT<uint8_t>& input,
uint8_t src_alpha,
DestPixelStruct& output) { … }
template <typename DestPixelStruct>
void CompositeRowBgra2Bgra(pdfium::span<const FX_BGRA_STRUCT<uint8_t>> src_span,
pdfium::span<const uint8_t> clip_span,
pdfium::span<DestPixelStruct> dest_span,
BlendMode blend_type) { … }
#if defined(PDF_USE_SKIA)
template <typename DestPixelStruct>
uint8_t CompositePixelBgraPremul2BgraPremulCommon(
const FX_BGRA_STRUCT<uint8_t>& input,
DestPixelStruct& output) { … }
template <typename DestPixelStruct>
void CompositePixelBgraPremul2BgraPremulNonSeparableBlend(
const FX_BGRA_STRUCT<uint8_t>& input,
DestPixelStruct& output,
BlendMode blend_type) { … }
template <typename DestPixelStruct>
void CompositePixelBgraPremul2BgraPremulBlend(
const FX_BGRA_STRUCT<uint8_t>& input,
DestPixelStruct& output,
BlendMode blend_type) { … }
template <typename DestPixelStruct>
void CompositePixelBgraPremul2BgraPremulNoBlend(
const FX_BGRA_STRUCT<uint8_t>& input,
DestPixelStruct& output) { … }
template <typename DestPixelStruct>
void CompositeRowBgraPremul2BgraPremul(
pdfium::span<const FX_BGRA_STRUCT<uint8_t>> src_span,
pdfium::span<DestPixelStruct> dest_span,
BlendMode blend_type) { … }
#endif
void CompositeRow_Rgb2Rgb_Blend_NoClip(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
BlendMode blend_type,
int dest_Bpp,
int src_Bpp) { … }
void CompositeRow_Rgb2Rgb_Blend_Clip(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
BlendMode blend_type,
int dest_Bpp,
int src_Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_Rgb2Rgb_NoBlend_NoClip(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
int dest_Bpp,
int src_Bpp) { … }
void CompositeRow_Rgb2Rgb_NoBlend_Clip(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
int dest_Bpp,
int src_Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_8bppPal2Gray(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
pdfium::span<const uint8_t> palette_span,
int pixel_count,
BlendMode blend_type,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_1bppPal2Gray(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int src_left,
pdfium::span<const uint8_t> src_palette,
int pixel_count,
BlendMode blend_type,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_8bppRgb2Rgb_NoBlend(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
pdfium::span<const uint32_t> palette_span,
int pixel_count,
int DestBpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_1bppRgb2Rgb_NoBlend(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int src_left,
pdfium::span<const uint32_t> src_palette,
int pixel_count,
int DestBpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_8bppBgr2Bgra_NoBlend(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
pdfium::span<const uint32_t> palette_span,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_1bppBgr2Bgra_NoBlend(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int src_left,
int width,
pdfium::span<const uint32_t> src_palette,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_ByteMask2Bgra(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_r,
int src_g,
int src_b,
int pixel_count,
BlendMode blend_type,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_ByteMask2Rgb(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_r,
int src_g,
int src_b,
int pixel_count,
BlendMode blend_type,
int Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_ByteMask2Mask(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int pixel_count,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_ByteMask2Gray(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_gray,
int pixel_count,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_BitMask2Bgra(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_r,
int src_g,
int src_b,
int src_left,
int pixel_count,
BlendMode blend_type,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_BitMask2Rgb(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_r,
int src_g,
int src_b,
int src_left,
int pixel_count,
BlendMode blend_type,
int Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_BitMask2Mask(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_left,
int pixel_count,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_BitMask2Gray(pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_gray,
int src_left,
int pixel_count,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_Bgr2Bgra_Blend_NoClip_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
BlendMode blend_type,
int src_Bpp) { … }
void CompositeRow_Bgr2Bgra_NoBlend_NoClip_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
int src_Bpp) { … }
void CompositeRow_Rgb2Rgb_Blend_NoClip_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
BlendMode blend_type,
int dest_Bpp,
int src_Bpp) { … }
void CompositeRow_Rgb2Rgb_NoBlend_NoClip_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
int dest_Bpp,
int src_Bpp) { … }
void CompositeRow_Bgr2Bgra_Blend_Clip_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
BlendMode blend_type,
int src_Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_Rgb2Rgb_Blend_Clip_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
BlendMode blend_type,
int dest_Bpp,
int src_Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_Bgr2Bgra_NoBlend_Clip_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
int src_Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_Rgb2Rgb_NoBlend_Clip_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
int dest_Bpp,
int src_Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_8bppRgb2Rgb_NoBlend_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
const FX_ARGB* pPalette,
int pixel_count,
int DestBpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_1bppRgb2Rgb_NoBlend_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int src_left,
pdfium::span<const FX_ARGB> src_palette,
int pixel_count,
int DestBpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_8bppBgr2Bgra_NoBlend_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int width,
const FX_ARGB* pPalette,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_1bppBgr2Bgra_NoBlend_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int src_left,
int width,
pdfium::span<const FX_ARGB> src_palette,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_ByteMask2Bgra_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_r,
int src_g,
int src_b,
int pixel_count,
BlendMode blend_type,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_ByteMask2Rgb_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_r,
int src_g,
int src_b,
int pixel_count,
BlendMode blend_type,
int Bpp,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_BitMask2Bgra_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_r,
int src_g,
int src_b,
int src_left,
int pixel_count,
BlendMode blend_type,
pdfium::span<const uint8_t> clip_span) { … }
void CompositeRow_BitMask2Rgb_RgbByteOrder(
pdfium::span<uint8_t> dest_span,
pdfium::span<const uint8_t> src_span,
int mask_alpha,
int src_r,
int src_g,
int src_b,
int src_left,
int pixel_count,
BlendMode blend_type,
int Bpp,
pdfium::span<const uint8_t> clip_span) { … }
}
CFX_ScanlineCompositor::CFX_ScanlineCompositor() = default;
CFX_ScanlineCompositor::~CFX_ScanlineCompositor() = default;
bool CFX_ScanlineCompositor::Init(FXDIB_Format dest_format,
FXDIB_Format src_format,
pdfium::span<const uint32_t> src_palette,
uint32_t mask_color,
BlendMode blend_type,
bool bRgbByteOrder) { … }
void CFX_ScanlineCompositor::InitSourceMask(uint32_t mask_color) { … }
void CFX_ScanlineCompositor::InitSourcePalette(
pdfium::span<const uint32_t> src_palette) { … }
void CFX_ScanlineCompositor::CompositeRgbBitmapLine(
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int width,
pdfium::span<const uint8_t> clip_scan) const { … }
void CFX_ScanlineCompositor::CompositeRgbBitmapLineSrcBgrx(
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int width,
pdfium::span<const uint8_t> clip_scan) const { … }
void CFX_ScanlineCompositor::CompositeRgbBitmapLineSrcBgra(
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int width,
pdfium::span<const uint8_t> clip_scan) const { … }
#if defined(PDF_USE_SKIA)
void CFX_ScanlineCompositor::CompositeRgbBitmapLineSrcBgraPremul(
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int width) const { … }
#endif
void CFX_ScanlineCompositor::CompositePalBitmapLine(
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int src_left,
int width,
pdfium::span<const uint8_t> clip_scan) const { … }
void CFX_ScanlineCompositor::CompositePalBitmapLineSrcBpp1(
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int src_left,
int width,
pdfium::span<const uint8_t> clip_scan) const { … }
void CFX_ScanlineCompositor::CompositePalBitmapLineSrcBpp8(
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int src_left,
int width,
pdfium::span<const uint8_t> clip_scan) const { … }
void CFX_ScanlineCompositor::CompositeByteMaskLine(
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int width,
pdfium::span<const uint8_t> clip_scan) const { … }
void CFX_ScanlineCompositor::CompositeBitMaskLine(
pdfium::span<uint8_t> dest_scan,
pdfium::span<const uint8_t> src_scan,
int src_left,
int width,
pdfium::span<const uint8_t> clip_scan) const { … }
CFX_ScanlineCompositor::Palette::Palette() = default;
CFX_ScanlineCompositor::Palette::~Palette() = default;
void CFX_ScanlineCompositor::Palette::Reset() { … }
pdfium::span<uint8_t> CFX_ScanlineCompositor::Palette::Make8BitPalette(
size_t nElements) { … }
pdfium::span<uint32_t> CFX_ScanlineCompositor::Palette::Make32BitPalette(
size_t nElements) { … }
pdfium::span<const uint8_t> CFX_ScanlineCompositor::Palette::Get8BitPalette()
const { … }
pdfium::span<const uint32_t> CFX_ScanlineCompositor::Palette::Get32BitPalette()
const { … }