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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "core/src/fxge/agg/include/fx_agg_driver.h" | 7 #include "core/src/fxge/agg/fx_agg_driver.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "core/include/fxcodec/fx_codec.h" | 11 #include "core/include/fxcodec/fx_codec.h" |
12 #include "core/include/fxge/fx_ge.h" | 12 #include "core/include/fxge/fx_ge.h" |
13 #include "core/src/fxge/dib/dib_int.h" | 13 #include "core/src/fxge/dib/dib_int.h" |
14 #include "core/src/fxge/ge/fx_text_int.h" | 14 #include "core/src/fxge/ge/fx_text_int.h" |
15 #include "third_party/agg23/agg_conv_dash.h" | 15 #include "third_party/agg23/agg_conv_dash.h" |
16 #include "third_party/agg23/agg_conv_stroke.h" | 16 #include "third_party/agg23/agg_conv_stroke.h" |
17 #include "third_party/agg23/agg_curves.h" | 17 #include "third_party/agg23/agg_curves.h" |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 rasterizer.add_path_transformed(stroke, pObject2Device); | 176 rasterizer.add_path_transformed(stroke, pObject2Device); |
177 } else { | 177 } else { |
178 agg::conv_stroke<agg::path_storage> stroke(path_data); | 178 agg::conv_stroke<agg::path_storage> stroke(path_data); |
179 stroke.line_join(join); | 179 stroke.line_join(join); |
180 stroke.line_cap(cap); | 180 stroke.line_cap(cap); |
181 stroke.miter_limit(pGraphState->m_MiterLimit); | 181 stroke.miter_limit(pGraphState->m_MiterLimit); |
182 stroke.width(width); | 182 stroke.width(width); |
183 rasterizer.add_path_transformed(stroke, pObject2Device); | 183 rasterizer.add_path_transformed(stroke, pObject2Device); |
184 } | 184 } |
185 } | 185 } |
| 186 |
186 IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver( | 187 IFX_RenderDeviceDriver* IFX_RenderDeviceDriver::CreateFxgeDriver( |
187 CFX_DIBitmap* pBitmap, | 188 CFX_DIBitmap* pBitmap, |
188 FX_BOOL bRgbByteOrder, | 189 FX_BOOL bRgbByteOrder, |
189 CFX_DIBitmap* pOriDevice, | 190 CFX_DIBitmap* pOriDevice, |
190 FX_BOOL bGroupKnockout) { | 191 FX_BOOL bGroupKnockout) { |
191 return new CFX_AggDeviceDriver(pBitmap, 0, bRgbByteOrder, pOriDevice, | 192 return new CFX_AggDeviceDriver(pBitmap, 0, bRgbByteOrder, pOriDevice, |
192 bGroupKnockout); | 193 bGroupKnockout); |
193 } | 194 } |
| 195 |
194 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, | 196 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, |
195 int dither_bits, | 197 int dither_bits, |
196 FX_BOOL bRgbByteOrder, | 198 FX_BOOL bRgbByteOrder, |
197 CFX_DIBitmap* pOriDevice, | 199 CFX_DIBitmap* pOriDevice, |
198 FX_BOOL bGroupKnockout) { | 200 FX_BOOL bGroupKnockout) { |
199 m_pBitmap = pBitmap; | 201 m_pBitmap = pBitmap; |
200 m_DitherBits = dither_bits; | 202 m_DitherBits = dither_bits; |
201 m_pClipRgn = NULL; | 203 m_pClipRgn = NULL; |
202 m_pPlatformBitmap = NULL; | 204 m_pPlatformBitmap = NULL; |
203 m_pPlatformGraphics = NULL; | 205 m_pPlatformGraphics = NULL; |
204 m_pDwRenderTartget = NULL; | 206 m_pDwRenderTartget = NULL; |
205 m_bRgbByteOrder = bRgbByteOrder; | 207 m_bRgbByteOrder = bRgbByteOrder; |
206 m_pOriDevice = pOriDevice; | 208 m_pOriDevice = pOriDevice; |
207 m_bGroupKnockout = bGroupKnockout; | 209 m_bGroupKnockout = bGroupKnockout; |
208 m_FillFlags = 0; | 210 m_FillFlags = 0; |
209 InitPlatform(); | 211 InitPlatform(); |
210 } | 212 } |
| 213 |
211 CFX_AggDeviceDriver::~CFX_AggDeviceDriver() { | 214 CFX_AggDeviceDriver::~CFX_AggDeviceDriver() { |
212 delete m_pClipRgn; | 215 delete m_pClipRgn; |
213 for (int i = 0; i < m_StateStack.GetSize(); i++) | 216 for (int i = 0; i < m_StateStack.GetSize(); i++) |
214 delete m_StateStack[i]; | 217 delete m_StateStack[i]; |
215 DestroyPlatform(); | 218 DestroyPlatform(); |
216 } | 219 } |
| 220 |
| 221 uint8_t* CFX_AggDeviceDriver::GetBuffer() const { |
| 222 return m_pBitmap->GetBuffer(); |
| 223 } |
| 224 |
217 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 225 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
218 void CFX_AggDeviceDriver::InitPlatform() {} | 226 void CFX_AggDeviceDriver::InitPlatform() {} |
| 227 |
219 void CFX_AggDeviceDriver::DestroyPlatform() {} | 228 void CFX_AggDeviceDriver::DestroyPlatform() {} |
| 229 |
220 FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, | 230 FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, |
221 const FXTEXT_CHARPOS* pCharPos, | 231 const FXTEXT_CHARPOS* pCharPos, |
222 CFX_Font* pFont, | 232 CFX_Font* pFont, |
223 CFX_FontCache* pCache, | 233 CFX_FontCache* pCache, |
224 const CFX_Matrix* pObject2Device, | 234 const CFX_Matrix* pObject2Device, |
225 FX_FLOAT font_size, | 235 FX_FLOAT font_size, |
226 FX_DWORD color, | 236 FX_DWORD color, |
227 int alpha_flag, | 237 int alpha_flag, |
228 void* pIccTransform) { | 238 void* pIccTransform) { |
229 return FALSE; | 239 return FALSE; |
230 } | 240 } // _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
231 #endif | 241 #endif |
| 242 |
232 int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) { | 243 int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) { |
233 switch (caps_id) { | 244 switch (caps_id) { |
234 case FXDC_DEVICE_CLASS: | 245 case FXDC_DEVICE_CLASS: |
235 return FXDC_DISPLAY; | 246 return FXDC_DISPLAY; |
236 case FXDC_PIXEL_WIDTH: | 247 case FXDC_PIXEL_WIDTH: |
237 return m_pBitmap->GetWidth(); | 248 return m_pBitmap->GetWidth(); |
238 case FXDC_PIXEL_HEIGHT: | 249 case FXDC_PIXEL_HEIGHT: |
239 return m_pBitmap->GetHeight(); | 250 return m_pBitmap->GetHeight(); |
240 case FXDC_BITS_PIXEL: | 251 case FXDC_BITS_PIXEL: |
241 return m_pBitmap->GetBPP(); | 252 return m_pBitmap->GetBPP(); |
(...skipping 15 matching lines...) Expand all Loading... |
257 if (m_pBitmap->IsCmykImage()) { | 268 if (m_pBitmap->IsCmykImage()) { |
258 flags |= FXRC_CMYK_OUTPUT; | 269 flags |= FXRC_CMYK_OUTPUT; |
259 } | 270 } |
260 return flags; | 271 return flags; |
261 } | 272 } |
262 case FXDC_DITHER_BITS: | 273 case FXDC_DITHER_BITS: |
263 return m_DitherBits; | 274 return m_DitherBits; |
264 } | 275 } |
265 return 0; | 276 return 0; |
266 } | 277 } |
| 278 |
267 void CFX_AggDeviceDriver::SaveState() { | 279 void CFX_AggDeviceDriver::SaveState() { |
268 CFX_ClipRgn* pClip = NULL; | 280 CFX_ClipRgn* pClip = NULL; |
269 if (m_pClipRgn) { | 281 if (m_pClipRgn) { |
270 pClip = new CFX_ClipRgn(*m_pClipRgn); | 282 pClip = new CFX_ClipRgn(*m_pClipRgn); |
271 } | 283 } |
272 m_StateStack.Add(pClip); | 284 m_StateStack.Add(pClip); |
273 } | 285 } |
| 286 |
274 void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) { | 287 void CFX_AggDeviceDriver::RestoreState(FX_BOOL bKeepSaved) { |
275 if (m_StateStack.GetSize() == 0) { | 288 if (m_StateStack.GetSize() == 0) { |
276 delete m_pClipRgn; | 289 delete m_pClipRgn; |
277 m_pClipRgn = NULL; | 290 m_pClipRgn = NULL; |
278 return; | 291 return; |
279 } | 292 } |
280 CFX_ClipRgn* pSavedClip = m_StateStack[m_StateStack.GetSize() - 1]; | 293 CFX_ClipRgn* pSavedClip = m_StateStack[m_StateStack.GetSize() - 1]; |
281 delete m_pClipRgn; | 294 delete m_pClipRgn; |
282 m_pClipRgn = NULL; | 295 m_pClipRgn = NULL; |
283 if (bKeepSaved) { | 296 if (bKeepSaved) { |
284 if (pSavedClip) { | 297 if (pSavedClip) { |
285 m_pClipRgn = new CFX_ClipRgn(*pSavedClip); | 298 m_pClipRgn = new CFX_ClipRgn(*pSavedClip); |
286 } | 299 } |
287 } else { | 300 } else { |
288 m_StateStack.RemoveAt(m_StateStack.GetSize() - 1); | 301 m_StateStack.RemoveAt(m_StateStack.GetSize() - 1); |
289 m_pClipRgn = pSavedClip; | 302 m_pClipRgn = pSavedClip; |
290 } | 303 } |
291 } | 304 } |
| 305 |
292 void CFX_AggDeviceDriver::SetClipMask(agg::rasterizer_scanline_aa& rasterizer) { | 306 void CFX_AggDeviceDriver::SetClipMask(agg::rasterizer_scanline_aa& rasterizer) { |
293 FX_RECT path_rect(rasterizer.min_x(), rasterizer.min_y(), | 307 FX_RECT path_rect(rasterizer.min_x(), rasterizer.min_y(), |
294 rasterizer.max_x() + 1, rasterizer.max_y() + 1); | 308 rasterizer.max_x() + 1, rasterizer.max_y() + 1); |
295 path_rect.Intersect(m_pClipRgn->GetBox()); | 309 path_rect.Intersect(m_pClipRgn->GetBox()); |
296 CFX_DIBitmapRef mask; | 310 CFX_DIBitmapRef mask; |
297 CFX_DIBitmap* pThisLayer = mask.New(); | 311 CFX_DIBitmap* pThisLayer = mask.New(); |
298 if (!pThisLayer) { | 312 if (!pThisLayer) { |
299 return; | 313 return; |
300 } | 314 } |
301 pThisLayer->Create(path_rect.Width(), path_rect.Height(), FXDIB_8bppMask); | 315 pThisLayer->Create(path_rect.Width(), path_rect.Height(), FXDIB_8bppMask); |
302 pThisLayer->Clear(0); | 316 pThisLayer->Clear(0); |
303 agg::rendering_buffer raw_buf(pThisLayer->GetBuffer(), pThisLayer->GetWidth(), | 317 agg::rendering_buffer raw_buf(pThisLayer->GetBuffer(), pThisLayer->GetWidth(), |
304 pThisLayer->GetHeight(), | 318 pThisLayer->GetHeight(), |
305 pThisLayer->GetPitch()); | 319 pThisLayer->GetPitch()); |
306 agg::pixfmt_gray8 pixel_buf(raw_buf); | 320 agg::pixfmt_gray8 pixel_buf(raw_buf); |
307 agg::renderer_base<agg::pixfmt_gray8> base_buf(pixel_buf); | 321 agg::renderer_base<agg::pixfmt_gray8> base_buf(pixel_buf); |
308 agg::renderer_scanline_aa_offset<agg::renderer_base<agg::pixfmt_gray8> > | 322 agg::renderer_scanline_aa_offset<agg::renderer_base<agg::pixfmt_gray8> > |
309 final_render(base_buf, path_rect.left, path_rect.top); | 323 final_render(base_buf, path_rect.left, path_rect.top); |
310 final_render.color(agg::gray8(255)); | 324 final_render.color(agg::gray8(255)); |
311 agg::scanline_u8 scanline; | 325 agg::scanline_u8 scanline; |
312 agg::render_scanlines(rasterizer, scanline, final_render, | 326 agg::render_scanlines(rasterizer, scanline, final_render, |
313 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); | 327 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); |
314 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); | 328 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); |
315 } | 329 } |
| 330 |
316 FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, | 331 FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, |
317 const CFX_Matrix* pObject2Device, | 332 const CFX_Matrix* pObject2Device, |
318 int fill_mode) { | 333 int fill_mode) { |
319 m_FillFlags = fill_mode; | 334 m_FillFlags = fill_mode; |
320 if (!m_pClipRgn) { | 335 if (!m_pClipRgn) { |
321 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), | 336 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), |
322 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 337 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
323 } | 338 } |
324 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { | 339 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { |
325 CFX_FloatRect rectf; | 340 CFX_FloatRect rectf; |
(...skipping 12 matching lines...) Expand all Loading... |
338 agg::rasterizer_scanline_aa rasterizer; | 353 agg::rasterizer_scanline_aa rasterizer; |
339 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), | 354 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), |
340 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 355 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
341 rasterizer.add_path(path_data.m_PathData); | 356 rasterizer.add_path(path_data.m_PathData); |
342 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING | 357 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING |
343 ? agg::fill_non_zero | 358 ? agg::fill_non_zero |
344 : agg::fill_even_odd); | 359 : agg::fill_even_odd); |
345 SetClipMask(rasterizer); | 360 SetClipMask(rasterizer); |
346 return TRUE; | 361 return TRUE; |
347 } | 362 } |
| 363 |
348 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke( | 364 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke( |
349 const CFX_PathData* pPathData, | 365 const CFX_PathData* pPathData, |
350 const CFX_Matrix* pObject2Device, | 366 const CFX_Matrix* pObject2Device, |
351 const CFX_GraphStateData* pGraphState) { | 367 const CFX_GraphStateData* pGraphState) { |
352 if (!m_pClipRgn) { | 368 if (!m_pClipRgn) { |
353 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), | 369 m_pClipRgn = new CFX_ClipRgn(GetDeviceCaps(FXDC_PIXEL_WIDTH), |
354 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 370 GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
355 } | 371 } |
356 CAgg_PathData path_data; | 372 CAgg_PathData path_data; |
357 path_data.BuildPath(pPathData, NULL); | 373 path_data.BuildPath(pPathData, NULL); |
358 agg::rasterizer_scanline_aa rasterizer; | 374 agg::rasterizer_scanline_aa rasterizer; |
359 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), | 375 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), |
360 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 376 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
361 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, | 377 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, |
362 pGraphState); | 378 pGraphState); |
363 rasterizer.filling_rule(agg::fill_non_zero); | 379 rasterizer.filling_rule(agg::fill_non_zero); |
364 SetClipMask(rasterizer); | 380 SetClipMask(rasterizer); |
365 return TRUE; | 381 return TRUE; |
366 } | 382 } |
| 383 |
367 class CFX_Renderer { | 384 class CFX_Renderer { |
368 private: | 385 private: |
369 int m_Alpha, m_Red, m_Green, m_Blue, m_Gray; | 386 int m_Alpha, m_Red, m_Green, m_Blue, m_Gray; |
370 FX_DWORD m_Color; | 387 FX_DWORD m_Color; |
371 FX_BOOL m_bFullCover; | 388 FX_BOOL m_bFullCover; |
372 FX_BOOL m_bRgbByteOrder; | 389 FX_BOOL m_bRgbByteOrder; |
373 CFX_DIBitmap* m_pOriDevice; | 390 CFX_DIBitmap* m_pOriDevice; |
374 FX_RECT m_ClipBox; | 391 FX_RECT m_ClipBox; |
375 const CFX_DIBitmap* m_pClipMask; | 392 const CFX_DIBitmap* m_pClipMask; |
376 CFX_DIBitmap* m_pDevice; | 393 CFX_DIBitmap* m_pDevice; |
377 const CFX_ClipRgn* m_pClipRgn; | 394 const CFX_ClipRgn* m_pClipRgn; |
378 void (CFX_Renderer::*composite_span)(uint8_t*, | 395 void (CFX_Renderer::*composite_span)(uint8_t*, |
379 int, | 396 int, |
380 int, | 397 int, |
381 int, | 398 int, |
382 uint8_t*, | 399 uint8_t*, |
383 int, | 400 int, |
384 int, | 401 int, |
385 uint8_t*, | 402 uint8_t*, |
386 uint8_t*); | 403 uint8_t*); |
387 | 404 |
388 public: | 405 public: |
389 void prepare(unsigned) {} | 406 void prepare(unsigned) {} |
| 407 |
390 void CompositeSpan(uint8_t* dest_scan, | 408 void CompositeSpan(uint8_t* dest_scan, |
391 uint8_t* ori_scan, | 409 uint8_t* ori_scan, |
392 int Bpp, | 410 int Bpp, |
393 FX_BOOL bDestAlpha, | 411 FX_BOOL bDestAlpha, |
394 int span_left, | 412 int span_left, |
395 int span_len, | 413 int span_len, |
396 uint8_t* cover_scan, | 414 uint8_t* cover_scan, |
397 int clip_left, | 415 int clip_left, |
398 int clip_right, | 416 int clip_right, |
399 uint8_t* clip_scan) { | 417 uint8_t* clip_scan) { |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 if (!index) { | 593 if (!index) { |
576 *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); | 594 *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); |
577 } else { | 595 } else { |
578 *dest_scan1 |= 1 << (7 - (col + span_left) % 8); | 596 *dest_scan1 |= 1 << (7 - (col + span_left) % 8); |
579 } | 597 } |
580 } | 598 } |
581 dest_scan1 = dest_scan + (span_left % 8 + col - col_start + 1) / 8; | 599 dest_scan1 = dest_scan + (span_left % 8 + col - col_start + 1) / 8; |
582 } | 600 } |
583 } | 601 } |
584 } | 602 } |
| 603 |
585 void CompositeSpan1bpp(uint8_t* dest_scan, | 604 void CompositeSpan1bpp(uint8_t* dest_scan, |
586 int Bpp, | 605 int Bpp, |
587 int span_left, | 606 int span_left, |
588 int span_len, | 607 int span_len, |
589 uint8_t* cover_scan, | 608 uint8_t* cover_scan, |
590 int clip_left, | 609 int clip_left, |
591 int clip_right, | 610 int clip_right, |
592 uint8_t* clip_scan, | 611 uint8_t* clip_scan, |
593 uint8_t* dest_extra_alpha_scan) { | 612 uint8_t* dest_extra_alpha_scan) { |
594 ASSERT(!m_bRgbByteOrder); | 613 ASSERT(!m_bRgbByteOrder); |
(...skipping 24 matching lines...) Expand all Loading... |
619 if (src_alpha) { | 638 if (src_alpha) { |
620 if (!index) { | 639 if (!index) { |
621 *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); | 640 *dest_scan1 &= ~(1 << (7 - (col + span_left) % 8)); |
622 } else { | 641 } else { |
623 *dest_scan1 |= 1 << (7 - (col + span_left) % 8); | 642 *dest_scan1 |= 1 << (7 - (col + span_left) % 8); |
624 } | 643 } |
625 } | 644 } |
626 dest_scan1 = dest_scan + (span_left % 8 + col - col_start + 1) / 8; | 645 dest_scan1 = dest_scan + (span_left % 8 + col - col_start + 1) / 8; |
627 } | 646 } |
628 } | 647 } |
| 648 |
629 void CompositeSpanGray(uint8_t* dest_scan, | 649 void CompositeSpanGray(uint8_t* dest_scan, |
630 int Bpp, | 650 int Bpp, |
631 int span_left, | 651 int span_left, |
632 int span_len, | 652 int span_len, |
633 uint8_t* cover_scan, | 653 uint8_t* cover_scan, |
634 int clip_left, | 654 int clip_left, |
635 int clip_right, | 655 int clip_right, |
636 uint8_t* clip_scan, | 656 uint8_t* clip_scan, |
637 uint8_t* dest_extra_alpha_scan) { | 657 uint8_t* dest_extra_alpha_scan) { |
638 ASSERT(!m_bRgbByteOrder); | 658 ASSERT(!m_bRgbByteOrder); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 if (src_alpha == 255) { | 706 if (src_alpha == 255) { |
687 *dest_scan = m_Gray; | 707 *dest_scan = m_Gray; |
688 } else { | 708 } else { |
689 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); | 709 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); |
690 } | 710 } |
691 } | 711 } |
692 dest_scan++; | 712 dest_scan++; |
693 } | 713 } |
694 } | 714 } |
695 } | 715 } |
| 716 |
696 void CompositeSpanARGB(uint8_t* dest_scan, | 717 void CompositeSpanARGB(uint8_t* dest_scan, |
697 int Bpp, | 718 int Bpp, |
698 int span_left, | 719 int span_left, |
699 int span_len, | 720 int span_len, |
700 uint8_t* cover_scan, | 721 uint8_t* cover_scan, |
701 int clip_left, | 722 int clip_left, |
702 int clip_right, | 723 int clip_right, |
703 uint8_t* clip_scan, | 724 uint8_t* clip_scan, |
704 uint8_t* dest_extra_alpha_scan) { | 725 uint8_t* dest_extra_alpha_scan) { |
705 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 726 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); | 801 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Green, alpha_ratio); |
781 dest_scan++; | 802 dest_scan++; |
782 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); | 803 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, alpha_ratio); |
783 dest_scan += 2; | 804 dest_scan += 2; |
784 continue; | 805 continue; |
785 } | 806 } |
786 } | 807 } |
787 dest_scan += Bpp; | 808 dest_scan += Bpp; |
788 } | 809 } |
789 } | 810 } |
| 811 |
790 void CompositeSpanRGB(uint8_t* dest_scan, | 812 void CompositeSpanRGB(uint8_t* dest_scan, |
791 int Bpp, | 813 int Bpp, |
792 int span_left, | 814 int span_left, |
793 int span_len, | 815 int span_len, |
794 uint8_t* cover_scan, | 816 uint8_t* cover_scan, |
795 int clip_left, | 817 int clip_left, |
796 int clip_right, | 818 int clip_right, |
797 uint8_t* clip_scan, | 819 uint8_t* clip_scan, |
798 uint8_t* dest_extra_alpha_scan) { | 820 uint8_t* dest_extra_alpha_scan) { |
799 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 821 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
906 dest_scan++; | 928 dest_scan++; |
907 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); | 929 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Red, src_alpha); |
908 dest_scan += Bpp - 2; | 930 dest_scan += Bpp - 2; |
909 continue; | 931 continue; |
910 } | 932 } |
911 } | 933 } |
912 dest_scan += Bpp; | 934 dest_scan += Bpp; |
913 } | 935 } |
914 } | 936 } |
915 } | 937 } |
| 938 |
916 void CompositeSpanCMYK(uint8_t* dest_scan, | 939 void CompositeSpanCMYK(uint8_t* dest_scan, |
917 int Bpp, | 940 int Bpp, |
918 int span_left, | 941 int span_left, |
919 int span_len, | 942 int span_len, |
920 uint8_t* cover_scan, | 943 uint8_t* cover_scan, |
921 int clip_left, | 944 int clip_left, |
922 int clip_right, | 945 int clip_right, |
923 uint8_t* clip_scan, | 946 uint8_t* clip_scan, |
924 uint8_t* dest_extra_alpha_scan) { | 947 uint8_t* dest_extra_alpha_scan) { |
925 ASSERT(!m_bRgbByteOrder); | 948 ASSERT(!m_bRgbByteOrder); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
987 dest_scan++; | 1010 dest_scan++; |
988 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); | 1011 *dest_scan = FXDIB_ALPHA_MERGE(*dest_scan, m_Gray, src_alpha); |
989 dest_scan++; | 1012 dest_scan++; |
990 continue; | 1013 continue; |
991 } | 1014 } |
992 } | 1015 } |
993 dest_scan += 4; | 1016 dest_scan += 4; |
994 } | 1017 } |
995 } | 1018 } |
996 } | 1019 } |
| 1020 |
997 template <class Scanline> | 1021 template <class Scanline> |
998 void render(const Scanline& sl) { | 1022 void render(const Scanline& sl) { |
999 if (!m_pOriDevice && !composite_span) { | 1023 if (!m_pOriDevice && !composite_span) { |
1000 return; | 1024 return; |
1001 } | 1025 } |
1002 int y = sl.y(); | 1026 int y = sl.y(); |
1003 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) { | 1027 if (y < m_ClipBox.top || y >= m_ClipBox.bottom) { |
1004 return; | 1028 return; |
1005 } | 1029 } |
1006 uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * y; | 1030 uint8_t* dest_scan = m_pDevice->GetBuffer() + m_pDevice->GetPitch() * y; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); | 1201 ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); |
1178 } | 1202 } |
1179 } | 1203 } |
1180 } | 1204 } |
1181 if (m_pDevice->GetBPP() == 1) { | 1205 if (m_pDevice->GetBPP() == 1) { |
1182 composite_span = &CFX_Renderer::CompositeSpan1bpp; | 1206 composite_span = &CFX_Renderer::CompositeSpan1bpp; |
1183 } | 1207 } |
1184 return TRUE; | 1208 return TRUE; |
1185 } | 1209 } |
1186 }; | 1210 }; |
| 1211 |
1187 FX_BOOL CFX_AggDeviceDriver::RenderRasterizer( | 1212 FX_BOOL CFX_AggDeviceDriver::RenderRasterizer( |
1188 agg::rasterizer_scanline_aa& rasterizer, | 1213 agg::rasterizer_scanline_aa& rasterizer, |
1189 FX_DWORD color, | 1214 FX_DWORD color, |
1190 FX_BOOL bFullCover, | 1215 FX_BOOL bFullCover, |
1191 FX_BOOL bGroupKnockout, | 1216 FX_BOOL bGroupKnockout, |
1192 int alpha_flag, | 1217 int alpha_flag, |
1193 void* pIccTransform) { | 1218 void* pIccTransform) { |
1194 CFX_DIBitmap* pt = bGroupKnockout ? m_pOriDevice : NULL; | 1219 CFX_DIBitmap* pt = bGroupKnockout ? m_pOriDevice : NULL; |
1195 CFX_Renderer render; | 1220 CFX_Renderer render; |
1196 if (!render.Init(m_pBitmap, pt, m_pClipRgn, color, bFullCover, | 1221 if (!render.Init(m_pBitmap, pt, m_pClipRgn, color, bFullCover, |
1197 m_bRgbByteOrder, alpha_flag, pIccTransform)) { | 1222 m_bRgbByteOrder, alpha_flag, pIccTransform)) { |
1198 return FALSE; | 1223 return FALSE; |
1199 } | 1224 } |
1200 agg::scanline_u8 scanline; | 1225 agg::scanline_u8 scanline; |
1201 agg::render_scanlines(rasterizer, scanline, render, | 1226 agg::render_scanlines(rasterizer, scanline, render, |
1202 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); | 1227 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); |
1203 return TRUE; | 1228 return TRUE; |
1204 } | 1229 } |
| 1230 |
1205 FX_BOOL CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, | 1231 FX_BOOL CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, |
1206 const CFX_Matrix* pObject2Device, | 1232 const CFX_Matrix* pObject2Device, |
1207 const CFX_GraphStateData* pGraphState, | 1233 const CFX_GraphStateData* pGraphState, |
1208 FX_DWORD fill_color, | 1234 FX_DWORD fill_color, |
1209 FX_DWORD stroke_color, | 1235 FX_DWORD stroke_color, |
1210 int fill_mode, | 1236 int fill_mode, |
1211 int alpha_flag, | 1237 int alpha_flag, |
1212 void* pIccTransform, | 1238 void* pIccTransform, |
1213 int blend_type) { | 1239 int blend_type) { |
1214 if (blend_type != FXDIB_BLEND_NORMAL) { | 1240 if (blend_type != FXDIB_BLEND_NORMAL) { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 | | 1304 int fill_flag = FXGETFLAG_COLORTYPE(alpha_flag) << 8 | |
1279 FXGETFLAG_ALPHA_STROKE(alpha_flag); | 1305 FXGETFLAG_ALPHA_STROKE(alpha_flag); |
1280 if (!RenderRasterizer(rasterizer, stroke_color, | 1306 if (!RenderRasterizer(rasterizer, stroke_color, |
1281 fill_mode & FXFILL_FULLCOVER, m_bGroupKnockout, | 1307 fill_mode & FXFILL_FULLCOVER, m_bGroupKnockout, |
1282 fill_flag, pIccTransform)) { | 1308 fill_flag, pIccTransform)) { |
1283 return FALSE; | 1309 return FALSE; |
1284 } | 1310 } |
1285 } | 1311 } |
1286 return TRUE; | 1312 return TRUE; |
1287 } | 1313 } |
| 1314 |
1288 void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, FX_DWORD argb) { | 1315 void RgbByteOrderSetPixel(CFX_DIBitmap* pBitmap, int x, int y, FX_DWORD argb) { |
1289 if (x < 0 || x >= pBitmap->GetWidth() || y < 0 || y >= pBitmap->GetHeight()) { | 1316 if (x < 0 || x >= pBitmap->GetWidth() || y < 0 || y >= pBitmap->GetHeight()) { |
1290 return; | 1317 return; |
1291 } | 1318 } |
1292 uint8_t* pos = (uint8_t*)pBitmap->GetBuffer() + y * pBitmap->GetPitch() + | 1319 uint8_t* pos = (uint8_t*)pBitmap->GetBuffer() + y * pBitmap->GetPitch() + |
1293 x * pBitmap->GetBPP() / 8; | 1320 x * pBitmap->GetBPP() / 8; |
1294 if (pBitmap->GetFormat() == FXDIB_Argb) { | 1321 if (pBitmap->GetFormat() == FXDIB_Argb) { |
1295 FXARGB_SETRGBORDERDIB(pos, ArgbGamma(argb)); | 1322 FXARGB_SETRGBORDERDIB(pos, ArgbGamma(argb)); |
1296 } else { | 1323 } else { |
1297 int alpha = FXARGB_A(argb); | 1324 int alpha = FXARGB_A(argb); |
1298 pos[0] = (FXARGB_R(argb) * alpha + pos[0] * (255 - alpha)) / 255; | 1325 pos[0] = (FXARGB_R(argb) * alpha + pos[0] * (255 - alpha)) / 255; |
1299 pos[1] = (FXARGB_G(argb) * alpha + pos[1] * (255 - alpha)) / 255; | 1326 pos[1] = (FXARGB_G(argb) * alpha + pos[1] * (255 - alpha)) / 255; |
1300 pos[2] = (FXARGB_B(argb) * alpha + pos[2] * (255 - alpha)) / 255; | 1327 pos[2] = (FXARGB_B(argb) * alpha + pos[2] * (255 - alpha)) / 255; |
1301 } | 1328 } |
1302 } | 1329 } |
| 1330 |
1303 void RgbByteOrderCompositeRect(CFX_DIBitmap* pBitmap, | 1331 void RgbByteOrderCompositeRect(CFX_DIBitmap* pBitmap, |
1304 int left, | 1332 int left, |
1305 int top, | 1333 int top, |
1306 int width, | 1334 int width, |
1307 int height, | 1335 int height, |
1308 FX_ARGB argb) { | 1336 FX_ARGB argb) { |
1309 int src_alpha = FXARGB_A(argb); | 1337 int src_alpha = FXARGB_A(argb); |
1310 if (src_alpha == 0) { | 1338 if (src_alpha == 0) { |
1311 return; | 1339 return; |
1312 } | 1340 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 *dest_scan = FX_GAMMA_INVERSE( | 1401 *dest_scan = FX_GAMMA_INVERSE( |
1374 FXDIB_ALPHA_MERGE(FX_GAMMA(*dest_scan), src_b, src_alpha)); | 1402 FXDIB_ALPHA_MERGE(FX_GAMMA(*dest_scan), src_b, src_alpha)); |
1375 dest_scan++; | 1403 dest_scan++; |
1376 if (Bpp == 4) { | 1404 if (Bpp == 4) { |
1377 dest_scan++; | 1405 dest_scan++; |
1378 } | 1406 } |
1379 } | 1407 } |
1380 } | 1408 } |
1381 } | 1409 } |
1382 } | 1410 } |
| 1411 |
1383 void RgbByteOrderTransferBitmap(CFX_DIBitmap* pBitmap, | 1412 void RgbByteOrderTransferBitmap(CFX_DIBitmap* pBitmap, |
1384 int dest_left, | 1413 int dest_left, |
1385 int dest_top, | 1414 int dest_top, |
1386 int width, | 1415 int width, |
1387 int height, | 1416 int height, |
1388 const CFX_DIBSource* pSrcBitmap, | 1417 const CFX_DIBSource* pSrcBitmap, |
1389 int src_left, | 1418 int src_left, |
1390 int src_top) { | 1419 int src_top) { |
1391 if (!pBitmap) { | 1420 if (!pBitmap) { |
1392 return; | 1421 return; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1476 src_scan[2])); | 1505 src_scan[2])); |
1477 src_scan += 4; | 1506 src_scan += 4; |
1478 dest_scan += 4; | 1507 dest_scan += 4; |
1479 } | 1508 } |
1480 } | 1509 } |
1481 } | 1510 } |
1482 } else { | 1511 } else { |
1483 ASSERT(FALSE); | 1512 ASSERT(FALSE); |
1484 } | 1513 } |
1485 } | 1514 } |
| 1515 |
1486 FX_ARGB _DefaultCMYK2ARGB(FX_CMYK cmyk, uint8_t alpha) { | 1516 FX_ARGB _DefaultCMYK2ARGB(FX_CMYK cmyk, uint8_t alpha) { |
1487 uint8_t r, g, b; | 1517 uint8_t r, g, b; |
1488 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), | 1518 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), |
1489 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, b); | 1519 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, b); |
1490 return ArgbEncode(alpha, r, g, b); | 1520 return ArgbEncode(alpha, r, g, b); |
1491 } | 1521 } |
| 1522 |
1492 FX_BOOL _DibSetPixel(CFX_DIBitmap* pDevice, | 1523 FX_BOOL _DibSetPixel(CFX_DIBitmap* pDevice, |
1493 int x, | 1524 int x, |
1494 int y, | 1525 int y, |
1495 FX_DWORD color, | 1526 FX_DWORD color, |
1496 int alpha_flag, | 1527 int alpha_flag, |
1497 void* pIccTransform) { | 1528 void* pIccTransform) { |
1498 FX_BOOL bObjCMYK = FXGETFLAG_COLORTYPE(alpha_flag); | 1529 FX_BOOL bObjCMYK = FXGETFLAG_COLORTYPE(alpha_flag); |
1499 int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); | 1530 int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); |
1500 if (pIccTransform) { | 1531 if (pIccTransform) { |
1501 ICodec_IccModule* pIccModule = | 1532 ICodec_IccModule* pIccModule = |
(...skipping 15 matching lines...) Expand all Loading... |
1517 color = _DefaultCMYK2ARGB(color, alpha); | 1548 color = _DefaultCMYK2ARGB(color, alpha); |
1518 } | 1549 } |
1519 } | 1550 } |
1520 } | 1551 } |
1521 pDevice->SetPixel(x, y, color); | 1552 pDevice->SetPixel(x, y, color); |
1522 if (pDevice->m_pAlphaMask) { | 1553 if (pDevice->m_pAlphaMask) { |
1523 pDevice->m_pAlphaMask->SetPixel(x, y, alpha << 24); | 1554 pDevice->m_pAlphaMask->SetPixel(x, y, alpha << 24); |
1524 } | 1555 } |
1525 return TRUE; | 1556 return TRUE; |
1526 } | 1557 } |
| 1558 |
1527 FX_BOOL CFX_AggDeviceDriver::SetPixel(int x, | 1559 FX_BOOL CFX_AggDeviceDriver::SetPixel(int x, |
1528 int y, | 1560 int y, |
1529 FX_DWORD color, | 1561 FX_DWORD color, |
1530 int alpha_flag, | 1562 int alpha_flag, |
1531 void* pIccTransform) { | 1563 void* pIccTransform) { |
1532 if (!m_pBitmap->GetBuffer()) { | 1564 if (!m_pBitmap->GetBuffer()) { |
1533 return TRUE; | 1565 return TRUE; |
1534 } | 1566 } |
1535 if (!CFX_GEModule::Get()->GetCodecModule() || | 1567 if (!CFX_GEModule::Get()->GetCodecModule() || |
1536 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { | 1568 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { |
(...skipping 26 matching lines...) Expand all Loading... |
1563 if (bCMYK) { | 1595 if (bCMYK) { |
1564 FXSETFLAG_ALPHA_FILL(alpha_flag, new_alpha); | 1596 FXSETFLAG_ALPHA_FILL(alpha_flag, new_alpha); |
1565 } else { | 1597 } else { |
1566 color = (color & 0xffffff) | (new_alpha << 24); | 1598 color = (color & 0xffffff) | (new_alpha << 24); |
1567 } | 1599 } |
1568 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransform); | 1600 return _DibSetPixel(m_pBitmap, x, y, color, alpha_flag, pIccTransform); |
1569 } | 1601 } |
1570 } | 1602 } |
1571 return TRUE; | 1603 return TRUE; |
1572 } | 1604 } |
| 1605 |
1573 FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect, | 1606 FX_BOOL CFX_AggDeviceDriver::FillRect(const FX_RECT* pRect, |
1574 FX_DWORD fill_color, | 1607 FX_DWORD fill_color, |
1575 int alpha_flag, | 1608 int alpha_flag, |
1576 void* pIccTransform, | 1609 void* pIccTransform, |
1577 int blend_type) { | 1610 int blend_type) { |
1578 if (blend_type != FXDIB_BLEND_NORMAL) { | 1611 if (blend_type != FXDIB_BLEND_NORMAL) { |
1579 return FALSE; | 1612 return FALSE; |
1580 } | 1613 } |
1581 if (!m_pBitmap->GetBuffer()) { | 1614 if (!m_pBitmap->GetBuffer()) { |
1582 return TRUE; | 1615 return TRUE; |
(...skipping 19 matching lines...) Expand all Loading... |
1602 } | 1635 } |
1603 return TRUE; | 1636 return TRUE; |
1604 } | 1637 } |
1605 m_pBitmap->CompositeMask( | 1638 m_pBitmap->CompositeMask( |
1606 draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(), | 1639 draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(), |
1607 (const CFX_DIBitmap*)m_pClipRgn->GetMask(), fill_color, | 1640 (const CFX_DIBitmap*)m_pClipRgn->GetMask(), fill_color, |
1608 draw_rect.left - clip_rect.left, draw_rect.top - clip_rect.top, | 1641 draw_rect.left - clip_rect.left, draw_rect.top - clip_rect.top, |
1609 FXDIB_BLEND_NORMAL, NULL, m_bRgbByteOrder, alpha_flag, pIccTransform); | 1642 FXDIB_BLEND_NORMAL, NULL, m_bRgbByteOrder, alpha_flag, pIccTransform); |
1610 return TRUE; | 1643 return TRUE; |
1611 } | 1644 } |
| 1645 |
1612 FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) { | 1646 FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) { |
1613 if (!m_pClipRgn) { | 1647 if (!m_pClipRgn) { |
1614 pRect->left = pRect->top = 0; | 1648 pRect->left = pRect->top = 0; |
1615 pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH); | 1649 pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH); |
1616 pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT); | 1650 pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT); |
1617 return TRUE; | 1651 return TRUE; |
1618 } | 1652 } |
1619 *pRect = m_pClipRgn->GetBox(); | 1653 *pRect = m_pClipRgn->GetBox(); |
1620 return TRUE; | 1654 return TRUE; |
1621 } | 1655 } |
| 1656 |
1622 FX_BOOL CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, | 1657 FX_BOOL CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, |
1623 int left, | 1658 int left, |
1624 int top, | 1659 int top, |
1625 void* pIccTransform, | 1660 void* pIccTransform, |
1626 FX_BOOL bDEdge) { | 1661 FX_BOOL bDEdge) { |
1627 if (!m_pBitmap->GetBuffer()) { | 1662 if (!m_pBitmap->GetBuffer()) { |
1628 return TRUE; | 1663 return TRUE; |
1629 } | 1664 } |
1630 if (bDEdge) { | 1665 if (bDEdge) { |
1631 if (m_bRgbByteOrder) { | 1666 if (m_bRgbByteOrder) { |
(...skipping 28 matching lines...) Expand all Loading... |
1660 if (m_bRgbByteOrder) { | 1695 if (m_bRgbByteOrder) { |
1661 RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(), | 1696 RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(), |
1662 pBack, left, top); | 1697 pBack, left, top); |
1663 } else { | 1698 } else { |
1664 bRet = pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack, | 1699 bRet = pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack, |
1665 left, top, pIccTransform); | 1700 left, top, pIccTransform); |
1666 } | 1701 } |
1667 delete pBack; | 1702 delete pBack; |
1668 return bRet; | 1703 return bRet; |
1669 } | 1704 } |
| 1705 |
1670 FX_BOOL CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, | 1706 FX_BOOL CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, |
1671 FX_DWORD argb, | 1707 FX_DWORD argb, |
1672 const FX_RECT* pSrcRect, | 1708 const FX_RECT* pSrcRect, |
1673 int left, | 1709 int left, |
1674 int top, | 1710 int top, |
1675 int blend_type, | 1711 int blend_type, |
1676 int alpha_flag, | 1712 int alpha_flag, |
1677 void* pIccTransform) { | 1713 void* pIccTransform) { |
1678 if (!m_pBitmap->GetBuffer()) { | 1714 if (!m_pBitmap->GetBuffer()) { |
1679 return TRUE; | 1715 return TRUE; |
1680 } | 1716 } |
1681 if (pBitmap->IsAlphaMask()) | 1717 if (pBitmap->IsAlphaMask()) |
1682 return m_pBitmap->CompositeMask( | 1718 return m_pBitmap->CompositeMask( |
1683 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb, | 1719 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb, |
1684 pSrcRect->left, pSrcRect->top, blend_type, m_pClipRgn, m_bRgbByteOrder, | 1720 pSrcRect->left, pSrcRect->top, blend_type, m_pClipRgn, m_bRgbByteOrder, |
1685 alpha_flag, pIccTransform); | 1721 alpha_flag, pIccTransform); |
1686 return m_pBitmap->CompositeBitmap( | 1722 return m_pBitmap->CompositeBitmap( |
1687 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left, | 1723 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left, |
1688 pSrcRect->top, blend_type, m_pClipRgn, m_bRgbByteOrder, pIccTransform); | 1724 pSrcRect->top, blend_type, m_pClipRgn, m_bRgbByteOrder, pIccTransform); |
1689 } | 1725 } |
| 1726 |
1690 FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, | 1727 FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, |
1691 FX_DWORD argb, | 1728 FX_DWORD argb, |
1692 int dest_left, | 1729 int dest_left, |
1693 int dest_top, | 1730 int dest_top, |
1694 int dest_width, | 1731 int dest_width, |
1695 int dest_height, | 1732 int dest_height, |
1696 const FX_RECT* pClipRect, | 1733 const FX_RECT* pClipRect, |
1697 FX_DWORD flags, | 1734 FX_DWORD flags, |
1698 int alpha_flag, | 1735 int alpha_flag, |
1699 void* pIccTransform, | 1736 void* pIccTransform, |
(...skipping 17 matching lines...) Expand all Loading... |
1717 FALSE, m_bRgbByteOrder, alpha_flag, pIccTransform, | 1754 FALSE, m_bRgbByteOrder, alpha_flag, pIccTransform, |
1718 blend_type); | 1755 blend_type); |
1719 dest_clip.Offset(-dest_rect.left, -dest_rect.top); | 1756 dest_clip.Offset(-dest_rect.left, -dest_rect.top); |
1720 CFX_ImageStretcher stretcher; | 1757 CFX_ImageStretcher stretcher; |
1721 if (stretcher.Start(&composer, pSource, dest_width, dest_height, dest_clip, | 1758 if (stretcher.Start(&composer, pSource, dest_width, dest_height, dest_clip, |
1722 flags)) { | 1759 flags)) { |
1723 stretcher.Continue(NULL); | 1760 stretcher.Continue(NULL); |
1724 } | 1761 } |
1725 return TRUE; | 1762 return TRUE; |
1726 } | 1763 } |
| 1764 |
1727 FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, | 1765 FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, |
1728 int bitmap_alpha, | 1766 int bitmap_alpha, |
1729 FX_DWORD argb, | 1767 FX_DWORD argb, |
1730 const CFX_Matrix* pMatrix, | 1768 const CFX_Matrix* pMatrix, |
1731 FX_DWORD render_flags, | 1769 FX_DWORD render_flags, |
1732 void*& handle, | 1770 void*& handle, |
1733 int alpha_flag, | 1771 int alpha_flag, |
1734 void* pIccTransform, | 1772 void* pIccTransform, |
1735 int blend_type) { | 1773 int blend_type) { |
1736 if (!m_pBitmap->GetBuffer()) { | 1774 if (!m_pBitmap->GetBuffer()) { |
1737 return TRUE; | 1775 return TRUE; |
1738 } | 1776 } |
1739 CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer; | 1777 CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer; |
1740 pRenderer->Start(m_pBitmap, m_pClipRgn, pSource, bitmap_alpha, argb, pMatrix, | 1778 pRenderer->Start(m_pBitmap, m_pClipRgn, pSource, bitmap_alpha, argb, pMatrix, |
1741 render_flags, m_bRgbByteOrder, alpha_flag, pIccTransform); | 1779 render_flags, m_bRgbByteOrder, alpha_flag, pIccTransform); |
1742 handle = pRenderer; | 1780 handle = pRenderer; |
1743 return TRUE; | 1781 return TRUE; |
1744 } | 1782 } |
| 1783 |
1745 FX_BOOL CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) { | 1784 FX_BOOL CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) { |
1746 if (!m_pBitmap->GetBuffer()) { | 1785 if (!m_pBitmap->GetBuffer()) { |
1747 return TRUE; | 1786 return TRUE; |
1748 } | 1787 } |
1749 return ((CFX_ImageRenderer*)pHandle)->Continue(pPause); | 1788 return ((CFX_ImageRenderer*)pHandle)->Continue(pPause); |
1750 } | 1789 } |
| 1790 |
1751 void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) { | 1791 void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) { |
1752 if (!m_pBitmap->GetBuffer()) { | 1792 if (!m_pBitmap->GetBuffer()) { |
1753 return; | 1793 return; |
1754 } | 1794 } |
1755 delete (CFX_ImageRenderer*)pHandle; | 1795 delete (CFX_ImageRenderer*)pHandle; |
1756 } | 1796 } |
| 1797 |
1757 CFX_FxgeDevice::CFX_FxgeDevice() { | 1798 CFX_FxgeDevice::CFX_FxgeDevice() { |
1758 m_bOwnedBitmap = FALSE; | 1799 m_bOwnedBitmap = FALSE; |
1759 } | 1800 } |
| 1801 |
1760 FX_BOOL CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, | 1802 FX_BOOL CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, |
1761 int dither_bits, | 1803 int dither_bits, |
1762 FX_BOOL bRgbByteOrder, | 1804 FX_BOOL bRgbByteOrder, |
1763 CFX_DIBitmap* pOriDevice, | 1805 CFX_DIBitmap* pOriDevice, |
1764 FX_BOOL bGroupKnockout) { | 1806 FX_BOOL bGroupKnockout) { |
1765 if (!pBitmap) { | 1807 if (!pBitmap) { |
1766 return FALSE; | 1808 return FALSE; |
1767 } | 1809 } |
1768 SetBitmap(pBitmap); | 1810 SetBitmap(pBitmap); |
1769 IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver( | 1811 IFX_RenderDeviceDriver* pDriver = new CFX_AggDeviceDriver( |
1770 pBitmap, dither_bits, bRgbByteOrder, pOriDevice, bGroupKnockout); | 1812 pBitmap, dither_bits, bRgbByteOrder, pOriDevice, bGroupKnockout); |
1771 SetDeviceDriver(pDriver); | 1813 SetDeviceDriver(pDriver); |
1772 return TRUE; | 1814 return TRUE; |
1773 } | 1815 } |
| 1816 |
1774 FX_BOOL CFX_FxgeDevice::Create(int width, | 1817 FX_BOOL CFX_FxgeDevice::Create(int width, |
1775 int height, | 1818 int height, |
1776 FXDIB_Format format, | 1819 FXDIB_Format format, |
1777 int dither_bits, | 1820 int dither_bits, |
1778 CFX_DIBitmap* pOriDevice) { | 1821 CFX_DIBitmap* pOriDevice) { |
1779 m_bOwnedBitmap = TRUE; | 1822 m_bOwnedBitmap = TRUE; |
1780 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; | 1823 CFX_DIBitmap* pBitmap = new CFX_DIBitmap; |
1781 if (!pBitmap->Create(width, height, format)) { | 1824 if (!pBitmap->Create(width, height, format)) { |
1782 delete pBitmap; | 1825 delete pBitmap; |
1783 return FALSE; | 1826 return FALSE; |
1784 } | 1827 } |
1785 SetBitmap(pBitmap); | 1828 SetBitmap(pBitmap); |
1786 IFX_RenderDeviceDriver* pDriver = | 1829 IFX_RenderDeviceDriver* pDriver = |
1787 new CFX_AggDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE); | 1830 new CFX_AggDeviceDriver(pBitmap, dither_bits, FALSE, pOriDevice, FALSE); |
1788 SetDeviceDriver(pDriver); | 1831 SetDeviceDriver(pDriver); |
1789 return TRUE; | 1832 return TRUE; |
1790 } | 1833 } |
| 1834 |
1791 CFX_FxgeDevice::~CFX_FxgeDevice() { | 1835 CFX_FxgeDevice::~CFX_FxgeDevice() { |
1792 if (m_bOwnedBitmap) { | 1836 if (m_bOwnedBitmap) { |
1793 delete GetBitmap(); | 1837 delete GetBitmap(); |
1794 } | 1838 } |
1795 } | 1839 } |
OLD | NEW |