| 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 "core/fpdfapi/fpdf_font/cpdf_type3char.h" | 9 #include "core/fpdfapi/fpdf_font/cpdf_type3char.h" |
| 10 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" | 10 #include "core/fpdfapi/fpdf_font/cpdf_type3font.h" |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 pResources = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); | 436 pResources = pFormObj->m_pForm->m_pFormDict->GetDictBy("Resources"); |
| 437 } | 437 } |
| 438 CPDF_RenderStatus status; | 438 CPDF_RenderStatus status; |
| 439 status.Initialize(m_pContext, m_pDevice, NULL, m_pStopObj, this, pFormObj, | 439 status.Initialize(m_pContext, m_pDevice, NULL, m_pStopObj, this, pFormObj, |
| 440 &m_Options, m_Transparency, m_bDropObjects, pResources, | 440 &m_Options, m_Transparency, m_bDropObjects, pResources, |
| 441 FALSE); | 441 FALSE); |
| 442 status.m_curBlend = m_curBlend; | 442 status.m_curBlend = m_curBlend; |
| 443 m_pDevice->SaveState(); | 443 m_pDevice->SaveState(); |
| 444 status.RenderObjectList(pFormObj->m_pForm, &matrix); | 444 status.RenderObjectList(pFormObj->m_pForm, &matrix); |
| 445 m_bStopped = status.m_bStopped; | 445 m_bStopped = status.m_bStopped; |
| 446 m_pDevice->RestoreState(); | 446 m_pDevice->RestoreState(false); |
| 447 return TRUE; | 447 return TRUE; |
| 448 } | 448 } |
| 449 FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) { | 449 FX_BOOL IsAvailableMatrix(const CFX_Matrix& matrix) { |
| 450 if (matrix.a == 0 || matrix.d == 0) { | 450 if (matrix.a == 0 || matrix.d == 0) { |
| 451 return matrix.b != 0 && matrix.c != 0; | 451 return matrix.b != 0 && matrix.c != 0; |
| 452 } | 452 } |
| 453 if (matrix.b == 0 || matrix.c == 0) { | 453 if (matrix.b == 0 || matrix.c == 0) { |
| 454 return matrix.a != 0 && matrix.d != 0; | 454 return matrix.a != 0 && matrix.d != 0; |
| 455 } | 455 } |
| 456 return TRUE; | 456 return TRUE; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 } | 576 } |
| 577 } else { | 577 } else { |
| 578 alpha = 255; | 578 alpha = 255; |
| 579 } | 579 } |
| 580 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); | 580 return m_Options.TranslateColor(ArgbEncode(alpha, rgb)); |
| 581 } | 581 } |
| 582 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, | 582 void CPDF_RenderStatus::ProcessClipPath(CPDF_ClipPath ClipPath, |
| 583 const CFX_Matrix* pObj2Device) { | 583 const CFX_Matrix* pObj2Device) { |
| 584 if (ClipPath.IsNull()) { | 584 if (ClipPath.IsNull()) { |
| 585 if (!m_LastClipPath.IsNull()) { | 585 if (!m_LastClipPath.IsNull()) { |
| 586 m_pDevice->RestoreState(TRUE); | 586 m_pDevice->RestoreState(true); |
| 587 m_LastClipPath.SetNull(); | 587 m_LastClipPath.SetNull(); |
| 588 } | 588 } |
| 589 return; | 589 return; |
| 590 } | 590 } |
| 591 if (m_LastClipPath == ClipPath) | 591 if (m_LastClipPath == ClipPath) |
| 592 return; | 592 return; |
| 593 | 593 |
| 594 m_LastClipPath = ClipPath; | 594 m_LastClipPath = ClipPath; |
| 595 m_pDevice->RestoreState(TRUE); | 595 m_pDevice->RestoreState(true); |
| 596 int nClipPath = ClipPath.GetPathCount(); | 596 int nClipPath = ClipPath.GetPathCount(); |
| 597 for (int i = 0; i < nClipPath; ++i) { | 597 for (int i = 0; i < nClipPath; ++i) { |
| 598 const CFX_PathData* pPathData = ClipPath.GetPath(i); | 598 const CFX_PathData* pPathData = ClipPath.GetPath(i); |
| 599 if (!pPathData) | 599 if (!pPathData) |
| 600 continue; | 600 continue; |
| 601 | 601 |
| 602 if (pPathData->GetPointCount() == 0) { | 602 if (pPathData->GetPointCount() == 0) { |
| 603 CFX_PathData EmptyPath; | 603 CFX_PathData EmptyPath; |
| 604 EmptyPath.AppendRect(-1, -1, 0, 0); | 604 EmptyPath.AppendRect(-1, -1, 0, 0); |
| 605 int fill_mode = FXFILL_WINDING; | 605 int fill_mode = FXFILL_WINDING; |
| (...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 967 FinalMatrix.Concat(*pLastMatrix); | 967 FinalMatrix.Concat(*pLastMatrix); |
| 968 CPDF_RenderStatus status; | 968 CPDF_RenderStatus status; |
| 969 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL, | 969 status.Initialize(this, pDevice, pLastMatrix, pStopObj, NULL, NULL, |
| 970 pOptions, pLayer->m_pObjectHolder->m_Transparency, | 970 pOptions, pLayer->m_pObjectHolder->m_Transparency, |
| 971 FALSE, NULL); | 971 FALSE, NULL); |
| 972 status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); | 972 status.RenderObjectList(pLayer->m_pObjectHolder, &FinalMatrix); |
| 973 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 973 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
| 974 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); | 974 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); |
| 975 } | 975 } |
| 976 if (status.m_bStopped) { | 976 if (status.m_bStopped) { |
| 977 pDevice->RestoreState(); | 977 pDevice->RestoreState(false); |
| 978 break; | 978 break; |
| 979 } | 979 } |
| 980 } else { | 980 } else { |
| 981 CPDF_RenderStatus status; | 981 CPDF_RenderStatus status; |
| 982 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOptions, | 982 status.Initialize(this, pDevice, NULL, pStopObj, NULL, NULL, pOptions, |
| 983 pLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); | 983 pLayer->m_pObjectHolder->m_Transparency, FALSE, NULL); |
| 984 status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); | 984 status.RenderObjectList(pLayer->m_pObjectHolder, &pLayer->m_Matrix); |
| 985 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { | 985 if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { |
| 986 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); | 986 m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); |
| 987 } | 987 } |
| 988 if (status.m_bStopped) { | 988 if (status.m_bStopped) { |
| 989 pDevice->RestoreState(); | 989 pDevice->RestoreState(false); |
| 990 break; | 990 break; |
| 991 } | 991 } |
| 992 } | 992 } |
| 993 pDevice->RestoreState(); | 993 pDevice->RestoreState(false); |
| 994 } | 994 } |
| 995 } | 995 } |
| 996 | 996 |
| 997 CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer( | 997 CPDF_ProgressiveRenderer::CPDF_ProgressiveRenderer( |
| 998 CPDF_RenderContext* pContext, | 998 CPDF_RenderContext* pContext, |
| 999 CFX_RenderDevice* pDevice, | 999 CFX_RenderDevice* pDevice, |
| 1000 const CPDF_RenderOptions* pOptions) | 1000 const CPDF_RenderOptions* pOptions) |
| 1001 : m_Status(Ready), | 1001 : m_Status(Ready), |
| 1002 m_pContext(pContext), | 1002 m_pContext(pContext), |
| 1003 m_pDevice(pDevice), | 1003 m_pDevice(pDevice), |
| 1004 m_pOptions(pOptions), | 1004 m_pOptions(pOptions), |
| 1005 m_LayerIndex(0), | 1005 m_LayerIndex(0), |
| 1006 m_pCurrentLayer(nullptr) {} | 1006 m_pCurrentLayer(nullptr) {} |
| 1007 | 1007 |
| 1008 CPDF_ProgressiveRenderer::~CPDF_ProgressiveRenderer() { | 1008 CPDF_ProgressiveRenderer::~CPDF_ProgressiveRenderer() { |
| 1009 if (m_pRenderStatus) | 1009 if (m_pRenderStatus) |
| 1010 m_pDevice->RestoreState(); | 1010 m_pDevice->RestoreState(false); |
| 1011 } | 1011 } |
| 1012 | 1012 |
| 1013 void CPDF_ProgressiveRenderer::Start(IFX_Pause* pPause) { | 1013 void CPDF_ProgressiveRenderer::Start(IFX_Pause* pPause) { |
| 1014 if (!m_pContext || !m_pDevice || m_Status != Ready) { | 1014 if (!m_pContext || !m_pDevice || m_Status != Ready) { |
| 1015 m_Status = Failed; | 1015 m_Status = Failed; |
| 1016 return; | 1016 return; |
| 1017 } | 1017 } |
| 1018 m_Status = ToBeContinued; | 1018 m_Status = ToBeContinued; |
| 1019 Continue(pPause); | 1019 Continue(pPause); |
| 1020 } | 1020 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1073 m_LastObjectRendered = iter; | 1073 m_LastObjectRendered = iter; |
| 1074 if (nObjsToGo == 0) { | 1074 if (nObjsToGo == 0) { |
| 1075 if (pPause && pPause->NeedToPauseNow()) | 1075 if (pPause && pPause->NeedToPauseNow()) |
| 1076 return; | 1076 return; |
| 1077 nObjsToGo = kStepLimit; | 1077 nObjsToGo = kStepLimit; |
| 1078 } | 1078 } |
| 1079 ++iter; | 1079 ++iter; |
| 1080 } | 1080 } |
| 1081 if (m_pCurrentLayer->m_pObjectHolder->IsParsed()) { | 1081 if (m_pCurrentLayer->m_pObjectHolder->IsParsed()) { |
| 1082 m_pRenderStatus.reset(); | 1082 m_pRenderStatus.reset(); |
| 1083 m_pDevice->RestoreState(); | 1083 m_pDevice->RestoreState(false); |
| 1084 m_pCurrentLayer = nullptr; | 1084 m_pCurrentLayer = nullptr; |
| 1085 m_LayerIndex++; | 1085 m_LayerIndex++; |
| 1086 if (pPause && pPause->NeedToPauseNow()) { | 1086 if (pPause && pPause->NeedToPauseNow()) { |
| 1087 return; | 1087 return; |
| 1088 } | 1088 } |
| 1089 } else { | 1089 } else { |
| 1090 m_pCurrentLayer->m_pObjectHolder->ContinueParse(pPause); | 1090 m_pCurrentLayer->m_pObjectHolder->ContinueParse(pPause); |
| 1091 if (!m_pCurrentLayer->m_pObjectHolder->IsParsed()) | 1091 if (!m_pCurrentLayer->m_pObjectHolder->IsParsed()) |
| 1092 return; | 1092 return; |
| 1093 } | 1093 } |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1288 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, | 1288 m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, |
| 1289 &m_Matrix); | 1289 &m_Matrix); |
| 1290 return TRUE; | 1290 return TRUE; |
| 1291 } | 1291 } |
| 1292 void CPDF_ScaledRenderBuffer::OutputToDevice() { | 1292 void CPDF_ScaledRenderBuffer::OutputToDevice() { |
| 1293 if (m_pBitmapDevice) { | 1293 if (m_pBitmapDevice) { |
| 1294 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, | 1294 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, |
| 1295 m_Rect.top, m_Rect.Width(), m_Rect.Height()); | 1295 m_Rect.top, m_Rect.Width(), m_Rect.Height()); |
| 1296 } | 1296 } |
| 1297 } | 1297 } |
| OLD | NEW |