Chromium Code Reviews| 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/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 Loading... | |
| 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 Loading... | |
| 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 Loading... | |
| 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 = (int32_t)(pObj->m_GeneralState.GetFillAlpha() * 255); |
|
Lei Zhang
2016/09/02 22:00:43
Get rid of C-style casts here and below.
Tom Sepez
2016/09/02 22:09:57
Done.
| |
| 525 int alpha; | 528 if (pObj->m_GeneralState.GetTR()) { |
| 526 if (pGeneralData) { | 529 if (!pObj->m_GeneralState.GetTransferFunc()) { |
| 527 alpha = (int32_t)(pGeneralData->m_FillAlpha * 255); | 530 pObj->m_GeneralState.SetTransferFunc( |
| 528 if (pGeneralData->m_pTR) { | 531 GetTransferFunc(pObj->m_GeneralState.GetTR())); |
| 529 if (!pGeneralData->m_pTransferFunc) { | |
| 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 } | 532 } |
| 537 } else { | 533 if (pObj->m_GeneralState.GetTransferFunc()) |
| 538 alpha = 255; | 534 rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb); |
| 539 } | 535 } |
| 540 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); | 536 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); |
| 541 } | 537 } |
| 542 FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const { | 538 |
| 539 FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const { | |
| 543 const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject(); | 540 const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject(); |
| 544 if (m_pType3Char && (!m_pType3Char->m_bColored || | 541 if (m_pType3Char && (!m_pType3Char->m_bColored || |
| 545 (m_pType3Char->m_bColored && | 542 (m_pType3Char->m_bColored && |
| 546 (!pColorData || pColorData->m_StrokeColor.IsNull())))) { | 543 (!pColorData || pColorData->m_StrokeColor.IsNull())))) { |
| 547 return m_T3FillColor; | 544 return m_T3FillColor; |
| 548 } | 545 } |
| 549 if (!pColorData || pColorData->m_StrokeColor.IsNull()) { | 546 if (!pColorData || pColorData->m_StrokeColor.IsNull()) { |
| 550 pColorData = m_InitialStates.m_ColorState.GetObject(); | 547 pColorData = m_InitialStates.m_ColorState.GetObject(); |
| 551 } | 548 } |
| 552 FX_COLORREF rgb = pColorData->m_StrokeRGB; | 549 FX_COLORREF rgb = pColorData->m_StrokeRGB; |
| 553 if (rgb == (uint32_t)-1) { | 550 if (rgb == (uint32_t)-1) { |
| 554 return 0; | 551 return 0; |
| 555 } | 552 } |
| 556 const CPDF_GeneralStateData* pGeneralData = pObj->m_GeneralState.GetObject(); | 553 int32_t alpha = |
| 557 int alpha; | 554 (int32_t)(pObj->m_GeneralState.GetStrokeAlpha() * 255); // not rounded. |
| 558 if (pGeneralData) { | 555 if (pObj->m_GeneralState.GetTR()) { |
| 559 alpha = (int32_t)(pGeneralData->m_StrokeAlpha * 255); | 556 if (!pObj->m_GeneralState.GetTransferFunc()) { |
| 560 if (pGeneralData->m_pTR) { | 557 pObj->m_GeneralState.SetTransferFunc( |
| 561 if (!pGeneralData->m_pTransferFunc) { | 558 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 } | 559 } |
| 569 } else { | 560 if (pObj->m_GeneralState.GetTransferFunc()) |
| 570 alpha = 255; | 561 rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb); |
| 571 } | 562 } |
| 572 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); | 563 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); |
| 573 } | 564 } |
| 574 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, | 565 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, |
| 575 const CFX_Matrix* pObj2Device) { | 566 const CFX_Matrix* pObj2Device) { |
| 576 if (!ClipPath) { | 567 if (!ClipPath) { |
| 577 if (m_LastClipPath) { | 568 if (m_LastClipPath) { |
| 578 m_pDevice->RestoreState(true); | 569 m_pDevice->RestoreState(true); |
| 579 m_LastClipPath.SetNull(); | 570 m_LastClipPath.SetNull(); |
| 580 } | 571 } |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path.GetObject(), | 659 return m_pDevice->SetClip_PathStroke(pPathObj->m_Path.GetObject(), |
| 669 &path_matrix, &graphState); | 660 &path_matrix, &graphState); |
| 670 } | 661 } |
| 671 int fill_mode = pPathObj->m_FillType; | 662 int fill_mode = pPathObj->m_FillType; |
| 672 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { | 663 if (m_Options.m_Flags & RENDER_NOPATHSMOOTH) { |
| 673 fill_mode |= FXFILL_NOPATHSMOOTH; | 664 fill_mode |= FXFILL_NOPATHSMOOTH; |
| 674 } | 665 } |
| 675 return m_pDevice->SetClip_PathFill(pPathObj->m_Path.GetObject(), &path_matrix, | 666 return m_pDevice->SetClip_PathFill(pPathObj->m_Path.GetObject(), &path_matrix, |
| 676 fill_mode); | 667 fill_mode); |
| 677 } | 668 } |
| 678 FX_BOOL CPDF_RenderStatus::ProcessTransparency(const CPDF_PageObject* pPageObj, | 669 FX_BOOL CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj, |
| 679 const CFX_Matrix* pObj2Device) { | 670 const CFX_Matrix* pObj2Device) { |
| 680 #if defined _SKIA_SUPPORT_ | 671 #if defined _SKIA_SUPPORT_ |
| 681 DebugVerifyDeviceIsPreMultiplied(); | 672 DebugVerifyDeviceIsPreMultiplied(); |
| 682 #endif | 673 #endif |
| 683 const CPDF_GeneralStateData* pGeneralState = | 674 int blend_type = pPageObj->m_GeneralState.GetBlendType(); |
| 684 pPageObj->m_GeneralState.GetObject(); | 675 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; | 676 return TRUE; |
| 689 } | 677 |
| 690 CPDF_Dictionary* pSMaskDict = | 678 CPDF_Dictionary* pSMaskDict = |
| 691 pGeneralState ? ToDictionary(pGeneralState->m_pSoftMask) : nullptr; | 679 ToDictionary(pPageObj->m_GeneralState.GetSoftMask()); |
| 692 if (pSMaskDict) { | 680 if (pSMaskDict) { |
| 693 if (pPageObj->IsImage() && | 681 if (pPageObj->IsImage() && |
| 694 pPageObj->AsImage()->GetImage()->GetDict()->KeyExist("SMask")) { | 682 pPageObj->AsImage()->GetImage()->GetDict()->KeyExist("SMask")) { |
| 695 pSMaskDict = nullptr; | 683 pSMaskDict = nullptr; |
| 696 } | 684 } |
| 697 } | 685 } |
| 698 CPDF_Dictionary* pFormResource = nullptr; | 686 CPDF_Dictionary* pFormResource = nullptr; |
| 699 FX_FLOAT group_alpha = 1.0f; | 687 FX_FLOAT group_alpha = 1.0f; |
| 700 int Transparency = m_Transparency; | 688 int Transparency = m_Transparency; |
| 701 FX_BOOL bGroupTransparent = FALSE; | 689 FX_BOOL bGroupTransparent = FALSE; |
| 702 if (pPageObj->IsForm()) { | 690 if (pPageObj->IsForm()) { |
| 703 const CPDF_FormObject* pFormObj = pPageObj->AsForm(); | 691 const CPDF_FormObject* pFormObj = pPageObj->AsForm(); |
| 704 const CPDF_GeneralStateData* pStateData = | 692 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; | 693 Transparency = pFormObj->m_pForm->m_Transparency; |
| 710 bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED); | 694 bGroupTransparent = !!(Transparency & PDFTRANS_ISOLATED); |
| 711 if (pFormObj->m_pForm->m_pFormDict) { | 695 if (pFormObj->m_pForm->m_pFormDict) { |
| 712 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); | 696 pFormResource = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); |
| 713 } | 697 } |
| 714 } | 698 } |
| 715 bool bTextClip = | 699 bool bTextClip = |
| 716 (pPageObj->m_ClipPath && pPageObj->m_ClipPath.GetTextCount() && | 700 (pPageObj->m_ClipPath && pPageObj->m_ClipPath.GetTextCount() && |
| 717 m_pDevice->GetDeviceClass() == FXDC_DISPLAY && | 701 m_pDevice->GetDeviceClass() == FXDC_DISPLAY && |
| 718 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)); | 702 !(m_pDevice->GetDeviceCaps(FXDC_RENDER_CAPS) & FXRC_SOFT_CLIP)); |
| 719 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() && | 703 if ((m_Options.m_Flags & RENDER_OVERPRINT) && pPageObj->IsImage() && |
| 720 pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_StrokeOP) { | 704 pPageObj->m_GeneralState.GetFillOP() && |
| 705 pPageObj->m_GeneralState.GetStrokeOP()) { | |
| 721 CPDF_Document* pDocument = nullptr; | 706 CPDF_Document* pDocument = nullptr; |
| 722 CPDF_Page* pPage = nullptr; | 707 CPDF_Page* pPage = nullptr; |
| 723 if (m_pContext->GetPageCache()) { | 708 if (m_pContext->GetPageCache()) { |
| 724 pPage = m_pContext->GetPageCache()->GetPage(); | 709 pPage = m_pContext->GetPageCache()->GetPage(); |
| 725 pDocument = pPage->m_pDocument; | 710 pDocument = pPage->m_pDocument; |
| 726 } else { | 711 } else { |
| 727 pDocument = pPageObj->AsImage()->GetImage()->GetDocument(); | 712 pDocument = pPageObj->AsImage()->GetImage()->GetDocument(); |
| 728 } | 713 } |
| 729 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; | 714 CPDF_Dictionary* pPageResources = pPage ? pPage->m_pPageResources : nullptr; |
| 730 CPDF_Object* pCSObj = pPageObj->AsImage() | 715 CPDF_Object* pCSObj = pPageObj->AsImage() |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 812 } | 797 } |
| 813 } | 798 } |
| 814 CPDF_RenderStatus bitmap_render; | 799 CPDF_RenderStatus bitmap_render; |
| 815 bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, | 800 bitmap_render.Initialize(m_pContext, &bitmap_device, nullptr, m_pStopObj, |
| 816 nullptr, nullptr, &m_Options, 0, m_bDropObjects, | 801 nullptr, nullptr, &m_Options, 0, m_bDropObjects, |
| 817 pFormResource, TRUE); | 802 pFormResource, TRUE); |
| 818 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); | 803 bitmap_render.ProcessObjectNoClip(pPageObj, &new_matrix); |
| 819 m_bStopped = bitmap_render.m_bStopped; | 804 m_bStopped = bitmap_render.m_bStopped; |
| 820 if (pSMaskDict) { | 805 if (pSMaskDict) { |
| 821 CFX_Matrix smask_matrix; | 806 CFX_Matrix smask_matrix; |
| 822 FXSYS_memcpy(&smask_matrix, pGeneralState->m_SMaskMatrix, | 807 FXSYS_memcpy(&smask_matrix, pPageObj->m_GeneralState.GetSMaskMatrix(), |
|
Lei Zhang
2016/09/02 22:00:43
The only other |m_SMaskMatrix| usage.
Tom Sepez
2016/09/02 22:09:57
Ok, I've got a follow-up started already where I'v
| |
| 823 sizeof smask_matrix); | 808 sizeof smask_matrix); |
| 824 smask_matrix.Concat(*pObj2Device); | 809 smask_matrix.Concat(*pObj2Device); |
| 825 std::unique_ptr<CFX_DIBSource> pSMaskSource( | 810 std::unique_ptr<CFX_DIBSource> pSMaskSource( |
| 826 LoadSMask(pSMaskDict, &rect, &smask_matrix)); | 811 LoadSMask(pSMaskDict, &rect, &smask_matrix)); |
| 827 if (pSMaskSource) | 812 if (pSMaskSource) |
| 828 bitmap->MultiplyAlpha(pSMaskSource.get()); | 813 bitmap->MultiplyAlpha(pSMaskSource.get()); |
| 829 } | 814 } |
| 830 if (pTextMask) { | 815 if (pTextMask) { |
| 831 bitmap->MultiplyAlpha(pTextMask.get()); | 816 bitmap->MultiplyAlpha(pTextMask.get()); |
| 832 pTextMask.reset(); | 817 pTextMask.reset(); |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1293 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, | 1278 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, |
| 1294 m_Rect.top, m_Rect.Width(), m_Rect.Height()); | 1279 m_Rect.top, m_Rect.Width(), m_Rect.Height()); |
| 1295 } | 1280 } |
| 1296 } | 1281 } |
| 1297 | 1282 |
| 1298 #if defined _SKIA_SUPPORT_ | 1283 #if defined _SKIA_SUPPORT_ |
| 1299 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { | 1284 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { |
| 1300 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); | 1285 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); |
| 1301 } | 1286 } |
| 1302 #endif | 1287 #endif |
| OLD | NEW |