Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(213)

Side by Side Diff: core/fpdfapi/render/fpdf_render_image.cpp

Issue 2551593002: Rename fpdf_render_image and fpdf_render_text (Closed)
Patch Set: Remove commented Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fpdfapi/render/cpdf_transferfunc.cpp ('k') | core/fpdfapi/render/fpdf_render_text.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7 #include "core/fpdfapi/render/render_int.h"
8
9 #include <memory>
10 #include <utility>
11 #include <vector>
12
13 #include "core/fpdfapi/page/cpdf_docpagedata.h"
14 #include "core/fpdfapi/page/cpdf_form.h"
15 #include "core/fpdfapi/page/cpdf_image.h"
16 #include "core/fpdfapi/page/cpdf_imageobject.h"
17 #include "core/fpdfapi/page/cpdf_page.h"
18 #include "core/fpdfapi/page/cpdf_shadingpattern.h"
19 #include "core/fpdfapi/page/cpdf_tilingpattern.h"
20 #include "core/fpdfapi/page/pageint.h"
21 #include "core/fpdfapi/parser/cpdf_array.h"
22 #include "core/fpdfapi/parser/cpdf_dictionary.h"
23 #include "core/fpdfapi/parser/cpdf_document.h"
24 #include "core/fpdfapi/render/cpdf_pagerendercache.h"
25 #include "core/fpdfapi/render/cpdf_rendercontext.h"
26 #include "core/fpdfapi/render/cpdf_renderoptions.h"
27 #include "core/fpdfapi/render/cpdf_renderstatus.h"
28 #include "core/fpdfapi/render/cpdf_transferfunc.h"
29 #include "core/fpdfdoc/cpdf_occontext.h"
30 #include "core/fxcodec/fx_codec.h"
31 #include "core/fxcrt/fx_safe_types.h"
32 #include "core/fxge/cfx_fxgedevice.h"
33 #include "core/fxge/cfx_pathdata.h"
34
35 #ifdef _SKIA_SUPPORT_
36 #include "core/fxge/skia/fx_skia_device.h"
37 #endif
38
39 CPDF_DIBTransferFunc::~CPDF_DIBTransferFunc() {}
40
41 FXDIB_Format CPDF_DIBTransferFunc::GetDestFormat() {
42 if (m_pSrc->IsAlphaMask()) {
43 return FXDIB_8bppMask;
44 }
45 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
46 return (m_pSrc->HasAlpha()) ? FXDIB_Argb : FXDIB_Rgb32;
47 #else
48 return (m_pSrc->HasAlpha()) ? FXDIB_Argb : FXDIB_Rgb;
49 #endif
50 }
51
52 FX_ARGB* CPDF_DIBTransferFunc::GetDestPalette() {
53 return nullptr;
54 }
55
56 CPDF_DIBTransferFunc::CPDF_DIBTransferFunc(
57 const CPDF_TransferFunc* pTransferFunc) {
58 m_RampR = pTransferFunc->m_Samples;
59 m_RampG = &pTransferFunc->m_Samples[256];
60 m_RampB = &pTransferFunc->m_Samples[512];
61 }
62
63 void CPDF_DIBTransferFunc::TranslateScanline(
64 const uint8_t* src_buf,
65 std::vector<uint8_t>* dest_buf) const {
66 bool bSkip = false;
67 switch (m_pSrc->GetFormat()) {
68 case FXDIB_1bppRgb: {
69 int r0 = m_RampR[0];
70 int g0 = m_RampG[0];
71 int b0 = m_RampB[0];
72 int r1 = m_RampR[255];
73 int g1 = m_RampG[255];
74 int b1 = m_RampB[255];
75 int index = 0;
76 for (int i = 0; i < m_Width; i++) {
77 if (src_buf[i / 8] & (1 << (7 - i % 8))) {
78 (*dest_buf)[index++] = b1;
79 (*dest_buf)[index++] = g1;
80 (*dest_buf)[index++] = r1;
81 } else {
82 (*dest_buf)[index++] = b0;
83 (*dest_buf)[index++] = g0;
84 (*dest_buf)[index++] = r0;
85 }
86 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
87 index++;
88 #endif
89 }
90 break;
91 }
92 case FXDIB_1bppMask: {
93 int m0 = m_RampR[0];
94 int m1 = m_RampR[255];
95 int index = 0;
96 for (int i = 0; i < m_Width; i++) {
97 if (src_buf[i / 8] & (1 << (7 - i % 8)))
98 (*dest_buf)[index++] = m1;
99 else
100 (*dest_buf)[index++] = m0;
101 }
102 break;
103 }
104 case FXDIB_8bppRgb: {
105 FX_ARGB* pPal = m_pSrc->GetPalette();
106 int index = 0;
107 for (int i = 0; i < m_Width; i++) {
108 if (pPal) {
109 FX_ARGB src_argb = pPal[*src_buf];
110 (*dest_buf)[index++] = m_RampB[FXARGB_R(src_argb)];
111 (*dest_buf)[index++] = m_RampG[FXARGB_G(src_argb)];
112 (*dest_buf)[index++] = m_RampR[FXARGB_B(src_argb)];
113 } else {
114 uint32_t src_byte = *src_buf;
115 (*dest_buf)[index++] = m_RampB[src_byte];
116 (*dest_buf)[index++] = m_RampG[src_byte];
117 (*dest_buf)[index++] = m_RampR[src_byte];
118 }
119 src_buf++;
120 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
121 index++;
122 #endif
123 }
124 break;
125 }
126 case FXDIB_8bppMask: {
127 int index = 0;
128 for (int i = 0; i < m_Width; i++) {
129 (*dest_buf)[index++] = m_RampR[*(src_buf++)];
130 }
131 break;
132 }
133 case FXDIB_Rgb: {
134 int index = 0;
135 for (int i = 0; i < m_Width; i++) {
136 (*dest_buf)[index++] = m_RampB[*(src_buf++)];
137 (*dest_buf)[index++] = m_RampG[*(src_buf++)];
138 (*dest_buf)[index++] = m_RampR[*(src_buf++)];
139 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
140 index++;
141 #endif
142 }
143 break;
144 }
145 case FXDIB_Rgb32:
146 bSkip = true;
147 case FXDIB_Argb: {
148 int index = 0;
149 for (int i = 0; i < m_Width; i++) {
150 (*dest_buf)[index++] = m_RampB[*(src_buf++)];
151 (*dest_buf)[index++] = m_RampG[*(src_buf++)];
152 (*dest_buf)[index++] = m_RampR[*(src_buf++)];
153 if (!bSkip) {
154 (*dest_buf)[index++] = *src_buf;
155 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
156 } else {
157 index++;
158 #endif
159 }
160 src_buf++;
161 }
162 break;
163 }
164 default:
165 break;
166 }
167 }
168
169 void CPDF_DIBTransferFunc::TranslateDownSamples(uint8_t* dest_buf,
170 const uint8_t* src_buf,
171 int pixels,
172 int Bpp) const {
173 if (Bpp == 8) {
174 for (int i = 0; i < pixels; i++) {
175 *dest_buf++ = m_RampR[*(src_buf++)];
176 }
177 } else if (Bpp == 24) {
178 for (int i = 0; i < pixels; i++) {
179 *dest_buf++ = m_RampB[*(src_buf++)];
180 *dest_buf++ = m_RampG[*(src_buf++)];
181 *dest_buf++ = m_RampR[*(src_buf++)];
182 }
183 } else {
184 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
185 if (!m_pSrc->HasAlpha()) {
186 for (int i = 0; i < pixels; i++) {
187 *dest_buf++ = m_RampB[*(src_buf++)];
188 *dest_buf++ = m_RampG[*(src_buf++)];
189 *dest_buf++ = m_RampR[*(src_buf++)];
190 dest_buf++;
191 src_buf++;
192 }
193 } else {
194 #endif
195 for (int i = 0; i < pixels; i++) {
196 *dest_buf++ = m_RampB[*(src_buf++)];
197 *dest_buf++ = m_RampG[*(src_buf++)];
198 *dest_buf++ = m_RampR[*(src_buf++)];
199 *dest_buf++ = *(src_buf++);
200 }
201 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
202 }
203 #endif
204 }
205 }
206
207 CCodec_ScanlineDecoder* FPDFAPI_CreateFlateDecoder(
208 const uint8_t* src_buf,
209 uint32_t src_size,
210 int width,
211 int height,
212 int nComps,
213 int bpc,
214 const CPDF_Dictionary* pParams);
OLDNEW
« no previous file with comments | « core/fpdfapi/render/cpdf_transferfunc.cpp ('k') | core/fpdfapi/render/fpdf_render_text.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698