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