1 /* 2 * Copyright 2001-2007, Haiku Inc. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Marc Flerackers (mflerackers@androme.be) 7 * Stefano Ceccherini (stefano.ceccherini@gmail.com) 8 * Marcus Overhagen (marcus@overhagen.de) 9 */ 10 #ifndef _PICTURE_PLAYER_H 11 #define _PICTURE_PLAYER_H 12 13 /*! PicturePlayer is used to play picture data. */ 14 15 16 #include <GraphicsDefs.h> 17 #include <InterfaceDefs.h> 18 #include <Point.h> 19 #include <Rect.h> 20 21 22 class BAffineTransform; 23 class BList; 24 class BPicture; 25 class BShape; 26 27 28 namespace BPrivate { 29 30 31 struct picture_player_callbacks { 32 void (*move_pen_by)(void* userData, const BPoint& where); 33 void (*stroke_line)(void* userData, const BPoint& start, const BPoint& end); 34 void (*draw_rect)(void* userData, const BRect& rect, bool fill); 35 void (*draw_round_rect)(void* userData, const BRect& rect, 36 const BPoint& radii, bool fill); 37 void (*draw_bezier)(void* userData, size_t numControlPoints, 38 const BPoint controlPoints[], bool fill); 39 void (*draw_arc)(void* userData, const BPoint& center, const BPoint& radii, 40 float startTheta, float arcTheta, bool fill); 41 void (*draw_ellipse)(void* userData, const BRect& rect, bool fill); 42 void (*draw_polygon)(void* userData, size_t numPoints, 43 const BPoint points[], bool isClosed, bool fill); 44 void (*draw_shape)(void* userData, const BShape& shape, bool fill); 45 void (*draw_string)(void* userData, const char* string, size_t length, 46 float spaceEscapement, float nonSpaceEscapement); 47 void (*draw_pixels)(void* userData, const BRect& source, 48 const BRect& destination, uint32 width, uint32 height, 49 size_t bytesPerRow, color_space pixelFormat, uint32 flags, 50 const void* data, size_t length); 51 void (*draw_picture)(void* userData, const BPoint& where, int32 token); 52 void (*set_clipping_rects)(void* userData, size_t numRects, 53 const BRect rects[]); 54 void (*clip_to_picture)(void* userData, int32 token, 55 const BPoint& where, bool clipToInverse); 56 void (*push_state)(void* userData); 57 void (*pop_state)(void* userData); 58 void (*enter_state_change)(void* userData); 59 void (*exit_state_change)(void* userData); 60 void (*enter_font_state)(void* userData); 61 void (*exit_font_state)(void* userData); 62 void (*set_origin)(void* userData, const BPoint& origin); 63 void (*set_pen_location)(void* userData, const BPoint& location); 64 void (*set_drawing_mode)(void* userData, drawing_mode mode); 65 void (*set_line_mode)(void* userData, cap_mode capMode, join_mode joinMode, 66 float miterLimit); 67 void (*set_pen_size)(void* userData, float size); 68 void (*set_fore_color)(void* userData, const rgb_color& color); 69 void (*set_back_color)(void* userData, const rgb_color& color); 70 void (*set_stipple_pattern)(void* userData, const pattern& patter); 71 void (*set_scale)(void* userData, float scale); 72 void (*set_font_family)(void* userData, const char* familyName, 73 size_t length); 74 void (*set_font_style)(void* userData, const char* styleName, 75 size_t length); 76 void (*set_font_spacing)(void* userData, uint8 spacing); 77 void (*set_font_size)(void* userData, float size); 78 void (*set_font_rotation)(void* userData, float rotation); 79 void (*set_font_encoding)(void* userData, uint8 encoding); 80 void (*set_font_flags)(void* userData, uint32 flags); 81 void (*set_font_shear)(void* userData, float shear); 82 void (*set_font_face)(void* userData, uint16 face); 83 void (*set_blending_mode)(void* userData, source_alpha alphaSourceMode, 84 alpha_function alphaFunctionMode); 85 void (*set_transform)(void* userData, const BAffineTransform& transform); 86 }; 87 88 89 class PicturePlayer { 90 public: 91 PicturePlayer(); 92 PicturePlayer(const void* data, size_t size, BList* pictures); 93 virtual ~PicturePlayer(); 94 95 status_t Play(void** callbacks, int32 tableEntries, 96 void* userData); 97 status_t Play(const picture_player_callbacks& callbacks, 98 size_t callbacksSize, void* userData); 99 100 private: 101 status_t _Play(const picture_player_callbacks& callbacks, void* userData, 102 const void* data, size_t length, uint16 parentOp); 103 104 const void* fData; 105 size_t fSize; 106 BList* fPictures; 107 }; 108 109 } // namespace BPrivate 110 111 #endif // _PICTURE_PLAYER_H 112