summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render
diff options
context:
space:
mode:
authorLei Zhang <thestig@chromium.org>2017-03-15 13:26:37 -0700
committerChromium commit bot <commit-bot@chromium.org>2017-03-15 21:10:29 +0000
commita12159b17085796e2b72d2b49e850092e0b4e8b7 (patch)
treedf7a5d149c9bbfe5c2d2ec16631c3dcb6ae9a901 /core/fpdfapi/render
parent59d9416553b293f6df923c2f3ef33def2d51d7b7 (diff)
downloadpdfium-a12159b17085796e2b72d2b49e850092e0b4e8b7.tar.xz
Refactor some CPDF_ColorSpace code.
Change-Id: I1e30d68dae3bf70cf3c426f6126d593b7f1c3ba4 Reviewed-on: https://pdfium-review.googlesource.com/2991 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
Diffstat (limited to 'core/fpdfapi/render')
-rw-r--r--core/fpdfapi/render/cpdf_dibsource.cpp28
-rw-r--r--core/fpdfapi/render/cpdf_docrenderdata.cpp4
-rw-r--r--core/fpdfapi/render/cpdf_renderstatus.cpp30
3 files changed, 34 insertions, 28 deletions
diff --git a/core/fpdfapi/render/cpdf_dibsource.cpp b/core/fpdfapi/render/cpdf_dibsource.cpp
index 403866300d..341327b5e9 100644
--- a/core/fpdfapi/render/cpdf_dibsource.cpp
+++ b/core/fpdfapi/render/cpdf_dibsource.cpp
@@ -457,7 +457,7 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(bool& bDefaultDecode,
float def_value;
float def_min;
float def_max;
- m_pColorSpace->GetDefaultValue(i, def_value, def_min, def_max);
+ m_pColorSpace->GetDefaultValue(i, &def_value, &def_min, &def_max);
if (m_Family == PDFCS_INDEXED) {
def_max = max_data;
}
@@ -468,8 +468,8 @@ DIB_COMP_DATA* CPDF_DIBSource::GetDecodeAndMaskArray(bool& bDefaultDecode,
} else {
for (uint32_t i = 0; i < m_nComponents; i++) {
float def_value;
- m_pColorSpace->GetDefaultValue(i, def_value, pCompData[i].m_DecodeMin,
- pCompData[i].m_DecodeStep);
+ m_pColorSpace->GetDefaultValue(i, &def_value, &pCompData[i].m_DecodeMin,
+ &pCompData[i].m_DecodeStep);
if (m_Family == PDFCS_INDEXED) {
pCompData[i].m_DecodeStep = max_data;
}
@@ -701,10 +701,10 @@ int CPDF_DIBSource::StratLoadMask() {
m_pColorSpace->CountComponents() <= m_nComponents) {
float R, G, B;
std::vector<float> colors(m_nComponents);
- for (uint32_t i = 0; i < m_nComponents; i++) {
+ for (uint32_t i = 0; i < m_nComponents; i++)
colors[i] = pMatte->GetFloatAt(i);
- }
- m_pColorSpace->GetRGB(colors.data(), R, G, B);
+
+ m_pColorSpace->GetRGB(colors.data(), &R, &G, &B);
m_MatteColor = FXARGB_MAKE(0, FXSYS_round(R * 255), FXSYS_round(G * 255),
FXSYS_round(B * 255));
}
@@ -779,13 +779,13 @@ void CPDF_DIBSource::LoadPalette() {
color_values[0] = m_pCompData[0].m_DecodeMin;
color_values[1] = color_values[2] = color_values[0];
float R = 0.0f, G = 0.0f, B = 0.0f;
- m_pColorSpace->GetRGB(color_values, R, G, B);
+ m_pColorSpace->GetRGB(color_values, &R, &G, &B);
FX_ARGB argb0 = ArgbEncode(255, FXSYS_round(R * 255), FXSYS_round(G * 255),
FXSYS_round(B * 255));
color_values[0] += m_pCompData[0].m_DecodeStep;
color_values[1] += m_pCompData[0].m_DecodeStep;
color_values[2] += m_pCompData[0].m_DecodeStep;
- m_pColorSpace->GetRGB(color_values, R, G, B);
+ m_pColorSpace->GetRGB(color_values, &R, &G, &B);
FX_ARGB argb1 = ArgbEncode(255, FXSYS_round(R * 255), FXSYS_round(G * 255),
FXSYS_round(B * 255));
if (argb0 != 0xFF000000 || argb1 != 0xFFFFFFFF) {
@@ -816,9 +816,9 @@ void CPDF_DIBSource::LoadPalette() {
for (int k = 0; k < nComponents; k++) {
temp_buf[k] = *color_value;
}
- m_pColorSpace->GetRGB(temp_buf.data(), R, G, B);
+ m_pColorSpace->GetRGB(temp_buf.data(), &R, &G, &B);
} else {
- m_pColorSpace->GetRGB(color_value, R, G, B);
+ m_pColorSpace->GetRGB(color_value, &R, &G, &B);
}
SetPaletteArgb(i, ArgbEncode(255, FXSYS_round(R * 255),
FXSYS_round(G * 255), FXSYS_round(B * 255)));
@@ -935,7 +935,7 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan,
G = (1.0f - color_values[1]) * k;
B = (1.0f - color_values[2]) * k;
} else {
- m_pColorSpace->GetRGB(color_values, R, G, B);
+ m_pColorSpace->GetRGB(color_values, &R, &G, &B);
}
R = ClampValue(R, 1.0f);
G = ClampValue(G, 1.0f);
@@ -961,7 +961,7 @@ void CPDF_DIBSource::TranslateScanline24bpp(uint8_t* dest_scan,
G = (1.0f - color_values[1]) * k;
B = (1.0f - color_values[2]) * k;
} else {
- m_pColorSpace->GetRGB(color_values, R, G, B);
+ m_pColorSpace->GetRGB(color_values, &R, &G, &B);
}
R = ClampValue(R, 1.0f);
G = ClampValue(G, 1.0f);
@@ -1183,12 +1183,12 @@ void CPDF_DIBSource::DownSampleScanline1Bit(int orig_Bpp,
bool bFlipX,
int clip_left,
int clip_width) const {
- uint32_t set_argb = (uint32_t)-1;
+ uint32_t set_argb = 0xFFFFFFFF;
uint32_t reset_argb = 0;
if (m_bImageMask) {
if (m_bDefaultDecode) {
set_argb = 0;
- reset_argb = (uint32_t)-1;
+ reset_argb = 0xFFFFFFFF;
}
} else if (m_bColorKey) {
reset_argb = m_pPalette ? m_pPalette.get()[0] : 0xFF000000;
diff --git a/core/fpdfapi/render/cpdf_docrenderdata.cpp b/core/fpdfapi/render/cpdf_docrenderdata.cpp
index a6488c64d8..1c430e8f0f 100644
--- a/core/fpdfapi/render/cpdf_docrenderdata.cpp
+++ b/core/fpdfapi/render/cpdf_docrenderdata.cpp
@@ -117,7 +117,7 @@ CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) {
input = (float)v / 255.0f;
if (bUniTransfer) {
if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs)
- pFuncs[0]->Call(&input, 1, output, noutput);
+ pFuncs[0]->Call(&input, 1, output, &noutput);
int o = FXSYS_round(output[0] * 255);
if (o != v)
bIdentity = false;
@@ -130,7 +130,7 @@ CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) {
pTransfer->m_Samples[i * 256 + v] = v;
continue;
}
- pFuncs[i]->Call(&input, 1, output, noutput);
+ pFuncs[i]->Call(&input, 1, output, &noutput);
int o = FXSYS_round(output[0] * 255);
if (o != v)
bIdentity = false;
diff --git a/core/fpdfapi/render/cpdf_renderstatus.cpp b/core/fpdfapi/render/cpdf_renderstatus.cpp
index 28c7166013..17576fc1f3 100644
--- a/core/fpdfapi/render/cpdf_renderstatus.cpp
+++ b/core/fpdfapi/render/cpdf_renderstatus.cpp
@@ -145,12 +145,14 @@ void DrawAxialShading(CFX_DIBitmap* pBitmap,
for (const auto& func : funcs) {
if (func) {
int nresults = 0;
- if (func->Call(&input, 1, pResults + offset, nresults))
+ if (func->Call(&input, 1, pResults + offset, &nresults))
offset += nresults;
}
}
- float R = 0.0f, G = 0.0f, B = 0.0f;
- pCS->GetRGB(pResults, R, G, B);
+ float R = 0.0f;
+ float G = 0.0f;
+ float B = 0.0f;
+ pCS->GetRGB(pResults, &R, &G, &B);
rgb_array[i] =
FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255),
FXSYS_round(G * 255), FXSYS_round(B * 255)));
@@ -226,12 +228,14 @@ void DrawRadialShading(CFX_DIBitmap* pBitmap,
for (const auto& func : funcs) {
if (func) {
int nresults;
- if (func->Call(&input, 1, pResults + offset, nresults))
+ if (func->Call(&input, 1, pResults + offset, &nresults))
offset += nresults;
}
}
- float R = 0.0f, G = 0.0f, B = 0.0f;
- pCS->GetRGB(pResults, R, G, B);
+ float R = 0.0f;
+ float G = 0.0f;
+ float B = 0.0f;
+ pCS->GetRGB(pResults, &R, &G, &B);
rgb_array[i] =
FXARGB_TODIB(FXARGB_MAKE(alpha, FXSYS_round(R * 255),
FXSYS_round(G * 255), FXSYS_round(B * 255)));
@@ -355,7 +359,7 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap,
for (const auto& func : funcs) {
if (func) {
int nresults;
- if (func->Call(input, 2, pResults + offset, nresults))
+ if (func->Call(input, 2, pResults + offset, &nresults))
offset += nresults;
}
}
@@ -363,7 +367,7 @@ void DrawFuncShading(CFX_DIBitmap* pBitmap,
float R = 0.0f;
float G = 0.0f;
float B = 0.0f;
- pCS->GetRGB(pResults, R, G, B);
+ pCS->GetRGB(pResults, &R, &G, &B);
dib_buf[column] = FXARGB_TODIB(FXARGB_MAKE(
alpha, (int32_t)(R * 255), (int32_t)(G * 255), (int32_t)(B * 255)));
}
@@ -2041,8 +2045,10 @@ void CPDF_RenderStatus::DrawShading(CPDF_ShadingPattern* pPattern,
CFX_FixedBufGrow<float, 16> comps(pColorSpace->CountComponents());
for (uint32_t i = 0; i < pColorSpace->CountComponents(); i++)
comps[i] = pBackColor->GetNumberAt(i);
- float R = 0.0f, G = 0.0f, B = 0.0f;
- pColorSpace->GetRGB(comps, R, G, B);
+ float R = 0.0f;
+ float G = 0.0f;
+ float B = 0.0f;
+ pColorSpace->GetRGB(comps, &R, &G, &B);
background = ArgbEncode(255, (int32_t)(R * 255), (int32_t)(G * 255),
(int32_t)(B * 255));
}
@@ -2585,7 +2591,7 @@ std::unique_ptr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
for (size_t i = 0; i < count; i++) {
pFloats[i] = pBC->GetNumberAt(i);
}
- pCS->GetRGB(pFloats, R, G, B);
+ pCS->GetRGB(pFloats, &R, &G, &B);
back_color = 0xff000000 | ((int32_t)(R * 255) << 16) |
((int32_t)(G * 255) << 8) | (int32_t)(B * 255);
m_pContext->GetDocument()->GetPageData()->ReleaseColorSpace(pCSObj);
@@ -2621,7 +2627,7 @@ std::unique_ptr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
for (int i = 0; i < 256; i++) {
float input = (float)i / 255.0f;
int nresult;
- pFunc->Call(&input, 1, results, nresult);
+ pFunc->Call(&input, 1, results, &nresult);
transfers[i] = FXSYS_round(results[0] * 255);
}
} else {