1 /* 2 * Copyright 2001-2018, 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 * Stephan Aßmus <superstippi@gmx.de> 10 */ 11 #ifndef _PICTURE_PLAYER_H 12 #define _PICTURE_PLAYER_H 13 14 /*! PicturePlayer is used to play picture data. */ 15 16 17 #include <GraphicsDefs.h> 18 #include <InterfaceDefs.h> 19 #include <Point.h> 20 #include <Rect.h> 21 22 23 class BAffineTransform; 24 class BList; 25 class BPicture; 26 class BShape; 27 class Layer; 28 29 30 namespace BPrivate { 31 32 33 struct picture_player_callbacks { 34 void (*move_pen_by)(void* userData, const BPoint& where); 35 void (*stroke_line)(void* userData, const BPoint& start, const BPoint& end); 36 void (*draw_rect)(void* userData, const BRect& rect, bool fill); 37 void (*draw_round_rect)(void* userData, const BRect& rect, 38 const BPoint& radii, bool fill); 39 void (*draw_bezier)(void* userData, size_t numControlPoints, 40 const BPoint controlPoints[], bool fill); 41 void (*draw_arc)(void* userData, const BPoint& center, const BPoint& radii, 42 float startTheta, float arcTheta, bool fill); 43 void (*draw_ellipse)(void* userData, const BRect& rect, bool fill); 44 void (*draw_polygon)(void* userData, size_t numPoints, 45 const BPoint points[], bool isClosed, bool fill); 46 void (*draw_shape)(void* userData, const BShape& shape, bool fill); 47 void (*draw_string)(void* userData, const char* string, size_t length, 48 float spaceEscapement, float nonSpaceEscapement); 49 void (*draw_pixels)(void* userData, const BRect& source, 50 const BRect& destination, uint32 width, uint32 height, 51 size_t bytesPerRow, color_space pixelFormat, uint32 flags, 52 const void* data, size_t length); 53 void (*draw_picture)(void* userData, const BPoint& where, int32 token); 54 void (*set_clipping_rects)(void* userData, size_t numRects, 55 const BRect rects[]); 56 void (*clip_to_picture)(void* userData, int32 token, 57 const BPoint& where, bool clipToInverse); 58 void (*push_state)(void* userData); 59 void (*pop_state)(void* userData); 60 void (*enter_state_change)(void* userData); 61 void (*exit_state_change)(void* userData); 62 void (*enter_font_state)(void* userData); 63 void (*exit_font_state)(void* userData); 64 void (*set_origin)(void* userData, const BPoint& origin); 65 void (*set_pen_location)(void* userData, const BPoint& location); 66 void (*set_drawing_mode)(void* userData, drawing_mode mode); 67 void (*set_line_mode)(void* userData, cap_mode capMode, join_mode joinMode, 68 float miterLimit); 69 void (*set_pen_size)(void* userData, float size); 70 void (*set_fore_color)(void* userData, const rgb_color& color); 71 void (*set_back_color)(void* userData, const rgb_color& color); 72 void (*set_stipple_pattern)(void* userData, const pattern& patter); 73 void (*set_scale)(void* userData, float scale); 74 void (*set_font_family)(void* userData, const char* familyName, 75 size_t length); 76 void (*set_font_style)(void* userData, const char* styleName, 77 size_t length); 78 void (*set_font_spacing)(void* userData, uint8 spacing); 79 void (*set_font_size)(void* userData, float size); 80 void (*set_font_rotation)(void* userData, float rotation); 81 void (*set_font_encoding)(void* userData, uint8 encoding); 82 void (*set_font_flags)(void* userData, uint32 flags); 83 void (*set_font_shear)(void* userData, float shear); 84 void (*set_font_face)(void* userData, uint16 face); 85 void (*set_blending_mode)(void* userData, source_alpha alphaSourceMode, 86 alpha_function alphaFunctionMode); 87 void (*set_transform)(void* userData, const BAffineTransform& transform); 88 void (*translate_by)(void* userData, double x, double y); 89 void (*scale_by)(void* userData, double x, double y); 90 void (*rotate_by)(void* userData, double angleRadians); 91 void (*blend_layer)(void* userData, Layer* layer); 92 void (*clip_to_rect)(void* userData, const BRect& rect, bool inverse); 93 void (*clip_to_shape)(void* userData, int32 opCount, const uint32 opList[], 94 int32 ptCount, const BPoint ptList[], bool inverse); 95 void (*draw_string_locations)(void* userData, const char* string, 96 size_t length, const BPoint locations[], size_t locationCount); 97 }; 98 99 100 class PicturePlayer { 101 public: 102 PicturePlayer(); 103 PicturePlayer(const void* data, size_t size, BList* pictures); 104 virtual ~PicturePlayer(); 105 106 status_t Play(void** callbacks, int32 tableEntries, 107 void* userData); 108 status_t Play(const picture_player_callbacks& callbacks, 109 size_t callbacksSize, void* userData); 110 111 private: 112 status_t _Play(const picture_player_callbacks& callbacks, void* userData, 113 const void* data, size_t length, uint16 parentOp); 114 115 const void* fData; 116 size_t fSize; 117 BList* fPictures; 118 }; 119 120 } // namespace BPrivate 121 122 #endif // _PICTURE_PLAYER_H 123