xref: /haiku/src/servers/app/drawing/Painter/bitmap_painter/BitmapPainter.h (revision c302a243e15e640fae0f689e32cdf0c18749afee)
1 /*
2  * Copyright 2005-2007, Stephan Aßmus <superstippi@gmx.de>.
3  * Copyright 2008, Andrej Spielmann <andrej.spielmann@seh.ox.ac.uk>.
4  * Copyright 2015, Julian Harnath <julian.harnath@rwth-aachen.de>
5  * All rights reserved. Distributed under the terms of the MIT License.
6  */
7 #ifndef BITMAP_PAINTER_H
8 #define BITMAP_PAINTER_H
9 
10 #include <AutoDeleter.h>
11 
12 #include "Painter.h"
13 
14 
15 class Painter::BitmapPainter {
16 public:
17 
18 public:
19 								BitmapPainter(const Painter* painter,
20 									const ServerBitmap* bitmap,
21 									uint32 options);
22 
23 			void				Draw(const BRect& sourceRect,
24 									const BRect& destinationRect);
25 
26 private:
27 			bool				_DetermineTransform(
28 									BRect sourceRect,
29 									const BRect& destinationRect);
30 
31 			bool				_HasScale();
32 			bool				_HasAffineTransform();
33 			bool				_HasAlphaMask();
34 
35 			void				_ConvertColorSpace(ObjectDeleter<BBitmap>&
36 									convertedBitmapDeleter);
37 
38 			template<typename sourcePixel>
39 			void				_TransparentMagicToAlpha(sourcePixel *buffer,
40 									uint32 width, uint32 height,
41 									uint32 sourceBytesPerRow,
42 									sourcePixel transparentMagic,
43 									BBitmap *output);
44 
45 private:
46 			const Painter*			fPainter;
47 			status_t				fStatus;
48 			agg::rendering_buffer	fBitmap;
49 			BRect					fBitmapBounds;
50 			color_space				fColorSpace;
51 			uint32					fOptions;
52 
53 			BRect					fDestinationRect;
54 			double					fScaleX;
55 			double					fScaleY;
56 			BPoint					fOffset;
57 };
58 
59 
60 #endif // BITMAP_PAINTER_H
61