Remove lots of unused CMYK code.
With no CMYK FXDIB_Format entries remaining, GetIsCmykFromFormat()
always returns false, and then so does CFX_DIBBase::IsCmykImage().
Remove these functions and any code that assumes they return true.
Change-Id: I6816c1293b158825e048d28a5479d97d183658af
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/75552
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
diff --git a/core/fxcodec/jpeg/jpegmodule.cpp b/core/fxcodec/jpeg/jpegmodule.cpp
index a63cdef..8084e6f 100644
--- a/core/fxcodec/jpeg/jpegmodule.cpp
+++ b/core/fxcodec/jpeg/jpegmodule.cpp
@@ -419,7 +419,7 @@
cinfo.err = &jerr;
jpeg_create_compress(&cinfo);
int Bpp = pSource->GetBPP() / 8;
- uint32_t nComponents = Bpp >= 3 ? (pSource->IsCmykImage() ? 4 : 3) : 1;
+ uint32_t nComponents = Bpp >= 3 ? 3 : 1;
uint32_t pitch = pSource->GetPitch();
uint32_t width = pdfium::base::checked_cast<uint32_t>(pSource->GetWidth());
uint32_t height = pdfium::base::checked_cast<uint32_t>(pSource->GetHeight());
diff --git a/core/fxge/agg/fx_agg_driver.cpp b/core/fxge/agg/fx_agg_driver.cpp
index e46140c..3d0f9dc 100644
--- a/core/fxge/agg/fx_agg_driver.cpp
+++ b/core/fxge/agg/fx_agg_driver.cpp
@@ -823,8 +823,6 @@
m_pDevice(pDevice),
m_pClipRgn(pClipRgn),
m_CompositeSpanFunc(GetCompositeSpanFunc(m_pDevice)) {
- DCHECK(!m_pDevice->IsCmykImage());
-
if (m_pDevice->GetBPP() == 8) {
ASSERT(!m_bRgbByteOrder);
if (m_pDevice->IsMask())
@@ -1022,7 +1020,6 @@
m_bGroupKnockout(bGroupKnockout),
m_pBackdropBitmap(pBackdropBitmap) {
DCHECK(m_pBitmap);
- DCHECK(!m_pBitmap->IsCmykImage());
InitPlatform();
}
diff --git a/core/fxge/dib/cfx_dibbase.cpp b/core/fxge/dib/cfx_dibbase.cpp
index ef9d6b6..c24ac1f 100644
--- a/core/fxge/dib/cfx_dibbase.cpp
+++ b/core/fxge/dib/cfx_dibbase.cpp
@@ -144,28 +144,13 @@
int src_left,
int src_top) {
pdfium::span<const uint32_t> src_palette = pSrcBitmap->GetPaletteSpan();
+ uint8_t reset_r = FXARGB_R(src_palette[0]);
+ uint8_t reset_g = FXARGB_G(src_palette[0]);
+ uint8_t reset_b = FXARGB_B(src_palette[0]);
+ uint8_t set_r = FXARGB_R(src_palette[1]);
+ uint8_t set_g = FXARGB_G(src_palette[1]);
+ uint8_t set_b = FXARGB_B(src_palette[1]);
uint8_t gray[2];
- uint8_t reset_r;
- uint8_t reset_g;
- uint8_t reset_b;
- uint8_t set_r;
- uint8_t set_g;
- uint8_t set_b;
- if (pSrcBitmap->IsCmykImage()) {
- std::tie(reset_r, reset_g, reset_b) = AdobeCMYK_to_sRGB1(
- FXSYS_GetCValue(src_palette[0]), FXSYS_GetMValue(src_palette[0]),
- FXSYS_GetYValue(src_palette[0]), FXSYS_GetKValue(src_palette[0]));
- std::tie(set_r, set_g, set_b) = AdobeCMYK_to_sRGB1(
- FXSYS_GetCValue(src_palette[1]), FXSYS_GetMValue(src_palette[1]),
- FXSYS_GetYValue(src_palette[1]), FXSYS_GetKValue(src_palette[1]));
- } else {
- reset_r = FXARGB_R(src_palette[0]);
- reset_g = FXARGB_G(src_palette[0]);
- reset_b = FXARGB_B(src_palette[0]);
- set_r = FXARGB_R(src_palette[1]);
- set_g = FXARGB_G(src_palette[1]);
- set_b = FXARGB_B(src_palette[1]);
- }
gray[0] = FXRGB2GRAY(reset_r, reset_g, reset_b);
gray[1] = FXRGB2GRAY(set_r, set_g, set_b);
@@ -190,21 +175,9 @@
int src_top) {
pdfium::span<const uint32_t> src_palette = pSrcBitmap->GetPaletteSpan();
uint8_t gray[256];
- if (pSrcBitmap->IsCmykImage()) {
- uint8_t r;
- uint8_t g;
- uint8_t b;
- for (size_t i = 0; i < pdfium::size(gray); ++i) {
- std::tie(r, g, b) = AdobeCMYK_to_sRGB1(
- FXSYS_GetCValue(src_palette[i]), FXSYS_GetMValue(src_palette[i]),
- FXSYS_GetYValue(src_palette[i]), FXSYS_GetKValue(src_palette[i]));
- gray[i] = FXRGB2GRAY(r, g, b);
- }
- } else {
- for (size_t i = 0; i < pdfium::size(gray); ++i) {
- gray[i] = FXRGB2GRAY(FXARGB_R(src_palette[i]), FXARGB_G(src_palette[i]),
- FXARGB_B(src_palette[i]));
- }
+ for (size_t i = 0; i < pdfium::size(gray); ++i) {
+ gray[i] = FXRGB2GRAY(FXARGB_R(src_palette[i]), FXARGB_G(src_palette[i]),
+ FXARGB_B(src_palette[i]));
}
for (int row = 0; row < height; ++row) {
@@ -223,33 +196,13 @@
int src_left,
int src_top) {
int Bpp = pSrcBitmap->GetBPP() / 8;
- if (pSrcBitmap->IsCmykImage()) {
- for (int row = 0; row < height; ++row) {
- uint8_t* dest_scan = dest_buf + row * dest_pitch;
- const uint8_t* src_scan =
- pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
- for (int col = 0; col < width; ++col) {
- uint8_t r;
- uint8_t g;
- uint8_t b;
- std::tie(r, g, b) = AdobeCMYK_to_sRGB1(
- FXSYS_GetCValue(static_cast<uint32_t>(src_scan[0])),
- FXSYS_GetMValue(static_cast<uint32_t>(src_scan[1])),
- FXSYS_GetYValue(static_cast<uint32_t>(src_scan[2])),
- FXSYS_GetKValue(static_cast<uint32_t>(src_scan[3])));
- *dest_scan++ = FXRGB2GRAY(r, g, b);
- src_scan += 4;
- }
- }
- } else {
- for (int row = 0; row < height; ++row) {
- uint8_t* dest_scan = dest_buf + row * dest_pitch;
- const uint8_t* src_scan =
- pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
- for (int col = 0; col < width; ++col) {
- *dest_scan++ = FXRGB2GRAY(src_scan[2], src_scan[1], src_scan[0]);
- src_scan += Bpp;
- }
+ for (int row = 0; row < height; ++row) {
+ uint8_t* dest_scan = dest_buf + row * dest_pitch;
+ const uint8_t* src_scan =
+ pSrcBitmap->GetScanline(src_top + row) + src_left * Bpp;
+ for (int col = 0; col < width; ++col) {
+ *dest_scan++ = FXRGB2GRAY(src_scan[2], src_scan[1], src_scan[0]);
+ src_scan += Bpp;
}
}
}
@@ -297,20 +250,8 @@
src_left, src_top);
const uint32_t* src_plt = pSrcBitmap->GetPaletteData();
size_t plt_size = pSrcBitmap->GetPaletteSize();
- if (pSrcBitmap->IsCmykImage()) {
- for (size_t i = 0; i < plt_size; ++i) {
- uint8_t r;
- uint8_t g;
- uint8_t b;
- std::tie(r, g, b) = AdobeCMYK_to_sRGB1(
- FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]),
- FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]));
- dst_plt[i] = ArgbEncode(0xff, r, g, b);
- }
- } else {
- for (size_t i = 0; i < plt_size; ++i)
- dst_plt[i] = src_plt[i];
- }
+ for (size_t i = 0; i < plt_size; ++i)
+ dst_plt[i] = src_plt[i];
}
void ConvertBuffer_Rgb2PltRgb8(uint8_t* dest_buf,
@@ -427,26 +368,12 @@
pdfium::span<const uint32_t> src_palette = pSrcBitmap->GetPaletteSpan();
uint32_t plt[2];
uint8_t* bgr_ptr = reinterpret_cast<uint8_t*>(plt);
- if (pSrcBitmap->IsCmykImage()) {
- plt[0] = FXCMYK_TODIB(src_palette[0]);
- plt[1] = FXCMYK_TODIB(src_palette[1]);
- } else {
- bgr_ptr[0] = FXARGB_B(src_palette[0]);
- bgr_ptr[1] = FXARGB_G(src_palette[0]);
- bgr_ptr[2] = FXARGB_R(src_palette[0]);
- bgr_ptr[3] = FXARGB_B(src_palette[1]);
- bgr_ptr[4] = FXARGB_G(src_palette[1]);
- bgr_ptr[5] = FXARGB_R(src_palette[1]);
- }
-
- if (pSrcBitmap->IsCmykImage()) {
- std::tie(bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]) = AdobeCMYK_to_sRGB1(
- FXSYS_GetCValue(src_palette[0]), FXSYS_GetMValue(src_palette[0]),
- FXSYS_GetYValue(src_palette[0]), FXSYS_GetKValue(src_palette[0]));
- std::tie(bgr_ptr[5], bgr_ptr[4], bgr_ptr[3]) = AdobeCMYK_to_sRGB1(
- FXSYS_GetCValue(src_palette[1]), FXSYS_GetMValue(src_palette[1]),
- FXSYS_GetYValue(src_palette[1]), FXSYS_GetKValue(src_palette[1]));
- }
+ bgr_ptr[0] = FXARGB_B(src_palette[0]);
+ bgr_ptr[1] = FXARGB_G(src_palette[0]);
+ bgr_ptr[2] = FXARGB_R(src_palette[0]);
+ bgr_ptr[3] = FXARGB_B(src_palette[1]);
+ bgr_ptr[4] = FXARGB_G(src_palette[1]);
+ bgr_ptr[5] = FXARGB_R(src_palette[1]);
for (int row = 0; row < height; ++row) {
uint8_t* dest_scan = dest_buf + row * dest_pitch;
@@ -471,24 +398,12 @@
pdfium::span<const uint32_t> src_palette = pSrcBitmap->GetPaletteSpan();
uint32_t plt[256];
uint8_t* bgr_ptr = reinterpret_cast<uint8_t*>(plt);
- if (!pSrcBitmap->IsCmykImage()) {
- for (int i = 0; i < 256; ++i) {
- *bgr_ptr++ = FXARGB_B(src_palette[i]);
- *bgr_ptr++ = FXARGB_G(src_palette[i]);
- *bgr_ptr++ = FXARGB_R(src_palette[i]);
- }
- bgr_ptr = reinterpret_cast<uint8_t*>(plt);
+ for (int i = 0; i < 256; ++i) {
+ *bgr_ptr++ = FXARGB_B(src_palette[i]);
+ *bgr_ptr++ = FXARGB_G(src_palette[i]);
+ *bgr_ptr++ = FXARGB_R(src_palette[i]);
}
-
- if (pSrcBitmap->IsCmykImage()) {
- for (int i = 0; i < 256; ++i) {
- std::tie(bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]) = AdobeCMYK_to_sRGB1(
- FXSYS_GetCValue(src_palette[i]), FXSYS_GetMValue(src_palette[i]),
- FXSYS_GetYValue(src_palette[i]), FXSYS_GetKValue(src_palette[i]));
- bgr_ptr += 3;
- }
- bgr_ptr = reinterpret_cast<uint8_t*>(plt);
- }
+ bgr_ptr = reinterpret_cast<uint8_t*>(plt);
for (int row = 0; row < height; ++row) {
uint8_t* dest_scan = dest_buf + row * dest_pitch;
@@ -555,26 +470,6 @@
}
}
-void ConvertBuffer_32bppCmyk2Rgb32(uint8_t* dest_buf,
- int dest_pitch,
- int width,
- int height,
- const RetainPtr<CFX_DIBBase>& pSrcBitmap,
- int src_left,
- int src_top) {
- for (int row = 0; row < height; ++row) {
- uint8_t* dest_scan = dest_buf + row * dest_pitch;
- const uint8_t* src_scan =
- pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
- for (int col = 0; col < width; ++col) {
- std::tie(dest_scan[2], dest_scan[1], dest_scan[0]) = AdobeCMYK_to_sRGB1(
- src_scan[0], src_scan[1], src_scan[2], src_scan[3]);
- dest_scan += 4;
- src_scan += 4;
- }
- }
-}
-
bool ConvertBuffer_8bppMask(int bpp,
uint8_t* dest_buf,
int dest_pitch,
@@ -654,7 +549,6 @@
}
bool ConvertBuffer_Argb(int bpp,
- bool cmyk,
FXDIB_Format dest_format,
uint8_t* dest_buf,
int dest_pitch,
@@ -684,13 +578,8 @@
return true;
case 24:
case 32:
- if (cmyk) {
- ConvertBuffer_32bppCmyk2Rgb32(dest_buf, dest_pitch, width, height,
- pSrcBitmap, src_left, src_top);
- } else {
- ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width, height, pSrcBitmap,
- src_left, src_top);
- }
+ ConvertBuffer_Rgb2Rgb32(dest_buf, dest_pitch, width, height, pSrcBitmap,
+ src_left, src_top);
return true;
default:
return false;
@@ -758,19 +647,11 @@
return;
if (GetBPP() == 1) {
- if (IsCmykImage())
- m_palette = {0xff, 0x00};
- else
- m_palette = {0xff000000, 0xffffffff};
+ m_palette = {0xff000000, 0xffffffff};
} else if (GetBPP() == 8) {
m_palette.resize(256);
- if (IsCmykImage()) {
- for (int i = 0; i < 256; ++i)
- m_palette[i] = 0xff - i;
- } else {
- for (int i = 0; i < 256; ++i)
- m_palette[i] = 0xff000000 | (i * 0x10101);
- }
+ for (int i = 0; i < 256; ++i)
+ m_palette[i] = 0xff000000 | (i * 0x10101);
}
}
@@ -807,12 +688,6 @@
if (HasPalette())
return GetPaletteSpan()[index];
- if (IsCmykImage()) {
- if (GetBPP() == 1)
- return index ? 0 : 0xff;
-
- return 0xff - index;
- }
if (GetBPP() == 1)
return index ? 0xffffffff : 0xff000000;
@@ -837,12 +712,6 @@
return -1;
}
- if (IsCmykImage()) {
- if (GetBPP() == 1)
- return (static_cast<uint8_t>(color) == 0xff) ? 0 : 1;
- return 0xff - static_cast<uint8_t>(color);
- }
-
if (GetBPP() == 1)
return (static_cast<uint8_t>(color) == 0xff) ? 1 : 0;
return static_cast<uint8_t>(color);
@@ -958,7 +827,6 @@
void CFX_DIBBase::GetPalette(uint32_t* pal, int alpha) const {
ASSERT(GetBPP() <= 8);
- ASSERT(!IsCmykImage());
if (GetBPP() == 1) {
pal[0] = ((HasPalette() ? GetPaletteSpan()[0] : 0xff000000) & 0xffffff) |
@@ -1307,8 +1175,7 @@
}
case FXDIB_Format::kArgb:
case FXDIB_Format::kRgb32: {
- return ConvertBuffer_Argb(bpp, GetIsCmykFromFormat(src_format),
- dest_format, dest_buf, dest_pitch, width,
+ return ConvertBuffer_Argb(bpp, dest_format, dest_buf, dest_pitch, width,
height, pSrcBitmap, src_left, src_top);
}
default:
diff --git a/core/fxge/dib/cfx_dibbase.h b/core/fxge/dib/cfx_dibbase.h
index c8550cf..3e99a45 100644
--- a/core/fxge/dib/cfx_dibbase.h
+++ b/core/fxge/dib/cfx_dibbase.h
@@ -61,7 +61,6 @@
bool IsMask() const { return GetIsMaskFromFormat(m_Format); }
bool HasAlpha() const { return GetIsAlphaFromFormat(m_Format); }
- bool IsCmykImage() const { return GetIsCmykFromFormat(m_Format); }
bool IsOpaqueImage() const { return !IsMask() && !HasAlpha(); }
size_t GetPaletteSize() const;
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index af44ab3..6ce40bb 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -159,9 +159,8 @@
}
case FXDIB_Format::kRgb32:
case FXDIB_Format::kArgb: {
- color = IsCmykImage() ? FXCMYK_TODIB(color) : color;
#if defined(_SKIA_SUPPORT_)
- if (FXDIB_Format::kRgb32 == GetFormat() && !IsCmykImage())
+ if (FXDIB_Format::kRgb32 == GetFormat())
color |= 0xFF000000;
#endif
for (int i = 0; i < m_Width; i++)
@@ -512,11 +511,6 @@
default:
if (HasAlpha()) {
m_pAlphaMask->MultiplyAlpha(alpha);
- } else if (IsCmykImage()) {
- if (!ConvertFormat(AddAlphaToCmykFormat(GetFormat()))) {
- return false;
- }
- m_pAlphaMask->MultiplyAlpha(alpha);
} else {
if (!ConvertFormat(FXDIB_Format::kArgb)) {
return false;
@@ -671,20 +665,11 @@
src_x %= m_Width;
int dest_pos = i;
if (HasPalette()) {
- if (!IsCmykImage()) {
- dest_pos *= 3;
- FX_ARGB argb = palette[scanline[src_x]];
- dest_scan[dest_pos] = FXARGB_B(argb);
- dest_scan[dest_pos + 1] = FXARGB_G(argb);
- dest_scan[dest_pos + 2] = FXARGB_R(argb);
- } else {
- dest_pos *= 4;
- FX_CMYK cmyk = palette[scanline[src_x]];
- dest_scan[dest_pos] = FXSYS_GetCValue(cmyk);
- dest_scan[dest_pos + 1] = FXSYS_GetMValue(cmyk);
- dest_scan[dest_pos + 2] = FXSYS_GetYValue(cmyk);
- dest_scan[dest_pos + 3] = FXSYS_GetKValue(cmyk);
- }
+ dest_pos *= 3;
+ FX_ARGB argb = palette[scanline[src_x]];
+ dest_scan[dest_pos] = FXARGB_B(argb);
+ dest_scan[dest_pos + 1] = FXARGB_G(argb);
+ dest_scan[dest_pos + 2] = FXARGB_R(argb);
} else {
dest_scan[dest_pos] = scanline[src_x];
}
@@ -754,78 +739,11 @@
}
}
-void CFX_DIBitmap::ConvertCMYKColorScale(uint32_t forecolor,
- uint32_t backcolor) {
- int fc = FXSYS_GetCValue(forecolor);
- int fm = FXSYS_GetMValue(forecolor);
- int fy = FXSYS_GetYValue(forecolor);
- int fk = FXSYS_GetKValue(forecolor);
- int bc = FXSYS_GetCValue(backcolor);
- int bm = FXSYS_GetMValue(backcolor);
- int by = FXSYS_GetYValue(backcolor);
- int bk = FXSYS_GetKValue(backcolor);
- if (GetBppFromFormat(m_Format) <= 8) {
- if (forecolor == 0xff && backcolor == 0 && !HasPalette())
- return;
-
- BuildPalette();
- int size = 1 << GetBppFromFormat(m_Format);
- for (int i = 0; i < size; ++i) {
- uint8_t r;
- uint8_t g;
- uint8_t b;
- std::tie(r, g, b) = AdobeCMYK_to_sRGB1(
- FXSYS_GetCValue(m_palette[i]), FXSYS_GetMValue(m_palette[i]),
- FXSYS_GetYValue(m_palette[i]), FXSYS_GetKValue(m_palette[i]));
- int gray = 255 - FXRGB2GRAY(r, g, b);
- m_palette[i] =
- CmykEncode(bc + (fc - bc) * gray / 255, bm + (fm - bm) * gray / 255,
- by + (fy - by) * gray / 255, bk + (fk - bk) * gray / 255);
- }
- return;
- }
- if (forecolor == 0xff && backcolor == 0x00) {
- for (int row = 0; row < m_Height; ++row) {
- uint8_t* scanline = m_pBuffer.Get() + row * m_Pitch;
- for (int col = 0; col < m_Width; ++col) {
- uint8_t r;
- uint8_t g;
- uint8_t b;
- std::tie(r, g, b) = AdobeCMYK_to_sRGB1(scanline[0], scanline[1],
- scanline[2], scanline[3]);
- *scanline++ = 0;
- *scanline++ = 0;
- *scanline++ = 0;
- *scanline++ = 255 - FXRGB2GRAY(r, g, b);
- }
- }
- return;
- }
- for (int row = 0; row < m_Height; ++row) {
- uint8_t* scanline = m_pBuffer.Get() + row * m_Pitch;
- for (int col = 0; col < m_Width; ++col) {
- uint8_t r;
- uint8_t g;
- uint8_t b;
- std::tie(r, g, b) = AdobeCMYK_to_sRGB1(scanline[0], scanline[1],
- scanline[2], scanline[3]);
- int gray = 255 - FXRGB2GRAY(r, g, b);
- *scanline++ = bc + (fc - bc) * gray / 255;
- *scanline++ = bm + (fm - bm) * gray / 255;
- *scanline++ = by + (fy - by) * gray / 255;
- *scanline++ = bk + (fk - bk) * gray / 255;
- }
- }
-}
-
bool CFX_DIBitmap::ConvertColorScale(uint32_t forecolor, uint32_t backcolor) {
if (!m_pBuffer || IsMask())
return false;
- if (IsCmykImage())
- ConvertCMYKColorScale(forecolor, backcolor);
- else
- ConvertBGRColorScale(forecolor, backcolor);
+ ConvertBGRColorScale(forecolor, backcolor);
return true;
}
@@ -907,7 +825,7 @@
}
const int dest_Bpp = GetBppFromFormat(m_Format) / 8;
const int src_Bpp = pSrcBitmap->GetBPP() / 8;
- const bool bRgb = src_Bpp > 1 && !pSrcBitmap->IsCmykImage();
+ const bool bRgb = src_Bpp > 1;
if (!bRgb && !pSrcBitmap->HasPalette())
return false;
@@ -1052,9 +970,6 @@
} else {
gray = (uint8_t)FXRGB2GRAY((int)color_p[2], color_p[1], color_p[0]);
}
- if (IsCmykImage()) {
- gray = ~gray;
- }
}
for (int row = rect.top; row < rect.bottom; row++) {
uint8_t* dest_scan = m_pBuffer.Get() + row * m_Pitch + rect.left;
@@ -1070,7 +985,6 @@
return true;
}
if (GetBppFromFormat(m_Format) == 1) {
- ASSERT(!IsCmykImage());
ASSERT(static_cast<uint8_t>(alpha_flag >> 8) == 0);
int left_shift = rect.left % 8;
@@ -1115,16 +1029,12 @@
return false;
}
- if (!(alpha_flag >> 8) && IsCmykImage())
- return false;
-
- if (alpha_flag >> 8 && !IsCmykImage()) {
+ if (alpha_flag >> 8) {
std::tie(color_p[2], color_p[1], color_p[0]) =
AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color),
FXSYS_GetYValue(color), FXSYS_GetKValue(color));
}
- if (!IsCmykImage())
- color_p[3] = static_cast<uint8_t>(src_alpha);
+ color_p[3] = static_cast<uint8_t>(src_alpha);
int Bpp = GetBppFromFormat(m_Format) / 8;
bool bAlpha = HasAlpha();
bool bArgb = GetFormat() == FXDIB_Format::kArgb;
diff --git a/core/fxge/dib/cfx_dibitmap.h b/core/fxge/dib/cfx_dibitmap.h
index 474130f..bf29f8f 100644
--- a/core/fxge/dib/cfx_dibitmap.h
+++ b/core/fxge/dib/cfx_dibitmap.h
@@ -138,7 +138,6 @@
private:
void ConvertBGRColorScale(uint32_t forecolor, uint32_t backcolor);
- void ConvertCMYKColorScale(uint32_t forecolor, uint32_t backcolor);
bool TransferWithUnequalFormats(FXDIB_Format dest_format,
int dest_left,
int dest_top,
diff --git a/core/fxge/dib/cfx_imagetransformer.cpp b/core/fxge/dib/cfx_imagetransformer.cpp
index a129e73..ebf898f 100644
--- a/core/fxge/dib/cfx_imagetransformer.cpp
+++ b/core/fxge/dib/cfx_imagetransformer.cpp
@@ -512,9 +512,6 @@
m_Storer.GetBitmap()->GetPaletteSpan();
for (size_t i = 0; i < pdfium::size(argb); i++)
argb[i] = palette[i];
- } else if (m_Storer.GetBitmap()->IsCmykImage()) {
- for (size_t i = 0; i < pdfium::size(argb); i++)
- argb[i] = 255 - i;
} else {
for (size_t i = 0; i < pdfium::size(argb); i++)
argb[i] = 0xff000000 | (i * 0x010101);
diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp
index ab62044..8c49e29 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor.cpp
@@ -12,7 +12,6 @@
#include "core/fxge/dib/fx_dib.h"
#include "third_party/base/check.h"
-#define FX_CCOLOR(val) (255 - (val))
#define FXDIB_ALPHA_UNION(dest, src) ((dest) + (src) - (dest) * (src) / 255)
#define FXARGB_RGBORDERCOPY(dest, src) \
*((dest) + 3) = *((src) + 3), *(dest) = *((src) + 2), \
@@ -2761,8 +2760,6 @@
InitSourceMask(mask_color);
return true;
}
- if (!GetIsCmykFromFormat(src_format) && GetIsCmykFromFormat(dest_format))
- return false;
if (GetBppFromFormat(m_SrcFormat) <= 8) {
if (dest_format == FXDIB_Format::k8bppMask)
return true;
@@ -2770,16 +2767,13 @@
InitSourcePalette(src_format, dest_format, src_palette);
m_iTransparency = (dest_format == FXDIB_Format::kArgb ? 1 : 0) +
(GetIsAlphaFromFormat(dest_format) ? 2 : 0) +
- (GetIsCmykFromFormat(dest_format) ? 4 : 0) +
(GetBppFromFormat(src_format) == 1 ? 8 : 0);
return true;
}
m_iTransparency = (GetIsAlphaFromFormat(src_format) ? 0 : 1) +
(GetIsAlphaFromFormat(dest_format) ? 0 : 2) +
(blend_type == BlendMode::kNormal ? 4 : 0) +
- (bClip ? 8 : 0) +
- (GetIsCmykFromFormat(src_format) ? 16 : 0) +
- (GetIsCmykFromFormat(dest_format) ? 32 : 0);
+ (bClip ? 8 : 0);
return true;
}
@@ -2791,11 +2785,8 @@
if (m_DestFormat == FXDIB_Format::k8bppMask)
return;
- if (GetBppFromFormat(m_DestFormat) == 8) {
+ if (GetBppFromFormat(m_DestFormat) == 8)
m_MaskRed = FXRGB2GRAY(m_MaskRed, m_MaskGreen, m_MaskBlue);
- if (GetIsCmykFromFormat(m_DestFormat))
- m_MaskRed = FX_CCOLOR(m_MaskRed);
- }
}
void CFX_ScanlineCompositor::InitSourcePalette(
@@ -2803,8 +2794,6 @@
FXDIB_Format dest_format,
pdfium::span<const uint32_t> src_palette) {
m_SrcPalette.Reset();
- const bool bIsSrcCmyk = GetIsCmykFromFormat(src_format);
- const bool bIsDstCmyk = GetIsCmykFromFormat(dest_format);
const bool bIsDestBpp8 = GetBppFromFormat(dest_format) == 8;
const size_t pal_count = static_cast<size_t>(1)
<< GetBppFromFormat(src_format);
@@ -2812,42 +2801,16 @@
if (!src_palette.empty()) {
if (bIsDestBpp8) {
pdfium::span<uint8_t> gray_pal = m_SrcPalette.Make8BitPalette(pal_count);
- if (bIsSrcCmyk) {
- for (size_t i = 0; i < pal_count; ++i) {
- FX_CMYK cmyk = src_palette[i];
- uint8_t r;
- uint8_t g;
- uint8_t b;
- std::tie(r, g, b) =
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk),
- FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk));
- gray_pal[i] = FXRGB2GRAY(r, g, b);
- }
- } else {
- for (size_t i = 0; i < pal_count; ++i) {
- FX_ARGB argb = src_palette[i];
- gray_pal[i] =
- FXRGB2GRAY(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb));
- }
+ for (size_t i = 0; i < pal_count; ++i) {
+ FX_ARGB argb = src_palette[i];
+ gray_pal[i] =
+ FXRGB2GRAY(FXARGB_R(argb), FXARGB_G(argb), FXARGB_B(argb));
}
return;
}
pdfium::span<uint32_t> pPalette = m_SrcPalette.Make32BitPalette(pal_count);
- if (bIsDstCmyk == bIsSrcCmyk) {
- for (size_t i = 0; i < pal_count; ++i)
- pPalette[i] = src_palette[i];
- } else {
- for (size_t i = 0; i < pal_count; ++i) {
- FX_CMYK cmyk = src_palette[i];
- uint8_t r;
- uint8_t g;
- uint8_t b;
- std::tie(r, g, b) =
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk),
- FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk));
- pPalette[i] = ArgbEncode(0xff, r, g, b);
- }
- }
+ for (size_t i = 0; i < pal_count; ++i)
+ pPalette[i] = src_palette[i];
return;
}
if (bIsDestBpp8) {
@@ -2863,23 +2826,11 @@
}
pdfium::span<uint32_t> pPalette = m_SrcPalette.Make32BitPalette(pal_count);
if (pal_count == 2) {
- pPalette[0] = bIsSrcCmyk ? 0xff : 0xff000000;
- pPalette[1] = bIsSrcCmyk ? 0x00 : 0xffffffff;
+ pPalette[0] = 0xff000000;
+ pPalette[1] = 0xffffffff;
} else {
for (size_t i = 0; i < pal_count; ++i)
- pPalette[i] = bIsSrcCmyk ? FX_CCOLOR(i) : (i * 0x10101);
- }
- if (bIsSrcCmyk != bIsDstCmyk) {
- for (size_t i = 0; i < pal_count; ++i) {
- FX_CMYK cmyk = pPalette[i];
- uint8_t r;
- uint8_t g;
- uint8_t b;
- std::tie(r, g, b) =
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk),
- FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk));
- pPalette[i] = ArgbEncode(0xff, r, g, b);
- }
+ pPalette[i] = i * 0x10101;
}
}
@@ -2959,12 +2910,6 @@
CompositeRow_Rgb2Mask(dest_scan, src_scan, width, clip_scan);
}
} else if (GetBppFromFormat(m_DestFormat) == 8) {
- if (GetIsCmykFromFormat(m_DestFormat)) {
- for (int i = 0; i < width; ++i) {
- *dest_scan = ~*dest_scan;
- dest_scan++;
- }
- }
if (GetIsAlphaFromFormat(m_SrcFormat)) {
if (GetIsAlphaFromFormat(m_DestFormat)) {
CompositeRow_Argb2Graya(dest_scan, src_scan, width, m_BlendType,
@@ -2982,12 +2927,6 @@
clip_scan);
}
}
- if (GetIsCmykFromFormat(m_DestFormat)) {
- for (int i = 0; i < width; ++i) {
- *dest_scan = ~*dest_scan;
- dest_scan++;
- }
- }
} else {
switch (m_iTransparency) {
case 0:
diff --git a/core/fxge/dib/fx_dib.cpp b/core/fxge/dib/fx_dib.cpp
index 9d827b1..2bff739 100644
--- a/core/fxge/dib/fx_dib.cpp
+++ b/core/fxge/dib/fx_dib.cpp
@@ -70,10 +70,6 @@
}
}
-FXDIB_Format AddAlphaToCmykFormat(FXDIB_Format format) {
- return FXDIB_Format::kInvalid;
-}
-
FXDIB_ResampleOptions::FXDIB_ResampleOptions() = default;
bool FXDIB_ResampleOptions::HasAnyOptions() const {
diff --git a/core/fxge/dib/fx_dib.h b/core/fxge/dib/fx_dib.h
index d6e9309..437fa70 100644
--- a/core/fxge/dib/fx_dib.h
+++ b/core/fxge/dib/fx_dib.h
@@ -24,8 +24,6 @@
k8bppRgba = 0x208,
kRgba = 0x218,
kArgb = 0x220,
- kCmyk = 0x420,
- kCmyka = 0x620,
};
struct PixelWeight {
@@ -119,16 +117,11 @@
return !!(static_cast<uint16_t>(format) & 0x200);
}
-inline bool GetIsCmykFromFormat(FXDIB_Format format) {
- return false;
-}
-
inline bool HasNoFlags(FXDIB_Format format) {
- return (static_cast<uint16_t>(format) & 0x700) == 0;
+ return (static_cast<uint16_t>(format) & 0x300) == 0;
}
FXDIB_Format MakeRGBFormat(int bpp);
-FXDIB_Format AddAlphaToCmykFormat(FXDIB_Format format);
inline FX_CMYK CmykEncode(int c, int m, int y, int k) {
return (c << 24) | (m << 16) | (y << 8) | k;
diff --git a/core/fxge/skia/fx_skia_device.cpp b/core/fxge/skia/fx_skia_device.cpp
index 6ba27d6..7015aaa 100644
--- a/core/fxge/skia/fx_skia_device.cpp
+++ b/core/fxge/skia/fx_skia_device.cpp
@@ -1636,8 +1636,6 @@
#endif
m_bRgbByteOrder(bRgbByteOrder),
m_bGroupKnockout(bGroupKnockout) {
- DCHECK(!m_pBitmap->IsCmykImage());
-
SkBitmap skBitmap;
SkColorType color_type;
const int bpp = pBitmap->GetBPP();
diff --git a/core/fxge/win32/cgdi_device_driver.cpp b/core/fxge/win32/cgdi_device_driver.cpp
index 5811b5a..1a49aca 100644
--- a/core/fxge/win32/cgdi_device_driver.cpp
+++ b/core/fxge/win32/cgdi_device_driver.cpp
@@ -326,9 +326,6 @@
if (!pBitmap)
return false;
- if (pBitmap->IsCmykImage() && !pBitmap->ConvertFormat(FXDIB_Format::kRgb))
- return false;
-
LPBYTE pBuffer = pBitmap->GetBuffer();
ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
((BITMAPINFOHEADER*)info.c_str())->biHeight *= -1;
@@ -343,11 +340,6 @@
}
RetainPtr<CFX_DIBitmap> pBitmap = pBitmap1;
- if (pBitmap->IsCmykImage()) {
- pBitmap = pBitmap->CloneConvert(FXDIB_Format::kRgb);
- if (!pBitmap)
- return false;
- }
LPBYTE pBuffer = pBitmap->GetBuffer();
ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
::SetDIBitsToDevice(m_hDC, left, top, src_rect.Width(), src_rect.Height(),
@@ -368,9 +360,6 @@
if (!pBitmap || dest_width == 0 || dest_height == 0)
return false;
- if (pBitmap->IsCmykImage() && !pBitmap->ConvertFormat(FXDIB_Format::kRgb))
- return false;
-
ByteString info = CFX_WindowsDIB::GetBitmapInfo(pBitmap);
if ((int64_t)abs(dest_width) * abs(dest_height) <
(int64_t)pBitmap1->GetWidth() * pBitmap1->GetHeight() * 4 ||
diff --git a/core/fxge/win32/cgdi_display_driver.cpp b/core/fxge/win32/cgdi_display_driver.cpp
index f438be1..7e9ec91 100644
--- a/core/fxge/win32/cgdi_display_driver.cpp
+++ b/core/fxge/win32/cgdi_display_driver.cpp
@@ -48,7 +48,7 @@
bmi.bmiHeader.biHeight = -height;
bmi.bmiHeader.biPlanes = 1;
bmi.bmiHeader.biWidth = width;
- if (pBitmap->GetBPP() > 8 && !pBitmap->IsCmykImage()) {
+ if (pBitmap->GetBPP() > 8) {
ret = ::GetDIBits(hDCMemory, hbmp, 0, height, pBitmap->GetBuffer(), &bmi,
DIB_RGB_COLORS) == height;
} else {
@@ -195,7 +195,7 @@
if (pSource->HasAlpha()) {
auto* pPlatform =
static_cast<CWin32Platform*>(CFX_GEModule::Get()->GetPlatform());
- if (pPlatform->m_GdiplusExt.IsAvailable() && !pSource->IsCmykImage()) {
+ if (pPlatform->m_GdiplusExt.IsAvailable()) {
CFX_DIBExtractor temp(pSource);
RetainPtr<CFX_DIBitmap> pBitmap = temp.GetBitmap();
if (!pBitmap)