1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
// Copyright 2017 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
#ifndef CORE_FXGE_DIB_CFX_DIBITMAP_H_
#define CORE_FXGE_DIB_CFX_DIBITMAP_H_
#include "core/fxcrt/fx_coordinates.h"
#include "core/fxcrt/maybe_owned.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/dib/cfx_dibbase.h"
#include "third_party/base/stl_util.h"
class CFX_DIBitmap : public CFX_DIBBase {
public:
template <typename T, typename... Args>
friend RetainPtr<T> pdfium::MakeRetain(Args&&... args);
bool Create(int width, int height, FXDIB_Format format);
bool Create(int width,
int height,
FXDIB_Format format,
uint8_t* pBuffer,
uint32_t pitch);
bool Copy(const RetainPtr<CFX_DIBBase>& pSrc);
// CFX_DIBBase
uint8_t* GetBuffer() const override;
const uint8_t* GetScanline(int line) const override;
void DownSampleScanline(int line,
uint8_t* dest_scan,
int dest_bpp,
int dest_width,
bool bFlipX,
int clip_left,
int clip_width) const override;
void TakeOver(RetainPtr<CFX_DIBitmap>&& pSrcBitmap);
bool ConvertFormat(FXDIB_Format format);
void Clear(uint32_t color);
uint32_t GetPixel(int x, int y) const;
void SetPixel(int x, int y, uint32_t color);
bool LoadChannel(FXDIB_Channel destChannel,
const RetainPtr<CFX_DIBBase>& pSrcBitmap,
FXDIB_Channel srcChannel);
bool LoadChannel(FXDIB_Channel destChannel, int value);
bool MultiplyAlpha(int alpha);
bool MultiplyAlpha(const RetainPtr<CFX_DIBBase>& pAlphaMask);
bool TransferBitmap(int dest_left,
int dest_top,
int width,
int height,
const RetainPtr<CFX_DIBBase>& pSrcBitmap,
int src_left,
int src_top);
bool CompositeBitmap(int dest_left,
int dest_top,
int width,
int height,
const RetainPtr<CFX_DIBBase>& pSrcBitmap,
int src_left,
int src_top,
int blend_type,
const CFX_ClipRgn* pClipRgn,
bool bRgbByteOrder);
bool CompositeMask(int dest_left,
int dest_top,
int width,
int height,
const RetainPtr<CFX_DIBBase>& pMask,
uint32_t color,
int src_left,
int src_top,
int blend_type,
const CFX_ClipRgn* pClipRgn,
bool bRgbByteOrder,
int alpha_flag);
bool CompositeRect(int dest_left,
int dest_top,
int width,
int height,
uint32_t color,
int alpha_flag);
bool ConvertColorScale(uint32_t forecolor, uint32_t backcolor);
static bool CalculatePitchAndSize(int height,
int width,
FXDIB_Format format,
uint32_t* pitch,
uint32_t* size);
#if defined _SKIA_SUPPORT_ || _SKIA_SUPPORT_PATHS_
void PreMultiply();
#endif
#if defined _SKIA_SUPPORT_PATHS_
void UnPreMultiply();
#endif
protected:
CFX_DIBitmap();
CFX_DIBitmap(const CFX_DIBitmap& src);
~CFX_DIBitmap() override;
#if defined _SKIA_SUPPORT_PATHS_
enum class Format { kCleared, kPreMultiplied, kUnPreMultiplied };
#endif
MaybeOwned<uint8_t, FxFreeDeleter> m_pBuffer;
#if defined _SKIA_SUPPORT_PATHS_
Format m_nFormat;
#endif
private:
void ConvertBGRColorScale(uint32_t forecolor, uint32_t backcolor);
void ConvertCMYKColorScale(uint32_t forecolor, uint32_t backcolor);
bool TransferWithUnequalFormats(FXDIB_Format dest_format,
int dest_left,
int dest_top,
int width,
int height,
const RetainPtr<CFX_DIBBase>& pSrcBitmap,
int src_left,
int src_top);
void TransferWithMultipleBPP(int dest_left,
int dest_top,
int width,
int height,
const RetainPtr<CFX_DIBBase>& pSrcBitmap,
int src_left,
int src_top);
void TransferEqualFormatsOneBPP(int dest_left,
int dest_top,
int width,
int height,
const RetainPtr<CFX_DIBBase>& pSrcBitmap,
int src_left,
int src_top);
};
#endif // CORE_FXGE_DIB_CFX_DIBITMAP_H_
|