| 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 |
| 11 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" | 11 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" |
| 12 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" | 12 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" |
| 13 #include "core/fpdfapi/fpdf_page/cpdf_colorstatedata.h" | |
| 14 #include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h" | 13 #include "core/fpdfapi/fpdf_page/cpdf_graphicstates.h" |
| 15 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" | 14 #include "core/fpdfapi/fpdf_page/include/cpdf_form.h" |
| 16 #include "core/fpdfapi/fpdf_page/include/cpdf_formobject.h" | 15 #include "core/fpdfapi/fpdf_page/include/cpdf_formobject.h" |
| 17 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" | 16 #include "core/fpdfapi/fpdf_page/include/cpdf_image.h" |
| 18 #include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h" | 17 #include "core/fpdfapi/fpdf_page/include/cpdf_imageobject.h" |
| 19 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" | 18 #include "core/fpdfapi/fpdf_page/include/cpdf_page.h" |
| 20 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" | 19 #include "core/fpdfapi/fpdf_page/include/cpdf_pageobject.h" |
| 21 #include "core/fpdfapi/fpdf_page/include/cpdf_pathobject.h" | 20 #include "core/fpdfapi/fpdf_page/include/cpdf_pathobject.h" |
| 22 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" | 21 #include "core/fpdfapi/fpdf_page/include/cpdf_textobject.h" |
| 23 #include "core/fpdfapi/fpdf_page/pageint.h" | 22 #include "core/fpdfapi/fpdf_page/pageint.h" |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 } | 502 } |
| 504 | 503 |
| 505 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const { | 504 CPDF_TransferFunc* CPDF_RenderStatus::GetTransferFunc(CPDF_Object* pObj) const { |
| 506 ASSERT(pObj); | 505 ASSERT(pObj); |
| 507 CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData(); | 506 CPDF_DocRenderData* pDocCache = m_pContext->GetDocument()->GetRenderData(); |
| 508 return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr; | 507 return pDocCache ? pDocCache->GetTransferFunc(pObj) : nullptr; |
| 509 } | 508 } |
| 510 | 509 |
| 511 FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj, | 510 FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj, |
| 512 FX_BOOL bType3) const { | 511 FX_BOOL bType3) const { |
| 513 const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject(); | 512 const CPDF_ColorState* pColorState = &pObj->m_ColorState; |
| 514 if (m_pType3Char && !bType3 && | 513 if (m_pType3Char && !bType3 && |
| 515 (!m_pType3Char->m_bColored || | 514 (!m_pType3Char->m_bColored || |
| 516 (m_pType3Char->m_bColored && | 515 (m_pType3Char->m_bColored && |
| 517 (!pColorData || pColorData->m_FillColor.IsNull())))) { | 516 (!*pColorState || pColorState->GetFillColor()->IsNull())))) { |
| 518 return m_T3FillColor; | 517 return m_T3FillColor; |
| 519 } | 518 } |
| 520 if (!pColorData || pColorData->m_FillColor.IsNull()) { | 519 if (!*pColorState || pColorState->GetFillColor()->IsNull()) |
| 521 pColorData = m_InitialStates.m_ColorState.GetObject(); | 520 pColorState = &m_InitialStates.m_ColorState; |
| 522 } | 521 |
| 523 FX_COLORREF rgb = pColorData->m_FillRGB; | 522 FX_COLORREF rgb = pColorState->GetFillRGB(); |
| 524 if (rgb == (uint32_t)-1) { | 523 if (rgb == (uint32_t)-1) |
| 525 return 0; | 524 return 0; |
| 526 } | 525 |
| 527 int32_t alpha = | 526 int32_t alpha = |
| 528 static_cast<int32_t>((pObj->m_GeneralState.GetFillAlpha() * 255)); | 527 static_cast<int32_t>((pObj->m_GeneralState.GetFillAlpha() * 255)); |
| 529 if (pObj->m_GeneralState.GetTR()) { | 528 if (pObj->m_GeneralState.GetTR()) { |
| 530 if (!pObj->m_GeneralState.GetTransferFunc()) { | 529 if (!pObj->m_GeneralState.GetTransferFunc()) { |
| 531 pObj->m_GeneralState.SetTransferFunc( | 530 pObj->m_GeneralState.SetTransferFunc( |
| 532 GetTransferFunc(pObj->m_GeneralState.GetTR())); | 531 GetTransferFunc(pObj->m_GeneralState.GetTR())); |
| 533 } | 532 } |
| 534 if (pObj->m_GeneralState.GetTransferFunc()) | 533 if (pObj->m_GeneralState.GetTransferFunc()) |
| 535 rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb); | 534 rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb); |
| 536 } | 535 } |
| 537 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); | 536 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); |
| 538 } | 537 } |
| 539 | 538 |
| 540 FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const { | 539 FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const { |
| 541 const CPDF_ColorStateData* pColorData = pObj->m_ColorState.GetObject(); | 540 const CPDF_ColorState* pColorState = &pObj->m_ColorState; |
| 542 if (m_pType3Char && (!m_pType3Char->m_bColored || | 541 if (m_pType3Char && |
| 543 (m_pType3Char->m_bColored && | 542 (!m_pType3Char->m_bColored || |
| 544 (!pColorData || pColorData->m_StrokeColor.IsNull())))) { | 543 (m_pType3Char->m_bColored && |
| 544 (!*pColorState || pColorState->GetStrokeColor()->IsNull())))) { |
| 545 return m_T3FillColor; | 545 return m_T3FillColor; |
| 546 } | 546 } |
| 547 if (!pColorData || pColorData->m_StrokeColor.IsNull()) { | 547 if (!*pColorState || pColorState->GetStrokeColor()->IsNull()) |
| 548 pColorData = m_InitialStates.m_ColorState.GetObject(); | 548 pColorState = &m_InitialStates.m_ColorState; |
| 549 } | 549 |
| 550 FX_COLORREF rgb = pColorData->m_StrokeRGB; | 550 FX_COLORREF rgb = pColorState->GetStrokeRGB(); |
| 551 if (rgb == (uint32_t)-1) { | 551 if (rgb == (uint32_t)-1) |
| 552 return 0; | 552 return 0; |
| 553 } | 553 |
| 554 int32_t alpha = static_cast<int32_t>(pObj->m_GeneralState.GetStrokeAlpha() * | 554 int32_t alpha = static_cast<int32_t>(pObj->m_GeneralState.GetStrokeAlpha() * |
| 555 255); // not rounded. | 555 255); // not rounded. |
| 556 if (pObj->m_GeneralState.GetTR()) { | 556 if (pObj->m_GeneralState.GetTR()) { |
| 557 if (!pObj->m_GeneralState.GetTransferFunc()) { | 557 if (!pObj->m_GeneralState.GetTransferFunc()) { |
| 558 pObj->m_GeneralState.SetTransferFunc( | 558 pObj->m_GeneralState.SetTransferFunc( |
| 559 GetTransferFunc(pObj->m_GeneralState.GetTR())); | 559 GetTransferFunc(pObj->m_GeneralState.GetTR())); |
| 560 } | 560 } |
| 561 if (pObj->m_GeneralState.GetTransferFunc()) | 561 if (pObj->m_GeneralState.GetTransferFunc()) |
| 562 rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb); | 562 rgb = pObj->m_GeneralState.GetTransferFunc()->TranslateColor(rgb); |
| 563 } | 563 } |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1277 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, | 1277 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, |
| 1278 m_Rect.top, m_Rect.Width(), m_Rect.Height()); | 1278 m_Rect.top, m_Rect.Width(), m_Rect.Height()); |
| 1279 } | 1279 } |
| 1280 } | 1280 } |
| 1281 | 1281 |
| 1282 #if defined _SKIA_SUPPORT_ | 1282 #if defined _SKIA_SUPPORT_ |
| 1283 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { | 1283 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { |
| 1284 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); | 1284 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); |
| 1285 } | 1285 } |
| 1286 #endif | 1286 #endif |
| OLD | NEW |