diff options
author | John Abd-El-Malek <jam@chromium.org> | 2014-12-12 16:42:18 -0800 |
---|---|---|
committer | John Abd-El-Malek <jam@chromium.org> | 2014-12-12 16:42:18 -0800 |
commit | 217ecf3b39f8d5c01260684848a8886c8ed2bf89 (patch) | |
tree | 1ab05e729480f2d8fab6882285c2e169c8ba007e /core/src/fpdfapi | |
parent | 239955073722582152d9ab190794317dd775a1c1 (diff) | |
download | pdfium-217ecf3b39f8d5c01260684848a8886c8ed2bf89.tar.xz |
Simplify PDFium by removing code that's not used in the open source repo.
-remove parameter from FPDF_InitLibrary
-remove a bunch of ifdefs that are unused
R=tsepez@chromium.org
Review URL: https://codereview.chromium.org/801913002
Diffstat (limited to 'core/src/fpdfapi')
-rw-r--r-- | core/src/fpdfapi/fpdf_basic_module.cpp | 34 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_font/font_int.h | 4 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp | 39 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_font/fpdf_font_utility.cpp | 2 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp | 11 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp | 94 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/fpdf_page_parser_new.cpp | 822 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_page/pageint.h | 44 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp | 9 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render.cpp | 59 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp | 36 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp | 83 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp | 10 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp | 12 | ||||
-rw-r--r-- | core/src/fpdfapi/fpdf_render/render_int.h | 4 |
15 files changed, 4 insertions, 1259 deletions
diff --git a/core/src/fpdfapi/fpdf_basic_module.cpp b/core/src/fpdfapi/fpdf_basic_module.cpp index a446aa5d21..edccda5743 100644 --- a/core/src/fpdfapi/fpdf_basic_module.cpp +++ b/core/src/fpdfapi/fpdf_basic_module.cpp @@ -78,40 +78,6 @@ static CFX_ByteString _GetPath(const CFX_ByteString& folder, FX_LPCSTR name) } #endif } -void CPDF_ModuleMgr::SetModulePath(FX_LPCSTR module_name, FX_LPCSTR path) -{ - if (module_name == NULL || module_name[0] == 0) { - m_DefaultModulePath = path; - } else { - m_ModulePathList.SetAt(module_name, FX_NEW CFX_ByteString(path, -1)); - } -} -CFX_ByteString CPDF_ModuleMgr::GetModuleFilePath(FX_LPCSTR module_name, FX_LPCSTR name) -{ - CFX_ByteString* pPath = NULL; - if (m_ModulePathList.Lookup(module_name, (FX_LPVOID&)pPath)) { - return _GetPath(*pPath, name); - } - if (!m_DefaultModulePath.IsEmpty()) { - return _GetPath(m_DefaultModulePath, name); - } -#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ - FX_WCHAR app_path[260]; - ::GetModuleFileNameW(NULL, (LPWSTR)app_path, 260); - FX_INTPTR len = FXSYS_wcslen(app_path); - for (FX_INTPTR i = len; i >= 0; i --) - if (app_path[i] == '\\') { - app_path[i] = 0; - break; - } - CFX_ByteString path = CFX_ByteString::FromUnicode(app_path); - path += '\\'; - path += name; - return path; -#else - return name; -#endif -} void CPDF_ModuleMgr::NotifyModuleAvailable(FX_LPCSTR module_name) { if (FXSYS_strcmp(module_name, ADDIN_NAME_CJK) == 0) { diff --git a/core/src/fpdfapi/fpdf_font/font_int.h b/core/src/fpdfapi/fpdf_font/font_int.h index 3ce9664ceb..2922ed2308 100644 --- a/core/src/fpdfapi/fpdf_font/font_int.h +++ b/core/src/fpdfapi/fpdf_font/font_int.h @@ -18,10 +18,8 @@ private: CPDF_CMap* LoadPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPrompt); CPDF_CID2UnicodeMap* LoadCID2UnicodeMap(int charset, FX_BOOL bPrompt); void DropAll(FX_BOOL bReload); -#ifndef _FPDFAPI_MINI_ FX_BOOL m_bPrompted; FX_LPVOID m_pPackage; -#endif CFX_MapByteStringToPtr m_CMaps; CPDF_CID2UnicodeMap* m_CID2UnicodeMaps[6]; }; @@ -178,9 +176,7 @@ protected: int m_Charset; const FX_WORD* m_pEmbeddedMap; FX_DWORD m_EmbeddedCount; -#ifndef _FPDFAPI_MINI_ CPDF_FXMP* m_pExternalMap; -#endif }; class CPDF_ToUnicodeMap : public CFX_Object { diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp index e5dabc33da..766fd352b4 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_cid.cpp @@ -19,40 +19,21 @@ extern FX_BOOL FT_UseTTCharmap(FXFT_Face face, int platform_id, int encoding_id) extern FX_LPCSTR GetAdobeCharName(int iBaseEncoding, const CFX_ByteString* pCharNames, int charcode); CPDF_CMapManager::CPDF_CMapManager() { -#ifndef _FPDFAPI_MINI_ m_bPrompted = FALSE; m_pPackage = NULL; -#endif FXSYS_memset32(m_CID2UnicodeMaps, 0, sizeof m_CID2UnicodeMaps); } CPDF_CMapManager::~CPDF_CMapManager() { DropAll(FALSE); -#ifndef _FPDFAPI_MINI_ if (m_pPackage) { FXFC_ClosePackage(m_pPackage); } -#endif } -#ifndef _FPDFAPI_MINI_ FX_LPVOID CPDF_CMapManager::GetPackage(FX_BOOL bPrompt) { -#ifndef FOXIT_CHROME_BUILD - if (m_pPackage == NULL) { - CFX_ByteString filename = CPDF_ModuleMgr::Get()->GetModuleFilePath(ADDIN_NAME_CJK, "FPDFCJK.BIN"); - m_pPackage = FXFC_LoadPackage(filename); - if (bPrompt && m_pPackage == NULL && !m_bPrompted) { - m_bPrompted = TRUE; - if (!CPDF_ModuleMgr::Get()->DownloadModule(ADDIN_NAME_CJK)) { - return NULL; - } - m_pPackage = FXFC_LoadPackage(filename); - } - } -#endif return m_pPackage; } -#endif CPDF_CMap* CPDF_CMapManager::GetPredefinedCMap(const CFX_ByteString& name, FX_BOOL bPromptCJK) { CPDF_CMap* pCMap; @@ -418,7 +399,6 @@ FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, FX_LPCSTR pName, FX_BO m_bLoaded = TRUE; return TRUE; } -#ifndef _FPDFAPI_MINI_ FX_LPVOID pPackage = pMgr->GetPackage(bPromptCJK); FX_LPBYTE pBuffer; FX_DWORD size; @@ -462,7 +442,6 @@ FX_BOOL CPDF_CMap::LoadPredefined(CPDF_CMapManager* pMgr, FX_LPCSTR pName, FX_BO } FX_Free(pBuffer); m_bLoaded = TRUE; -#endif return TRUE; } extern "C" { @@ -739,32 +718,22 @@ int CPDF_CMap::AppendChar(FX_LPSTR str, FX_DWORD charcode) const CPDF_CID2UnicodeMap::CPDF_CID2UnicodeMap() { m_EmbeddedCount = 0; -#ifndef _FPDFAPI_MINI_ m_pExternalMap = NULL; -#endif } CPDF_CID2UnicodeMap::~CPDF_CID2UnicodeMap() { -#ifndef _FPDFAPI_MINI_ if (m_pExternalMap) { delete m_pExternalMap; } -#endif } FX_BOOL CPDF_CID2UnicodeMap::Initialize() { -#ifndef _FPDFAPI_MINI_ m_pExternalMap = FX_NEW CPDF_FXMP; -#endif return TRUE; } FX_BOOL CPDF_CID2UnicodeMap::IsLoaded() { -#ifdef _FPDFAPI_MINI_ - return m_EmbeddedCount != 0; -#else return m_EmbeddedCount != 0 || (m_pExternalMap != NULL && m_pExternalMap->IsLoaded()); -#endif } FX_WCHAR CPDF_CID2UnicodeMap::UnicodeFromCID(FX_WORD CID) { @@ -774,15 +743,11 @@ FX_WCHAR CPDF_CID2UnicodeMap::UnicodeFromCID(FX_WORD CID) if (CID < m_EmbeddedCount) { return m_pEmbeddedMap[CID]; } -#ifdef _FPDFAPI_MINI_ - return 0; -#else FX_LPCBYTE record = m_pExternalMap->GetRecord(CID); if (record == NULL) { return 0; } return *(FX_WORD*)record; -#endif } void FPDFAPI_LoadCID2UnicodeMap(int charset, const FX_WORD*& pMap, FX_DWORD& count); void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr, int charset, FX_BOOL bPromptCJK) @@ -792,13 +757,11 @@ void CPDF_CID2UnicodeMap::Load(CPDF_CMapManager* pMgr, int charset, FX_BOOL bPro if (m_EmbeddedCount) { return; } -#ifndef _FPDFAPI_MINI_ FX_LPVOID pPackage = pMgr->GetPackage(bPromptCJK); if (pPackage == NULL) { return; } m_pExternalMap->LoadFile(pPackage, FX_BSTRC("CIDInfo_") + g_CharsetNames[charset]); -#endif } #include "ttgsubtable.h" CPDF_CIDFont::CPDF_CIDFont() @@ -1356,7 +1319,7 @@ int CPDF_CIDFont::GlyphFromCharCode(FX_DWORD charcode, FX_BOOL *pVertGlyph) if (unicode == '\\') { unicode = '/'; } -#if !defined(_FPDFAPI_MINI_) && _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ +#if _FXM_PLATFORM_ != _FXM_PLATFORM_APPLE_ else if (unicode == 0xa5) { unicode = 0x5c; } diff --git a/core/src/fpdfapi/fpdf_font/fpdf_font_utility.cpp b/core/src/fpdfapi/fpdf_font/fpdf_font_utility.cpp index d7c725cc2f..5c4852d586 100644 --- a/core/src/fpdfapi/fpdf_font/fpdf_font_utility.cpp +++ b/core/src/fpdfapi/fpdf_font/fpdf_font_utility.cpp @@ -8,7 +8,6 @@ #include "../../../include/fpdfapi/fpdf_resource.h" #include "../../../include/fxcodec/fx_codec.h" #include "font_int.h" -#ifndef _FPDFAPI_MINI_ typedef struct { FXSYS_FILE* m_pFile; int m_nFiles; @@ -93,4 +92,3 @@ FX_LPBYTE CPDF_FXMP::GetRecord(FX_DWORD index) } return m_pTable + (index - m_pHeader->dwStartIndex) * m_pHeader->dwRecordSize; } -#endif diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp index b1fbe01b90..5d24ab742a 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_image.cpp @@ -77,15 +77,6 @@ CPDF_Image::~CPDF_Image() { if (m_bInline) { if (m_pStream) { -#ifndef FOXIT_CHROME_BUILD - CPDF_Dictionary* pDict = m_pStream->GetDict(); - if (pDict) { - CPDF_Object* pCSObj = pDict->GetElementValue(FX_BSTRC("ColorSpace")); - if (pCSObj && m_pDocument) { - m_pDocument->RemoveColorSpaceFromPageData(pCSObj); - } - } -#endif m_pStream->Release(); } if (m_pInlineDict) { @@ -107,9 +98,7 @@ FX_BOOL CPDF_Image::LoadImageF(CPDF_Stream* pStream, FX_BOOL bInline) } m_pOC = pDict->GetDict(FX_BSTRC("OC")); m_bIsMask = !pDict->KeyExist(FX_BSTRC("ColorSpace")) || pDict->GetInteger(FX_BSTRC("ImageMask")); -#ifndef _FPDFAPI_MINI_ m_bInterpolate = pDict->GetInteger(FX_BSTRC("Interpolate")); -#endif m_Height = pDict->GetInteger(FX_BSTRC("Height")); m_Width = pDict->GetInteger(FX_BSTRC("Width")); return TRUE; diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp index 7d8bd4842a..879c2f3c0e 100644 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp +++ b/core/src/fpdfapi/fpdf_page/fpdf_page_parser.cpp @@ -29,33 +29,9 @@ CPDF_StreamContentParser::CPDF_StreamContentParser() m_pLastImage = NULL; m_bReleaseLastDict = TRUE; m_pParentResources = NULL; -#ifdef _FPDFAPI_MINI_ - m_pObjectState = NULL; - m_pObjectStack = NULL; - m_pWordBuf = NULL; - m_pDictName = NULL; - m_pStreamBuf = NULL; - m_WordState = 0; - m_ObjectSize = 0; -#endif } FX_BOOL CPDF_StreamContentParser::Initialize() { -#ifdef _FPDFAPI_MINI_ - m_pObjectState = FX_Alloc(FX_BOOL, _FPDF_MAX_OBJECT_STACK_SIZE_); - FXSYS_memset32(m_pObjectState, 0, _FPDF_MAX_OBJECT_STACK_SIZE_ * sizeof(FX_BOOL)); - m_pObjectStack = FX_Alloc(CPDF_Object*, _FPDF_MAX_OBJECT_STACK_SIZE_); - FXSYS_memset32(m_pObjectStack, 0, _FPDF_MAX_OBJECT_STACK_SIZE_ * sizeof(CPDF_Object*)); - m_pWordBuf = FX_Alloc(FX_BYTE, 256); - FXSYS_memset32(m_pWordBuf, 0, 256 * sizeof(FX_BYTE)); - m_pDictName = FX_Alloc(FX_BYTE, 256); - FXSYS_memset32(m_pDictName, 0, 256 * sizeof(FX_BYTE)); - m_pStreamBuf = FX_Alloc(FX_BYTE, STREAM_PARSE_BUFSIZE); - FXSYS_memset32(m_pStreamBuf, 0, STREAM_PARSE_BUFSIZE * sizeof(FX_BYTE)); - m_StringBuf.EstimateSize(1024); - m_ObjectSize = 0; - m_ImageSrcBuf.EstimateSize(STREAM_PARSE_BUFSIZE); -#endif return TRUE; } CPDF_StreamContentParser::~CPDF_StreamContentParser() @@ -77,18 +53,6 @@ CPDF_StreamContentParser::~CPDF_StreamContentParser() if (m_pLastCloneImageDict) { m_pLastCloneImageDict->Release(); } -#ifdef _FPDFAPI_MINI_ - for (i = 0; i < (int)m_ObjectSize; ++i) { - if (!m_pObjectState[i]) { - m_pObjectStack[i]->Release(); - } - } - FX_Free(m_pObjectStack); - FX_Free(m_pObjectState); - FX_Free(m_pStreamBuf); - FX_Free(m_pWordBuf); - FX_Free(m_pDictName); -#endif } void CPDF_StreamContentParser::PrepareParse(CPDF_Document* pDocument, CPDF_Dictionary* pPageResources, CPDF_Dictionary* pParentResources, CFX_AffineMatrix* pmtContentToUser, CPDF_PageObjects* pObjList, @@ -128,9 +92,6 @@ void CPDF_StreamContentParser::PrepareParse(CPDF_Document* pDocument, m_pCurStates->m_TextState.New(); m_pCurStates->m_ColorState.New(); } -#ifdef _FPDFAPI_MINI_ - FXSYS_memset32(m_pObjectState, 0, _FPDF_MAX_OBJECT_STACK_SIZE_ * sizeof(FX_BOOL)); -#endif } int CPDF_StreamContentParser::GetNextParamPos() { @@ -676,11 +637,7 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() { CFX_ByteString name = GetString(0); if (name == m_LastImageName && m_pLastImage && m_pLastImage->GetStream() && m_pLastImage->GetStream()->GetObjNum()) { -#if defined(_FPDFAPI_MINI_) && !defined(_FXCORE_FEATURE_ALL_) - AddDuplicateImage(); -#else AddImage(NULL, m_pLastImage, FALSE); -#endif return; } if (m_Options.m_bTextOnly) { @@ -744,7 +701,6 @@ void CPDF_StreamContentParser::Handle_ExecuteXObject() } void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) { -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) if (!m_Options.m_bSeparateForm) { CPDF_Dictionary* pResources = pStream->GetDict()->GetDict(FX_BSTRC("Resources")); CFX_AffineMatrix form_matrix = pStream->GetDict()->GetMatrix(FX_BSTRC("Matrix")); @@ -772,15 +728,9 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) if (stream.GetSize() == 0) { return; } -#ifdef _FPDFAPI_MINI_ - parser.InputData(stream.GetData(), stream.GetSize()); - parser.Finish(); -#else parser.Parse(stream.GetData(), stream.GetSize(), 0); -#endif return; } -#endif CPDF_FormObject* pFormObj = FX_NEW CPDF_FormObject; pFormObj->m_pForm = FX_NEW CPDF_Form(m_pDocument, m_pPageResources, pStream, m_pResources); pFormObj->m_FormMatrix = m_pCurStates->m_CTM; @@ -798,44 +748,6 @@ void CPDF_StreamContentParser::AddForm(CPDF_Stream* pStream) SetGraphicStates(pFormObj, TRUE, TRUE, TRUE); m_pObjectList->m_ObjectList.AddTail(pFormObj); } -#if defined(_FPDFAPI_MINI_) && !defined(_FXCORE_FEATURE_ALL_) -void CPDF_StreamContentParser::AddDuplicateImage() -{ - FX_POSITION tailpos = m_pObjectList->m_ObjectList.GetTailPosition(); - CPDF_PageObject* pLastObj = (CPDF_PageObject*)m_pObjectList->m_ObjectList.GetAt(tailpos); - if (pLastObj == NULL || (pLastObj->m_Type != PDFPAGE_INLINES && pLastObj->m_Type != PDFPAGE_IMAGE)) { - AddImage(NULL, m_pLastImage, FALSE); - return; - } - if (pLastObj->m_GeneralState != m_pCurStates->m_GeneralState || - pLastObj->m_ClipPath != m_pCurStates->m_ClipPath || - pLastObj->m_ColorState != m_pCurStates->m_ColorState) { - AddImage(NULL, m_pLastImage, FALSE); - return; - } - CFX_AffineMatrix ImageMatrix; - ImageMatrix.Copy(m_pCurStates->m_CTM); - ImageMatrix.Concat(m_mtContentToUser); - if (pLastObj->m_Type == PDFPAGE_INLINES) { - CPDF_InlineImages* pInlines = (CPDF_InlineImages*)pLastObj; - if (pInlines->m_pStream != m_pLastImage->GetStream()) { - AddImage(NULL, m_pLastImage, FALSE); - return; - } - pInlines->AddMatrix(ImageMatrix); - } else { - CPDF_ImageObject* pImageObj = (CPDF_ImageObject*)pLastObj; - CPDF_InlineImages* pInlines = FX_NEW CPDF_InlineImages; - pInlines->m_pStream = m_pLastImage->GetStream(); - SetGraphicStates(pInlines, !pInlines->m_pStream->GetDict()->KeyExist(FX_BSTRC("ColorSpace")), FALSE, FALSE); - pInlines->AddMatrix(pImageObj->m_Matrix); - pInlines->AddMatrix(ImageMatrix); - m_pObjectList->m_ObjectList.RemoveAt(tailpos); - m_pObjectList->m_ObjectList.AddTail(pInlines); - pLastObj->Release(); - } -} -#endif CPDF_ImageObject* CPDF_StreamContentParser::AddImage(CPDF_Stream* pStream, CPDF_Image* pImage, FX_BOOL bInline) { if (pStream == NULL && pImage == NULL) { @@ -963,9 +875,7 @@ void CPDF_StreamContentParser::Handle_ClosePath() } void CPDF_StreamContentParser::Handle_SetFlat() { -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) m_pCurStates->m_GeneralState.GetModify()->m_Flatness = GetNumber(0); -#endif } void CPDF_StreamContentParser::Handle_BeginImageData() { @@ -1010,15 +920,11 @@ void CPDF_StreamContentParser::Handle_MoveTo() { REQUIRE_PARAMS(2); if (m_Options.m_bTextOnly) { -#ifndef _FPDFAPI_MINI_ m_pSyntax->SkipPathObject(); -#endif return; } AddPathPoint(GetNumber(1), GetNumber(0), FXPT_MOVETO); -#ifndef _FPDFAPI_MINI_ ParsePathObject(); -#endif } void CPDF_StreamContentParser::Handle_SetMiterLimit() { diff --git a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_new.cpp b/core/src/fpdfapi/fpdf_page/fpdf_page_parser_new.cpp deleted file mode 100644 index 24ec7436aa..0000000000 --- a/core/src/fpdfapi/fpdf_page/fpdf_page_parser_new.cpp +++ /dev/null @@ -1,822 +0,0 @@ -// Copyright 2014 PDFium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com - -#include "../../../include/fpdfapi/fpdf_page.h" -#include "../../../include/fpdfapi/fpdf_module.h" -#include "pageint.h" -#if defined(_FPDFAPI_MINI_) -extern const FX_LPCSTR _PDF_CharType; -void CPDF_StreamContentParser::InputData(FX_LPCBYTE src_buf, FX_DWORD src_size) -{ - if (m_Level > _FPDF_MAX_FORM_LEVEL_) { - return; - } - for (FX_DWORD i = 0; i < src_size; i ++) { - int ch = src_buf[i]; - int type = _PDF_CharType[ch]; -start: - switch (m_WordState) { - case 0: - if (type == 'W') { - } else if (type == 'N') { - m_WordState = 5; - m_pWordBuf[0] = ch; - m_WordSize = 1; - } else if (type == 'R') { - m_WordState = 4; - m_pWordBuf[0] = ch; - m_WordSize = 1; - } else switch (ch) { - case '/': - m_WordState = 2; - m_WordSize = 0; - break; - case '[': - StartArray(); - break; - case ']': - EndArray(); - break; - case '(': - m_WordState = 7; - m_StringLevel = 1; - m_StringState = 0; - m_StringBuf.Clear(); - break; - case '<': - m_WordState = 3; - break; - case '>': - m_WordState = 8; - break; - case '%': - m_WordState = 1; - break; - } - break; - case 1: - if (ch == '\n' || ch == '\r') { - m_WordState = 0; - } - break; - case 2: - if (type != 'R' && type != 'N') { - EndName(); - m_WordState = 0; - goto start; - } - if (m_WordSize < 256) { - m_pWordBuf[m_WordSize++] = ch; - } - break; - case 3: - if (ch == '<') { - StartDict(); - m_WordState = 0; - } else { - m_StringBuf.Clear(); - m_WordState = 6; - goto start; - } - break; - case 4: - if (type != 'R' && type != 'N') { - m_WordState = 0; - EndKeyword(); - if (m_bAbort) { - return; - } - goto start; - } - if (m_WordSize < 256) { - m_pWordBuf[m_WordSize++] = ch; - } - break; - case 5: - if (type != 'N') { - EndNumber(); - m_WordState = 0; - goto start; - } - if (m_WordSize < 256) { - m_pWordBuf[m_WordSize++] = ch; - } - break; - case 6: - if (ch == '>') { - EndHexString(); - m_WordState = 0; - } else { - m_StringBuf.AppendByte(ch); - } - break; - case 7: - switch (m_StringState) { - case 0: - if (ch == ')') { - m_StringLevel --; - if (m_StringLevel == 0) { - EndString(); - m_WordState = 0; - break; - } - m_StringBuf.AppendByte(')'); - } else if (ch == '(') { - m_StringLevel ++; - m_StringBuf.AppendByte('('); - } else if (ch == '\\') { - m_StringState = 1; - } else { - m_StringBuf.AppendByte((char)ch); - } - break; - case 1: - if (ch >= '0' && ch <= '7') { - m_EscCode = ch - '0'; - m_StringState = 2; - break; - } - if (ch == 'n') { - m_StringBuf.AppendByte('\n'); - } else if (ch == 'r') { - m_StringBuf.AppendByte('\r'); - } else if (ch == 't') { - m_StringBuf.AppendByte('\t'); - } else if (ch == 'b') { - m_StringBuf.AppendByte('\b'); - } else if (ch == 'f') { - m_StringBuf.AppendByte('\f'); - } else if (ch == '\\') { - m_StringBuf.AppendByte('\\'); - } else if (ch == '(') { - m_StringBuf.AppendByte('('); - } else if (ch == ')') { - m_StringBuf.AppendByte(')'); - } else if (ch == '\r') { - m_StringState = 4; - break; - } else if (ch == '\n') { - } else { - m_StringBuf.AppendByte(ch); - } - m_StringState = 0; - break; - case 2: - if (ch >= '0' && ch <= '7') { - m_EscCode = m_EscCode * 8 + ch - '0'; - m_StringState = 3; - } else { - m_StringBuf.AppendByte(m_EscCode); - m_StringState = 0; - goto start; - } - break; - case 3: - if (ch >= '0' && ch <= '7') { - m_EscCode = m_EscCode * 8 + ch - '0'; - m_StringBuf.AppendByte(m_EscCode); - m_StringState = 0; - } else { - m_StringBuf.AppendByte(m_EscCode); - m_StringState = 0; - goto start; - } - break; - case 4: - m_StringState = 0; - if (ch != '\n') { - goto start; - } - break; - } - break; - case 8: - m_WordState = 0; - if (ch == '>') { - EndDict(); - } else { - goto start; - } - break; - case 9: - switch (m_InlineImageState) { - case 0: - if (type == 'W' || type == 'D') { - m_InlineImageState = 1; - m_InlineWhiteChar = ch; - } else { - m_StringBuf.AppendByte(ch); - } - break; - case 1: - m_StringBuf.AppendByte(m_InlineWhiteChar); - if (ch == 'I') { - m_InlineImageState = 2; - } else { - m_InlineImageState = 0; - goto start; - } - break; - case 2: - if (ch == 'D') { - m_InlineImageState = 3; - } else { - m_StringBuf.AppendByte('I'); - m_InlineImageState = 0; - goto start; - } - break; - case 3: - EndImageDict(); - break; - } - break; - case 10: - switch (m_InlineImageState) { - case 0: - if (type == 'W') { - m_InlineImageState = 1; - m_InlineWhiteChar = ch; - } else { - m_ImageSrcBuf.AppendByte(ch); - } - break; - case 1: - if (ch == 'E') { - m_InlineImageState = 2; - } else { - m_ImageSrcBuf.AppendByte(m_InlineWhiteChar); - m_InlineImageState = 0; - goto start; - } - break; - case 2: - if (ch == 'I') { - m_InlineImageState = 3; - } else { - m_ImageSrcBuf.AppendByte(m_InlineWhiteChar); - m_ImageSrcBuf.AppendByte('E'); - m_InlineImageState = 0; - goto start; - } - break; - case 3: - if (type == 'W') { - EndInlineImage(); - } else { - m_ImageSrcBuf.AppendByte(m_InlineWhiteChar); - m_ImageSrcBuf.AppendByte('E'); - m_ImageSrcBuf.AppendByte('I'); - m_InlineImageState = 0; - goto start; - } - break; - } - break; - case 11: - if (m_InlineImageState < m_ImageSrcBuf.GetSize()) { - m_ImageSrcBuf.GetBuffer()[m_InlineImageState ++] = ch; - } else { - if (ch == 'I') { - EndInlineImage(); - } - } - break; - } - } -} -void CPDF_StreamContentParser::Finish() -{ - switch (m_WordState) { - case 0: - break; - case 1: - break; - case 2: - EndName(); - break; - case 3: - break; - case 4: - EndKeyword(); - break; - case 5: - EndNumber(); - break; - case 6: - EndHexString(); - break; - case 7: - EndString(); - break; - case 8: - break; - case 9: - break; - case 10: - EndInlineImage(); - break; - } - m_WordState = 0; -} -void CPDF_StreamContentParser::AddContainer(CPDF_Object* pObject) -{ - if (m_ObjectSize) { - m_pObjectState[m_ObjectSize] = SetToCurObj(pObject); - } - FXSYS_assert(m_ObjectSize < _FPDF_MAX_OBJECT_STACK_SIZE_); - m_pObjectStack[m_ObjectSize++] = pObject; -} -FX_BOOL CPDF_StreamContentParser::SetToCurObj(CPDF_Object* pObject) -{ - if (m_ObjectSize == 0) { - AddObjectParam(pObject); - return TRUE; - } - FX_BOOL bInArrayOrDict = TRUE; - CPDF_Object* pCurObj = m_pObjectStack[m_ObjectSize - 1]; - if (pCurObj->GetType() == PDFOBJ_ARRAY) { - ((CPDF_Array*)pCurObj)->Add(pObject, m_pDocument); - } else { - if (!m_bDictName && m_pDictName[0]) { - ((CPDF_Dictionary*)pCurObj)->SetAt((FX_LPCSTR)m_pDictName, pObject, m_pDocument); - } else { - bInArrayOrDict = FALSE; - } - m_bDictName = TRUE; - } - return bInArrayOrDict; -} -void CPDF_StreamContentParser::StartArray() -{ - if (m_ObjectSize) - if (m_pObjectStack[0]->GetType() != PDFOBJ_DICTIONARY && m_pObjectStack[m_ObjectSize - 1]->GetType() == PDFOBJ_ARRAY) { - return; - } - CPDF_Array* pArray = FX_NEW CPDF_Array; - AddContainer(pArray); -} -void CPDF_StreamContentParser::EndArray() -{ - if (m_ObjectSize == 0) { - return; - } - CPDF_Object* pCurObj = m_pObjectStack[m_ObjectSize - 1]; - if (pCurObj->GetType() != PDFOBJ_ARRAY) { - return; - } - m_ObjectSize --; - if (m_ObjectSize == 0) { - AddObjectParam(pCurObj); - } else { - if (!m_pObjectState[m_ObjectSize]) { - pCurObj->Release(); - } - } - m_pObjectState[m_ObjectSize] = FALSE; -} -void CPDF_StreamContentParser::StartDict() -{ - CPDF_Dictionary* pDict = FX_NEW CPDF_Dictionary; - AddContainer(pDict); - m_bDictName = TRUE; -} -void CPDF_StreamContentParser::EndDict() -{ - if (m_ObjectSize == 0) { - return; - } - CPDF_Object* pCurObj = m_pObjectStack[m_ObjectSize - 1]; - if (pCurObj->GetType() != PDFOBJ_DICTIONARY) { - return; - } - m_ObjectSize --; - if (m_ObjectSize == 0) { - AddObjectParam(pCurObj); - } else { - if (!m_pObjectState[m_ObjectSize]) { - pCurObj->Release(); - } - } - m_pObjectState[m_ObjectSize] = FALSE; -} -void CPDF_StreamContentParser::EndName() -{ - if (m_ObjectSize == 0) { - AddNameParam((FX_LPCSTR)m_pWordBuf, m_WordSize); - return; - } - CPDF_Object* pCurObj = m_pObjectStack[m_ObjectSize - 1]; - if (pCurObj->GetType() == PDFOBJ_ARRAY) { - ((CPDF_Array*)pCurObj)->AddName(CFX_ByteString(m_pWordBuf, m_WordSize)); - } else { - if (m_bDictName) { - FXSYS_memcpy32(m_pDictName, m_pWordBuf, m_WordSize); - m_pDictName[m_WordSize] = 0; - } else { - if (m_pDictName[0] != 0) { - ((CPDF_Dictionary*)pCurObj)->SetAtName((FX_LPCSTR)m_pDictName, CFX_ByteString(m_pWordBuf, m_WordSize)); - } - } - m_bDictName = !m_bDictName; - } -} -void CPDF_StreamContentParser::EndNumber() -{ - if (m_ObjectSize == 0) { - AddNumberParam((FX_LPCSTR)m_pWordBuf, m_WordSize); - return; - } - CPDF_Number *pObj = FX_NEW CPDF_Number(CFX_ByteStringC(m_pWordBuf, m_WordSize)); - if (!SetToCurObj(pObj)) { - pObj->Release(); - } -} -extern CFX_ByteString _FPDF_ByteStringFromHex(CFX_BinaryBuf& src_buf); -void CPDF_StreamContentParser::EndHexString() -{ - CPDF_String *pObj = FX_NEW CPDF_String(_FPDF_ByteStringFromHex(m_StringBuf), TRUE); - if (!SetToCurObj(pObj)) { - pObj->Release(); - } -} -void CPDF_StreamContentParser::EndString() -{ - CPDF_String *pObj = FX_NEW CPDF_String(m_StringBuf.GetByteString()); - if (!SetToCurObj(pObj)) { - pObj->Release(); - } -} -void CPDF_StreamContentParser::Handle_BeginImage(void) -{ - m_WordState = 9; - m_InlineImageState = 0; - m_StringBuf.Clear(); -} -void _PDF_ReplaceAbbr(CPDF_Object* pObj); -void CPDF_StreamContentParser::EndImageDict() -{ - if (m_StringBuf.GetSize() != m_LastImageDict.GetSize() || - FXSYS_memcmp32(m_StringBuf.GetBuffer(), m_LastImageDict.GetBuffer(), m_StringBuf.GetSize())) { - m_WordState = 0; - StartDict(); - InputData(m_StringBuf.GetBuffer(), m_StringBuf.GetSize()); - Finish(); - m_bSameLastDict = FALSE; - if (m_pLastImageDict && m_bReleaseLastDict) { - m_pLastImageDict->Release(); - m_pLastImageDict = NULL; - } - if (!m_ObjectSize) { - m_InlineImageState = 0; - return; - } - m_pLastImageDict = (CPDF_Dictionary*)m_pObjectStack[--m_ObjectSize]; - m_bReleaseLastDict = !m_pObjectState[m_ObjectSize]; - m_pObjectState[m_ObjectSize] = FALSE; - _PDF_ReplaceAbbr(m_pLastImageDict); - m_LastImageDict.TakeOver(m_StringBuf); - if (m_pLastImageDict->KeyExist(FX_BSTRC("ColorSpace"))) { - CPDF_Object* pCSObj = m_pLastImageDict->GetElementValue(FX_BSTRC("ColorSpace")); - if (pCSObj->GetType() == PDFOBJ_NAME) { - CFX_ByteString name = pCSObj->GetString(); - if (name != FX_BSTRC("DeviceRGB") && name != FX_BSTRC("DeviceGray") && name != FX_BSTRC("DeviceCMYK")) { - pCSObj = FindResourceObj(FX_BSTRC("ColorSpace"), name); - if (pCSObj) { - if (!pCSObj->GetObjNum()) { - pCSObj = pCSObj->Clone(); - } - m_pLastImageDict->SetAt(FX_BSTRC("ColorSpace"), pCSObj, m_pDocument); - } - } - } - } - } else { - m_bSameLastDict = TRUE; - } - m_ImageSrcBuf.Clear(); - if (m_pLastCloneImageDict) - m_pLastCloneImageDict->Release(); - - m_pLastCloneImageDict = (CPDF_Dictionary*)m_pLastImageDict->Clone(); - if (m_pLastCloneImageDict->KeyExist(FX_BSTRC("Filter"))) { - m_WordState = 10; - m_InlineImageState = 0; - } else { - int width = m_pLastCloneImageDict->GetInteger(FX_BSTRC("Width")); - int height = m_pLastCloneImageDict->GetInteger(FX_BSTRC("Height")); - int OrigSize = 0; - CPDF_Object* pCSObj = m_pLastCloneImageDict->GetElementValue(FX_BSTRC("ColorSpace")); - if (pCSObj != NULL) { - int bpc = m_pLastCloneImageDict->GetInteger(FX_BSTRC("BitsPerComponent")); - int nComponents = 1; - CPDF_ColorSpace* pCS = m_pDocument->LoadColorSpace(pCSObj); - if (pCS == NULL) { - nComponents = 3; - } else { - nComponents = pCS->CountComponents(); - m_pDocument->GetPageData()->ReleaseColorSpace(pCSObj); - } - int pitch = (width * bpc * nComponents + 7) / 8; - OrigSize = pitch * height; - } else { - OrigSize = ((width + 7) / 8) * height; - } - m_ImageSrcBuf.AppendBlock(NULL, OrigSize); - m_WordState = 11; - m_InlineImageState = 0; - } -} -void CPDF_StreamContentParser::EndInlineImage() -{ - CFX_AffineMatrix ImageMatrix; - ImageMatrix.Copy(m_pCurStates->m_CTM); - ImageMatrix.Concat(m_mtContentToUser); - m_LastImageData.CopyData(m_ImageSrcBuf.GetBuffer(), m_ImageSrcBuf.GetSize()); - CPDF_Stream* pStream = CPDF_Stream::Create(m_ImageSrcBuf.GetBuffer(), m_ImageSrcBuf.GetSize(), - m_pLastCloneImageDict); - m_ImageSrcBuf.DetachBuffer(); - m_pLastCloneImageDict = NULL; - CPDF_InlineImages* pImages = FX_NEW CPDF_InlineImages; - pImages->m_pStream = pStream; - SetGraphicStates(pImages, !m_pLastCloneImageDict->KeyExist(FX_BSTRC("ColorSpace")), FALSE, FALSE); - pImages->AddMatrix(ImageMatrix); - m_pObjectList->m_ObjectList.AddTail(pImages); - m_WordState = 0; -} -#define FXDWORD_TRUE FXDWORD_FROM_LSBFIRST(0x65757274) -#define FXDWORD_NULL FXDWORD_FROM_LSBFIRST(0x6c6c756e) -#define FXDWORD_FALS FXDWORD_FROM_LSBFIRST(0x736c6166) -void CPDF_StreamContentParser::EndKeyword() -{ - CPDF_Object *pObj = NULL; - if (m_WordSize == 4) { - if (*(FX_DWORD*)m_pWordBuf == FXDWORD_TRUE) { - pObj = CPDF_Boolean::Create(TRUE); - if (!SetToCurObj(pObj)) { - pObj->Release(); - } - return; - } else if (*(FX_DWORD*)m_pWordBuf == FXDWORD_NULL) { - pObj = CPDF_Null::Create(); - if (!SetToCurObj(pObj)) { - pObj->Release(); - } - return; - } - } else if (m_WordSize == 5) { - if (*(FX_DWORD*)m_pWordBuf == FXDWORD_FALS && m_pWordBuf[4] == 'e') { - pObj = CPDF_Boolean::Create(FALSE); - if (!SetToCurObj(pObj)) { - pObj->Release(); - } - return; - } - } - m_pWordBuf[m_WordSize] = 0; - OnOperator((char*)m_pWordBuf); - ClearAllParams(); -} -#define PAGEPARSE_STAGE_PARSE 2 -#define PAGEPARSE_STAGE_CHECKCLIP 3 -CPDF_ContentParser::CPDF_ContentParser() -{ - m_pParser = NULL; - m_Status = Ready; - m_pStreamFilter = NULL; - m_pType3Char = NULL; -} -CPDF_ContentParser::~CPDF_ContentParser() -{ - Clear(); -} -void CPDF_ContentParser::Clear() -{ - if (m_pParser) { - delete m_pParser; - } - if (m_pStreamFilter) { - delete m_pStreamFilter; - } - m_pParser = NULL; - m_Status = Ready; -} -void CPDF_ContentParser::Start(CPDF_Page* pPage, CPDF_ParseOptions* pOptions) -{ - if (m_Status != Ready || pPage == NULL || pPage->m_pDocument == NULL || pPage->m_pFormDict == NULL) { - m_Status = Done; - return; - } - m_pObjects = pPage; - m_bForm = FALSE; - if (pOptions) { - m_Options = *pOptions; - } - CPDF_Object* pContent = pPage->m_pFormDict->GetElementValue(FX_BSTRC("Contents")); - if (pContent == NULL) { - m_Status = Done; - return; - } - if (pContent->GetType() == PDFOBJ_STREAM) { - m_nStreams = 1; - } else if (pContent->GetType() == PDFOBJ_ARRAY) { - m_nStreams = ((CPDF_Array*)pContent)->GetCount(); - } else { - m_Status = Done; - return; - } - m_Status = ToBeContinued; - m_InternalStage = PAGEPARSE_STAGE_PARSE; - m_CurrentOffset = 0; - m_pParser = FX_NEW CPDF_StreamContentParser; - m_pParser->Initialize(); - m_pParser->PrepareParse(pPage->m_pDocument, pPage->m_pResources, NULL, NULL, pPage, - pPage->m_pResources, &pPage->m_BBox, &m_Options, NULL, 0); - m_pParser->m_pCurStates->m_ColorState.GetModify()->Default(); -} -void CPDF_ContentParser::Start(CPDF_Form* pForm, CPDF_AllStates* pGraphicStates, CFX_AffineMatrix* pParentMatrix, - CPDF_Type3Char* pType3Char, CPDF_ParseOptions* pOptions, int level) -{ - m_pType3Char = pType3Char; - m_pObjects = pForm; - m_bForm = TRUE; - CFX_AffineMatrix form_matrix = pForm->m_pFormDict->GetMatrix(FX_BSTRC("Matrix")); - if (pGraphicStates) { - form_matrix.Concat(pGraphicStates->m_CTM); - } - CPDF_Array* pBBox = pForm->m_pFormDict->GetArray(FX_BSTRC("BBox")); - CFX_FloatRect form_bbox; - CPDF_Path ClipPath; - if (pBBox) { - form_bbox = pBBox->GetRect(); - ClipPath.New(); - ClipPath.AppendRect(form_bbox.left, form_bbox.bottom, form_bbox.right, form_bbox.top); - ClipPath.Transform(&form_matrix); - if (pParentMatrix) { - ClipPath.Transform(pParentMatrix); - } - form_bbox.Transform(&form_matrix); - } - CPDF_Dictionary* pResources = pForm->m_pFormDict->GetDict(FX_BSTRC("Resources")); - m_pParser = FX_NEW CPDF_StreamContentParser; - m_pParser->Initialize(); - m_pParser->PrepareParse(pForm->m_pDocument, pForm->m_pPageResources, pForm->m_pResources, pParentMatrix, pForm, - pResources, &form_bbox, pOptions, pGraphicStates, level); - m_pParser->m_pCurStates->m_CTM = form_matrix; - if (ClipPath.NotNull()) { - m_pParser->m_pCurStates->m_ClipPath.AppendPath(ClipPath, FXFILL_WINDING, TRUE); - } - if (pForm->m_Transparency & PDFTRANS_GROUP) { - CPDF_GeneralStateData* pData = m_pParser->m_pCurStates->m_GeneralState.GetModify(); - pData->m_BlendType = FXDIB_BLEND_NORMAL; - pData->m_StrokeAlpha = 1.0f; - pData->m_FillAlpha = 1.0f; - pData->m_pSoftMask = NULL; - } - m_pStreamFilter = pForm->m_pFormStream->GetStreamFilter(); - m_nStreams = 1; - m_Status = ToBeContinued; - m_InternalStage = PAGEPARSE_STAGE_PARSE; - m_CurrentOffset = 0; -} -void CPDF_ContentParser::Continue(IFX_Pause* pPause) -{ - while (m_Status == ToBeContinued) { - if (m_InternalStage == PAGEPARSE_STAGE_PARSE) { - if (m_pStreamFilter == NULL) { - if (m_CurrentOffset == m_nStreams) { - m_InternalStage = PAGEPARSE_STAGE_CHECKCLIP; - if (m_pType3Char) { - m_pType3Char->m_bColored = m_pParser->m_bColored; - m_pType3Char->m_Width = FXSYS_round(m_pParser->m_Type3Data[0] * 1000); - m_pType3Char->m_BBox.left = FXSYS_round(m_pParser->m_Type3Data[2] * 1000); - m_pType3Char->m_BBox.bottom = FXSYS_round(m_pParser->m_Type3Data[3] * 1000); - m_pType3Char->m_BBox.right = FXSYS_round(m_pParser->m_Type3Data[4] * 1000); - m_pType3Char->m_BBox.top = FXSYS_round(m_pParser->m_Type3Data[5] * 1000); - m_pType3Char->m_bPageRequired = m_pParser->m_bResourceMissing; - } - delete m_pParser; - m_pParser = NULL; - continue; - } - CPDF_Object* pContent = m_pObjects->m_pFormDict->GetElementValue(FX_BSTRC("Contents")); - if (pContent->GetType() == PDFOBJ_STREAM) { - m_pStreamFilter = ((CPDF_Stream*)pContent)->GetStreamFilter(); - } else { - CPDF_Stream* pStream = ((CPDF_Array*)pContent)->GetStream(m_CurrentOffset); - if (pStream == NULL) { - m_CurrentOffset ++; - continue; - } - m_pStreamFilter = pStream->GetStreamFilter(); - } - } - FX_DWORD len = m_pStreamFilter->ReadBlock(m_pParser->m_pStreamBuf, STREAM_PARSE_BUFSIZE); - m_pParser->InputData(m_pParser->m_pStreamBuf, len); - if (m_pParser->m_bAbort) { - delete m_pStreamFilter; - m_pStreamFilter = NULL; - m_Status = Done; - delete m_pParser; - m_pParser = NULL; - return; - } - if (len < STREAM_PARSE_BUFSIZE) { - m_pParser->Finish(); - m_CurrentOffset ++; - delete m_pStreamFilter; - m_pStreamFilter = NULL; - } - if (pPause && pPause->NeedToPauseNow()) { - return; - } - } - if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) { - FX_POSITION pos = m_pObjects->m_ObjectList.GetHeadPosition(); - while (pos) { - CPDF_PageObject* pObj = (CPDF_PageObject*)m_pObjects->m_ObjectList.GetNext(pos); - if (pObj == NULL) { - continue; - } - if (pObj->m_ClipPath.IsNull()) { - continue; - } - if (pObj->m_ClipPath.GetPathCount() != 1) { - continue; - } - if (pObj->m_ClipPath.GetTextCount()) { - continue; - } - CPDF_Path ClipPath = pObj->m_ClipPath.GetPath(0); - if (!ClipPath.IsRect() || pObj->m_Type == PDFPAGE_SHADING) { - continue; - } - CFX_FloatRect old_rect(ClipPath.GetPointX(0), ClipPath.GetPointY(0), - ClipPath.GetPointX(2), ClipPath.GetPointY(2)); - CFX_FloatRect obj_rect(pObj->m_Left, pObj->m_Bottom, pObj->m_Right, pObj->m_Top); - if (old_rect.Contains(obj_rect)) { - pObj->m_ClipPath.SetNull(); - } - } - if (m_pObjects->m_ObjectList.GetCount() == 1) { - CPDF_PageObject* pObj = (CPDF_PageObject*)m_pObjects->m_ObjectList.GetAt(m_pObjects->m_ObjectList.GetHeadPosition()); - if (pObj && pObj->m_Type == PDFPAGE_TEXT) { - CPDF_TextObject* pText = (CPDF_TextObject*)pObj; - } - } - m_Status = Done; - return; - } - } -} -int CPDF_ContentParser::EstimateProgress() -{ - if (m_Status == Ready) { - return 0; - } - if (m_Status == Done) { - return 100; - } - if (m_InternalStage == PAGEPARSE_STAGE_CHECKCLIP) { - return 90; - } - if (m_pStreamFilter == NULL) { - return 90 * m_CurrentOffset / m_nStreams; - } - int total_raw_size = m_pStreamFilter->GetStream()->GetRawSize() * m_nStreams; - int parsed_raw_size = m_pStreamFilter->GetStream()->GetRawSize() * m_CurrentOffset + - m_pStreamFilter->GetSrcPos(); - return 90 * parsed_raw_size / total_raw_size; -} -CPDF_InlineImages::CPDF_InlineImages() -{ - m_Type = PDFPAGE_INLINES; - m_pStream = NULL; - m_pBitmap = NULL; -} -CPDF_InlineImages::~CPDF_InlineImages() -{ - if (m_pStream) { - m_pStream->Release(); - } - if (m_pBitmap) { - delete m_pBitmap; - } -} -void CPDF_InlineImages::AddMatrix(CFX_AffineMatrix& matrix) -{ - m_Matrices.Add(matrix); - CFX_FloatRect rect = matrix.GetUnitRect(); - if (m_Matrices.GetSize() > 1) { - CFX_FloatRect rect1(m_Left, m_Bottom, m_Right, m_Top); - rect.Union(rect1); - } - m_Left = rect.left; - m_Right = rect.right; - m_Top = rect.top; - m_Bottom = rect.bottom; -} -#endif diff --git a/core/src/fpdfapi/fpdf_page/pageint.h b/core/src/fpdfapi/fpdf_page/pageint.h index cc35dbe744..f6b6bea4b9 100644 --- a/core/src/fpdfapi/fpdf_page/pageint.h +++ b/core/src/fpdfapi/fpdf_page/pageint.h @@ -11,7 +11,6 @@ #define PARSE_STEP_LIMIT 100 #define STREAM_PARSE_BUFSIZE 20480 class CPDF_QuickFontCache; -#ifndef _FPDFAPI_MINI_ class CPDF_StreamParser : public CFX_Object { public: @@ -59,7 +58,6 @@ protected: FX_DWORD m_WordSize; CPDF_Object* m_pLastObj; }; -#endif typedef enum { PDFOP_CloseFillStrokePath = 0, PDFOP_FillStrokePath, PDFOP_CloseEOFillStrokePath, PDFOP_EOFillStrokePath, @@ -117,11 +115,7 @@ typedef struct { } m_Name; }; } _ContentParam; -#if defined(_FPDFAPI_MINI_) -#define _FPDF_MAX_FORM_LEVEL_ 17 -#else #define _FPDF_MAX_FORM_LEVEL_ 30 -#endif #define _FPDF_MAX_TYPE3_FORM_LEVEL_ 4 #define _FPDF_MAX_OBJECT_STACK_SIZE_ 512 class CPDF_StreamContentParser : public CFX_Object @@ -163,43 +157,11 @@ public: FX_BOOL OnOperator(FX_LPCSTR op); void BigCaseCaller(int index); FX_BOOL m_bAbort; -#ifndef _FPDFAPI_MINI_ CPDF_StreamParser* m_pSyntax; FX_DWORD GetParsePos() { return m_pSyntax->GetPos(); } -#else - int m_WordState; - void InputData(FX_LPCBYTE src_buf, FX_DWORD src_size); - void Finish(); - void StartArray(); - void EndArray(); - void StartDict(); - void EndDict(); - void EndName(); - void EndNumber(); - void EndKeyword(); - void EndHexString(); - void EndString(); - void EndImageDict(); - void EndInlineImage(); - FX_LPBYTE m_pWordBuf; - FX_DWORD m_WordSize; - CFX_BinaryBuf m_StringBuf; - int m_StringLevel, m_StringState, m_EscCode; - void AddContainer(CPDF_Object* pObject); - FX_BOOL SetToCurObj(CPDF_Object* pObject); - FX_LPBYTE m_pDictName; - FX_BOOL m_bDictName; - CPDF_Object** m_pObjectStack; - FX_BOOL* m_pObjectState; - FX_DWORD m_ObjectSize; - int m_InlineImageState; - FX_BYTE m_InlineWhiteChar; - CFX_BinaryBuf m_ImageSrcBuf; - FX_LPBYTE m_pStreamBuf; -#endif CPDF_AllStates* m_pCurStates; CPDF_ContentMark m_CurContentMark; CFX_PtrArray m_ClipTextList; @@ -210,10 +172,8 @@ public: void ConvertUserSpace(FX_FLOAT& x, FX_FLOAT& y); void ConvertTextSpace(FX_FLOAT& x, FX_FLOAT& y); void OnChangeTextMatrix(); -#ifndef _FPDFAPI_MINI_ FX_DWORD Parse(FX_LPCBYTE pData, FX_DWORD dwSize, FX_DWORD max_cost); void ParsePathObject(); -#endif int m_CompatCount; FX_PATHPOINT* m_pPathPoints; int m_PathPointCount; @@ -419,8 +379,8 @@ public: void ReleaseIccProfile(CPDF_Stream* pIccProfileStream, CPDF_IccProfile* pIccProfile); CPDF_StreamAcc* GetFontFileStreamAcc(CPDF_Stream* pFontStream); void ReleaseFontFileStreamAcc(CPDF_Stream* pFontStream, FX_BOOL bForce = FALSE); - FX_BOOL IsForceClear() const {return m_bForceClear;}
- CPDF_CountedColorSpace* FindColorSpacePtr(CPDF_Object* pCSObj) const;
+ FX_BOOL IsForceClear() const {return m_bForceClear;} + CPDF_CountedColorSpace* FindColorSpacePtr(CPDF_Object* pCSObj) const; CPDF_CountedPattern* FindPatternPtr(CPDF_Object* pPatternObj) const; CPDF_Document* m_pPDFDoc; diff --git a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp index 66231aa528..2f834ea400 100644 --- a/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp +++ b/core/src/fpdfapi/fpdf_parser/fpdf_parser_parser.cpp @@ -1677,11 +1677,7 @@ CPDF_SyntaxParser::CPDF_SyntaxParser() m_pFileBuf = NULL; m_MetadataObjnum = 0; m_dwWordPos = 0; -#if defined(_FPDFAPI_MINI_) - m_bFileStream = TRUE; -#else m_bFileStream = FALSE; -#endif } CPDF_SyntaxParser::~CPDF_SyntaxParser() { @@ -2469,10 +2465,6 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT m_Pos = StreamStartPos; } CPDF_Stream* pStream; -#if defined(_FPDFAPI_MINI_) && !defined(_FXCORE_FEATURE_ALL_) - pStream = FX_NEW CPDF_Stream(m_pFileAccess, pCryptoHandler, m_HeaderOffset + m_Pos, len, pDict, gennum); - m_Pos += len; -#else FX_LPBYTE pData = FX_Alloc(FX_BYTE, len); if (!pData) { return NULL; @@ -2490,7 +2482,6 @@ CPDF_Stream* CPDF_SyntaxParser::ReadStream(CPDF_Dictionary* pDict, PARSE_CONTEXT dest_buf.DetachBuffer(); } pStream = FX_NEW CPDF_Stream(pData, len, pDict); -#endif if (pContext) { pContext->m_DataEnd = pContext->m_DataStart + len; } diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp index 611804bc06..ab1ddb6e85 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render.cpp @@ -35,7 +35,6 @@ void CPDF_DocRenderData::Clear(FX_BOOL bRelease) } } } -#ifndef _FPDFAPI_MINI_ { pos = m_TransferFuncMap.GetStartPosition(); while (pos) { @@ -49,7 +48,6 @@ void CPDF_DocRenderData::Clear(FX_BOOL bRelease) } } } -#endif if (m_pFontCache) { if (bRelease) { delete m_pFontCache; @@ -149,9 +147,6 @@ CPDF_RenderOptions::CPDF_RenderOptions() , m_dwLimitCacheSize(1024 * 1024 * 100) , m_HalftoneLimit(-1) { -#if defined(_FPDFAPI_MINI_) - m_Flags |= RENDER_LIMITEDIMAGECACHE; -#endif } FX_ARGB CPDF_RenderOptions::TranslateColor(FX_ARGB argb) const { @@ -261,12 +256,6 @@ FX_BOOL CPDF_RenderStatus::Initialize(int level, CPDF_RenderContext* pContext, C } else { m_InitialStates.DefaultStates(); } -#if defined(_FPDFAPI_MINI_)||defined(_FXCORE_LIMITED_CPU_) - m_HalftoneLimit = CPDF_ModuleMgr::Get()->GetRenderModule()->GetConfig()->m_HalftoneLimit; - if (pOptions && pOptions->m_HalftoneLimit >= 0) { - m_HalftoneLimit = pOptions->m_HalftoneLimit; - } -#endif m_pObjectRenderer = NULL; m_Transparency = transparency; return TRUE; @@ -327,11 +316,6 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, con if (!m_pObjectRenderer->m_Result) { DrawObjWithBackground(pObj, pObj2Device); } -#ifdef _FPDFAPI_MINI_ - if (m_DitherBits) { - DitherObjectArea(pObj, pObj2Device); - } -#endif delete m_pObjectRenderer; m_pObjectRenderer = NULL; return FALSE; @@ -351,11 +335,6 @@ FX_BOOL CPDF_RenderStatus::ContinueSingleObject(const CPDF_PageObject* pObj, con if (!m_pObjectRenderer->m_Result) { DrawObjWithBackground(pObj, pObj2Device); } -#ifdef _FPDFAPI_MINI_ - if (m_DitherBits) { - DitherObjectArea(pObj, pObj2Device); - } -#endif delete m_pObjectRenderer; m_pObjectRenderer = NULL; return FALSE; @@ -431,11 +410,6 @@ void CPDF_RenderStatus::ProcessObjectNoClip(const CPDF_PageObject* pObj, const C case PDFPAGE_FORM: bRet = ProcessForm((CPDF_FormObject*)pObj, pObj2Device); break; -#if defined(_FPDFAPI_MINI_) - case PDFPAGE_INLINES: - bRet = ProcessInlines((CPDF_InlineImages*)pObj, pObj2Device); - break; -#endif } if (!bRet) { DrawObjWithBackground(pObj, pObj2Device); @@ -465,7 +439,6 @@ void CPDF_RenderStatus::GetScaledMatrix(CFX_Matrix &matrix) const } void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, const CFX_AffineMatrix* pObj2Device) { -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) FX_RECT rect; if (GetObjectClippedRect(pObj, pObj2Device, FALSE, rect)) { return; @@ -492,7 +465,6 @@ void CPDF_RenderStatus::DrawObjWithBackground(const CPDF_PageObject* pObj, const status.Initialize(m_Level + 1, m_pContext, buffer.GetDevice(), buffer.GetMatrix(), NULL, NULL, NULL, &m_Options, m_Transparency, m_bDropObjects, pFormResource); status.RenderSingleObject(pObj, &matrix); buffer.OutputToDevice(); -#endif } FX_BOOL CPDF_RenderStatus::ProcessForm(CPDF_FormObject* pFormObj, const CFX_AffineMatrix* pObj2Device) { @@ -559,12 +531,10 @@ FX_BOOL CPDF_RenderStatus::ProcessPath(CPDF_PathObject* pPathObj, const CFX_Affi if (bStroke) { FillType |= FX_FILL_STROKE; } -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) const CPDF_GeneralStateData* pGeneralData = ((CPDF_PageObject*)pPathObj)->m_GeneralState; if (pGeneralData && pGeneralData->m_StrokeAdjust) { FillType |= FX_STROKE_ADJUST; } -#endif if (m_pType3Char) { FillType |= FX_FILL_TEXT_MODE; } @@ -599,7 +569,6 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, FX_BOOL bTyp int alpha; if (pGeneralData) { alpha = (FX_INT32)(pGeneralData->m_FillAlpha * 255); -#ifndef _FPDFAPI_MINI_ if (pGeneralData->m_pTR) { if (!pGeneralData->m_pTransferFunc) { ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = GetTransferFunc(pGeneralData->m_pTR); @@ -608,7 +577,6 @@ FX_ARGB CPDF_RenderStatus::GetFillArgb(const CPDF_PageObject* pObj, FX_BOOL bTyp rgb = pGeneralData->m_pTransferFunc->TranslateColor(rgb); } } -#endif } else { alpha = 255; } @@ -630,7 +598,6 @@ FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const int alpha; if (pGeneralData) { alpha = (FX_INT32)(pGeneralData->m_StrokeAlpha * 255); -#ifndef _FPDFAPI_MINI_ if (pGeneralData->m_pTR) { if (!pGeneralData->m_pTransferFunc) { ((CPDF_GeneralStateData*)pGeneralData)->m_pTransferFunc = GetTransferFunc(pGeneralData->m_pTR); @@ -639,7 +606,6 @@ FX_ARGB CPDF_RenderStatus::GetStrokeArgb(const CPDF_PageObject* pObj) const rgb = pGeneralData->m_pTransferFunc->TranslateColor(rgb); } } -#endif } else { alpha = 255; } @@ -1038,11 +1004,9 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_PageObject status.Initialize(0, this, pDevice, pLastMatrix, pStopObj, NULL, NULL, pOptions, pItem->m_pObjectList->m_Transparency, FALSE, NULL); status.RenderObjectList(pItem->m_pObjectList, &FinalMatrix); -#if !defined(_FPDFAPI_MINI_) if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); } -#endif if (status.m_bStopped) { pDevice->RestoreState(); break; @@ -1052,11 +1016,9 @@ void CPDF_RenderContext::Render(CFX_RenderDevice* pDevice, const CPDF_PageObject status.Initialize(0, this, pDevice, NULL, pStopObj, NULL, NULL, pOptions, pItem->m_pObjectList->m_Transparency, FALSE, NULL); status.RenderObjectList(pItem->m_pObjectList, &pItem->m_Matrix); -#if !defined(_FPDFAPI_MINI_) if (status.m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { m_pPageCache->CacheOptimization(status.m_Options.m_dwLimitCacheSize); } -#endif if (status.m_bStopped) { pDevice->RestoreState(); break; @@ -1113,11 +1075,7 @@ void CPDF_ProgressiveRenderer::Start(CPDF_RenderContext* pContext, CFX_RenderDev m_PrevLastPos = NULL; Continue(pPause); } -#ifdef _FPDFAPI_MINI_ -#define RENDER_STEP_LIMIT 20 -#else #define RENDER_STEP_LIMIT 100 -#endif void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) { if (m_Status != ToBeContinued) { @@ -1175,11 +1133,9 @@ void CPDF_ProgressiveRenderer::Continue(IFX_Pause* pPause) if (m_pRenderer->ContinueSingleObject(pCurObj, &pItem->m_Matrix, pPause)) { return; } -#if !defined(_FPDFAPI_MINI_) if (pCurObj->m_Type == PDFPAGE_IMAGE && m_pRenderer->m_Options.m_Flags & RENDER_LIMITEDIMAGECACHE) { m_pContext->GetPageCache()->CacheOptimization(m_pRenderer->m_Options.m_dwLimitCacheSize); } -#endif if (pCurObj->m_Type == PDFPAGE_FORM || pCurObj->m_Type == PDFPAGE_SHADING) { objs_to_go = 0; } else { @@ -1320,11 +1276,7 @@ void CPDF_DocRenderData::ReleaseTransferFunc(CPDF_Object* pObj) CPDF_RenderConfig::CPDF_RenderConfig() { m_HalftoneLimit = 0; -#ifdef _FPDFAPI_MINI_ - m_RenderStepLimit = 20; -#else m_RenderStepLimit = 100; -#endif } CPDF_RenderConfig::~CPDF_RenderConfig() { @@ -1363,9 +1315,6 @@ FX_BOOL CPDF_DeviceBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDe m_Matrix.Scale(1.0f, (FX_FLOAT)(max_dpi) / (FX_FLOAT)dpiv); } } -#ifdef _FPDFAPI_MINI_ - m_Matrix.Scale(0.5f, 0.5f); -#endif #endif CFX_Matrix ctm = m_pDevice->GetCTM(); FX_FLOAT fScaleX = FXSYS_fabs(ctm.a); @@ -1387,13 +1336,11 @@ void CPDF_DeviceBuffer::OutputToDevice() m_pDevice->StretchDIBits(m_pBitmap, m_Rect.left, m_Rect.top, m_Rect.Width(), m_Rect.Height()); } } else { -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) CFX_DIBitmap buffer; m_pDevice->CreateCompatibleBitmap(&buffer, m_pBitmap->GetWidth(), m_pBitmap->GetHeight()); m_pContext->GetBackground(&buffer, m_pObject, NULL, &m_Matrix); buffer.CompositeBitmap(0, 0, buffer.GetWidth(), buffer.GetHeight(), m_pBitmap, 0, 0); m_pDevice->StretchDIBits(&buffer, m_Rect.left, m_Rect.top, m_Rect.Width(), m_Rect.Height()); -#endif } } CPDF_ScaledRenderBuffer::CPDF_ScaledRenderBuffer() @@ -1406,11 +1353,7 @@ CPDF_ScaledRenderBuffer::~CPDF_ScaledRenderBuffer() delete m_pBitmapDevice; } } -#ifndef _FPDFAPI_MINI_ #define _FPDFAPI_IMAGESIZE_LIMIT_ (30 * 1024 * 1024) -#else -#define _FPDFAPI_IMAGESIZE_LIMIT_ (10 * 1024 * 1024) -#endif FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_RenderDevice* pDevice, FX_RECT* pRect, const CPDF_PageObject* pObj, const CPDF_RenderOptions *pOptions, int max_dpi) { @@ -1460,9 +1403,7 @@ FX_BOOL CPDF_ScaledRenderBuffer::Initialize(CPDF_RenderContext* pContext, CFX_Re } m_Matrix.Scale(0.5f, 0.5f); } -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) m_pContext->GetBackground(m_pBitmapDevice->GetBitmap(), m_pObject, pOptions, &m_Matrix); -#endif return TRUE; } void CPDF_ScaledRenderBuffer::OutputToDevice() diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp index 45b6970e2a..de2a409e1c 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_cache.cpp @@ -248,7 +248,6 @@ FX_BOOL CPDF_ImageCache::GetCachedBitmap(CFX_DIBSource*& pBitmap, CFX_DIBSource* return FALSE; } m_MatteColor = MatteColor; -#if !defined(_FPDFAPI_MINI_) if (pSrc->GetPitch() * pSrc->GetHeight() < FPDF_HUGE_IMAGE_SIZE) { m_pCachedBitmap = pSrc->Clone(); delete pSrc; @@ -259,23 +258,7 @@ FX_BOOL CPDF_ImageCache::GetCachedBitmap(CFX_DIBSource*& pBitmap, CFX_DIBSource* m_pCachedMask = pMaskSrc->Clone(); delete pMaskSrc; } -#else - if (pSrc->GetFormat() == FXDIB_8bppRgb && pSrc->GetPalette() && - pSrc->GetHeight() * pSrc->GetWidth() * 3 < 1024) { -#if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ - m_pCachedBitmap = pSrc->CloneConvert(FXDIB_Rgb32); -#else - m_pCachedBitmap = pSrc->CloneConvert(FXDIB_Rgb); -#endif - delete pSrc; - } else if (pSrc->GetPitch() * pSrc->GetHeight() < 102400) { - m_pCachedBitmap = pSrc->Clone(); - delete pSrc; - } else { - m_pCachedBitmap = pSrc; - } - m_pCachedMask = pMaskSrc; -#endif + pBitmap = m_pCachedBitmap; pMask = m_pCachedMask; CalcSize(); @@ -326,7 +309,6 @@ int CPDF_ImageCache::ContinueGetCachedBitmap() CPDF_RenderContext*pContext = m_pRenderStatus->GetContext(); CPDF_PageRenderCache* pPageRenderCache = pContext->m_pPageCache; m_dwTimeCount = pPageRenderCache->GetTimeCount(); -#if !defined(_FPDFAPI_MINI_) if (m_pCurBitmap->GetPitch() * m_pCurBitmap->GetHeight() < FPDF_HUGE_IMAGE_SIZE) { m_pCachedBitmap = m_pCurBitmap->Clone(); delete m_pCurBitmap; @@ -339,22 +321,6 @@ int CPDF_ImageCache::ContinueGetCachedBitmap() delete m_pCurMask; m_pCurMask = NULL; } -#else - if (m_pCurBitmap->GetFormat() == FXDIB_8bppRgb && m_pCurBitmap->GetPalette() && - m_pCurBitmap->GetHeight() * m_pCurBitmap->GetWidth() * 3 < 1024) { - m_pCachedBitmap = m_pCurBitmap->CloneConvert(FXDIB_Rgb32); - m_pCachedBitmap = m_pCurBitmap->CloneConvert(FXDIB_Rgb); - delete m_pCurBitmap; - m_pCurBitmap = NULL; - } else if (m_pCurBitmap->GetPitch() * m_pCurBitmap->GetHeight() < 102400) { - m_pCachedBitmap = m_pCurBitmap->Clone(); - delete m_pCurBitmap; - m_pCurBitmap = NULL; - } else { - m_pCachedBitmap = m_pCurBitmap; - } - m_pCachedMask = m_pCurMask; -#endif m_pCurBitmap = m_pCachedBitmap; m_pCurMask = m_pCachedMask; CalcSize(); diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp index 1452b9d9f9..ffe559ad54 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_image.cpp @@ -17,53 +17,8 @@ FX_BOOL CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj, const CFX_A if (render.Start(this, pImageObj, pObj2Device, m_bStdCS, m_curBlend)) { render.Continue(NULL); } -#ifdef _FPDFAPI_MINI_ - if (m_DitherBits) { - DitherObjectArea(pImageObj, pObj2Device); - } -#endif return render.m_Result; } -#if defined(_FPDFAPI_MINI_) -FX_BOOL CPDF_RenderStatus::ProcessInlines(CPDF_InlineImages* pInlines, const CFX_AffineMatrix* pObj2Device) -{ - int bitmap_alpha = 255; - if (!pInlines->m_GeneralState.IsNull()) { - bitmap_alpha = FXSYS_round(pInlines->m_GeneralState.GetObject()->m_FillAlpha * 255); - } - if (pInlines->m_pStream) { - CPDF_DIBSource dibsrc; - if (!dibsrc.Load(m_pContext->m_pDocument, pInlines->m_pStream, NULL, NULL, NULL, NULL)) { - return TRUE; - } - pInlines->m_pBitmap = dibsrc.Clone(); - pInlines->m_pStream->Release(); - pInlines->m_pStream = NULL; - } - if (pInlines->m_pBitmap == NULL) { - return TRUE; - } - FX_ARGB fill_argb = 0; - if (pInlines->m_pBitmap->IsAlphaMask()) { - fill_argb = GetFillArgb(pInlines); - } - int flags = 0; - if (m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { - flags |= RENDER_FORCE_DOWNSAMPLE; - } else if (m_Options.m_Flags & RENDER_FORCE_HALFTONE) { - flags = 0; - } - for (int i = 0; i < pInlines->m_Matrices.GetSize(); i ++) { - CFX_AffineMatrix image_matrix = pInlines->m_Matrices.GetAt(i); - image_matrix.Concat(*pObj2Device); - CPDF_ImageRenderer renderer; - if (renderer.Start(this, pInlines->m_pBitmap, fill_argb, bitmap_alpha, &image_matrix, flags, FALSE, m_curBlend)) { - renderer.Continue(NULL); - } - } - return TRUE; -} -#endif void CPDF_RenderStatus::CompositeDIBitmap(CFX_DIBitmap* pDIBitmap, int left, int top, FX_ARGB mask_argb, int bitmap_alpha, int blend_mode, int Transparency) { @@ -392,7 +347,6 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() if (m_pRenderStatus->m_Options.m_ColorMode == RENDER_COLOR_ALPHA && m_Loader.m_pMask == NULL) { return StartBitmapAlpha(); } -#ifndef _FPDFAPI_MINI_ if (pGeneralState && pGeneralState->m_pTR) { if (!pGeneralState->m_pTransferFunc) { ((CPDF_GeneralStateData*)pGeneralState)->m_pTransferFunc = m_pRenderStatus->GetTransferFunc(pGeneralState->m_pTR); @@ -405,7 +359,6 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() m_Loader.m_bCached = FALSE; } } -#endif m_FillArgb = 0; m_bPatternColor = FALSE; m_pPattern = NULL; @@ -424,32 +377,11 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() m_pDIBSource = m_pClone; } m_Flags = 0; -#if !defined(_FPDFAPI_MINI_) if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_DOWNSAMPLE) { m_Flags |= RENDER_FORCE_DOWNSAMPLE; } else if (m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE) { m_Flags |= RENDER_FORCE_HALFTONE; } -#else - if (!(m_pRenderStatus->m_Options.m_Flags & RENDER_FORCE_HALFTONE)) { - if (m_pRenderStatus->m_HalftoneLimit) { - CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); - FX_RECT image_rect = image_rect_f.GetOutterRect(); - FX_RECT image_clip = image_rect; - image_rect.Intersect(m_pRenderStatus->m_pDevice->GetClipBox()); - if (image_rect.Width() && image_rect.Height()) { - if ((image_clip.Width() * m_pDIBSource->GetWidth() / image_rect.Width()) * - (image_clip.Height() * m_pDIBSource->GetHeight() / image_rect.Height()) > - m_pRenderStatus->m_HalftoneLimit) { - m_Flags |= RENDER_FORCE_DOWNSAMPLE; - } - } - } else { - m_Flags |= RENDER_FORCE_DOWNSAMPLE; - } - } -#endif -#ifndef _FPDFAPI_MINI_ if (m_pRenderStatus->m_pDevice->GetDeviceClass() != FXDC_DISPLAY) { CPDF_Object* pFilters = m_pImageObject->m_pImage->GetStream()->GetDict()->GetElementValue(FX_BSTRC("Filter")); if (pFilters) { @@ -475,14 +407,12 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() } else if (m_pImageObject->m_pImage->IsInterpol()) { m_Flags |= FXDIB_INTERPOL; } -#endif if (m_Loader.m_pMask) { return DrawMaskedImage(); } if (m_bPatternColor) { return DrawPatternImage(m_pObj2Device); } -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) if (m_BitmapAlpha == 255 && pGeneralState && pGeneralState->m_FillOP && pGeneralState->m_OPMode == 0 && pGeneralState->m_BlendType == FXDIB_BLEND_NORMAL && pGeneralState->m_StrokeAlpha == 1 && pGeneralState->m_FillAlpha == 1) { CPDF_Document* pDocument = NULL; @@ -504,7 +434,6 @@ FX_BOOL CPDF_ImageRenderer::StartRenderDIBSource() pDocument->GetPageData()->ReleaseColorSpace(pCSObj); } } -#endif return StartDIBSource(); } FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CPDF_PageObject* pObj, const CFX_AffineMatrix* pObj2Device, FX_BOOL bStdCS, int blendType) @@ -514,12 +443,10 @@ FX_BOOL CPDF_ImageRenderer::Start(CPDF_RenderStatus* pStatus, const CPDF_PageObj m_pImageObject = (CPDF_ImageObject*)pObj; m_BlendType = blendType; m_pObj2Device = pObj2Device; -#ifndef _FPDFAPI_MINI_ CPDF_Dictionary* pOC = m_pImageObject->m_pImage->GetOC(); if (pOC && m_pRenderStatus->m_Options.m_pOCContext && !m_pRenderStatus->m_Options.m_pOCContext->CheckOCGVisible(pOC)) { return FALSE; } -#endif m_ImageMatrix = m_pImageObject->m_Matrix; m_ImageMatrix.Concat(*pObj2Device); if (StartLoadDIBSource()) { @@ -721,14 +648,12 @@ FX_BOOL CPDF_ImageRenderer::DrawMaskedImage() } FX_BOOL CPDF_ImageRenderer::StartDIBSource() { -#if !defined(_FPDFAPI_MINI_) if (!(m_Flags & RENDER_FORCE_DOWNSAMPLE) && m_pDIBSource->GetBPP() > 1) { int image_size = m_pDIBSource->GetBPP() / 8 * m_pDIBSource->GetWidth() * m_pDIBSource->GetHeight(); if (image_size > FPDF_HUGE_IMAGE_SIZE && !(m_Flags & RENDER_FORCE_HALFTONE)) { m_Flags |= RENDER_FORCE_DOWNSAMPLE; } } -#endif if (m_pRenderStatus->m_pDevice->StartDIBits(m_pDIBSource, m_BitmapAlpha, m_FillArgb, &m_ImageMatrix, m_Flags, m_DeviceHandle, 0, NULL, m_BlendType)) { if (m_DeviceHandle != NULL) { @@ -737,7 +662,6 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() } return FALSE; } -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) CFX_FloatRect image_rect_f = m_ImageMatrix.GetUnitRect(); FX_RECT image_rect = image_rect_f.GetOutterRect(); int dest_width = image_rect.Width(); @@ -794,12 +718,10 @@ FX_BOOL CPDF_ImageRenderer::StartDIBSource() delete pStretched; pStretched = NULL; } -#endif return FALSE; } FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() { -#ifndef _FPDFAPI_MINI_ if (m_pDIBSource->IsOpaqueImage()) { CFX_PathData path; path.AppendRect(0, 0, 1, 1); @@ -830,13 +752,11 @@ FX_BOOL CPDF_ImageRenderer::StartBitmapAlpha() delete pAlphaMask; } } -#endif return FALSE; } FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) { if (m_Status == 1) { -#ifndef _FPDFAPI_MINI_ if (m_pQuickStretcher->Continue(pPause)) { return TRUE; } @@ -847,9 +767,7 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) m_pRenderStatus->m_pDevice->SetDIBits(m_pQuickStretcher->m_pBitmap, m_pQuickStretcher->m_ResultLeft, m_pQuickStretcher->m_ResultTop, m_BlendType); return FALSE; -#endif } else if (m_Status == 2) { -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) if (m_pTransformer->Continue(pPause)) { return TRUE; } @@ -872,7 +790,6 @@ FX_BOOL CPDF_ImageRenderer::Continue(IFX_Pause* pPause) } delete pBitmap; return FALSE; -#endif } else if (m_Status == 3) { return m_pRenderStatus->m_pDevice->ContinueDIBits(m_DeviceHandle, pPause); } else if (m_Status == 4) { diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp index 9d9d9ecfd1..6b895b525b 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_pattern.cpp @@ -881,11 +881,6 @@ FX_BOOL CPDF_RenderStatus::ProcessShading(CPDF_ShadingObject* pShadingObj, const matrix.Concat(*pObj2Device); DrawShading(pShadingObj->m_pShading, &matrix, rect, pShadingObj->m_GeneralState.GetAlpha(FALSE), m_Options.m_ColorMode == RENDER_COLOR_ALPHA); -#ifdef _FPDFAPI_MINI_ - if (m_DitherBits) { - DitherObjectArea(pShadingObj, pObj2Device); - } -#endif return TRUE; } static CFX_DIBitmap* DrawPatternBitmap(CPDF_Document* pDoc, CPDF_PageRenderCache* pCache, @@ -1117,9 +1112,4 @@ void CPDF_RenderStatus::ProcessPathPattern(CPDF_PathObject* pPathObj, const CFX_ bPattern = TRUE; } } -#ifdef _FPDFAPI_MINI_ - if (bPattern && m_DitherBits) { - DitherObjectArea(pPathObj, pObj2Device); - } -#endif } diff --git a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp index fcb422b6c4..449b003c56 100644 --- a/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp +++ b/core/src/fpdfapi/fpdf_render/fpdf_render_text.cpp @@ -256,16 +256,6 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj, const CFX DrawTextPathWithPattern(textobj, pObj2Device, pFont, font_size, &text_matrix, bFill, bStroke); return TRUE; } -#if defined(_FPDFAPI_MINI_) - if (bFill) { - bStroke = FALSE; - } - if (bStroke) { - if (font_size * text_matrix.GetXUnit() * pObj2Device->GetXUnit() < 6) { - bStroke = FALSE; - } - } -#endif if (bClip || bStroke) { const CFX_AffineMatrix* pDeviceMatrix = pObj2Device; CFX_AffineMatrix device_matrix; @@ -284,12 +274,10 @@ FX_BOOL CPDF_RenderStatus::ProcessText(const CPDF_TextObject* textobj, const CFX flag |= FX_FILL_STROKE; flag |= FX_STROKE_TEXT_MODE; } -#if !defined(_FPDFAPI_MINI_) || defined(_FXCORE_FEATURE_ALL_) const CPDF_GeneralStateData* pGeneralData = ((CPDF_PageObject*)textobj)->m_GeneralState; if (pGeneralData && pGeneralData->m_StrokeAdjust) { flag |= FX_STROKE_ADJUST; } -#endif if (m_Options.m_Flags & RENDER_NOTEXTSMOOTH) { flag |= FXFILL_NOPATHSMOOTH; } diff --git a/core/src/fpdfapi/fpdf_render/render_int.h b/core/src/fpdfapi/fpdf_render/render_int.h index f9a04a99a4..81feb5eb88 100644 --- a/core/src/fpdfapi/fpdf_render/render_int.h +++ b/core/src/fpdfapi/fpdf_render/render_int.h @@ -435,11 +435,7 @@ protected: CFX_DIBitmap* m_pCachedBitmap; ICodec_ScanlineDecoder* m_pDecoder; }; -#ifdef _FPDFAPI_MINI_ -#define FPDF_HUGE_IMAGE_SIZE 3000000 -#else #define FPDF_HUGE_IMAGE_SIZE 60000000 -#endif class CPDF_DIBTransferFunc : public CFX_FilteredDIB { public: |