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

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

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

Powered by Google App Engine
This is Rietveld 408576698