OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "../../../include/fxge/fx_ge.h" | 5 #include "../../../include/fxge/fx_ge.h" |
6 //#define _SKIA_SUPPORT_ | 6 //#define _SKIA_SUPPORT_ |
7 #if defined(_SKIA_SUPPORT_) | 7 #if defined(_SKIA_SUPPORT_) |
8 #include "../../../include/fxcodec/fx_codec.h" | 8 #include "../../../include/fxcodec/fx_codec.h" |
9 #include "SkBlitter.h" | 9 #include "SkBlitter.h" |
10 #include "fx_skia_blitter_new.h" | 10 #include "fx_skia_blitter_new.h" |
11 // We use our own renderer here to make it simple | 11 // We use our own renderer here to make it simple |
12 void CFX_SkiaRenderer::blitAntiH(int x, int y, const SkAlpha antialias[], co
nst int16_t runs[]) | 12 void CFX_SkiaRenderer::blitAntiH(int x, |
13 { | 13 int y, |
14 FXSYS_assert(m_Alpha); | 14 const SkAlpha antialias[], |
15 if (m_pOriDevice == NULL && composite_span == NULL) return; | 15 const int16_t runs[]) { |
16 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return; | 16 FXSYS_assert(m_Alpha); |
17 while (1) | 17 if (m_pOriDevice == NULL && composite_span == NULL) |
18 { | 18 return; |
19 int width = runs[0]; | 19 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) |
20 SkASSERT(width >= 0); | 20 return; |
21 if (width <= 0) | 21 while (1) { |
22 return; | 22 int width = runs[0]; |
23 unsigned aa = antialias[0]; | 23 SkASSERT(width >= 0); |
24 if (aa) | 24 if (width <= 0) |
25 (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, aa, m
_ClipBox.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaSca
n); | 25 return; |
26 runs += width; | 26 unsigned aa = antialias[0]; |
27 antialias += width; | 27 if (aa) |
28 x += width; | 28 (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, aa, |
29 } | 29 m_ClipBox.top, m_ClipBox.left, m_ClipBox.right, |
30 } | 30 m_pClipScan, m_pDestExtraAlphaScan); |
31 | 31 runs += width; |
32 void CFX_SkiaRenderer::blitH(int x, int y, int width) | 32 antialias += width; |
33 { | 33 x += width; |
34 FXSYS_assert(m_Alpha && width); | 34 } |
35 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) return; | 35 } |
36 (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, 255, m_ClipBo
x.top, m_ClipBox.left, m_ClipBox.right, m_pClipScan, m_pDestExtraAlphaScan); | 36 |
37 } | 37 void CFX_SkiaRenderer::blitH(int x, int y, int width) { |
38 | 38 FXSYS_assert(m_Alpha && width); |
39 void CFX_SkiaRenderer::blitV(int x, int y, int height, SkAlpha alpha) | 39 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) |
40 { | 40 return; |
41 FXSYS_assert(m_Alpha && alpha); | 41 (*composite_span)(m_pDestScan, m_pOriScan, 0, x, width, y, 255, m_ClipBox.top, |
42 if (alpha == 255) { | 42 m_ClipBox.left, m_ClipBox.right, m_pClipScan, |
43 blitRect(x, y, 1, height); | 43 m_pDestExtraAlphaScan); |
44 } else { | 44 } |
45 int16_t runs[2]; | 45 |
46 runs[0] = 1; | 46 void CFX_SkiaRenderer::blitV(int x, int y, int height, SkAlpha alpha) { |
47 runs[1] = 0; | 47 FXSYS_assert(m_Alpha && alpha); |
48 while (--height >= 0) { | 48 if (alpha == 255) { |
49 if (y >= m_ClipBox.bottom) | 49 blitRect(x, y, 1, height); |
50 return; | 50 } else { |
51 blitAntiH(x, y ++, &alpha, runs); | 51 int16_t runs[2]; |
52 } | 52 runs[0] = 1; |
53 } | 53 runs[1] = 0; |
54 } | 54 while (--height >= 0) { |
55 void CFX_SkiaRenderer::blitRect(int x, int y, int width, int height) | 55 if (y >= m_ClipBox.bottom) |
56 { | 56 return; |
57 FXSYS_assert(m_Alpha && width); | 57 blitAntiH(x, y++, &alpha, runs); |
58 while (--height >= 0){ | 58 } |
59 if (y >= m_ClipBox.bottom) | 59 } |
60 return; | 60 } |
61 blitH(x, y ++, width); | 61 void CFX_SkiaRenderer::blitRect(int x, int y, int width, int height) { |
62 } | 62 FXSYS_assert(m_Alpha && width); |
63 } | 63 while (--height >= 0) { |
64 | 64 if (y >= m_ClipBox.bottom) |
65 void CFX_SkiaRenderer::blitAntiRect(int x, int y, int width, int height, | 65 return; |
66 SkAlpha leftAlpha, SkAlpha rightAlpha) | 66 blitH(x, y++, width); |
67 { | 67 } |
68 blitV(x++, y, height, leftAlpha); | 68 } |
69 if (width > 0) { | 69 |
70 blitRect(x, y, width, height); | 70 void CFX_SkiaRenderer::blitAntiRect(int x, |
71 x += width; | 71 int y, |
72 } | 72 int width, |
73 blitV(x, y, height, rightAlpha); | 73 int height, |
74 } | 74 SkAlpha leftAlpha, |
75 /*--------------------------------------------------------------------------
-------------------------*/ | 75 SkAlpha rightAlpha) { |
76 void CFX_SkiaRenderer::CompositeSpan1bpp_0(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | 76 blitV(x++, y, height, leftAlpha); |
77 int span_left, int span_len, int span_top, uint8_t cover_scan, | 77 if (width > 0) { |
78 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 78 blitRect(x, y, width, height); |
79 uint8_t* dest_extra_alpha_scan) | 79 x += width; |
80 { | 80 } |
81 ASSERT(!m_bRgbByteOrder); | 81 blitV(x, y, height, rightAlpha); |
82 ASSERT(!m_pDevice->IsCmykImage()); | 82 } |
83 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8; | 83 /*------------------------------------------------------------------------------
---------------------*/ |
84 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 84 void CFX_SkiaRenderer::CompositeSpan1bpp_0(uint8_t* dest_scan, |
85 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 85 uint8_t* ori_scan, |
86 if (col_end < col_start) return; // do nothing. | 86 int Bpp, |
87 dest_scan += col_start/8; | 87 int span_left, |
88 | 88 int span_len, |
89 int index = 0; | 89 int span_top, |
90 if (m_pDevice->GetPalette() == NULL) | 90 uint8_t cover_scan, |
91 index = ((uint8_t)m_Color == 0xff) ? 1 : 0; | 91 int clip_top, |
92 else { | 92 int clip_left, |
93 for (int i = 0; i < 2; i ++) | 93 int clip_right, |
94 if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) | 94 uint8_t* clip_scan, |
95 index = i; | 95 uint8_t* dest_extra_alpha_scan) { |
96 } | 96 ASSERT(!m_bRgbByteOrder); |
97 uint8_t* dest_scan1 = dest_scan; | 97 ASSERT(!m_pDevice->IsCmykImage()); |
98 int src_alpha = m_Alpha * cover_scan / 255; | 98 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left / 8; |
99 for (int col = col_start; col < col_end; col ++) { | 99 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
100 if (src_alpha) { | 100 int col_end = |
101 if (!index) | 101 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
102 *dest_scan1 &= ~(1 << (7 - (col+span_left)%8)); | 102 if (col_end < col_start) |
103 else | 103 return; // do nothing. |
104 *dest_scan1|= 1 << (7 - (col+span_left)%8); | 104 dest_scan += col_start / 8; |
105 } | 105 |
106 dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8; | 106 int index = 0; |
107 } | 107 if (m_pDevice->GetPalette() == NULL) |
108 } | 108 index = ((uint8_t)m_Color == 0xff) ? 1 : 0; |
109 void CFX_SkiaRenderer::CompositeSpan1bpp_4(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | 109 else { |
110 int span_left, int span_len, int span_top, uint8_t cover_scan, | 110 for (int i = 0; i < 2; i++) |
111 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 111 if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) |
112 uint8_t* dest_extra_alpha_scan) | 112 index = i; |
113 { | 113 } |
114 ASSERT(!m_bRgbByteOrder); | 114 uint8_t* dest_scan1 = dest_scan; |
115 ASSERT(!m_pDevice->IsCmykImage()); | 115 int src_alpha = m_Alpha * cover_scan / 255; |
116 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left/8; | 116 for (int col = col_start; col < col_end; col++) { |
117 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | 117 if (src_alpha) { |
118 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 118 if (!index) |
119 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 119 *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); |
120 if (col_end < col_start) return; // do nothing. | 120 else |
121 dest_scan += col_start/8; | 121 *dest_scan1 |= 1 << (7 - (col + span_left) % 8); |
122 | 122 } |
123 int index = 0; | 123 dest_scan1 = dest_scan + (span_left % 8 + col - col_start + 1) / 8; |
124 if (m_pDevice->GetPalette() == NULL) | 124 } |
125 index = ((uint8_t)m_Color == 0xff) ? 1 : 0; | 125 } |
126 else { | 126 void CFX_SkiaRenderer::CompositeSpan1bpp_4(uint8_t* dest_scan, |
127 for (int i = 0; i < 2; i ++) | 127 uint8_t* ori_scan, |
128 if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) | 128 int Bpp, |
129 index = i; | 129 int span_left, |
130 } | 130 int span_len, |
131 uint8_t* dest_scan1 = dest_scan; | 131 int span_top, |
132 int src_alpha = m_Alpha * cover_scan / 255; | 132 uint8_t cover_scan, |
133 for (int col = col_start; col < col_end; col ++) { | 133 int clip_top, |
134 int src_alpha1 = src_alpha * clip_scan[col] / 255; | 134 int clip_left, |
135 if (src_alpha1) { | 135 int clip_right, |
136 if (!index) | 136 uint8_t* clip_scan, |
137 *dest_scan1 &= ~(1 << (7 - (col+span_left)%8)); | 137 uint8_t* dest_extra_alpha_scan) { |
138 else | 138 ASSERT(!m_bRgbByteOrder); |
139 *dest_scan1|= 1 << (7 - (col+span_left)%8); | 139 ASSERT(!m_pDevice->IsCmykImage()); |
140 } | 140 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left / 8; |
141 dest_scan1 = dest_scan+(span_left%8+col-col_start+1)/8; | 141 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
142 } | 142 clip_left + span_left; |
143 } | 143 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
144 /*--------------------------------------------------------------------------
---------------------------*/ | 144 int col_end = |
145 void CFX_SkiaRenderer::CompositeSpanGray_2(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | 145 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
146 int span_left, int span_len, int span_top, uint8_t cover_scan, | 146 if (col_end < col_start) |
147 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 147 return; // do nothing. |
148 uint8_t* dest_extra_alpha_scan) | 148 dest_scan += col_start / 8; |
149 { | 149 |
150 ASSERT(!m_pDevice->IsCmykImage()); | 150 int index = 0; |
151 ASSERT(!m_bRgbByteOrder); | 151 if (m_pDevice->GetPalette() == NULL) |
152 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; | 152 index = ((uint8_t)m_Color == 0xff) ? 1 : 0; |
153 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 153 else { |
154 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 154 for (int i = 0; i < 2; i++) |
155 if (col_end < col_start) return; // do nothing. | 155 if (FXARGB_TODIB(m_pDevice->GetPalette()[i]) == m_Color) |
156 dest_scan += col_start; | 156 index = i; |
157 if (cover_scan == 255 && m_Alpha == 255) { | 157 } |
158 FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray),
col_end - col_start); | 158 uint8_t* dest_scan1 = dest_scan; |
159 return; | 159 int src_alpha = m_Alpha * cover_scan / 255; |
160 } | 160 for (int col = col_start; col < col_end; col++) { |
161 int src_alpha = m_Alpha * cover_scan / 255; | 161 int src_alpha1 = src_alpha * clip_scan[col] / 255; |
162 for (int col = col_start; col < col_end; col ++) { | 162 if (src_alpha1) { |
163 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); | 163 if (!index) |
164 dest_scan++; | 164 *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); |
165 } | 165 else |
166 } | 166 *dest_scan1 |= 1 << (7 - (col + span_left) % 8); |
167 void CFX_SkiaRenderer::CompositeSpanGray_3(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | 167 } |
168 int span_left, int span_len, int span_top, uint8_t cover_scan, | 168 dest_scan1 = dest_scan + (span_left % 8 + col - col_start + 1) / 8; |
169 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 169 } |
170 uint8_t* dest_extra_alpha_scan) | 170 } |
171 { | 171 /*------------------------------------------------------------------------------
-----------------------*/ |
172 ASSERT(!m_pDevice->IsCmykImage()); | 172 void CFX_SkiaRenderer::CompositeSpanGray_2(uint8_t* dest_scan, |
173 ASSERT(!m_bRgbByteOrder); | 173 uint8_t* ori_scan, |
174 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; | 174 int Bpp, |
175 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left; | 175 int span_left, |
176 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 176 int span_len, |
177 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 177 int span_top, |
178 if (col_end < col_start) return; // do nothing. | 178 uint8_t cover_scan, |
179 dest_scan += col_start; | 179 int clip_top, |
180 ori_scan += col_start; | 180 int clip_left, |
181 if (m_Alpha == 255 && cover_scan == 255) { | 181 int clip_right, |
182 FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray),
col_end - col_start); | 182 uint8_t* clip_scan, |
183 } else { | 183 uint8_t* dest_extra_alpha_scan) { |
184 int src_alpha = m_Alpha; | 184 ASSERT(!m_pDevice->IsCmykImage()); |
| 185 ASSERT(!m_bRgbByteOrder); |
| 186 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; |
| 187 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 188 int col_end = |
| 189 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 190 if (col_end < col_start) |
| 191 return; // do nothing. |
| 192 dest_scan += col_start; |
| 193 if (cover_scan == 255 && m_Alpha == 255) { |
| 194 FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), |
| 195 col_end - col_start); |
| 196 return; |
| 197 } |
| 198 int src_alpha = m_Alpha * cover_scan / 255; |
| 199 for (int col = col_start; col < col_end; col++) { |
| 200 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); |
| 201 dest_scan++; |
| 202 } |
| 203 } |
| 204 void CFX_SkiaRenderer::CompositeSpanGray_3(uint8_t* dest_scan, |
| 205 uint8_t* ori_scan, |
| 206 int Bpp, |
| 207 int span_left, |
| 208 int span_len, |
| 209 int span_top, |
| 210 uint8_t cover_scan, |
| 211 int clip_top, |
| 212 int clip_left, |
| 213 int clip_right, |
| 214 uint8_t* clip_scan, |
| 215 uint8_t* dest_extra_alpha_scan) { |
| 216 ASSERT(!m_pDevice->IsCmykImage()); |
| 217 ASSERT(!m_bRgbByteOrder); |
| 218 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; |
| 219 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left; |
| 220 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 221 int col_end = |
| 222 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 223 if (col_end < col_start) |
| 224 return; // do nothing. |
| 225 dest_scan += col_start; |
| 226 ori_scan += col_start; |
| 227 if (m_Alpha == 255 && cover_scan == 255) { |
| 228 FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), |
| 229 col_end - col_start); |
| 230 } else { |
| 231 int src_alpha = m_Alpha; |
185 #if 1 | 232 #if 1 |
186 for (int col = col_start; col < col_end; col ++) { | 233 for (int col = col_start; col < col_end; col++) { |
187 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); | 234 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); |
188 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); | 235 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); |
189 dest_scan ++; | 236 dest_scan++; |
190 } | 237 } |
191 #else | 238 #else |
192 if (m_bFullCover) { | 239 if (m_bFullCover) { |
193 if (src_alpha == 255) { | 240 if (src_alpha == 255) { |
194 FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray,
m_Gray), col_end - col_start); | 241 FXSYS_memset(dest_scan, FXARGB_MAKE(m_Gray, m_Gray, m_Gray, m_Gray), |
195 return; | 242 col_end - col_start); |
196 } | 243 return; |
197 for (int col = col_start; col < col_end; col ++) | 244 } |
198 *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alph
a); | 245 for (int col = col_start; col < col_end; col++) |
199 } else { | 246 *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); |
200 for (int col = col_start; col < col_end; col ++) { | 247 } else { |
201 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha)
; | 248 for (int col = col_start; col < col_end; col++) { |
202 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan)
; | 249 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); |
203 dest_scan++; | 250 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); |
204 } | 251 dest_scan++; |
205 } | 252 } |
| 253 } |
206 #endif | 254 #endif |
207 } | 255 } |
208 } | 256 } |
209 | 257 |
210 void CFX_SkiaRenderer::CompositeSpanGray_6(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | 258 void CFX_SkiaRenderer::CompositeSpanGray_6(uint8_t* dest_scan, |
211 int span_left, int span_len, int span_top, uint8_t cover_scan, | 259 uint8_t* ori_scan, |
212 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 260 int Bpp, |
213 uint8_t* dest_extra_alpha_scan) | 261 int span_left, |
214 { | 262 int span_len, |
215 ASSERT(!m_bRgbByteOrder); | 263 int span_top, |
216 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; | 264 uint8_t cover_scan, |
217 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | 265 int clip_top, |
218 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 266 int clip_left, |
219 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 267 int clip_right, |
220 if (col_end < col_start) return; // do nothing. | 268 uint8_t* clip_scan, |
221 dest_scan += col_start; | 269 uint8_t* dest_extra_alpha_scan) { |
222 int src_alpha = m_Alpha * cover_scan / 255; | 270 ASSERT(!m_bRgbByteOrder); |
223 for (int col = col_start; col < col_end; col ++) { | 271 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; |
224 int src_alpha1 = src_alpha * clip_scan[col] / 255; | 272 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
225 if (!src_alpha1) { | 273 clip_left + span_left; |
226 dest_scan ++; | 274 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
227 continue; | 275 int col_end = |
228 } | 276 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
229 if (src_alpha1 == 255) | 277 if (col_end < col_start) |
230 *dest_scan++ = m_Gray; | 278 return; // do nothing. |
231 else { | 279 dest_scan += col_start; |
232 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha1); | 280 int src_alpha = m_Alpha * cover_scan / 255; |
233 dest_scan ++; | 281 for (int col = col_start; col < col_end; col++) { |
234 } | 282 int src_alpha1 = src_alpha * clip_scan[col] / 255; |
235 } | 283 if (!src_alpha1) { |
236 } | 284 dest_scan++; |
237 | 285 continue; |
238 void CFX_SkiaRenderer::CompositeSpanGray_7(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | 286 } |
239 int span_left, int span_len, int span_top, uint8_t cover_scan, | 287 if (src_alpha1 == 255) |
240 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 288 *dest_scan++ = m_Gray; |
241 uint8_t* dest_extra_alpha_scan) | 289 else { |
242 { | 290 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha1); |
243 ASSERT(!m_pDevice->IsCmykImage()); | 291 dest_scan++; |
244 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; | 292 } |
245 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left; | 293 } |
246 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | 294 } |
247 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 295 |
248 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 296 void CFX_SkiaRenderer::CompositeSpanGray_7(uint8_t* dest_scan, |
249 if (col_end < col_start) return; // do nothing. | 297 uint8_t* ori_scan, |
250 dest_scan += col_start; | 298 int Bpp, |
251 ori_scan += col_start; | 299 int span_left, |
| 300 int span_len, |
| 301 int span_top, |
| 302 uint8_t cover_scan, |
| 303 int clip_top, |
| 304 int clip_left, |
| 305 int clip_right, |
| 306 uint8_t* clip_scan, |
| 307 uint8_t* dest_extra_alpha_scan) { |
| 308 ASSERT(!m_pDevice->IsCmykImage()); |
| 309 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left; |
| 310 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left; |
| 311 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
| 312 clip_left + span_left; |
| 313 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 314 int col_end = |
| 315 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 316 if (col_end < col_start) |
| 317 return; // do nothing. |
| 318 dest_scan += col_start; |
| 319 ori_scan += col_start; |
252 #if 1 | 320 #if 1 |
253 for (int col = col_start; col < col_end; col ++) { | 321 for (int col = col_start; col < col_end; col++) { |
254 int src_alpha = m_Alpha * clip_scan[col] / 255; | 322 int src_alpha = m_Alpha * clip_scan[col] / 255; |
255 if (src_alpha == 255 && cover_scan == 255) { | 323 if (src_alpha == 255 && cover_scan == 255) { |
256 *dest_scan++ = m_Gray; | 324 *dest_scan++ = m_Gray; |
257 ori_scan++; | 325 ori_scan++; |
258 continue; | 326 continue; |
259 } | 327 } |
260 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); | 328 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); |
261 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); | 329 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); |
262 dest_scan++; | 330 dest_scan++; |
263 } | 331 } |
264 | 332 |
265 #else | 333 #else |
266 if (m_bFullCover) { | 334 if (m_bFullCover) { |
267 for (int col = col_start; col < col_end; col ++) { | 335 for (int col = col_start; col < col_end; col++) { |
268 int src_alpha = m_Alpha * clip_scan[col] / 255; | 336 int src_alpha = m_Alpha * clip_scan[col] / 255; |
269 if (!src_alpha) { | 337 if (!src_alpha) { |
270 dest_scan++; | 338 dest_scan++; |
271 ori_scan++; | 339 ori_scan++; |
272 continue; | 340 continue; |
273 } | 341 } |
274 if (src_alpha == 255){ | 342 if (src_alpha == 255) { |
275 *dest_scan++ = m_Gray; | 343 *dest_scan++ = m_Gray; |
276 ori_scan++; | 344 ori_scan++; |
277 continue; | 345 continue; |
278 } | 346 } |
279 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha)
; | 347 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); |
280 } | 348 } |
281 } else { | 349 } else { |
282 for (int col = col_start; col < col_end; col ++) { | 350 for (int col = col_start; col < col_end; col++) { |
283 int src_alpha = m_Alpha * clip_scan[col] / 255; | 351 int src_alpha = m_Alpha * clip_scan[col] / 255; |
284 if (src_alpha == 255 && cover_scan == 255) { | 352 if (src_alpha == 255 && cover_scan == 255) { |
285 *dest_scan++ = m_Gray; | 353 *dest_scan++ = m_Gray; |
286 ori_scan++; | 354 ori_scan++; |
287 continue; | 355 continue; |
288 } | 356 } |
289 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); | 357 int gray = FXDIB_ALPHA_MERGE(*ori_scan++, m_Gray, src_alpha); |
290 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); | 358 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, gray, cover_scan); |
291 dest_scan++; | 359 dest_scan++; |
292 } | 360 } |
293 } | 361 } |
294 #endif | 362 #endif |
295 } | 363 } |
296 /*--------------------------------------------------------------------------
------------------------*/ | 364 /*------------------------------------------------------------------------------
--------------------*/ |
297 | 365 |
298 void CFX_SkiaRenderer::CompositeSpanARGB_2(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | 366 void CFX_SkiaRenderer::CompositeSpanARGB_2(uint8_t* dest_scan, |
299 int span_left, int span_len, int span_top, uint8_t cover_scan, | 367 uint8_t* ori_scan, |
300 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 368 int Bpp, |
301 uint8_t* dest_extra_alpha_scan) | 369 int span_left, |
302 { | 370 int span_len, |
303 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); | 371 int span_top, |
304 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 372 uint8_t cover_scan, |
305 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 373 int clip_top, |
306 if (col_end < col_start) return; // do nothing. | 374 int clip_left, |
307 dest_scan += col_start<<2; | 375 int clip_right, |
308 if (m_Alpha == 255 && cover_scan == 255) { | 376 uint8_t* clip_scan, |
309 FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); | 377 uint8_t* dest_extra_alpha_scan) { |
310 return; | 378 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2); |
311 } | 379 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
312 int src_alpha; | 380 int col_end = |
| 381 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 382 if (col_end < col_start) |
| 383 return; // do nothing. |
| 384 dest_scan += col_start << 2; |
| 385 if (m_Alpha == 255 && cover_scan == 255) { |
| 386 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); |
| 387 return; |
| 388 } |
| 389 int src_alpha; |
313 #if 0 | 390 #if 0 |
314 if (m_bFullCover) { | 391 if (m_bFullCover) { |
315 if (m_Alpha == 255) { | 392 if (m_Alpha == 255) { |
316 FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); | 393 FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); |
317 return; | 394 return; |
318 } | 395 } |
319 } | 396 } |
320 else | 397 else |
321 #endif | 398 #endif |
322 src_alpha = m_Alpha * cover_scan / 255; | 399 src_alpha = m_Alpha * cover_scan / 255; |
323 for (int col = col_start; col < col_end; col ++) { | 400 for (int col = col_start; col < col_end; col++) { |
324 // Dest format: Argb | 401 // Dest format: Argb |
325 // calculate destination alpha (it's union of source and dest alpha) | 402 // calculate destination alpha (it's union of source and dest alpha) |
326 if (dest_scan[3] == 0) { | 403 if (dest_scan[3] == 0) { |
327 dest_scan[3] = src_alpha; | 404 dest_scan[3] = src_alpha; |
328 *dest_scan++ = m_Blue; | 405 *dest_scan++ = m_Blue; |
329 *dest_scan++ = m_Green; | 406 *dest_scan++ = m_Green; |
330 *dest_scan = m_Red; | 407 *dest_scan = m_Red; |
331 dest_scan += 2; | 408 dest_scan += 2; |
332 continue; | 409 continue; |
333 } | 410 } |
334 uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3] * src_a
lpha / 255; | 411 uint8_t dest_alpha = |
335 dest_scan[3] = dest_alpha; | 412 dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255; |
336 int alpha_ratio = src_alpha*255/dest_alpha; | 413 dest_scan[3] = dest_alpha; |
337 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); | 414 int alpha_ratio = src_alpha * 255 / dest_alpha; |
338 dest_scan ++; | 415 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
339 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); | 416 dest_scan++; |
340 dest_scan ++; | 417 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
341 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); | 418 dest_scan++; |
342 dest_scan += 2; | 419 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 420 dest_scan += 2; |
| 421 } |
| 422 } |
| 423 |
| 424 void CFX_SkiaRenderer::CompositeSpanARGB_3(uint8_t* dest_scan, |
| 425 uint8_t* ori_scan, |
| 426 int Bpp, |
| 427 int span_left, |
| 428 int span_len, |
| 429 int span_top, |
| 430 uint8_t cover_scan, |
| 431 int clip_top, |
| 432 int clip_left, |
| 433 int clip_right, |
| 434 uint8_t* clip_scan, |
| 435 uint8_t* dest_extra_alpha_scan) { |
| 436 ASSERT(!m_pDevice->IsCmykImage()); |
| 437 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2); |
| 438 // ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); |
| 439 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 440 int col_end = |
| 441 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 442 if (col_end < col_start) |
| 443 return; // do nothing. |
| 444 dest_scan += col_start << 2; |
| 445 // ori_scan += col_start << 2; |
| 446 |
| 447 if (m_Alpha == 255 && cover_scan == 255) { |
| 448 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); |
| 449 return; |
| 450 } |
| 451 if (cover_scan == 255) { |
| 452 int dst_color = (0x00ffffff & m_Color) | (m_Alpha << 24); |
| 453 FXSYS_memset(dest_scan, dst_color, (col_end - col_start) << 2); |
| 454 return; |
| 455 } |
| 456 // Do not need origin bitmap, because of merge in pure transparent background |
| 457 int src_alpha_covered = m_Alpha * cover_scan / 255; |
| 458 for (int col = col_start; col < col_end; col++) { |
| 459 // shortcut |
| 460 if (dest_scan[3] == 0) { |
| 461 dest_scan[3] = src_alpha_covered; |
| 462 *dest_scan++ = m_Blue; |
| 463 *dest_scan++ = m_Green; |
| 464 *dest_scan = m_Red; |
| 465 dest_scan += 2; |
| 466 continue; |
| 467 } |
| 468 // We should do alpha transition and color transition |
| 469 // alpha fg color fg |
| 470 // alpha bg color bg |
| 471 // alpha cover color cover |
| 472 dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], m_Alpha, cover_scan); |
| 473 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan); |
| 474 dest_scan++; |
| 475 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan); |
| 476 dest_scan++; |
| 477 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan); |
| 478 dest_scan += 2; |
| 479 } |
| 480 } |
| 481 void CFX_SkiaRenderer::CompositeSpanARGB_6(uint8_t* dest_scan, |
| 482 uint8_t* ori_scan, |
| 483 int Bpp, |
| 484 int span_left, |
| 485 int span_len, |
| 486 int span_top, |
| 487 uint8_t cover_scan, |
| 488 int clip_top, |
| 489 int clip_left, |
| 490 int clip_right, |
| 491 uint8_t* clip_scan, |
| 492 uint8_t* dest_extra_alpha_scan) { |
| 493 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2); |
| 494 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
| 495 clip_left + span_left; |
| 496 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 497 int col_end = |
| 498 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 499 if (col_end < col_start) |
| 500 return; // do nothing. |
| 501 dest_scan += col_start << 2; |
| 502 #if 1 |
| 503 int src_alpha = m_Alpha * cover_scan / 255; |
| 504 for (int col = col_start; col < col_end; col++) { |
| 505 int src_alpha1 = src_alpha * clip_scan[col] / 255; |
| 506 if (!src_alpha1) { |
| 507 dest_scan += 4; |
| 508 continue; |
| 509 } |
| 510 if (src_alpha1 == 255) { |
| 511 *(FX_DWORD*)dest_scan = m_Color; |
| 512 dest_scan += 4; |
| 513 } else { |
| 514 // Dest format: Argb |
| 515 // calculate destination alpha (it's union of source and dest alpha) |
| 516 if (dest_scan[3] == 0) { |
| 517 dest_scan[3] = src_alpha1; |
| 518 *dest_scan++ = m_Blue; |
| 519 *dest_scan++ = m_Green; |
| 520 *dest_scan = m_Red; |
| 521 dest_scan += 2; |
| 522 continue; |
| 523 } |
| 524 uint8_t dest_alpha = |
| 525 dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255; |
| 526 dest_scan[3] = dest_alpha; |
| 527 int alpha_ratio = src_alpha1 * 255 / dest_alpha; |
| 528 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 529 dest_scan++; |
| 530 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 531 dest_scan++; |
| 532 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 533 dest_scan += 2; |
| 534 } |
| 535 } |
| 536 #else |
| 537 if (m_bFullCover) { |
| 538 for (int col = col_start; col < col_end; col++) { |
| 539 int src_alpha = m_Alpha * clip_scan[col] / 255; |
| 540 if (!src_alpha) { |
| 541 dest_scan += 4; |
| 542 continue; |
| 543 } |
| 544 if (src_alpha == 255) { |
| 545 *(FX_DWORD*)dest_scan = m_Color; |
| 546 dest_scan += 4; |
| 547 continue; |
| 548 } else { |
| 549 // Dest format: Argb |
| 550 // calculate destination alpha (it's union of source and dest alpha) |
| 551 if (dest_scan[3] == 0) { |
| 552 dest_scan[3] = src_alpha; |
| 553 *dest_scan++ = m_Blue; |
| 554 *dest_scan++ = m_Green; |
| 555 *dest_scan = m_Red; |
| 556 dest_scan += 2; |
| 557 continue; |
343 } | 558 } |
344 } | 559 uint8_t dest_alpha = |
| 560 dest_scan[3] + src_alpha - dest_scan[3] * src_alpha / 255; |
| 561 dest_scan[3] = dest_alpha; |
| 562 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 563 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 564 dest_scan++; |
| 565 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 566 dest_scan++; |
| 567 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 568 dest_scan += 2; |
| 569 } |
| 570 } |
| 571 } else { |
| 572 int src_alpha = m_Alpha * cover_scan / 255; |
| 573 for (int col = col_start; col < col_end; col++) { |
| 574 int src_alpha1 = src_alpha * clip_scan[col] / 255; |
| 575 if (!src_alpha1) { |
| 576 dest_scan += 4; |
| 577 continue; |
| 578 } |
| 579 if (src_alpha1 == 255) { |
| 580 *(FX_DWORD*)dest_scan = m_Color; |
| 581 dest_scan += 4; |
| 582 } else { |
| 583 // Dest format: Argb |
| 584 // calculate destination alpha (it's union of source and dest alpha) |
| 585 if (dest_scan[3] == 0) { |
| 586 dest_scan[3] = src_alpha1; |
| 587 *dest_scan++ = m_Blue; |
| 588 *dest_scan++ = m_Green; |
| 589 *dest_scan = m_Red; |
| 590 dest_scan += 2; |
| 591 continue; |
| 592 } |
| 593 uint8_t dest_alpha = |
| 594 dest_scan[3] + src_alpha1 - dest_scan[3] * src_alpha1 / 255; |
| 595 dest_scan[3] = dest_alpha; |
| 596 int alpha_ratio = src_alpha1 * 255 / dest_alpha; |
| 597 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 598 dest_scan++; |
| 599 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 600 dest_scan++; |
| 601 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 602 dest_scan += 2; |
| 603 } |
| 604 } |
| 605 } |
| 606 #endif |
| 607 } |
345 | 608 |
346 void CFX_SkiaRenderer::CompositeSpanARGB_3(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | 609 void CFX_SkiaRenderer::CompositeSpanARGB_7(uint8_t* dest_scan, |
347 int span_left, int span_len, int span_top, uint8_t cover_scan, | 610 uint8_t* ori_scan, |
348 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 611 int Bpp, |
349 uint8_t* dest_extra_alpha_scan) | 612 int span_left, |
350 { | 613 int span_len, |
351 ASSERT(!m_pDevice->IsCmykImage()); | 614 int span_top, |
352 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); | 615 uint8_t cover_scan, |
353 //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left
<<2); | 616 int clip_top, |
354 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 617 int clip_left, |
355 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 618 int clip_right, |
356 if (col_end < col_start) return; // do nothing. | 619 uint8_t* clip_scan, |
357 dest_scan += col_start << 2; | 620 uint8_t* dest_extra_alpha_scan) { |
358 //ori_scan += col_start << 2; | 621 ASSERT(!m_pDevice->IsCmykImage()); |
| 622 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2); |
| 623 // ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<2); |
| 624 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
| 625 clip_left + span_left; |
| 626 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 627 int col_end = |
| 628 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 629 if (col_end < col_start) |
| 630 return; // do nothing. |
| 631 dest_scan += col_start << 2; |
| 632 // ori_scan += col_start << 2; |
| 633 // Do not need origin bitmap, because of merge in pure transparent background |
| 634 for (int col = col_start; col < col_end; col++) { |
| 635 int src_alpha = m_Alpha * clip_scan[col] / 255; |
| 636 int src_alpha_covered = src_alpha * cover_scan / 255; |
| 637 // shortcut |
| 638 if (src_alpha_covered == 0) { |
| 639 dest_scan += 4; |
| 640 continue; |
| 641 } |
| 642 // shortcut |
| 643 if (cover_scan == 255 || dest_scan[3] == 0) { |
| 644 // origin alpha always zero, just get src alpha |
| 645 dest_scan[3] = src_alpha_covered; |
| 646 *dest_scan++ = m_Blue; |
| 647 *dest_scan++ = m_Green; |
| 648 *dest_scan = m_Red; |
| 649 dest_scan += 2; |
| 650 continue; |
| 651 } |
| 652 // We should do alpha transition and color transition |
| 653 // alpha fg color fg |
| 654 // alpha bg color bg |
| 655 // alpha cover color cover |
| 656 dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], src_alpha, cover_scan); |
| 657 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan); |
| 658 dest_scan++; |
| 659 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan); |
| 660 dest_scan++; |
| 661 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan); |
| 662 dest_scan += 2; |
| 663 } |
| 664 } |
359 | 665 |
360 if (m_Alpha == 255 && cover_scan == 255){ | 666 /*------------------------------------------------------------------------------
-----------------------------*/ |
361 FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); | 667 void CFX_SkiaRenderer::CompositeSpanRGB32_2(uint8_t* dest_scan, |
362 return; | 668 uint8_t* ori_scan, |
363 } | 669 int Bpp, |
364 if (cover_scan == 255) { | 670 int span_left, |
365 int dst_color = (0x00ffffff&m_Color)|(m_Alpha<<24); | 671 int span_len, |
366 FXSYS_memset(dest_scan, dst_color, (col_end - col_start)<<2); | 672 int span_top, |
367 return; | 673 uint8_t cover_scan, |
368 } | 674 int clip_top, |
369 // Do not need origin bitmap, because of merge in pure transparent backg
round | 675 int clip_left, |
370 int src_alpha_covered = m_Alpha * cover_scan / 255; | 676 int clip_right, |
371 for (int col = col_start; col < col_end; col ++) | 677 uint8_t* clip_scan, |
372 { | 678 uint8_t* dest_extra_alpha_scan) { |
373 // shortcut | 679 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2); |
374 if (dest_scan[3] == 0) { | 680 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
375 dest_scan[3] = src_alpha_covered; | 681 int col_end = |
376 *dest_scan ++ = m_Blue; | 682 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
377 *dest_scan ++ = m_Green; | 683 if (col_end < col_start) |
378 *dest_scan = m_Red; | 684 return; // do nothing. |
379 dest_scan += 2; | 685 dest_scan += (col_start << 2); |
380 continue; | 686 if (m_Alpha == 255 && cover_scan == 255) { |
381 } | 687 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); |
382 // We should do alpha transition and color transition | 688 return; |
383 // alpha fg color fg | 689 } |
384 // alpha bg color bg | 690 int src_alpha; |
385 // alpha cover color cover | |
386 dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], m_Alpha, cover_scan); | |
387 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan); | |
388 dest_scan ++; | |
389 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan); | |
390 dest_scan ++; | |
391 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan); | |
392 dest_scan += 2; | |
393 } | |
394 } | |
395 void CFX_SkiaRenderer::CompositeSpanARGB_6(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | |
396 int span_left, int span_len, int span_top, uint8_t cover_scan, | |
397 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | |
398 uint8_t* dest_extra_alpha_scan) | |
399 { | |
400 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); | |
401 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | |
402 int col_start = span_left < clip_left ? clip_left - span_left : 0; | |
403 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | |
404 if (col_end < col_start) return; // do nothing. | |
405 dest_scan += col_start << 2; | |
406 #if 1 | |
407 int src_alpha = m_Alpha * cover_scan / 255; | |
408 for (int col = col_start; col < col_end; col ++) { | |
409 int src_alpha1 = src_alpha* clip_scan[col] / 255; | |
410 if (!src_alpha1) { | |
411 dest_scan += 4; | |
412 continue; | |
413 } | |
414 if (src_alpha1 == 255) { | |
415 *(FX_DWORD*)dest_scan = m_Color; | |
416 dest_scan += 4; | |
417 } else { | |
418 // Dest format: Argb | |
419 // calculate destination alpha (it's union of source and dest al
pha) | |
420 if (dest_scan[3] == 0) { | |
421 dest_scan[3] = src_alpha1; | |
422 *dest_scan++ = m_Blue; | |
423 *dest_scan++ = m_Green; | |
424 *dest_scan = m_Red; | |
425 dest_scan += 2; | |
426 continue; | |
427 } | |
428 uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3] *
src_alpha1 / 255; | |
429 dest_scan[3] = dest_alpha; | |
430 int alpha_ratio = src_alpha1*255/dest_alpha; | |
431 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); | |
432 dest_scan ++; | |
433 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio)
; | |
434 dest_scan ++; | |
435 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); | |
436 dest_scan += 2; | |
437 } | |
438 } | |
439 #else | |
440 if (m_bFullCover) { | |
441 for (int col = col_start; col < col_end; col ++) { | |
442 int src_alpha = m_Alpha * clip_scan[col] / 255; | |
443 if (!src_alpha) { | |
444 dest_scan += 4; | |
445 continue; | |
446 } | |
447 if (src_alpha == 255){ | |
448 *(FX_DWORD*)dest_scan = m_Color; | |
449 dest_scan += 4; | |
450 continue; | |
451 } else { | |
452 // Dest format: Argb | |
453 // calculate destination alpha (it's union of source and des
t alpha) | |
454 if (dest_scan[3] == 0) { | |
455 dest_scan[3] = src_alpha; | |
456 *dest_scan++ = m_Blue; | |
457 *dest_scan++ = m_Green; | |
458 *dest_scan = m_Red; | |
459 dest_scan += 2; | |
460 continue; | |
461 } | |
462 uint8_t dest_alpha = dest_scan[3] + src_alpha - dest_scan[3]
* src_alpha / 255; | |
463 dest_scan[3] = dest_alpha; | |
464 int alpha_ratio = src_alpha*255/dest_alpha; | |
465 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_rat
io); | |
466 dest_scan ++; | |
467 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ra
tio); | |
468 dest_scan ++; | |
469 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_rati
o); | |
470 dest_scan += 2; | |
471 } | |
472 } | |
473 } else { | |
474 int src_alpha = m_Alpha * cover_scan / 255; | |
475 for (int col = col_start; col < col_end; col ++) { | |
476 int src_alpha1 = src_alpha* clip_scan[col] / 255; | |
477 if (!src_alpha1) { | |
478 dest_scan += 4; | |
479 continue; | |
480 } | |
481 if (src_alpha1 == 255) { | |
482 *(FX_DWORD*)dest_scan = m_Color; | |
483 dest_scan += 4; | |
484 } else { | |
485 // Dest format: Argb | |
486 // calculate destination alpha (it's union of source and des
t alpha) | |
487 if (dest_scan[3] == 0) { | |
488 dest_scan[3] = src_alpha1; | |
489 *dest_scan++ = m_Blue; | |
490 *dest_scan++ = m_Green; | |
491 *dest_scan = m_Red; | |
492 dest_scan += 2; | |
493 continue; | |
494 } | |
495 uint8_t dest_alpha = dest_scan[3] + src_alpha1 - dest_scan[3
] * src_alpha1 / 255; | |
496 dest_scan[3] = dest_alpha; | |
497 int alpha_ratio = src_alpha1*255/dest_alpha; | |
498 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_rat
io); | |
499 dest_scan ++; | |
500 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ra
tio); | |
501 dest_scan ++; | |
502 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_rati
o); | |
503 dest_scan += 2; | |
504 } | |
505 } | |
506 } | |
507 #endif | |
508 } | |
509 | |
510 void CFX_SkiaRenderer::CompositeSpanARGB_7(uint8_t* dest_scan, uint8_t* ori_
scan,int Bpp, | |
511 int span_left, int span_len, int span_top, uint8_t cover_scan, | |
512 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | |
513 uint8_t* dest_extra_alpha_scan) | |
514 { | |
515 ASSERT(!m_pDevice->IsCmykImage()); | |
516 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); | |
517 //ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left
<<2); | |
518 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | |
519 int col_start = span_left < clip_left ? clip_left - span_left : 0; | |
520 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | |
521 if (col_end < col_start) return; // do nothing. | |
522 dest_scan += col_start << 2; | |
523 //ori_scan += col_start << 2; | |
524 // Do not need origin bitmap, because of merge in pure transparent backg
round | |
525 for (int col = col_start; col < col_end; col ++) | |
526 { | |
527 int src_alpha = m_Alpha * clip_scan[col] / 255; | |
528 int src_alpha_covered = src_alpha * cover_scan / 255; | |
529 // shortcut | |
530 if (src_alpha_covered == 0){ | |
531 dest_scan += 4; | |
532 continue; | |
533 } | |
534 // shortcut | |
535 if (cover_scan == 255 || dest_scan[3] == 0) | |
536 { | |
537 // origin alpha always zero, just get src alpha | |
538 dest_scan[3] = src_alpha_covered; | |
539 *dest_scan ++ = m_Blue; | |
540 *dest_scan ++ = m_Green; | |
541 *dest_scan = m_Red; | |
542 dest_scan += 2; | |
543 continue; | |
544 } | |
545 // We should do alpha transition and color transition | |
546 // alpha fg color fg | |
547 // alpha bg color bg | |
548 // alpha cover color cover | |
549 dest_scan[3] = FXDIB_ALPHA_MERGE(dest_scan[3], src_alpha, cover_scan
); | |
550 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, cover_scan); | |
551 dest_scan ++; | |
552 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, cover_scan); | |
553 dest_scan ++; | |
554 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, cover_scan); | |
555 dest_scan += 2; | |
556 } | |
557 } | |
558 | |
559 /*--------------------------------------------------------------------------
---------------------------------*/ | |
560 void CFX_SkiaRenderer::CompositeSpanRGB32_2(uint8_t* dest_scan, uint8_t* ori
_scan,int Bpp, | |
561 int span_left, int span_len, int span_top, uint8_t cover_scan, | |
562 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | |
563 uint8_t* dest_extra_alpha_scan) | |
564 { | |
565 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); | |
566 int col_start = span_left < clip_left ? clip_left - span_left : 0; | |
567 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | |
568 if (col_end < col_start) return; // do nothing. | |
569 dest_scan += (col_start << 2); | |
570 if (m_Alpha == 255 && cover_scan == 255) { | |
571 FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); | |
572 return; | |
573 } | |
574 int src_alpha; | |
575 #if 0 | 691 #if 0 |
576 if (m_bFullCover) | 692 if (m_bFullCover) |
577 src_alpha = m_Alpha; | 693 src_alpha = m_Alpha; |
578 else | 694 else |
579 #endif | 695 #endif |
580 src_alpha = m_Alpha * cover_scan / 255; | 696 src_alpha = m_Alpha * cover_scan / 255; |
581 for (int col = col_start; col < col_end; col ++) { | 697 for (int col = col_start; col < col_end; col++) { |
582 // Dest format: Rgb32 | 698 // Dest format: Rgb32 |
583 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); | 699 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); |
584 dest_scan ++; | 700 dest_scan++; |
585 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); | 701 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); |
586 dest_scan ++; | 702 dest_scan++; |
587 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); | 703 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); |
588 dest_scan += 2; | 704 dest_scan += 2; |
589 } | 705 } |
590 } | 706 } |
591 void CFX_SkiaRenderer::CompositeSpanRGB32_3(uint8_t* dest_scan, uint8_t* ori
_scan,int Bpp, | 707 void CFX_SkiaRenderer::CompositeSpanRGB32_3(uint8_t* dest_scan, |
592 int span_left, int span_len, int span_top, uint8_t cover_scan, | 708 uint8_t* ori_scan, |
593 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 709 int Bpp, |
594 uint8_t* dest_extra_alpha_scan) | 710 int span_left, |
595 { | 711 int span_len, |
596 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); | 712 int span_top, |
597 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<
2); | 713 uint8_t cover_scan, |
598 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 714 int clip_top, |
599 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 715 int clip_left, |
600 if (col_end < col_start) return; // do nothing. | 716 int clip_right, |
601 dest_scan += col_start << 2; | 717 uint8_t* clip_scan, |
602 ori_scan += col_start << 2; | 718 uint8_t* dest_extra_alpha_scan) { |
603 if (m_Alpha == 255 && cover_scan == 255) { | 719 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2); |
604 FXSYS_memset(dest_scan, m_Color, (col_end - col_start)<<2); | 720 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left << 2); |
605 return; | 721 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
606 } | 722 int col_end = |
607 int src_alpha = m_Alpha; | 723 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
608 for (int col = col_start; col < col_end; col ++) { | 724 if (col_end < col_start) |
| 725 return; // do nothing. |
| 726 dest_scan += col_start << 2; |
| 727 ori_scan += col_start << 2; |
| 728 if (m_Alpha == 255 && cover_scan == 255) { |
| 729 FXSYS_memset(dest_scan, m_Color, (col_end - col_start) << 2); |
| 730 return; |
| 731 } |
| 732 int src_alpha = m_Alpha; |
| 733 for (int col = col_start; col < col_end; col++) { |
609 #if 0 | 734 #if 0 |
610 if (m_bFullCover) { | 735 if (m_bFullCover) { |
611 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha)
; | 736 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha)
; |
612 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha
); | 737 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha
); |
613 *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); | 738 *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); |
614 dest_scan += 2; ori_scan += 2; | 739 dest_scan += 2; ori_scan += 2; |
615 continue; | 740 continue; |
616 } | 741 } |
617 #endif | 742 #endif |
618 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); | 743 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); |
619 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); | 744 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); |
620 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); | 745 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); |
621 ori_scan += 2; | 746 ori_scan += 2; |
622 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); | 747 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); |
623 dest_scan ++; | 748 dest_scan++; |
624 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); | 749 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); |
625 dest_scan ++; | 750 dest_scan++; |
626 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); | 751 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); |
627 dest_scan += 2; | 752 dest_scan += 2; |
628 } | 753 } |
629 } | 754 } |
630 void CFX_SkiaRenderer::CompositeSpanRGB32_6(uint8_t* dest_scan, uint8_t* ori
_scan,int Bpp, | 755 void CFX_SkiaRenderer::CompositeSpanRGB32_6(uint8_t* dest_scan, |
631 int span_left, int span_len, int span_top, uint8_t cover_scan, | 756 uint8_t* ori_scan, |
632 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 757 int Bpp, |
633 uint8_t* dest_extra_alpha_scan) | 758 int span_left, |
634 { | 759 int span_len, |
635 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); | 760 int span_top, |
636 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | 761 uint8_t cover_scan, |
637 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 762 int clip_top, |
638 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 763 int clip_left, |
639 if (col_end < col_start) return; // do nothing. | 764 int clip_right, |
640 dest_scan += col_start << 2; | 765 uint8_t* clip_scan, |
| 766 uint8_t* dest_extra_alpha_scan) { |
| 767 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2); |
| 768 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
| 769 clip_left + span_left; |
| 770 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 771 int col_end = |
| 772 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 773 if (col_end < col_start) |
| 774 return; // do nothing. |
| 775 dest_scan += col_start << 2; |
641 #if 1 | 776 #if 1 |
642 int src_alpha = m_Alpha * cover_scan / 255; | 777 int src_alpha = m_Alpha * cover_scan / 255; |
643 for (int col = col_start; col < col_end; col ++) { | 778 for (int col = col_start; col < col_end; col++) { |
644 int src_alpha1 = src_alpha * clip_scan[col] / 255; | 779 int src_alpha1 = src_alpha * clip_scan[col] / 255; |
645 if (!src_alpha1) { | 780 if (!src_alpha1) { |
646 dest_scan += 4; | 781 dest_scan += 4; |
647 continue; | 782 continue; |
648 } | 783 } |
649 if (src_alpha1 == 255) { | 784 if (src_alpha1 == 255) { |
650 *(FX_DWORD*)dest_scan = m_Color; | 785 *(FX_DWORD*)dest_scan = m_Color; |
651 dest_scan += 4; | 786 dest_scan += 4; |
652 } else { | 787 } else { |
653 // Dest format: Rgb or Rgb32 | 788 // Dest format: Rgb or Rgb32 |
654 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); | 789 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); |
655 dest_scan ++; | 790 dest_scan++; |
656 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); | 791 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); |
657 dest_scan ++; | 792 dest_scan++; |
658 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); | 793 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); |
659 dest_scan += 2; | 794 dest_scan += 2; |
660 } | 795 } |
661 } | 796 } |
662 #else | 797 #else |
663 if (m_bFullCover) { | 798 if (m_bFullCover) { |
664 for (int col = col_start; col < col_end; col ++) { | 799 for (int col = col_start; col < col_end; col++) { |
665 int src_alpha = m_Alpha * clip_scan[col] / 255; | 800 int src_alpha = m_Alpha * clip_scan[col] / 255; |
666 if (!src_alpha) { | 801 if (!src_alpha) { |
667 dest_scan += 4; | 802 dest_scan += 4; |
668 continue; | 803 continue; |
669 } | 804 } |
670 if (src_alpha == 255) { | 805 if (src_alpha == 255) { |
671 *(FX_DWORD*)dest_scan = m_Color; | 806 *(FX_DWORD*)dest_scan = m_Color; |
672 dest_scan += 4; | 807 dest_scan += 4; |
673 } else { | 808 } else { |
674 // Dest format: Rgb or Rgb32 | 809 // Dest format: Rgb or Rgb32 |
675 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha
); | 810 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); |
676 dest_scan ++; | 811 dest_scan++; |
677 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alph
a); | 812 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); |
678 dest_scan ++; | 813 dest_scan++; |
679 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha)
; | 814 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); |
680 dest_scan += 2; | 815 dest_scan += 2; |
681 } | 816 } |
682 } | 817 } |
683 } else { | 818 } else { |
684 // Rgb32 | 819 // Rgb32 |
685 int src_alpha = m_Alpha * cover_scan / 255; | 820 int src_alpha = m_Alpha * cover_scan / 255; |
686 for (int col = col_start; col < col_end; col ++) { | 821 for (int col = col_start; col < col_end; col++) { |
687 int src_alpha1 = src_alpha * clip_scan[col] / 255; | 822 int src_alpha1 = src_alpha * clip_scan[col] / 255; |
688 if (!src_alpha1) { | 823 if (!src_alpha1) { |
689 dest_scan += 4; | 824 dest_scan += 4; |
690 continue; | 825 continue; |
691 } | 826 } |
692 if (src_alpha1 == 255) { | 827 if (src_alpha1 == 255) { |
693 *(FX_DWORD*)dest_scan = m_Color; | 828 *(FX_DWORD*)dest_scan = m_Color; |
694 dest_scan += 4; | 829 dest_scan += 4; |
695 } else { | 830 } else { |
696 // Dest format: Rgb or Rgb32 | 831 // Dest format: Rgb or Rgb32 |
697 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha
1); | 832 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); |
698 dest_scan ++; | 833 dest_scan++; |
699 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alph
a1); | 834 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); |
700 dest_scan ++; | 835 dest_scan++; |
701 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1
); | 836 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); |
702 dest_scan += 2; | 837 dest_scan += 2; |
703 } | 838 } |
704 } | 839 } |
705 } | 840 } |
706 #endif | 841 #endif |
707 } | 842 } |
708 void CFX_SkiaRenderer::CompositeSpanRGB32_7(uint8_t* dest_scan, uint8_t* ori
_scan,int Bpp, | 843 void CFX_SkiaRenderer::CompositeSpanRGB32_7(uint8_t* dest_scan, |
709 int span_left, int span_len, int span_top, uint8_t cover_scan, | 844 uint8_t* ori_scan, |
710 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 845 int Bpp, |
711 uint8_t* dest_extra_alpha_scan) | 846 int span_left, |
712 { | 847 int span_len, |
713 ASSERT(!m_pDevice->IsCmykImage()); | 848 int span_top, |
714 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left<<2); | 849 uint8_t cover_scan, |
715 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left<<
2); | 850 int clip_top, |
716 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | 851 int clip_left, |
717 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 852 int clip_right, |
718 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 853 uint8_t* clip_scan, |
719 if (col_end < col_start) return; // do nothing. | 854 uint8_t* dest_extra_alpha_scan) { |
720 dest_scan += col_start << 2; | 855 ASSERT(!m_pDevice->IsCmykImage()); |
721 ori_scan += col_start << 2; | 856 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + (span_left << 2); |
| 857 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + (span_left << 2); |
| 858 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
| 859 clip_left + span_left; |
| 860 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 861 int col_end = |
| 862 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 863 if (col_end < col_start) |
| 864 return; // do nothing. |
| 865 dest_scan += col_start << 2; |
| 866 ori_scan += col_start << 2; |
722 #if 1 | 867 #if 1 |
723 for (int col = col_start; col < col_end; col ++) { | 868 for (int col = col_start; col < col_end; col++) { |
724 int src_alpha = m_Alpha * clip_scan[col] / 255; | 869 int src_alpha = m_Alpha * clip_scan[col] / 255; |
725 if (src_alpha == 255 && cover_scan == 255) { | 870 if (src_alpha == 255 && cover_scan == 255) { |
726 *(FX_DWORD*)dest_scan = m_Color; | 871 *(FX_DWORD*)dest_scan = m_Color; |
727 dest_scan += 4; | 872 dest_scan += 4; |
728 ori_scan += 4; | 873 ori_scan += 4; |
729 continue; | 874 continue; |
730 } | 875 } |
731 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); | 876 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); |
732 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); | 877 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); |
733 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); | 878 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); |
734 ori_scan += 2; | 879 ori_scan += 2; |
735 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); | 880 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); |
736 dest_scan ++; | 881 dest_scan++; |
737 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); | 882 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); |
738 dest_scan ++; | 883 dest_scan++; |
739 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); | 884 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); |
740 dest_scan += 2; | 885 dest_scan += 2; |
741 } | 886 } |
742 #else | 887 #else |
743 if (m_bFullCover) { | 888 if (m_bFullCover) { |
744 for (int col = col_start; col < col_end; col ++) { | 889 for (int col = col_start; col < col_end; col++) { |
745 int src_alpha = m_Alpha * clip_scan[col] / 255; | 890 int src_alpha = m_Alpha * clip_scan[col] / 255; |
746 if (!src_alpha) { | 891 if (!src_alpha) { |
747 *(FX_DWORD*)dest_scan = *(FX_DWORD*)ori_scan; | 892 *(FX_DWORD*)dest_scan = *(FX_DWORD*)ori_scan; |
748 dest_scan += 4; | 893 dest_scan += 4; |
749 ori_scan += 4; | 894 ori_scan += 4; |
750 continue; | 895 continue; |
751 } | 896 } |
752 if (src_alpha == 255) { | 897 if (src_alpha == 255) { |
753 *(FX_DWORD*)dest_scan = m_Color; | 898 *(FX_DWORD*)dest_scan = m_Color; |
754 dest_scan += 4; | 899 dest_scan += 4; |
755 ori_scan += 4; | 900 ori_scan += 4; |
756 continue; | 901 continue; |
757 } | 902 } |
758 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha)
; | 903 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); |
759 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha
); | 904 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); |
760 *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); | 905 *dest_scan = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); |
761 dest_scan += 2; ori_scan += 2; | 906 dest_scan += 2; |
762 } | 907 ori_scan += 2; |
763 } else { | 908 } |
764 for (int col = col_start; col < col_end; col ++) { | 909 } else { |
765 int src_alpha = m_Alpha * clip_scan[col] / 255; | 910 for (int col = col_start; col < col_end; col++) { |
766 if (src_alpha == 255 && cover_scan == 255) { | 911 int src_alpha = m_Alpha * clip_scan[col] / 255; |
767 *(FX_DWORD*)dest_scan = m_Color; | 912 if (src_alpha == 255 && cover_scan == 255) { |
768 dest_scan += 4; | 913 *(FX_DWORD*)dest_scan = m_Color; |
769 ori_scan += 4; | 914 dest_scan += 4; |
770 continue; | 915 ori_scan += 4; |
771 } | 916 continue; |
772 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); | 917 } |
773 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); | 918 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); |
774 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); | 919 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); |
775 ori_scan += 2; | 920 int r = FXDIB_ALPHA_MERGE(*ori_scan, m_Red, src_alpha); |
776 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); | 921 ori_scan += 2; |
777 dest_scan ++; | 922 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); |
778 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); | 923 dest_scan++; |
779 dest_scan ++; | 924 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); |
780 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); | 925 dest_scan++; |
781 dest_scan += 2; | 926 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); |
782 } | 927 dest_scan += 2; |
783 } | 928 } |
784 #endif | 929 } |
785 } | 930 #endif |
786 /*--------------------------------------------------------------------------
---------------------------*/ | 931 } |
787 void CFX_SkiaRenderer::CompositeSpanRGB24_2(uint8_t* dest_scan, uint8_t* ori
_scan,int Bpp, | 932 /*------------------------------------------------------------------------------
-----------------------*/ |
788 int span_left, int span_len, int span_top, uint8_t cover_scan, | 933 void CFX_SkiaRenderer::CompositeSpanRGB24_2(uint8_t* dest_scan, |
789 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 934 uint8_t* ori_scan, |
790 uint8_t* dest_extra_alpha_scan) | 935 int Bpp, |
791 { | 936 int span_left, |
792 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (sp
an_left<<1); | 937 int span_len, |
793 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 938 int span_top, |
794 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 939 uint8_t cover_scan, |
795 if (col_end < col_start) return; // do nothing. | 940 int clip_top, |
796 dest_scan += (col_start<<1)+col_start; | 941 int clip_left, |
797 int src_alpha; | 942 int clip_right, |
| 943 uint8_t* clip_scan, |
| 944 uint8_t* dest_extra_alpha_scan) { |
| 945 dest_scan = |
| 946 (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1); |
| 947 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 948 int col_end = |
| 949 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 950 if (col_end < col_start) |
| 951 return; // do nothing. |
| 952 dest_scan += (col_start << 1) + col_start; |
| 953 int src_alpha; |
798 #if 0 | 954 #if 0 |
799 if (m_bFullCover) | 955 if (m_bFullCover) |
800 src_alpha = m_Alpha; | 956 src_alpha = m_Alpha; |
801 else | 957 else |
802 #endif | 958 #endif |
803 src_alpha = m_Alpha * cover_scan / 255; | 959 src_alpha = m_Alpha * cover_scan / 255; |
804 if (src_alpha == 255) { | 960 if (src_alpha == 255) { |
805 for (int col = col_start; col < col_end; col ++) { | 961 for (int col = col_start; col < col_end; col++) { |
806 *dest_scan++ = m_Blue; | 962 *dest_scan++ = m_Blue; |
807 *dest_scan++ = m_Green; | 963 *dest_scan++ = m_Green; |
808 *dest_scan++ = m_Red; | 964 *dest_scan++ = m_Red; |
809 } | 965 } |
810 return; | 966 return; |
811 } | 967 } |
812 for (int col = col_start; col < col_end; col ++) { | 968 for (int col = col_start; col < col_end; col++) { |
813 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); | 969 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); |
814 dest_scan ++; | 970 dest_scan++; |
815 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); | 971 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); |
816 dest_scan ++; | 972 dest_scan++; |
817 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); | 973 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); |
818 dest_scan ++; | 974 dest_scan++; |
819 } | 975 } |
820 } | 976 } |
821 void CFX_SkiaRenderer::CompositeSpanRGB24_3(uint8_t* dest_scan, uint8_t* ori
_scan,int Bpp, | 977 void CFX_SkiaRenderer::CompositeSpanRGB24_3(uint8_t* dest_scan, |
822 int span_left, int span_len, int span_top, uint8_t cover_scan, | 978 uint8_t* ori_scan, |
823 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 979 int Bpp, |
824 uint8_t* dest_extra_alpha_scan) | 980 int span_left, |
825 { | 981 int span_len, |
826 ASSERT(!m_pDevice->IsCmykImage()); | 982 int span_top, |
827 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (sp
an_left<<1); | 983 uint8_t cover_scan, |
828 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left +
(span_left<<1); | 984 int clip_top, |
829 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 985 int clip_left, |
830 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 986 int clip_right, |
831 if (col_end < col_start) return; // do nothing. | 987 uint8_t* clip_scan, |
832 dest_scan += (col_start<<1) + col_start; | 988 uint8_t* dest_extra_alpha_scan) { |
833 ori_scan += (col_start<<1) + col_start; | 989 ASSERT(!m_pDevice->IsCmykImage()); |
834 if (m_Alpha == 255&&cover_scan == 255) { | 990 dest_scan = |
835 for (int col = col_start; col < col_end; col ++) { | 991 (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1); |
836 *dest_scan ++ = m_Blue; | 992 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left + |
837 *dest_scan ++ = m_Green; | 993 (span_left << 1); |
838 *dest_scan ++ = m_Red; | 994 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
839 } | 995 int col_end = |
840 return; | 996 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
841 } | 997 if (col_end < col_start) |
842 for (int col = col_start; col < col_end; col ++) { | 998 return; // do nothing. |
| 999 dest_scan += (col_start << 1) + col_start; |
| 1000 ori_scan += (col_start << 1) + col_start; |
| 1001 if (m_Alpha == 255 && cover_scan == 255) { |
| 1002 for (int col = col_start; col < col_end; col++) { |
| 1003 *dest_scan++ = m_Blue; |
| 1004 *dest_scan++ = m_Green; |
| 1005 *dest_scan++ = m_Red; |
| 1006 } |
| 1007 return; |
| 1008 } |
| 1009 for (int col = col_start; col < col_end; col++) { |
843 #if 0 | 1010 #if 0 |
844 if (m_bFullCover) { | 1011 if (m_bFullCover) { |
845 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); | 1012 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); |
846 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); | 1013 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); |
847 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); | 1014 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); |
848 continue; | 1015 continue; |
849 } | 1016 } |
850 #endif | 1017 #endif |
851 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); | 1018 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, m_Alpha); |
852 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); | 1019 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, m_Alpha); |
853 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); | 1020 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, m_Alpha); |
854 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); | 1021 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); |
855 dest_scan ++; | 1022 dest_scan++; |
856 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); | 1023 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); |
857 dest_scan ++; | 1024 dest_scan++; |
858 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); | 1025 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); |
859 dest_scan ++; | 1026 dest_scan++; |
| 1027 } |
| 1028 } |
| 1029 void CFX_SkiaRenderer::CompositeSpanRGB24_6(uint8_t* dest_scan, |
| 1030 uint8_t* ori_scan, |
| 1031 int Bpp, |
| 1032 int span_left, |
| 1033 int span_len, |
| 1034 int span_top, |
| 1035 uint8_t cover_scan, |
| 1036 int clip_top, |
| 1037 int clip_left, |
| 1038 int clip_right, |
| 1039 uint8_t* clip_scan, |
| 1040 uint8_t* dest_extra_alpha_scan) { |
| 1041 dest_scan = |
| 1042 (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1); |
| 1043 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
| 1044 clip_left + span_left; |
| 1045 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 1046 int col_end = |
| 1047 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 1048 if (col_end < col_start) |
| 1049 return; // do nothing. |
| 1050 dest_scan += col_start + (col_start << 1); |
| 1051 #if 1 |
| 1052 int src_alpha = m_Alpha * cover_scan / 255; |
| 1053 for (int col = col_start; col < col_end; col++) { |
| 1054 int src_alpha1 = src_alpha * clip_scan[col] / 255; |
| 1055 if (!src_alpha1) { |
| 1056 dest_scan += 3; |
| 1057 continue; |
| 1058 } |
| 1059 if (src_alpha1 == 255) { |
| 1060 *dest_scan++ = m_Blue; |
| 1061 *dest_scan++ = m_Green; |
| 1062 *dest_scan++ = m_Red; |
| 1063 } else { |
| 1064 // Dest format: Rgb |
| 1065 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); |
| 1066 dest_scan++; |
| 1067 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); |
| 1068 dest_scan++; |
| 1069 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); |
| 1070 dest_scan++; |
| 1071 } |
| 1072 } |
| 1073 #else |
| 1074 if (m_bFullCover) { |
| 1075 for (int col = col_start; col < col_end; col++) { |
| 1076 int src_alpha = m_Alpha * clip_scan[col] / 255; |
| 1077 if (!src_alpha) { |
| 1078 dest_scan += 3; |
| 1079 continue; |
| 1080 } |
| 1081 if (src_alpha == 255) { |
| 1082 *dest_scan++ = m_Blue; |
| 1083 *dest_scan++ = m_Green; |
| 1084 *dest_scan++ = m_Red; |
| 1085 } else { |
| 1086 // Dest format: Rgb |
| 1087 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); |
| 1088 dest_scan++; |
| 1089 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); |
| 1090 dest_scan++; |
| 1091 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); |
| 1092 dest_scan++; |
| 1093 } |
| 1094 } |
| 1095 } else { |
| 1096 int src_alpha = m_Alpha * cover_scan / 255; |
| 1097 for (int col = col_start; col < col_end; col++) { |
| 1098 int src_alpha1 = src_alpha * clip_scan[col] / 255; |
| 1099 if (!src_alpha1) { |
| 1100 dest_scan += 3; |
| 1101 continue; |
| 1102 } |
| 1103 if (src_alpha1 == 255) { |
| 1104 *dest_scan++ = m_Blue; |
| 1105 *dest_scan++ = m_Green; |
| 1106 *dest_scan++ = m_Red; |
| 1107 } else { |
| 1108 // Dest format: Rgb |
| 1109 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); |
| 1110 dest_scan++; |
| 1111 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); |
| 1112 dest_scan++; |
| 1113 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); |
| 1114 dest_scan++; |
| 1115 } |
| 1116 } |
| 1117 } |
| 1118 #endif |
| 1119 } |
| 1120 void CFX_SkiaRenderer::CompositeSpanRGB24_7(uint8_t* dest_scan, |
| 1121 uint8_t* ori_scan, |
| 1122 int Bpp, |
| 1123 int span_left, |
| 1124 int span_len, |
| 1125 int span_top, |
| 1126 uint8_t cover_scan, |
| 1127 int clip_top, |
| 1128 int clip_left, |
| 1129 int clip_right, |
| 1130 uint8_t* clip_scan, |
| 1131 uint8_t* dest_extra_alpha_scan) { |
| 1132 ASSERT(!m_pDevice->IsCmykImage()); |
| 1133 dest_scan = |
| 1134 (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1); |
| 1135 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left + |
| 1136 (span_left << 1); |
| 1137 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
| 1138 clip_left + span_left; |
| 1139 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 1140 int col_end = |
| 1141 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 1142 if (col_end < col_start) |
| 1143 return; // do nothing. |
| 1144 dest_scan += col_start + (col_start << 1); |
| 1145 ori_scan += col_start + (col_start << 1); |
| 1146 #if 1 |
| 1147 for (int col = col_start; col < col_end; col++) { |
| 1148 int src_alpha = m_Alpha * clip_scan[col] / 255; |
| 1149 if (src_alpha == 255 && cover_scan == 255) { |
| 1150 *dest_scan++ = m_Blue; |
| 1151 *dest_scan++ = m_Green; |
| 1152 *dest_scan++ = m_Red; |
| 1153 ori_scan += 3; |
| 1154 continue; |
| 1155 } |
| 1156 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); |
| 1157 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); |
| 1158 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); |
| 1159 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); |
| 1160 dest_scan++; |
| 1161 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); |
| 1162 dest_scan++; |
| 1163 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); |
| 1164 dest_scan++; |
| 1165 } |
| 1166 #else |
| 1167 if (m_bFullCover) { |
| 1168 for (int col = col_start; col < col_end; col++) { |
| 1169 int src_alpha = m_Alpha * clip_scan[col] / 255; |
| 1170 if (!src_alpha) { |
| 1171 *dest_scan++ = *ori_scan++; |
| 1172 *dest_scan++ = *ori_scan++; |
| 1173 *dest_scan++ = *ori_scan++; |
| 1174 continue; |
| 1175 } |
| 1176 if (src_alpha == 255) { |
| 1177 *dest_scan++ = m_Blue; |
| 1178 *dest_scan++ = m_Green; |
| 1179 *dest_scan++ = m_Red; |
| 1180 ori_scan += 3; |
| 1181 continue; |
| 1182 } |
| 1183 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); |
| 1184 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); |
| 1185 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); |
| 1186 } |
| 1187 } else { |
| 1188 for (int col = col_start; col < col_end; col++) { |
| 1189 int src_alpha = m_Alpha * clip_scan[col] / 255; |
| 1190 if (src_alpha == 255 && cover_scan == 255) { |
| 1191 *dest_scan++ = m_Blue; |
| 1192 *dest_scan++ = m_Green; |
| 1193 *dest_scan++ = m_Red; |
| 1194 ori_scan += 3; |
| 1195 continue; |
| 1196 } |
| 1197 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); |
| 1198 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); |
| 1199 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); |
| 1200 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, b, cover_scan); |
| 1201 dest_scan++; |
| 1202 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); |
| 1203 dest_scan++; |
| 1204 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); |
| 1205 dest_scan++; |
| 1206 } |
| 1207 } |
| 1208 #endif |
| 1209 } |
| 1210 void CFX_SkiaRenderer::CompositeSpanRGB24_10(uint8_t* dest_scan, |
| 1211 uint8_t* ori_scan, |
| 1212 int Bpp, |
| 1213 int span_left, |
| 1214 int span_len, |
| 1215 int span_top, |
| 1216 uint8_t cover_scan, |
| 1217 int clip_top, |
| 1218 int clip_left, |
| 1219 int clip_right, |
| 1220 uint8_t* clip_scan, |
| 1221 uint8_t* dest_extra_alpha_scan) { |
| 1222 dest_scan = |
| 1223 (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1); |
| 1224 dest_extra_alpha_scan = |
| 1225 (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top) + span_left; |
| 1226 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 1227 int col_end = |
| 1228 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 1229 if (col_end < col_start) |
| 1230 return; // do nothing. |
| 1231 dest_scan += col_start + (col_start << 1); |
| 1232 #if 1 |
| 1233 if (m_Alpha == 255 && cover_scan == 255) { |
| 1234 for (int col = col_start; col < col_end; col++) { |
| 1235 *dest_scan++ = (uint8_t)m_Blue; |
| 1236 *dest_scan++ = (uint8_t)m_Green; |
| 1237 *dest_scan++ = (uint8_t)m_Red; |
| 1238 *dest_extra_alpha_scan++ = 255; |
| 1239 } |
| 1240 return; |
| 1241 } |
| 1242 int src_alpha = m_Alpha * cover_scan / 255; |
| 1243 for (int col = col_start; col < col_end; col++) { |
| 1244 // Dest format: Rgba |
| 1245 // calculate destination alpha (it's union of source and dest alpha) |
| 1246 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - |
| 1247 (*dest_extra_alpha_scan) * src_alpha / 255; |
| 1248 *dest_extra_alpha_scan++ = dest_alpha; |
| 1249 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1250 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 1251 dest_scan++; |
| 1252 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 1253 dest_scan++; |
| 1254 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 1255 dest_scan++; |
| 1256 } |
| 1257 #else |
| 1258 if (m_bFullCover) { |
| 1259 if (m_Alpha == 255) { |
| 1260 for (int col = col_start; col < col_end; col++) { |
| 1261 *dest_scan++ = (uint8_t)m_Blue; |
| 1262 *dest_scan++ = (uint8_t)m_Green; |
| 1263 *dest_scan++ = (uint8_t)m_Red; |
| 1264 *dest_extra_alpha_scan++ = 255; |
| 1265 } |
| 1266 return; |
| 1267 } |
| 1268 for (int col = col_start; col < col_end; col++) { |
| 1269 // Dest format: Rgba |
| 1270 // calculate destination alpha (it's union of source and dest alpha) |
| 1271 uint8_t dest_alpha = (*dest_extra_alpha_scan) + m_Alpha - |
| 1272 (*dest_extra_alpha_scan) * m_Alpha / 255; |
| 1273 *dest_extra_alpha_scan++ = dest_alpha; |
| 1274 int alpha_ratio = m_Alpha * 255 / dest_alpha; |
| 1275 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 1276 dest_scan++; |
| 1277 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 1278 dest_scan++; |
| 1279 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 1280 dest_scan++; |
| 1281 } |
| 1282 } else { |
| 1283 if (m_Alpha == 255 && cover_scan == 255) { |
| 1284 for (int col = col_start; col < col_end; col++) { |
| 1285 *dest_scan++ = (uint8_t)m_Blue; |
| 1286 *dest_scan++ = (uint8_t)m_Green; |
| 1287 *dest_scan++ = (uint8_t)m_Red; |
| 1288 *dest_extra_alpha_scan++ = 255; |
| 1289 } |
| 1290 return; |
| 1291 } |
| 1292 int src_alpha = m_Alpha * cover_scan / 255; |
| 1293 for (int col = col_start; col < col_end; col++) { |
| 1294 // Dest format: Rgba |
| 1295 // calculate destination alpha (it's union of source and dest alpha) |
| 1296 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - |
| 1297 (*dest_extra_alpha_scan) * src_alpha / 255; |
| 1298 *dest_extra_alpha_scan++ = dest_alpha; |
| 1299 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1300 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 1301 dest_scan++; |
| 1302 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 1303 dest_scan++; |
| 1304 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 1305 dest_scan++; |
| 1306 } |
| 1307 } |
| 1308 #endif |
| 1309 } |
| 1310 void CFX_SkiaRenderer::CompositeSpanRGB24_14(uint8_t* dest_scan, |
| 1311 uint8_t* ori_scan, |
| 1312 int Bpp, |
| 1313 int span_left, |
| 1314 int span_len, |
| 1315 int span_top, |
| 1316 uint8_t cover_scan, |
| 1317 int clip_top, |
| 1318 int clip_left, |
| 1319 int clip_right, |
| 1320 uint8_t* clip_scan, |
| 1321 uint8_t* dest_extra_alpha_scan) { |
| 1322 dest_scan = |
| 1323 (uint8_t*)m_pDevice->GetScanline(span_top) + span_left + (span_left << 1); |
| 1324 dest_extra_alpha_scan = |
| 1325 (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(span_top) + span_left; |
| 1326 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top - clip_top) - |
| 1327 clip_left + span_left; |
| 1328 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 1329 int col_end = |
| 1330 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 1331 if (col_end < col_start) |
| 1332 return; // do nothing. |
| 1333 dest_scan += col_start + (col_start << 1); |
| 1334 #if 1 |
| 1335 int src_alpha = m_Alpha * cover_scan / 255; |
| 1336 for (int col = col_start; col < col_end; col++) { |
| 1337 int src_alpha1 = src_alpha * clip_scan[col] / 255; |
| 1338 if (!src_alpha1) { |
| 1339 dest_extra_alpha_scan++; |
| 1340 dest_scan += 3; |
| 1341 continue; |
| 1342 } |
| 1343 if (src_alpha1 == 255) { |
| 1344 *dest_scan++ = (uint8_t)m_Blue; |
| 1345 *dest_scan++ = (uint8_t)m_Green; |
| 1346 *dest_scan++ = (uint8_t)m_Red; |
| 1347 *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; |
| 1348 } else { |
| 1349 // Dest format: Rgba |
| 1350 // calculate destination alpha (it's union of source and dest alpha) |
| 1351 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 - |
| 1352 (*dest_extra_alpha_scan) * src_alpha1 / 255; |
| 1353 *dest_extra_alpha_scan++ = dest_alpha; |
| 1354 int alpha_ratio = src_alpha1 * 255 / dest_alpha; |
| 1355 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 1356 dest_scan++; |
| 1357 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 1358 dest_scan++; |
| 1359 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 1360 dest_scan++; |
| 1361 } |
| 1362 } |
| 1363 #else |
| 1364 if (m_bFullCover) { |
| 1365 for (int col = col_start; col < col_end; col++) { |
| 1366 int src_alpha = m_Alpha * clip_scan[col] / 255; |
| 1367 if (!src_alpha) { |
| 1368 dest_extra_alpha_scan++; |
| 1369 dest_scan += 3; |
| 1370 continue; |
| 1371 } |
| 1372 if (src_alpha == 255) { |
| 1373 *dest_scan++ = (uint8_t)m_Blue; |
| 1374 *dest_scan++ = (uint8_t)m_Green; |
| 1375 *dest_scan++ = (uint8_t)m_Red; |
| 1376 *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; |
| 1377 } else { |
| 1378 // Dest format: Rgba |
| 1379 // calculate destination alpha (it's union of source and dest alpha) |
| 1380 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - |
| 1381 (*dest_extra_alpha_scan) * src_alpha / 255; |
| 1382 *dest_extra_alpha_scan++ = dest_alpha; |
| 1383 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1384 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 1385 dest_scan++; |
| 1386 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 1387 dest_scan++; |
| 1388 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 1389 dest_scan++; |
| 1390 } |
| 1391 } |
| 1392 } else { |
| 1393 int src_alpha = m_Alpha * cover_scan / 255; |
| 1394 for (int col = col_start; col < col_end; col++) { |
| 1395 int src_alpha1 = m_Alpha * cover_scan * clip_scan[col] / 255; |
| 1396 if (!src_alpha1) { |
| 1397 dest_extra_alpha_scan++; |
| 1398 dest_scan += 3; |
| 1399 continue; |
| 1400 } |
| 1401 if (src_alpha1 == 255) { |
| 1402 *dest_scan++ = (uint8_t)m_Blue; |
| 1403 *dest_scan++ = (uint8_t)m_Green; |
| 1404 *dest_scan++ = (uint8_t)m_Red; |
| 1405 *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; |
| 1406 } else { |
| 1407 // Dest format: Rgba |
| 1408 // calculate destination alpha (it's union of source and dest alpha) |
| 1409 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 - |
| 1410 (*dest_extra_alpha_scan) * src_alpha1 / 255; |
| 1411 *dest_extra_alpha_scan++ = dest_alpha; |
| 1412 int alpha_ratio = src_alpha1 * 255 / dest_alpha; |
| 1413 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 1414 dest_scan++; |
| 1415 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 1416 dest_scan++; |
| 1417 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 1418 dest_scan++; |
| 1419 } |
| 1420 } |
| 1421 } |
| 1422 #endif |
| 1423 } |
| 1424 /*------------------------------------------------------------------------------
-----------------------*/ |
| 1425 |
| 1426 // A general alpha merge function (with clipping mask). Cmyka/Cmyk device. |
| 1427 void CFX_SkiaRenderer::CompositeSpanCMYK(uint8_t* dest_scan, |
| 1428 uint8_t* ori_scan, |
| 1429 int Bpp, |
| 1430 int span_left, |
| 1431 int span_len, |
| 1432 int span_top, |
| 1433 uint8_t cover_scan, |
| 1434 int clip_top, |
| 1435 int clip_left, |
| 1436 int clip_right, |
| 1437 uint8_t* clip_scan, |
| 1438 uint8_t* dest_extra_alpha_scan) { |
| 1439 ASSERT(!m_bRgbByteOrder); |
| 1440 // Cmyk(a) |
| 1441 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
| 1442 int col_end = |
| 1443 (span_left + span_len) < clip_right ? span_len : (clip_right - span_left); |
| 1444 if (col_end < col_start) |
| 1445 return; // do nothing. |
| 1446 dest_scan += col_start * 4; |
| 1447 Bpp; // for avoid compile warning. |
| 1448 |
| 1449 if (dest_extra_alpha_scan) { |
| 1450 // CMYKa |
| 1451 for (int col = col_start; col < col_end; col++) { |
| 1452 int src_alpha; |
| 1453 if (m_bFullCover) { |
| 1454 if (clip_scan) |
| 1455 src_alpha = m_Alpha * clip_scan[col] / 255; |
| 1456 else |
| 1457 src_alpha = m_Alpha; |
| 1458 } else { |
| 1459 if (clip_scan) |
| 1460 src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255; |
| 1461 else |
| 1462 src_alpha = m_Alpha * cover_scan / 255; |
| 1463 } |
| 1464 |
| 1465 if (src_alpha) { |
| 1466 if (src_alpha == 255) { |
| 1467 *(FX_CMYK*)dest_scan = m_Color; |
| 1468 *dest_extra_alpha_scan = (uint8_t)m_Alpha; |
| 1469 } else { |
| 1470 // Dest format: Cmyka |
| 1471 // calculate destination alpha (it's union of source and dest alpha) |
| 1472 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - |
| 1473 (*dest_extra_alpha_scan) * src_alpha / 255; |
| 1474 *dest_extra_alpha_scan++ = dest_alpha; |
| 1475 int alpha_ratio = src_alpha * 255 / dest_alpha; |
| 1476 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
| 1477 dest_scan++; |
| 1478 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
| 1479 dest_scan++; |
| 1480 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); |
| 1481 dest_scan++; |
| 1482 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, alpha_ratio); |
| 1483 dest_scan++; |
| 1484 continue; |
860 } | 1485 } |
861 } | 1486 } |
862 void CFX_SkiaRenderer::CompositeSpanRGB24_6(uint8_t* dest_scan, uint8_t* ori
_scan,int Bpp, | 1487 dest_extra_alpha_scan++; |
863 int span_left, int span_len, int span_top, uint8_t cover_scan, | 1488 dest_scan += 4; |
864 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | 1489 } |
865 uint8_t* dest_extra_alpha_scan) | 1490 } else { |
866 { | 1491 // CMYK |
867 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span
_left<<1); | 1492 for (int col = col_start; col < col_end; col++) { |
868 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | 1493 int src_alpha; |
869 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 1494 if (clip_scan) |
870 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | 1495 src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 255; |
871 if (col_end < col_start) return; // do nothing. | 1496 else |
872 dest_scan += col_start + (col_start << 1); | 1497 src_alpha = m_Alpha * cover_scan / 255; |
873 #if 1 | 1498 |
874 int src_alpha = m_Alpha * cover_scan /255; | 1499 if (src_alpha) { |
875 for (int col = col_start; col < col_end; col ++) { | 1500 if (src_alpha == 255) { |
876 int src_alpha1 = src_alpha * clip_scan[col] / 255; | 1501 *(FX_CMYK*)dest_scan = m_Color; |
877 if (!src_alpha1) { | 1502 } else { |
878 dest_scan += 3; | 1503 // Dest format: cmyk |
879 continue; | 1504 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); |
880 } | 1505 dest_scan++; |
881 if (src_alpha1 == 255) { | 1506 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha); |
882 *dest_scan++ = m_Blue; | 1507 dest_scan++; |
883 *dest_scan++ = m_Green; | 1508 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha); |
884 *dest_scan++ = m_Red; | 1509 dest_scan++; |
885 } else { | 1510 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); |
886 // Dest format: Rgb | 1511 dest_scan++; |
887 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha1); | 1512 continue; |
888 dest_scan ++; | |
889 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alpha1); | |
890 dest_scan ++; | |
891 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1); | |
892 dest_scan ++; | |
893 } | |
894 } | 1513 } |
895 #else | 1514 } |
896 if (m_bFullCover) { | 1515 dest_scan += 4; |
897 for (int col = col_start; col < col_end; col ++) { | 1516 } |
898 int src_alpha = m_Alpha * clip_scan[col] / 255; | 1517 } |
899 if (!src_alpha) { | 1518 } |
900 dest_scan += 3; | 1519 |
901 continue; | 1520 //-------------------------------------------------------------------- |
902 } | 1521 FX_BOOL CFX_SkiaRenderer::Init( |
903 if (src_alpha == 255) { | 1522 CFX_DIBitmap* pDevice, |
904 *dest_scan++ = m_Blue; | 1523 CFX_DIBitmap* pOriDevice, |
905 *dest_scan++ = m_Green; | 1524 const CFX_ClipRgn* pClipRgn, |
906 *dest_scan++ = m_Red; | 1525 FX_DWORD color, |
907 } else { | 1526 FX_BOOL bFullCover, |
908 // Dest format: Rgb | 1527 FX_BOOL bRgbByteOrder, |
909 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha
); | 1528 int alpha_flag, |
910 dest_scan ++; | 1529 void* pIccTransform) // The alpha flag must be fill_flag if exist. |
911 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alph
a); | 1530 { |
912 dest_scan ++; | 1531 m_pDevice = pDevice; |
913 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha)
; | 1532 m_pClipRgn = pClipRgn; |
914 dest_scan ++; | 1533 m_bRgbByteOrder = bRgbByteOrder; |
915 } | 1534 m_pOriDevice = pOriDevice; |
916 } | 1535 m_pDestScan = NULL; |
| 1536 m_pDestExtraAlphaScan = NULL; |
| 1537 m_pOriScan = NULL; |
| 1538 m_pClipScan = NULL; |
| 1539 composite_span = NULL; |
| 1540 if (m_pClipRgn) |
| 1541 m_ClipBox = m_pClipRgn->GetBox(); |
| 1542 else { |
| 1543 m_ClipBox.left = m_ClipBox.top = 0; |
| 1544 m_ClipBox.right = m_pDevice->GetWidth(); |
| 1545 m_ClipBox.bottom = m_pDevice->GetHeight(); |
| 1546 } |
| 1547 m_pClipMask = NULL; |
| 1548 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) { |
| 1549 m_pClipMask = m_pClipRgn->GetMask(); |
| 1550 m_pClipScan = m_pClipMask->GetBuffer(); |
| 1551 } |
| 1552 if (m_pDevice->m_pAlphaMask) |
| 1553 m_pDestExtraAlphaScan = m_pDevice->m_pAlphaMask->GetBuffer(); |
| 1554 if (m_pOriDevice) |
| 1555 m_pOriScan = m_pOriDevice->GetBuffer(); |
| 1556 m_pDestScan = m_pDevice->GetBuffer(); |
| 1557 |
| 1558 m_bFullCover = bFullCover; |
| 1559 |
| 1560 FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag); |
| 1561 FX_BOOL bDeviceCMYK = pDevice->IsCmykImage(); |
| 1562 |
| 1563 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); |
| 1564 |
| 1565 ICodec_IccModule* pIccModule = NULL; |
| 1566 // No lcms engine, we skip the transform |
| 1567 if (!CFX_GEModule::Get()->GetCodecModule() || |
| 1568 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) |
| 1569 pIccTransform = NULL; |
| 1570 else |
| 1571 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
| 1572 |
| 1573 if (m_pDevice->GetBPP() == 8) { // Gray(a) device |
| 1574 ASSERT(!m_bRgbByteOrder); |
| 1575 if (m_pDevice->IsAlphaMask()) { |
| 1576 // Alpha Mask |
| 1577 m_Gray = 255; |
| 1578 } else { |
| 1579 // Gray(a) device |
| 1580 if (pIccTransform) { |
| 1581 uint8_t gray; |
| 1582 color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); |
| 1583 pIccModule->TranslateScanline(pIccTransform, &gray, |
| 1584 (const uint8_t*)&color, 1); |
| 1585 m_Gray = gray; |
| 1586 } else { |
| 1587 if (bObjectCMYK) { |
| 1588 uint8_t r, g, b; |
| 1589 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), |
| 1590 FXSYS_GetYValue(color), FXSYS_GetKValue(color), r, |
| 1591 g, b); |
| 1592 m_Gray = FXRGB2GRAY(r, g, b); |
917 } else { | 1593 } else { |
918 int src_alpha = m_Alpha * cover_scan /255; | 1594 m_Gray = |
919 for (int col = col_start; col < col_end; col ++) { | 1595 FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color)); |
920 int src_alpha1 = src_alpha * clip_scan[col] / 255; | |
921 if (!src_alpha1) { | |
922 dest_scan += 3; | |
923 continue; | |
924 } | |
925 if (src_alpha1 == 255) { | |
926 *dest_scan++ = m_Blue; | |
927 *dest_scan++ = m_Green; | |
928 *dest_scan++ = m_Red; | |
929 } else { | |
930 // Dest format: Rgb | |
931 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_alpha
1); | |
932 dest_scan ++; | |
933 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_alph
a1); | |
934 dest_scan ++; | |
935 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha1
); | |
936 dest_scan ++; | |
937 } | |
938 } | |
939 } | 1596 } |
| 1597 } |
| 1598 } |
| 1599 } else { |
| 1600 if (bDeviceCMYK) { // Cmyk(a) Device |
| 1601 ASSERT(!m_bRgbByteOrder); |
| 1602 // TODO... opt for cmyk |
| 1603 composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK; |
| 1604 if (bObjectCMYK) { |
| 1605 m_Color = FXCMYK_TODIB(color); |
| 1606 if (pIccTransform) |
| 1607 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, |
| 1608 (const uint8_t*)&m_Color, 1); |
| 1609 } else { // Object RGB |
| 1610 if (!pIccTransform) |
| 1611 return FALSE; |
| 1612 color = FXARGB_TODIB(color); |
| 1613 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, |
| 1614 (const uint8_t*)&color, 1); |
| 1615 } |
| 1616 m_Red = ((uint8_t*)&m_Color)[0]; |
| 1617 m_Green = ((uint8_t*)&m_Color)[1]; |
| 1618 m_Blue = ((uint8_t*)&m_Color)[2]; |
| 1619 m_Gray = ((uint8_t*)&m_Color)[3]; |
| 1620 return TRUE; |
| 1621 } |
| 1622 if (pIccTransform) { |
| 1623 color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); |
| 1624 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, |
| 1625 (const uint8_t*)&color, 1); |
| 1626 ((uint8_t*)&m_Color)[3] = m_Alpha; |
| 1627 m_Red = ((uint8_t*)&m_Color)[2]; |
| 1628 m_Green = ((uint8_t*)&m_Color)[1]; |
| 1629 m_Blue = ((uint8_t*)&m_Color)[0]; |
| 1630 // Need Johnson to improvement it. |
| 1631 if (m_bRgbByteOrder) { |
| 1632 // swap |
| 1633 m_Red = ((uint8_t*)&m_Color)[0]; |
| 1634 m_Blue = ((uint8_t*)&m_Color)[2]; |
| 1635 m_Color = FXARGB_TODIB(m_Color); |
| 1636 m_Color = FXARGB_TOBGRORDERDIB(m_Color); |
| 1637 } |
| 1638 } else { |
| 1639 if (bObjectCMYK) { |
| 1640 uint8_t r, g, b; |
| 1641 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), |
| 1642 FXSYS_GetYValue(color), FXSYS_GetKValue(color), r, g, |
| 1643 b); |
| 1644 m_Color = FXARGB_MAKE(m_Alpha, r, g, b); |
| 1645 if (m_bRgbByteOrder) { |
| 1646 m_Color = FXARGB_TOBGRORDERDIB(m_Color); |
| 1647 m_Red = b; |
| 1648 m_Green = g; |
| 1649 m_Blue = r; // |
| 1650 } else { |
| 1651 m_Color = FXARGB_TODIB(m_Color); |
| 1652 m_Red = r; |
| 1653 m_Green = g; |
| 1654 m_Blue = b; // |
| 1655 } |
| 1656 } else { |
| 1657 if (m_bRgbByteOrder) { |
| 1658 m_Color = FXARGB_TOBGRORDERDIB(color); |
| 1659 ArgbDecode(color, m_Alpha, m_Blue, m_Green, m_Red); // |
| 1660 } else { |
| 1661 m_Color = FXARGB_TODIB(color); |
| 1662 ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); |
| 1663 } |
| 1664 } |
| 1665 } |
| 1666 } |
| 1667 // Get palette transparency selector |
| 1668 m_ProcessFilter = |
| 1669 (m_pOriDevice ? 1 : 0) /* has Ori Device flag */ |
| 1670 + (m_pDevice->GetBPP() >= 8 ? 2 : 0) /* bpp flag */ |
| 1671 + (m_pClipMask ? 4 : 0) /* has clip region flag */ |
| 1672 + (m_pDevice->m_pAlphaMask ? 8 : 0); /* has Alpha Mask chanel flag */ |
| 1673 switch (m_ProcessFilter) { |
| 1674 case 0: |
| 1675 composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_0; |
| 1676 break; |
| 1677 case 2: { |
| 1678 if (m_pDevice->GetBPP() == 8) |
| 1679 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_2; |
| 1680 else if (m_pDevice->GetBPP() == 24) |
| 1681 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_2; |
| 1682 else |
| 1683 composite_span = m_pDevice->HasAlpha() |
| 1684 ? &CFX_SkiaRenderer::CompositeSpanARGB_2 |
| 1685 : &CFX_SkiaRenderer::CompositeSpanRGB32_2; |
| 1686 } break; |
| 1687 case 3: { |
| 1688 if (m_pDevice->GetBPP() == 8) |
| 1689 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_3; |
| 1690 else if (m_pDevice->GetBPP() == 24) |
| 1691 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_3; |
| 1692 else |
| 1693 composite_span = m_pDevice->HasAlpha() |
| 1694 ? &CFX_SkiaRenderer::CompositeSpanARGB_3 |
| 1695 : &CFX_SkiaRenderer::CompositeSpanRGB32_3; |
| 1696 } break; |
| 1697 case 4: |
| 1698 composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_4; |
| 1699 break; |
| 1700 case 6: { |
| 1701 if (m_pDevice->GetBPP() == 8) |
| 1702 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_6; |
| 1703 else if (m_pDevice->GetBPP() == 24) |
| 1704 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_6; |
| 1705 else |
| 1706 composite_span = m_pDevice->HasAlpha() |
| 1707 ? &CFX_SkiaRenderer::CompositeSpanARGB_6 |
| 1708 : &CFX_SkiaRenderer::CompositeSpanRGB32_6; |
| 1709 } break; |
| 1710 case 7: { |
| 1711 if (m_pDevice->GetBPP() == 8) |
| 1712 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_7; |
| 1713 else if (m_pDevice->GetBPP() == 24) |
| 1714 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_7; |
| 1715 else |
| 1716 composite_span = m_pDevice->HasAlpha() |
| 1717 ? &CFX_SkiaRenderer::CompositeSpanARGB_7 |
| 1718 : &CFX_SkiaRenderer::CompositeSpanRGB32_7; |
| 1719 } break; |
| 1720 case 1: |
| 1721 case 5: |
| 1722 case 8: |
| 1723 case 9: |
| 1724 case 11: |
| 1725 case 12: |
| 1726 case 13: |
| 1727 case 15: |
| 1728 // TODO... |
| 1729 break; |
| 1730 case 10: |
| 1731 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10; |
| 1732 break; |
| 1733 case 14: |
| 1734 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14; |
| 1735 break; |
| 1736 } |
| 1737 if (composite_span == NULL) |
| 1738 return FALSE; |
| 1739 return TRUE; |
| 1740 } |
| 1741 |
| 1742 /*------------------------------------------------------------------------------
----------------------*/ |
| 1743 void CFX_SkiaA8Renderer::blitAntiH(int x, |
| 1744 int y, |
| 1745 const SkAlpha antialias[], |
| 1746 const int16_t runs[]) { |
| 1747 FXSYS_assert(m_pDevice); |
| 1748 int dst_y = y - m_Top; |
| 1749 if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) |
| 1750 return; |
| 1751 |
| 1752 uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y; |
| 1753 uint8_t* dest_pos = dest_scan; |
| 1754 while (1) { |
| 1755 if (x >= m_dstWidth) |
| 1756 return; |
| 1757 int width = runs[0]; |
| 1758 SkASSERT(width >= 0); |
| 1759 if (width <= 0) |
| 1760 return; |
| 1761 unsigned aa = antialias[0]; |
| 1762 if (aa) { |
| 1763 int col_start = x < m_Left ? 0 : x - m_Left; |
| 1764 int col_end = x + width; |
| 1765 col_end = col_end < m_dstWidth ? col_end - m_Left : m_pDevice->GetWidth(); |
| 1766 int result = col_end - col_start; |
| 1767 if (result > 0) { |
| 1768 dest_pos = dest_scan + col_start; |
| 1769 if (result >= 4) |
| 1770 FXSYS_memset(dest_pos, FXARGB_MAKE(aa, aa, aa, aa), result); |
| 1771 else |
| 1772 FXSYS_memset(dest_pos, aa, result); |
| 1773 } |
| 1774 } |
| 1775 runs += width; |
| 1776 antialias += width; |
| 1777 x += width; |
| 1778 } |
| 1779 } |
| 1780 void CFX_SkiaA8Renderer::blitH(int x, int y, int width) { |
| 1781 FXSYS_assert(m_pDevice); |
| 1782 int dst_y = y - m_Top; |
| 1783 if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) |
| 1784 return; |
| 1785 if (x >= m_dstWidth) |
| 1786 return; |
| 1787 uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * dst_y; |
| 1788 int col_start = x < m_Left ? 0 : x - m_Left; |
| 1789 int col_end = x + width; |
| 1790 col_end = col_end < m_dstWidth ? col_end - m_Left : m_pDevice->GetWidth(); |
| 1791 int result = col_end - col_start; |
| 1792 if (result > 0) { |
| 1793 uint8_t* dest_pos = dest_scan + col_start; |
| 1794 if (result >= 4) |
| 1795 FXSYS_memset(dest_pos, 0xffffffff, result); |
| 1796 else |
| 1797 FXSYS_memset(dest_pos, 255, result); |
| 1798 } |
| 1799 } |
| 1800 void CFX_SkiaA8Renderer::blitV(int x, int y, int height, SkAlpha alpha) { |
| 1801 FXSYS_assert(alpha); |
| 1802 if (alpha == 255) { |
| 1803 blitRect(x, y, 1, height); |
| 1804 } else { |
| 1805 int16_t runs[2]; |
| 1806 runs[0] = 1; |
| 1807 runs[1] = 0; |
| 1808 while (--height >= 0) { |
| 1809 if (y >= m_dstHeight) |
| 1810 return; |
| 1811 blitAntiH(x, y++, &alpha, runs); |
| 1812 } |
| 1813 } |
| 1814 } |
| 1815 void CFX_SkiaA8Renderer::blitRect(int x, int y, int width, int height) { |
| 1816 FXSYS_assert(m_pDevice); |
| 1817 while (--height >= 0) { |
| 1818 if (y >= m_dstHeight) |
| 1819 return; |
| 1820 blitH(x, y++, width); |
| 1821 } |
| 1822 } |
| 1823 |
| 1824 void CFX_SkiaA8Renderer::blitAntiRect(int x, |
| 1825 int y, |
| 1826 int width, |
| 1827 int height, |
| 1828 SkAlpha leftAlpha, |
| 1829 SkAlpha rightAlpha) { |
| 1830 blitV(x++, y, height, leftAlpha); |
| 1831 if (width > 0) { |
| 1832 blitRect(x, y, width, height); |
| 1833 x += width; |
| 1834 } |
| 1835 blitV(x, y, height, rightAlpha); |
| 1836 } |
| 1837 |
| 1838 FX_BOOL CFX_SkiaA8Renderer::Init(CFX_DIBitmap* pDevice, int Left, int Top) { |
| 1839 m_pDevice = pDevice; |
| 1840 m_Left = Left; |
| 1841 m_Top = Top; |
| 1842 if (pDevice) { |
| 1843 m_dstWidth = m_Left + pDevice->GetWidth(); |
| 1844 m_dstHeight = m_Top + pDevice->GetHeight(); |
| 1845 } |
| 1846 return TRUE; |
| 1847 } |
940 #endif | 1848 #endif |
941 } | |
942 void CFX_SkiaRenderer::CompositeSpanRGB24_7(uint8_t* dest_scan, uint8_t* ori
_scan,int Bpp, | |
943 int span_left, int span_len, int span_top, uint8_t cover_scan, | |
944 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | |
945 uint8_t* dest_extra_alpha_scan) | |
946 { | |
947 ASSERT(!m_pDevice->IsCmykImage()); | |
948 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span
_left<<1); | |
949 ori_scan = (uint8_t*)m_pOriDevice->GetScanline(span_top) + span_left+(s
pan_left<<1); | |
950 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | |
951 int col_start = span_left < clip_left ? clip_left - span_left : 0; | |
952 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | |
953 if (col_end < col_start) return; // do nothing. | |
954 dest_scan += col_start + (col_start<<1); | |
955 ori_scan += col_start + (col_start<<1); | |
956 #if 1 | |
957 for (int col = col_start; col < col_end; col ++) { | |
958 int src_alpha = m_Alpha * clip_scan[col] / 255; | |
959 if (src_alpha == 255 && cover_scan == 255) { | |
960 *dest_scan++ = m_Blue; | |
961 *dest_scan++ = m_Green; | |
962 *dest_scan++ = m_Red; | |
963 ori_scan += 3; | |
964 continue; | |
965 } | |
966 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); | |
967 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); | |
968 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); | |
969 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); | |
970 dest_scan ++; | |
971 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); | |
972 dest_scan ++; | |
973 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); | |
974 dest_scan ++; | |
975 } | |
976 #else | |
977 if (m_bFullCover) { | |
978 for (int col = col_start; col < col_end; col ++) { | |
979 int src_alpha = m_Alpha * clip_scan[col] / 255; | |
980 if (!src_alpha){ | |
981 *dest_scan++ = *ori_scan++; | |
982 *dest_scan++ = *ori_scan++; | |
983 *dest_scan++ = *ori_scan++; | |
984 continue; | |
985 } | |
986 if (src_alpha == 255){ | |
987 *dest_scan++ = m_Blue; | |
988 *dest_scan++ = m_Green; | |
989 *dest_scan++ = m_Red; | |
990 ori_scan += 3; | |
991 continue; | |
992 } | |
993 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha)
; | |
994 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha
); | |
995 *dest_scan++ = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); | |
996 } | |
997 } else { | |
998 for (int col = col_start; col < col_end; col ++) { | |
999 int src_alpha = m_Alpha * clip_scan[col] / 255; | |
1000 if (src_alpha == 255 && cover_scan == 255) { | |
1001 *dest_scan++ = m_Blue; | |
1002 *dest_scan++ = m_Green; | |
1003 *dest_scan++ = m_Red; | |
1004 ori_scan += 3; | |
1005 continue; | |
1006 } | |
1007 int b = FXDIB_ALPHA_MERGE(*ori_scan++, m_Blue, src_alpha); | |
1008 int g = FXDIB_ALPHA_MERGE(*ori_scan++, m_Green, src_alpha); | |
1009 int r = FXDIB_ALPHA_MERGE(*ori_scan++, m_Red, src_alpha); | |
1010 *dest_scan = FXDIB_ALPHA_MERGE( *dest_scan, b, cover_scan); | |
1011 dest_scan ++; | |
1012 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, g, cover_scan); | |
1013 dest_scan ++; | |
1014 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, r, cover_scan); | |
1015 dest_scan ++; | |
1016 } | |
1017 } | |
1018 #endif | |
1019 } | |
1020 void CFX_SkiaRenderer::CompositeSpanRGB24_10(uint8_t* dest_scan, uint8_t* or
i_scan,int Bpp, | |
1021 int span_left, int span_len, int span_top, uint8_t cover_scan, | |
1022 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | |
1023 uint8_t* dest_extra_alpha_scan) | |
1024 { | |
1025 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span
_left<<1); | |
1026 dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(
span_top)+span_left; | |
1027 int col_start = span_left < clip_left ? clip_left - span_left : 0; | |
1028 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | |
1029 if (col_end < col_start) return; // do nothing. | |
1030 dest_scan += col_start+(col_start<<1); | |
1031 #if 1 | |
1032 if (m_Alpha == 255 && cover_scan == 255) { | |
1033 for (int col = col_start; col < col_end; col ++) { | |
1034 *dest_scan++ = (uint8_t)m_Blue; | |
1035 *dest_scan++ = (uint8_t)m_Green; | |
1036 *dest_scan++ = (uint8_t)m_Red; | |
1037 *dest_extra_alpha_scan++ = 255; | |
1038 } | |
1039 return; | |
1040 } | |
1041 int src_alpha = m_Alpha * cover_scan / 255; | |
1042 for (int col = col_start; col < col_end; col ++) { | |
1043 // Dest format: Rgba | |
1044 // calculate destination alpha (it's union of source and dest alpha) | |
1045 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - | |
1046 (*dest_extra_alpha_scan) * src_alpha / 255; | |
1047 *dest_extra_alpha_scan++ = dest_alpha; | |
1048 int alpha_ratio = src_alpha*255/dest_alpha; | |
1049 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); | |
1050 dest_scan ++; | |
1051 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); | |
1052 dest_scan ++; | |
1053 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); | |
1054 dest_scan ++; | |
1055 } | |
1056 #else | |
1057 if (m_bFullCover) { | |
1058 if (m_Alpha == 255) { | |
1059 for (int col = col_start; col < col_end; col ++) { | |
1060 *dest_scan++ = (uint8_t)m_Blue; | |
1061 *dest_scan++ = (uint8_t)m_Green; | |
1062 *dest_scan++ = (uint8_t)m_Red; | |
1063 *dest_extra_alpha_scan++ = 255; | |
1064 } | |
1065 return; | |
1066 } | |
1067 for (int col = col_start; col < col_end; col ++) { | |
1068 // Dest format: Rgba | |
1069 // calculate destination alpha (it's union of source and dest al
pha) | |
1070 uint8_t dest_alpha = (*dest_extra_alpha_scan) + m_Alpha - | |
1071 (*dest_extra_alpha_scan) * m_Alpha / 255; | |
1072 *dest_extra_alpha_scan++ = dest_alpha; | |
1073 int alpha_ratio = m_Alpha*255/dest_alpha; | |
1074 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); | |
1075 dest_scan ++; | |
1076 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio)
; | |
1077 dest_scan ++; | |
1078 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); | |
1079 dest_scan ++; | |
1080 } | |
1081 } else { | |
1082 if (m_Alpha == 255 && cover_scan == 255) { | |
1083 for (int col = col_start; col < col_end; col ++) { | |
1084 *dest_scan++ = (uint8_t)m_Blue; | |
1085 *dest_scan++ = (uint8_t)m_Green; | |
1086 *dest_scan++ = (uint8_t)m_Red; | |
1087 *dest_extra_alpha_scan++ = 255; | |
1088 } | |
1089 return; | |
1090 } | |
1091 int src_alpha = m_Alpha * cover_scan / 255; | |
1092 for (int col = col_start; col < col_end; col ++) { | |
1093 // Dest format: Rgba | |
1094 // calculate destination alpha (it's union of source and dest al
pha) | |
1095 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - | |
1096 (*dest_extra_alpha_scan) * src_alpha / 255; | |
1097 *dest_extra_alpha_scan++ = dest_alpha; | |
1098 int alpha_ratio = src_alpha*255/dest_alpha; | |
1099 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); | |
1100 dest_scan ++; | |
1101 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio)
; | |
1102 dest_scan ++; | |
1103 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); | |
1104 dest_scan ++; | |
1105 } | |
1106 } | |
1107 #endif | |
1108 } | |
1109 void CFX_SkiaRenderer::CompositeSpanRGB24_14(uint8_t* dest_scan, uint8_t* or
i_scan,int Bpp, | |
1110 int span_left, int span_len, int span_top, uint8_t cover_scan, | |
1111 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | |
1112 uint8_t* dest_extra_alpha_scan) | |
1113 { | |
1114 dest_scan = (uint8_t*)m_pDevice->GetScanline(span_top) + span_left+(span
_left<<1); | |
1115 dest_extra_alpha_scan = (uint8_t*)m_pDevice->m_pAlphaMask->GetScanline(
span_top)+span_left; | |
1116 clip_scan = (uint8_t*)m_pClipMask->GetScanline(span_top-clip_top) - clip
_left + span_left; | |
1117 int col_start = span_left < clip_left ? clip_left - span_left : 0; | |
1118 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | |
1119 if (col_end < col_start) return; // do nothing. | |
1120 dest_scan += col_start + (col_start << 1); | |
1121 #if 1 | |
1122 int src_alpha = m_Alpha * cover_scan / 255; | |
1123 for (int col = col_start; col < col_end; col ++) { | |
1124 int src_alpha1 = src_alpha * clip_scan[col] / 255; | |
1125 if (!src_alpha1) { | |
1126 dest_extra_alpha_scan++; | |
1127 dest_scan += 3; | |
1128 continue; | |
1129 } | |
1130 if (src_alpha1 == 255) { | |
1131 *dest_scan++ = (uint8_t)m_Blue; | |
1132 *dest_scan++ = (uint8_t)m_Green; | |
1133 *dest_scan++ = (uint8_t)m_Red; | |
1134 *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; | |
1135 } else { | |
1136 // Dest format: Rgba | |
1137 // calculate destination alpha (it's union of source and dest al
pha) | |
1138 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 - | |
1139 (*dest_extra_alpha_scan) * src_alpha1 / 255; | |
1140 *dest_extra_alpha_scan++ = dest_alpha; | |
1141 int alpha_ratio = src_alpha1*255/dest_alpha; | |
1142 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_ratio); | |
1143 dest_scan ++; | |
1144 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio)
; | |
1145 dest_scan ++; | |
1146 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); | |
1147 dest_scan ++; | |
1148 } | |
1149 } | |
1150 #else | |
1151 if (m_bFullCover) { | |
1152 for (int col = col_start; col < col_end; col ++) { | |
1153 int src_alpha = m_Alpha * clip_scan[col] / 255; | |
1154 if (!src_alpha) { | |
1155 dest_extra_alpha_scan++; | |
1156 dest_scan += 3; | |
1157 continue; | |
1158 } | |
1159 if (src_alpha == 255) { | |
1160 *dest_scan++ = (uint8_t)m_Blue; | |
1161 *dest_scan++ = (uint8_t)m_Green; | |
1162 *dest_scan++ = (uint8_t)m_Red; | |
1163 *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; | |
1164 } else { | |
1165 // Dest format: Rgba | |
1166 // calculate destination alpha (it's union of source and des
t alpha) | |
1167 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha - | |
1168 (*dest_extra_alpha_scan) * src_alpha / 2
55; | |
1169 *dest_extra_alpha_scan++ = dest_alpha; | |
1170 int alpha_ratio = src_alpha*255/dest_alpha; | |
1171 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_rat
io); | |
1172 dest_scan ++; | |
1173 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ra
tio); | |
1174 dest_scan ++; | |
1175 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_rati
o); | |
1176 dest_scan ++; | |
1177 } | |
1178 } | |
1179 } else { | |
1180 int src_alpha = m_Alpha * cover_scan / 255; | |
1181 for (int col = col_start; col < col_end; col ++) { | |
1182 int src_alpha1 = m_Alpha * cover_scan * clip_scan[col] / 255; | |
1183 if (!src_alpha1) { | |
1184 dest_extra_alpha_scan++; | |
1185 dest_scan += 3; | |
1186 continue; | |
1187 } | |
1188 if (src_alpha1 == 255) { | |
1189 *dest_scan++ = (uint8_t)m_Blue; | |
1190 *dest_scan++ = (uint8_t)m_Green; | |
1191 *dest_scan++ = (uint8_t)m_Red; | |
1192 *dest_extra_alpha_scan++ = (uint8_t)m_Alpha; | |
1193 } else { | |
1194 // Dest format: Rgba | |
1195 // calculate destination alpha (it's union of source and des
t alpha) | |
1196 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alpha1 - | |
1197 (*dest_extra_alpha_scan) * src_alpha1 /
255; | |
1198 *dest_extra_alpha_scan++ = dest_alpha; | |
1199 int alpha_ratio = src_alpha1*255/dest_alpha; | |
1200 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha_rat
io); | |
1201 dest_scan ++; | |
1202 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ra
tio); | |
1203 dest_scan ++; | |
1204 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_rati
o); | |
1205 dest_scan ++; | |
1206 } | |
1207 } | |
1208 } | |
1209 #endif | |
1210 } | |
1211 /*--------------------------------------------------------------------------
---------------------------*/ | |
1212 | |
1213 // A general alpha merge function (with clipping mask). Cmyka/Cmyk device. | |
1214 void CFX_SkiaRenderer::CompositeSpanCMYK(uint8_t* dest_scan, uint8_t* ori_sc
an,int Bpp, | |
1215 int span_left, int span_len, int span_top, uint8_t cover_scan, | |
1216 int clip_top, int clip_left, int clip_right, uint8_t* clip_scan, | |
1217 uint8_t* dest_extra_alpha_scan) | |
1218 { | |
1219 ASSERT(!m_bRgbByteOrder); | |
1220 // Cmyk(a) | |
1221 int col_start = span_left < clip_left ? clip_left - span_left : 0; | |
1222 int col_end = (span_left + span_len) < clip_right ? span_len : (clip_rig
ht - span_left); | |
1223 if (col_end < col_start) return; // do nothing. | |
1224 dest_scan += col_start * 4; | |
1225 Bpp; // for avoid compile warning. | |
1226 | |
1227 if (dest_extra_alpha_scan) { | |
1228 // CMYKa | |
1229 for (int col = col_start; col < col_end; col ++) { | |
1230 int src_alpha; | |
1231 if (m_bFullCover) { | |
1232 if (clip_scan) | |
1233 src_alpha = m_Alpha * clip_scan[col] / 255; | |
1234 else | |
1235 src_alpha = m_Alpha; | |
1236 } else { | |
1237 if (clip_scan) | |
1238 src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255
/ 255; | |
1239 else | |
1240 src_alpha = m_Alpha * cover_scan / 255; | |
1241 } | |
1242 | |
1243 if (src_alpha) { | |
1244 if (src_alpha == 255) { | |
1245 *(FX_CMYK*)dest_scan = m_Color; | |
1246 *dest_extra_alpha_scan = (uint8_t)m_Alpha; | |
1247 } else { | |
1248 // Dest format: Cmyka | |
1249 // calculate destination alpha (it's union of source and
dest alpha) | |
1250 uint8_t dest_alpha = (*dest_extra_alpha_scan) + src_alph
a - | |
1251 (*dest_extra_alpha_scan) * src_alpha / 255; | |
1252 *dest_extra_alpha_scan++ = dest_alpha; | |
1253 int alpha_ratio = src_alpha*255/dest_alpha; | |
1254 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_
ratio); | |
1255 dest_scan ++; | |
1256 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alph
a_ratio); | |
1257 dest_scan ++; | |
1258 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, alpha
_ratio); | |
1259 dest_scan ++; | |
1260 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, alpha
_ratio); | |
1261 dest_scan ++; | |
1262 continue; | |
1263 } | |
1264 } | |
1265 dest_extra_alpha_scan++; | |
1266 dest_scan += 4; | |
1267 } | |
1268 } else { | |
1269 // CMYK | |
1270 for (int col = col_start; col < col_end; col ++) { | |
1271 int src_alpha; | |
1272 if (clip_scan) | |
1273 src_alpha = m_Alpha * cover_scan * clip_scan[col] / 255 / 25
5; | |
1274 else | |
1275 src_alpha = m_Alpha * cover_scan / 255; | |
1276 | |
1277 if (src_alpha) { | |
1278 if (src_alpha == 255) { | |
1279 *(FX_CMYK*)dest_scan = m_Color; | |
1280 } else { | |
1281 // Dest format: cmyk | |
1282 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_al
pha); | |
1283 dest_scan ++; | |
1284 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, src_
alpha); | |
1285 dest_scan ++; | |
1286 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Blue, src_a
lpha); | |
1287 dest_scan ++; | |
1288 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_a
lpha); | |
1289 dest_scan ++; | |
1290 continue; | |
1291 } | |
1292 } | |
1293 dest_scan += 4; | |
1294 } | |
1295 } | |
1296 } | |
1297 | |
1298 | |
1299 | |
1300 //-------------------------------------------------------------------- | |
1301 FX_BOOL CFX_SkiaRenderer::Init(CFX_DIBitmap* pDevice, CFX_DIBitmap* pOriDevi
ce, const CFX_ClipRgn* pClipRgn, FX_DWORD color, FX_BOOL bFullCover, FX_BOOL bRg
bByteOrder, | |
1302 int alpha_flag, void* pIccTransform) //The alpha flag must be fill_flag
if exist. | |
1303 { | |
1304 m_pDevice = pDevice; | |
1305 m_pClipRgn = pClipRgn; | |
1306 m_bRgbByteOrder = bRgbByteOrder; | |
1307 m_pOriDevice = pOriDevice; | |
1308 m_pDestScan = NULL; | |
1309 m_pDestExtraAlphaScan = NULL; | |
1310 m_pOriScan = NULL; | |
1311 m_pClipScan = NULL; | |
1312 composite_span = NULL; | |
1313 if (m_pClipRgn) | |
1314 m_ClipBox = m_pClipRgn->GetBox(); | |
1315 else { | |
1316 m_ClipBox.left = m_ClipBox.top = 0; | |
1317 m_ClipBox.right = m_pDevice->GetWidth(); | |
1318 m_ClipBox.bottom = m_pDevice->GetHeight(); | |
1319 } | |
1320 m_pClipMask = NULL; | |
1321 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) | |
1322 { | |
1323 m_pClipMask = m_pClipRgn->GetMask(); | |
1324 m_pClipScan = m_pClipMask->GetBuffer(); | |
1325 } | |
1326 if (m_pDevice->m_pAlphaMask) | |
1327 m_pDestExtraAlphaScan = m_pDevice->m_pAlphaMask->GetBuffer(); | |
1328 if (m_pOriDevice) | |
1329 m_pOriScan = m_pOriDevice->GetBuffer(); | |
1330 m_pDestScan = m_pDevice->GetBuffer(); | |
1331 | |
1332 m_bFullCover = bFullCover; | |
1333 | |
1334 FX_BOOL bObjectCMYK = FXGETFLAG_COLORTYPE(alpha_flag); | |
1335 FX_BOOL bDeviceCMYK = pDevice->IsCmykImage(); | |
1336 | |
1337 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(colo
r); | |
1338 | |
1339 ICodec_IccModule* pIccModule = NULL; | |
1340 // No lcms engine, we skip the transform | |
1341 if (!CFX_GEModule::Get()->GetCodecModule() || !CFX_GEModule::Get()->GetC
odecModule()->GetIccModule()) | |
1342 pIccTransform = NULL; | |
1343 else | |
1344 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | |
1345 | |
1346 if (m_pDevice->GetBPP() == 8) { // Gray(a) device | |
1347 ASSERT(!m_bRgbByteOrder); | |
1348 if (m_pDevice->IsAlphaMask()) { | |
1349 //Alpha Mask | |
1350 m_Gray = 255; | |
1351 } else { | |
1352 //Gray(a) device | |
1353 if (pIccTransform) { | |
1354 uint8_t gray; | |
1355 color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(col
or); | |
1356 pIccModule->TranslateScanline(pIccTransform, &gray, (const u
int8_t*)&color, 1); | |
1357 m_Gray = gray; | |
1358 } else { | |
1359 if (bObjectCMYK) { | |
1360 uint8_t r, g, b; | |
1361 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMVal
ue(color), FXSYS_GetYValue(color), FXSYS_GetKValue(color), | |
1362 r, g, b); | |
1363 m_Gray = FXRGB2GRAY(r, g, b); | |
1364 } else { | |
1365 m_Gray = FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FX
ARGB_B(color)); | |
1366 } | |
1367 } | |
1368 } | |
1369 } else { | |
1370 if (bDeviceCMYK) { // Cmyk(a) Device | |
1371 ASSERT(!m_bRgbByteOrder); | |
1372 //TODO... opt for cmyk | |
1373 composite_span = &CFX_SkiaRenderer::CompositeSpanCMYK; | |
1374 if (bObjectCMYK) { | |
1375 m_Color = FXCMYK_TODIB(color); | |
1376 if (pIccTransform) | |
1377 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&
m_Color, (const uint8_t*)&m_Color, 1); | |
1378 } else { // Object RGB | |
1379 if (!pIccTransform) | |
1380 return FALSE; | |
1381 color = FXARGB_TODIB(color); | |
1382 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Co
lor, (const uint8_t*)&color, 1); | |
1383 } | |
1384 m_Red = ((uint8_t*)&m_Color)[0]; | |
1385 m_Green = ((uint8_t*)&m_Color)[1]; | |
1386 m_Blue = ((uint8_t*)&m_Color)[2]; | |
1387 m_Gray = ((uint8_t*)&m_Color)[3]; | |
1388 return TRUE; | |
1389 } | |
1390 if (pIccTransform) { | |
1391 color = bObjectCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); | |
1392 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color,
(const uint8_t*)&color, 1); | |
1393 ((uint8_t*)&m_Color)[3] = m_Alpha; | |
1394 m_Red = ((uint8_t*)&m_Color)[2]; | |
1395 m_Green = ((uint8_t*)&m_Color)[1]; | |
1396 m_Blue = ((uint8_t*)&m_Color)[0]; | |
1397 // Need Johnson to improvement it. | |
1398 if (m_bRgbByteOrder) { | |
1399 // swap | |
1400 m_Red = ((uint8_t*)&m_Color)[0]; | |
1401 m_Blue = ((uint8_t*)&m_Color)[2]; | |
1402 m_Color = FXARGB_TODIB(m_Color); | |
1403 m_Color = FXARGB_TOBGRORDERDIB(m_Color); | |
1404 } | |
1405 } else { | |
1406 if (bObjectCMYK) { | |
1407 uint8_t r, g, b; | |
1408 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(c
olor), FXSYS_GetYValue(color), FXSYS_GetKValue(color), | |
1409 r, g, b); | |
1410 m_Color = FXARGB_MAKE(m_Alpha, r, g, b); | |
1411 if (m_bRgbByteOrder){ | |
1412 m_Color = FXARGB_TOBGRORDERDIB(m_Color); | |
1413 m_Red = b; m_Green = g; m_Blue = r;// | |
1414 }else { | |
1415 m_Color = FXARGB_TODIB(m_Color); | |
1416 m_Red = r; m_Green = g; m_Blue = b;// | |
1417 } | |
1418 } else { | |
1419 if (m_bRgbByteOrder){ | |
1420 m_Color = FXARGB_TOBGRORDERDIB(color); | |
1421 ArgbDecode(color, m_Alpha, m_Blue, m_Green, m_Red); // | |
1422 }else { | |
1423 m_Color = FXARGB_TODIB(color); | |
1424 ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); | |
1425 } | |
1426 } | |
1427 } | |
1428 } | |
1429 // Get palette transparency selector | |
1430 m_ProcessFilter = (m_pOriDevice? 1 : 0) /* has Ori Device flag */ | |
1431 + (m_pDevice->GetBPP() >= 8 ? 2 : 0) /* bpp flag */ | |
1432 + (m_pClipMask? 4 : 0) /* has clip regi
on flag */ | |
1433 + (m_pDevice->m_pAlphaMask? 8 : 0); /* has Alpha Mas
k chanel flag */ | |
1434 switch(m_ProcessFilter) { | |
1435 case 0: | |
1436 composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_0; | |
1437 break; | |
1438 case 2: | |
1439 { | |
1440 if (m_pDevice->GetBPP() == 8) | |
1441 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_2; | |
1442 else if (m_pDevice->GetBPP() == 24) | |
1443 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_2
; | |
1444 else | |
1445 composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer
::CompositeSpanARGB_2 : &CFX_SkiaRenderer::CompositeSpanRGB32_2; | |
1446 } | |
1447 break; | |
1448 case 3: | |
1449 { | |
1450 if (m_pDevice->GetBPP() == 8) | |
1451 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_3; | |
1452 else if (m_pDevice->GetBPP() == 24) | |
1453 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_3
; | |
1454 else | |
1455 composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer
::CompositeSpanARGB_3 : &CFX_SkiaRenderer::CompositeSpanRGB32_3; | |
1456 } | |
1457 break; | |
1458 case 4: | |
1459 composite_span = &CFX_SkiaRenderer::CompositeSpan1bpp_4; | |
1460 break; | |
1461 case 6: | |
1462 { | |
1463 if (m_pDevice->GetBPP() == 8) | |
1464 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_6; | |
1465 else if (m_pDevice->GetBPP() == 24) | |
1466 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_6
; | |
1467 else | |
1468 composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer
::CompositeSpanARGB_6 : &CFX_SkiaRenderer::CompositeSpanRGB32_6; | |
1469 } | |
1470 break; | |
1471 case 7: | |
1472 { | |
1473 if (m_pDevice->GetBPP() == 8) | |
1474 composite_span = &CFX_SkiaRenderer::CompositeSpanGray_7; | |
1475 else if (m_pDevice->GetBPP() == 24) | |
1476 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_7
; | |
1477 else | |
1478 composite_span = m_pDevice->HasAlpha()?&CFX_SkiaRenderer
::CompositeSpanARGB_7 : &CFX_SkiaRenderer::CompositeSpanRGB32_7; | |
1479 } | |
1480 break; | |
1481 case 1: | |
1482 case 5: | |
1483 case 8: | |
1484 case 9: | |
1485 case 11: | |
1486 case 12: | |
1487 case 13: | |
1488 case 15: | |
1489 //TODO... | |
1490 break; | |
1491 case 10: | |
1492 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_10; | |
1493 break; | |
1494 case 14: | |
1495 composite_span = &CFX_SkiaRenderer::CompositeSpanRGB24_14; | |
1496 break; | |
1497 } | |
1498 if (composite_span == NULL) | |
1499 return FALSE; | |
1500 return TRUE; | |
1501 } | |
1502 | |
1503 /*--------------------------------------------------------------------------
--------------------------*/ | |
1504 void CFX_SkiaA8Renderer::blitAntiH(int x, int y, const SkAlpha antialias[],
const int16_t runs[]) | |
1505 { | |
1506 FXSYS_assert(m_pDevice); | |
1507 int dst_y = y - m_Top; | |
1508 if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) | |
1509 return; | |
1510 | |
1511 uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * ds
t_y; | |
1512 uint8_t* dest_pos = dest_scan; | |
1513 while (1) | |
1514 { | |
1515 if (x >= m_dstWidth) | |
1516 return; | |
1517 int width = runs[0]; | |
1518 SkASSERT(width >= 0); | |
1519 if (width <= 0) | |
1520 return; | |
1521 unsigned aa = antialias[0]; | |
1522 if (aa) { | |
1523 int col_start = x < m_Left ? 0 : x - m_Left; | |
1524 int col_end = x + width; | |
1525 col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->Ge
tWidth(); | |
1526 int result = col_end - col_start; | |
1527 if (result > 0) { | |
1528 dest_pos = dest_scan + col_start; | |
1529 if (result >= 4) | |
1530 FXSYS_memset(dest_pos, FXARGB_MAKE(aa, aa, aa, aa),resul
t); | |
1531 else | |
1532 FXSYS_memset(dest_pos,aa,result); | |
1533 } | |
1534 } | |
1535 runs += width; | |
1536 antialias += width; | |
1537 x += width; | |
1538 } | |
1539 } | |
1540 void CFX_SkiaA8Renderer::blitH(int x, int y, int width) | |
1541 { | |
1542 FXSYS_assert(m_pDevice); | |
1543 int dst_y = y - m_Top; | |
1544 if (dst_y < 0 || dst_y >= m_pDevice->GetHeight()) | |
1545 return; | |
1546 if (x >= m_dstWidth) | |
1547 return; | |
1548 uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * ds
t_y; | |
1549 int col_start = x < m_Left ? 0 : x - m_Left; | |
1550 int col_end = x + width; | |
1551 col_end = col_end < m_dstWidth ? col_end - m_Left: m_pDevice->GetWidth()
; | |
1552 int result = col_end - col_start; | |
1553 if (result > 0) { | |
1554 uint8_t* dest_pos = dest_scan + col_start; | |
1555 if (result >= 4) | |
1556 FXSYS_memset(dest_pos, 0xffffffff,result); | |
1557 else | |
1558 FXSYS_memset(dest_pos,255,result); | |
1559 } | |
1560 } | |
1561 void CFX_SkiaA8Renderer::blitV(int x, int y, int height, SkAlpha alpha) | |
1562 { | |
1563 FXSYS_assert(alpha); | |
1564 if (alpha == 255) { | |
1565 blitRect(x, y, 1, height); | |
1566 } else { | |
1567 int16_t runs[2]; | |
1568 runs[0] = 1; | |
1569 runs[1] = 0; | |
1570 while (--height >= 0) { | |
1571 if (y >= m_dstHeight) | |
1572 return; | |
1573 blitAntiH(x, y ++, &alpha, runs); | |
1574 } | |
1575 } | |
1576 } | |
1577 void CFX_SkiaA8Renderer::blitRect(int x, int y, int width, int height) | |
1578 { | |
1579 FXSYS_assert(m_pDevice); | |
1580 while (--height >= 0) { | |
1581 if (y >= m_dstHeight) | |
1582 return; | |
1583 blitH(x , y ++, width); | |
1584 } | |
1585 } | |
1586 | |
1587 void CFX_SkiaA8Renderer::blitAntiRect(int x, int y, int width, int height, | |
1588 SkAlpha leftAlpha, SkAlpha rightAlpha) | |
1589 { | |
1590 blitV(x++, y, height, leftAlpha); | |
1591 if (width > 0) { | |
1592 blitRect(x, y, width, height); | |
1593 x += width; | |
1594 } | |
1595 blitV(x, y, height, rightAlpha); | |
1596 } | |
1597 | |
1598 FX_BOOL CFX_SkiaA8Renderer::Init(CFX_DIBitmap* pDevice, int Left, int Top) | |
1599 { | |
1600 m_pDevice = pDevice; | |
1601 m_Left = Left; | |
1602 m_Top = Top; | |
1603 if (pDevice){ | |
1604 m_dstWidth = m_Left + pDevice->GetWidth(); | |
1605 m_dstHeight = m_Top + pDevice->GetHeight(); | |
1606 } | |
1607 return TRUE; | |
1608 } | |
1609 #endif | |
OLD | NEW |