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

Side by Side Diff: core/src/fxge/skia/fx_skia_blitter.cpp

Issue 402463002: Replace agg with skia (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix clang compile error Created 6 years, 5 months 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/src/fxge/skia/fx_skia_blitter.h ('k') | core/src/fxge/skia/fx_skia_blitter_new.h » ('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 "../../../include/fxge/fx_ge.h"
8 #include "../../../include/fxcodec/fx_codec.h"
9 #include "fx_skia.h"
10 #include "fx_skia_blitter.h"
11
12 void CFX_SkiaRenderer::blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[])
13 {
14 FXSYS_assert(m_Alpha);
15 if (m_pOriDevice == NULL && composite_span == NULL) {
16 return;
17 }
18 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) {
19 return;
20 }
21 while (1) {
22 int width = runs[0];
23 SkASSERT(width >= 0);
24 if (width <= 0) {
25 return;
26 }
27 unsigned aa = antialias[0];
28 if (aa) {
29 (this->*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, aa, m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaS can);
30 }
31 runs += width;
32 antialias += width;
33 x += width;
34 }
35 }
36
37 void CFX_SkiaRenderer::blitH(int x, int y, int width)
38 {
39 FXSYS_assert(m_Alpha && width);
40 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) {
41 return;
42 }
43 (this->*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, 255, m_Clip Box.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan);
44 }
45
46 void CFX_SkiaRenderer::blitV(int x, int y, int height, SkAlpha alpha)
47 {
48 FXSYS_assert(m_Alpha && alpha);
49 if (alpha == 255) {
50 this->blitRect(x, y, 1, height);
51 } else {
52 int16_t runs[2];
53 runs[0] = 1;
54 runs[1] = 0;
55 while (--height >= 0) {
56 if (y >= m_ClipBox.bottom) {
57 return;
58 }
59 this->blitAntiH(x, y ++, &alpha, runs);
60 }
61 }
62 }
63 void CFX_SkiaRenderer::blitRect(int x, int y, int width, int height)
64 {
65 FXSYS_assert(m_Alpha && width);
66 while (--height >= 0) {
67 if (y >= m_ClipBox.bottom) {
68 return;
69 }
70 blitH(x, y ++, width);
71 }
72 }
73
74 void CFX_SkiaRenderer::blitAntiRect(int x, int y, int width, int height,
75 SkAlpha leftAlpha, SkAlpha rightAlpha)
76 {
77 blitV(x++, y, height, leftAlpha);
78 if (width > 0) {
79 blitRect(x, y, width, height);
80 x += width;
81 }
82 blitV(x, y, height, rightAlpha);
83 }
84
85 void CFX_SkiaRenderer::CompositeSpan1bpp_0(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
86 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
87 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
88 FX_LPBYTE dest_extra_alpha_scan)
89 {
90 ASSERT(!m_bRgbByteOrder);
91 ASSERT(!m_pDevice->IsCmykImage());
92 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left / 8;
93 int col_start = span_left < clip_left ? clip_left - span_left : 0;
94 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
95 if (col_end < col_start) {
96 return;
97 }
98 dest_scan += col_start / 8;
99 int index = 0;
100 if (m_pDevice->GetPalette() == NULL) {
101 index = ((FX_BYTE)m_Color == 0xff) ? 1 : 0;
102 } else {
103 for (int i = 0; i < 2; i ++)
104 if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) {
105 index = i;
106 }
107 }
108 FX_LPBYTE dest_scan1 = dest_scan;
109 int src_alpha = m_Alpha * cover_scan / 255;
110 for (int col = col_start; col < col_end; col ++) {
111 if (src_alpha) {
112 if (!index) {
113 *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8));
114 } else {
115 *dest_scan1 |= 1 << (7 - (col + span_left) % 8);
116 }
117 }
118 dest_scan1 = dest_scan + (span_left % 8 + col - col_start + 1) / 8;
119 }
120 }
121
122 void CFX_SkiaRenderer::CompositeSpan1bpp_4(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
123 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
124 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
125 FX_LPBYTE dest_extra_alpha_scan)
126 {
127 ASSERT(!m_bRgbByteOrder);
128 ASSERT(!m_pDevice->IsCmykImage());
129 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left / 8;
130 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
131 int col_start = span_left < clip_left ? clip_left - span_left : 0;
132 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
133 if (col_end < col_start) {
134 return;
135 }
136 dest_scan += col_start / 8;
137 int index = 0;
138 if (m_pDevice->GetPalette() == NULL) {
139 index = ((FX_BYTE)m_Color == 0xff) ? 1 : 0;
140 } else {
141 for (int i = 0; i < 2; i ++)
142 if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) {
143 index = i;
144 }
145 }
146 FX_LPBYTE dest_scan1 = dest_scan;
147 int src_alpha = m_Alpha * cover_scan / 255;
148 for (int col = col_start; col < col_end; col ++) {
149 int src_alpha1 = src_alpha * clip_scan[col] / 255;
150 if (src_alpha1) {
151 if (!index) {
152 *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8));
153 } else {
154 *dest_scan1 |= 1 << (7 - (col + span_left) % 8);
155 }
156 }
157 dest_scan1 = dest_scan + (span_left % 8 + col - col_start + 1) / 8;
158 }
159 }
160
161 void CFX_SkiaRenderer::CompositeSpanGray_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
162 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
163 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
164 FX_LPBYTE dest_extra_alpha_scan)
165 {
166 ASSERT(!m_pDevice->IsCmykImage());
167 ASSERT(!m_bRgbByteOrder);
168 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left;
169 int col_start = span_left < clip_left ? clip_left - span_left : 0;
170 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
171 if (col_end < col_start) {
172 return;
173 }
174 dest_scan += col_start;
175 if (cover_scan == 255 && m_Alpha == 255) {
176 for (int col = 0; col < col_end - col_start; col++) {
177 *(FX_DWORD*)dest_scan = FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray);
178 dest_scan += 4;
179 }
180 return;
181 }
182 int src_alpha = m_Alpha * cover_scan / 255;
183 for (int col = col_start; col < col_end; col ++) {
184 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha);
185 dest_scan++;
186 }
187 }
188
189 void CFX_SkiaRenderer::CompositeSpanGray_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
190 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
191 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
192 FX_LPBYTE dest_extra_alpha_scan)
193 {
194 ASSERT(!m_pDevice->IsCmykImage());
195 ASSERT(!m_bRgbByteOrder);
196 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left;
197 ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + span_left;
198 int col_start = span_left < clip_left ? clip_left - span_left : 0;
199 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
200 if (col_end < col_start) {
201 return;
202 }
203 dest_scan += col_start;
204 ori_scan += col_start;
205 if (m_Alpha == 255 && cover_scan == 255) {
206 for (int col = 0; col < col_end - col_start; col++) {
207 *(FX_DWORD*)dest_scan = FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray);
208 dest_scan += 4;
209 }
210 } else {
211 int src_alpha = m_Alpha;
212 for (int col = col_start; col < col_end; col ++) {
213 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
214 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
215 dest_scan ++;
216 }
217 }
218 }
219
220 void CFX_SkiaRenderer::CompositeSpanGray_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
221 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
222 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
223 FX_LPBYTE dest_extra_alpha_scan)
224 {
225 ASSERT(!m_bRgbByteOrder);
226 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left;
227 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
228 int col_start = span_left < clip_left ? clip_left - span_left : 0;
229 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
230 if (col_end < col_start) {
231 return;
232 }
233 dest_scan += col_start;
234 int src_alpha = m_Alpha * cover_scan / 255;
235 for (int col = col_start; col < col_end; col ++) {
236 int src_alpha1 = src_alpha * clip_scan[col] / 255;
237 if (!src_alpha1) {
238 dest_scan ++;
239 continue;
240 }
241 if (src_alpha1 == 255) {
242 *dest_scan++ = m_Gray;
243 } else {
244 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha1);
245 dest_scan ++;
246 }
247 }
248 }
249
250 void CFX_SkiaRenderer::CompositeSpanGray_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
251 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
252 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
253 FX_LPBYTE dest_extra_alpha_scan)
254 {
255 ASSERT(!m_pDevice->IsCmykImage());
256 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left;
257 ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + span_left;
258 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
259 int col_start = span_left < clip_left ? clip_left - span_left : 0;
260 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
261 if (col_end < col_start) {
262 return;
263 }
264 dest_scan += col_start;
265 ori_scan += col_start;
266 for (int col = col_start; col < col_end; col ++) {
267 int src_alpha = m_Alpha * clip_scan[col] / 255;
268 if (src_alpha == 255 && cover_scan == 255) {
269 *dest_scan++ = m_Gray;
270 ori_scan++;
271 continue;
272 }
273 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha);
274 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan);
275 dest_scan++;
276 }
277 }
278
279 void CFX_SkiaRenderer::CompositeSpanARGB_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
280 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
281 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
282 FX_LPBYTE dest_extra_alpha_scan)
283 {
284 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left << 2);
285 int col_start = span_left < clip_left ? clip_left - span_left : 0;
286 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
287 if (col_end < col_start) {
288 return;
289 }
290 dest_scan += col_start << 2;
291 if (m_Alpha == 255 && cover_scan == 255) {
292 for (int col = 0; col < col_end - col_start; col++) {
293 *(FX_DWORD*)dest_scan = m_Color;
294 dest_scan += 4;
295 }
296 return;
297 }
298 int src_alpha;
299 src_alpha = m_Alpha * cover_scan / 255;
300 for (int col = col_start; col < col_end; col ++) {
301 if (dest_scan[3] == 0) {
302 dest_scan[3] = src_alpha;
303 *dest_scan++ = m_Blue;
304 *dest_scan++ = m_Green;
305 *dest_scan = m_Red;
306 dest_scan += 2;
307 continue;
308 }
309 FX_BYTE dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255;
310 dest_scan[3] = dest_alpha;
311 int alpha_ratio = src_alpha * 255 / dest_alpha;
312 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
313 dest_scan ++;
314 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
315 dest_scan ++;
316 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
317 dest_scan += 2;
318 }
319 }
320
321 void CFX_SkiaRenderer::CompositeSpanARGB_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
322 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
323 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
324 FX_LPBYTE dest_extra_alpha_scan)
325 {
326 ASSERT(!m_pDevice->IsCmykImage());
327 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left << 2);
328 int col_start = span_left < clip_left ? clip_left - span_left : 0;
329 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
330 if (col_end < col_start) {
331 return;
332 }
333 dest_scan += col_start << 2;
334 if (m_Alpha == 255 && cover_scan == 255) {
335 for (int col = 0; col < col_end - col_start; col++) {
336 *(FX_DWORD*)dest_scan = m_Color;
337 dest_scan += 4;
338 }
339 return;
340 }
341 if (cover_scan == 255) {
342 int dst_color = (0x00ffffff & m_Color) | (m_Alpha << 24);
343 for (int col = 0; col < col_end - col_start; col++) {
344 *(FX_DWORD*)dest_scan = dst_color;
345 dest_scan += 4;
346 }
347 return;
348 }
349 int src_alpha_covered = m_Alpha * cover_scan / 255;
350 for (int col = col_start; col < col_end; col ++) {
351 if (dest_scan[3] == 0) {
352 dest_scan[3] = src_alpha_covered;
353 *dest_scan ++ = m_Blue;
354 *dest_scan ++ = m_Green;
355 *dest_scan = m_Red;
356 dest_scan += 2;
357 continue;
358 }
359 dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], m_Alpha, cover_scan);
360 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan);
361 dest_scan ++;
362 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan);
363 dest_scan ++;
364 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan);
365 dest_scan += 2;
366 }
367 }
368
369 void CFX_SkiaRenderer::CompositeSpanARGB_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
370 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
371 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
372 FX_LPBYTE dest_extra_alpha_scan)
373 {
374 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left << 2);
375 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
376 int col_start = span_left < clip_left ? clip_left - span_left : 0;
377 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
378 if (col_end < col_start) {
379 return;
380 }
381 dest_scan += col_start << 2;
382 int src_alpha = m_Alpha * cover_scan / 255;
383 for (int col = col_start; col < col_end; col ++) {
384 int src_alpha1 = src_alpha * clip_scan[col] / 255;
385 if (!src_alpha1) {
386 dest_scan += 4;
387 continue;
388 }
389 if (src_alpha1 == 255) {
390 *(FX_DWORD*)dest_scan = m_Color;
391 dest_scan += 4;
392 } else {
393 if (dest_scan[3] == 0) {
394 dest_scan[3] = src_alpha1;
395 *dest_scan++ = m_Blue;
396 *dest_scan++ = m_Green;
397 *dest_scan = m_Red;
398 dest_scan += 2;
399 continue;
400 }
401 FX_BYTE dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] * src_ alpha1 / 255;
402 dest_scan[3] = dest_alpha;
403 int alpha_ratio = src_alpha1 * 255 / dest_alpha;
404 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
405 dest_scan ++;
406 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
407 dest_scan ++;
408 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
409 dest_scan += 2;
410 }
411 }
412 }
413
414 void CFX_SkiaRenderer::CompositeSpanARGB_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_sc an, int Bpp,
415 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
416 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
417 FX_LPBYTE dest_extra_alpha_scan)
418 {
419 ASSERT(!m_pDevice->IsCmykImage());
420 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left << 2);
421 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
422 int col_start = span_left < clip_left ? clip_left - span_left : 0;
423 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
424 if (col_end < col_start) {
425 return;
426 }
427 dest_scan += col_start << 2;
428 for (int col = col_start; col < col_end; col ++) {
429 int src_alpha = m_Alpha * clip_scan[col] / 255;
430 int src_alpha_covered = src_alpha * cover_scan / 255;
431 if (src_alpha_covered == 0) {
432 dest_scan += 4;
433 continue;
434 }
435 if (cover_scan == 255 || dest_scan[3] == 0) {
436 dest_scan[3] = src_alpha_covered;
437 *dest_scan ++ = m_Blue;
438 *dest_scan ++ = m_Green;
439 *dest_scan = m_Red;
440 dest_scan += 2;
441 continue;
442 }
443 dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], src_alpha, cover_scan);
444 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan);
445 dest_scan ++;
446 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan);
447 dest_scan ++;
448 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan);
449 dest_scan += 2;
450 }
451 }
452
453 void CFX_SkiaRenderer::CompositeSpanRGB32_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_s can, int Bpp,
454 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
455 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
456 FX_LPBYTE dest_extra_alpha_scan)
457 {
458 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left << 2);
459 int col_start = span_left < clip_left ? clip_left - span_left : 0;
460 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
461 if (col_end < col_start) {
462 return;
463 }
464 dest_scan += (col_start << 2);
465 if (m_Alpha == 255 && cover_scan == 255) {
466 for (int col = 0; col < col_end - col_start; col++) {
467 *(FX_DWORD*)dest_scan = m_Color;
468 dest_scan += 4;
469 }
470 return;
471 }
472 int src_alpha;
473 src_alpha = m_Alpha * cover_scan / 255;
474 for (int col = col_start; col < col_end; col ++) {
475 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
476 dest_scan ++;
477 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
478 dest_scan ++;
479 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
480 dest_scan += 2;
481 }
482 }
483 void CFX_SkiaRenderer::CompositeSpanRGB32_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_s can, int Bpp,
484 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
485 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
486 FX_LPBYTE dest_extra_alpha_scan)
487 {
488 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left << 2);
489 ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + (span_left << 2) ;
490 int col_start = span_left < clip_left ? clip_left - span_left : 0;
491 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
492 if (col_end < col_start) {
493 return;
494 }
495 dest_scan += col_start << 2;
496 ori_scan += col_start << 2;
497 if (m_Alpha == 255 && cover_scan == 255) {
498 for (int col = 0; col < col_end - col_start; col++) {
499 *(FX_DWORD*)dest_scan = m_Color;
500 dest_scan += 4;
501 }
502 return;
503 }
504 int src_alpha = m_Alpha;
505 for (int col = col_start; col < col_end; col ++) {
506 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
507 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
508 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
509 ori_scan += 2;
510 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
511 dest_scan ++;
512 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
513 dest_scan ++;
514 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
515 dest_scan += 2;
516 }
517 }
518 void CFX_SkiaRenderer::CompositeSpanRGB32_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_s can, int Bpp,
519 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
520 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
521 FX_LPBYTE dest_extra_alpha_scan)
522 {
523 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left << 2);
524 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
525 int col_start = span_left < clip_left ? clip_left - span_left : 0;
526 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
527 if (col_end < col_start) {
528 return;
529 }
530 dest_scan += col_start << 2;
531 int src_alpha = m_Alpha * cover_scan / 255;
532 for (int col = col_start; col < col_end; col ++) {
533 int src_alpha1 = src_alpha * clip_scan[col] / 255;
534 if (!src_alpha1) {
535 dest_scan += 4;
536 continue;
537 }
538 if (src_alpha1 == 255) {
539 *(FX_DWORD*)dest_scan = m_Color;
540 dest_scan += 4;
541 } else {
542 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
543 dest_scan ++;
544 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
545 dest_scan ++;
546 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
547 dest_scan += 2;
548 }
549 }
550 }
551 void CFX_SkiaRenderer::CompositeSpanRGB32_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_s can, int Bpp,
552 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
553 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
554 FX_LPBYTE dest_extra_alpha_scan)
555 {
556 ASSERT(!m_pDevice->IsCmykImage());
557 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + (span_left << 2);
558 ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + (span_left << 2) ;
559 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
560 int col_start = span_left < clip_left ? clip_left - span_left : 0;
561 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
562 if (col_end < col_start) {
563 return;
564 }
565 dest_scan += col_start << 2;
566 ori_scan += col_start << 2;
567 for (int col = col_start; col < col_end; col ++) {
568 int src_alpha = m_Alpha * clip_scan[col] / 255;
569 if (src_alpha == 255 && cover_scan == 255) {
570 *(FX_DWORD*)dest_scan = m_Color;
571 dest_scan += 4;
572 ori_scan += 4;
573 continue;
574 }
575 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
576 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
577 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha);
578 ori_scan += 2;
579 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
580 dest_scan ++;
581 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
582 dest_scan ++;
583 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
584 dest_scan += 2;
585 }
586 }
587
588 void CFX_SkiaRenderer::CompositeSpanRGB24_2(FX_LPBYTE dest_scan, FX_LPBYTE ori_s can, int Bpp,
589 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
590 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
591 FX_LPBYTE dest_extra_alpha_scan)
592 {
593 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left + (span_l eft << 1);
594 int col_start = span_left < clip_left ? clip_left - span_left : 0;
595 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
596 if (col_end < col_start) {
597 return;
598 }
599 dest_scan += (col_start << 1) + col_start;
600 int src_alpha;
601 src_alpha = m_Alpha * cover_scan / 255;
602 if (src_alpha == 255) {
603 for (int col = col_start; col < col_end; col ++) {
604 *dest_scan++ = m_Blue;
605 *dest_scan++ = m_Green;
606 *dest_scan++ = m_Red;
607 }
608 return;
609 }
610 for (int col = col_start; col < col_end; col ++) {
611 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha);
612 dest_scan ++;
613 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha);
614 dest_scan ++;
615 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha);
616 dest_scan ++;
617 }
618 }
619 void CFX_SkiaRenderer::CompositeSpanRGB24_3(FX_LPBYTE dest_scan, FX_LPBYTE ori_s can, int Bpp,
620 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
621 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
622 FX_LPBYTE dest_extra_alpha_scan)
623 {
624 ASSERT(!m_pDevice->IsCmykImage());
625 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left + (span_l eft << 1);
626 ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + span_left + (spa n_left << 1);
627 int col_start = span_left < clip_left ? clip_left - span_left : 0;
628 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
629 if (col_end < col_start) {
630 return;
631 }
632 dest_scan += (col_start << 1) + col_start;
633 ori_scan += (col_start << 1) + col_start;
634 if (m_Alpha == 255 && cover_scan == 255) {
635 for (int col = col_start; col < col_end; col ++) {
636 *dest_scan ++ = m_Blue;
637 *dest_scan ++ = m_Green;
638 *dest_scan ++ = m_Red;
639 }
640 return;
641 }
642 for (int col = col_start; col < col_end; col ++) {
643 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha);
644 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha);
645 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha);
646 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
647 dest_scan ++;
648 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
649 dest_scan ++;
650 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
651 dest_scan ++;
652 }
653 }
654 void CFX_SkiaRenderer::CompositeSpanRGB24_6(FX_LPBYTE dest_scan, FX_LPBYTE ori_s can, int Bpp,
655 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
656 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
657 FX_LPBYTE dest_extra_alpha_scan)
658 {
659 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left + (span_l eft << 1);
660 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
661 int col_start = span_left < clip_left ? clip_left - span_left : 0;
662 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
663 if (col_end < col_start) {
664 return;
665 }
666 dest_scan += col_start + (col_start << 1);
667 int src_alpha = m_Alpha * cover_scan / 255;
668 for (int col = col_start; col < col_end; col ++) {
669 int src_alpha1 = src_alpha * clip_scan[col] / 255;
670 if (!src_alpha1) {
671 dest_scan += 3;
672 continue;
673 }
674 if (src_alpha1 == 255) {
675 *dest_scan++ = m_Blue;
676 *dest_scan++ = m_Green;
677 *dest_scan++ = m_Red;
678 } else {
679 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1);
680 dest_scan ++;
681 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1);
682 dest_scan ++;
683 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1);
684 dest_scan ++;
685 }
686 }
687 }
688 void CFX_SkiaRenderer::CompositeSpanRGB24_7(FX_LPBYTE dest_scan, FX_LPBYTE ori_s can, int Bpp,
689 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
690 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
691 FX_LPBYTE dest_extra_alpha_scan)
692 {
693 ASSERT(!m_pDevice->IsCmykImage());
694 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left + (span_l eft << 1);
695 ori_scan = (FX_BYTE*)m_pOriDevice->GetScanline(span_top) + span_left + (spa n_left << 1);
696 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
697 int col_start = span_left < clip_left ? clip_left - span_left : 0;
698 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
699 if (col_end < col_start) {
700 return;
701 }
702 dest_scan += col_start + (col_start << 1);
703 ori_scan += col_start + (col_start << 1);
704 for (int col = col_start; col < col_end; col ++) {
705 int src_alpha = m_Alpha * clip_scan[col] / 255;
706 if (src_alpha == 255 && cover_scan == 255) {
707 *dest_scan++ = m_Blue;
708 *dest_scan++ = m_Green;
709 *dest_scan++ = m_Red;
710 ori_scan += 3;
711 continue;
712 }
713 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha);
714 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha);
715 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha);
716 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan);
717 dest_scan ++;
718 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan);
719 dest_scan ++;
720 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan);
721 dest_scan ++;
722 }
723 }
724 void CFX_SkiaRenderer::CompositeSpanRGB24_10(FX_LPBYTE dest_scan, FX_LPBYTE ori_ scan, int Bpp,
725 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
726 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
727 FX_LPBYTE dest_extra_alpha_scan)
728 {
729 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left + (span_l eft << 1);
730 dest_extra_alpha_scan = (FX_BYTE*)m_pDevice->m_pAlphaMask->GetScanline(span _top) + span_left;
731 int col_start = span_left < clip_left ? clip_left - span_left : 0;
732 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
733 if (col_end < col_start) {
734 return;
735 }
736 dest_scan += col_start + (col_start << 1);
737 if (m_Alpha == 255 && cover_scan == 255) {
738 for (int col = col_start; col < col_end; col ++) {
739 *dest_scan++ = (FX_BYTE)m_Blue;
740 *dest_scan++ = (FX_BYTE)m_Green;
741 *dest_scan++ = (FX_BYTE)m_Red;
742 *dest_extra_alpha_scan++ = 255;
743 }
744 return;
745 }
746 int src_alpha = m_Alpha * cover_scan / 255;
747 for (int col = col_start; col < col_end; col ++) {
748 FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
749 (*dest_extra_alpha_scan) * src_alpha / 255;
750 *dest_extra_alpha_scan++ = dest_alpha;
751 int alpha_ratio = src_alpha * 255 / dest_alpha;
752 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
753 dest_scan ++;
754 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
755 dest_scan ++;
756 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
757 dest_scan ++;
758 }
759 }
760 void CFX_SkiaRenderer::CompositeSpanRGB24_14(FX_LPBYTE dest_scan, FX_LPBYTE ori_ scan, int Bpp,
761 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
762 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
763 FX_LPBYTE dest_extra_alpha_scan)
764 {
765 dest_scan = (FX_BYTE*)m_pDevice->GetScanline(span_top) + span_left + (span_l eft << 1);
766 dest_extra_alpha_scan = (FX_BYTE*)m_pDevice->m_pAlphaMask->GetScanline(span _top) + span_left;
767 clip_scan = (FX_BYTE*)m_pClipMask->GetScanline(span_top - clip_top) - clip_l eft + span_left;
768 int col_start = span_left < clip_left ? clip_left - span_left : 0;
769 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
770 if (col_end < col_start) {
771 return;
772 }
773 dest_scan += col_start + (col_start << 1);
774 int src_alpha = m_Alpha * cover_scan / 255;
775 for (int col = col_start; col < col_end; col ++) {
776 int src_alpha1 = src_alpha * clip_scan[col] / 255;
777 if (!src_alpha1) {
778 dest_extra_alpha_scan++;
779 dest_scan += 3;
780 continue;
781 }
782 if (src_alpha1 == 255) {
783 *dest_scan++ = (FX_BYTE)m_Blue;
784 *dest_scan++ = (FX_BYTE)m_Green;
785 *dest_scan++ = (FX_BYTE)m_Red;
786 *dest_extra_alpha_scan++ = (FX_BYTE)m_Alpha;
787 } else {
788 FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 -
789 (*dest_extra_alpha_scan) * src_alpha1 / 255;
790 *dest_extra_alpha_scan++ = dest_alpha;
791 int alpha_ratio = src_alpha1 * 255 / dest_alpha;
792 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio);
793 dest_scan ++;
794 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio);
795 dest_scan ++;
796 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio);
797 dest_scan ++;
798 }
799 }
800 }
801
802 void CFX_SkiaRenderer::CompositeSpanCMYK(FX_LPBYTE dest_scan, FX_LPBYTE ori_scan , int Bpp,
803 int span_left, int span_len, int span_top, FX_BYTE cover_scan,
804 int clip_top, int clip_left, int clip_right, FX_LPBYTE clip_scan,
805 FX_LPBYTE dest_extra_alpha_scan)
806 {
807 ASSERT(!m_bRgbByteOrder);
808 int col_start = span_left < clip_left ? clip_left - span_left : 0;
809 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_right - span_left);
810 if (col_end < col_start) {
811 return;
812 }
813 dest_scan += col_start * 4;
814
815 if (dest_extra_alpha_scan) {
816 for (int col = col_start; col < col_end; col ++) {
817 int src_alpha;
818 if (m_bFullCover) {
819 if (clip_scan) {
820 src_alpha = m_Alpha * clip_scan[col] / 255;
821 } else {
822 src_alpha = m_Alpha;
823 }
824 } else {
825 if (clip_scan) {
826 src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 25 5;
827 } else {
828 src_alpha = m_Alpha * cover_scan / 255;
829 }
830 }
831 if (src_alpha) {
832 if (src_alpha == 255) {
833 *(FX_CMYK*)dest_scan = m_Color;
834 *dest_extra_alpha_scan = (FX_BYTE)m_Alpha;
835 } else {
836 FX_BYTE dest_alpha = (*dest_extra_alpha_scan) + src_alpha -
837 (*dest_extra_alpha_scan) * src_alpha / 255;
838 *dest_extra_alpha_scan++ = dest_alpha;
839 int alpha_ratio = src_alpha * 255 / dest_alpha;
840 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_rati o);
841 dest_scan ++;
842 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ra tio);
843 dest_scan ++;
844 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_rat io);
845 dest_scan ++;
846 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, alpha_rat io);
847 dest_scan ++;
848 continue;
849 }
850 }
851 dest_extra_alpha_scan++;
852 dest_scan += 4;
853 }
854 } else {
855 for (int col = col_start; col < col_end; col ++) {
856 int src_alpha;
857 if (clip_scan) {
858 src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255;
859 } else {
860 src_alpha = m_Alpha * cover_scan / 255;
861 }
862 if (src_alpha) {
863 if (src_alpha == 255) {
864 *(FX_CMYK*)dest_scan = m_Color;
865 } else {
866 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha) ;
867 dest_scan ++;
868 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alph a);
869 dest_scan ++;
870 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha );
871 dest_scan ++;
872 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha );
873 dest_scan ++;
874 continue;
875 }
876 }
877 dest_scan += 4;
878 }
879 }
880 }
881
882 FX_BOOL CFX_SkiaRenderer::Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevice, const CFX_ClipRgn* pClipRgn, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bRgbByt eOrder,
883 int alpha_flag, void* pIccTransform)
884 {
885 m_pDevice = pDevice;
886 m_pClipRgn = pClipRgn;
887 m_bRgbByteOrder = bRgbByteOrder;
888 m_pOriDevice = pOriDevice;
889 m_pDestScan = NULL;
890 m_pDestExtraAlphaScan = NULL;
891 m_pOriScan = NULL;
892 m_pClipScan = NULL;
893 composite_span = NULL;
894 if (m_pClipRgn) {
895 m_ClipBox = m_pClipRgn->GetBox();
896 } else {
897 m_ClipBox.left = m_ClipBox.top = 0;
898 m_ClipBox.right = m_pDevice->GetWidth();
899 m_ClipBox.bottom = m_pDevice->GetHeight();
900 }
901 m_pClipMask = NULL;
902 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) {
903 m_pClipMask = m_pClipRgn->GetMask();
904 m_pClipScan = m_pClipMask->GetBuffer();
905 }
906 if (m_pDevice->m_pAlphaMask) {
907 m_pDestExtraAlphaScan = m_pDevice->m_pAlphaMask->GetBuffer();
908 }
909 if (m_pOriDevice) {
910 m_pOriScan = m_pOriDevice->GetBuffer();
911 }
912 m_pDestScan = m_pDevice->GetBuffer();
913 m_bFullCover = bFullCover;
914 FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag);
915 FX_BOOL bDeviceCMYK = pDevice->IsCmykImage();
916 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color);
917 ICodec_IccModule* pIccModule = NULL;
918 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetCodec Module()->GetIccModule()) {
919 pIccTransform = NULL;
920 } else {
921 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule();
922 }
923 if (m_pDevice->GetBPP() == 8) {
924 ASSERT(!m_bRgbByteOrder);
925 if (m_pDevice->IsAlphaMask()) {
926 m_Gray = 255;
927 } else {
928 if (pIccTransform) {
929 FX_BYTE gray;
930 color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
931 pIccModule->TranslateScanline(pIccTransform, &gray, (FX_LPCBYTE) &color, 1);
932 m_Gray = gray;
933 } else {
934 if (bObjectCMYK) {
935 FX_BYTE r, g, b;
936 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(c olor), FXSYS_GetYValue(color), FXSYS_GetKValue(color),
937 r, g, b);
938 m_Gray = FXRGB2GRAY(r, g, b);
939 } else {
940 m_Gray = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB _B(color));
941 }
942 }
943 }
944 } else {
945 if (bDeviceCMYK) {
946 ASSERT(!m_bRgbByteOrder);
947 composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK;
948 if (bObjectCMYK) {
949 m_Color = FXCMYK_TODIB(color);
950 if (pIccTransform) {
951 pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&m_C olor, (FX_LPCBYTE)&m_Color, 1);
952 }
953 } else {
954 if (!pIccTransform) {
955 return FALSE;
956 }
957 color = FXARGB_TODIB(color);
958 pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&m_Color , (FX_LPCBYTE)&color, 1);
959 }
960 m_Red = ((FX_LPBYTE)&m_Color)[0];
961 m_Green = ((FX_LPBYTE)&m_Color)[1];
962 m_Blue = ((FX_LPBYTE)&m_Color)[2];
963 m_Gray = ((FX_LPBYTE)&m_Color)[3];
964 return TRUE;
965 } else {
966 if (pIccTransform) {
967 color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color);
968 pIccModule->TranslateScanline(pIccTransform, (FX_LPBYTE)&m_Color , (FX_LPCBYTE)&color, 1);
969 ((FX_LPBYTE)&m_Color)[3] = m_Alpha;
970 m_Red = ((FX_LPBYTE)&m_Color)[2];
971 m_Green = ((FX_LPBYTE)&m_Color)[1];
972 m_Blue = ((FX_LPBYTE)&m_Color)[0];
973 if (m_bRgbByteOrder) {
974 m_Red = ((FX_LPBYTE)&m_Color)[0];
975 m_Blue = ((FX_LPBYTE)&m_Color)[2];
976 m_Color = FXARGB_TODIB(m_Color);
977 m_Color = FXARGB_TOBGRORDERDIB(m_Color);
978 }
979 } else {
980 if (bObjectCMYK) {
981 FX_BYTE r, g, b;
982 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(c olor), FXSYS_GetYValue(color), FXSYS_GetKValue(color),
983 r, g, b);
984 m_Color = FXARGB_MAKE(m_Alpha, r, g, b);
985 if (m_bRgbByteOrder) {
986 m_Color = FXARGB_TOBGRORDERDIB(m_Color);
987 m_Red = b;
988 m_Green = g;
989 m_Blue = r;
990 } else {
991 m_Color = FXARGB_TODIB(m_Color);
992 m_Red = r;
993 m_Green = g;
994 m_Blue = b;
995 }
996 } else {
997 if (m_bRgbByteOrder) {
998 m_Color = FXARGB_TOBGRORDERDIB(color);
999 ArgbDecode(color, m_Alpha, m_Blue, m_Green, m_Red);
1000 } else {
1001 m_Color = FXARGB_TODIB(color);
1002 ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue);
1003 }
1004 }
1005 }
1006 }
1007 }
1008 m_ProcessFilter = (m_pOriDevice ? 1 : 0)
1009 + (m_pDevice->GetBPP() >= 8 ? 2 : 0)
1010 + (m_pClipMask ? 4 : 0)
1011 + (m_pDevice->m_pAlphaMask ? 8 : 0);
1012 switch(m_ProcessFilter) {
1013 case 0:
1014 composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_0;
1015 break;
1016 case 2: {
1017 if (m_pDevice->GetBPP() == 8) {
1018 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_2;
1019 } else if (m_pDevice->GetBPP() == 24) {
1020 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_2;
1021 } else {
1022 composite_span = m_pDevice->HasAlpha() ? &CFX_SkiaRenderer:: CompositeSpanARGB_2 : &CFX_SkiaRenderer::CompositeSpanRGB32_2;
1023 }
1024 }
1025 break;
1026 case 3: {
1027 if (m_pDevice->GetBPP() == 8) {
1028 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_3;
1029 } else if (m_pDevice->GetBPP() == 24) {
1030 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_3;
1031 } else {
1032 composite_span = m_pDevice->HasAlpha() ? &CFX_SkiaRenderer:: CompositeSpanARGB_3 : &CFX_SkiaRenderer::CompositeSpanRGB32_3;
1033 }
1034 }
1035 break;
1036 case 4:
1037 composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_4;
1038 break;
1039 case 6: {
1040 if (m_pDevice->GetBPP() == 8) {
1041 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_6;
1042 } else if (m_pDevice->GetBPP() == 24) {
1043 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_6;
1044 } else {
1045 composite_span = m_pDevice->HasAlpha() ? &CFX_SkiaRenderer:: CompositeSpanARGB_6 : &CFX_SkiaRenderer::CompositeSpanRGB32_6;
1046 }
1047 }
1048 break;
1049 case 7: {
1050 if (m_pDevice->GetBPP() == 8) {
1051 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_7;
1052 } else if (m_pDevice->GetBPP() == 24) {
1053 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_7;
1054 } else {
1055 composite_span = m_pDevice->HasAlpha() ? &CFX_SkiaRenderer:: CompositeSpanARGB_7 : &CFX_SkiaRenderer::CompositeSpanRGB32_7;
1056 }
1057 }
1058 break;
1059 case 1:
1060 case 5:
1061 case 8:
1062 case 9:
1063 case 11:
1064 case 12:
1065 case 13:
1066 case 15:
1067 break;
1068 case 10:
1069 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10;
1070 break;
1071 case 14:
1072 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14;
1073 break;
1074 }
1075 if (composite_span == NULL) {
1076 return FALSE;
1077 }
1078 return TRUE;
1079 }
1080
1081 void CFX_SkiaA8Renderer::blitAntiH(int x, int y, const SkAlpha antialias[], cons t int16_t runs[])
1082 {
1083 FXSYS_assert(m_pDevice);
1084 int dst_y = y - m_Top;
1085 if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) {
1086 return;
1087 }
1088 FX_LPBYTE dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y ;
1089 FX_LPBYTE dest_pos = dest_scan;
1090 while (1) {
1091 if (x >= m_dstWidth) {
1092 return;
1093 }
1094 int width = runs[0];
1095 SkASSERT(width >= 0);
1096 if (width <= 0) {
1097 return;
1098 }
1099 unsigned aa = antialias[0];
1100 if (aa) {
1101 int col_start = x < m_Left ? 0 : x - m_Left;
1102 int col_end = x + width;
1103 col_end = col_end < m_dstWidth ? col_end - m_Left : m_pDevice->GetWi dth();
1104 int result = col_end - col_start;
1105 if (result > 0) {
1106 dest_pos = dest_scan + col_start;
1107 FXSYS_memset(dest_pos, aa, result);
1108 }
1109 }
1110 runs += width;
1111 antialias += width;
1112 x += width;
1113 }
1114 }
1115 void CFX_SkiaA8Renderer::blitH(int x, int y, int width)
1116 {
1117 FXSYS_assert(m_pDevice);
1118 int dst_y = y - m_Top;
1119 if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) {
1120 return;
1121 }
1122 if (x >= m_dstWidth) {
1123 return;
1124 }
1125 FX_LPBYTE dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y ;
1126 int col_start = x < m_Left ? 0 : x - m_Left;
1127 int col_end = x + width;
1128 col_end = col_end < m_dstWidth ? col_end - m_Left : m_pDevice->GetWidth();
1129 int result = col_end - col_start;
1130 if (result > 0) {
1131 FX_BYTE* dest_pos = dest_scan + col_start;
1132 FXSYS_memset(dest_pos, 255, result);
1133 }
1134 }
1135 void CFX_SkiaA8Renderer::blitV(int x, int y, int height, SkAlpha alpha)
1136 {
1137 FXSYS_assert(alpha);
1138 if (alpha == 255) {
1139 this->blitRect(x, y, 1, height);
1140 } else {
1141 int16_t runs[2];
1142 runs[0] = 1;
1143 runs[1] = 0;
1144 while (--height >= 0) {
1145 if (y >= m_dstHeight) {
1146 return;
1147 }
1148 this->blitAntiH(x, y ++, &alpha, runs);
1149 }
1150 }
1151 }
1152 void CFX_SkiaA8Renderer::blitRect(int x, int y, int width, int height)
1153 {
1154 FXSYS_assert(m_pDevice);
1155 while (--height >= 0) {
1156 if (y >= m_dstHeight) {
1157 return;
1158 }
1159 blitH(x , y ++, width);
1160 }
1161 }
1162 void CFX_SkiaA8Renderer::blitAntiRect(int x, int y, int width, int height,
1163 SkAlpha leftAlpha, SkAlpha rightAlpha)
1164 {
1165 blitV(x++, y, height, leftAlpha);
1166 if (width > 0) {
1167 blitRect(x, y, width, height);
1168 x += width;
1169 }
1170 blitV(x, y, height, rightAlpha);
1171 }
1172 FX_BOOL CFX_SkiaA8Renderer::Init(CFX_DIBitmap* pDevice, int Left, int Top)
1173 {
1174 m_pDevice = pDevice;
1175 m_Left = Left;
1176 m_Top = Top;
1177 if (pDevice) {
1178 m_dstWidth = m_Left + pDevice->GetWidth();
1179 m_dstHeight = m_Top + pDevice->GetHeight();
1180 }
1181 return TRUE;
1182 }
OLDNEW
« no previous file with comments | « core/src/fxge/skia/fx_skia_blitter.h ('k') | core/src/fxge/skia/fx_skia_blitter_new.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698