OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #ifndef CORE_FXGE_FX_DIB_H_ | 7 #ifndef CORE_FXGE_FX_DIB_H_ |
8 #define CORE_FXGE_FX_DIB_H_ | 8 #define CORE_FXGE_FX_DIB_H_ |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 #define FXARGB_TODIB(argb) (argb) | 151 #define FXARGB_TODIB(argb) (argb) |
152 #define FXCMYK_TODIB(cmyk) \ | 152 #define FXCMYK_TODIB(cmyk) \ |
153 ((uint8_t)((cmyk) >> 24) | ((uint8_t)((cmyk) >> 16)) << 8 | \ | 153 ((uint8_t)((cmyk) >> 24) | ((uint8_t)((cmyk) >> 16)) << 8 | \ |
154 ((uint8_t)((cmyk) >> 8)) << 16 | ((uint8_t)(cmyk) << 24)) | 154 ((uint8_t)((cmyk) >> 8)) << 16 | ((uint8_t)(cmyk) << 24)) |
155 #define FXARGB_TOBGRORDERDIB(argb) \ | 155 #define FXARGB_TOBGRORDERDIB(argb) \ |
156 ((uint8_t)(argb >> 16) | ((uint8_t)(argb >> 8)) << 8 | \ | 156 ((uint8_t)(argb >> 16) | ((uint8_t)(argb >> 8)) << 8 | \ |
157 ((uint8_t)(argb)) << 16 | ((uint8_t)(argb >> 24) << 24)) | 157 ((uint8_t)(argb)) << 16 | ((uint8_t)(argb >> 24) << 24)) |
158 #define FXGETFLAG_COLORTYPE(flag) (uint8_t)((flag) >> 8) | 158 #define FXGETFLAG_COLORTYPE(flag) (uint8_t)((flag) >> 8) |
159 #define FXGETFLAG_ALPHA_FILL(flag) (uint8_t)(flag) | 159 #define FXGETFLAG_ALPHA_FILL(flag) (uint8_t)(flag) |
160 | 160 |
161 FX_BOOL ConvertBuffer(FXDIB_Format dest_format, | 161 bool ConvertBuffer(FXDIB_Format dest_format, |
162 uint8_t* dest_buf, | 162 uint8_t* dest_buf, |
163 int dest_pitch, | 163 int dest_pitch, |
164 int width, | 164 int width, |
165 int height, | 165 int height, |
166 const CFX_DIBSource* pSrcBitmap, | 166 const CFX_DIBSource* pSrcBitmap, |
167 int src_left, | 167 int src_left, |
168 int src_top, | 168 int src_top, |
169 std::unique_ptr<uint32_t, FxFreeDeleter>* pal); | 169 std::unique_ptr<uint32_t, FxFreeDeleter>* pal); |
170 | 170 |
171 class CFX_DIBSource { | 171 class CFX_DIBSource { |
172 public: | 172 public: |
173 virtual ~CFX_DIBSource(); | 173 virtual ~CFX_DIBSource(); |
174 | 174 |
175 virtual uint8_t* GetBuffer() const; | 175 virtual uint8_t* GetBuffer() const; |
176 virtual const uint8_t* GetScanline(int line) const = 0; | 176 virtual const uint8_t* GetScanline(int line) const = 0; |
177 virtual FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) const; | 177 virtual bool SkipToScanline(int line, IFX_Pause* pPause) const; |
178 virtual void DownSampleScanline(int line, | 178 virtual void DownSampleScanline(int line, |
179 uint8_t* dest_scan, | 179 uint8_t* dest_scan, |
180 int dest_bpp, | 180 int dest_bpp, |
181 int dest_width, | 181 int dest_width, |
182 FX_BOOL bFlipX, | 182 bool bFlipX, |
183 int clip_left, | 183 int clip_left, |
184 int clip_width) const = 0; | 184 int clip_width) const = 0; |
185 | 185 |
186 int GetWidth() const { return m_Width; } | 186 int GetWidth() const { return m_Width; } |
187 int GetHeight() const { return m_Height; } | 187 int GetHeight() const { return m_Height; } |
188 | 188 |
189 FXDIB_Format GetFormat() const { | 189 FXDIB_Format GetFormat() const { |
190 return (FXDIB_Format)(m_AlphaFlag * 0x100 + m_bpp); | 190 return (FXDIB_Format)(m_AlphaFlag * 0x100 + m_bpp); |
191 } | 191 } |
192 uint32_t GetPitch() const { return m_Pitch; } | 192 uint32_t GetPitch() const { return m_Pitch; } |
193 uint32_t* GetPalette() const { return m_pPalette.get(); } | 193 uint32_t* GetPalette() const { return m_pPalette.get(); } |
194 int GetBPP() const { return m_bpp; } | 194 int GetBPP() const { return m_bpp; } |
195 | 195 |
196 // TODO(thestig): Investigate this. Given the possible values of FXDIB_Format, | 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 | 197 // it feels as though this should be implemented as !!(m_AlphaFlag & 1) and |
198 // IsOpaqueImage() below should never be able to return TRUE. | 198 // IsOpaqueImage() below should never be able to return true. |
199 bool IsAlphaMask() const { return m_AlphaFlag == 1; } | 199 bool IsAlphaMask() const { return m_AlphaFlag == 1; } |
200 bool HasAlpha() const { return !!(m_AlphaFlag & 2); } | 200 bool HasAlpha() const { return !!(m_AlphaFlag & 2); } |
201 bool IsOpaqueImage() const { return !(m_AlphaFlag & 3); } | 201 bool IsOpaqueImage() const { return !(m_AlphaFlag & 3); } |
202 bool IsCmykImage() const { return !!(m_AlphaFlag & 4); } | 202 bool IsCmykImage() const { return !!(m_AlphaFlag & 4); } |
203 | 203 |
204 int GetPaletteSize() const { | 204 int GetPaletteSize() const { |
205 return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0)); | 205 return IsAlphaMask() ? 0 : (m_bpp == 1 ? 2 : (m_bpp == 8 ? 256 : 0)); |
206 } | 206 } |
207 | 207 |
208 uint32_t GetPaletteEntry(int index) const; | 208 uint32_t GetPaletteEntry(int index) const; |
(...skipping 13 matching lines...) Expand all Loading... |
222 int dest_height, | 222 int dest_height, |
223 uint32_t flags = 0, | 223 uint32_t flags = 0, |
224 const FX_RECT* pClip = nullptr) const; | 224 const FX_RECT* pClip = nullptr) const; |
225 CFX_DIBitmap* TransformTo(const CFX_Matrix* pMatrix, | 225 CFX_DIBitmap* TransformTo(const CFX_Matrix* pMatrix, |
226 int& left, | 226 int& left, |
227 int& top, | 227 int& top, |
228 uint32_t flags = 0, | 228 uint32_t flags = 0, |
229 const FX_RECT* pClip = nullptr) const; | 229 const FX_RECT* pClip = nullptr) const; |
230 | 230 |
231 CFX_DIBitmap* GetAlphaMask(const FX_RECT* pClip = nullptr) const; | 231 CFX_DIBitmap* GetAlphaMask(const FX_RECT* pClip = nullptr) const; |
232 FX_BOOL CopyAlphaMask(const CFX_DIBSource* pAlphaMask, | 232 bool CopyAlphaMask(const CFX_DIBSource* pAlphaMask, |
233 const FX_RECT* pClip = nullptr); | 233 const FX_RECT* pClip = nullptr); |
234 | 234 |
235 CFX_DIBitmap* SwapXY(FX_BOOL bXFlip, | 235 CFX_DIBitmap* SwapXY(bool bXFlip, |
236 FX_BOOL bYFlip, | 236 bool bYFlip, |
237 const FX_RECT* pClip = nullptr) const; | 237 const FX_RECT* pClip = nullptr) const; |
238 | 238 |
239 CFX_DIBitmap* FlipImage(FX_BOOL bXFlip, FX_BOOL bYFlip) const; | 239 CFX_DIBitmap* FlipImage(bool bXFlip, bool bYFlip) const; |
240 | 240 |
241 void GetOverlapRect(int& dest_left, | 241 void GetOverlapRect(int& dest_left, |
242 int& dest_top, | 242 int& dest_top, |
243 int& width, | 243 int& width, |
244 int& height, | 244 int& height, |
245 int src_width, | 245 int src_width, |
246 int src_height, | 246 int src_height, |
247 int& src_left, | 247 int& src_left, |
248 int& src_top, | 248 int& src_top, |
249 const CFX_ClipRgn* pClipRgn); | 249 const CFX_ClipRgn* pClipRgn); |
250 | 250 |
251 #if defined _SKIA_SUPPORT_ | 251 #if defined _SKIA_SUPPORT_ |
252 void DebugVerifyBitmapIsPreMultiplied(void* buffer = nullptr) const; | 252 void DebugVerifyBitmapIsPreMultiplied(void* buffer = nullptr) const; |
253 #endif | 253 #endif |
254 | 254 |
255 CFX_DIBitmap* m_pAlphaMask; | 255 CFX_DIBitmap* m_pAlphaMask; |
256 | 256 |
257 protected: | 257 protected: |
258 CFX_DIBSource(); | 258 CFX_DIBSource(); |
259 | 259 |
260 void BuildPalette(); | 260 void BuildPalette(); |
261 FX_BOOL BuildAlphaMask(); | 261 bool BuildAlphaMask(); |
262 int FindPalette(uint32_t color) const; | 262 int FindPalette(uint32_t color) const; |
263 void GetPalette(uint32_t* pal, int alpha) const; | 263 void GetPalette(uint32_t* pal, int alpha) const; |
264 | 264 |
265 int m_Width; | 265 int m_Width; |
266 int m_Height; | 266 int m_Height; |
267 int m_bpp; | 267 int m_bpp; |
268 uint32_t m_AlphaFlag; | 268 uint32_t m_AlphaFlag; |
269 uint32_t m_Pitch; | 269 uint32_t m_Pitch; |
270 // TODO(weili): Use std::vector for this. | 270 // TODO(weili): Use std::vector for this. |
271 std::unique_ptr<uint32_t, FxFreeDeleter> m_pPalette; | 271 std::unique_ptr<uint32_t, FxFreeDeleter> m_pPalette; |
272 }; | 272 }; |
273 | 273 |
274 class CFX_DIBitmap : public CFX_DIBSource { | 274 class CFX_DIBitmap : public CFX_DIBSource { |
275 public: | 275 public: |
276 CFX_DIBitmap(); | 276 CFX_DIBitmap(); |
277 explicit CFX_DIBitmap(const CFX_DIBitmap& src); | 277 explicit CFX_DIBitmap(const CFX_DIBitmap& src); |
278 ~CFX_DIBitmap() override; | 278 ~CFX_DIBitmap() override; |
279 | 279 |
280 FX_BOOL Create(int width, | 280 bool Create(int width, |
281 int height, | 281 int height, |
282 FXDIB_Format format, | 282 FXDIB_Format format, |
283 uint8_t* pBuffer = nullptr, | 283 uint8_t* pBuffer = nullptr, |
284 int pitch = 0); | 284 int pitch = 0); |
285 | 285 |
286 FX_BOOL Copy(const CFX_DIBSource* pSrc); | 286 bool Copy(const CFX_DIBSource* pSrc); |
287 | 287 |
288 // CFX_DIBSource | 288 // CFX_DIBSource |
289 uint8_t* GetBuffer() const override; | 289 uint8_t* GetBuffer() const override; |
290 const uint8_t* GetScanline(int line) const override; | 290 const uint8_t* GetScanline(int line) const override; |
291 void DownSampleScanline(int line, | 291 void DownSampleScanline(int line, |
292 uint8_t* dest_scan, | 292 uint8_t* dest_scan, |
293 int dest_bpp, | 293 int dest_bpp, |
294 int dest_width, | 294 int dest_width, |
295 FX_BOOL bFlipX, | 295 bool bFlipX, |
296 int clip_left, | 296 int clip_left, |
297 int clip_width) const override; | 297 int clip_width) const override; |
298 | 298 |
299 void TakeOver(CFX_DIBitmap* pSrcBitmap); | 299 void TakeOver(CFX_DIBitmap* pSrcBitmap); |
300 | 300 |
301 FX_BOOL ConvertFormat(FXDIB_Format format); | 301 bool ConvertFormat(FXDIB_Format format); |
302 | 302 |
303 void Clear(uint32_t color); | 303 void Clear(uint32_t color); |
304 | 304 |
305 uint32_t GetPixel(int x, int y) const; | 305 uint32_t GetPixel(int x, int y) const; |
306 | 306 |
307 void SetPixel(int x, int y, uint32_t color); | 307 void SetPixel(int x, int y, uint32_t color); |
308 | 308 |
309 FX_BOOL LoadChannel(FXDIB_Channel destChannel, | 309 bool LoadChannel(FXDIB_Channel destChannel, |
| 310 const CFX_DIBSource* pSrcBitmap, |
| 311 FXDIB_Channel srcChannel); |
| 312 |
| 313 bool LoadChannel(FXDIB_Channel destChannel, int value); |
| 314 |
| 315 bool MultiplyAlpha(int alpha); |
| 316 |
| 317 bool MultiplyAlpha(const CFX_DIBSource* pAlphaMask); |
| 318 |
| 319 bool TransferBitmap(int dest_left, |
| 320 int dest_top, |
| 321 int width, |
| 322 int height, |
310 const CFX_DIBSource* pSrcBitmap, | 323 const CFX_DIBSource* pSrcBitmap, |
311 FXDIB_Channel srcChannel); | 324 int src_left, |
| 325 int src_top); |
312 | 326 |
313 FX_BOOL LoadChannel(FXDIB_Channel destChannel, int value); | 327 bool CompositeBitmap(int dest_left, |
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, | 328 int dest_top, |
341 int width, | 329 int width, |
342 int height, | 330 int height, |
343 const CFX_DIBSource* pMask, | 331 const CFX_DIBSource* pSrcBitmap, |
344 uint32_t color, | |
345 int src_left, | 332 int src_left, |
346 int src_top, | 333 int src_top, |
347 int alpha_flag = 0, | 334 int blend_type = FXDIB_BLEND_NORMAL, |
| 335 const CFX_ClipRgn* pClipRgn = nullptr, |
| 336 bool bRgbByteOrder = false, |
348 void* pIccTransform = nullptr); | 337 void* pIccTransform = nullptr); |
349 | 338 |
350 FX_BOOL CompositeMask(int dest_left, | 339 bool TransferMask(int dest_left, |
351 int dest_top, | 340 int dest_top, |
352 int width, | 341 int width, |
353 int height, | 342 int height, |
354 const CFX_DIBSource* pMask, | 343 const CFX_DIBSource* pMask, |
355 uint32_t color, | 344 uint32_t color, |
356 int src_left, | 345 int src_left, |
357 int src_top, | 346 int src_top, |
358 int blend_type = FXDIB_BLEND_NORMAL, | 347 int alpha_flag = 0, |
359 const CFX_ClipRgn* pClipRgn = nullptr, | 348 void* pIccTransform = nullptr); |
360 FX_BOOL bRgbByteOrder = FALSE, | |
361 int alpha_flag = 0, | |
362 void* pIccTransform = nullptr); | |
363 | 349 |
364 FX_BOOL CompositeRect(int dest_left, | 350 bool CompositeMask(int dest_left, |
365 int dest_top, | 351 int dest_top, |
366 int width, | 352 int width, |
367 int height, | 353 int height, |
368 uint32_t color, | 354 const CFX_DIBSource* pMask, |
369 int alpha_flag = 0, | 355 uint32_t color, |
370 void* pIccTransform = nullptr); | 356 int src_left, |
| 357 int src_top, |
| 358 int blend_type = FXDIB_BLEND_NORMAL, |
| 359 const CFX_ClipRgn* pClipRgn = nullptr, |
| 360 bool bRgbByteOrder = false, |
| 361 int alpha_flag = 0, |
| 362 void* pIccTransform = nullptr); |
371 | 363 |
372 FX_BOOL ConvertColorScale(uint32_t forecolor, uint32_t backcolor); | 364 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 bool ConvertColorScale(uint32_t forecolor, uint32_t backcolor); |
373 | 373 |
374 protected: | 374 protected: |
375 FX_BOOL GetGrayData(void* pIccTransform = nullptr); | 375 bool GetGrayData(void* pIccTransform = nullptr); |
376 | 376 |
377 uint8_t* m_pBuffer; | 377 uint8_t* m_pBuffer; |
378 FX_BOOL m_bExtBuf; | 378 bool m_bExtBuf; |
379 }; | 379 }; |
380 | 380 |
381 class CFX_DIBExtractor { | 381 class CFX_DIBExtractor { |
382 public: | 382 public: |
383 explicit CFX_DIBExtractor(const CFX_DIBSource* pSrc); | 383 explicit CFX_DIBExtractor(const CFX_DIBSource* pSrc); |
384 ~CFX_DIBExtractor(); | 384 ~CFX_DIBExtractor(); |
385 | 385 |
386 CFX_DIBitmap* GetBitmap() { return m_pBitmap.get(); } | 386 CFX_DIBitmap* GetBitmap() { return m_pBitmap.get(); } |
387 | 387 |
388 private: | 388 private: |
389 std::unique_ptr<CFX_DIBitmap> m_pBitmap; | 389 std::unique_ptr<CFX_DIBitmap> m_pBitmap; |
390 }; | 390 }; |
391 | 391 |
392 typedef CFX_SharedCopyOnWrite<CFX_DIBitmap> CFX_DIBitmapRef; | 392 typedef CFX_SharedCopyOnWrite<CFX_DIBitmap> CFX_DIBitmapRef; |
393 | 393 |
394 class CFX_FilteredDIB : public CFX_DIBSource { | 394 class CFX_FilteredDIB : public CFX_DIBSource { |
395 public: | 395 public: |
396 CFX_FilteredDIB(); | 396 CFX_FilteredDIB(); |
397 ~CFX_FilteredDIB() override; | 397 ~CFX_FilteredDIB() override; |
398 | 398 |
399 void LoadSrc(const CFX_DIBSource* pSrc, FX_BOOL bAutoDropSrc = FALSE); | 399 void LoadSrc(const CFX_DIBSource* pSrc, bool bAutoDropSrc = false); |
400 | 400 |
401 virtual FXDIB_Format GetDestFormat() = 0; | 401 virtual FXDIB_Format GetDestFormat() = 0; |
402 | 402 |
403 virtual uint32_t* GetDestPalette() = 0; | 403 virtual uint32_t* GetDestPalette() = 0; |
404 | 404 |
405 virtual void TranslateScanline(const uint8_t* src_buf, | 405 virtual void TranslateScanline(const uint8_t* src_buf, |
406 std::vector<uint8_t>* dest_buf) const = 0; | 406 std::vector<uint8_t>* dest_buf) const = 0; |
407 | 407 |
408 virtual void TranslateDownSamples(uint8_t* dest_buf, | 408 virtual void TranslateDownSamples(uint8_t* dest_buf, |
409 const uint8_t* src_buf, | 409 const uint8_t* src_buf, |
410 int pixels, | 410 int pixels, |
411 int Bpp) const = 0; | 411 int Bpp) const = 0; |
412 | 412 |
413 protected: | 413 protected: |
414 // CFX_DIBSource | 414 // CFX_DIBSource |
415 const uint8_t* GetScanline(int line) const override; | 415 const uint8_t* GetScanline(int line) const override; |
416 void DownSampleScanline(int line, | 416 void DownSampleScanline(int line, |
417 uint8_t* dest_scan, | 417 uint8_t* dest_scan, |
418 int dest_bpp, | 418 int dest_bpp, |
419 int dest_width, | 419 int dest_width, |
420 FX_BOOL bFlipX, | 420 bool bFlipX, |
421 int clip_left, | 421 int clip_left, |
422 int clip_width) const override; | 422 int clip_width) const override; |
423 | 423 |
424 const CFX_DIBSource* m_pSrc; | 424 const CFX_DIBSource* m_pSrc; |
425 FX_BOOL m_bAutoDropSrc; | 425 bool m_bAutoDropSrc; |
426 mutable std::vector<uint8_t> m_Scanline; | 426 mutable std::vector<uint8_t> m_Scanline; |
427 }; | 427 }; |
428 | 428 |
429 class IFX_ScanlineComposer { | 429 class IFX_ScanlineComposer { |
430 public: | 430 public: |
431 virtual ~IFX_ScanlineComposer() {} | 431 virtual ~IFX_ScanlineComposer() {} |
432 | 432 |
433 virtual void ComposeScanline(int line, | 433 virtual void ComposeScanline(int line, |
434 const uint8_t* scanline, | 434 const uint8_t* scanline, |
435 const uint8_t* scan_extra_alpha = nullptr) = 0; | 435 const uint8_t* scan_extra_alpha = nullptr) = 0; |
436 | 436 |
437 virtual FX_BOOL SetInfo(int width, | 437 virtual bool SetInfo(int width, |
438 int height, | 438 int height, |
439 FXDIB_Format src_format, | 439 FXDIB_Format src_format, |
440 uint32_t* pSrcPalette) = 0; | 440 uint32_t* pSrcPalette) = 0; |
441 }; | 441 }; |
442 | 442 |
443 class CFX_ScanlineCompositor { | 443 class CFX_ScanlineCompositor { |
444 public: | 444 public: |
445 CFX_ScanlineCompositor(); | 445 CFX_ScanlineCompositor(); |
446 | 446 |
447 ~CFX_ScanlineCompositor(); | 447 ~CFX_ScanlineCompositor(); |
448 | 448 |
449 FX_BOOL Init(FXDIB_Format dest_format, | 449 bool Init(FXDIB_Format dest_format, |
450 FXDIB_Format src_format, | 450 FXDIB_Format src_format, |
451 int32_t width, | 451 int32_t width, |
452 uint32_t* pSrcPalette, | 452 uint32_t* pSrcPalette, |
453 uint32_t mask_color, | 453 uint32_t mask_color, |
454 int blend_type, | 454 int blend_type, |
455 FX_BOOL bClip, | 455 bool bClip, |
456 FX_BOOL bRgbByteOrder = FALSE, | 456 bool bRgbByteOrder = false, |
457 int alpha_flag = 0, | 457 int alpha_flag = 0, |
458 void* pIccTransform = nullptr); | 458 void* pIccTransform = nullptr); |
459 | 459 |
460 void CompositeRgbBitmapLine(uint8_t* dest_scan, | 460 void CompositeRgbBitmapLine(uint8_t* dest_scan, |
461 const uint8_t* src_scan, | 461 const uint8_t* src_scan, |
462 int width, | 462 int width, |
463 const uint8_t* clip_scan, | 463 const uint8_t* clip_scan, |
464 const uint8_t* src_extra_alpha = nullptr, | 464 const uint8_t* src_extra_alpha = nullptr, |
465 uint8_t* dst_extra_alpha = nullptr); | 465 uint8_t* dst_extra_alpha = nullptr); |
466 | 466 |
467 void CompositePalBitmapLine(uint8_t* dest_scan, | 467 void CompositePalBitmapLine(uint8_t* dest_scan, |
468 const uint8_t* src_scan, | 468 const uint8_t* src_scan, |
(...skipping 19 matching lines...) Expand all Loading... |
488 protected: | 488 protected: |
489 int m_Transparency; | 489 int m_Transparency; |
490 FXDIB_Format m_SrcFormat, m_DestFormat; | 490 FXDIB_Format m_SrcFormat, m_DestFormat; |
491 uint32_t* m_pSrcPalette; | 491 uint32_t* m_pSrcPalette; |
492 | 492 |
493 int m_MaskAlpha, m_MaskRed, m_MaskGreen, m_MaskBlue, m_MaskBlack; | 493 int m_MaskAlpha, m_MaskRed, m_MaskGreen, m_MaskBlue, m_MaskBlack; |
494 int m_BlendType; | 494 int m_BlendType; |
495 void* m_pIccTransform; | 495 void* m_pIccTransform; |
496 uint8_t* m_pCacheScanline; | 496 uint8_t* m_pCacheScanline; |
497 int m_CacheSize; | 497 int m_CacheSize; |
498 FX_BOOL m_bRgbByteOrder; | 498 bool m_bRgbByteOrder; |
499 }; | 499 }; |
500 | 500 |
501 class CFX_BitmapComposer : public IFX_ScanlineComposer { | 501 class CFX_BitmapComposer : public IFX_ScanlineComposer { |
502 public: | 502 public: |
503 CFX_BitmapComposer(); | 503 CFX_BitmapComposer(); |
504 ~CFX_BitmapComposer() override; | 504 ~CFX_BitmapComposer() override; |
505 | 505 |
506 void Compose(CFX_DIBitmap* pDest, | 506 void Compose(CFX_DIBitmap* pDest, |
507 const CFX_ClipRgn* pClipRgn, | 507 const CFX_ClipRgn* pClipRgn, |
508 int bitmap_alpha, | 508 int bitmap_alpha, |
509 uint32_t mask_color, | 509 uint32_t mask_color, |
510 FX_RECT& dest_rect, | 510 FX_RECT& dest_rect, |
511 FX_BOOL bVertical, | 511 bool bVertical, |
512 FX_BOOL bFlipX, | 512 bool bFlipX, |
513 FX_BOOL bFlipY, | 513 bool bFlipY, |
514 FX_BOOL bRgbByteOrder = FALSE, | 514 bool bRgbByteOrder = false, |
515 int alpha_flag = 0, | 515 int alpha_flag = 0, |
516 void* pIccTransform = nullptr, | 516 void* pIccTransform = nullptr, |
517 int blend_type = FXDIB_BLEND_NORMAL); | 517 int blend_type = FXDIB_BLEND_NORMAL); |
518 | 518 |
519 // IFX_ScanlineComposer | 519 // IFX_ScanlineComposer |
520 FX_BOOL SetInfo(int width, | 520 bool SetInfo(int width, |
521 int height, | 521 int height, |
522 FXDIB_Format src_format, | 522 FXDIB_Format src_format, |
523 uint32_t* pSrcPalette) override; | 523 uint32_t* pSrcPalette) override; |
524 | 524 |
525 void ComposeScanline(int line, | 525 void ComposeScanline(int line, |
526 const uint8_t* scanline, | 526 const uint8_t* scanline, |
527 const uint8_t* scan_extra_alpha) override; | 527 const uint8_t* scan_extra_alpha) override; |
528 | 528 |
529 protected: | 529 protected: |
530 void DoCompose(uint8_t* dest_scan, | 530 void DoCompose(uint8_t* dest_scan, |
531 const uint8_t* src_scan, | 531 const uint8_t* src_scan, |
532 int dest_width, | 532 int dest_width, |
533 const uint8_t* clip_scan, | 533 const uint8_t* clip_scan, |
534 const uint8_t* src_extra_alpha = nullptr, | 534 const uint8_t* src_extra_alpha = nullptr, |
535 uint8_t* dst_extra_alpha = nullptr); | 535 uint8_t* dst_extra_alpha = nullptr); |
536 CFX_DIBitmap* m_pBitmap; | 536 CFX_DIBitmap* m_pBitmap; |
537 const CFX_ClipRgn* m_pClipRgn; | 537 const CFX_ClipRgn* m_pClipRgn; |
538 FXDIB_Format m_SrcFormat; | 538 FXDIB_Format m_SrcFormat; |
539 int m_DestLeft, m_DestTop, m_DestWidth, m_DestHeight, m_BitmapAlpha; | 539 int m_DestLeft, m_DestTop, m_DestWidth, m_DestHeight, m_BitmapAlpha; |
540 uint32_t m_MaskColor; | 540 uint32_t m_MaskColor; |
541 const CFX_DIBitmap* m_pClipMask; | 541 const CFX_DIBitmap* m_pClipMask; |
542 CFX_ScanlineCompositor m_Compositor; | 542 CFX_ScanlineCompositor m_Compositor; |
543 FX_BOOL m_bVertical, m_bFlipX, m_bFlipY; | 543 bool m_bVertical, m_bFlipX, m_bFlipY; |
544 int m_AlphaFlag; | 544 int m_AlphaFlag; |
545 void* m_pIccTransform; | 545 void* m_pIccTransform; |
546 FX_BOOL m_bRgbByteOrder; | 546 bool m_bRgbByteOrder; |
547 int m_BlendType; | 547 int m_BlendType; |
548 void ComposeScanlineV(int line, | 548 void ComposeScanlineV(int line, |
549 const uint8_t* scanline, | 549 const uint8_t* scanline, |
550 const uint8_t* scan_extra_alpha = nullptr); | 550 const uint8_t* scan_extra_alpha = nullptr); |
551 uint8_t* m_pScanlineV; | 551 uint8_t* m_pScanlineV; |
552 uint8_t* m_pClipScanV; | 552 uint8_t* m_pClipScanV; |
553 uint8_t* m_pAddClipScan; | 553 uint8_t* m_pAddClipScan; |
554 uint8_t* m_pScanlineAlphaV; | 554 uint8_t* m_pScanlineAlphaV; |
555 }; | 555 }; |
556 | 556 |
557 class CFX_BitmapStorer : public IFX_ScanlineComposer { | 557 class CFX_BitmapStorer : public IFX_ScanlineComposer { |
558 public: | 558 public: |
559 CFX_BitmapStorer(); | 559 CFX_BitmapStorer(); |
560 ~CFX_BitmapStorer() override; | 560 ~CFX_BitmapStorer() override; |
561 | 561 |
562 // IFX_ScanlineComposer | 562 // IFX_ScanlineComposer |
563 void ComposeScanline(int line, | 563 void ComposeScanline(int line, |
564 const uint8_t* scanline, | 564 const uint8_t* scanline, |
565 const uint8_t* scan_extra_alpha) override; | 565 const uint8_t* scan_extra_alpha) override; |
566 FX_BOOL SetInfo(int width, | 566 bool SetInfo(int width, |
567 int height, | 567 int height, |
568 FXDIB_Format src_format, | 568 FXDIB_Format src_format, |
569 uint32_t* pSrcPalette) override; | 569 uint32_t* pSrcPalette) override; |
570 | 570 |
571 CFX_DIBitmap* GetBitmap() { return m_pBitmap.get(); } | 571 CFX_DIBitmap* GetBitmap() { return m_pBitmap.get(); } |
572 std::unique_ptr<CFX_DIBitmap> Detach(); | 572 std::unique_ptr<CFX_DIBitmap> Detach(); |
573 void Replace(std::unique_ptr<CFX_DIBitmap> pBitmap); | 573 void Replace(std::unique_ptr<CFX_DIBitmap> pBitmap); |
574 | 574 |
575 private: | 575 private: |
576 std::unique_ptr<CFX_DIBitmap> m_pBitmap; | 576 std::unique_ptr<CFX_DIBitmap> m_pBitmap; |
577 }; | 577 }; |
578 | 578 |
579 class CFX_ImageStretcher { | 579 class CFX_ImageStretcher { |
580 public: | 580 public: |
581 CFX_ImageStretcher(IFX_ScanlineComposer* pDest, | 581 CFX_ImageStretcher(IFX_ScanlineComposer* pDest, |
582 const CFX_DIBSource* pSource, | 582 const CFX_DIBSource* pSource, |
583 int dest_width, | 583 int dest_width, |
584 int dest_height, | 584 int dest_height, |
585 const FX_RECT& bitmap_rect, | 585 const FX_RECT& bitmap_rect, |
586 uint32_t flags); | 586 uint32_t flags); |
587 ~CFX_ImageStretcher(); | 587 ~CFX_ImageStretcher(); |
588 | 588 |
589 FX_BOOL Start(); | 589 bool Start(); |
590 FX_BOOL Continue(IFX_Pause* pPause); | 590 bool Continue(IFX_Pause* pPause); |
591 | 591 |
592 const CFX_DIBSource* source() { return m_pSource; } | 592 const CFX_DIBSource* source() { return m_pSource; } |
593 | 593 |
594 private: | 594 private: |
595 FX_BOOL StartQuickStretch(); | 595 bool StartQuickStretch(); |
596 FX_BOOL StartStretch(); | 596 bool StartStretch(); |
597 FX_BOOL ContinueQuickStretch(IFX_Pause* pPause); | 597 bool ContinueQuickStretch(IFX_Pause* pPause); |
598 FX_BOOL ContinueStretch(IFX_Pause* pPause); | 598 bool ContinueStretch(IFX_Pause* pPause); |
599 | 599 |
600 IFX_ScanlineComposer* const m_pDest; | 600 IFX_ScanlineComposer* const m_pDest; |
601 const CFX_DIBSource* const m_pSource; | 601 const CFX_DIBSource* const m_pSource; |
602 std::unique_ptr<CStretchEngine> m_pStretchEngine; | 602 std::unique_ptr<CStretchEngine> m_pStretchEngine; |
603 std::unique_ptr<uint8_t, FxFreeDeleter> m_pScanline; | 603 std::unique_ptr<uint8_t, FxFreeDeleter> m_pScanline; |
604 std::unique_ptr<uint8_t, FxFreeDeleter> m_pMaskScanline; | 604 std::unique_ptr<uint8_t, FxFreeDeleter> m_pMaskScanline; |
605 const uint32_t m_Flags; | 605 const uint32_t m_Flags; |
606 FX_BOOL m_bFlipX; | 606 bool m_bFlipX; |
607 FX_BOOL m_bFlipY; | 607 bool m_bFlipY; |
608 int m_DestWidth; | 608 int m_DestWidth; |
609 int m_DestHeight; | 609 int m_DestHeight; |
610 FX_RECT m_ClipRect; | 610 FX_RECT m_ClipRect; |
611 const FXDIB_Format m_DestFormat; | 611 const FXDIB_Format m_DestFormat; |
612 const int m_DestBPP; | 612 const int m_DestBPP; |
613 int m_LineIndex; | 613 int m_LineIndex; |
614 }; | 614 }; |
615 | 615 |
616 class CFX_ImageTransformer { | 616 class CFX_ImageTransformer { |
617 public: | 617 public: |
618 CFX_ImageTransformer(const CFX_DIBSource* pSrc, | 618 CFX_ImageTransformer(const CFX_DIBSource* pSrc, |
619 const CFX_Matrix* pMatrix, | 619 const CFX_Matrix* pMatrix, |
620 int flags, | 620 int flags, |
621 const FX_RECT* pClip); | 621 const FX_RECT* pClip); |
622 ~CFX_ImageTransformer(); | 622 ~CFX_ImageTransformer(); |
623 | 623 |
624 FX_BOOL Start(); | 624 bool Start(); |
625 FX_BOOL Continue(IFX_Pause* pPause); | 625 bool Continue(IFX_Pause* pPause); |
626 | 626 |
627 const FX_RECT& result() const { return m_result; } | 627 const FX_RECT& result() const { return m_result; } |
628 std::unique_ptr<CFX_DIBitmap> DetachBitmap(); | 628 std::unique_ptr<CFX_DIBitmap> DetachBitmap(); |
629 | 629 |
630 private: | 630 private: |
631 const CFX_DIBSource* const m_pSrc; | 631 const CFX_DIBSource* const m_pSrc; |
632 const CFX_Matrix* const m_pMatrix; | 632 const CFX_Matrix* const m_pMatrix; |
633 const FX_RECT* const m_pClip; | 633 const FX_RECT* const m_pClip; |
634 FX_RECT m_StretchClip; | 634 FX_RECT m_StretchClip; |
635 FX_RECT m_result; | 635 FX_RECT m_result; |
636 CFX_Matrix m_dest2stretch; | 636 CFX_Matrix m_dest2stretch; |
637 std::unique_ptr<CFX_ImageStretcher> m_Stretcher; | 637 std::unique_ptr<CFX_ImageStretcher> m_Stretcher; |
638 CFX_BitmapStorer m_Storer; | 638 CFX_BitmapStorer m_Storer; |
639 const uint32_t m_Flags; | 639 const uint32_t m_Flags; |
640 int m_Status; | 640 int m_Status; |
641 }; | 641 }; |
642 | 642 |
643 class CFX_ImageRenderer { | 643 class CFX_ImageRenderer { |
644 public: | 644 public: |
645 CFX_ImageRenderer(); | 645 CFX_ImageRenderer(); |
646 ~CFX_ImageRenderer(); | 646 ~CFX_ImageRenderer(); |
647 | 647 |
648 FX_BOOL Start(CFX_DIBitmap* pDevice, | 648 bool Start(CFX_DIBitmap* pDevice, |
649 const CFX_ClipRgn* pClipRgn, | 649 const CFX_ClipRgn* pClipRgn, |
650 const CFX_DIBSource* pSource, | 650 const CFX_DIBSource* pSource, |
651 int bitmap_alpha, | 651 int bitmap_alpha, |
652 uint32_t mask_color, | 652 uint32_t mask_color, |
653 const CFX_Matrix* pMatrix, | 653 const CFX_Matrix* pMatrix, |
654 uint32_t dib_flags, | 654 uint32_t dib_flags, |
655 FX_BOOL bRgbByteOrder = FALSE, | 655 bool bRgbByteOrder = false, |
656 int alpha_flag = 0, | 656 int alpha_flag = 0, |
657 void* pIccTransform = nullptr, | 657 void* pIccTransform = nullptr, |
658 int blend_type = FXDIB_BLEND_NORMAL); | 658 int blend_type = FXDIB_BLEND_NORMAL); |
659 | 659 |
660 FX_BOOL Continue(IFX_Pause* pPause); | 660 bool Continue(IFX_Pause* pPause); |
661 | 661 |
662 protected: | 662 protected: |
663 CFX_DIBitmap* m_pDevice; | 663 CFX_DIBitmap* m_pDevice; |
664 const CFX_ClipRgn* m_pClipRgn; | 664 const CFX_ClipRgn* m_pClipRgn; |
665 int m_BitmapAlpha; | 665 int m_BitmapAlpha; |
666 uint32_t m_MaskColor; | 666 uint32_t m_MaskColor; |
667 CFX_Matrix m_Matrix; | 667 CFX_Matrix m_Matrix; |
668 std::unique_ptr<CFX_ImageTransformer> m_pTransformer; | 668 std::unique_ptr<CFX_ImageTransformer> m_pTransformer; |
669 std::unique_ptr<CFX_ImageStretcher> m_Stretcher; | 669 std::unique_ptr<CFX_ImageStretcher> m_Stretcher; |
670 CFX_BitmapComposer m_Composer; | 670 CFX_BitmapComposer m_Composer; |
671 int m_Status; | 671 int m_Status; |
672 FX_RECT m_ClipBox; | 672 FX_RECT m_ClipBox; |
673 uint32_t m_Flags; | 673 uint32_t m_Flags; |
674 int m_AlphaFlag; | 674 int m_AlphaFlag; |
675 void* m_pIccTransform; | 675 void* m_pIccTransform; |
676 FX_BOOL m_bRgbByteOrder; | 676 bool m_bRgbByteOrder; |
677 int m_BlendType; | 677 int m_BlendType; |
678 }; | 678 }; |
679 | 679 |
680 #endif // CORE_FXGE_FX_DIB_H_ | 680 #endif // CORE_FXGE_FX_DIB_H_ |
OLD | NEW |