summaryrefslogtreecommitdiff
path: root/core/fpdfapi/fpdf_render
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi/fpdf_render')
-rw-r--r--core/fpdfapi/fpdf_render/fpdf_render_image.cpp103
-rw-r--r--core/fpdfapi/fpdf_render/render_int.h5
2 files changed, 62 insertions, 46 deletions
diff --git a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
index 0ea4a17684..de9d1099cf 100644
--- a/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
+++ b/core/fpdfapi/fpdf_render/fpdf_render_image.cpp
@@ -197,98 +197,113 @@ CPDF_DIBTransferFunc::CPDF_DIBTransferFunc(
m_RampG = &pTransferFunc->m_Samples[256];
m_RampB = &pTransferFunc->m_Samples[512];
}
-void CPDF_DIBTransferFunc::TranslateScanline(uint8_t* dest_buf,
- const uint8_t* src_buf) const {
- int i;
+
+void CPDF_DIBTransferFunc::TranslateScanline(
+ const uint8_t* src_buf,
+ std::vector<uint8_t>* dest_buf) const {
FX_BOOL bSkip = FALSE;
switch (m_pSrc->GetFormat()) {
case FXDIB_1bppRgb: {
- int r0 = m_RampR[0], g0 = m_RampG[0], b0 = m_RampB[0];
- int r1 = m_RampR[255], g1 = m_RampG[255], b1 = m_RampB[255];
- for (i = 0; i < m_Width; i++) {
+ int r0 = m_RampR[0];
+ int g0 = m_RampG[0];
+ int b0 = m_RampB[0];
+ int r1 = m_RampR[255];
+ int g1 = m_RampG[255];
+ int b1 = m_RampB[255];
+ int index = 0;
+ for (int i = 0; i < m_Width; i++) {
if (src_buf[i / 8] & (1 << (7 - i % 8))) {
- *dest_buf++ = b1;
- *dest_buf++ = g1;
- *dest_buf++ = r1;
+ (*dest_buf)[index++] = b1;
+ (*dest_buf)[index++] = g1;
+ (*dest_buf)[index++] = r1;
} else {
- *dest_buf++ = b0;
- *dest_buf++ = g0;
- *dest_buf++ = r0;
+ (*dest_buf)[index++] = b0;
+ (*dest_buf)[index++] = g0;
+ (*dest_buf)[index++] = r0;
}
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- dest_buf++;
+ index++;
#endif
}
break;
}
case FXDIB_1bppMask: {
- int m0 = m_RampR[0], m1 = m_RampR[255];
- for (i = 0; i < m_Width; i++) {
- if (src_buf[i / 8] & (1 << (7 - i % 8))) {
- *dest_buf++ = m1;
- } else {
- *dest_buf++ = m0;
- }
+ int m0 = m_RampR[0];
+ int m1 = m_RampR[255];
+ int index = 0;
+ for (int i = 0; i < m_Width; i++) {
+ if (src_buf[i / 8] & (1 << (7 - i % 8)))
+ (*dest_buf)[index++] = m1;
+ else
+ (*dest_buf)[index++] = m0;
}
break;
}
case FXDIB_8bppRgb: {
FX_ARGB* pPal = m_pSrc->GetPalette();
- for (i = 0; i < m_Width; i++) {
+ int index = 0;
+ for (int i = 0; i < m_Width; i++) {
if (pPal) {
FX_ARGB src_argb = pPal[*src_buf];
- *dest_buf++ = m_RampB[FXARGB_R(src_argb)];
- *dest_buf++ = m_RampG[FXARGB_G(src_argb)];
- *dest_buf++ = m_RampR[FXARGB_B(src_argb)];
+ (*dest_buf)[index++] = m_RampB[FXARGB_R(src_argb)];
+ (*dest_buf)[index++] = m_RampG[FXARGB_G(src_argb)];
+ (*dest_buf)[index++] = m_RampR[FXARGB_B(src_argb)];
} else {
uint32_t src_byte = *src_buf;
- *dest_buf++ = m_RampB[src_byte];
- *dest_buf++ = m_RampG[src_byte];
- *dest_buf++ = m_RampR[src_byte];
+ (*dest_buf)[index++] = m_RampB[src_byte];
+ (*dest_buf)[index++] = m_RampG[src_byte];
+ (*dest_buf)[index++] = m_RampR[src_byte];
}
src_buf++;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- dest_buf++;
+ index++;
#endif
}
break;
}
- case FXDIB_8bppMask:
- for (i = 0; i < m_Width; i++) {
- *dest_buf++ = m_RampR[*(src_buf++)];
+ case FXDIB_8bppMask: {
+ int index = 0;
+ for (int i = 0; i < m_Width; i++) {
+ (*dest_buf)[index++] = m_RampR[*(src_buf++)];
}
break;
- case FXDIB_Rgb:
- for (i = 0; i < m_Width; i++) {
- *dest_buf++ = m_RampB[*(src_buf++)];
- *dest_buf++ = m_RampG[*(src_buf++)];
- *dest_buf++ = m_RampR[*(src_buf++)];
+ }
+ case FXDIB_Rgb: {
+ int index = 0;
+ for (int i = 0; i < m_Width; i++) {
+ (*dest_buf)[index++] = m_RampB[*(src_buf++)];
+ (*dest_buf)[index++] = m_RampG[*(src_buf++)];
+ (*dest_buf)[index++] = m_RampR[*(src_buf++)];
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
- dest_buf++;
+ index++;
#endif
}
break;
+ }
case FXDIB_Rgb32:
bSkip = TRUE;
- case FXDIB_Argb:
- for (i = 0; i < m_Width; i++) {
- *dest_buf++ = m_RampB[*(src_buf++)];
- *dest_buf++ = m_RampG[*(src_buf++)];
- *dest_buf++ = m_RampR[*(src_buf++)];
+ case FXDIB_Argb: {
+ int index = 0;
+ for (int i = 0; i < m_Width; i++) {
+ (*dest_buf)[index++] = m_RampB[*(src_buf++)];
+ (*dest_buf)[index++] = m_RampG[*(src_buf++)];
+ (*dest_buf)[index++] = m_RampR[*(src_buf++)];
if (!bSkip) {
- *dest_buf++ = *src_buf;
+ (*dest_buf)[index++] = *src_buf;
#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
} else {
- dest_buf++;
+ index++;
#endif
}
src_buf++;
}
break;
+ }
default:
break;
}
}
+
void CPDF_DIBTransferFunc::TranslateDownSamples(uint8_t* dest_buf,
const uint8_t* src_buf,
int pixels,
diff --git a/core/fpdfapi/fpdf_render/render_int.h b/core/fpdfapi/fpdf_render/render_int.h
index edbbad53c8..4494b8cefb 100644
--- a/core/fpdfapi/fpdf_render/render_int.h
+++ b/core/fpdfapi/fpdf_render/render_int.h
@@ -9,6 +9,7 @@
#include <map>
#include <memory>
+#include <vector>
#include "core/fpdfapi/fpdf_page/cpdf_countedobject.h"
#include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h"
@@ -618,8 +619,8 @@ class CPDF_DIBTransferFunc : public CFX_FilteredDIB {
// CFX_FilteredDIB
FXDIB_Format GetDestFormat() override;
FX_ARGB* GetDestPalette() override;
- void TranslateScanline(uint8_t* dest_buf,
- const uint8_t* src_buf) const override;
+ void TranslateScanline(const uint8_t* src_buf,
+ std::vector<uint8_t>* dest_buf) const override;
void TranslateDownSamples(uint8_t* dest_buf,
const uint8_t* src_buf,
int pixels,