xref: /haiku/headers/private/interface/PicturePlayer.h (revision 4399ec510de9714e2440cdae346d00c286d69906)
1e372c1baSStefano Ceccherini /*
2954a0a0cSStephan Aßmus  * Copyright 2001-2018, Haiku Inc.
3e372c1baSStefano Ceccherini  * Distributed under the terms of the MIT License.
4e372c1baSStefano Ceccherini  *
5e372c1baSStefano Ceccherini  * Authors:
6e372c1baSStefano Ceccherini  *		Marc Flerackers (mflerackers@androme.be)
7422fadc8SStefano Ceccherini  *		Stefano Ceccherini (stefano.ceccherini@gmail.com)
80b0ecfabSMarcus Overhagen  *		Marcus Overhagen (marcus@overhagen.de)
9954a0a0cSStephan Aßmus  *		Stephan Aßmus <superstippi@gmx.de>
10e372c1baSStefano Ceccherini  */
11f6e4cbb9SAxel Dörfler #ifndef	_PICTURE_PLAYER_H
12f6e4cbb9SAxel Dörfler #define	_PICTURE_PLAYER_H
13e372c1baSStefano Ceccherini 
14f6e4cbb9SAxel Dörfler /*!	PicturePlayer is used to play picture data. */
15e372c1baSStefano Ceccherini 
16e372c1baSStefano Ceccherini 
17e372c1baSStefano Ceccherini #include <GraphicsDefs.h>
18eec73693SMichael Lotz #include <InterfaceDefs.h>
19e372c1baSStefano Ceccherini #include <Point.h>
20e372c1baSStefano Ceccherini #include <Rect.h>
21e372c1baSStefano Ceccherini 
22eec73693SMichael Lotz 
23eec73693SMichael Lotz class BAffineTransform;
2490ab1a44SX512 class BGradient;
25f6e4cbb9SAxel Dörfler class BList;
26eec73693SMichael Lotz class BPicture;
27eec73693SMichael Lotz class BShape;
286109a208SJulian Harnath class Layer;
29f6e4cbb9SAxel Dörfler 
30e372c1baSStefano Ceccherini 
31422fadc8SStefano Ceccherini namespace BPrivate {
32422fadc8SStefano Ceccherini 
33eec73693SMichael Lotz 
34eec73693SMichael Lotz struct picture_player_callbacks {
35eec73693SMichael Lotz 	void (*move_pen_by)(void* userData, const BPoint& where);
36eec73693SMichael Lotz 	void (*stroke_line)(void* userData, const BPoint& start, const BPoint& end);
37eec73693SMichael Lotz 	void (*draw_rect)(void* userData, const BRect& rect, bool fill);
38eec73693SMichael Lotz 	void (*draw_round_rect)(void* userData, const BRect& rect,
39eec73693SMichael Lotz 		const BPoint& radii, bool fill);
40eec73693SMichael Lotz 	void (*draw_bezier)(void* userData, size_t numControlPoints,
41eec73693SMichael Lotz 		const BPoint controlPoints[], bool fill);
42eec73693SMichael Lotz 	void (*draw_arc)(void* userData, const BPoint& center, const BPoint& radii,
43eec73693SMichael Lotz 		float startTheta, float arcTheta, bool fill);
44eec73693SMichael Lotz 	void (*draw_ellipse)(void* userData, const BRect& rect, bool fill);
45eec73693SMichael Lotz 	void (*draw_polygon)(void* userData, size_t numPoints,
46eec73693SMichael Lotz 		const BPoint points[], bool isClosed, bool fill);
47eec73693SMichael Lotz 	void (*draw_shape)(void* userData, const BShape& shape, bool fill);
48eec73693SMichael Lotz 	void (*draw_string)(void* userData, const char* string, size_t length,
49eec73693SMichael Lotz 		float spaceEscapement, float nonSpaceEscapement);
50eec73693SMichael Lotz 	void (*draw_pixels)(void* userData, const BRect& source,
51eec73693SMichael Lotz 		const BRect& destination, uint32 width, uint32 height,
52eec73693SMichael Lotz 		size_t bytesPerRow, color_space pixelFormat, uint32 flags,
53eec73693SMichael Lotz 		const void* data, size_t length);
54eec73693SMichael Lotz 	void (*draw_picture)(void* userData, const BPoint& where, int32 token);
55eec73693SMichael Lotz 	void (*set_clipping_rects)(void* userData, size_t numRects,
56eec73693SMichael Lotz 		const BRect rects[]);
57ce27f961SStefano Ceccherini 	void (*clip_to_picture)(void* userData, int32 token,
58eec73693SMichael Lotz 		const BPoint& where, bool clipToInverse);
59eec73693SMichael Lotz 	void (*push_state)(void* userData);
60eec73693SMichael Lotz 	void (*pop_state)(void* userData);
61eec73693SMichael Lotz 	void (*enter_state_change)(void* userData);
62eec73693SMichael Lotz 	void (*exit_state_change)(void* userData);
63eec73693SMichael Lotz 	void (*enter_font_state)(void* userData);
64eec73693SMichael Lotz 	void (*exit_font_state)(void* userData);
65eec73693SMichael Lotz 	void (*set_origin)(void* userData, const BPoint& origin);
66eec73693SMichael Lotz 	void (*set_pen_location)(void* userData, const BPoint& location);
67eec73693SMichael Lotz 	void (*set_drawing_mode)(void* userData, drawing_mode mode);
68eec73693SMichael Lotz 	void (*set_line_mode)(void* userData, cap_mode capMode, join_mode joinMode,
69eec73693SMichael Lotz 		float miterLimit);
70eec73693SMichael Lotz 	void (*set_pen_size)(void* userData, float size);
71eec73693SMichael Lotz 	void (*set_fore_color)(void* userData, const rgb_color& color);
72eec73693SMichael Lotz 	void (*set_back_color)(void* userData, const rgb_color& color);
73eec73693SMichael Lotz 	void (*set_stipple_pattern)(void* userData, const pattern& patter);
74eec73693SMichael Lotz 	void (*set_scale)(void* userData, float scale);
75eec73693SMichael Lotz 	void (*set_font_family)(void* userData, const char* familyName,
76eec73693SMichael Lotz 		size_t length);
77eec73693SMichael Lotz 	void (*set_font_style)(void* userData, const char* styleName,
78eec73693SMichael Lotz 		size_t length);
79eec73693SMichael Lotz 	void (*set_font_spacing)(void* userData, uint8 spacing);
80eec73693SMichael Lotz 	void (*set_font_size)(void* userData, float size);
81eec73693SMichael Lotz 	void (*set_font_rotation)(void* userData, float rotation);
82eec73693SMichael Lotz 	void (*set_font_encoding)(void* userData, uint8 encoding);
83eec73693SMichael Lotz 	void (*set_font_flags)(void* userData, uint32 flags);
84eec73693SMichael Lotz 	void (*set_font_shear)(void* userData, float shear);
85eec73693SMichael Lotz 	void (*set_font_face)(void* userData, uint16 face);
86eec73693SMichael Lotz 	void (*set_blending_mode)(void* userData, source_alpha alphaSourceMode,
87eec73693SMichael Lotz 		alpha_function alphaFunctionMode);
88eec73693SMichael Lotz 	void (*set_transform)(void* userData, const BAffineTransform& transform);
8925dbf74bSJulian Harnath 	void (*translate_by)(void* userData, double x, double y);
9025dbf74bSJulian Harnath 	void (*scale_by)(void* userData, double x, double y);
9125dbf74bSJulian Harnath 	void (*rotate_by)(void* userData, double angleRadians);
926109a208SJulian Harnath 	void (*blend_layer)(void* userData, Layer* layer);
934bd6f322SJulian Harnath 	void (*clip_to_rect)(void* userData, const BRect& rect, bool inverse);
944bd6f322SJulian Harnath 	void (*clip_to_shape)(void* userData, int32 opCount, const uint32 opList[],
954bd6f322SJulian Harnath 		int32 ptCount, const BPoint ptList[], bool inverse);
96954a0a0cSStephan Aßmus 	void (*draw_string_locations)(void* userData, const char* string,
97954a0a0cSStephan Aßmus 		size_t length, const BPoint locations[], size_t locationCount);
9890ab1a44SX512 	void (*draw_rect_gradient)(void* userData, const BRect& rect, BGradient& gradient, bool fill);
9990ab1a44SX512 	void (*draw_round_rect_gradient)(void* userData, const BRect& rect, const BPoint& radii, BGradient& gradient, bool fill);
10090ab1a44SX512 	void (*draw_bezier_gradient)(void* userData, size_t numControlPoints, const BPoint controlPoints[], BGradient& gradient, bool fill);
10190ab1a44SX512 	void (*draw_arc_gradient)(void* userData, const BPoint& center, const BPoint& radii, float startTheta, float arcTheta, BGradient& gradient, bool fill);
10290ab1a44SX512 	void (*draw_ellipse_gradient)(void* userData, const BRect& rect, BGradient& gradient, bool fill);
10390ab1a44SX512 	void (*draw_polygon_gradient)(void* userData, size_t numPoints, const BPoint points[], bool isClosed, BGradient& gradient, bool fill);
10490ab1a44SX512 	void (*draw_shape_gradient)(void* userData, const BShape& shape, BGradient& gradient, bool fill);
105*4399ec51SX512 	void (*set_fill_rule)(void* userData, int32 fillRule);
106eec73693SMichael Lotz };
107eec73693SMichael Lotz 
108eec73693SMichael Lotz 
109e372c1baSStefano Ceccherini class PicturePlayer {
110e372c1baSStefano Ceccherini public:
111e372c1baSStefano Ceccherini 	PicturePlayer();
1120b0ecfabSMarcus Overhagen 	PicturePlayer(const void* data, size_t size, BList* pictures);
113e372c1baSStefano Ceccherini 	virtual	~PicturePlayer();
114e372c1baSStefano Ceccherini 
115eec73693SMichael Lotz 	status_t	Play(void** callbacks, int32 tableEntries,
116e372c1baSStefano Ceccherini 					void* userData);
117eec73693SMichael Lotz 	status_t	Play(const picture_player_callbacks& callbacks,
118eec73693SMichael Lotz 					size_t callbacksSize, void* userData);
119e372c1baSStefano Ceccherini 
120e372c1baSStefano Ceccherini private:
121eec73693SMichael Lotz 	status_t	_Play(const picture_player_callbacks& callbacks, void* userData,
122eec73693SMichael Lotz 					const void* data, size_t length, uint16 parentOp);
123eec73693SMichael Lotz 
1240b0ecfabSMarcus Overhagen 	const void*	fData;
1250b0ecfabSMarcus Overhagen 	size_t		fSize;
126e372c1baSStefano Ceccherini 	BList*		fPictures;
127e372c1baSStefano Ceccherini };
128e372c1baSStefano Ceccherini 
129f6e4cbb9SAxel Dörfler } // namespace BPrivate
130422fadc8SStefano Ceccherini 
131f6e4cbb9SAxel Dörfler #endif // _PICTURE_PLAYER_H
132