PicturePlayer: Use C++ virtual interface instead of C function table
Also use C function table instead of `void*` table function casts. Improve type safety and readability. Change-Id: Ie5f544b5c2bb9f2333fe3353462325dbfb4453ec Reviewed-on: https://review.haiku-os.org/c/haiku/+/9656 Reviewed-by: Adrien Destugues <[email protected]> Tested-by: Commit checker robot <[email protected]> Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
@@ -32,78 +32,184 @@ class Layer;
|
|||||||
namespace BPrivate {
|
namespace BPrivate {
|
||||||
|
|
||||||
|
|
||||||
struct picture_player_callbacks {
|
struct picture_player_callbacks_compat {
|
||||||
void (*move_pen_by)(void* userData, const BPoint& where);
|
/* 0 */ void (*nop)(void* user);
|
||||||
void (*stroke_line)(void* userData, const BPoint& start, const BPoint& end);
|
/* 1 */ void (*move_pen_by)(void* user, BPoint delta);
|
||||||
void (*draw_rect)(void* userData, const BRect& rect, bool fill);
|
/* 2 */ void (*stroke_line)(void* user, BPoint start, BPoint end);
|
||||||
void (*draw_round_rect)(void* userData, const BRect& rect,
|
/* 3 */ void (*stroke_rect)(void* user, BRect rect);
|
||||||
const BPoint& radii, bool fill);
|
/* 4 */ void (*fill_rect)(void* user, BRect rect);
|
||||||
void (*draw_bezier)(void* userData, const BPoint controlPoints[4], bool fill);
|
/* 5 */ void (*stroke_round_rect)(void* user, BRect rect, BPoint radii);
|
||||||
void (*draw_arc)(void* userData, const BPoint& center, const BPoint& radii,
|
/* 6 */ void (*fill_round_rect)(void* user, BRect rect, BPoint radii);
|
||||||
float startTheta, float arcTheta, bool fill);
|
/* 7 */ void (*stroke_bezier)(void* user, BPoint* control);
|
||||||
void (*draw_ellipse)(void* userData, const BRect& rect, bool fill);
|
/* 8 */ void (*fill_bezier)(void* user, BPoint* control);
|
||||||
void (*draw_polygon)(void* userData, size_t numPoints,
|
/* 9 */ void (*stroke_arc)(void* user, BPoint center, BPoint radii, float startTheta,
|
||||||
const BPoint points[], bool isClosed, bool fill);
|
float arcTheta);
|
||||||
void (*draw_shape)(void* userData, const BShape& shape, bool fill);
|
/* 10 */ void (*fill_arc)(void* user, BPoint center, BPoint radii, float startTheta,
|
||||||
void (*draw_string)(void* userData, const char* string, size_t length,
|
float arcTheta);
|
||||||
float spaceEscapement, float nonSpaceEscapement);
|
/* 11 */ void (*stroke_ellipse)(void* user, BPoint center, BPoint radii);
|
||||||
void (*draw_pixels)(void* userData, const BRect& source,
|
/* 12 */ void (*fill_ellipse)(void* user, BPoint center, BPoint radii);
|
||||||
const BRect& destination, uint32 width, uint32 height,
|
/* 13 */ void (*stroke_polygon)(void* user, int32 numPoints, const BPoint* points,
|
||||||
size_t bytesPerRow, color_space pixelFormat, uint32 flags,
|
bool isClosed);
|
||||||
const void* data, size_t length);
|
/* 14 */ void (*fill_polygon)(void* user, int32 numPoints, const BPoint* points,
|
||||||
void (*draw_picture)(void* userData, const BPoint& where, int32 token);
|
bool isClosed);
|
||||||
void (*set_clipping_rects)(void* userData, size_t numRects,
|
// Called "Reserved" in BeBook
|
||||||
const clipping_rect rects[]);
|
/* 15 */ void (*stroke_shape)(void* user, const BShape *shape);
|
||||||
void (*clip_to_picture)(void* userData, int32 token,
|
// Called "Reserved" in BeBook
|
||||||
const BPoint& where, bool clipToInverse);
|
/* 16 */ void (*fill_shape)(void* user, const BShape *shape);
|
||||||
void (*push_state)(void* userData);
|
/* 17 */ void (*draw_string)(void* user, const char* string, float deltax, float deltay);
|
||||||
void (*pop_state)(void* userData);
|
/* 18 */ void (*draw_pixels)(void* user, BRect src, BRect dest, int32 width, int32 height,
|
||||||
void (*enter_state_change)(void* userData);
|
int32 bytesPerRow, int32 pixelFormat, int32 flags, const void* data);
|
||||||
void (*exit_state_change)(void* userData);
|
// Called "Reserved" in BeBook
|
||||||
void (*enter_font_state)(void* userData);
|
/* 19 */ void (*draw_picture)(void* user, BPoint where, int32 token);
|
||||||
void (*exit_font_state)(void* userData);
|
/* 20 */ void (*set_clipping_rects)(void* user, const BRect* rects, uint32 numRects);
|
||||||
void (*set_origin)(void* userData, const BPoint& origin);
|
// Called "Reserved" in BeBook
|
||||||
void (*set_pen_location)(void* userData, const BPoint& location);
|
/* 21 */ void (*clip_to_picture)(void* user, int32 token, BPoint point,
|
||||||
void (*set_drawing_mode)(void* userData, drawing_mode mode);
|
bool clip_to_inverse_picture);
|
||||||
void (*set_line_mode)(void* userData, cap_mode capMode, join_mode joinMode,
|
/* 22 */ void (*push_state)(void* user);
|
||||||
|
/* 23 */ void (*pop_state)(void* user);
|
||||||
|
/* 24 */ void (*enter_state_change)(void* user);
|
||||||
|
/* 25 */ void (*exit_state_change)(void* user);
|
||||||
|
/* 26 */ void (*enter_font_state)(void* user);
|
||||||
|
/* 27 */ void (*exit_font_state)(void* user);
|
||||||
|
/* 28 */ void (*set_origin)(void* user, BPoint pt);
|
||||||
|
/* 29 */ void (*set_pen_location)(void* user, BPoint pt);
|
||||||
|
/* 30 */ void (*set_drawing_mode)(void* user, drawing_mode mode);
|
||||||
|
/* 31 */ void (*set_line_mode)(void* user, cap_mode capMode, join_mode joinMode,
|
||||||
float miterLimit);
|
float miterLimit);
|
||||||
void (*set_pen_size)(void* userData, float size);
|
/* 32 */ void (*set_pen_size)(void* user, float size);
|
||||||
void (*set_fore_color)(void* userData, const rgb_color& color);
|
/* 33 */ void (*set_fore_color)(void* user, rgb_color color);
|
||||||
void (*set_back_color)(void* userData, const rgb_color& color);
|
/* 34 */ void (*set_back_color)(void* user, rgb_color color);
|
||||||
void (*set_stipple_pattern)(void* userData, const pattern& patter);
|
/* 35 */ void (*set_stipple_pattern)(void* user, pattern p);
|
||||||
void (*set_scale)(void* userData, float scale);
|
/* 36 */ void (*set_scale)(void* user, float scale);
|
||||||
void (*set_font_family)(void* userData, const char* familyName,
|
/* 37 */ void (*set_font_family)(void* user, const char* family);
|
||||||
size_t length);
|
/* 38 */ void (*set_font_style)(void* user, const char* style);
|
||||||
void (*set_font_style)(void* userData, const char* styleName,
|
/* 39 */ void (*set_font_spacing)(void* user, int32 spacing);
|
||||||
size_t length);
|
/* 40 */ void (*set_font_size)(void* user, float size);
|
||||||
void (*set_font_spacing)(void* userData, uint8 spacing);
|
/* 41 */ void (*set_font_rotate)(void* user, float rotation);
|
||||||
void (*set_font_size)(void* userData, float size);
|
/* 42 */ void (*set_font_encoding)(void* user, int32 encoding);
|
||||||
void (*set_font_rotation)(void* userData, float rotation);
|
/* 43 */ void (*set_font_flags)(void* user, int32 flags);
|
||||||
void (*set_font_encoding)(void* userData, uint8 encoding);
|
/* 44 */ void (*set_font_shear)(void* user, float shear);
|
||||||
void (*set_font_flags)(void* userData, uint32 flags);
|
// Called "Reserved" in BeBook
|
||||||
void (*set_font_shear)(void* userData, float shear);
|
/* 45 */ void (*set_font_bpp)(void* user, int32 bpp);
|
||||||
void (*set_font_face)(void* userData, uint16 face);
|
/* 46 */ void (*set_font_face)(void* user, int32 flags);
|
||||||
void (*set_blending_mode)(void* userData, source_alpha alphaSourceMode,
|
|
||||||
alpha_function alphaFunctionMode);
|
// New in Haiku
|
||||||
void (*set_transform)(void* userData, const BAffineTransform& transform);
|
/* 47 */ void (*set_blending_mode)(void* user, source_alpha alphaSrcMode,
|
||||||
void (*translate_by)(void* userData, double x, double y);
|
alpha_function alphaFncMode);
|
||||||
void (*scale_by)(void* userData, double x, double y);
|
/* 48 */ void (*set_transform)(void* user, const BAffineTransform& transform);
|
||||||
void (*rotate_by)(void* userData, double angleRadians);
|
/* 49 */ void (*translate_by)(void* user, double x, double y);
|
||||||
void (*blend_layer)(void* userData, Layer* layer);
|
/* 50 */ void (*scale_by)(void* user, double x, double y);
|
||||||
void (*clip_to_rect)(void* userData, const BRect& rect, bool inverse);
|
/* 51 */ void (*rotate_by)(void* user, double angleRadians);
|
||||||
void (*clip_to_shape)(void* userData, int32 opCount, const uint32 opList[],
|
// Broken when saved to file
|
||||||
int32 ptCount, const BPoint ptList[], bool inverse);
|
/* 52 */ void (*blend_layer)(void* user, class Layer* layer);
|
||||||
void (*draw_string_locations)(void* userData, const char* string,
|
/* 53 */ void (*clip_to_rect)(void* user, const BRect& rect, bool inverse);
|
||||||
size_t length, const BPoint locations[], size_t locationCount);
|
// Why not BShape?
|
||||||
void (*draw_rect_gradient)(void* userData, const BRect& rect, BGradient& gradient, bool fill);
|
/* 54 */ void (*clip_to_shape)(void* user, int32 opCount, const uint32 opList[], int32 ptCount,
|
||||||
void (*draw_round_rect_gradient)(void* userData, const BRect& rect, const BPoint& radii, BGradient& gradient, bool fill);
|
const BPoint ptList[], bool inverse);
|
||||||
void (*draw_bezier_gradient)(void* userData, const BPoint controlPoints[4], BGradient& gradient, bool fill);
|
/* 55 */ void (*draw_string_locations)(void* user, const char* string, const BPoint* locations,
|
||||||
void (*draw_arc_gradient)(void* userData, const BPoint& center, const BPoint& radii, float startTheta, float arcTheta, BGradient& gradient, bool fill);
|
size_t locationCount);
|
||||||
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);
|
/* 56 */ void (*fill_rect_gradient)(void* user, BRect rect, const BGradient& gradient);
|
||||||
void (*draw_shape_gradient)(void* userData, const BShape& shape, BGradient& gradient, bool fill);
|
/* 57 */ void (*stroke_rect_gradient)(void* user, BRect rect, const BGradient& gradient);
|
||||||
void (*set_fill_rule)(void* userData, int32 fillRule);
|
/* 58 */ void (*fill_round_rect_gradient)(void* user, BRect rect, BPoint radii,
|
||||||
void (*stroke_line_gradient)(void* userData, const BPoint& start, const BPoint& end, const BGradient& gradient);
|
const BGradient& gradient);
|
||||||
|
/* 59 */ void (*stroke_round_rect_gradient)(void* user, BRect rect, BPoint radii,
|
||||||
|
const BGradient& gradient);
|
||||||
|
/* 60 */ void (*fill_bezier_gradient)(void* user, const BPoint* points,
|
||||||
|
const BGradient& gradient);
|
||||||
|
/* 61 */ void (*stroke_bezier_gradient)(void* user, const BPoint* points,
|
||||||
|
const BGradient& gradient);
|
||||||
|
/* 62 */ void (*fill_arc_gradient)(void* user, BPoint center, BPoint radii, float startTheta,
|
||||||
|
float arcTheta, const BGradient& gradient);
|
||||||
|
/* 63 */ void (*stroke_arc_gradient)(void* user, BPoint center, BPoint radii, float startTheta,
|
||||||
|
float arcTheta, const BGradient& gradient);
|
||||||
|
/* 64 */ void (*fill_ellipse_gradient)(void* user, BPoint center, BPoint radii,
|
||||||
|
const BGradient& gradient);
|
||||||
|
/* 65 */ void (*stroke_ellipse_gradient)(void* user, BPoint center, BPoint radii,
|
||||||
|
const BGradient& gradient);
|
||||||
|
/* 66 */ void (*fill_polygon_gradient)(void* user, int32 numPoints, const BPoint* points,
|
||||||
|
bool isClosed, const BGradient& gradient);
|
||||||
|
/* 67 */ void (*stroke_polygon_gradient)(void* user, int32 numPoints, const BPoint* points,
|
||||||
|
bool isClosed, const BGradient& gradient);
|
||||||
|
/* 68 */ void (*fill_shape_gradient)(void* user, BShape shape, const BGradient& gradient);
|
||||||
|
/* 69 */ void (*stroke_shape_gradient)(void* user, BShape shape, const BGradient& gradient);
|
||||||
|
|
||||||
|
/* 70 */ void (*set_fill_rule)(void* user, int32 fillRule);
|
||||||
|
|
||||||
|
/* 71 */ void (*stroke_line_gradient)(void* user, BPoint start, BPoint end,
|
||||||
|
const BGradient& gradient);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class PicturePlayerCallbacks {
|
||||||
|
public:
|
||||||
|
virtual void MovePenBy(const BPoint& where) {}
|
||||||
|
virtual void StrokeLine(const BPoint& start, const BPoint& end) {}
|
||||||
|
virtual void DrawRect(const BRect& rect, bool fill) {}
|
||||||
|
virtual void DrawRoundRect(const BRect& rect, const BPoint& radii, bool fill) {}
|
||||||
|
virtual void DrawBezier(const BPoint controlPoints[4], bool fill) {}
|
||||||
|
virtual void DrawArc(const BPoint& center, const BPoint& radii, float startTheta,
|
||||||
|
float arcTheta, bool fill) {}
|
||||||
|
virtual void DrawEllipse(const BRect& rect, bool fill) {}
|
||||||
|
virtual void DrawPolygon(size_t numPoints, const BPoint points[], bool isClosed, bool fill) {}
|
||||||
|
virtual void DrawShape(const BShape& shape, bool fill) {}
|
||||||
|
virtual void DrawString(const char* string, size_t length, float spaceEscapement,
|
||||||
|
float nonSpaceEscapement) {}
|
||||||
|
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
||||||
|
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
||||||
|
size_t length) {}
|
||||||
|
virtual void DrawPicture(const BPoint& where, int32 token) {}
|
||||||
|
virtual void SetClippingRects(size_t numRects, const clipping_rect rects[]) {}
|
||||||
|
virtual void ClipToPicture(int32 token, const BPoint& where, bool clipToInverse) {}
|
||||||
|
virtual void PushState() {}
|
||||||
|
virtual void PopState() {}
|
||||||
|
virtual void EnterStateChange() {}
|
||||||
|
virtual void ExitStateChange() {}
|
||||||
|
virtual void EnterFontState() {}
|
||||||
|
virtual void ExitFontState() {}
|
||||||
|
virtual void SetOrigin(const BPoint& origin) {}
|
||||||
|
virtual void SetPenLocation(const BPoint& location) {}
|
||||||
|
virtual void SetDrawingMode(drawing_mode mode) {}
|
||||||
|
virtual void SetLineMode(cap_mode capMode, join_mode joinMode, float miterLimit) {}
|
||||||
|
virtual void SetPenSize(float size) {}
|
||||||
|
virtual void SetForeColor(const rgb_color& color) {}
|
||||||
|
virtual void SetBackColor(const rgb_color& color) {}
|
||||||
|
virtual void SetStipplePattern(const pattern& patter) {}
|
||||||
|
virtual void SetScale(float scale) {}
|
||||||
|
virtual void SetFontFamily(const char* familyName, size_t length) {}
|
||||||
|
virtual void SetFontStyle(const char* styleName, size_t length) {}
|
||||||
|
virtual void SetFontSpacing(uint8 spacing) {}
|
||||||
|
virtual void SetFontSize(float size) {}
|
||||||
|
virtual void SetFontRotation(float rotation) {}
|
||||||
|
virtual void SetFontEncoding(uint8 encoding) {}
|
||||||
|
virtual void SetFontFlags(uint32 flags) {}
|
||||||
|
virtual void SetFontShear(float shear) {}
|
||||||
|
virtual void SetFontFace(uint16 face) {}
|
||||||
|
virtual void SetBlendingMode(source_alpha alphaSourceMode, alpha_function alphaFunctionMode) {}
|
||||||
|
virtual void SetTransform(const BAffineTransform& transform) {}
|
||||||
|
virtual void TranslateBy(double x, double y) {}
|
||||||
|
virtual void ScaleBy(double x, double y) {}
|
||||||
|
virtual void RotateBy(double angleRadians) {}
|
||||||
|
virtual void BlendLayer(Layer* layer) {}
|
||||||
|
virtual void ClipToRect(const BRect& rect, bool inverse) {}
|
||||||
|
virtual void ClipToShape(int32 opCount, const uint32 opList[], int32 ptCount,
|
||||||
|
const BPoint ptList[], bool inverse) {}
|
||||||
|
virtual void DrawStringLocations(const char* string, size_t length, const BPoint locations[],
|
||||||
|
size_t locationCount) {}
|
||||||
|
virtual void DrawRectGradient(const BRect& rect, BGradient& gradient, bool fill) {}
|
||||||
|
virtual void DrawRoundRectGradient(const BRect& rect, const BPoint& radii, BGradient& gradient,
|
||||||
|
bool fill) {}
|
||||||
|
virtual void DrawBezierGradient(const BPoint controlPoints[4], BGradient& gradient, bool fill)
|
||||||
|
{}
|
||||||
|
virtual void DrawArcGradient(const BPoint& center, const BPoint& radii, float startTheta,
|
||||||
|
float arcTheta, BGradient& gradient, bool fill) {}
|
||||||
|
virtual void DrawEllipseGradient(const BRect& rect, BGradient& gradient, bool fill) {}
|
||||||
|
virtual void DrawPolygonGradient(size_t numPoints, const BPoint points[], bool isClosed,
|
||||||
|
BGradient& gradient, bool fill) {}
|
||||||
|
virtual void DrawShapeGradient(const BShape& shape, BGradient& gradient, bool fill) {}
|
||||||
|
virtual void SetFillRule(int32 fillRule) {}
|
||||||
|
virtual void StrokeLineGradient(const BPoint& start, const BPoint& end,
|
||||||
|
const BGradient& gradient) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -115,11 +221,10 @@ public:
|
|||||||
|
|
||||||
status_t Play(void** callbacks, int32 tableEntries,
|
status_t Play(void** callbacks, int32 tableEntries,
|
||||||
void* userData);
|
void* userData);
|
||||||
status_t Play(const picture_player_callbacks& callbacks,
|
status_t Play(PicturePlayerCallbacks& callbacks);
|
||||||
size_t callbacksSize, void* userData);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
status_t _Play(const picture_player_callbacks& callbacks, void* userData,
|
status_t _Play(PicturePlayerCallbacks& callbacks,
|
||||||
const void* data, size_t length, uint16 parentOp);
|
const void* data, size_t length, uint16 parentOp);
|
||||||
|
|
||||||
const void* fData;
|
const void* fData;
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -142,6 +142,71 @@ private:
|
|||||||
// #pragma mark - Picture playback hooks
|
// #pragma mark - Picture playback hooks
|
||||||
|
|
||||||
|
|
||||||
|
class BoundingBoxCallbacks: public BPrivate::PicturePlayerCallbacks {
|
||||||
|
public:
|
||||||
|
BoundingBoxCallbacks(BoundingBoxState* const state);
|
||||||
|
|
||||||
|
virtual void MovePenBy(const BPoint& where);
|
||||||
|
virtual void StrokeLine(const BPoint& start, const BPoint& end);
|
||||||
|
virtual void DrawRect(const BRect& rect, bool fill);
|
||||||
|
virtual void DrawRoundRect(const BRect& rect, const BPoint& radii, bool fill);
|
||||||
|
virtual void DrawBezier(const BPoint controlPoints[4], bool fill);
|
||||||
|
virtual void DrawArc(const BPoint& center, const BPoint& radii, float startTheta,
|
||||||
|
float arcTheta, bool fill);
|
||||||
|
virtual void DrawEllipse(const BRect& rect, bool fill);
|
||||||
|
virtual void DrawPolygon(size_t numPoints, const BPoint points[], bool isClosed, bool fill);
|
||||||
|
virtual void DrawShape(const BShape& shape, bool fill);
|
||||||
|
virtual void DrawString(const char* string, size_t length, float spaceEscapement,
|
||||||
|
float nonSpaceEscapement);
|
||||||
|
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
||||||
|
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
||||||
|
size_t length);
|
||||||
|
virtual void DrawPicture(const BPoint& where, int32 token);
|
||||||
|
virtual void SetClippingRects(size_t numRects, const clipping_rect rects[]);
|
||||||
|
virtual void ClipToPicture(int32 token, const BPoint& where, bool clipToInverse);
|
||||||
|
virtual void PushState();
|
||||||
|
virtual void PopState();
|
||||||
|
virtual void EnterStateChange();
|
||||||
|
virtual void ExitStateChange();
|
||||||
|
virtual void EnterFontState();
|
||||||
|
virtual void ExitFontState();
|
||||||
|
virtual void SetOrigin(const BPoint& origin);
|
||||||
|
virtual void SetPenLocation(const BPoint& location);
|
||||||
|
virtual void SetDrawingMode(drawing_mode mode);
|
||||||
|
virtual void SetLineMode(cap_mode capMode, join_mode joinMode, float miterLimit);
|
||||||
|
virtual void SetPenSize(float size);
|
||||||
|
virtual void SetForeColor(const rgb_color& color);
|
||||||
|
virtual void SetBackColor(const rgb_color& color);
|
||||||
|
virtual void SetStipplePattern(const pattern& patter);
|
||||||
|
virtual void SetScale(float scale);
|
||||||
|
virtual void SetFontFamily(const char* familyName, size_t length);
|
||||||
|
virtual void SetFontStyle(const char* styleName, size_t length);
|
||||||
|
virtual void SetFontSpacing(uint8 spacing);
|
||||||
|
virtual void SetFontSize(float size);
|
||||||
|
virtual void SetFontRotation(float rotation);
|
||||||
|
virtual void SetFontEncoding(uint8 encoding);
|
||||||
|
virtual void SetFontFlags(uint32 flags);
|
||||||
|
virtual void SetFontShear(float shear);
|
||||||
|
virtual void SetFontFace(uint16 face);
|
||||||
|
virtual void SetBlendingMode(source_alpha alphaSourceMode, alpha_function alphaFunctionMode);
|
||||||
|
virtual void SetTransform(const BAffineTransform& transform);
|
||||||
|
virtual void TranslateBy(double x, double y);
|
||||||
|
virtual void ScaleBy(double x, double y);
|
||||||
|
virtual void RotateBy(double angleRadians);
|
||||||
|
virtual void BlendLayer(Layer* layer);
|
||||||
|
|
||||||
|
private:
|
||||||
|
BoundingBoxState* const fState;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
BoundingBoxCallbacks::BoundingBoxCallbacks(BoundingBoxState* const state)
|
||||||
|
:
|
||||||
|
fState(state)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_polygon_frame(const BPoint* points, int32 numPoints, BRect* frame)
|
get_polygon_frame(const BPoint* points, int32 numPoints, BRect* frame)
|
||||||
{
|
{
|
||||||
@@ -180,31 +245,27 @@ expand_rect_for_pen_size(BoundingBoxState* state, RectType& rect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
move_pen_by(void* _state, const BPoint& delta)
|
BoundingBoxCallbacks::MovePenBy(const BPoint& delta)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p move pen by %.2f %.2f\n", _state, delta.x, delta.y);
|
TRACE_BB("%p move pen by %.2f %.2f\n", _state, delta.x, delta.y);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
state->GetDrawState()->SetPenLocation(
|
fState->GetDrawState()->SetPenLocation(
|
||||||
state->GetDrawState()->PenLocation() + delta);
|
fState->GetDrawState()->PenLocation() + delta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_stroke_line(void* _state, const BPoint& _start,
|
BoundingBoxCallbacks::StrokeLine(const BPoint& _start,
|
||||||
const BPoint& _end)
|
const BPoint& _end)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p stroke line %.2f %.2f -> %.2f %.2f\n", _state,
|
TRACE_BB("%p stroke line %.2f %.2f -> %.2f %.2f\n", _state,
|
||||||
_start.x, _start.y, _end.x, _end.y);
|
_start.x, _start.y, _end.x, _end.y);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
BPoint start = _start;
|
BPoint start = _start;
|
||||||
BPoint end = _end;
|
BPoint end = _end;
|
||||||
|
|
||||||
const SimpleTransform transform = state->PenToLocalTransform();
|
const SimpleTransform transform = fState->PenToLocalTransform();
|
||||||
transform.Apply(&start);
|
transform.Apply(&start);
|
||||||
transform.Apply(&end);
|
transform.Apply(&end);
|
||||||
|
|
||||||
@@ -224,34 +285,32 @@ determine_bounds_stroke_line(void* _state, const BPoint& _start,
|
|||||||
rect.bottom = start.y;
|
rect.bottom = start.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
expand_rect_for_pen_size(state, rect);
|
expand_rect_for_pen_size(fState, rect);
|
||||||
state->IncludeRect(rect);
|
fState->IncludeRect(rect);
|
||||||
|
|
||||||
state->GetDrawState()->SetPenLocation(_end);
|
fState->GetDrawState()->SetPenLocation(_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_draw_rect(void* _state, const BRect& _rect, bool fill)
|
BoundingBoxCallbacks::DrawRect(const BRect& _rect, bool fill)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p draw rect fill=%d %.2f %.2f %.2f %.2f\n", _state, fill,
|
TRACE_BB("%p draw rect fill=%d %.2f %.2f %.2f %.2f\n", _state, fill,
|
||||||
_rect.left, _rect.top, _rect.right, _rect.bottom);
|
_rect.left, _rect.top, _rect.right, _rect.bottom);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
BRect rect = _rect;
|
BRect rect = _rect;
|
||||||
state->PenToLocalTransform().Apply(&rect);
|
fState->PenToLocalTransform().Apply(&rect);
|
||||||
if (!fill)
|
if (!fill)
|
||||||
expand_rect_for_pen_size(state, rect);
|
expand_rect_for_pen_size(fState, rect);
|
||||||
state->IncludeRect(rect);
|
fState->IncludeRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_draw_round_rect(void* _state, const BRect& _rect,
|
BoundingBoxCallbacks::DrawRoundRect(const BRect& _rect,
|
||||||
const BPoint&, bool fill)
|
const BPoint&, bool fill)
|
||||||
{
|
{
|
||||||
determine_bounds_draw_rect(_state, _rect, fill);
|
DrawRect(_rect, fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -280,9 +339,8 @@ determine_bounds_bezier(BoundingBoxState* state, const BPoint viewPoints[4],
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_draw_bezier(void* _state,
|
BoundingBoxCallbacks::DrawBezier(const BPoint viewPoints[4], bool fill)
|
||||||
const BPoint viewPoints[4], bool fill)
|
|
||||||
{
|
{
|
||||||
TRACE_BB("%p draw bezier fill=%d (%.2f %.2f) (%.2f %.2f) "
|
TRACE_BB("%p draw bezier fill=%d (%.2f %.2f) (%.2f %.2f) "
|
||||||
"(%.2f %.2f) (%.2f %.2f)\n",
|
"(%.2f %.2f) (%.2f %.2f)\n",
|
||||||
@@ -292,40 +350,36 @@ determine_bounds_draw_bezier(void* _state,
|
|||||||
viewPoints[1].x, viewPoints[1].y,
|
viewPoints[1].x, viewPoints[1].y,
|
||||||
viewPoints[2].x, viewPoints[2].y,
|
viewPoints[2].x, viewPoints[2].y,
|
||||||
viewPoints[3].x, viewPoints[3].y);
|
viewPoints[3].x, viewPoints[3].y);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
BRect rect;
|
BRect rect;
|
||||||
determine_bounds_bezier(state, viewPoints, rect);
|
determine_bounds_bezier(fState, viewPoints, rect);
|
||||||
if (!fill)
|
if (!fill)
|
||||||
expand_rect_for_pen_size(state, rect);
|
expand_rect_for_pen_size(fState, rect);
|
||||||
state->IncludeRect(rect);
|
fState->IncludeRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_draw_ellipse(void* _state, const BRect& _rect, bool fill)
|
BoundingBoxCallbacks::DrawEllipse(const BRect& _rect, bool fill)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p draw ellipse fill=%d (%.2f %.2f) (%.2f %.2f)\n", _state, fill,
|
TRACE_BB("%p draw ellipse fill=%d (%.2f %.2f) (%.2f %.2f)\n", _state, fill,
|
||||||
_rect.left, _rect.top, _rect.right, _rect.bottom);
|
_rect.left, _rect.top, _rect.right, _rect.bottom);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
BRect rect = _rect;
|
BRect rect = _rect;
|
||||||
state->PenToLocalTransform().Apply(&rect);
|
fState->PenToLocalTransform().Apply(&rect);
|
||||||
if (!fill)
|
if (!fill)
|
||||||
expand_rect_for_pen_size(state, rect);
|
expand_rect_for_pen_size(fState, rect);
|
||||||
state->IncludeRect(rect);
|
fState->IncludeRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_draw_arc(void* _state, const BPoint& center,
|
BoundingBoxCallbacks::DrawArc(const BPoint& center,
|
||||||
const BPoint& radii, float, float, bool fill)
|
const BPoint& radii, float, float, bool fill)
|
||||||
{
|
{
|
||||||
BRect rect(center.x - radii.x, center.y - radii.y,
|
BRect rect(center.x - radii.x, center.y - radii.y,
|
||||||
center.x + radii.x - 1, center.y + radii.y - 1);
|
center.x + radii.x - 1, center.y + radii.y - 1);
|
||||||
determine_bounds_draw_ellipse(_state, rect, fill);
|
DrawEllipse(rect, fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -361,481 +415,360 @@ determine_bounds_polygon(BoundingBoxState* state, int32 numPoints,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
determine_bounds_draw_polygon(void* _state, size_t numPoints,
|
BoundingBoxCallbacks::DrawPolygon(size_t numPoints,
|
||||||
const BPoint viewPoints[], bool, bool fill)
|
const BPoint viewPoints[], bool, bool fill)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p draw polygon fill=%d (%ld points)\n", _state, fill, numPoints);
|
TRACE_BB("%p draw polygon fill=%d (%ld points)\n", fState, fill, numPoints);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
BRect rect;
|
BRect rect;
|
||||||
determine_bounds_polygon(state, numPoints, viewPoints, rect);
|
determine_bounds_polygon(fState, numPoints, viewPoints, rect);
|
||||||
if (!fill)
|
if (!fill)
|
||||||
expand_rect_for_pen_size(state, rect);
|
expand_rect_for_pen_size(fState, rect);
|
||||||
state->IncludeRect(rect);
|
fState->IncludeRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_draw_shape(void* _state, const BShape& shape, bool fill)
|
BoundingBoxCallbacks::DrawShape(const BShape& shape, bool fill)
|
||||||
{
|
{
|
||||||
BRect rect = shape.Bounds();
|
BRect rect = shape.Bounds();
|
||||||
|
|
||||||
TRACE_BB("%p stroke shape (bounds %.2f %.2f %.2f %.2f)\n", _state,
|
TRACE_BB("%p stroke shape (bounds %.2f %.2f %.2f %.2f)\n", fState,
|
||||||
rect.left, rect.top, rect.right, rect.bottom);
|
rect.left, rect.top, rect.right, rect.bottom);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
state->PenToLocalTransform().Apply(&rect);
|
fState->PenToLocalTransform().Apply(&rect);
|
||||||
if (!fill)
|
if (!fill)
|
||||||
expand_rect_for_pen_size(state, rect);
|
expand_rect_for_pen_size(fState, rect);
|
||||||
state->IncludeRect(rect);
|
fState->IncludeRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_draw_string(void* _state, const char* string, size_t length,
|
BoundingBoxCallbacks::DrawString(const char* string, size_t length,
|
||||||
float deltaSpace, float deltaNonSpace)
|
float deltaSpace, float deltaNonSpace)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p string '%s'\n", _state, string);
|
TRACE_BB("%p string '%s'\n", fState, string);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
ServerFont font = state->GetDrawState()->Font();
|
ServerFont font = fState->GetDrawState()->Font();
|
||||||
|
|
||||||
escapement_delta delta = { deltaSpace, deltaNonSpace };
|
escapement_delta delta = { deltaSpace, deltaNonSpace };
|
||||||
BRect rect;
|
BRect rect;
|
||||||
font.GetBoundingBoxesForStrings((char**)&string, &length, 1, &rect,
|
font.GetBoundingBoxesForStrings((char**)&string, &length, 1, &rect,
|
||||||
B_SCREEN_METRIC, &delta);
|
B_SCREEN_METRIC, &delta);
|
||||||
|
|
||||||
BPoint location = state->GetDrawState()->PenLocation();
|
BPoint location = fState->GetDrawState()->PenLocation();
|
||||||
|
|
||||||
state->PenToLocalTransform().Apply(&location);
|
fState->PenToLocalTransform().Apply(&location);
|
||||||
rect.OffsetBy(location);
|
rect.OffsetBy(location);
|
||||||
state->IncludeRect(rect);
|
fState->IncludeRect(rect);
|
||||||
|
|
||||||
state->PenToLocalTransform().Apply(&location);
|
fState->PenToLocalTransform().Apply(&location);
|
||||||
state->GetDrawState()->SetPenLocation(location);
|
fState->GetDrawState()->SetPenLocation(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_draw_pixels(void* _state, const BRect&, const BRect& _dest,
|
BoundingBoxCallbacks::DrawPixels(const BRect&, const BRect& _dest,
|
||||||
uint32, uint32, size_t, color_space, uint32, const void*, size_t)
|
uint32, uint32, size_t, color_space, uint32, const void*, size_t)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p pixels (dest %.2f %.2f %.2f %.2f)\n", _state,
|
TRACE_BB("%p pixels (dest %.2f %.2f %.2f %.2f)\n", fState,
|
||||||
_dest.left, _dest.top, _dest.right, _dest.bottom);
|
_dest.left, _dest.top, _dest.right, _dest.bottom);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
BRect dest = _dest;
|
BRect dest = _dest;
|
||||||
state->PenToLocalTransform().Apply(&dest);
|
fState->PenToLocalTransform().Apply(&dest);
|
||||||
state->IncludeRect(dest);
|
fState->IncludeRect(dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
draw_picture(void* _state, const BPoint& where, int32 token)
|
BoundingBoxCallbacks::DrawPicture(const BPoint& where, int32 token)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p picture (unimplemented)\n", _state);
|
TRACE_BB("%p picture (unimplemented)\n", fState);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
(void)_state;
|
|
||||||
(void)where;
|
(void)where;
|
||||||
(void)token;
|
(void)token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_clipping_rects(void* _state, size_t numRects, const clipping_rect rects[])
|
BoundingBoxCallbacks::SetClippingRects(size_t numRects, const clipping_rect rects[])
|
||||||
{
|
{
|
||||||
TRACE_BB("%p cliping rects (%ld rects)\n", _state, numRects);
|
TRACE_BB("%p cliping rects (%ld rects)\n", fState, numRects);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
(void)_state;
|
|
||||||
(void)rects;
|
(void)rects;
|
||||||
(void)numRects;
|
(void)numRects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
clip_to_picture(void* _state, int32 pictureToken, const BPoint& where,
|
BoundingBoxCallbacks::ClipToPicture(int32 pictureToken, const BPoint& where,
|
||||||
bool clipToInverse)
|
bool clipToInverse)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p clip to picture (unimplemented)\n", _state);
|
TRACE_BB("%p clip to picture (unimplemented)\n", fState);
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
push_state(void* _state)
|
BoundingBoxCallbacks::PushState()
|
||||||
{
|
{
|
||||||
TRACE_BB("%p push state\n", _state);
|
TRACE_BB("%p push state\n", fState);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
state->PushDrawState();
|
fState->PushDrawState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
pop_state(void* _state)
|
BoundingBoxCallbacks::PopState()
|
||||||
{
|
{
|
||||||
TRACE_BB("%p pop state\n", _state);
|
TRACE_BB("%p pop state\n", fState);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
state->PopDrawState();
|
fState->PopDrawState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
enter_state_change(void*)
|
BoundingBoxCallbacks::EnterStateChange()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
exit_state_change(void*)
|
BoundingBoxCallbacks::ExitStateChange()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
enter_font_state(void*)
|
BoundingBoxCallbacks::EnterFontState()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
exit_font_state(void*)
|
BoundingBoxCallbacks::ExitFontState()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_origin(void* _state, const BPoint& pt)
|
BoundingBoxCallbacks::SetOrigin(const BPoint& pt)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p set origin %.2f %.2f\n", _state, pt.x, pt.y);
|
TRACE_BB("%p set origin %.2f %.2f\n", , pt.x, pt.y);
|
||||||
BoundingBoxState* const state =
|
fState->GetDrawState()->SetOrigin(pt);
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
state->GetDrawState()->SetOrigin(pt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_pen_location(void* _state, const BPoint& pt)
|
BoundingBoxCallbacks::SetPenLocation(const BPoint& pt)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p set pen location %.2f %.2f\n", _state, pt.x, pt.y);
|
TRACE_BB("%p set pen location %.2f %.2f\n", fState, pt.x, pt.y);
|
||||||
BoundingBoxState* const state =
|
fState->GetDrawState()->SetPenLocation(pt);
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
state->GetDrawState()->SetPenLocation(pt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_drawing_mode(void*, drawing_mode)
|
BoundingBoxCallbacks::SetDrawingMode(drawing_mode)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_line_mode(void* _state, cap_mode capMode, join_mode joinMode,
|
BoundingBoxCallbacks::SetLineMode(cap_mode capMode, join_mode joinMode,
|
||||||
float miterLimit)
|
float miterLimit)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
DrawState* drawState = fState->GetDrawState();
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
DrawState* drawState = state->GetDrawState();
|
|
||||||
drawState->SetLineCapMode(capMode);
|
drawState->SetLineCapMode(capMode);
|
||||||
drawState->SetLineJoinMode(joinMode);
|
drawState->SetLineJoinMode(joinMode);
|
||||||
drawState->SetMiterLimit(miterLimit);
|
drawState->SetMiterLimit(miterLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_pen_size(void* _state, float size)
|
BoundingBoxCallbacks::SetPenSize(float size)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p set pen size %.2f\n", _state, size);
|
TRACE_BB("%p set pen size %.2f\n", fState, size);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
state->GetDrawState()->SetPenSize(size);
|
fState->GetDrawState()->SetPenSize(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_fore_color(void* _state, const rgb_color& color)
|
BoundingBoxCallbacks::SetForeColor(const rgb_color& color)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
fState->GetDrawState()->SetHighColor(color);
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
state->GetDrawState()->SetHighColor(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_back_color(void* _state, const rgb_color& color)
|
BoundingBoxCallbacks::SetBackColor(const rgb_color& color)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
fState->GetDrawState()->SetLowColor(color);
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
state->GetDrawState()->SetLowColor(color);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_stipple_pattern(void* _state, const pattern& _pattern)
|
BoundingBoxCallbacks::SetStipplePattern(const pattern& _pattern)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
fState->GetDrawState()->SetPattern(Pattern(_pattern));
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
state->GetDrawState()->SetPattern(Pattern(_pattern));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_scale(void* _state, float scale)
|
BoundingBoxCallbacks::SetScale(float scale)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
fState->GetDrawState()->SetScale(scale);
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
state->GetDrawState()->SetScale(scale);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_font_family(void* _state, const char* _family, size_t length)
|
BoundingBoxCallbacks::SetFontFamily(const char* _family, size_t length)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
BString family(_family, length);
|
BString family(_family, length);
|
||||||
gFontManager->Lock();
|
gFontManager->Lock();
|
||||||
FontStyle* fontStyle = gFontManager->GetStyleByIndex(family, 0);
|
FontStyle* fontStyle = gFontManager->GetStyleByIndex(family, 0);
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
font.SetStyle(fontStyle);
|
font.SetStyle(fontStyle);
|
||||||
gFontManager->Unlock();
|
gFontManager->Unlock();
|
||||||
state->GetDrawState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
|
fState->GetDrawState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_font_style(void* _state, const char* _style, size_t length)
|
BoundingBoxCallbacks::SetFontStyle(const char* _style, size_t length)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
BString style(_style, length);
|
BString style(_style, length);
|
||||||
ServerFont font(state->GetDrawState()->Font());
|
ServerFont font(fState->GetDrawState()->Font());
|
||||||
gFontManager->Lock();
|
gFontManager->Lock();
|
||||||
FontStyle* fontStyle = gFontManager->GetStyle(font.Family(), style);
|
FontStyle* fontStyle = gFontManager->GetStyle(font.Family(), style);
|
||||||
font.SetStyle(fontStyle);
|
font.SetStyle(fontStyle);
|
||||||
gFontManager->Unlock();
|
gFontManager->Unlock();
|
||||||
state->GetDrawState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
|
fState->GetDrawState()->SetFont(font, B_FONT_FAMILY_AND_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_font_spacing(void* _state, uint8 spacing)
|
BoundingBoxCallbacks::SetFontSpacing(uint8 spacing)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
font.SetSpacing(spacing);
|
font.SetSpacing(spacing);
|
||||||
state->GetDrawState()->SetFont(font, B_FONT_SPACING);
|
fState->GetDrawState()->SetFont(font, B_FONT_SPACING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_font_size(void* _state, float size)
|
BoundingBoxCallbacks::SetFontSize(float size)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
font.SetSize(size);
|
font.SetSize(size);
|
||||||
state->GetDrawState()->SetFont(font, B_FONT_SIZE);
|
fState->GetDrawState()->SetFont(font, B_FONT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_font_rotate(void* _state, float rotation)
|
BoundingBoxCallbacks::SetFontRotation(float rotation)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
font.SetRotation(rotation);
|
font.SetRotation(rotation);
|
||||||
state->GetDrawState()->SetFont(font, B_FONT_ROTATION);
|
fState->GetDrawState()->SetFont(font, B_FONT_ROTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_font_encoding(void* _state, uint8 encoding)
|
BoundingBoxCallbacks::SetFontEncoding(uint8 encoding)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
font.SetEncoding(encoding);
|
font.SetEncoding(encoding);
|
||||||
state->GetDrawState()->SetFont(font, B_FONT_ENCODING);
|
fState->GetDrawState()->SetFont(font, B_FONT_ENCODING);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_font_flags(void* _state, uint32 flags)
|
BoundingBoxCallbacks::SetFontFlags(uint32 flags)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
font.SetFlags(flags);
|
font.SetFlags(flags);
|
||||||
state->GetDrawState()->SetFont(font, B_FONT_FLAGS);
|
fState->GetDrawState()->SetFont(font, B_FONT_FLAGS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_font_shear(void* _state, float shear)
|
BoundingBoxCallbacks::SetFontShear(float shear)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
font.SetShear(shear);
|
font.SetShear(shear);
|
||||||
state->GetDrawState()->SetFont(font, B_FONT_SHEAR);
|
fState->GetDrawState()->SetFont(font, B_FONT_SHEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_font_face(void* _state, uint16 face)
|
BoundingBoxCallbacks::SetFontFace(uint16 face)
|
||||||
{
|
{
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
ServerFont font;
|
ServerFont font;
|
||||||
font.SetFace(face);
|
font.SetFace(face);
|
||||||
state->GetDrawState()->SetFont(font, B_FONT_FACE);
|
fState->GetDrawState()->SetFont(font, B_FONT_FACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_blending_mode(void*, source_alpha, alpha_function)
|
BoundingBoxCallbacks::SetBlendingMode(source_alpha, alpha_function)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
set_transform(void* _state, const BAffineTransform& transform)
|
BoundingBoxCallbacks::SetTransform(const BAffineTransform& transform)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p transform\n", _state);
|
TRACE_BB("%p transform\n", fState);
|
||||||
BoundingBoxState* const state =
|
fState->GetDrawState()->SetTransform(transform);
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
state->GetDrawState()->SetTransform(transform);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
translate_by(void* _state, double x, double y)
|
BoundingBoxCallbacks::TranslateBy(double x, double y)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p translate\n", _state);
|
TRACE_BB("%p translate\n", fState);
|
||||||
BoundingBoxState* const state =
|
BAffineTransform transform = fState->GetDrawState()->Transform();
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
BAffineTransform transform = state->GetDrawState()->Transform();
|
|
||||||
transform.PreTranslateBy(x, y);
|
transform.PreTranslateBy(x, y);
|
||||||
state->GetDrawState()->SetTransform(transform);
|
fState->GetDrawState()->SetTransform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
scale_by(void* _state, double x, double y)
|
BoundingBoxCallbacks::ScaleBy(double x, double y)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p scale\n", _state);
|
TRACE_BB("%p scale\n", fState);
|
||||||
BoundingBoxState* const state =
|
BAffineTransform transform = fState->GetDrawState()->Transform();
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
BAffineTransform transform = state->GetDrawState()->Transform();
|
|
||||||
transform.PreScaleBy(x, y);
|
transform.PreScaleBy(x, y);
|
||||||
state->GetDrawState()->SetTransform(transform);
|
fState->GetDrawState()->SetTransform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
rotate_by(void* _state, double angleRadians)
|
BoundingBoxCallbacks::RotateBy(double angleRadians)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p rotate\n", _state);
|
TRACE_BB("%p rotate\n", fState);
|
||||||
BoundingBoxState* const state =
|
BAffineTransform transform = fState->GetDrawState()->Transform();
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
BAffineTransform transform = state->GetDrawState()->Transform();
|
|
||||||
transform.PreRotateBy(angleRadians);
|
transform.PreRotateBy(angleRadians);
|
||||||
state->GetDrawState()->SetTransform(transform);
|
fState->GetDrawState()->SetTransform(transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
void
|
||||||
determine_bounds_nested_layer(void* _state, Layer* layer)
|
BoundingBoxCallbacks::BlendLayer(Layer* layer)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p nested layer\n", _state);
|
TRACE_BB("%p nested layer\n", fState);
|
||||||
BoundingBoxState* const state =
|
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
|
||||||
|
|
||||||
BRect boundingBox;
|
BRect boundingBox;
|
||||||
PictureBoundingBoxPlayer::Play(layer, state->GetDrawState(), &boundingBox);
|
PictureBoundingBoxPlayer::Play(layer, fState->GetDrawState(), &boundingBox);
|
||||||
if (boundingBox.IsValid())
|
if (boundingBox.IsValid())
|
||||||
state->IncludeRect(boundingBox);
|
fState->IncludeRect(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const BPrivate::picture_player_callbacks
|
|
||||||
kPictureBoundingBoxPlayerCallbacks = {
|
|
||||||
move_pen_by,
|
|
||||||
determine_bounds_stroke_line,
|
|
||||||
determine_bounds_draw_rect,
|
|
||||||
determine_bounds_draw_round_rect,
|
|
||||||
determine_bounds_draw_bezier,
|
|
||||||
determine_bounds_draw_arc,
|
|
||||||
determine_bounds_draw_ellipse,
|
|
||||||
determine_bounds_draw_polygon,
|
|
||||||
determine_bounds_draw_shape,
|
|
||||||
determine_bounds_draw_string,
|
|
||||||
determine_bounds_draw_pixels,
|
|
||||||
draw_picture,
|
|
||||||
set_clipping_rects,
|
|
||||||
clip_to_picture,
|
|
||||||
push_state,
|
|
||||||
pop_state,
|
|
||||||
enter_state_change,
|
|
||||||
exit_state_change,
|
|
||||||
enter_font_state,
|
|
||||||
exit_font_state,
|
|
||||||
set_origin,
|
|
||||||
set_pen_location,
|
|
||||||
set_drawing_mode,
|
|
||||||
set_line_mode,
|
|
||||||
set_pen_size,
|
|
||||||
set_fore_color,
|
|
||||||
set_back_color,
|
|
||||||
set_stipple_pattern,
|
|
||||||
set_scale,
|
|
||||||
set_font_family,
|
|
||||||
set_font_style,
|
|
||||||
set_font_spacing,
|
|
||||||
set_font_size,
|
|
||||||
set_font_rotate,
|
|
||||||
set_font_encoding,
|
|
||||||
set_font_flags,
|
|
||||||
set_font_shear,
|
|
||||||
set_font_face,
|
|
||||||
set_blending_mode,
|
|
||||||
set_transform,
|
|
||||||
translate_by,
|
|
||||||
scale_by,
|
|
||||||
rotate_by,
|
|
||||||
determine_bounds_nested_layer
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark - PictureBoundingBoxPlayer
|
// #pragma mark - PictureBoundingBoxPlayer
|
||||||
|
|
||||||
|
|
||||||
@@ -849,9 +782,10 @@ PictureBoundingBoxPlayer::Play(ServerPicture* picture,
|
|||||||
if (mallocIO == NULL)
|
if (mallocIO == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
BoundingBoxCallbacks callbacks(&state);
|
||||||
|
|
||||||
BPrivate::PicturePlayer player(mallocIO->Buffer(),
|
BPrivate::PicturePlayer player(mallocIO->Buffer(),
|
||||||
mallocIO->BufferLength(), ServerPicture::PictureList::Private(
|
mallocIO->BufferLength(), ServerPicture::PictureList::Private(
|
||||||
picture->fPictures.Get()).AsBList());
|
picture->fPictures.Get()).AsBList());
|
||||||
player.Play(kPictureBoundingBoxPlayerCallbacks,
|
player.Play(callbacks);
|
||||||
sizeof(kPictureBoundingBoxPlayerCallbacks), &state);
|
|
||||||
}
|
}
|
||||||
|
|||||||
+328
-374
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user