summaryrefslogtreecommitdiff
path: root/core/fxge
diff options
context:
space:
mode:
authorNicolas Pena <npm@chromium.org>2017-07-12 14:45:08 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-07-12 18:58:24 +0000
commitd79ac21b7595442bce82ec93f59cda9f8fb3cb24 (patch)
tree2c479141e360094a21cad7a1566a0c1a04e8a9c9 /core/fxge
parent58bf3de718e510648ee136c887be5b2d577644a7 (diff)
downloadpdfium-d79ac21b7595442bce82ec93f59cda9f8fb3cb24.tar.xz
Move CMYKtoRGB methods to fx_codec and clean them up
This CL moves CMYKtoRGB methods to fx_codec. It also cleans them up a bit, including allowing them to return tuples instead of having non-const refs in their parameters. Change-Id: Ib3ec45102ec7eff623cd07a624e852d39bf335e4 Reviewed-on: https://pdfium-review.googlesource.com/7591 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxge')
-rw-r--r--core/fxge/dib/cfx_dibitmap.cpp27
-rw-r--r--core/fxge/dib/cfx_dibsource.cpp55
-rw-r--r--core/fxge/dib/cfx_scanlinecompositor.cpp39
3 files changed, 65 insertions, 56 deletions
diff --git a/core/fxge/dib/cfx_dibitmap.cpp b/core/fxge/dib/cfx_dibitmap.cpp
index 02c3543c85..fd6defece2 100644
--- a/core/fxge/dib/cfx_dibitmap.cpp
+++ b/core/fxge/dib/cfx_dibitmap.cpp
@@ -755,10 +755,11 @@ void CFX_DIBitmap::ConvertCMYKColorScale(uint32_t forecolor,
uint8_t r;
uint8_t g;
uint8_t b;
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(m_pPalette.get()[i]),
- FXSYS_GetMValue(m_pPalette.get()[i]),
- FXSYS_GetYValue(m_pPalette.get()[i]),
- FXSYS_GetKValue(m_pPalette.get()[i]), r, g, b);
+ std::tie(r, g, b) =
+ AdobeCMYK_to_sRGB1(FXSYS_GetCValue(m_pPalette.get()[i]),
+ FXSYS_GetMValue(m_pPalette.get()[i]),
+ FXSYS_GetYValue(m_pPalette.get()[i]),
+ FXSYS_GetKValue(m_pPalette.get()[i]));
int gray = 255 - FXRGB2GRAY(r, g, b);
m_pPalette.get()[i] =
CmykEncode(bc + (fc - bc) * gray / 255, bm + (fm - bm) * gray / 255,
@@ -773,8 +774,8 @@ void CFX_DIBitmap::ConvertCMYKColorScale(uint32_t forecolor,
uint8_t r;
uint8_t g;
uint8_t b;
- AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], scanline[3],
- r, g, b);
+ std::tie(r, g, b) = AdobeCMYK_to_sRGB1(scanline[0], scanline[1],
+ scanline[2], scanline[3]);
*scanline++ = 0;
*scanline++ = 0;
*scanline++ = 0;
@@ -789,8 +790,8 @@ void CFX_DIBitmap::ConvertCMYKColorScale(uint32_t forecolor,
uint8_t r;
uint8_t g;
uint8_t b;
- AdobeCMYK_to_sRGB1(scanline[0], scanline[1], scanline[2], scanline[3], r,
- g, 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;
@@ -1007,8 +1008,8 @@ bool CFX_DIBitmap::CompositeRect(int left,
uint8_t r;
uint8_t g;
uint8_t b;
- AdobeCMYK_to_sRGB1(color_p[0], color_p[1], color_p[2], color_p[3], r, g,
- b);
+ std::tie(r, g, b) =
+ AdobeCMYK_to_sRGB1(color_p[0], color_p[1], color_p[2], color_p[3]);
gray = FXRGB2GRAY(r, g, b);
} else {
gray = (uint8_t)FXRGB2GRAY((int)color_p[2], color_p[1], color_p[0]);
@@ -1074,9 +1075,9 @@ bool CFX_DIBitmap::CompositeRect(int left,
if (m_bpp < 24 || (!(alpha_flag >> 8) && IsCmykImage()))
return false;
if (alpha_flag >> 8 && !IsCmykImage()) {
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color),
- FXSYS_GetYValue(color), FXSYS_GetKValue(color),
- color_p[2], color_p[1], color_p[0]);
+ 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);
diff --git a/core/fxge/dib/cfx_dibsource.cpp b/core/fxge/dib/cfx_dibsource.cpp
index e19619df1d..a0ed95055b 100644
--- a/core/fxge/dib/cfx_dibsource.cpp
+++ b/core/fxge/dib/cfx_dibsource.cpp
@@ -153,12 +153,12 @@ bool ConvertBuffer_1bppPlt2Gray(uint8_t* dest_buf,
uint8_t set_g;
uint8_t set_b;
if (pSrcBitmap->IsCmykImage()) {
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_plt[0]),
- FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]),
- reset_r, reset_g, reset_b);
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_plt[1]),
- FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]),
- set_r, set_g, set_b);
+ std::tie(reset_r, reset_g, reset_b) = AdobeCMYK_to_sRGB1(
+ FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_plt[0]),
+ FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]));
+ std::tie(set_r, set_g, set_b) = AdobeCMYK_to_sRGB1(
+ FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_plt[1]),
+ FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]));
} else {
reset_r = FXARGB_R(src_plt[0]);
reset_g = FXARGB_G(src_plt[0]);
@@ -198,9 +198,9 @@ bool ConvertBuffer_8bppPlt2Gray(uint8_t* dest_buf,
uint8_t g;
uint8_t b;
for (size_t i = 0; i < FX_ArraySize(gray); i++) {
- AdobeCMYK_to_sRGB1(
+ 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]), r, g, b);
+ FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]));
gray[i] = FXRGB2GRAY(r, g, b);
}
} else {
@@ -235,12 +235,14 @@ bool ConvertBuffer_RgbOrCmyk2Gray(
const uint8_t* src_scan =
pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
for (int col = 0; col < width; col++) {
- uint8_t 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])),
- r, g, b);
+ 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;
}
@@ -305,9 +307,9 @@ bool ConvertBuffer_Plt2PltRgb8(uint8_t* dest_buf,
uint8_t r;
uint8_t g;
uint8_t b;
- AdobeCMYK_to_sRGB1(
+ 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]), r, g, b);
+ FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]));
dst_plt[i] = FXARGB_MAKE(0xff, r, g, b);
}
} else {
@@ -458,12 +460,12 @@ bool ConvertBuffer_1bppPlt2Rgb(FXDIB_Format dst_format,
}
if (pSrcBitmap->IsCmykImage()) {
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_plt[0]),
- FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]),
- bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]);
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_plt[1]),
- FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]),
- bgr_ptr[5], bgr_ptr[4], bgr_ptr[3]);
+ std::tie(bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]) = AdobeCMYK_to_sRGB1(
+ FXSYS_GetCValue(src_plt[0]), FXSYS_GetMValue(src_plt[0]),
+ FXSYS_GetYValue(src_plt[0]), FXSYS_GetKValue(src_plt[0]));
+ std::tie(bgr_ptr[5], bgr_ptr[4], bgr_ptr[3]) = AdobeCMYK_to_sRGB1(
+ FXSYS_GetCValue(src_plt[1]), FXSYS_GetMValue(src_plt[1]),
+ FXSYS_GetYValue(src_plt[1]), FXSYS_GetKValue(src_plt[1]));
}
for (int row = 0; row < height; row++) {
@@ -508,10 +510,9 @@ bool ConvertBuffer_8bppPlt2Rgb(FXDIB_Format dst_format,
if (pSrcBitmap->IsCmykImage()) {
for (int i = 0; i < 256; i++) {
- AdobeCMYK_to_sRGB1(
+ std::tie(bgr_ptr[2], bgr_ptr[1], bgr_ptr[0]) = AdobeCMYK_to_sRGB1(
FXSYS_GetCValue(src_plt[i]), FXSYS_GetMValue(src_plt[i]),
- FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]), bgr_ptr[2],
- bgr_ptr[1], bgr_ptr[0]);
+ FXSYS_GetYValue(src_plt[i]), FXSYS_GetKValue(src_plt[i]));
bgr_ptr += 3;
}
bgr_ptr = reinterpret_cast<uint8_t*>(plt);
@@ -606,8 +607,8 @@ bool ConvertBuffer_32bppCmyk2Rgb32(
const uint8_t* src_scan =
pSrcBitmap->GetScanline(src_top + row) + src_left * 4;
for (int col = 0; col < width; col++) {
- AdobeCMYK_to_sRGB1(src_scan[0], src_scan[1], src_scan[2], src_scan[3],
- dest_scan[2], dest_scan[1], dest_scan[0]);
+ 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;
}
diff --git a/core/fxge/dib/cfx_scanlinecompositor.cpp b/core/fxge/dib/cfx_scanlinecompositor.cpp
index 5bd654b3e6..b9c51f6122 100644
--- a/core/fxge/dib/cfx_scanlinecompositor.cpp
+++ b/core/fxge/dib/cfx_scanlinecompositor.cpp
@@ -2881,8 +2881,8 @@ void CFX_ScanlineCompositor::InitSourceMask(int alpha_flag,
uint8_t r;
uint8_t g;
uint8_t b;
- AdobeCMYK_to_sRGB1(m_MaskRed, m_MaskGreen, m_MaskBlue, mask_black, r, g,
- b);
+ std::tie(r, g, b) =
+ AdobeCMYK_to_sRGB1(m_MaskRed, m_MaskGreen, m_MaskBlue, mask_black);
m_MaskRed = FXRGB2GRAY(r, g, b);
} else {
m_MaskRed = FXRGB2GRAY(m_MaskRed, m_MaskGreen, m_MaskBlue);
@@ -2895,9 +2895,9 @@ void CFX_ScanlineCompositor::InitSourceMask(int alpha_flag,
mask_color =
(alpha_flag >> 8) ? FXCMYK_TODIB(mask_color) : FXARGB_TODIB(mask_color);
if (alpha_flag >> 8) {
- AdobeCMYK_to_sRGB1(mask_color_p[0], mask_color_p[1], mask_color_p[2],
- mask_color_p[3], mask_color_p[2], mask_color_p[1],
- mask_color_p[0]);
+ std::tie(mask_color_p[2], mask_color_p[1], mask_color_p[0]) =
+ AdobeCMYK_to_sRGB1(mask_color_p[0], mask_color_p[1], mask_color_p[2],
+ mask_color_p[3]);
m_MaskRed = mask_color_p[2];
m_MaskGreen = mask_color_p[1];
m_MaskBlue = mask_color_p[0];
@@ -2918,10 +2918,12 @@ void CFX_ScanlineCompositor::InitSourcePalette(FXDIB_Format src_format,
if (isSrcCmyk) {
for (int i = 0; i < pal_count; ++i) {
FX_CMYK cmyk = pSrcPalette[i];
- uint8_t r, g, b;
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk),
- FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g,
- b);
+ 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++ = FXRGB2GRAY(r, g, b);
}
} else {
@@ -2941,10 +2943,12 @@ void CFX_ScanlineCompositor::InitSourcePalette(FXDIB_Format src_format,
} else {
for (int i = 0; i < palsize; ++i) {
FX_CMYK cmyk = pSrcPalette[i];
- uint8_t r, g, b;
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk),
- FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g,
- b);
+ 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] = FXARGB_MAKE(0xff, r, g, b);
}
}
@@ -2976,9 +2980,12 @@ void CFX_ScanlineCompositor::InitSourcePalette(FXDIB_Format src_format,
if (isSrcCmyk != isDstCmyk) {
for (int i = 0; i < palsize; ++i) {
FX_CMYK cmyk = pPalette[i];
- uint8_t r, g, b;
- AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk),
- FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, b);
+ 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] = FXARGB_MAKE(0xff, r, g, b);
}
}