| 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 27 matching lines...) Expand all Loading... |
| 38 CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) | 38 CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc) |
| 39 : m_pPDFDoc(pPDFDoc) {} | 39 : m_pPDFDoc(pPDFDoc) {} |
| 40 | 40 |
| 41 CPDF_DocRenderData::~CPDF_DocRenderData() { | 41 CPDF_DocRenderData::~CPDF_DocRenderData() { |
| 42 Clear(TRUE); | 42 Clear(TRUE); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void CPDF_DocRenderData::Clear(FX_BOOL bRelease) { | 45 void CPDF_DocRenderData::Clear(FX_BOOL bRelease) { |
| 46 for (auto it = m_Type3FaceMap.begin(); it != m_Type3FaceMap.end();) { | 46 for (auto it = m_Type3FaceMap.begin(); it != m_Type3FaceMap.end();) { |
| 47 auto curr_it = it++; | 47 auto curr_it = it++; |
| 48 CFX_WeakPtr<CPDF_Type3Cache>::Handle* cache = curr_it->second; | 48 CPDF_CountedObject<CPDF_Type3Cache>* cache = curr_it->second; |
| 49 if (bRelease || cache->use_count() < 2) { | 49 if (bRelease || cache->use_count() < 2) { |
| 50 delete cache->get(); | 50 delete cache->get(); |
| 51 delete cache; | 51 delete cache; |
| 52 m_Type3FaceMap.erase(curr_it); | 52 m_Type3FaceMap.erase(curr_it); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 for (auto it = m_TransferFuncMap.begin(); it != m_TransferFuncMap.end();) { | 56 for (auto it = m_TransferFuncMap.begin(); it != m_TransferFuncMap.end();) { |
| 57 auto curr_it = it++; | 57 auto curr_it = it++; |
| 58 CFX_WeakPtr<CPDF_TransferFunc>::Handle* value = curr_it->second; | 58 CPDF_CountedObject<CPDF_TransferFunc>* value = curr_it->second; |
| 59 if (bRelease || value->use_count() < 2) { | 59 if (bRelease || value->use_count() < 2) { |
| 60 delete value->get(); | 60 delete value->get(); |
| 61 delete value; | 61 delete value; |
| 62 m_TransferFuncMap.erase(curr_it); | 62 m_TransferFuncMap.erase(curr_it); |
| 63 } | 63 } |
| 64 } | 64 } |
| 65 } | 65 } |
| 66 | 66 |
| 67 CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) { | 67 CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) { |
| 68 CFX_WeakPtr<CPDF_Type3Cache>::Handle* pCache; | 68 CPDF_CountedObject<CPDF_Type3Cache>* pCache; |
| 69 auto it = m_Type3FaceMap.find(pFont); | 69 auto it = m_Type3FaceMap.find(pFont); |
| 70 if (it == m_Type3FaceMap.end()) { | 70 if (it == m_Type3FaceMap.end()) { |
| 71 CPDF_Type3Cache* pType3 = new CPDF_Type3Cache(pFont); | 71 CPDF_Type3Cache* pType3 = new CPDF_Type3Cache(pFont); |
| 72 pCache = new CFX_WeakPtr<CPDF_Type3Cache>::Handle(pType3); | 72 pCache = new CPDF_CountedObject<CPDF_Type3Cache>(pType3); |
| 73 m_Type3FaceMap[pFont] = pCache; | 73 m_Type3FaceMap[pFont] = pCache; |
| 74 } else { | 74 } else { |
| 75 pCache = it->second; | 75 pCache = it->second; |
| 76 } | 76 } |
| 77 return pCache->AddRef(); | 77 return pCache->AddRef(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 void CPDF_DocRenderData::ReleaseCachedType3(CPDF_Type3Font* pFont) { | 80 void CPDF_DocRenderData::ReleaseCachedType3(CPDF_Type3Font* pFont) { |
| 81 auto it = m_Type3FaceMap.find(pFont); | 81 auto it = m_Type3FaceMap.find(pFont); |
| 82 if (it != m_Type3FaceMap.end()) | 82 if (it != m_Type3FaceMap.end()) |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 } | 1079 } |
| 1080 } | 1080 } |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { | 1083 CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) { |
| 1084 if (!pObj) | 1084 if (!pObj) |
| 1085 return nullptr; | 1085 return nullptr; |
| 1086 | 1086 |
| 1087 auto it = m_TransferFuncMap.find(pObj); | 1087 auto it = m_TransferFuncMap.find(pObj); |
| 1088 if (it != m_TransferFuncMap.end()) { | 1088 if (it != m_TransferFuncMap.end()) { |
| 1089 CFX_WeakPtr<CPDF_TransferFunc>::Handle* pTransferCounter = it->second; | 1089 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second; |
| 1090 return pTransferCounter->AddRef(); | 1090 return pTransferCounter->AddRef(); |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 std::unique_ptr<CPDF_Function> pFuncs[3]; | 1093 std::unique_ptr<CPDF_Function> pFuncs[3]; |
| 1094 FX_BOOL bUniTransfer = TRUE; | 1094 FX_BOOL bUniTransfer = TRUE; |
| 1095 FX_BOOL bIdentity = TRUE; | 1095 FX_BOOL bIdentity = TRUE; |
| 1096 if (CPDF_Array* pArray = pObj->AsArray()) { | 1096 if (CPDF_Array* pArray = pObj->AsArray()) { |
| 1097 bUniTransfer = FALSE; | 1097 bUniTransfer = FALSE; |
| 1098 if (pArray->GetCount() < 3) | 1098 if (pArray->GetCount() < 3) |
| 1099 return nullptr; | 1099 return nullptr; |
| 1100 | 1100 |
| 1101 for (uint32_t i = 0; i < 3; ++i) { | 1101 for (uint32_t i = 0; i < 3; ++i) { |
| 1102 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); | 1102 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); |
| 1103 if (!pFuncs[2 - i]) | 1103 if (!pFuncs[2 - i]) |
| 1104 return nullptr; | 1104 return nullptr; |
| 1105 } | 1105 } |
| 1106 } else { | 1106 } else { |
| 1107 pFuncs[0] = CPDF_Function::Load(pObj); | 1107 pFuncs[0] = CPDF_Function::Load(pObj); |
| 1108 if (!pFuncs[0]) | 1108 if (!pFuncs[0]) |
| 1109 return nullptr; | 1109 return nullptr; |
| 1110 } | 1110 } |
| 1111 CPDF_TransferFunc* pTransfer = new CPDF_TransferFunc(m_pPDFDoc); | 1111 CPDF_TransferFunc* pTransfer = new CPDF_TransferFunc(m_pPDFDoc); |
| 1112 CFX_WeakPtr<CPDF_TransferFunc>::Handle* pTransferCounter = | 1112 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = |
| 1113 new CFX_WeakPtr<CPDF_TransferFunc>::Handle(pTransfer); | 1113 new CPDF_CountedObject<CPDF_TransferFunc>(pTransfer); |
| 1114 m_TransferFuncMap[pObj] = pTransferCounter; | 1114 m_TransferFuncMap[pObj] = pTransferCounter; |
| 1115 static const int kMaxOutputs = 16; | 1115 static const int kMaxOutputs = 16; |
| 1116 FX_FLOAT output[kMaxOutputs]; | 1116 FX_FLOAT output[kMaxOutputs]; |
| 1117 FXSYS_memset(output, 0, sizeof(output)); | 1117 FXSYS_memset(output, 0, sizeof(output)); |
| 1118 FX_FLOAT input; | 1118 FX_FLOAT input; |
| 1119 int noutput; | 1119 int noutput; |
| 1120 for (int v = 0; v < 256; ++v) { | 1120 for (int v = 0; v < 256; ++v) { |
| 1121 input = (FX_FLOAT)v / 255.0f; | 1121 input = (FX_FLOAT)v / 255.0f; |
| 1122 if (bUniTransfer) { | 1122 if (bUniTransfer) { |
| 1123 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) | 1123 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1280 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, | 1280 m_pDevice->StretchDIBits(m_pBitmapDevice->GetBitmap(), m_Rect.left, |
| 1281 m_Rect.top, m_Rect.Width(), m_Rect.Height()); | 1281 m_Rect.top, m_Rect.Width(), m_Rect.Height()); |
| 1282 } | 1282 } |
| 1283 } | 1283 } |
| 1284 | 1284 |
| 1285 #if defined _SKIA_SUPPORT_ | 1285 #if defined _SKIA_SUPPORT_ |
| 1286 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { | 1286 void CPDF_RenderStatus::DebugVerifyDeviceIsPreMultiplied() const { |
| 1287 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); | 1287 m_pDevice->DebugVerifyBitmapIsPreMultiplied(); |
| 1288 } | 1288 } |
| 1289 #endif | 1289 #endif |
| OLD | NEW |