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/fxge/agg/fx_agg_driver.h" | 7 #include "core/fxge/agg/fx_agg_driver.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 if (src_alpha == 0) | 63 if (src_alpha == 0) |
64 return; | 64 return; |
65 | 65 |
66 FX_RECT rect(left, top, left + width, top + height); | 66 FX_RECT rect(left, top, left + width, top + height); |
67 rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); | 67 rect.Intersect(0, 0, pBitmap->GetWidth(), pBitmap->GetHeight()); |
68 width = rect.Width(); | 68 width = rect.Width(); |
69 int src_r = FXARGB_R(argb); | 69 int src_r = FXARGB_R(argb); |
70 int src_g = FXARGB_G(argb); | 70 int src_g = FXARGB_G(argb); |
71 int src_b = FXARGB_B(argb); | 71 int src_b = FXARGB_B(argb); |
72 int Bpp = pBitmap->GetBPP() / 8; | 72 int Bpp = pBitmap->GetBPP() / 8; |
73 FX_BOOL bAlpha = pBitmap->HasAlpha(); | 73 bool bAlpha = pBitmap->HasAlpha(); |
74 int dib_argb = FXARGB_TOBGRORDERDIB(argb); | 74 int dib_argb = FXARGB_TOBGRORDERDIB(argb); |
75 uint8_t* pBuffer = pBitmap->GetBuffer(); | 75 uint8_t* pBuffer = pBitmap->GetBuffer(); |
76 if (src_alpha == 255) { | 76 if (src_alpha == 255) { |
77 for (int row = rect.top; row < rect.bottom; row++) { | 77 for (int row = rect.top; row < rect.bottom; row++) { |
78 uint8_t* dest_scan = | 78 uint8_t* dest_scan = |
79 pBuffer + row * pBitmap->GetPitch() + rect.left * Bpp; | 79 pBuffer + row * pBitmap->GetPitch() + rect.left * Bpp; |
80 if (Bpp == 4) { | 80 if (Bpp == 4) { |
81 uint32_t* scan = (uint32_t*)dest_scan; | 81 uint32_t* scan = (uint32_t*)dest_scan; |
82 for (int col = 0; col < width; col++) | 82 for (int col = 0; col < width; col++) |
83 *scan++ = dib_argb; | 83 *scan++ = dib_argb; |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 uint8_t* src_scan = | 182 uint8_t* src_scan = |
183 (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 4; | 183 (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 4; |
184 for (int col = 0; col < width; col++) { | 184 for (int col = 0; col < width; col++) { |
185 *dest_scan++ = src_scan[2]; | 185 *dest_scan++ = src_scan[2]; |
186 *dest_scan++ = src_scan[1]; | 186 *dest_scan++ = src_scan[1]; |
187 *dest_scan++ = src_scan[0]; | 187 *dest_scan++ = src_scan[0]; |
188 src_scan += 4; | 188 src_scan += 4; |
189 } | 189 } |
190 } | 190 } |
191 } else { | 191 } else { |
192 ASSERT(FALSE); | 192 ASSERT(false); |
193 } | 193 } |
194 return; | 194 return; |
195 } | 195 } |
196 | 196 |
197 if (dest_format == FXDIB_Argb || dest_format == FXDIB_Rgb32) { | 197 if (dest_format == FXDIB_Argb || dest_format == FXDIB_Rgb32) { |
198 if (src_format == FXDIB_Rgb) { | 198 if (src_format == FXDIB_Rgb) { |
199 for (int row = 0; row < height; row++) { | 199 for (int row = 0; row < height; row++) { |
200 uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch); | 200 uint8_t* dest_scan = (uint8_t*)(dest_buf + row * pitch); |
201 uint8_t* src_scan = | 201 uint8_t* src_scan = |
202 (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 3; | 202 (uint8_t*)pSrcBitmap->GetScanline(src_top + row) + src_left * 3; |
(...skipping 14 matching lines...) Expand all Loading... |
217 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1], | 217 FXARGB_SETDIB(dest_scan, FXARGB_MAKE(0xff, src_scan[0], src_scan[1], |
218 src_scan[2])); | 218 src_scan[2])); |
219 src_scan += 4; | 219 src_scan += 4; |
220 dest_scan += 4; | 220 dest_scan += 4; |
221 } | 221 } |
222 } | 222 } |
223 } | 223 } |
224 return; | 224 return; |
225 } | 225 } |
226 | 226 |
227 ASSERT(FALSE); | 227 ASSERT(false); |
228 } | 228 } |
229 | 229 |
230 FX_ARGB DefaultCMYK2ARGB(FX_CMYK cmyk, uint8_t alpha) { | 230 FX_ARGB DefaultCMYK2ARGB(FX_CMYK cmyk, uint8_t alpha) { |
231 uint8_t r, g, b; | 231 uint8_t r, g, b; |
232 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), | 232 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(cmyk), FXSYS_GetMValue(cmyk), |
233 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, b); | 233 FXSYS_GetYValue(cmyk), FXSYS_GetKValue(cmyk), r, g, b); |
234 return ArgbEncode(alpha, r, g, b); | 234 return ArgbEncode(alpha, r, g, b); |
235 } | 235 } |
236 | 236 |
237 FX_BOOL DibSetPixel(CFX_DIBitmap* pDevice, | 237 bool DibSetPixel(CFX_DIBitmap* pDevice, |
238 int x, | 238 int x, |
239 int y, | 239 int y, |
240 uint32_t color, | 240 uint32_t color, |
241 int alpha_flag, | 241 int alpha_flag, |
242 void* pIccTransform) { | 242 void* pIccTransform) { |
243 FX_BOOL bObjCMYK = !!FXGETFLAG_COLORTYPE(alpha_flag); | 243 bool bObjCMYK = !!FXGETFLAG_COLORTYPE(alpha_flag); |
244 int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); | 244 int alpha = bObjCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); |
245 if (pIccTransform) { | 245 if (pIccTransform) { |
246 CCodec_IccModule* pIccModule = | 246 CCodec_IccModule* pIccModule = |
247 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 247 CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
248 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); | 248 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); |
249 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color, | 249 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&color, |
250 (uint8_t*)&color, 1); | 250 (uint8_t*)&color, 1); |
251 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); | 251 color = bObjCMYK ? FXCMYK_TODIB(color) : FXARGB_TODIB(color); |
252 if (!pDevice->IsCmykImage()) { | 252 if (!pDevice->IsCmykImage()) { |
253 color = (color & 0xffffff) | (alpha << 24); | 253 color = (color & 0xffffff) | (alpha << 24); |
254 } | 254 } |
255 } else { | 255 } else { |
256 if (pDevice->IsCmykImage()) { | 256 if (pDevice->IsCmykImage()) { |
257 if (!bObjCMYK) | 257 if (!bObjCMYK) |
258 return FALSE; | 258 return false; |
259 } else { | 259 } else { |
260 if (bObjCMYK) | 260 if (bObjCMYK) |
261 color = DefaultCMYK2ARGB(color, alpha); | 261 color = DefaultCMYK2ARGB(color, alpha); |
262 } | 262 } |
263 } | 263 } |
264 pDevice->SetPixel(x, y, color); | 264 pDevice->SetPixel(x, y, color); |
265 if (pDevice->m_pAlphaMask) { | 265 if (pDevice->m_pAlphaMask) { |
266 pDevice->m_pAlphaMask->SetPixel(x, y, alpha << 24); | 266 pDevice->m_pAlphaMask->SetPixel(x, y, alpha << 24); |
267 } | 267 } |
268 return TRUE; | 268 return true; |
269 } | 269 } |
270 | 270 |
271 } // namespace | 271 } // namespace |
272 | 272 |
273 void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, | 273 void CAgg_PathData::BuildPath(const CFX_PathData* pPathData, |
274 const CFX_Matrix* pObject2Device) { | 274 const CFX_Matrix* pObject2Device) { |
275 int nPoints = pPathData->GetPointCount(); | 275 int nPoints = pPathData->GetPointCount(); |
276 FX_PATHPOINT* pPoints = pPathData->GetPoints(); | 276 FX_PATHPOINT* pPoints = pPathData->GetPoints(); |
277 for (int i = 0; i < nPoints; i++) { | 277 for (int i = 0; i < nPoints; i++) { |
278 FX_FLOAT x = pPoints[i].m_PointX, y = pPoints[i].m_PointY; | 278 FX_FLOAT x = pPoints[i].m_PointX, y = pPoints[i].m_PointY; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 unsigned m_left, m_top; | 348 unsigned m_left, m_top; |
349 }; | 349 }; |
350 | 350 |
351 } // namespace agg | 351 } // namespace agg |
352 | 352 |
353 static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer, | 353 static void RasterizeStroke(agg::rasterizer_scanline_aa& rasterizer, |
354 agg::path_storage& path_data, | 354 agg::path_storage& path_data, |
355 const CFX_Matrix* pObject2Device, | 355 const CFX_Matrix* pObject2Device, |
356 const CFX_GraphStateData* pGraphState, | 356 const CFX_GraphStateData* pGraphState, |
357 FX_FLOAT scale = 1.0f, | 357 FX_FLOAT scale = 1.0f, |
358 FX_BOOL bStrokeAdjust = FALSE, | 358 bool bStrokeAdjust = false, |
359 FX_BOOL bTextMode = FALSE) { | 359 bool bTextMode = false) { |
360 agg::line_cap_e cap; | 360 agg::line_cap_e cap; |
361 switch (pGraphState->m_LineCap) { | 361 switch (pGraphState->m_LineCap) { |
362 case CFX_GraphStateData::LineCapRound: | 362 case CFX_GraphStateData::LineCapRound: |
363 cap = agg::round_cap; | 363 cap = agg::round_cap; |
364 break; | 364 break; |
365 case CFX_GraphStateData::LineCapSquare: | 365 case CFX_GraphStateData::LineCapSquare: |
366 cap = agg::square_cap; | 366 cap = agg::square_cap; |
367 break; | 367 break; |
368 default: | 368 default: |
369 cap = agg::butt_cap; | 369 cap = agg::butt_cap; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 agg::conv_stroke<agg::path_storage> stroke(path_data); | 418 agg::conv_stroke<agg::path_storage> stroke(path_data); |
419 stroke.line_join(join); | 419 stroke.line_join(join); |
420 stroke.line_cap(cap); | 420 stroke.line_cap(cap); |
421 stroke.miter_limit(pGraphState->m_MiterLimit); | 421 stroke.miter_limit(pGraphState->m_MiterLimit); |
422 stroke.width(width); | 422 stroke.width(width); |
423 rasterizer.add_path_transformed(stroke, pObject2Device); | 423 rasterizer.add_path_transformed(stroke, pObject2Device); |
424 } | 424 } |
425 } | 425 } |
426 | 426 |
427 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, | 427 CFX_AggDeviceDriver::CFX_AggDeviceDriver(CFX_DIBitmap* pBitmap, |
428 FX_BOOL bRgbByteOrder, | 428 bool bRgbByteOrder, |
429 CFX_DIBitmap* pOriDevice, | 429 CFX_DIBitmap* pOriDevice, |
430 FX_BOOL bGroupKnockout) | 430 bool bGroupKnockout) |
431 : m_pBitmap(pBitmap), | 431 : m_pBitmap(pBitmap), |
432 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 432 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
433 m_pPlatformGraphics(nullptr), | 433 m_pPlatformGraphics(nullptr), |
434 #endif | 434 #endif |
435 m_FillFlags(0), | 435 m_FillFlags(0), |
436 m_bRgbByteOrder(bRgbByteOrder), | 436 m_bRgbByteOrder(bRgbByteOrder), |
437 m_pOriDevice(pOriDevice), | 437 m_pOriDevice(pOriDevice), |
438 m_bGroupKnockout(bGroupKnockout) { | 438 m_bGroupKnockout(bGroupKnockout) { |
439 InitPlatform(); | 439 InitPlatform(); |
440 } | 440 } |
441 | 441 |
442 CFX_AggDeviceDriver::~CFX_AggDeviceDriver() { | 442 CFX_AggDeviceDriver::~CFX_AggDeviceDriver() { |
443 DestroyPlatform(); | 443 DestroyPlatform(); |
444 } | 444 } |
445 | 445 |
446 uint8_t* CFX_AggDeviceDriver::GetBuffer() const { | 446 uint8_t* CFX_AggDeviceDriver::GetBuffer() const { |
447 return m_pBitmap->GetBuffer(); | 447 return m_pBitmap->GetBuffer(); |
448 } | 448 } |
449 | 449 |
450 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 450 #if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
451 void CFX_AggDeviceDriver::InitPlatform() {} | 451 void CFX_AggDeviceDriver::InitPlatform() {} |
452 | 452 |
453 void CFX_AggDeviceDriver::DestroyPlatform() {} | 453 void CFX_AggDeviceDriver::DestroyPlatform() {} |
454 | 454 |
455 FX_BOOL CFX_AggDeviceDriver::DrawDeviceText(int nChars, | 455 bool CFX_AggDeviceDriver::DrawDeviceText(int nChars, |
456 const FXTEXT_CHARPOS* pCharPos, | 456 const FXTEXT_CHARPOS* pCharPos, |
457 CFX_Font* pFont, | 457 CFX_Font* pFont, |
458 const CFX_Matrix* pObject2Device, | 458 const CFX_Matrix* pObject2Device, |
459 FX_FLOAT font_size, | 459 FX_FLOAT font_size, |
460 uint32_t color) { | 460 uint32_t color) { |
461 return FALSE; | 461 return false; |
462 } | 462 } |
463 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ | 463 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ |
464 | 464 |
465 int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) const { | 465 int CFX_AggDeviceDriver::GetDeviceCaps(int caps_id) const { |
466 switch (caps_id) { | 466 switch (caps_id) { |
467 case FXDC_DEVICE_CLASS: | 467 case FXDC_DEVICE_CLASS: |
468 return FXDC_DISPLAY; | 468 return FXDC_DISPLAY; |
469 case FXDC_PIXEL_WIDTH: | 469 case FXDC_PIXEL_WIDTH: |
470 return m_pBitmap->GetWidth(); | 470 return m_pBitmap->GetWidth(); |
471 case FXDC_PIXEL_HEIGHT: | 471 case FXDC_PIXEL_HEIGHT: |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 agg::renderer_base<agg::pixfmt_gray8> base_buf(pixel_buf); | 533 agg::renderer_base<agg::pixfmt_gray8> base_buf(pixel_buf); |
534 agg::renderer_scanline_aa_offset<agg::renderer_base<agg::pixfmt_gray8> > | 534 agg::renderer_scanline_aa_offset<agg::renderer_base<agg::pixfmt_gray8> > |
535 final_render(base_buf, path_rect.left, path_rect.top); | 535 final_render(base_buf, path_rect.left, path_rect.top); |
536 final_render.color(agg::gray8(255)); | 536 final_render.color(agg::gray8(255)); |
537 agg::scanline_u8 scanline; | 537 agg::scanline_u8 scanline; |
538 agg::render_scanlines(rasterizer, scanline, final_render, | 538 agg::render_scanlines(rasterizer, scanline, final_render, |
539 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); | 539 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); |
540 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); | 540 m_pClipRgn->IntersectMaskF(path_rect.left, path_rect.top, mask); |
541 } | 541 } |
542 | 542 |
543 FX_BOOL CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, | 543 bool CFX_AggDeviceDriver::SetClip_PathFill(const CFX_PathData* pPathData, |
544 const CFX_Matrix* pObject2Device, | 544 const CFX_Matrix* pObject2Device, |
545 int fill_mode) { | 545 int fill_mode) { |
546 m_FillFlags = fill_mode; | 546 m_FillFlags = fill_mode; |
547 if (!m_pClipRgn) { | 547 if (!m_pClipRgn) { |
548 m_pClipRgn = pdfium::MakeUnique<CFX_ClipRgn>( | 548 m_pClipRgn = pdfium::MakeUnique<CFX_ClipRgn>( |
549 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 549 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
550 } | 550 } |
551 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { | 551 if (pPathData->GetPointCount() == 5 || pPathData->GetPointCount() == 4) { |
552 CFX_FloatRect rectf; | 552 CFX_FloatRect rectf; |
553 if (pPathData->IsRect(pObject2Device, &rectf)) { | 553 if (pPathData->IsRect(pObject2Device, &rectf)) { |
554 rectf.Intersect( | 554 rectf.Intersect( |
555 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), | 555 CFX_FloatRect(0, 0, (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_WIDTH), |
556 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 556 (FX_FLOAT)GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
557 FX_RECT rect = rectf.GetOuterRect(); | 557 FX_RECT rect = rectf.GetOuterRect(); |
558 m_pClipRgn->IntersectRect(rect); | 558 m_pClipRgn->IntersectRect(rect); |
559 return TRUE; | 559 return true; |
560 } | 560 } |
561 } | 561 } |
562 CAgg_PathData path_data; | 562 CAgg_PathData path_data; |
563 path_data.BuildPath(pPathData, pObject2Device); | 563 path_data.BuildPath(pPathData, pObject2Device); |
564 path_data.m_PathData.end_poly(); | 564 path_data.m_PathData.end_poly(); |
565 agg::rasterizer_scanline_aa rasterizer; | 565 agg::rasterizer_scanline_aa rasterizer; |
566 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), | 566 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), |
567 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 567 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
568 rasterizer.add_path(path_data.m_PathData); | 568 rasterizer.add_path(path_data.m_PathData); |
569 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING | 569 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING |
570 ? agg::fill_non_zero | 570 ? agg::fill_non_zero |
571 : agg::fill_even_odd); | 571 : agg::fill_even_odd); |
572 SetClipMask(rasterizer); | 572 SetClipMask(rasterizer); |
573 return TRUE; | 573 return true; |
574 } | 574 } |
575 | 575 |
576 FX_BOOL CFX_AggDeviceDriver::SetClip_PathStroke( | 576 bool CFX_AggDeviceDriver::SetClip_PathStroke( |
577 const CFX_PathData* pPathData, | 577 const CFX_PathData* pPathData, |
578 const CFX_Matrix* pObject2Device, | 578 const CFX_Matrix* pObject2Device, |
579 const CFX_GraphStateData* pGraphState) { | 579 const CFX_GraphStateData* pGraphState) { |
580 if (!m_pClipRgn) { | 580 if (!m_pClipRgn) { |
581 m_pClipRgn = pdfium::MakeUnique<CFX_ClipRgn>( | 581 m_pClipRgn = pdfium::MakeUnique<CFX_ClipRgn>( |
582 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); | 582 GetDeviceCaps(FXDC_PIXEL_WIDTH), GetDeviceCaps(FXDC_PIXEL_HEIGHT)); |
583 } | 583 } |
584 CAgg_PathData path_data; | 584 CAgg_PathData path_data; |
585 path_data.BuildPath(pPathData, nullptr); | 585 path_data.BuildPath(pPathData, nullptr); |
586 agg::rasterizer_scanline_aa rasterizer; | 586 agg::rasterizer_scanline_aa rasterizer; |
587 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), | 587 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), |
588 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 588 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
589 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, | 589 RasterizeStroke(rasterizer, path_data.m_PathData, pObject2Device, |
590 pGraphState); | 590 pGraphState); |
591 rasterizer.filling_rule(agg::fill_non_zero); | 591 rasterizer.filling_rule(agg::fill_non_zero); |
592 SetClipMask(rasterizer); | 592 SetClipMask(rasterizer); |
593 return TRUE; | 593 return true; |
594 } | 594 } |
595 | 595 |
596 class CFX_Renderer { | 596 class CFX_Renderer { |
597 private: | 597 private: |
598 int m_Alpha, m_Red, m_Green, m_Blue, m_Gray; | 598 int m_Alpha, m_Red, m_Green, m_Blue, m_Gray; |
599 uint32_t m_Color; | 599 uint32_t m_Color; |
600 FX_BOOL m_bFullCover; | 600 bool m_bFullCover; |
601 FX_BOOL m_bRgbByteOrder; | 601 bool m_bRgbByteOrder; |
602 CFX_DIBitmap* m_pOriDevice; | 602 CFX_DIBitmap* m_pOriDevice; |
603 FX_RECT m_ClipBox; | 603 FX_RECT m_ClipBox; |
604 const CFX_DIBitmap* m_pClipMask; | 604 const CFX_DIBitmap* m_pClipMask; |
605 CFX_DIBitmap* m_pDevice; | 605 CFX_DIBitmap* m_pDevice; |
606 const CFX_ClipRgn* m_pClipRgn; | 606 const CFX_ClipRgn* m_pClipRgn; |
607 void (CFX_Renderer::*composite_span)(uint8_t*, | 607 void (CFX_Renderer::*composite_span)(uint8_t*, |
608 int, | 608 int, |
609 int, | 609 int, |
610 int, | 610 int, |
611 uint8_t*, | 611 uint8_t*, |
612 int, | 612 int, |
613 int, | 613 int, |
614 uint8_t*, | 614 uint8_t*, |
615 uint8_t*); | 615 uint8_t*); |
616 | 616 |
617 public: | 617 public: |
618 void prepare(unsigned) {} | 618 void prepare(unsigned) {} |
619 | 619 |
620 void CompositeSpan(uint8_t* dest_scan, | 620 void CompositeSpan(uint8_t* dest_scan, |
621 uint8_t* ori_scan, | 621 uint8_t* ori_scan, |
622 int Bpp, | 622 int Bpp, |
623 FX_BOOL bDestAlpha, | 623 bool bDestAlpha, |
624 int span_left, | 624 int span_left, |
625 int span_len, | 625 int span_len, |
626 uint8_t* cover_scan, | 626 uint8_t* cover_scan, |
627 int clip_left, | 627 int clip_left, |
628 int clip_right, | 628 int clip_right, |
629 uint8_t* clip_scan) { | 629 uint8_t* clip_scan) { |
630 ASSERT(!m_pDevice->IsCmykImage()); | 630 ASSERT(!m_pDevice->IsCmykImage()); |
631 int col_start = span_left < clip_left ? clip_left - span_left : 0; | 631 int col_start = span_left < clip_left ? clip_left - span_left : 0; |
632 int col_end = (span_left + span_len) < clip_right | 632 int col_end = (span_left + span_len) < clip_right |
633 ? span_len | 633 ? span_len |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 CFX_DIBitmap* pAlphaMask = m_pDevice->m_pAlphaMask; | 1244 CFX_DIBitmap* pAlphaMask = m_pDevice->m_pAlphaMask; |
1245 if (pAlphaMask) { | 1245 if (pAlphaMask) { |
1246 dest_scan_extra_alpha = | 1246 dest_scan_extra_alpha = |
1247 pAlphaMask->GetBuffer() + pAlphaMask->GetPitch() * y; | 1247 pAlphaMask->GetBuffer() + pAlphaMask->GetPitch() * y; |
1248 } | 1248 } |
1249 uint8_t* ori_scan = nullptr; | 1249 uint8_t* ori_scan = nullptr; |
1250 if (m_pOriDevice) { | 1250 if (m_pOriDevice) { |
1251 ori_scan = m_pOriDevice->GetBuffer() + m_pOriDevice->GetPitch() * y; | 1251 ori_scan = m_pOriDevice->GetBuffer() + m_pOriDevice->GetPitch() * y; |
1252 } | 1252 } |
1253 int Bpp = m_pDevice->GetBPP() / 8; | 1253 int Bpp = m_pDevice->GetBPP() / 8; |
1254 FX_BOOL bDestAlpha = m_pDevice->HasAlpha() || m_pDevice->IsAlphaMask(); | 1254 bool bDestAlpha = m_pDevice->HasAlpha() || m_pDevice->IsAlphaMask(); |
1255 unsigned num_spans = sl.num_spans(); | 1255 unsigned num_spans = sl.num_spans(); |
1256 typename Scanline::const_iterator span = sl.begin(); | 1256 typename Scanline::const_iterator span = sl.begin(); |
1257 while (1) { | 1257 while (1) { |
1258 int x = span->x; | 1258 int x = span->x; |
1259 ASSERT(span->len > 0); | 1259 ASSERT(span->len > 0); |
1260 uint8_t* dest_pos = nullptr; | 1260 uint8_t* dest_pos = nullptr; |
1261 uint8_t* dest_extra_alpha_pos = nullptr; | 1261 uint8_t* dest_extra_alpha_pos = nullptr; |
1262 uint8_t* ori_pos = nullptr; | 1262 uint8_t* ori_pos = nullptr; |
1263 if (Bpp) { | 1263 if (Bpp) { |
1264 ori_pos = ori_scan ? ori_scan + x * Bpp : nullptr; | 1264 ori_pos = ori_scan ? ori_scan + x * Bpp : nullptr; |
(...skipping 18 matching lines...) Expand all Loading... |
1283 m_ClipBox.left, m_ClipBox.right, clip_pos, | 1283 m_ClipBox.left, m_ClipBox.right, clip_pos, |
1284 dest_extra_alpha_pos); | 1284 dest_extra_alpha_pos); |
1285 } | 1285 } |
1286 if (--num_spans == 0) { | 1286 if (--num_spans == 0) { |
1287 break; | 1287 break; |
1288 } | 1288 } |
1289 ++span; | 1289 ++span; |
1290 } | 1290 } |
1291 } | 1291 } |
1292 | 1292 |
1293 FX_BOOL Init(CFX_DIBitmap* pDevice, | 1293 bool Init(CFX_DIBitmap* pDevice, |
1294 CFX_DIBitmap* pOriDevice, | 1294 CFX_DIBitmap* pOriDevice, |
1295 const CFX_ClipRgn* pClipRgn, | 1295 const CFX_ClipRgn* pClipRgn, |
1296 uint32_t color, | 1296 uint32_t color, |
1297 FX_BOOL bFullCover, | 1297 bool bFullCover, |
1298 FX_BOOL bRgbByteOrder, | 1298 bool bRgbByteOrder, |
1299 int alpha_flag = 0, | 1299 int alpha_flag = 0, |
1300 void* pIccTransform = nullptr) { | 1300 void* pIccTransform = nullptr) { |
1301 m_pDevice = pDevice; | 1301 m_pDevice = pDevice; |
1302 m_pClipRgn = pClipRgn; | 1302 m_pClipRgn = pClipRgn; |
1303 composite_span = nullptr; | 1303 composite_span = nullptr; |
1304 m_bRgbByteOrder = bRgbByteOrder; | 1304 m_bRgbByteOrder = bRgbByteOrder; |
1305 m_pOriDevice = pOriDevice; | 1305 m_pOriDevice = pOriDevice; |
1306 if (m_pClipRgn) { | 1306 if (m_pClipRgn) { |
1307 m_ClipBox = m_pClipRgn->GetBox(); | 1307 m_ClipBox = m_pClipRgn->GetBox(); |
1308 } else { | 1308 } else { |
1309 m_ClipBox.left = m_ClipBox.top = 0; | 1309 m_ClipBox.left = m_ClipBox.top = 0; |
1310 m_ClipBox.right = m_pDevice->GetWidth(); | 1310 m_ClipBox.right = m_pDevice->GetWidth(); |
1311 m_ClipBox.bottom = m_pDevice->GetHeight(); | 1311 m_ClipBox.bottom = m_pDevice->GetHeight(); |
1312 } | 1312 } |
1313 m_pClipMask = nullptr; | 1313 m_pClipMask = nullptr; |
1314 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) { | 1314 if (m_pClipRgn && m_pClipRgn->GetType() == CFX_ClipRgn::MaskF) { |
1315 m_pClipMask = m_pClipRgn->GetMask().GetObject(); | 1315 m_pClipMask = m_pClipRgn->GetMask().GetObject(); |
1316 } | 1316 } |
1317 m_bFullCover = bFullCover; | 1317 m_bFullCover = bFullCover; |
1318 FX_BOOL bObjectCMYK = !!FXGETFLAG_COLORTYPE(alpha_flag); | 1318 bool bObjectCMYK = !!FXGETFLAG_COLORTYPE(alpha_flag); |
1319 FX_BOOL bDeviceCMYK = pDevice->IsCmykImage(); | 1319 bool bDeviceCMYK = pDevice->IsCmykImage(); |
1320 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); | 1320 m_Alpha = bObjectCMYK ? FXGETFLAG_ALPHA_FILL(alpha_flag) : FXARGB_A(color); |
1321 CCodec_IccModule* pIccModule = nullptr; | 1321 CCodec_IccModule* pIccModule = nullptr; |
1322 if (!CFX_GEModule::Get()->GetCodecModule() || | 1322 if (!CFX_GEModule::Get()->GetCodecModule() || |
1323 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { | 1323 !CFX_GEModule::Get()->GetCodecModule()->GetIccModule()) { |
1324 pIccTransform = nullptr; | 1324 pIccTransform = nullptr; |
1325 } else { | 1325 } else { |
1326 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); | 1326 pIccModule = CFX_GEModule::Get()->GetCodecModule()->GetIccModule(); |
1327 } | 1327 } |
1328 if (m_pDevice->GetBPP() == 8) { | 1328 if (m_pDevice->GetBPP() == 8) { |
1329 ASSERT(!m_bRgbByteOrder); | 1329 ASSERT(!m_bRgbByteOrder); |
(...skipping 13 matching lines...) Expand all Loading... |
1343 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), | 1343 AdobeCMYK_to_sRGB1(FXSYS_GetCValue(color), FXSYS_GetMValue(color), |
1344 FXSYS_GetYValue(color), FXSYS_GetKValue(color), | 1344 FXSYS_GetYValue(color), FXSYS_GetKValue(color), |
1345 r, g, b); | 1345 r, g, b); |
1346 m_Gray = FXRGB2GRAY(r, g, b); | 1346 m_Gray = FXRGB2GRAY(r, g, b); |
1347 } else { | 1347 } else { |
1348 m_Gray = | 1348 m_Gray = |
1349 FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color)); | 1349 FXRGB2GRAY(FXARGB_R(color), FXARGB_G(color), FXARGB_B(color)); |
1350 } | 1350 } |
1351 } | 1351 } |
1352 } | 1352 } |
1353 return TRUE; | 1353 return true; |
1354 } | 1354 } |
1355 if (bDeviceCMYK) { | 1355 if (bDeviceCMYK) { |
1356 ASSERT(!m_bRgbByteOrder); | 1356 ASSERT(!m_bRgbByteOrder); |
1357 composite_span = &CFX_Renderer::CompositeSpanCMYK; | 1357 composite_span = &CFX_Renderer::CompositeSpanCMYK; |
1358 if (bObjectCMYK) { | 1358 if (bObjectCMYK) { |
1359 m_Color = FXCMYK_TODIB(color); | 1359 m_Color = FXCMYK_TODIB(color); |
1360 if (pIccTransform) { | 1360 if (pIccTransform) { |
1361 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, | 1361 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, |
1362 (const uint8_t*)&m_Color, 1); | 1362 (const uint8_t*)&m_Color, 1); |
1363 } | 1363 } |
1364 } else { | 1364 } else { |
1365 if (!pIccTransform) { | 1365 if (!pIccTransform) { |
1366 return FALSE; | 1366 return false; |
1367 } | 1367 } |
1368 color = FXARGB_TODIB(color); | 1368 color = FXARGB_TODIB(color); |
1369 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, | 1369 pIccModule->TranslateScanline(pIccTransform, (uint8_t*)&m_Color, |
1370 (const uint8_t*)&color, 1); | 1370 (const uint8_t*)&color, 1); |
1371 } | 1371 } |
1372 m_Red = ((uint8_t*)&m_Color)[0]; | 1372 m_Red = ((uint8_t*)&m_Color)[0]; |
1373 m_Green = ((uint8_t*)&m_Color)[1]; | 1373 m_Green = ((uint8_t*)&m_Color)[1]; |
1374 m_Blue = ((uint8_t*)&m_Color)[2]; | 1374 m_Blue = ((uint8_t*)&m_Color)[2]; |
1375 m_Gray = ((uint8_t*)&m_Color)[3]; | 1375 m_Gray = ((uint8_t*)&m_Color)[3]; |
1376 } else { | 1376 } else { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1410 } else { | 1410 } else { |
1411 m_Color = FXARGB_TODIB(color); | 1411 m_Color = FXARGB_TODIB(color); |
1412 } | 1412 } |
1413 ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); | 1413 ArgbDecode(color, m_Alpha, m_Red, m_Green, m_Blue); |
1414 } | 1414 } |
1415 } | 1415 } |
1416 } | 1416 } |
1417 if (m_pDevice->GetBPP() == 1) { | 1417 if (m_pDevice->GetBPP() == 1) { |
1418 composite_span = &CFX_Renderer::CompositeSpan1bpp; | 1418 composite_span = &CFX_Renderer::CompositeSpan1bpp; |
1419 } | 1419 } |
1420 return TRUE; | 1420 return true; |
1421 } | 1421 } |
1422 }; | 1422 }; |
1423 | 1423 |
1424 int CFX_AggDeviceDriver::GetDriverType() const { | 1424 int CFX_AggDeviceDriver::GetDriverType() const { |
1425 return 1; | 1425 return 1; |
1426 } | 1426 } |
1427 | 1427 |
1428 FX_BOOL CFX_AggDeviceDriver::RenderRasterizer( | 1428 bool CFX_AggDeviceDriver::RenderRasterizer( |
1429 agg::rasterizer_scanline_aa& rasterizer, | 1429 agg::rasterizer_scanline_aa& rasterizer, |
1430 uint32_t color, | 1430 uint32_t color, |
1431 FX_BOOL bFullCover, | 1431 bool bFullCover, |
1432 FX_BOOL bGroupKnockout, | 1432 bool bGroupKnockout, |
1433 int alpha_flag, | 1433 int alpha_flag, |
1434 void* pIccTransform) { | 1434 void* pIccTransform) { |
1435 CFX_DIBitmap* pt = bGroupKnockout ? m_pOriDevice : nullptr; | 1435 CFX_DIBitmap* pt = bGroupKnockout ? m_pOriDevice : nullptr; |
1436 CFX_Renderer render; | 1436 CFX_Renderer render; |
1437 if (!render.Init(m_pBitmap, pt, m_pClipRgn.get(), color, bFullCover, | 1437 if (!render.Init(m_pBitmap, pt, m_pClipRgn.get(), color, bFullCover, |
1438 m_bRgbByteOrder, alpha_flag, pIccTransform)) { | 1438 m_bRgbByteOrder, alpha_flag, pIccTransform)) { |
1439 return FALSE; | 1439 return false; |
1440 } | 1440 } |
1441 agg::scanline_u8 scanline; | 1441 agg::scanline_u8 scanline; |
1442 agg::render_scanlines(rasterizer, scanline, render, | 1442 agg::render_scanlines(rasterizer, scanline, render, |
1443 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); | 1443 (m_FillFlags & FXFILL_NOPATHSMOOTH) != 0); |
1444 return TRUE; | 1444 return true; |
1445 } | 1445 } |
1446 | 1446 |
1447 FX_BOOL CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, | 1447 bool CFX_AggDeviceDriver::DrawPath(const CFX_PathData* pPathData, |
1448 const CFX_Matrix* pObject2Device, | 1448 const CFX_Matrix* pObject2Device, |
1449 const CFX_GraphStateData* pGraphState, | 1449 const CFX_GraphStateData* pGraphState, |
1450 uint32_t fill_color, | 1450 uint32_t fill_color, |
1451 uint32_t stroke_color, | 1451 uint32_t stroke_color, |
1452 int fill_mode, | 1452 int fill_mode, |
1453 int blend_type) { | 1453 int blend_type) { |
1454 if (blend_type != FXDIB_BLEND_NORMAL) | 1454 if (blend_type != FXDIB_BLEND_NORMAL) |
1455 return FALSE; | 1455 return false; |
1456 | 1456 |
1457 if (!GetBuffer()) | 1457 if (!GetBuffer()) |
1458 return TRUE; | 1458 return true; |
1459 | 1459 |
1460 m_FillFlags = fill_mode; | 1460 m_FillFlags = fill_mode; |
1461 if ((fill_mode & 3) && fill_color) { | 1461 if ((fill_mode & 3) && fill_color) { |
1462 CAgg_PathData path_data; | 1462 CAgg_PathData path_data; |
1463 path_data.BuildPath(pPathData, pObject2Device); | 1463 path_data.BuildPath(pPathData, pObject2Device); |
1464 agg::rasterizer_scanline_aa rasterizer; | 1464 agg::rasterizer_scanline_aa rasterizer; |
1465 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), | 1465 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), |
1466 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 1466 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
1467 rasterizer.add_path(path_data.m_PathData); | 1467 rasterizer.add_path(path_data.m_PathData); |
1468 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING | 1468 rasterizer.filling_rule((fill_mode & 3) == FXFILL_WINDING |
1469 ? agg::fill_non_zero | 1469 ? agg::fill_non_zero |
1470 : agg::fill_even_odd); | 1470 : agg::fill_even_odd); |
1471 if (!RenderRasterizer(rasterizer, fill_color, | 1471 if (!RenderRasterizer(rasterizer, fill_color, |
1472 !!(fill_mode & FXFILL_FULLCOVER), FALSE, 0, | 1472 !!(fill_mode & FXFILL_FULLCOVER), false, 0, |
1473 nullptr)) { | 1473 nullptr)) { |
1474 return FALSE; | 1474 return false; |
1475 } | 1475 } |
1476 } | 1476 } |
1477 int stroke_alpha = FXARGB_A(stroke_color); | 1477 int stroke_alpha = FXARGB_A(stroke_color); |
1478 if (!pGraphState || !stroke_alpha) | 1478 if (!pGraphState || !stroke_alpha) |
1479 return TRUE; | 1479 return true; |
1480 | 1480 |
1481 if (fill_mode & FX_ZEROAREA_FILL) { | 1481 if (fill_mode & FX_ZEROAREA_FILL) { |
1482 CAgg_PathData path_data; | 1482 CAgg_PathData path_data; |
1483 path_data.BuildPath(pPathData, pObject2Device); | 1483 path_data.BuildPath(pPathData, pObject2Device); |
1484 agg::rasterizer_scanline_aa rasterizer; | 1484 agg::rasterizer_scanline_aa rasterizer; |
1485 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), | 1485 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), |
1486 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 1486 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
1487 RasterizeStroke(rasterizer, path_data.m_PathData, nullptr, pGraphState, 1, | 1487 RasterizeStroke(rasterizer, path_data.m_PathData, nullptr, pGraphState, 1, |
1488 FALSE, !!(fill_mode & FX_STROKE_TEXT_MODE)); | 1488 false, !!(fill_mode & FX_STROKE_TEXT_MODE)); |
1489 return RenderRasterizer(rasterizer, stroke_color, | 1489 return RenderRasterizer(rasterizer, stroke_color, |
1490 !!(fill_mode & FXFILL_FULLCOVER), m_bGroupKnockout, | 1490 !!(fill_mode & FXFILL_FULLCOVER), m_bGroupKnockout, |
1491 0, nullptr); | 1491 0, nullptr); |
1492 } | 1492 } |
1493 CFX_Matrix matrix1; | 1493 CFX_Matrix matrix1; |
1494 CFX_Matrix matrix2; | 1494 CFX_Matrix matrix2; |
1495 if (pObject2Device) { | 1495 if (pObject2Device) { |
1496 matrix1.a = | 1496 matrix1.a = |
1497 std::max(FXSYS_fabs(pObject2Device->a), FXSYS_fabs(pObject2Device->b)); | 1497 std::max(FXSYS_fabs(pObject2Device->a), FXSYS_fabs(pObject2Device->b)); |
1498 matrix1.d = matrix1.a; | 1498 matrix1.d = matrix1.a; |
1499 matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a, | 1499 matrix2.Set(pObject2Device->a / matrix1.a, pObject2Device->b / matrix1.a, |
1500 pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, 0, | 1500 pObject2Device->c / matrix1.d, pObject2Device->d / matrix1.d, 0, |
1501 0); | 1501 0); |
1502 CFX_Matrix mtRervese; | 1502 CFX_Matrix mtRervese; |
1503 mtRervese.SetReverse(matrix2); | 1503 mtRervese.SetReverse(matrix2); |
1504 matrix1 = *pObject2Device; | 1504 matrix1 = *pObject2Device; |
1505 matrix1.Concat(mtRervese); | 1505 matrix1.Concat(mtRervese); |
1506 } | 1506 } |
1507 CAgg_PathData path_data; | 1507 CAgg_PathData path_data; |
1508 path_data.BuildPath(pPathData, &matrix1); | 1508 path_data.BuildPath(pPathData, &matrix1); |
1509 agg::rasterizer_scanline_aa rasterizer; | 1509 agg::rasterizer_scanline_aa rasterizer; |
1510 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), | 1510 rasterizer.clip_box(0.0f, 0.0f, (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_WIDTH)), |
1511 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); | 1511 (FX_FLOAT)(GetDeviceCaps(FXDC_PIXEL_HEIGHT))); |
1512 RasterizeStroke(rasterizer, path_data.m_PathData, &matrix2, pGraphState, | 1512 RasterizeStroke(rasterizer, path_data.m_PathData, &matrix2, pGraphState, |
1513 matrix1.a, FALSE, !!(fill_mode & FX_STROKE_TEXT_MODE)); | 1513 matrix1.a, false, !!(fill_mode & FX_STROKE_TEXT_MODE)); |
1514 return RenderRasterizer(rasterizer, stroke_color, | 1514 return RenderRasterizer(rasterizer, stroke_color, |
1515 !!(fill_mode & FXFILL_FULLCOVER), m_bGroupKnockout, 0, | 1515 !!(fill_mode & FXFILL_FULLCOVER), m_bGroupKnockout, 0, |
1516 nullptr); | 1516 nullptr); |
1517 } | 1517 } |
1518 | 1518 |
1519 FX_BOOL CFX_AggDeviceDriver::SetPixel(int x, int y, uint32_t color) { | 1519 bool CFX_AggDeviceDriver::SetPixel(int x, int y, uint32_t color) { |
1520 if (!m_pBitmap->GetBuffer()) | 1520 if (!m_pBitmap->GetBuffer()) |
1521 return TRUE; | 1521 return true; |
1522 | 1522 |
1523 if (!m_pClipRgn) { | 1523 if (!m_pClipRgn) { |
1524 if (!m_bRgbByteOrder) | 1524 if (!m_bRgbByteOrder) |
1525 return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr); | 1525 return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr); |
1526 RgbByteOrderSetPixel(m_pBitmap, x, y, color); | 1526 RgbByteOrderSetPixel(m_pBitmap, x, y, color); |
1527 return TRUE; | 1527 return true; |
1528 } | 1528 } |
1529 if (!m_pClipRgn->GetBox().Contains(x, y)) | 1529 if (!m_pClipRgn->GetBox().Contains(x, y)) |
1530 return TRUE; | 1530 return true; |
1531 | 1531 |
1532 if (m_pClipRgn->GetType() == CFX_ClipRgn::RectI) { | 1532 if (m_pClipRgn->GetType() == CFX_ClipRgn::RectI) { |
1533 if (!m_bRgbByteOrder) | 1533 if (!m_bRgbByteOrder) |
1534 return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr); | 1534 return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr); |
1535 RgbByteOrderSetPixel(m_pBitmap, x, y, color); | 1535 RgbByteOrderSetPixel(m_pBitmap, x, y, color); |
1536 return TRUE; | 1536 return true; |
1537 } | 1537 } |
1538 if (m_pClipRgn->GetType() != CFX_ClipRgn::MaskF) | 1538 if (m_pClipRgn->GetType() != CFX_ClipRgn::MaskF) |
1539 return TRUE; | 1539 return true; |
1540 | 1540 |
1541 const CFX_DIBitmap* pMask = m_pClipRgn->GetMask().GetObject(); | 1541 const CFX_DIBitmap* pMask = m_pClipRgn->GetMask().GetObject(); |
1542 int new_alpha = FXARGB_A(color) * pMask->GetScanline(y)[x] / 255; | 1542 int new_alpha = FXARGB_A(color) * pMask->GetScanline(y)[x] / 255; |
1543 color = (color & 0xffffff) | (new_alpha << 24); | 1543 color = (color & 0xffffff) | (new_alpha << 24); |
1544 if (m_bRgbByteOrder) { | 1544 if (m_bRgbByteOrder) { |
1545 RgbByteOrderSetPixel(m_pBitmap, x, y, color); | 1545 RgbByteOrderSetPixel(m_pBitmap, x, y, color); |
1546 return TRUE; | 1546 return true; |
1547 } | 1547 } |
1548 return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr); | 1548 return DibSetPixel(m_pBitmap, x, y, color, 0, nullptr); |
1549 } | 1549 } |
1550 | 1550 |
1551 FX_BOOL CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, | 1551 bool CFX_AggDeviceDriver::FillRectWithBlend(const FX_RECT* pRect, |
1552 uint32_t fill_color, | 1552 uint32_t fill_color, |
1553 int blend_type) { | 1553 int blend_type) { |
1554 if (blend_type != FXDIB_BLEND_NORMAL) | 1554 if (blend_type != FXDIB_BLEND_NORMAL) |
1555 return FALSE; | 1555 return false; |
1556 | 1556 |
1557 if (!m_pBitmap->GetBuffer()) | 1557 if (!m_pBitmap->GetBuffer()) |
1558 return TRUE; | 1558 return true; |
1559 | 1559 |
1560 FX_RECT clip_rect; | 1560 FX_RECT clip_rect; |
1561 GetClipBox(&clip_rect); | 1561 GetClipBox(&clip_rect); |
1562 FX_RECT draw_rect = clip_rect; | 1562 FX_RECT draw_rect = clip_rect; |
1563 if (pRect) | 1563 if (pRect) |
1564 draw_rect.Intersect(*pRect); | 1564 draw_rect.Intersect(*pRect); |
1565 if (draw_rect.IsEmpty()) | 1565 if (draw_rect.IsEmpty()) |
1566 return TRUE; | 1566 return true; |
1567 | 1567 |
1568 if (!m_pClipRgn || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) { | 1568 if (!m_pClipRgn || m_pClipRgn->GetType() == CFX_ClipRgn::RectI) { |
1569 if (m_bRgbByteOrder) { | 1569 if (m_bRgbByteOrder) { |
1570 RgbByteOrderCompositeRect(m_pBitmap, draw_rect.left, draw_rect.top, | 1570 RgbByteOrderCompositeRect(m_pBitmap, draw_rect.left, draw_rect.top, |
1571 draw_rect.Width(), draw_rect.Height(), | 1571 draw_rect.Width(), draw_rect.Height(), |
1572 fill_color); | 1572 fill_color); |
1573 } else { | 1573 } else { |
1574 m_pBitmap->CompositeRect(draw_rect.left, draw_rect.top, draw_rect.Width(), | 1574 m_pBitmap->CompositeRect(draw_rect.left, draw_rect.top, draw_rect.Width(), |
1575 draw_rect.Height(), fill_color, 0, nullptr); | 1575 draw_rect.Height(), fill_color, 0, nullptr); |
1576 } | 1576 } |
1577 return TRUE; | 1577 return true; |
1578 } | 1578 } |
1579 m_pBitmap->CompositeMask( | 1579 m_pBitmap->CompositeMask( |
1580 draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(), | 1580 draw_rect.left, draw_rect.top, draw_rect.Width(), draw_rect.Height(), |
1581 m_pClipRgn->GetMask().GetObject(), fill_color, | 1581 m_pClipRgn->GetMask().GetObject(), fill_color, |
1582 draw_rect.left - clip_rect.left, draw_rect.top - clip_rect.top, | 1582 draw_rect.left - clip_rect.left, draw_rect.top - clip_rect.top, |
1583 FXDIB_BLEND_NORMAL, nullptr, m_bRgbByteOrder, 0, nullptr); | 1583 FXDIB_BLEND_NORMAL, nullptr, m_bRgbByteOrder, 0, nullptr); |
1584 return TRUE; | 1584 return true; |
1585 } | 1585 } |
1586 | 1586 |
1587 FX_BOOL CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) { | 1587 bool CFX_AggDeviceDriver::GetClipBox(FX_RECT* pRect) { |
1588 if (!m_pClipRgn) { | 1588 if (!m_pClipRgn) { |
1589 pRect->left = pRect->top = 0; | 1589 pRect->left = pRect->top = 0; |
1590 pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH); | 1590 pRect->right = GetDeviceCaps(FXDC_PIXEL_WIDTH); |
1591 pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT); | 1591 pRect->bottom = GetDeviceCaps(FXDC_PIXEL_HEIGHT); |
1592 return TRUE; | 1592 return true; |
1593 } | 1593 } |
1594 *pRect = m_pClipRgn->GetBox(); | 1594 *pRect = m_pClipRgn->GetBox(); |
1595 return TRUE; | 1595 return true; |
1596 } | 1596 } |
1597 | 1597 |
1598 FX_BOOL CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, | 1598 bool CFX_AggDeviceDriver::GetDIBits(CFX_DIBitmap* pBitmap, int left, int top) { |
1599 int left, | |
1600 int top) { | |
1601 if (!m_pBitmap || !m_pBitmap->GetBuffer()) | 1599 if (!m_pBitmap || !m_pBitmap->GetBuffer()) |
1602 return TRUE; | 1600 return true; |
1603 | 1601 |
1604 FX_RECT rect(left, top, left + pBitmap->GetWidth(), | 1602 FX_RECT rect(left, top, left + pBitmap->GetWidth(), |
1605 top + pBitmap->GetHeight()); | 1603 top + pBitmap->GetHeight()); |
1606 CFX_DIBitmap* pBack = nullptr; | 1604 CFX_DIBitmap* pBack = nullptr; |
1607 if (m_pOriDevice) { | 1605 if (m_pOriDevice) { |
1608 pBack = m_pOriDevice->Clone(&rect); | 1606 pBack = m_pOriDevice->Clone(&rect); |
1609 if (!pBack) | 1607 if (!pBack) |
1610 return TRUE; | 1608 return true; |
1611 | 1609 |
1612 pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(), | 1610 pBack->CompositeBitmap(0, 0, pBack->GetWidth(), pBack->GetHeight(), |
1613 m_pBitmap, 0, 0); | 1611 m_pBitmap, 0, 0); |
1614 } else { | 1612 } else { |
1615 pBack = m_pBitmap->Clone(&rect); | 1613 pBack = m_pBitmap->Clone(&rect); |
1616 if (!pBack) | 1614 if (!pBack) |
1617 return TRUE; | 1615 return true; |
1618 } | 1616 } |
1619 | 1617 |
1620 FX_BOOL bRet = TRUE; | 1618 bool bRet = true; |
1621 left = std::min(left, 0); | 1619 left = std::min(left, 0); |
1622 top = std::min(top, 0); | 1620 top = std::min(top, 0); |
1623 if (m_bRgbByteOrder) { | 1621 if (m_bRgbByteOrder) { |
1624 RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(), | 1622 RgbByteOrderTransferBitmap(pBitmap, 0, 0, rect.Width(), rect.Height(), |
1625 pBack, left, top); | 1623 pBack, left, top); |
1626 } else { | 1624 } else { |
1627 bRet = pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack, | 1625 bRet = pBitmap->TransferBitmap(0, 0, rect.Width(), rect.Height(), pBack, |
1628 left, top); | 1626 left, top); |
1629 } | 1627 } |
1630 delete pBack; | 1628 delete pBack; |
1631 return bRet; | 1629 return bRet; |
1632 } | 1630 } |
1633 | 1631 |
1634 CFX_DIBitmap* CFX_AggDeviceDriver::GetBackDrop() { | 1632 CFX_DIBitmap* CFX_AggDeviceDriver::GetBackDrop() { |
1635 return m_pOriDevice; | 1633 return m_pOriDevice; |
1636 } | 1634 } |
1637 | 1635 |
1638 FX_BOOL CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, | 1636 bool CFX_AggDeviceDriver::SetDIBits(const CFX_DIBSource* pBitmap, |
1639 uint32_t argb, | 1637 uint32_t argb, |
1640 const FX_RECT* pSrcRect, | 1638 const FX_RECT* pSrcRect, |
1641 int left, | 1639 int left, |
1642 int top, | 1640 int top, |
1643 int blend_type) { | 1641 int blend_type) { |
1644 if (!m_pBitmap->GetBuffer()) | 1642 if (!m_pBitmap->GetBuffer()) |
1645 return TRUE; | 1643 return true; |
1646 | 1644 |
1647 if (pBitmap->IsAlphaMask()) { | 1645 if (pBitmap->IsAlphaMask()) { |
1648 return m_pBitmap->CompositeMask( | 1646 return m_pBitmap->CompositeMask( |
1649 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb, | 1647 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, argb, |
1650 pSrcRect->left, pSrcRect->top, blend_type, m_pClipRgn.get(), | 1648 pSrcRect->left, pSrcRect->top, blend_type, m_pClipRgn.get(), |
1651 m_bRgbByteOrder, 0, nullptr); | 1649 m_bRgbByteOrder, 0, nullptr); |
1652 } | 1650 } |
1653 return m_pBitmap->CompositeBitmap( | 1651 return m_pBitmap->CompositeBitmap( |
1654 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left, | 1652 left, top, pSrcRect->Width(), pSrcRect->Height(), pBitmap, pSrcRect->left, |
1655 pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder, nullptr); | 1653 pSrcRect->top, blend_type, m_pClipRgn.get(), m_bRgbByteOrder, nullptr); |
1656 } | 1654 } |
1657 | 1655 |
1658 FX_BOOL CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, | 1656 bool CFX_AggDeviceDriver::StretchDIBits(const CFX_DIBSource* pSource, |
1659 uint32_t argb, | 1657 uint32_t argb, |
1660 int dest_left, | 1658 int dest_left, |
1661 int dest_top, | 1659 int dest_top, |
1662 int dest_width, | 1660 int dest_width, |
1663 int dest_height, | 1661 int dest_height, |
1664 const FX_RECT* pClipRect, | 1662 const FX_RECT* pClipRect, |
1665 uint32_t flags, | 1663 uint32_t flags, |
1666 int blend_type) { | 1664 int blend_type) { |
1667 if (!m_pBitmap->GetBuffer()) | 1665 if (!m_pBitmap->GetBuffer()) |
1668 return TRUE; | 1666 return true; |
1669 | 1667 |
1670 if (dest_width == pSource->GetWidth() && | 1668 if (dest_width == pSource->GetWidth() && |
1671 dest_height == pSource->GetHeight()) { | 1669 dest_height == pSource->GetHeight()) { |
1672 FX_RECT rect(0, 0, dest_width, dest_height); | 1670 FX_RECT rect(0, 0, dest_width, dest_height); |
1673 return SetDIBits(pSource, argb, &rect, dest_left, dest_top, blend_type); | 1671 return SetDIBits(pSource, argb, &rect, dest_left, dest_top, blend_type); |
1674 } | 1672 } |
1675 FX_RECT dest_rect(dest_left, dest_top, dest_left + dest_width, | 1673 FX_RECT dest_rect(dest_left, dest_top, dest_left + dest_width, |
1676 dest_top + dest_height); | 1674 dest_top + dest_height); |
1677 dest_rect.Normalize(); | 1675 dest_rect.Normalize(); |
1678 FX_RECT dest_clip = dest_rect; | 1676 FX_RECT dest_clip = dest_rect; |
1679 dest_clip.Intersect(*pClipRect); | 1677 dest_clip.Intersect(*pClipRect); |
1680 CFX_BitmapComposer composer; | 1678 CFX_BitmapComposer composer; |
1681 composer.Compose(m_pBitmap, m_pClipRgn.get(), 255, argb, dest_clip, FALSE, | 1679 composer.Compose(m_pBitmap, m_pClipRgn.get(), 255, argb, dest_clip, false, |
1682 FALSE, FALSE, m_bRgbByteOrder, 0, nullptr, blend_type); | 1680 false, false, m_bRgbByteOrder, 0, nullptr, blend_type); |
1683 dest_clip.Offset(-dest_rect.left, -dest_rect.top); | 1681 dest_clip.Offset(-dest_rect.left, -dest_rect.top); |
1684 CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height, | 1682 CFX_ImageStretcher stretcher(&composer, pSource, dest_width, dest_height, |
1685 dest_clip, flags); | 1683 dest_clip, flags); |
1686 if (stretcher.Start()) | 1684 if (stretcher.Start()) |
1687 stretcher.Continue(nullptr); | 1685 stretcher.Continue(nullptr); |
1688 return TRUE; | 1686 return true; |
1689 } | 1687 } |
1690 | 1688 |
1691 FX_BOOL CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, | 1689 bool CFX_AggDeviceDriver::StartDIBits(const CFX_DIBSource* pSource, |
1692 int bitmap_alpha, | 1690 int bitmap_alpha, |
1693 uint32_t argb, | 1691 uint32_t argb, |
1694 const CFX_Matrix* pMatrix, | 1692 const CFX_Matrix* pMatrix, |
1695 uint32_t render_flags, | 1693 uint32_t render_flags, |
1696 void*& handle, | 1694 void*& handle, |
1697 int blend_type) { | 1695 int blend_type) { |
1698 if (!m_pBitmap->GetBuffer()) | 1696 if (!m_pBitmap->GetBuffer()) |
1699 return TRUE; | 1697 return true; |
1700 | 1698 |
1701 CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer; | 1699 CFX_ImageRenderer* pRenderer = new CFX_ImageRenderer; |
1702 pRenderer->Start(m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, | 1700 pRenderer->Start(m_pBitmap, m_pClipRgn.get(), pSource, bitmap_alpha, argb, |
1703 pMatrix, render_flags, m_bRgbByteOrder, 0, nullptr); | 1701 pMatrix, render_flags, m_bRgbByteOrder, 0, nullptr); |
1704 handle = pRenderer; | 1702 handle = pRenderer; |
1705 return TRUE; | 1703 return true; |
1706 } | 1704 } |
1707 | 1705 |
1708 FX_BOOL CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) { | 1706 bool CFX_AggDeviceDriver::ContinueDIBits(void* pHandle, IFX_Pause* pPause) { |
1709 if (!m_pBitmap->GetBuffer()) { | 1707 if (!m_pBitmap->GetBuffer()) { |
1710 return TRUE; | 1708 return true; |
1711 } | 1709 } |
1712 return ((CFX_ImageRenderer*)pHandle)->Continue(pPause); | 1710 return ((CFX_ImageRenderer*)pHandle)->Continue(pPause); |
1713 } | 1711 } |
1714 | 1712 |
1715 void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) { | 1713 void CFX_AggDeviceDriver::CancelDIBits(void* pHandle) { |
1716 if (!m_pBitmap->GetBuffer()) { | 1714 if (!m_pBitmap->GetBuffer()) { |
1717 return; | 1715 return; |
1718 } | 1716 } |
1719 delete (CFX_ImageRenderer*)pHandle; | 1717 delete (CFX_ImageRenderer*)pHandle; |
1720 } | 1718 } |
1721 | 1719 |
1722 #ifndef _SKIA_SUPPORT_ | 1720 #ifndef _SKIA_SUPPORT_ |
1723 CFX_FxgeDevice::CFX_FxgeDevice() { | 1721 CFX_FxgeDevice::CFX_FxgeDevice() { |
1724 m_bOwnedBitmap = FALSE; | 1722 m_bOwnedBitmap = false; |
1725 } | 1723 } |
1726 | 1724 |
1727 bool CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, | 1725 bool CFX_FxgeDevice::Attach(CFX_DIBitmap* pBitmap, |
1728 bool bRgbByteOrder, | 1726 bool bRgbByteOrder, |
1729 CFX_DIBitmap* pOriDevice, | 1727 CFX_DIBitmap* pOriDevice, |
1730 bool bGroupKnockout) { | 1728 bool bGroupKnockout) { |
1731 if (!pBitmap) | 1729 if (!pBitmap) |
1732 return false; | 1730 return false; |
1733 | 1731 |
1734 SetBitmap(pBitmap); | 1732 SetBitmap(pBitmap); |
(...skipping 17 matching lines...) Expand all Loading... |
1752 pOriDevice, false)); | 1750 pOriDevice, false)); |
1753 return true; | 1751 return true; |
1754 } | 1752 } |
1755 | 1753 |
1756 CFX_FxgeDevice::~CFX_FxgeDevice() { | 1754 CFX_FxgeDevice::~CFX_FxgeDevice() { |
1757 if (m_bOwnedBitmap) { | 1755 if (m_bOwnedBitmap) { |
1758 delete GetBitmap(); | 1756 delete GetBitmap(); |
1759 } | 1757 } |
1760 } | 1758 } |
1761 #endif | 1759 #endif |
OLD | NEW |