#include "core/fpdfapi/render/cpdf_renderstatus.h"
#include <stdint.h>
#include <algorithm>
#include <memory>
#include <numeric>
#include <set>
#include <utility>
#include <vector>
#include "build/build_config.h"
#include "constants/transparency.h"
#include "core/fpdfapi/font/cpdf_font.h"
#include "core/fpdfapi/font/cpdf_type3char.h"
#include "core/fpdfapi/font/cpdf_type3font.h"
#include "core/fpdfapi/page/cpdf_docpagedata.h"
#include "core/fpdfapi/page/cpdf_form.h"
#include "core/fpdfapi/page/cpdf_formobject.h"
#include "core/fpdfapi/page/cpdf_function.h"
#include "core/fpdfapi/page/cpdf_graphicstates.h"
#include "core/fpdfapi/page/cpdf_image.h"
#include "core/fpdfapi/page/cpdf_imageobject.h"
#include "core/fpdfapi/page/cpdf_occontext.h"
#include "core/fpdfapi/page/cpdf_page.h"
#include "core/fpdfapi/page/cpdf_pageimagecache.h"
#include "core/fpdfapi/page/cpdf_pageobject.h"
#include "core/fpdfapi/page/cpdf_pathobject.h"
#include "core/fpdfapi/page/cpdf_shadingobject.h"
#include "core/fpdfapi/page/cpdf_shadingpattern.h"
#include "core/fpdfapi/page/cpdf_textobject.h"
#include "core/fpdfapi/page/cpdf_tilingpattern.h"
#include "core/fpdfapi/page/cpdf_transferfunc.h"
#include "core/fpdfapi/parser/cpdf_array.h"
#include "core/fpdfapi/parser/cpdf_document.h"
#include "core/fpdfapi/parser/cpdf_stream.h"
#include "core/fpdfapi/parser/fpdf_parser_utility.h"
#include "core/fpdfapi/render/charposlist.h"
#include "core/fpdfapi/render/cpdf_docrenderdata.h"
#include "core/fpdfapi/render/cpdf_imagerenderer.h"
#include "core/fpdfapi/render/cpdf_rendercontext.h"
#include "core/fpdfapi/render/cpdf_renderoptions.h"
#include "core/fpdfapi/render/cpdf_rendershading.h"
#include "core/fpdfapi/render/cpdf_rendertiling.h"
#include "core/fpdfapi/render/cpdf_textrenderer.h"
#include "core/fpdfapi/render/cpdf_type3cache.h"
#include "core/fxcrt/autorestorer.h"
#include "core/fxcrt/check.h"
#include "core/fxcrt/compiler_specific.h"
#include "core/fxcrt/containers/contains.h"
#include "core/fxcrt/data_vector.h"
#include "core/fxcrt/fx_2d_size.h"
#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_system.h"
#include "core/fxcrt/notreached.h"
#include "core/fxcrt/span.h"
#include "core/fxcrt/stl_util.h"
#include "core/fxcrt/unowned_ptr.h"
#include "core/fxge/agg/cfx_agg_imagerenderer.h"
#include "core/fxge/cfx_defaultrenderdevice.h"
#include "core/fxge/cfx_fillrenderoptions.h"
#include "core/fxge/cfx_glyphbitmap.h"
#include "core/fxge/cfx_path.h"
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/fx_font.h"
#include "core/fxge/renderdevicedriver_iface.h"
#include "core/fxge/text_char_pos.h"
#include "core/fxge/text_glyph_pos.h"
#if BUILDFLAG(IS_WIN)
#include "core/fpdfapi/render/cpdf_scaledrenderbuffer.h"
#endif
namespace {
constexpr int kRenderMaxRecursionDepth = …;
int g_CurrentRecursionDepth = …;
CFX_FillRenderOptions GetFillOptionsForDrawPathWithBlend(
const CPDF_RenderOptions::Options& options,
const CPDF_PathObject* path_obj,
CFX_FillRenderOptions::FillType fill_type,
bool is_stroke,
bool is_type3_char) { … }
CFX_FillRenderOptions GetFillOptionsForDrawTextPath(
const CPDF_RenderOptions::Options& options,
const CPDF_TextObject* text_obj,
bool is_stroke,
bool is_fill) { … }
FXDIB_Format GetFormatForLuminosity(bool is_luminosity) { … }
bool IsAvailableMatrix(const CFX_Matrix& matrix) { … }
bool MissingFillColor(const CPDF_ColorState* pColorState) { … }
bool MissingStrokeColor(const CPDF_ColorState* pColorState) { … }
bool Type3CharMissingFillColor(const CPDF_Type3Char* pChar,
const CPDF_ColorState* pColorState) { … }
bool Type3CharMissingStrokeColor(const CPDF_Type3Char* pChar,
const CPDF_ColorState* pColorState) { … }
}
CPDF_RenderStatus::CPDF_RenderStatus(CPDF_RenderContext* pContext,
CFX_RenderDevice* pDevice)
: … { … }
CPDF_RenderStatus::~CPDF_RenderStatus() = default;
void CPDF_RenderStatus::Initialize(const CPDF_RenderStatus* pParentStatus,
const CPDF_GraphicStates* pInitialStates) { … }
void CPDF_RenderStatus::RenderObjectList(
const CPDF_PageObjectHolder* pObjectHolder,
const CFX_Matrix& mtObj2Device) { … }
void CPDF_RenderStatus::RenderSingleObject(CPDF_PageObject* pObj,
const CFX_Matrix& mtObj2Device) { … }
bool CPDF_RenderStatus::ContinueSingleObject(CPDF_PageObject* pObj,
const CFX_Matrix& mtObj2Device,
PauseIndicatorIface* pPause) { … }
FX_RECT CPDF_RenderStatus::GetObjectClippedRect(
const CPDF_PageObject* pObj,
const CFX_Matrix& mtObj2Device) const { … }
void CPDF_RenderStatus::ProcessObjectNoClip(CPDF_PageObject* pObj,
const CFX_Matrix& mtObj2Device) { … }
bool CPDF_RenderStatus::DrawObjWithBlend(CPDF_PageObject* pObj,
const CFX_Matrix& mtObj2Device) { … }
void CPDF_RenderStatus::DrawObjWithBackground(CPDF_PageObject* pObj,
const CFX_Matrix& mtObj2Device) { … }
void CPDF_RenderStatus::DrawObjWithBackgroundToDevice(
CPDF_PageObject* obj,
const CFX_Matrix& object_to_device,
CFX_RenderDevice* device,
const CFX_Matrix& device_matrix) { … }
bool CPDF_RenderStatus::ProcessForm(const CPDF_FormObject* pFormObj,
const CFX_Matrix& mtObj2Device) { … }
bool CPDF_RenderStatus::ProcessPath(CPDF_PathObject* path_obj,
const CFX_Matrix& mtObj2Device) { … }
RetainPtr<CPDF_TransferFunc> CPDF_RenderStatus::GetTransferFunc(
RetainPtr<const CPDF_Object> pObj) const { … }
FX_ARGB CPDF_RenderStatus::GetFillArgb(CPDF_PageObject* pObj) const { … }
FX_ARGB CPDF_RenderStatus::GetFillArgbForType3(CPDF_PageObject* pObj) const { … }
FX_ARGB CPDF_RenderStatus::GetStrokeArgb(CPDF_PageObject* pObj) const { … }
void CPDF_RenderStatus::ProcessClipPath(const CPDF_ClipPath& ClipPath,
const CFX_Matrix& mtObj2Device) { … }
bool CPDF_RenderStatus::ClipPattern(const CPDF_PageObject* page_obj,
const CFX_Matrix& mtObj2Device,
bool stroke) { … }
bool CPDF_RenderStatus::SelectClipPath(const CPDF_PathObject* path_obj,
const CFX_Matrix& mtObj2Device,
bool stroke) { … }
bool CPDF_RenderStatus::ProcessTransparency(CPDF_PageObject* pPageObj,
const CFX_Matrix& mtObj2Device) { … }
FX_RECT CPDF_RenderStatus::GetClippedBBox(const FX_RECT& rect) const { … }
RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::GetBackdrop(
const CPDF_PageObject* pObj,
const FX_RECT& bbox,
bool bBackAlphaRequired) { … }
std::unique_ptr<CPDF_GraphicStates> CPDF_RenderStatus::CloneObjStates(
const CPDF_GraphicStates* pSrcStates,
bool stroke) { … }
bool CPDF_RenderStatus::ProcessText(CPDF_TextObject* textobj,
const CFX_Matrix& mtObj2Device,
CFX_Path* clipping_path) { … }
bool CPDF_RenderStatus::ProcessType3Text(CPDF_TextObject* textobj,
const CFX_Matrix& mtObj2Device) { … }
void CPDF_RenderStatus::DrawTextPathWithPattern(const CPDF_TextObject* textobj,
const CFX_Matrix& mtObj2Device,
CPDF_Font* pFont,
float font_size,
const CFX_Matrix& mtTextMatrix,
bool fill,
bool stroke) { … }
void CPDF_RenderStatus::DrawShadingPattern(CPDF_ShadingPattern* pattern,
const CPDF_PageObject* pPageObj,
const CFX_Matrix& mtObj2Device,
bool stroke) { … }
void CPDF_RenderStatus::ProcessShading(const CPDF_ShadingObject* pShadingObj,
const CFX_Matrix& mtObj2Device) { … }
void CPDF_RenderStatus::DrawTilingPattern(CPDF_TilingPattern* pattern,
CPDF_PageObject* pPageObj,
const CFX_Matrix& mtObj2Device,
bool stroke) { … }
void CPDF_RenderStatus::DrawPathWithPattern(CPDF_PathObject* path_obj,
const CFX_Matrix& mtObj2Device,
const CPDF_Color* pColor,
bool stroke) { … }
void CPDF_RenderStatus::ProcessPathPattern(
CPDF_PathObject* path_obj,
const CFX_Matrix& mtObj2Device,
CFX_FillRenderOptions::FillType* fill_type,
bool* stroke) { … }
bool CPDF_RenderStatus::ProcessImage(CPDF_ImageObject* pImageObj,
const CFX_Matrix& mtObj2Device) { … }
void CPDF_RenderStatus::CompositeDIBitmap(
RetainPtr<CFX_DIBitmap> bitmap,
int left,
int top,
FX_ARGB mask_argb,
float alpha,
BlendMode blend_mode,
const CPDF_Transparency& transparency) { … }
RetainPtr<CFX_DIBitmap> CPDF_RenderStatus::LoadSMask(
CPDF_Dictionary* smask_dict,
const FX_RECT& clip_rect,
const CFX_Matrix& smask_matrix) { … }
FX_ARGB CPDF_RenderStatus::GetBackgroundColor(
const CPDF_Dictionary* pSMaskDict,
const CPDF_Dictionary* pGroupDict,
CPDF_ColorSpace::Family* pCSFamily) { … }
FXDIB_Format CPDF_RenderStatus::GetCompatibleArgbFormat() const { … }