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

Side by Side Diff: core/fpdfapi/fpdf_render/fpdf_render.cpp

Issue 2303553002: Make CPDF_GeneralState have a CPDF_GeneralStateData (Closed)
Patch Set: Move functions .cpp file Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/fpdfapi/fpdf_render/render_int.h" 7 #include "core/fpdfapi/fpdf_render/render_int.h"
8 8
9 #include <memory> 9 #include <memory>
10 10
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 } 241 }
242 RenderSingleObject(pCurObj.get(), pObj2Device); 242 RenderSingleObject(pCurObj.get(), pObj2Device);
243 if (m_bStopped) 243 if (m_bStopped)
244 return; 244 return;
245 } 245 }
246 #if defined _SKIA_SUPPORT_ 246 #if defined _SKIA_SUPPORT_
247 DebugVerifyDeviceIsPreMultiplied(); 247 DebugVerifyDeviceIsPreMultiplied();
248 #endif 248 #endif
249 } 249 }
250 250
251 void CPDF_RenderStatus::RenderSingleObject(const CPDF_PageObject* pObj, 251 void CPDF_RenderStatus::RenderSingleObject(CPDF_PageObject* pObj,
252 const CFX_Matrix* pObj2Device) { 252 const CFX_Matrix* pObj2Device) {
253 #if defined _SKIA_SUPPORT_ 253 #if defined _SKIA_SUPPORT_
254 DebugVerifyDeviceIsPreMultiplied(); 254 DebugVerifyDeviceIsPreMultiplied();
255 #endif 255 #endif
256 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth); 256 CFX_AutoRestorer<int> restorer(&s_CurrentRecursionDepth);
257 if (++s_CurrentRecursionDepth > kRenderMaxRecursionDepth) { 257 if (++s_CurrentRecursionDepth > kRenderMaxRecursionDepth) {
258 return; 258 return;
259 } 259 }
260 m_pCurObj = pObj; 260 m_pCurObj = pObj;
261 if (m_Options.m_pOCContext && pObj->m_ContentMark) { 261 if (m_Options.m_pOCContext && pObj->m_ContentMark) {
262 if (!m_Options.m_pOCContext->CheckObjectVisible(pObj)) { 262 if (!m_Options.m_pOCContext->CheckObjectVisible(pObj)) {
263 return; 263 return;
264 } 264 }
265 } 265 }
266 ProcessClipPath(pObj->m_ClipPath, pObj2Device); 266 ProcessClipPath(pObj->m_ClipPath, pObj2Device);
267 if (ProcessTransparency(pObj, pObj2Device)) { 267 if (ProcessTransparency(pObj, pObj2Device)) {
268 return; 268 return;
269 } 269 }
270 ProcessObjectNoClip(pObj, pObj2Device); 270 ProcessObjectNoClip(pObj, pObj2Device);
271 #if defined _SKIA_SUPPORT_ 271 #if defined _SKIA_SUPPORT_
272 DebugVerifyDeviceIsPreMultiplied(); 272 DebugVerifyDeviceIsPreMultiplied();
273 #endif 273 #endif
274 } 274 }
275 275
276 FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, 276 FX_BOOL CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj,
277 const CFX_Matrix* pObj2Device, 277 const CFX_Matrix* pObj2Device,
278 IFX_Pause* pPause) { 278 IFX_Pause* pPause) {
279 if (m_pImageRenderer) { 279 if (m_pImageRenderer) {
280 if (m_pImageRenderer->Continue(pPause)) 280 if (m_pImageRenderer->Continue(pPause))
281 return TRUE; 281 return TRUE;
282 282
283 if (!m_pImageRenderer->m_Result) 283 if (!m_pImageRenderer->m_Result)
284 DrawObjWithBackground(pObj, pObj2Device); 284 DrawObjWithBackground(pObj, pObj2Device);
285 m_pImageRenderer.reset(); 285 m_pImageRenderer.reset();
286 return FALSE; 286 return FALSE;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 rtClip.right = 327 rtClip.right =
328 rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Width() * a); 328 rtClip.left + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Width() * a);
329 rtClip.bottom = 329 rtClip.bottom =
330 rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d); 330 rtClip.top + (int32_t)FXSYS_ceil((FX_FLOAT)rtClip.Height() * d);
331 } 331 }
332 } 332 }
333 rect.Intersect(rtClip); 333 rect.Intersect(rtClip);
334 return rect.IsEmpty(); 334 return rect.IsEmpty();
335 } 335 }
336 336
337 void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, 337 void CPDF_RenderStatus::ProcessObjectNoClip(CPDF_PageObject* pObj,
338 const CFX_Matrix* pObj2Device) { 338 const CFX_Matrix* pObj2Device) {
339 #if defined _SKIA_SUPPORT_ 339 #if defined _SKIA_SUPPORT_
340 DebugVerifyDeviceIsPreMultiplied(); 340 DebugVerifyDeviceIsPreMultiplied();
341 #endif 341 #endif
342 FX_BOOL bRet = FALSE; 342 FX_BOOL bRet = FALSE;
343 switch (pObj->GetType()) { 343 switch (pObj->GetType()) {
344 case CPDF_PageObject::TEXT: 344 case CPDF_PageObject::TEXT:
345 bRet = ProcessText(pObj->AsText(), pObj2Device, nullptr); 345 bRet = ProcessText(pObj->AsText(), pObj2Device, nullptr);
346 break; 346 break;
347 case CPDF_PageObject::PATH: 347 case CPDF_PageObject::PATH:
348 bRet = ProcessPath(pObj->AsPath(), pObj2Device); 348 bRet = ProcessPath(pObj->AsPath(), pObj2Device);
349 break; 349 break;
350 case CPDF_PageObject::IMAGE: 350 case CPDF_PageObject::IMAGE:
351 bRet = ProcessImage(pObj->AsImage(), pObj2Device); 351 bRet = ProcessImage(pObj->AsImage(), pObj2Device);
352 break; 352 break;
353 case CPDF_PageObject::SHADING: 353 case CPDF_PageObject::SHADING:
354 ProcessShading(pObj->AsShading(), pObj2Device); 354 ProcessShading(pObj->AsShading(), pObj2Device);
355 return; 355 return;
356 case CPDF_PageObject::FORM: 356 case CPDF_PageObject::FORM:
357 bRet = ProcessForm(pObj->AsForm(), pObj2Device); 357 bRet = ProcessForm(pObj->AsForm(), pObj2Device);
358 break; 358 break;
359 } 359 }
360 if (!bRet) 360 if (!bRet)
361 DrawObjWithBackground(pObj, pObj2Device); 361 DrawObjWithBackground(pObj, pObj2Device);
362 #if defined _SKIA_SUPPORT_ 362 #if defined _SKIA_SUPPORT_
363 DebugVerifyDeviceIsPreMultiplied(); 363 DebugVerifyDeviceIsPreMultiplied();
364 #endif 364 #endif
365 } 365 }
366 366
367 FX_BOOL CPDF_RenderStatus::DrawObjWithBlend(const CPDF_PageObject* pObj, 367 FX_BOOL CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj,
368 const CFX_Matrix* pObj2Device) { 368 const CFX_Matrix* pObj2Device) {
369 FX_BOOL bRet = FALSE; 369 FX_BOOL bRet = FALSE;
370 switch (pObj->GetType()) { 370 switch (pObj->GetType()) {
371 case CPDF_PageObject::PATH: 371 case CPDF_PageObject::PATH:
372 bRet = ProcessPath(pObj->AsPath(), pObj2Device); 372 bRet = ProcessPath(pObj->AsPath(), pObj2Device);
373 break; 373 break;
374 case CPDF_PageObject::IMAGE: 374 case CPDF_PageObject::IMAGE:
375 bRet = ProcessImage(pObj->AsImage(), pObj2Device); 375 bRet = ProcessImage(pObj->AsImage(), pObj2Device);
376 break; 376 break;
377 case CPDF_PageObject::FORM: 377 case CPDF_PageObject::FORM:
378 bRet = ProcessForm(pObj->AsForm(), pObj2Device); 378 bRet = ProcessForm(pObj->AsForm(), pObj2Device);
379 break; 379 break;
380 default: 380 default:
381 break; 381 break;
382 } 382 }
383 return bRet; 383 return bRet;
384 } 384 }
385 void CPDF_RenderStatus::GetScaledMatrix(CFX_Matrix& matrix) const { 385 void CPDF_RenderStatus::GetScaledMatrix(CFX_Matrix& matrix) const {
386 CFX_Matrix dCTM = m_pDevice->GetCTM(); 386 CFX_Matrix dCTM = m_pDevice->GetCTM();
387 matrix.a *= FXSYS_fabs(dCTM.a); 387 matrix.a *= FXSYS_fabs(dCTM.a);
388 matrix.d *= FXSYS_fabs(dCTM.d); 388 matrix.d *= FXSYS_fabs(dCTM.d);
389 } 389 }
390 void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, 390
391 void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj,
391 const CFX_Matrix* pObj2Device) { 392 const CFX_Matrix* pObj2Device) {
392 FX_RECT rect; 393 FX_RECT rect;
393 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { 394 if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) {
394 return; 395 return;
395 } 396 }
396 int res = 300; 397 int res = 300;
397 if (pObj->IsImage() && 398 if (pObj->IsImage() &&
398 m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) { 399 m_pDevice->GetDeviceCaps(FXDC_DEVICE_CLASS) == FXDC_PRINTER) {
399 res = 0; 400 res = 0;
400 } 401 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) { 455 FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) {
455 if (matrix.a == 0 || matrix.d == 0) { 456 if (matrix.a == 0 || matrix.d == 0) {
456 return matrix.b != 0 && matrix.c != 0; 457 return matrix.b != 0 && matrix.c != 0;
457 } 458 }
458 if (matrix.b == 0 || matrix.c == 0) { 459 if (matrix.b == 0 || matrix.c == 0) {
459 return matrix.a != 0 && matrix.d != 0; 460 return matrix.a != 0 && matrix.d != 0;
460 } 461 }
461 return TRUE; 462 return TRUE;
462 } 463 }
463 464
464 FX_BOOL CPDF_RenderStatus::ProcessPath(const CPDF_PathObject* pPathObj, 465 FX_BOOL CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj,
465 const CFX_Matrix* pObj2Device) { 466 const CFX_Matrix* pObj2Device) {
466 int FillType = pPathObj->m_FillType; 467 int FillType = pPathObj->m_FillType;
467 FX_BOOL bStroke = pPathObj->m_bStroke; 468 FX_BOOL bStroke = pPathObj->m_bStroke;
468 ProcessPathPattern(pPathObj, pObj2Device, FillType, bStroke); 469 ProcessPathPattern(pPathObj, pObj2Device, FillType, bStroke);
469 if (FillType == 0 && !bStroke) 470 if (FillType == 0 && !bStroke)
470 return TRUE; 471 return TRUE;
471 472
472 uint32_t fill_argb = FillType ? GetFillArgb(pPathObj) : 0; 473 uint32_t fill_argb = FillType ? GetFillArgb(pPathObj) : 0;
473 uint32_t stroke_argb = bStroke ? GetStrokeArgb(pPathObj) : 0; 474 uint32_t stroke_argb = bStroke ? GetStrokeArgb(pPathObj) : 0;
474 CFX_Matrix path_matrix = pPathObj->m_Matrix; 475 CFX_Matrix path_matrix = pPathObj->m_Matrix;
475 path_matrix.Concat(*pObj2Device); 476 path_matrix.Concat(*pObj2Device);
476 if (!IsAvailableMatrix(path_matrix)) 477 if (!IsAvailableMatrix(path_matrix))
477 return TRUE; 478 return TRUE;
478 479
479 if (FillType && (m_Options.m_Flags & RENDER_RECT_AA)) 480 if (FillType && (m_Options.m_Flags & RENDER_RECT_AA))
480 FillType |= FXFILL_RECT_AA; 481 FillType |= FXFILL_RECT_AA;
481 if (m_Options.m_Flags & RENDER_FILL_FULLCOVER) 482 if (m_Options.m_Flags & RENDER_FILL_FULLCOVER)
482 FillType |= FXFILL_FULLCOVER; 483 FillType |= FXFILL_FULLCOVER;
483 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) 484 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH)
484 FillType |= FXFILL_NOPATHSMOOTH; 485 FillType |= FXFILL_NOPATHSMOOTH;
485 if (bStroke) 486 if (bStroke)
486 FillType |= FX_FILL_STROKE; 487 FillType |= FX_FILL_STROKE;
487 const CPDF_GeneralStateData* pGeneralData = 488
488 static_cast<const CPDF_PageObject*>(pPathObj)->m_GeneralState.GetObject(); 489 const CPDF_PageObject* pPageObj =
489 if (pGeneralData && pGeneralData->m_StrokeAdjust) 490 static_cast<const CPDF_PageObject*>(pPathObj);
491 if (pPageObj->m_GeneralState.GetStrokeAdjust())
490 FillType |= FX_STROKE_ADJUST; 492 FillType |= FX_STROKE_ADJUST;
491 if (m_pType3Char) 493 if (m_pType3Char)
492 FillType |= FX_FILL_TEXT_MODE; 494 FillType |= FX_FILL_TEXT_MODE;
493 495
494 CPDF_GraphState graphState = pPathObj->m_GraphState; 496 CPDF_GraphState graphState = pPathObj->m_GraphState;
495 if (m_Options.m_Flags & RENDER_THINLINE) 497 if (m_Options.m_Flags & RENDER_THINLINE)
496 graphState.SetLineWidth(0); 498 graphState.SetLineWidth(0);
497 return m_pDevice->DrawPathWithBlend( 499 return m_pDevice->DrawPathWithBlend(
498 pPathObj->m_Path.GetObject(), &path_matrix, graphState.GetObject(), 500 pPathObj->m_Path.GetObject(), &path_matrix, graphState.GetObject(),
499 fill_argb, stroke_argb, FillType, m_curBlend); 501 fill_argb, stroke_argb, FillType, m_curBlend);
500 } 502 }
501 503
502 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const { 504 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const {
503 ASSERT(pObj); 505 ASSERT(pObj);
504 CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData(); 506 CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData();
505 return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr; 507 return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr;
506 } 508 }
507 FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, 509
510 FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj,
508 FX_BOOL bType3) const { 511 FX_BOOL bType3) const {
509 const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject(); 512 const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject();
510 if (m_pType3Char && !bType3 && 513 if (m_pType3Char && !bType3 &&
511 (!m_pType3Char->m_bColored || 514 (!m_pType3Char->m_bColored ||
512 (m_pType3Char->m_bColored && 515 (m_pType3Char->m_bColored &&
513 (!pColorData || pColorData->m_FillColor.IsNull())))) { 516 (!pColorData || pColorData->m_FillColor.IsNull())))) {
514 return m_T3FillColor; 517 return m_T3FillColor;
515 } 518 }
516 if (!pColorData || pColorData->m_FillColor.IsNull()) { 519 if (!pColorData || pColorData->m_FillColor.IsNull()) {
517 pColorData = m_InitialStates.m_ColorState.GetObject(); 520 pColorData = m_InitialStates.m_ColorState.GetObject();
518 } 521 }
519 FX_COLORREF rgb = pColorData->m_FillRGB; 522 FX_COLORREF rgb = pColorData->m_FillRGB;
520 if (rgb == (uint32_t)-1) { 523 if (rgb == (uint32_t)-1) {
521 return 0; 524 return 0;
522 } 525 }
523 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState.GetObject(); 526 int32_t alpha = (int32_t)(pObj->m_GeneralState.GetFillAlpha() * 255);
524 int alpha; 527 if (pObj->m_GeneralState.GetTR()) {
525 if (pGeneralData) { 528 if (!pObj->m_GeneralState.GetTransferFunc()) {
526 alpha = (int32_t)(pGeneralData->m_FillAlpha * 255); 529 pObj->m_GeneralState.SetTransferFunc(
527 if (pGeneralData->m_pTR) { 530 GetTransferFunc(pObj->m_GeneralState.GetTR()));
528 if (!pGeneralData->m_pTransferFunc) {
529 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc =
530 GetTransferFunc(pGeneralData->m_pTR);
531 }
532 if (pGeneralData->m_pTransferFunc) {
533 rgb = pGeneralData->m_pTransferFunc->TranslateColor(rgb);
534 }
535 } 531 }
536 } else { 532 if (pObj->m_GeneralState.GetTransferFunc())
537 alpha = 255; 533 rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb);
538 } 534 }
539 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); 535 return m_Options.TranslateColor(ArgbEncode(alpha, rgb));
540 } 536 }
541 FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const { 537
538 FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const {
542 const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject(); 539 const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject();
543 if (m_pType3Char && (!m_pType3Char->m_bColored || 540 if (m_pType3Char && (!m_pType3Char->m_bColored ||
544 (m_pType3Char->m_bColored && 541 (m_pType3Char->m_bColored &&
545 (!pColorData || pColorData->m_StrokeColor.IsNull())))) { 542 (!pColorData || pColorData->m_StrokeColor.IsNull())))) {
546 return m_T3FillColor; 543 return m_T3FillColor;
547 } 544 }
548 if (!pColorData || pColorData->m_StrokeColor.IsNull()) { 545 if (!pColorData || pColorData->m_StrokeColor.IsNull()) {
549 pColorData = m_InitialStates.m_ColorState.GetObject(); 546 pColorData = m_InitialStates.m_ColorState.GetObject();
550 } 547 }
551 FX_COLORREF rgb = pColorData->m_StrokeRGB; 548 FX_COLORREF rgb = pColorData->m_StrokeRGB;
552 if (rgb == (uint32_t)-1) { 549 if (rgb == (uint32_t)-1) {
553 return 0; 550 return 0;
554 } 551 }
555 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState.GetObject(); 552 int32_t alpha =
556 int alpha; 553 (int32_t)(pObj->m_GeneralState.GetStrokeAlpha() * 255); // not rounded.
557 if (pGeneralData) { 554 if (pObj->m_GeneralState.GetTR()) {
558 alpha = (int32_t)(pGeneralData->m_StrokeAlpha * 255); 555 if (!pObj->m_GeneralState.GetTransferFunc()) {
559 if (pGeneralData->m_pTR) { 556 pObj->m_GeneralState.SetTransferFunc(
560 if (!pGeneralData->m_pTransferFunc) { 557 GetTransferFunc(pObj->m_GeneralState.GetTR()));
561 ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc =
562 GetTransferFunc(pGeneralData->m_pTR);
563 }
564 if (pGeneralData->m_pTransferFunc) {
565 rgb = pGeneralData->m_pTransferFunc->TranslateColor(rgb);
566 }
567 } 558 }
568 } else { 559 if (pObj->m_GeneralState.GetTransferFunc())
569 alpha = 255; 560 rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb);
570 } 561 }
571 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); 562 return m_Options.TranslateColor(ArgbEncode(alpha, rgb));
572 } 563 }
573 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, 564 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath,
574 const CFX_Matrix* pObj2Device) { 565 const CFX_Matrix* pObj2Device) {
575 if (!ClipPath) { 566 if (!ClipPath) {
576 if (m_LastClipPath) { 567 if (m_LastClipPath) {
577 m_pDevice->RestoreState(true); 568 m_pDevice->RestoreState(true);
578 m_LastClipPath.SetNull(); 569 m_LastClipPath.SetNull();
579 } 570 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
667 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path.GetObject(), 658 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path.GetObject(),
668 &path_matrix, &graphState); 659 &path_matrix, &graphState);
669 } 660 }
670 int fill_mode = pPathObj->m_FillType; 661 int fill_mode = pPathObj->m_FillType;
671 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { 662 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) {
672 fill_mode |= FXFILL_NOPATHSMOOTH; 663 fill_mode |= FXFILL_NOPATHSMOOTH;
673 } 664 }
674 return m_pDevice->SetClip_PathFill(pPathObj->m_Path.GetObject(), &path_matrix, 665 return m_pDevice->SetClip_PathFill(pPathObj->m_Path.GetObject(), &path_matrix,
675 fill_mode); 666 fill_mode);
676 } 667 }
677 FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, 668 FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
678 const CFX_Matrix* pObj2Device) { 669 const CFX_Matrix* pObj2Device) {
679 #if defined _SKIA_SUPPORT_ 670 #if defined _SKIA_SUPPORT_
680 DebugVerifyDeviceIsPreMultiplied(); 671 DebugVerifyDeviceIsPreMultiplied();
681 #endif 672 #endif
682 const CPDF_GeneralStateData* pGeneralState = 673 int blend_type = pPageObj->m_GeneralState.GetBlendType();
683 pPageObj->m_GeneralState.GetObject(); 674 if (blend_type == FXDIB_BLEND_UNSUPPORTED)
684 int blend_type =
685 pGeneralState ? pGeneralState->m_BlendType : FXDIB_BLEND_NORMAL;
686 if (blend_type == FXDIB_BLEND_UNSUPPORTED) {
687 return TRUE; 675 return TRUE;
688 } 676
689 CPDF_Dictionary* pSMaskDict = 677 CPDF_Dictionary* pSMaskDict =
690 pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : nullptr; 678 ToDictionary(pPageObj->m_GeneralState.GetSoftMask());
691 if (pSMaskDict) { 679 if (pSMaskDict) {
692 if (pPageObj->IsImage() && 680 if (pPageObj->IsImage() &&
693 pPageObj->AsImage()->GetImage()->GetDict()->KeyExist("SMask")) { 681 pPageObj->AsImage()->GetImage()->GetDict()->KeyExist("SMask")) {
694 pSMaskDict = nullptr; 682 pSMaskDict = nullptr;
695 } 683 }
696 } 684 }
697 CPDF_Dictionary* pFormResource = nullptr; 685 CPDF_Dictionary* pFormResource = nullptr;
698 FX_FLOAT group_alpha = 1.0f; 686 FX_FLOAT group_alpha = 1.0f;
699 int Transparency = m_Transparency; 687 int Transparency = m_Transparency;
700 FX_BOOL bGroupTransparent = FALSE; 688 FX_BOOL bGroupTransparent = FALSE;
701 if (pPageObj->IsForm()) { 689 if (pPageObj->IsForm()) {
702 const CPDF_FormObject* pFormObj = pPageObj->AsForm(); 690 const CPDF_FormObject* pFormObj = pPageObj->AsForm();
703 const CPDF_GeneralStateData* pStateData = 691 group_alpha = pFormObj->m_GeneralState.GetFillAlpha();
704 pFormObj->m_GeneralState.GetObject();
705 if (pStateData) {
706 group_alpha = pStateData->m_FillAlpha;
707 }
708 Transparency = pFormObj->m_pForm->m_Transparency; 692 Transparency = pFormObj->m_pForm->m_Transparency;
709 bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED); 693 bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED);
710 if (pFormObj->m_pForm->m_pFormDict) { 694 if (pFormObj->m_pForm->m_pFormDict) {
711 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); 695 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources");
712 } 696 }
713 } 697 }
714 bool bTextClip = 698 bool bTextClip =
715 (pPageObj->m_ClipPath && pPageObj->m_ClipPath.GetTextCount() && 699 (pPageObj->m_ClipPath && pPageObj->m_ClipPath.GetTextCount() &&
716 m_pDevice->GetDeviceClass() == FXDC_DISPLAY && 700 m_pDevice->GetDeviceClass() == FXDC_DISPLAY &&
717 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)); 701 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP));
718 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() && 702 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() &&
719 pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { 703 pPageObj->m_GeneralState.GetFillOP() &&
704 pPageObj->m_GeneralState.GetStrokeOP()) {
720 CPDF_Document* pDocument = nullptr; 705 CPDF_Document* pDocument = nullptr;
721 CPDF_Page* pPage = nullptr; 706 CPDF_Page* pPage = nullptr;
722 if (m_pContext->GetPageCache()) { 707 if (m_pContext->GetPageCache()) {
723 pPage = m_pContext->GetPageCache()->GetPage(); 708 pPage = m_pContext->GetPageCache()->GetPage();
724 pDocument = pPage->m_pDocument; 709 pDocument = pPage->m_pDocument;
725 } else { 710 } else {
726 pDocument = pPageObj->AsImage()->GetImage()->GetDocument(); 711 pDocument = pPageObj->AsImage()->GetImage()->GetDocument();
727 } 712 }
728 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; 713 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr;
729 CPDF_Object* pCSObj = pPageObj->AsImage() 714 CPDF_Object* pCSObj = pPageObj->AsImage()
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 } 796 }
812 } 797 }
813 CPDF_RenderStatus bitmap_render; 798 CPDF_RenderStatus bitmap_render;
814 bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, 799 bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj,
815 nullptr, nullptr, &m_Options, 0, m_bDropObjects, 800 nullptr, nullptr, &m_Options, 0, m_bDropObjects,
816 pFormResource, TRUE); 801 pFormResource, TRUE);
817 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); 802 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix);
818 m_bStopped = bitmap_render.m_bStopped; 803 m_bStopped = bitmap_render.m_bStopped;
819 if (pSMaskDict) { 804 if (pSMaskDict) {
820 CFX_Matrix smask_matrix; 805 CFX_Matrix smask_matrix;
821 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, 806 FXSYS_memcpy(&smask_matrix, pPageObj->m_GeneralState.GetSMaskMatrix(),
822 sizeof smask_matrix); 807 sizeof smask_matrix);
823 smask_matrix.Concat(*pObj2Device); 808 smask_matrix.Concat(*pObj2Device);
824 std::unique_ptr<CFX_DIBSource> pSMaskSource( 809 std::unique_ptr<CFX_DIBSource> pSMaskSource(
825 LoadSMask(pSMaskDict, &rect, &smask_matrix)); 810 LoadSMask(pSMaskDict, &rect, &smask_matrix));
826 if (pSMaskSource) 811 if (pSMaskSource)
827 bitmap->MultiplyAlpha(pSMaskSource.get()); 812 bitmap->MultiplyAlpha(pSMaskSource.get());
828 } 813 }
829 if (pTextMask) { 814 if (pTextMask) {
830 bitmap->MultiplyAlpha(pTextMask.get()); 815 bitmap->MultiplyAlpha(pTextMask.get());
831 pTextMask.reset(); 816 pTextMask.reset();
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, 1277 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left,
1293 m_Rect.top, m_Rect.Width(), m_Rect.Height()); 1278 m_Rect.top, m_Rect.Width(), m_Rect.Height());
1294 } 1279 }
1295 } 1280 }
1296 1281
1297 #if defined _SKIA_SUPPORT_ 1282 #if defined _SKIA_SUPPORT_
1298 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { 1283 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const {
1299 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); 1284 m_pDevice->DebugVerifyBitmapIsPreMultiplied();
1300 } 1285 }
1301 #endif 1286 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698