Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_imagerenderer.h
Go to the documentation of this file.
1// Copyright 2016 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#ifndef CORE_FPDFAPI_RENDER_CPDF_IMAGERENDERER_H_
8#define CORE_FPDFAPI_RENDER_CPDF_IMAGERENDERER_H_
9
10#include <memory>
11#include <optional>
12
13#include "build/build_config.h"
14#include "core/fxcrt/fx_coordinates.h"
15#include "core/fxcrt/retain_ptr.h"
16#include "core/fxcrt/unowned_ptr.h"
17#include "core/fxge/dib/fx_dib.h"
18
20class CFX_DIBBase;
21class CFX_DIBitmap;
22class CFX_DefaultRenderDevice;
24class CPDF_ImageObject;
25class CPDF_Pattern;
29
30#if BUILDFLAG(IS_WIN)
31class CFX_ImageTransformer;
32#endif
33
35 public:
36 explicit CPDF_ImageRenderer(CPDF_RenderStatus* pStatus);
38
39 bool Start(CPDF_ImageObject* pImageObject,
40 const CFX_Matrix& mtObj2Device,
41 bool bStdCS);
42
43 bool Start(RetainPtr<CFX_DIBBase> pDIBBase,
44 FX_ARGB bitmap_argb,
45 const CFX_Matrix& mtImage2Device,
46 const FXDIB_ResampleOptions& options,
47 bool bStdCS);
48
49 bool Continue(PauseIndicatorIface* pPause);
50 bool GetResult() const { return m_Result; }
51
52 private:
53 enum class Mode {
54 kNone = 0,
55 kDefault,
56 kBlend, // AGG-specific
57#if BUILDFLAG(IS_WIN)
58 kTransform,
59#endif
60 };
61
62 bool StartBitmapAlpha();
63 bool StartDIBBase();
64 bool StartRenderDIBBase();
65 bool StartLoadDIBBase();
66 bool ContinueDefault(PauseIndicatorIface* pPause);
67 bool ContinueBlend(PauseIndicatorIface* pPause);
68 bool DrawMaskedImage();
69 bool DrawPatternImage();
70#if BUILDFLAG(IS_WIN)
73 bool IsPrinting() const;
74 void HandleFilters();
75#endif
76 FX_RECT GetDrawRect() const;
77 CFX_Matrix GetDrawMatrix(const FX_RECT& rect) const;
78 // Returns the mask, or nullptr if the mask could not be created.
79 RetainPtr<const CFX_DIBitmap> CalculateDrawImage(
80 CFX_DefaultRenderDevice& bitmap_device,
81 RetainPtr<CFX_DIBBase> pDIBBase,
82 const CFX_Matrix& mtNewMatrix,
83 const FX_RECT& rect) const;
84 const CPDF_RenderOptions& GetRenderOptions() const;
85 std::optional<FX_RECT> GetUnitRect() const;
86 bool GetDimensionsFromUnitRect(const FX_RECT& rect,
87 int* left,
88 int* top,
89 int* width,
90 int* height) const;
91
92 UnownedPtr<CPDF_RenderStatus> const m_pRenderStatus;
93 UnownedPtr<CPDF_ImageObject> m_pImageObject;
94 RetainPtr<CPDF_Pattern> m_pPattern;
95 RetainPtr<CFX_DIBBase> m_pDIBBase;
96 CFX_Matrix m_mtObj2Device;
97 CFX_Matrix m_ImageMatrix;
98 std::unique_ptr<CPDF_ImageLoader> const m_pLoader;
99#if BUILDFLAG(IS_WIN)
101#endif
102 std::unique_ptr<CFX_AggImageRenderer> m_DeviceHandle;
103 Mode m_Mode = Mode::kNone;
104 float m_Alpha = 0.0f;
105 BlendMode m_BlendType = BlendMode::kNormal;
106 FX_ARGB m_FillArgb = 0;
107 FXDIB_ResampleOptions m_ResampleOptions;
108 bool m_bPatternColor = false;
109 bool m_bStdCS = false;
110 bool m_Result = true;
111};
112
113#endif // CORE_FPDFAPI_RENDER_CPDF_IMAGERENDERER_H_
#define DCHECK
Definition check.h:33
#define CHECK_EQ(x, y)
Definition check_op.h:10
bool Attach(RetainPtr< CFX_DIBitmap > pBitmap)
bool Create(int width, int height, FXDIB_Format format)
FX_RECT GetOuterRect() const
CFX_Matrix & operator=(const CFX_Matrix &other)=default
void Translate(int32_t x, int32_t y)
CFX_FloatRect GetUnitRect() const
void Transform(const CFX_Matrix &matrix)
Definition cfx_path.cpp:393
void AppendRect(float left, float bottom, float right, float top)
Definition cfx_path.cpp:310
bool IsPattern() const
std::map< ByteString, RetainPtr< CPDF_Object >, std::less<> > DictMap
static CPDF_DocPageData * FromDocument(const CPDF_Document *pDoc)
float GetStrokeAlpha() const
BlendMode GetBlendType() const
CPDF_ImageRenderer(CPDF_RenderStatus *pStatus)
bool Start(RetainPtr< CFX_DIBBase > pDIBBase, FX_ARGB bitmap_argb, const CFX_Matrix &mtImage2Device, const FXDIB_ResampleOptions &options, bool bStdCS)
bool Start(CPDF_ImageObject *pImageObject, const CFX_Matrix &mtObj2Device, bool bStdCS)
bool Continue(PauseIndicatorIface *pPause)
CPDF_Document * GetDocument() const override
Definition cpdf_page.cpp:51
const Options & GetOptions() const
bool CheckOCGDictVisible(const CPDF_Dictionary *pOC) const
bool ColorModeIs(Type mode) const
void SetOptions(const CPDF_RenderOptions &options)
void SetStdCS(bool bStdCS)
void Initialize(const CPDF_RenderStatus *pParentStatus, const CPDF_GraphicStates *pInitialStates)
uint32_t FX_ARGB
Definition fx_dib.h:36
BlendMode
Definition fx_dib.h:119
@ kNormal
Definition fx_dib.h:120
@ kDarken
Definition fx_dib.h:124
#define FXARGB_B(argb)
Definition fx_dib.h:199
#define FXARGB_G(argb)
Definition fx_dib.h:198
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)
Definition fx_dib.h:188
#define FXARGB_R(argb)
Definition fx_dib.h:197
FXDIB_Format
Definition fx_dib.h:21
pdfium::CheckedNumeric< int32_t > FX_SAFE_INT32
int FXSYS_roundf(float f)
#define CHECK(cvref)
int Height() const
int32_t bottom
bool Valid() const
int32_t right
int Width() const
int32_t top
int32_t left
bool IsEmpty() const