2006-02-11 00:38:53 +03:00
|
|
|
/*
|
Fix some cases of updating draw state while recording a BPicture
* Also implemented recording DrawString(string, length,
BPoint[] locations), which was previously not recorded at all.
* Also implemented playing back recently added drawing commands
in PicturePlayer.cpp. I don't quite understand what this is
actually used for, but it seemed it was forgotten. I just followed
the pattern already established in the code.
* The other important bit in this change is to update the pen
location when it is needed while recording a BPicture. Often
the BView will use PenLocation() in order to transmit drawing
commands to the app_server which use absolute coordinates only.
This isn't actually so nice, since it means the client has to
wait for the server to transmit the current pen location. If there
were dedicated link-commands for pen-relative drawing commands,
the client could just keep sending without waiting for the server.
In any case, the app_server needs to update the pen location in
the current DrawState and even the DrawingEngine even while
recording a picture, because some next command may need up-2-date
state information, such as the font state and the pen location.
* I have not yet tried to find /all/ instances where the DrawState
needs to be updated while recording. This change should repair
/all/ font state changes, all versions of drawing a string, and
all versions of StrokeLine().
Change-Id: Ia0f23e7b1cd058f70f76a5849acb2d02e0f0da09
Reviewed-on: https://review.haiku-os.org/c/817
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2019-01-02 20:48:12 +03:00
|
|
|
* Copyright 2001-2018, Haiku Inc.
|
2006-02-11 00:38:53 +03:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Marc Flerackers (mflerackers@androme.be)
|
2007-08-16 18:40:03 +04:00
|
|
|
* Stefano Ceccherini (stefano.ceccherini@gmail.com)
|
2007-03-02 02:17:40 +03:00
|
|
|
* Marcus Overhagen (marcus@overhagen.de)
|
Fix some cases of updating draw state while recording a BPicture
* Also implemented recording DrawString(string, length,
BPoint[] locations), which was previously not recorded at all.
* Also implemented playing back recently added drawing commands
in PicturePlayer.cpp. I don't quite understand what this is
actually used for, but it seemed it was forgotten. I just followed
the pattern already established in the code.
* The other important bit in this change is to update the pen
location when it is needed while recording a BPicture. Often
the BView will use PenLocation() in order to transmit drawing
commands to the app_server which use absolute coordinates only.
This isn't actually so nice, since it means the client has to
wait for the server to transmit the current pen location. If there
were dedicated link-commands for pen-relative drawing commands,
the client could just keep sending without waiting for the server.
In any case, the app_server needs to update the pen location in
the current DrawState and even the DrawingEngine even while
recording a picture, because some next command may need up-2-date
state information, such as the font state and the pen location.
* I have not yet tried to find /all/ instances where the DrawState
needs to be updated while recording. This change should repair
/all/ font state changes, all versions of drawing a string, and
all versions of StrokeLine().
Change-Id: Ia0f23e7b1cd058f70f76a5849acb2d02e0f0da09
Reviewed-on: https://review.haiku-os.org/c/817
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2019-01-02 20:48:12 +03:00
|
|
|
* Stephan Aßmus <superstippi@gmx.de>
|
2006-02-11 00:38:53 +03:00
|
|
|
*/
|
2007-10-16 00:13:55 +04:00
|
|
|
#ifndef _PICTURE_PLAYER_H
|
|
|
|
#define _PICTURE_PLAYER_H
|
2006-02-11 00:38:53 +03:00
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
/*! PicturePlayer is used to play picture data. */
|
2006-01-18 00:39:07 +03:00
|
|
|
|
|
|
|
|
|
|
|
#include <GraphicsDefs.h>
|
2015-09-05 15:43:19 +03:00
|
|
|
#include <InterfaceDefs.h>
|
2006-01-18 00:39:07 +03:00
|
|
|
#include <Point.h>
|
|
|
|
#include <Rect.h>
|
|
|
|
|
2015-09-05 15:43:19 +03:00
|
|
|
|
|
|
|
class BAffineTransform;
|
2020-05-28 04:46:32 +03:00
|
|
|
class BGradient;
|
2007-10-16 00:13:55 +04:00
|
|
|
class BList;
|
2015-09-05 15:43:19 +03:00
|
|
|
class BPicture;
|
|
|
|
class BShape;
|
2015-11-11 01:09:54 +03:00
|
|
|
class Layer;
|
2007-10-16 00:13:55 +04:00
|
|
|
|
2006-01-18 00:39:07 +03:00
|
|
|
|
2007-08-16 18:40:03 +04:00
|
|
|
namespace BPrivate {
|
|
|
|
|
2015-09-05 15:43:19 +03:00
|
|
|
|
|
|
|
struct picture_player_callbacks {
|
|
|
|
void (*move_pen_by)(void* userData, const BPoint& where);
|
|
|
|
void (*stroke_line)(void* userData, const BPoint& start, const BPoint& end);
|
|
|
|
void (*draw_rect)(void* userData, const BRect& rect, bool fill);
|
|
|
|
void (*draw_round_rect)(void* userData, const BRect& rect,
|
|
|
|
const BPoint& radii, bool fill);
|
|
|
|
void (*draw_bezier)(void* userData, size_t numControlPoints,
|
|
|
|
const BPoint controlPoints[], bool fill);
|
|
|
|
void (*draw_arc)(void* userData, const BPoint& center, const BPoint& radii,
|
|
|
|
float startTheta, float arcTheta, bool fill);
|
|
|
|
void (*draw_ellipse)(void* userData, const BRect& rect, bool fill);
|
|
|
|
void (*draw_polygon)(void* userData, size_t numPoints,
|
|
|
|
const BPoint points[], bool isClosed, bool fill);
|
|
|
|
void (*draw_shape)(void* userData, const BShape& shape, bool fill);
|
|
|
|
void (*draw_string)(void* userData, const char* string, size_t length,
|
|
|
|
float spaceEscapement, float nonSpaceEscapement);
|
|
|
|
void (*draw_pixels)(void* userData, const BRect& source,
|
|
|
|
const BRect& destination, uint32 width, uint32 height,
|
|
|
|
size_t bytesPerRow, color_space pixelFormat, uint32 flags,
|
|
|
|
const void* data, size_t length);
|
|
|
|
void (*draw_picture)(void* userData, const BPoint& where, int32 token);
|
|
|
|
void (*set_clipping_rects)(void* userData, size_t numRects,
|
|
|
|
const BRect rects[]);
|
2015-09-05 21:59:06 +03:00
|
|
|
void (*clip_to_picture)(void* userData, int32 token,
|
2015-09-05 15:43:19 +03:00
|
|
|
const BPoint& where, bool clipToInverse);
|
|
|
|
void (*push_state)(void* userData);
|
|
|
|
void (*pop_state)(void* userData);
|
|
|
|
void (*enter_state_change)(void* userData);
|
|
|
|
void (*exit_state_change)(void* userData);
|
|
|
|
void (*enter_font_state)(void* userData);
|
|
|
|
void (*exit_font_state)(void* userData);
|
|
|
|
void (*set_origin)(void* userData, const BPoint& origin);
|
|
|
|
void (*set_pen_location)(void* userData, const BPoint& location);
|
|
|
|
void (*set_drawing_mode)(void* userData, drawing_mode mode);
|
|
|
|
void (*set_line_mode)(void* userData, cap_mode capMode, join_mode joinMode,
|
|
|
|
float miterLimit);
|
|
|
|
void (*set_pen_size)(void* userData, float size);
|
|
|
|
void (*set_fore_color)(void* userData, const rgb_color& color);
|
|
|
|
void (*set_back_color)(void* userData, const rgb_color& color);
|
|
|
|
void (*set_stipple_pattern)(void* userData, const pattern& patter);
|
|
|
|
void (*set_scale)(void* userData, float scale);
|
|
|
|
void (*set_font_family)(void* userData, const char* familyName,
|
|
|
|
size_t length);
|
|
|
|
void (*set_font_style)(void* userData, const char* styleName,
|
|
|
|
size_t length);
|
|
|
|
void (*set_font_spacing)(void* userData, uint8 spacing);
|
|
|
|
void (*set_font_size)(void* userData, float size);
|
|
|
|
void (*set_font_rotation)(void* userData, float rotation);
|
|
|
|
void (*set_font_encoding)(void* userData, uint8 encoding);
|
|
|
|
void (*set_font_flags)(void* userData, uint32 flags);
|
|
|
|
void (*set_font_shear)(void* userData, float shear);
|
|
|
|
void (*set_font_face)(void* userData, uint16 face);
|
|
|
|
void (*set_blending_mode)(void* userData, source_alpha alphaSourceMode,
|
|
|
|
alpha_function alphaFunctionMode);
|
|
|
|
void (*set_transform)(void* userData, const BAffineTransform& transform);
|
2015-11-11 00:52:56 +03:00
|
|
|
void (*translate_by)(void* userData, double x, double y);
|
|
|
|
void (*scale_by)(void* userData, double x, double y);
|
|
|
|
void (*rotate_by)(void* userData, double angleRadians);
|
2015-11-11 01:09:54 +03:00
|
|
|
void (*blend_layer)(void* userData, Layer* layer);
|
2015-11-09 21:57:13 +03:00
|
|
|
void (*clip_to_rect)(void* userData, const BRect& rect, bool inverse);
|
|
|
|
void (*clip_to_shape)(void* userData, int32 opCount, const uint32 opList[],
|
|
|
|
int32 ptCount, const BPoint ptList[], bool inverse);
|
Fix some cases of updating draw state while recording a BPicture
* Also implemented recording DrawString(string, length,
BPoint[] locations), which was previously not recorded at all.
* Also implemented playing back recently added drawing commands
in PicturePlayer.cpp. I don't quite understand what this is
actually used for, but it seemed it was forgotten. I just followed
the pattern already established in the code.
* The other important bit in this change is to update the pen
location when it is needed while recording a BPicture. Often
the BView will use PenLocation() in order to transmit drawing
commands to the app_server which use absolute coordinates only.
This isn't actually so nice, since it means the client has to
wait for the server to transmit the current pen location. If there
were dedicated link-commands for pen-relative drawing commands,
the client could just keep sending without waiting for the server.
In any case, the app_server needs to update the pen location in
the current DrawState and even the DrawingEngine even while
recording a picture, because some next command may need up-2-date
state information, such as the font state and the pen location.
* I have not yet tried to find /all/ instances where the DrawState
needs to be updated while recording. This change should repair
/all/ font state changes, all versions of drawing a string, and
all versions of StrokeLine().
Change-Id: Ia0f23e7b1cd058f70f76a5849acb2d02e0f0da09
Reviewed-on: https://review.haiku-os.org/c/817
Reviewed-by: Stephan Aßmus <superstippi@gmx.de>
2019-01-02 20:48:12 +03:00
|
|
|
void (*draw_string_locations)(void* userData, const char* string,
|
|
|
|
size_t length, const BPoint locations[], size_t locationCount);
|
2020-05-28 04:46:32 +03:00
|
|
|
void (*draw_rect_gradient)(void* userData, const BRect& rect, BGradient& gradient, bool fill);
|
|
|
|
void (*draw_round_rect_gradient)(void* userData, const BRect& rect, const BPoint& radii, BGradient& gradient, bool fill);
|
|
|
|
void (*draw_bezier_gradient)(void* userData, size_t numControlPoints, const BPoint controlPoints[], BGradient& gradient, bool fill);
|
|
|
|
void (*draw_arc_gradient)(void* userData, const BPoint& center, const BPoint& radii, float startTheta, float arcTheta, BGradient& gradient, bool fill);
|
|
|
|
void (*draw_ellipse_gradient)(void* userData, const BRect& rect, BGradient& gradient, bool fill);
|
|
|
|
void (*draw_polygon_gradient)(void* userData, size_t numPoints, const BPoint points[], bool isClosed, BGradient& gradient, bool fill);
|
|
|
|
void (*draw_shape_gradient)(void* userData, const BShape& shape, BGradient& gradient, bool fill);
|
2020-06-10 09:40:14 +03:00
|
|
|
void (*set_fill_rule)(void* userData, int32 fillRule);
|
2015-09-05 15:43:19 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-02-11 00:38:53 +03:00
|
|
|
class PicturePlayer {
|
2006-01-18 00:39:07 +03:00
|
|
|
public:
|
2007-10-16 00:13:55 +04:00
|
|
|
PicturePlayer();
|
2015-09-05 15:43:19 +03:00
|
|
|
PicturePlayer(const void* data, size_t size, BList* pictures);
|
2007-10-16 00:13:55 +04:00
|
|
|
virtual ~PicturePlayer();
|
2006-01-18 00:39:07 +03:00
|
|
|
|
2015-09-05 15:43:19 +03:00
|
|
|
status_t Play(void** callbacks, int32 tableEntries,
|
|
|
|
void* userData);
|
|
|
|
status_t Play(const picture_player_callbacks& callbacks,
|
|
|
|
size_t callbacksSize, void* userData);
|
2006-01-18 00:39:07 +03:00
|
|
|
|
|
|
|
private:
|
2015-09-05 15:43:19 +03:00
|
|
|
status_t _Play(const picture_player_callbacks& callbacks, void* userData,
|
|
|
|
const void* data, size_t length, uint16 parentOp);
|
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
const void* fData;
|
|
|
|
size_t fSize;
|
|
|
|
BList* fPictures;
|
2006-01-18 00:39:07 +03:00
|
|
|
};
|
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
} // namespace BPrivate
|
2007-08-16 18:40:03 +04:00
|
|
|
|
2007-10-16 00:13:55 +04:00
|
|
|
#endif // _PICTURE_PLAYER_H
|