Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: core/fxge/include/fx_dib.h

Issue 2377393002: Move core/fxge/include to core/fxge (Closed)
Patch Set: Rebase to master Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxge/include/cfx_windowsdevice.h ('k') | core/fxge/include/fx_font.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 PDFium Authors. All rights reserved.
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_FXGE_INCLUDE_FX_DIB_H_
8 #define CORE_FXGE_INCLUDE_FX_DIB_H_
9
10 #include <memory>
11 #include <vector>
12
13 #include "core/fxcrt/cfx_count_ref.h"
14 #include "core/fxcrt/fx_basic.h"
15 #include "core/fxcrt/fx_coordinates.h"
16
17 enum FXDIB_Format {
18 FXDIB_Invalid = 0,
19 FXDIB_1bppMask = 0x101,
20 FXDIB_1bppRgb = 0x001,
21 FXDIB_1bppCmyk = 0x401,
22 FXDIB_8bppMask = 0x108,
23 FXDIB_8bppRgb = 0x008,
24 FXDIB_8bppRgba = 0x208,
25 FXDIB_8bppCmyk = 0x408,
26 FXDIB_8bppCmyka = 0x608,
27 FXDIB_Rgb = 0x018,
28 FXDIB_Rgba = 0x218,
29 FXDIB_Rgb32 = 0x020,
30 FXDIB_Argb = 0x220,
31 FXDIB_Cmyk = 0x420,
32 FXDIB_Cmyka = 0x620,
33 };
34
35 enum FXDIB_Channel {
36 FXDIB_Red = 1,
37 FXDIB_Green,
38 FXDIB_Blue,
39 FXDIB_Cyan,
40 FXDIB_Magenta,
41 FXDIB_Yellow,
42 FXDIB_Black,
43 FXDIB_Alpha
44 };
45
46 #define FXDIB_DOWNSAMPLE 0x04
47 #define FXDIB_INTERPOL 0x20
48 #define FXDIB_BICUBIC_INTERPOL 0x80
49 #define FXDIB_NOSMOOTH 0x100
50 #define FXDIB_BLEND_NORMAL 0
51 #define FXDIB_BLEND_MULTIPLY 1
52 #define FXDIB_BLEND_SCREEN 2
53 #define FXDIB_BLEND_OVERLAY 3
54 #define FXDIB_BLEND_DARKEN 4
55 #define FXDIB_BLEND_LIGHTEN 5
56
57 #define FXDIB_BLEND_COLORDODGE 6
58 #define FXDIB_BLEND_COLORBURN 7
59 #define FXDIB_BLEND_HARDLIGHT 8
60 #define FXDIB_BLEND_SOFTLIGHT 9
61 #define FXDIB_BLEND_DIFFERENCE 10
62 #define FXDIB_BLEND_EXCLUSION 11
63 #define FXDIB_BLEND_NONSEPARABLE 21
64 #define FXDIB_BLEND_HUE 21
65 #define FXDIB_BLEND_SATURATION 22
66 #define FXDIB_BLEND_COLOR 23
67 #define FXDIB_BLEND_LUMINOSITY 24
68 #define FXDIB_BLEND_UNSUPPORTED -1
69 typedef uint32_t FX_ARGB;
70 typedef uint32_t FX_COLORREF;
71 typedef uint32_t FX_CMYK;
72 class CFX_ClipRgn;
73 class CFX_DIBSource;
74 class CFX_DIBitmap;
75 class CStretchEngine;
76
77 #define FXSYS_RGB(r, g, b) ((r) | ((g) << 8) | ((b) << 16))
78 #define FXSYS_GetRValue(rgb) ((rgb)&0xff)
79 #define FXSYS_GetGValue(rgb) (((rgb) >> 8) & 0xff)
80 #define FXSYS_GetBValue(rgb) (((rgb) >> 16) & 0xff)
81 #define FX_CCOLOR(val) (255 - (val))
82 #define FXSYS_CMYK(c, m, y, k) (((c) << 24) | ((m) << 16) | ((y) << 8) | (k))
83 #define FXSYS_GetCValue(cmyk) ((uint8_t)((cmyk) >> 24) & 0xff)
84 #define FXSYS_GetMValue(cmyk) ((uint8_t)((cmyk) >> 16) & 0xff)
85 #define FXSYS_GetYValue(cmyk) ((uint8_t)((cmyk) >> 8) & 0xff)
86 #define FXSYS_GetKValue(cmyk) ((uint8_t)(cmyk)&0xff)
87 void CmykDecode(FX_CMYK cmyk, int& c, int& m, int& y, int& k);
88 inline FX_CMYK CmykEncode(int c, int m, int y, int k) {
89 return (c << 24) | (m << 16) | (y << 8) | k;
90 }
91 void ArgbDecode(FX_ARGB argb, int& a, int& r, int& g, int& b);
92 void ArgbDecode(FX_ARGB argb, int& a, FX_COLORREF& rgb);
93 inline FX_ARGB ArgbEncode(int a, int r, int g, int b) {
94 return (a << 24) | (r << 16) | (g << 8) | b;
95 }
96 FX_ARGB ArgbEncode(int a, FX_COLORREF rgb);
97 #define FXARGB_A(argb) ((uint8_t)((argb) >> 24))
98 #define FXARGB_R(argb) ((uint8_t)((argb) >> 16))
99 #define FXARGB_G(argb) ((uint8_t)((argb) >> 8))
100 #define FXARGB_B(argb) ((uint8_t)(argb))
101 #define FXARGB_MAKE(a, r, g, b) \
102 (((uint32_t)(a) << 24) | ((r) << 16) | ((g) << 8) | (b))
103 #define FXARGB_MUL_ALPHA(argb, alpha) \
104 (((((argb) >> 24) * (alpha) / 255) << 24) | ((argb)&0xffffff))
105 #define FXRGB2GRAY(r, g, b) (((b)*11 + (g)*59 + (r)*30) / 100)
106 #define FXCMYK2GRAY(c, m, y, k) \
107 (((255 - (c)) * (255 - (k)) * 30 + (255 - (m)) * (255 - (k)) * 59 + \
108 (255 - (y)) * (255 - (k)) * 11) / \
109 25500)
110 #define FXDIB_ALPHA_MERGE(backdrop, source, source_alpha) \
111 (((backdrop) * (255 - (source_alpha)) + (source) * (source_alpha)) / 255)
112 #define FXDIB_ALPHA_UNION(dest, src) ((dest) + (src) - (dest) * (src) / 255)
113 #define FXCMYK_GETDIB(p) \
114 ((((uint8_t*)(p))[0] << 24 | (((uint8_t*)(p))[1] << 16) | \
115 (((uint8_t*)(p))[2] << 8) | ((uint8_t*)(p))[3]))
116 #define FXCMYK_SETDIB(p, cmyk) ((uint8_t*)(p))[0] = (uint8_t)((cmyk) >> 24), \
117 ((uint8_t*)(p))[1] = (uint8_t)((cmyk) >> 16), \
118 ((uint8_t*)(p))[2] = (uint8_t)((cmyk) >> 8), \
119 ((uint8_t*)(p))[3] = (uint8_t)(cmyk))
120 #define FXARGB_GETDIB(p) \
121 ((((uint8_t*)(p))[0]) | (((uint8_t*)(p))[1] << 8) | \
122 (((uint8_t*)(p))[2] << 16) | (((uint8_t*)(p))[3] << 24))
123 #define FXARGB_SETDIB(p, argb) \
124 ((uint8_t*)(p))[0] = (uint8_t)(argb), \
125 ((uint8_t*)(p))[1] = (uint8_t)((argb) >> 8), \
126 ((uint8_t*)(p))[2] = (uint8_t)((argb) >> 16), \
127 ((uint8_t*)(p))[3] = (uint8_t)((argb) >> 24)
128 #define FXARGB_COPY(dest, src) \
129 *(uint8_t*)(dest) = *(uint8_t*)(src), \
130 *((uint8_t*)(dest) + 1) = *((uint8_t*)(src) + 1), \
131 *((uint8_t*)(dest) + 2) = *((uint8_t*)(src) + 2), \
132 *((uint8_t*)(dest) + 3) = *((uint8_t*)(src) + 3)
133 #define FXCMYK_COPY(dest, src) \
134 *(uint8_t*)(dest) = *(uint8_t*)(src), \
135 *((uint8_t*)(dest) + 1) = *((uint8_t*)(src) + 1), \
136 *((uint8_t*)(dest) + 2) = *((uint8_t*)(src) + 2), \
137 *((uint8_t*)(dest) + 3) = *((uint8_t*)(src) + 3)
138 #define FXARGB_SETRGBORDERDIB(p, argb) \
139 ((uint8_t*)(p))[3] = (uint8_t)(argb >> 24), \
140 ((uint8_t*)(p))[0] = (uint8_t)((argb) >> 16), \
141 ((uint8_t*)(p))[1] = (uint8_t)((argb) >> 8), \
142 ((uint8_t*)(p))[2] = (uint8_t)(argb)
143 #define FXARGB_GETRGBORDERDIB(p) \
144 (((uint8_t*)(p))[2]) | (((uint8_t*)(p))[1] << 8) | \
145 (((uint8_t*)(p))[0] << 16) | (((uint8_t*)(p))[3] << 24)
146 #define FXARGB_RGBORDERCOPY(dest, src) \
147 *((uint8_t*)(dest) + 3) = *((uint8_t*)(src) + 3), \
148 *(uint8_t*)(dest) = *((uint8_t*)(src) + 2), \
149 *((uint8_t*)(dest) + 1) = *((uint8_t*)(src) + 1), \
150 *((uint8_t*)(dest) + 2) = *((uint8_t*)(src))
151 #define FXARGB_TODIB(argb) (argb)
152 #define FXCMYK_TODIB(cmyk) \
153 ((uint8_t)((cmyk) >> 24) | ((uint8_t)((cmyk) >> 16)) << 8 | \
154 ((uint8_t)((cmyk) >> 8)) << 16 | ((uint8_t)(cmyk) << 24))
155 #define FXARGB_TOBGRORDERDIB(argb) \
156 ((uint8_t)(argb >> 16) | ((uint8_t)(argb >> 8)) << 8 | \
157 ((uint8_t)(argb)) << 16 | ((uint8_t)(argb >> 24) << 24))
158 #define FXGETFLAG_COLORTYPE(flag) (uint8_t)((flag) >> 8)
159 #define FXGETFLAG_ALPHA_FILL(flag) (uint8_t)(flag)
160
161 FX_BOOL ConvertBuffer(FXDIB_Format dest_format,
162 uint8_t* dest_buf,
163 int dest_pitch,
164 int width,
165 int height,
166 const CFX_DIBSource* pSrcBitmap,
167 int src_left,
168 int src_top,
169 std::unique_ptr<uint32_t, FxFreeDeleter>* pal);
170
171 class CFX_DIBSource {
172 public:
173 virtual ~CFX_DIBSource();
174
175 virtual uint8_t* GetBuffer() const;
176 virtual const uint8_t* GetScanline(int line) const = 0;
177 virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const;
178 virtual void DownSampleScanline(int line,
179 uint8_t* dest_scan,
180 int dest_bpp,
181 int dest_width,
182 FX_BOOL bFlipX,
183 int clip_left,
184 int clip_width) const = 0;
185
186 int GetWidth() const { return m_Width; }
187 int GetHeight() const { return m_Height; }
188
189 FXDIB_Format GetFormat() const {
190 return (FXDIB_Format)(m_AlphaFlag * 0x100 + m_bpp);
191 }
192 uint32_t GetPitch() const { return m_Pitch; }
193 uint32_t* GetPalette() const { return m_pPalette.get(); }
194 int GetBPP() const { return m_bpp; }
195
196 // TODO(thestig): Investigate this. Given the possible values of FXDIB_Format,
197 // it feels as though this should be implemented as !!(m_AlphaFlag & 1) and
198 // IsOpaqueImage() below should never be able to return TRUE.
199 bool IsAlphaMask() const { return m_AlphaFlag == 1; }
200 bool HasAlpha() const { return !!(m_AlphaFlag & 2); }
201 bool IsOpaqueImage() const { return !(m_AlphaFlag & 3); }
202 bool IsCmykImage() const { return !!(m_AlphaFlag & 4); }
203
204 int GetPaletteSize() const {
205 return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0));
206 }
207
208 uint32_t GetPaletteEntry(int index) const;
209
210 void SetPaletteEntry(int index, uint32_t color);
211 uint32_t GetPaletteArgb(int index) const { return GetPaletteEntry(index); }
212 void SetPaletteArgb(int index, uint32_t color) {
213 SetPaletteEntry(index, color);
214 }
215
216 void CopyPalette(const uint32_t* pSrcPal);
217
218 CFX_DIBitmap* Clone(const FX_RECT* pClip = nullptr) const;
219 CFX_DIBitmap* CloneConvert(FXDIB_Format format) const;
220
221 CFX_DIBitmap* StretchTo(int dest_width,
222 int dest_height,
223 uint32_t flags = 0,
224 const FX_RECT* pClip = nullptr) const;
225 CFX_DIBitmap* TransformTo(const CFX_Matrix* pMatrix,
226 int& left,
227 int& top,
228 uint32_t flags = 0,
229 const FX_RECT* pClip = nullptr) const;
230
231 CFX_DIBitmap* GetAlphaMask(const FX_RECT* pClip = nullptr) const;
232 FX_BOOL CopyAlphaMask(const CFX_DIBSource* pAlphaMask,
233 const FX_RECT* pClip = nullptr);
234
235 CFX_DIBitmap* SwapXY(FX_BOOL bXFlip,
236 FX_BOOL bYFlip,
237 const FX_RECT* pClip = nullptr) const;
238
239 CFX_DIBitmap* FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const;
240
241 void GetOverlapRect(int& dest_left,
242 int& dest_top,
243 int& width,
244 int& height,
245 int src_width,
246 int src_height,
247 int& src_left,
248 int& src_top,
249 const CFX_ClipRgn* pClipRgn);
250
251 #if defined _SKIA_SUPPORT_
252 void DebugVerifyBitmapIsPreMultiplied(void* buffer = nullptr) const;
253 #endif
254
255 CFX_DIBitmap* m_pAlphaMask;
256
257 protected:
258 CFX_DIBSource();
259
260 void BuildPalette();
261 FX_BOOL BuildAlphaMask();
262 int FindPalette(uint32_t color) const;
263 void GetPalette(uint32_t* pal, int alpha) const;
264
265 int m_Width;
266 int m_Height;
267 int m_bpp;
268 uint32_t m_AlphaFlag;
269 uint32_t m_Pitch;
270 // TODO(weili): Use std::vector for this.
271 std::unique_ptr<uint32_t, FxFreeDeleter> m_pPalette;
272 };
273
274 class CFX_DIBitmap : public CFX_DIBSource {
275 public:
276 CFX_DIBitmap();
277 explicit CFX_DIBitmap(const CFX_DIBitmap& src);
278 ~CFX_DIBitmap() override;
279
280 FX_BOOL Create(int width,
281 int height,
282 FXDIB_Format format,
283 uint8_t* pBuffer = nullptr,
284 int pitch = 0);
285
286 FX_BOOL Copy(const CFX_DIBSource* pSrc);
287
288 // CFX_DIBSource
289 uint8_t* GetBuffer() const override;
290 const uint8_t* GetScanline(int line) const override;
291 void DownSampleScanline(int line,
292 uint8_t* dest_scan,
293 int dest_bpp,
294 int dest_width,
295 FX_BOOL bFlipX,
296 int clip_left,
297 int clip_width) const override;
298
299 void TakeOver(CFX_DIBitmap* pSrcBitmap);
300
301 FX_BOOL ConvertFormat(FXDIB_Format format);
302
303 void Clear(uint32_t color);
304
305 uint32_t GetPixel(int x, int y) const;
306
307 void SetPixel(int x, int y, uint32_t color);
308
309 FX_BOOL LoadChannel(FXDIB_Channel destChannel,
310 const CFX_DIBSource* pSrcBitmap,
311 FXDIB_Channel srcChannel);
312
313 FX_BOOL LoadChannel(FXDIB_Channel destChannel, int value);
314
315 FX_BOOL MultiplyAlpha(int alpha);
316
317 FX_BOOL MultiplyAlpha(const CFX_DIBSource* pAlphaMask);
318
319 FX_BOOL TransferBitmap(int dest_left,
320 int dest_top,
321 int width,
322 int height,
323 const CFX_DIBSource* pSrcBitmap,
324 int src_left,
325 int src_top);
326
327 FX_BOOL CompositeBitmap(int dest_left,
328 int dest_top,
329 int width,
330 int height,
331 const CFX_DIBSource* pSrcBitmap,
332 int src_left,
333 int src_top,
334 int blend_type = FXDIB_BLEND_NORMAL,
335 const CFX_ClipRgn* pClipRgn = nullptr,
336 FX_BOOL bRgbByteOrder = FALSE,
337 void* pIccTransform = nullptr);
338
339 FX_BOOL TransferMask(int dest_left,
340 int dest_top,
341 int width,
342 int height,
343 const CFX_DIBSource* pMask,
344 uint32_t color,
345 int src_left,
346 int src_top,
347 int alpha_flag = 0,
348 void* pIccTransform = nullptr);
349
350 FX_BOOL CompositeMask(int dest_left,
351 int dest_top,
352 int width,
353 int height,
354 const CFX_DIBSource* pMask,
355 uint32_t color,
356 int src_left,
357 int src_top,
358 int blend_type = FXDIB_BLEND_NORMAL,
359 const CFX_ClipRgn* pClipRgn = nullptr,
360 FX_BOOL bRgbByteOrder = FALSE,
361 int alpha_flag = 0,
362 void* pIccTransform = nullptr);
363
364 FX_BOOL CompositeRect(int dest_left,
365 int dest_top,
366 int width,
367 int height,
368 uint32_t color,
369 int alpha_flag = 0,
370 void* pIccTransform = nullptr);
371
372 FX_BOOL ConvertColorScale(uint32_t forecolor, uint32_t backcolor);
373
374 protected:
375 FX_BOOL GetGrayData(void* pIccTransform = nullptr);
376
377 uint8_t* m_pBuffer;
378 FX_BOOL m_bExtBuf;
379 };
380
381 class CFX_DIBExtractor {
382 public:
383 explicit CFX_DIBExtractor(const CFX_DIBSource* pSrc);
384 ~CFX_DIBExtractor();
385
386 CFX_DIBitmap* GetBitmap() { return m_pBitmap.get(); }
387
388 private:
389 std::unique_ptr<CFX_DIBitmap> m_pBitmap;
390 };
391
392 typedef CFX_CountRef<CFX_DIBitmap> CFX_DIBitmapRef;
393
394 class CFX_FilteredDIB : public CFX_DIBSource {
395 public:
396 CFX_FilteredDIB();
397 ~CFX_FilteredDIB() override;
398
399 void LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc = FALSE);
400
401 virtual FXDIB_Format GetDestFormat() = 0;
402
403 virtual uint32_t* GetDestPalette() = 0;
404
405 virtual void TranslateScanline(const uint8_t* src_buf,
406 std::vector<uint8_t>* dest_buf) const = 0;
407
408 virtual void TranslateDownSamples(uint8_t* dest_buf,
409 const uint8_t* src_buf,
410 int pixels,
411 int Bpp) const = 0;
412
413 protected:
414 // CFX_DIBSource
415 const uint8_t* GetScanline(int line) const override;
416 void DownSampleScanline(int line,
417 uint8_t* dest_scan,
418 int dest_bpp,
419 int dest_width,
420 FX_BOOL bFlipX,
421 int clip_left,
422 int clip_width) const override;
423
424 const CFX_DIBSource* m_pSrc;
425 FX_BOOL m_bAutoDropSrc;
426 mutable std::vector<uint8_t> m_Scanline;
427 };
428
429 class IFX_ScanlineComposer {
430 public:
431 virtual ~IFX_ScanlineComposer() {}
432
433 virtual void ComposeScanline(int line,
434 const uint8_t* scanline,
435 const uint8_t* scan_extra_alpha = nullptr) = 0;
436
437 virtual FX_BOOL SetInfo(int width,
438 int height,
439 FXDIB_Format src_format,
440 uint32_t* pSrcPalette) = 0;
441 };
442
443 class CFX_ScanlineCompositor {
444 public:
445 CFX_ScanlineCompositor();
446
447 ~CFX_ScanlineCompositor();
448
449 FX_BOOL Init(FXDIB_Format dest_format,
450 FXDIB_Format src_format,
451 int32_t width,
452 uint32_t* pSrcPalette,
453 uint32_t mask_color,
454 int blend_type,
455 FX_BOOL bClip,
456 FX_BOOL bRgbByteOrder = FALSE,
457 int alpha_flag = 0,
458 void* pIccTransform = nullptr);
459
460 void CompositeRgbBitmapLine(uint8_t* dest_scan,
461 const uint8_t* src_scan,
462 int width,
463 const uint8_t* clip_scan,
464 const uint8_t* src_extra_alpha = nullptr,
465 uint8_t* dst_extra_alpha = nullptr);
466
467 void CompositePalBitmapLine(uint8_t* dest_scan,
468 const uint8_t* src_scan,
469 int src_left,
470 int width,
471 const uint8_t* clip_scan,
472 const uint8_t* src_extra_alpha = nullptr,
473 uint8_t* dst_extra_alpha = nullptr);
474
475 void CompositeByteMaskLine(uint8_t* dest_scan,
476 const uint8_t* src_scan,
477 int width,
478 const uint8_t* clip_scan,
479 uint8_t* dst_extra_alpha = nullptr);
480
481 void CompositeBitMaskLine(uint8_t* dest_scan,
482 const uint8_t* src_scan,
483 int src_left,
484 int width,
485 const uint8_t* clip_scan,
486 uint8_t* dst_extra_alpha = nullptr);
487
488 protected:
489 int m_Transparency;
490 FXDIB_Format m_SrcFormat, m_DestFormat;
491 uint32_t* m_pSrcPalette;
492
493 int m_MaskAlpha, m_MaskRed, m_MaskGreen, m_MaskBlue, m_MaskBlack;
494 int m_BlendType;
495 void* m_pIccTransform;
496 uint8_t* m_pCacheScanline;
497 int m_CacheSize;
498 FX_BOOL m_bRgbByteOrder;
499 };
500
501 class CFX_BitmapComposer : public IFX_ScanlineComposer {
502 public:
503 CFX_BitmapComposer();
504 ~CFX_BitmapComposer() override;
505
506 void Compose(CFX_DIBitmap* pDest,
507 const CFX_ClipRgn* pClipRgn,
508 int bitmap_alpha,
509 uint32_t mask_color,
510 FX_RECT& dest_rect,
511 FX_BOOL bVertical,
512 FX_BOOL bFlipX,
513 FX_BOOL bFlipY,
514 FX_BOOL bRgbByteOrder = FALSE,
515 int alpha_flag = 0,
516 void* pIccTransform = nullptr,
517 int blend_type = FXDIB_BLEND_NORMAL);
518
519 // IFX_ScanlineComposer
520 FX_BOOL SetInfo(int width,
521 int height,
522 FXDIB_Format src_format,
523 uint32_t* pSrcPalette) override;
524
525 void ComposeScanline(int line,
526 const uint8_t* scanline,
527 const uint8_t* scan_extra_alpha) override;
528
529 protected:
530 void DoCompose(uint8_t* dest_scan,
531 const uint8_t* src_scan,
532 int dest_width,
533 const uint8_t* clip_scan,
534 const uint8_t* src_extra_alpha = nullptr,
535 uint8_t* dst_extra_alpha = nullptr);
536 CFX_DIBitmap* m_pBitmap;
537 const CFX_ClipRgn* m_pClipRgn;
538 FXDIB_Format m_SrcFormat;
539 int m_DestLeft, m_DestTop, m_DestWidth, m_DestHeight, m_BitmapAlpha;
540 uint32_t m_MaskColor;
541 const CFX_DIBitmap* m_pClipMask;
542 CFX_ScanlineCompositor m_Compositor;
543 FX_BOOL m_bVertical, m_bFlipX, m_bFlipY;
544 int m_AlphaFlag;
545 void* m_pIccTransform;
546 FX_BOOL m_bRgbByteOrder;
547 int m_BlendType;
548 void ComposeScanlineV(int line,
549 const uint8_t* scanline,
550 const uint8_t* scan_extra_alpha = nullptr);
551 uint8_t* m_pScanlineV;
552 uint8_t* m_pClipScanV;
553 uint8_t* m_pAddClipScan;
554 uint8_t* m_pScanlineAlphaV;
555 };
556
557 class CFX_BitmapStorer : public IFX_ScanlineComposer {
558 public:
559 CFX_BitmapStorer();
560 ~CFX_BitmapStorer() override;
561
562 // IFX_ScanlineComposer
563 void ComposeScanline(int line,
564 const uint8_t* scanline,
565 const uint8_t* scan_extra_alpha) override;
566 FX_BOOL SetInfo(int width,
567 int height,
568 FXDIB_Format src_format,
569 uint32_t* pSrcPalette) override;
570
571 CFX_DIBitmap* GetBitmap() { return m_pBitmap.get(); }
572 std::unique_ptr<CFX_DIBitmap> Detach();
573 void Replace(std::unique_ptr<CFX_DIBitmap> pBitmap);
574
575 private:
576 std::unique_ptr<CFX_DIBitmap> m_pBitmap;
577 };
578
579 class CFX_ImageStretcher {
580 public:
581 CFX_ImageStretcher(IFX_ScanlineComposer* pDest,
582 const CFX_DIBSource* pSource,
583 int dest_width,
584 int dest_height,
585 const FX_RECT& bitmap_rect,
586 uint32_t flags);
587 ~CFX_ImageStretcher();
588
589 FX_BOOL Start();
590 FX_BOOL Continue(IFX_Pause* pPause);
591
592 const CFX_DIBSource* source() { return m_pSource; }
593
594 private:
595 FX_BOOL StartQuickStretch();
596 FX_BOOL StartStretch();
597 FX_BOOL ContinueQuickStretch(IFX_Pause* pPause);
598 FX_BOOL ContinueStretch(IFX_Pause* pPause);
599
600 IFX_ScanlineComposer* const m_pDest;
601 const CFX_DIBSource* const m_pSource;
602 std::unique_ptr<CStretchEngine> m_pStretchEngine;
603 std::unique_ptr<uint8_t, FxFreeDeleter> m_pScanline;
604 std::unique_ptr<uint8_t, FxFreeDeleter> m_pMaskScanline;
605 const uint32_t m_Flags;
606 FX_BOOL m_bFlipX;
607 FX_BOOL m_bFlipY;
608 int m_DestWidth;
609 int m_DestHeight;
610 FX_RECT m_ClipRect;
611 const FXDIB_Format m_DestFormat;
612 const int m_DestBPP;
613 int m_LineIndex;
614 };
615
616 class CFX_ImageTransformer {
617 public:
618 CFX_ImageTransformer(const CFX_DIBSource* pSrc,
619 const CFX_Matrix* pMatrix,
620 int flags,
621 const FX_RECT* pClip);
622 ~CFX_ImageTransformer();
623
624 FX_BOOL Start();
625 FX_BOOL Continue(IFX_Pause* pPause);
626
627 const FX_RECT& result() const { return m_result; }
628 std::unique_ptr<CFX_DIBitmap> DetachBitmap();
629
630 private:
631 const CFX_DIBSource* const m_pSrc;
632 const CFX_Matrix* const m_pMatrix;
633 const FX_RECT* const m_pClip;
634 FX_RECT m_StretchClip;
635 FX_RECT m_result;
636 CFX_Matrix m_dest2stretch;
637 std::unique_ptr<CFX_ImageStretcher> m_Stretcher;
638 CFX_BitmapStorer m_Storer;
639 const uint32_t m_Flags;
640 int m_Status;
641 };
642
643 class CFX_ImageRenderer {
644 public:
645 CFX_ImageRenderer();
646 ~CFX_ImageRenderer();
647
648 FX_BOOL Start(CFX_DIBitmap* pDevice,
649 const CFX_ClipRgn* pClipRgn,
650 const CFX_DIBSource* pSource,
651 int bitmap_alpha,
652 uint32_t mask_color,
653 const CFX_Matrix* pMatrix,
654 uint32_t dib_flags,
655 FX_BOOL bRgbByteOrder = FALSE,
656 int alpha_flag = 0,
657 void* pIccTransform = nullptr,
658 int blend_type = FXDIB_BLEND_NORMAL);
659
660 FX_BOOL Continue(IFX_Pause* pPause);
661
662 protected:
663 CFX_DIBitmap* m_pDevice;
664 const CFX_ClipRgn* m_pClipRgn;
665 int m_BitmapAlpha;
666 uint32_t m_MaskColor;
667 CFX_Matrix m_Matrix;
668 std::unique_ptr<CFX_ImageTransformer> m_pTransformer;
669 std::unique_ptr<CFX_ImageStretcher> m_Stretcher;
670 CFX_BitmapComposer m_Composer;
671 int m_Status;
672 FX_RECT m_ClipBox;
673 uint32_t m_Flags;
674 int m_AlphaFlag;
675 void* m_pIccTransform;
676 FX_BOOL m_bRgbByteOrder;
677 int m_BlendType;
678 };
679
680 #endif // CORE_FXGE_INCLUDE_FX_DIB_H_
OLDNEW
« no previous file with comments | « core/fxge/include/cfx_windowsdevice.h ('k') | core/fxge/include/fx_font.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698