| OLD | NEW |
| 1 // Copyright 2016 PDFium Authors. All rights reserved. | 1 // Copyright 2016 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/render/cpdf_docrenderdata.h" | 7 #include "core/fpdfapi/render/cpdf_docrenderdata.h" |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 delete value; | 48 delete value; |
| 49 m_TransferFuncMap.erase(curr_it); | 49 m_TransferFuncMap.erase(curr_it); |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 } | 52 } |
| 53 | 53 |
| 54 CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) { | 54 CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) { |
| 55 CPDF_CountedObject<CPDF_Type3Cache>* pCache; | 55 CPDF_CountedObject<CPDF_Type3Cache>* pCache; |
| 56 auto it = m_Type3FaceMap.find(pFont); | 56 auto it = m_Type3FaceMap.find(pFont); |
| 57 if (it == m_Type3FaceMap.end()) { | 57 if (it == m_Type3FaceMap.end()) { |
| 58 CPDF_Type3Cache* pType3 = new CPDF_Type3Cache(pFont); | 58 pCache = new CPDF_CountedObject<CPDF_Type3Cache>( |
| 59 pCache = new CPDF_CountedObject<CPDF_Type3Cache>(pType3); | 59 pdfium::MakeUnique<CPDF_Type3Cache>(pFont)); |
| 60 m_Type3FaceMap[pFont] = pCache; | 60 m_Type3FaceMap[pFont] = pCache; |
| 61 } else { | 61 } else { |
| 62 pCache = it->second; | 62 pCache = it->second; |
| 63 } | 63 } |
| 64 return pCache->AddRef(); | 64 return pCache->AddRef(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void CPDF_DocRenderData::ReleaseCachedType3(CPDF_Type3Font* pFont) { | 67 void CPDF_DocRenderData::ReleaseCachedType3(CPDF_Type3Font* pFont) { |
| 68 auto it = m_Type3FaceMap.find(pFont); | 68 auto it = m_Type3FaceMap.find(pFont); |
| 69 if (it != m_Type3FaceMap.end()) { | 69 if (it != m_Type3FaceMap.end()) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 97 for (uint32_t i = 0; i < 3; ++i) { | 97 for (uint32_t i = 0; i < 3; ++i) { |
| 98 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); | 98 pFuncs[2 - i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i)); |
| 99 if (!pFuncs[2 - i]) | 99 if (!pFuncs[2 - i]) |
| 100 return nullptr; | 100 return nullptr; |
| 101 } | 101 } |
| 102 } else { | 102 } else { |
| 103 pFuncs[0] = CPDF_Function::Load(pObj); | 103 pFuncs[0] = CPDF_Function::Load(pObj); |
| 104 if (!pFuncs[0]) | 104 if (!pFuncs[0]) |
| 105 return nullptr; | 105 return nullptr; |
| 106 } | 106 } |
| 107 CPDF_TransferFunc* pTransfer = new CPDF_TransferFunc(m_pPDFDoc); | |
| 108 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = | 107 CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = |
| 109 new CPDF_CountedObject<CPDF_TransferFunc>(pTransfer); | 108 new CPDF_CountedObject<CPDF_TransferFunc>( |
| 109 pdfium::MakeUnique<CPDF_TransferFunc>(m_pPDFDoc)); |
| 110 CPDF_TransferFunc* pTransfer = pTransferCounter->get(); |
| 110 m_TransferFuncMap[pObj] = pTransferCounter; | 111 m_TransferFuncMap[pObj] = pTransferCounter; |
| 111 FX_FLOAT output[kMaxOutputs]; | 112 FX_FLOAT output[kMaxOutputs]; |
| 112 FXSYS_memset(output, 0, sizeof(output)); | 113 FXSYS_memset(output, 0, sizeof(output)); |
| 113 FX_FLOAT input; | 114 FX_FLOAT input; |
| 114 int noutput; | 115 int noutput; |
| 115 for (int v = 0; v < 256; ++v) { | 116 for (int v = 0; v < 256; ++v) { |
| 116 input = (FX_FLOAT)v / 255.0f; | 117 input = (FX_FLOAT)v / 255.0f; |
| 117 if (bUniTransfer) { | 118 if (bUniTransfer) { |
| 118 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) | 119 if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs) |
| 119 pFuncs[0]->Call(&input, 1, output, noutput); | 120 pFuncs[0]->Call(&input, 1, output, noutput); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 145 auto it = m_TransferFuncMap.find(pObj); | 146 auto it = m_TransferFuncMap.find(pObj); |
| 146 if (it != m_TransferFuncMap.end()) { | 147 if (it != m_TransferFuncMap.end()) { |
| 147 it->second->RemoveRef(); | 148 it->second->RemoveRef(); |
| 148 if (it->second->use_count() < 2) { | 149 if (it->second->use_count() < 2) { |
| 149 delete it->second->get(); | 150 delete it->second->get(); |
| 150 delete it->second; | 151 delete it->second; |
| 151 m_TransferFuncMap.erase(it); | 152 m_TransferFuncMap.erase(it); |
| 152 } | 153 } |
| 153 } | 154 } |
| 154 } | 155 } |
| OLD | NEW |