1 /*
2
3 PictureIterator
4
5 Copyright (c) 2001, 2002 Haiku.
6
7 Authors:
8 Philippe Houdoin
9 Simon Gauvin
10 Michael Pfeiffer
11
12 Permission is hereby granted, free of charge, to any person obtaining a copy of
13 this software and associated documentation files (the "Software"), to deal in
14 the Software without restriction, including without limitation the rights to
15 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
16 of the Software, and to permit persons to whom the Software is furnished to do
17 so, subject to the following conditions:
18
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 THE SOFTWARE.
29
30 */
31
32 #include "PictureIterator.h"
33
34 // BPicture playback handlers class instance redirectors
_MovePenBy(void * p,BPoint delta)35 static void _MovePenBy(void *p, BPoint delta) { return ((PictureIterator *) p)->MovePenBy(delta); }
_StrokeLine(void * p,BPoint start,BPoint end)36 static void _StrokeLine(void *p, BPoint start, BPoint end) { return ((PictureIterator *) p)->StrokeLine(start, end); }
_StrokeRect(void * p,BRect rect)37 static void _StrokeRect(void *p, BRect rect) { return ((PictureIterator *) p)->StrokeRect(rect); }
_FillRect(void * p,BRect rect)38 static void _FillRect(void *p, BRect rect) { return ((PictureIterator *) p)->FillRect(rect); }
_StrokeRoundRect(void * p,BRect rect,BPoint radii)39 static void _StrokeRoundRect(void *p, BRect rect, BPoint radii) { return ((PictureIterator *) p)->StrokeRoundRect(rect, radii); }
_FillRoundRect(void * p,BRect rect,BPoint radii)40 static void _FillRoundRect(void *p, BRect rect, BPoint radii) { return ((PictureIterator *) p)->FillRoundRect(rect, radii); }
_StrokeBezier(void * p,BPoint * control)41 static void _StrokeBezier(void *p, BPoint *control) { return ((PictureIterator *) p)->StrokeBezier(control); }
_FillBezier(void * p,BPoint * control)42 static void _FillBezier(void *p, BPoint *control) { return ((PictureIterator *) p)->FillBezier(control); }
_StrokeArc(void * p,BPoint center,BPoint radii,float startTheta,float arcTheta)43 static void _StrokeArc(void *p, BPoint center, BPoint radii, float startTheta, float arcTheta) { return ((PictureIterator *) p)->StrokeArc(center, radii, startTheta, arcTheta); }
_FillArc(void * p,BPoint center,BPoint radii,float startTheta,float arcTheta)44 static void _FillArc(void *p, BPoint center, BPoint radii, float startTheta, float arcTheta) { return ((PictureIterator *) p)->FillArc(center, radii, startTheta, arcTheta); }
_StrokeEllipse(void * p,BPoint center,BPoint radii)45 static void _StrokeEllipse(void *p, BPoint center, BPoint radii) { return ((PictureIterator *) p)->StrokeEllipse(center, radii); }
_FillEllipse(void * p,BPoint center,BPoint radii)46 static void _FillEllipse(void *p, BPoint center, BPoint radii) { return ((PictureIterator *) p)->FillEllipse(center, radii); }
_StrokePolygon(void * p,int32 numPoints,BPoint * points,bool isClosed)47 static void _StrokePolygon(void *p, int32 numPoints, BPoint *points, bool isClosed) { return ((PictureIterator *) p)->StrokePolygon(numPoints, points, isClosed); }
_FillPolygon(void * p,int32 numPoints,BPoint * points,bool isClosed)48 static void _FillPolygon(void *p, int32 numPoints, BPoint *points, bool isClosed) { return ((PictureIterator *) p)->FillPolygon(numPoints, points, isClosed); }
_StrokeShape(void * p,BShape * shape)49 static void _StrokeShape(void * p, BShape *shape) { return ((PictureIterator *) p)->StrokeShape(shape); }
_FillShape(void * p,BShape * shape)50 static void _FillShape(void * p, BShape *shape) { return ((PictureIterator *) p)->FillShape(shape); }
_DrawString(void * p,char * string,float deltax,float deltay)51 static void _DrawString(void *p, char *string, float deltax, float deltay) { return ((PictureIterator *) p)->DrawString(string, deltax, deltay); }
_DrawPixels(void * p,BRect src,BRect dest,int32 width,int32 height,int32 bytesPerRow,int32 pixelFormat,int32 flags,void * data)52 static void _DrawPixels(void *p, BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data)
53 { return ((PictureIterator *) p)->DrawPixels(src, dest, width, height, bytesPerRow, pixelFormat, flags, data); }
_SetClippingRects(void * p,BRect * rects,uint32 numRects)54 static void _SetClippingRects(void *p, BRect *rects, uint32 numRects) { return ((PictureIterator *) p)->SetClippingRects(rects, numRects); }
_ClipToPicture(void * p,BPicture * picture,BPoint point,bool clip_to_inverse_picture)55 static void _ClipToPicture(void * p, BPicture *picture, BPoint point, bool clip_to_inverse_picture) { return ((PictureIterator *) p)->ClipToPicture(picture, point, clip_to_inverse_picture); }
_PushState(void * p)56 static void _PushState(void *p) { return ((PictureIterator *) p)->PushState(); }
_PopState(void * p)57 static void _PopState(void *p) { return ((PictureIterator *) p)->PopState(); }
_EnterStateChange(void * p)58 static void _EnterStateChange(void *p) { return ((PictureIterator *) p)->EnterStateChange(); }
_ExitStateChange(void * p)59 static void _ExitStateChange(void *p) { return ((PictureIterator *) p)->ExitStateChange(); }
_EnterFontState(void * p)60 static void _EnterFontState(void *p) { return ((PictureIterator *) p)->EnterFontState(); }
_ExitFontState(void * p)61 static void _ExitFontState(void *p) { return ((PictureIterator *) p)->ExitFontState(); }
_SetOrigin(void * p,BPoint pt)62 static void _SetOrigin(void *p, BPoint pt) { return ((PictureIterator *) p)->SetOrigin(pt); }
_SetPenLocation(void * p,BPoint pt)63 static void _SetPenLocation(void *p, BPoint pt) { return ((PictureIterator *) p)->SetPenLocation(pt); }
_SetDrawingMode(void * p,drawing_mode mode)64 static void _SetDrawingMode(void *p, drawing_mode mode) { return ((PictureIterator *) p)->SetDrawingMode(mode); }
_SetLineMode(void * p,cap_mode capMode,join_mode joinMode,float miterLimit)65 static void _SetLineMode(void *p, cap_mode capMode, join_mode joinMode, float miterLimit) { return ((PictureIterator *) p)->SetLineMode(capMode, joinMode, miterLimit); }
_SetPenSize(void * p,float size)66 static void _SetPenSize(void *p, float size) { return ((PictureIterator *) p)->SetPenSize(size); }
_SetForeColor(void * p,rgb_color color)67 static void _SetForeColor(void *p, rgb_color color) { return ((PictureIterator *) p)->SetForeColor(color); }
_SetBackColor(void * p,rgb_color color)68 static void _SetBackColor(void *p, rgb_color color) { return ((PictureIterator *) p)->SetBackColor(color); }
_SetStipplePattern(void * p,pattern pat)69 static void _SetStipplePattern(void *p, pattern pat) { return ((PictureIterator *) p)->SetStipplePattern(pat); }
_SetScale(void * p,float scale)70 static void _SetScale(void *p, float scale) { return ((PictureIterator *) p)->SetScale(scale); }
_SetFontFamily(void * p,char * family)71 static void _SetFontFamily(void *p, char *family) { return ((PictureIterator *) p)->SetFontFamily(family); }
_SetFontStyle(void * p,char * style)72 static void _SetFontStyle(void *p, char *style) { return ((PictureIterator *) p)->SetFontStyle(style); }
_SetFontSpacing(void * p,int32 spacing)73 static void _SetFontSpacing(void *p, int32 spacing) { return ((PictureIterator *) p)->SetFontSpacing(spacing); }
_SetFontSize(void * p,float size)74 static void _SetFontSize(void *p, float size) { return ((PictureIterator *) p)->SetFontSize(size); }
_SetFontRotate(void * p,float rotation)75 static void _SetFontRotate(void *p, float rotation) { return ((PictureIterator *) p)->SetFontRotate(rotation); }
_SetFontEncoding(void * p,int32 encoding)76 static void _SetFontEncoding(void *p, int32 encoding) { return ((PictureIterator *) p)->SetFontEncoding(encoding); }
_SetFontFlags(void * p,int32 flags)77 static void _SetFontFlags(void *p, int32 flags) { return ((PictureIterator *) p)->SetFontFlags(flags); }
_SetFontShear(void * p,float shear)78 static void _SetFontShear(void *p, float shear) { return ((PictureIterator *) p)->SetFontShear(shear); }
_SetFontFace(void * p,int32 flags)79 static void _SetFontFace(void * p, int32 flags) { return ((PictureIterator *) p)->SetFontFace(flags); }
80
81 // undefined or undocumented operation handlers...
_op0(void * p)82 static void _op0(void * p) { return ((PictureIterator *) p)->Op(0); }
_op19(void * p)83 static void _op19(void * p) { return ((PictureIterator *) p)->Op(19); }
_op45(void * p)84 static void _op45(void * p) { return ((PictureIterator *) p)->Op(45); }
_op47(void * p)85 static void _op47(void * p) { return ((PictureIterator *) p)->Op(47); }
_op48(void * p)86 static void _op48(void * p) { return ((PictureIterator *) p)->Op(48); }
_op49(void * p)87 static void _op49(void * p) { return ((PictureIterator *) p)->Op(49); }
88
89 // Private Variables
90 // -----------------
91
92 static void *
93 playbackHandlers[] = {
94 (void *)_op0, // 0 no operation
95 (void *)_MovePenBy, // 1 MovePenBy(void *user, BPoint delta)
96 (void *)_StrokeLine, // 2 StrokeLine(void *user, BPoint start, BPoint end)
97 (void *)_StrokeRect, // 3 StrokeRect(void *user, BRect rect)
98 (void *)_FillRect, // 4 FillRect(void *user, BRect rect)
99 (void *)_StrokeRoundRect, // 5 StrokeRoundRect(void *user, BRect rect, BPoint radii)
100 (void *)_FillRoundRect, // 6 FillRoundRect(void *user, BRect rect, BPoint radii)
101 (void *)_StrokeBezier, // 7 StrokeBezier(void *user, BPoint *control)
102 (void *)_FillBezier, // 8 FillBezier(void *user, BPoint *control)
103 (void *)_StrokeArc, // 9 StrokeArc(void *user, BPoint center, BPoint radii, float startTheta, float arcTheta)
104 (void *)_FillArc, // 10 FillArc(void *user, BPoint center, BPoint radii, float startTheta, float arcTheta)
105 (void *)_StrokeEllipse, // 11 StrokeEllipse(void *user, BPoint center, BPoint radii)
106 (void *)_FillEllipse, // 12 FillEllipse(void *user, BPoint center, BPoint radii)
107 (void *)_StrokePolygon, // 13 StrokePolygon(void *user, int32 numPoints, BPoint *points, bool isClosed)
108 (void *)_FillPolygon, // 14 FillPolygon(void *user, int32 numPoints, BPoint *points, bool isClosed)
109 (void *)_StrokeShape, // 15 StrokeShape(void *user, BShape *shape)
110 (void *)_FillShape, // 16 FillShape(void *user, BShape *shape)
111 (void *)_DrawString, // 17 DrawString(void *user, char *string, float deltax, float deltay)
112 (void *)_DrawPixels, // 18 DrawPixels(void *user, BRect src, BRect dest, int32 width, int32 height, int32 bytesPerRow, int32 pixelFormat, int32 flags, void *data)
113 (void *)_op19, // 19 *reserved*
114 (void *)_SetClippingRects, // 20 SetClippingRects(void *user, BRect *rects, uint32 numRects)
115 (void *)_ClipToPicture, // 21 ClipToPicture(void *user, BPicture *picture, BPoint pt, bool clip_to_inverse_picture)
116 (void *)_PushState, // 22 PushState(void *user)
117 (void *)_PopState, // 23 PopState(void *user)
118 (void *)_EnterStateChange, // 24 EnterStateChange(void *user)
119 (void *)_ExitStateChange, // 25 ExitStateChange(void *user)
120 (void *)_EnterFontState, // 26 EnterFontState(void *user)
121 (void *)_ExitFontState, // 27 ExitFontState(void *user)
122 (void *)_SetOrigin, // 28 SetOrigin(void *user, BPoint pt)
123 (void *)_SetPenLocation, // 29 SetPenLocation(void *user, BPoint pt)
124 (void *)_SetDrawingMode, // 30 SetDrawingMode(void *user, drawing_mode mode)
125 (void *)_SetLineMode, // 31 SetLineMode(void *user, cap_mode capMode, join_mode joinMode, float miterLimit)
126 (void *)_SetPenSize, // 32 SetPenSize(void *user, float size)
127 (void *)_SetForeColor, // 33 SetForeColor(void *user, rgb_color color)
128 (void *)_SetBackColor, // 34 SetBackColor(void *user, rgb_color color)
129 (void *)_SetStipplePattern, // 35 SetStipplePattern(void *user, pattern p)
130 (void *)_SetScale, // 36 SetScale(void *user, float scale)
131 (void *)_SetFontFamily, // 37 SetFontFamily(void *user, char *family)
132 (void *)_SetFontStyle, // 38 SetFontStyle(void *user, char *style)
133 (void *)_SetFontSpacing, // 39 SetFontSpacing(void *user, int32 spacing)
134 (void *)_SetFontSize, // 40 SetFontSize(void *user, float size)
135 (void *)_SetFontRotate, // 41 SetFontRotate(void *user, float rotation)
136 (void *)_SetFontEncoding, // 42 SetFontEncoding(void *user, int32 encoding)
137 (void *)_SetFontFlags, // 43 SetFontFlags(void *user, int32 flags)
138 (void *)_SetFontShear, // 44 SetFontShear(void *user, float shear)
139 (void *)_op45, // 45 *reserved*
140 (void *)_SetFontFace, // 46 SetFontFace(void *user, int32 flags)
141 (void *)_op47,
142 (void *)_op48,
143 (void *)_op49,
144
145 NULL
146 };
147
148 void
Iterate(BPicture * picture)149 PictureIterator::Iterate(BPicture* picture) {
150 picture->Play(playbackHandlers, 50, this);
151 }
152