summaryrefslogtreecommitdiff
path: root/core/fpdfapi/render/fpdf_render.cpp
diff options
context:
space:
mode:
authornpm <npm@chromium.org>2016-11-17 10:47:43 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-17 10:47:43 -0800
commit935c6310adacf2f4a4265e831e6cb60dc7a35803 (patch)
tree77f069eb3f7e9f45ffdf58dd11a9b12196515a93 /core/fpdfapi/render/fpdf_render.cpp
parentb977720aa7f159ae2c1e9d9b3af1adecff730545 (diff)
downloadpdfium-935c6310adacf2f4a4265e831e6cb60dc7a35803.tar.xz
Move CPDF_DocRenderData from render_int
First CL in an attempt to reduce the class cluttering in fpdf_render_text, fpdf_render_image, and fpdf_render. Review-Url: https://codereview.chromium.org/2507023006
Diffstat (limited to 'core/fpdfapi/render/fpdf_render.cpp')
-rw-r--r--core/fpdfapi/render/fpdf_render.cpp134
1 files changed, 1 insertions, 133 deletions
diff --git a/core/fpdfapi/render/fpdf_render.cpp b/core/fpdfapi/render/fpdf_render.cpp
index e4abb7e832..ca9e059171 100644
--- a/core/fpdfapi/render/fpdf_render.cpp
+++ b/core/fpdfapi/render/fpdf_render.cpp
@@ -25,6 +25,7 @@
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_dictionary.h"
#include "core/fpdfapi/parser/cpdf_document.h"
+#include "core/fpdfapi/render/cpdf_docrenderdata.h"
#include "core/fpdfapi/render/cpdf_pagerendercache.h"
#include "core/fpdfapi/render/cpdf_progressiverenderer.h"
#include "core/fpdfapi/render/cpdf_renderoptions.h"
@@ -36,60 +37,6 @@
#include "core/fxge/cfx_pathdata.h"
#include "core/fxge/cfx_renderdevice.h"
-CPDF_DocRenderData::CPDF_DocRenderData(CPDF_Document* pPDFDoc)
- : m_pPDFDoc(pPDFDoc) {}
-
-CPDF_DocRenderData::~CPDF_DocRenderData() {
- Clear(true);
-}
-
-void CPDF_DocRenderData::Clear(bool bRelease) {
- for (auto it = m_Type3FaceMap.begin(); it != m_Type3FaceMap.end();) {
- auto curr_it = it++;
- CPDF_CountedObject<CPDF_Type3Cache>* cache = curr_it->second;
- if (bRelease || cache->use_count() < 2) {
- delete cache->get();
- delete cache;
- m_Type3FaceMap.erase(curr_it);
- }
- }
-
- for (auto it = m_TransferFuncMap.begin(); it != m_TransferFuncMap.end();) {
- auto curr_it = it++;
- CPDF_CountedObject<CPDF_TransferFunc>* value = curr_it->second;
- if (bRelease || value->use_count() < 2) {
- delete value->get();
- delete value;
- m_TransferFuncMap.erase(curr_it);
- }
- }
-}
-
-CPDF_Type3Cache* CPDF_DocRenderData::GetCachedType3(CPDF_Type3Font* pFont) {
- CPDF_CountedObject<CPDF_Type3Cache>* pCache;
- auto it = m_Type3FaceMap.find(pFont);
- if (it == m_Type3FaceMap.end()) {
- CPDF_Type3Cache* pType3 = new CPDF_Type3Cache(pFont);
- pCache = new CPDF_CountedObject<CPDF_Type3Cache>(pType3);
- m_Type3FaceMap[pFont] = pCache;
- } else {
- pCache = it->second;
- }
- return pCache->AddRef();
-}
-
-void CPDF_DocRenderData::ReleaseCachedType3(CPDF_Type3Font* pFont) {
- auto it = m_Type3FaceMap.find(pFont);
- if (it != m_Type3FaceMap.end()) {
- it->second->RemoveRef();
- if (it->second->use_count() < 2) {
- delete it->second->get();
- delete it->second;
- m_Type3FaceMap.erase(it);
- }
- }
-}
-
CPDF_RenderOptions::CPDF_RenderOptions()
: m_ColorMode(RENDER_COLOR_NORMAL),
m_Flags(RENDER_CLEARTYPE),
@@ -1087,85 +1034,6 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) {
}
}
-CPDF_TransferFunc* CPDF_DocRenderData::GetTransferFunc(CPDF_Object* pObj) {
- if (!pObj)
- return nullptr;
-
- auto it = m_TransferFuncMap.find(pObj);
- if (it != m_TransferFuncMap.end()) {
- CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter = it->second;
- return pTransferCounter->AddRef();
- }
-
- std::unique_ptr<CPDF_Function> pFuncs[3];
- bool bUniTransfer = true;
- bool bIdentity = true;
- if (CPDF_Array* pArray = pObj->AsArray()) {
- bUniTransfer = false;
- if (pArray->GetCount() < 3)
- return nullptr;
-
- for (uint32_t i = 0; i < 3; ++i) {
- pFuncs[2 - i] = CPDF_Function::Load(pArray->GetDirectObjectAt(i));
- if (!pFuncs[2 - i])
- return nullptr;
- }
- } else {
- pFuncs[0] = CPDF_Function::Load(pObj);
- if (!pFuncs[0])
- return nullptr;
- }
- CPDF_TransferFunc* pTransfer = new CPDF_TransferFunc(m_pPDFDoc);
- CPDF_CountedObject<CPDF_TransferFunc>* pTransferCounter =
- new CPDF_CountedObject<CPDF_TransferFunc>(pTransfer);
- m_TransferFuncMap[pObj] = pTransferCounter;
- static const int kMaxOutputs = 16;
- FX_FLOAT output[kMaxOutputs];
- FXSYS_memset(output, 0, sizeof(output));
- FX_FLOAT input;
- int noutput;
- for (int v = 0; v < 256; ++v) {
- input = (FX_FLOAT)v / 255.0f;
- if (bUniTransfer) {
- if (pFuncs[0] && pFuncs[0]->CountOutputs() <= kMaxOutputs)
- pFuncs[0]->Call(&input, 1, output, noutput);
- int o = FXSYS_round(output[0] * 255);
- if (o != v)
- bIdentity = false;
- for (int i = 0; i < 3; ++i) {
- pTransfer->m_Samples[i * 256 + v] = o;
- }
- } else {
- for (int i = 0; i < 3; ++i) {
- if (pFuncs[i] && pFuncs[i]->CountOutputs() <= kMaxOutputs) {
- pFuncs[i]->Call(&input, 1, output, noutput);
- int o = FXSYS_round(output[0] * 255);
- if (o != v)
- bIdentity = false;
- pTransfer->m_Samples[i * 256 + v] = o;
- } else {
- pTransfer->m_Samples[i * 256 + v] = v;
- }
- }
- }
- }
-
- pTransfer->m_bIdentity = bIdentity;
- return pTransferCounter->AddRef();
-}
-
-void CPDF_DocRenderData::ReleaseTransferFunc(CPDF_Object* pObj) {
- auto it = m_TransferFuncMap.find(pObj);
- if (it != m_TransferFuncMap.end()) {
- it->second->RemoveRef();
- if (it->second->use_count() < 2) {
- delete it->second->get();
- delete it->second;
- m_TransferFuncMap.erase(it);
- }
- }
-}
-
CPDF_DeviceBuffer::CPDF_DeviceBuffer()
: m_pDevice(nullptr), m_pContext(nullptr), m_pObject(nullptr) {}