BPicture: add fill rule support
Change-Id: I068e1c2e8659f7b90c6d7c7331a8bb25ae343fe9 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2922 Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
@@ -41,6 +41,7 @@ public:
|
|||||||
status_t WriteSetLineMode(const cap_mode& cap,
|
status_t WriteSetLineMode(const cap_mode& cap,
|
||||||
const join_mode& join,
|
const join_mode& join,
|
||||||
const float& miterLimit);
|
const float& miterLimit);
|
||||||
|
status_t WriteSetFillRule(int32 fillRule);
|
||||||
status_t WriteSetScale(const float& scale);
|
status_t WriteSetScale(const float& scale);
|
||||||
status_t WriteSetTransform(BAffineTransform transform);
|
status_t WriteSetTransform(BAffineTransform transform);
|
||||||
status_t WriteTranslateBy(double x, double y);
|
status_t WriteTranslateBy(double x, double y);
|
||||||
|
|||||||
@@ -102,6 +102,7 @@ struct picture_player_callbacks {
|
|||||||
void (*draw_ellipse_gradient)(void* userData, const BRect& rect, 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_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);
|
void (*draw_shape_gradient)(void* userData, const BShape& shape, BGradient& gradient, bool fill);
|
||||||
|
void (*set_fill_rule)(void* userData, int32 fillRule);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ enum {
|
|||||||
B_PIC_SET_STIPLE_PATTERN = 0x0308,
|
B_PIC_SET_STIPLE_PATTERN = 0x0308,
|
||||||
B_PIC_ENTER_FONT_STATE = 0x0309,
|
B_PIC_ENTER_FONT_STATE = 0x0309,
|
||||||
B_PIC_SET_BLENDING_MODE = 0x030A,
|
B_PIC_SET_BLENDING_MODE = 0x030A,
|
||||||
|
B_PIC_SET_FILL_RULE = 0x030B,
|
||||||
B_PIC_SET_FONT_FAMILY = 0x0380,
|
B_PIC_SET_FONT_FAMILY = 0x0380,
|
||||||
B_PIC_SET_FONT_STYLE = 0x0381,
|
B_PIC_SET_FONT_STYLE = 0x0381,
|
||||||
B_PIC_SET_FONT_SPACING = 0x0382,
|
B_PIC_SET_FONT_SPACING = 0x0382,
|
||||||
@@ -76,7 +77,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const static uint32 kOpsTableSize = 70;
|
const static uint32 kOpsTableSize = 71;
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -156,6 +156,21 @@ PictureDataWriter::WriteSetLineMode(const cap_mode& cap, const join_mode& join,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
status_t
|
||||||
|
PictureDataWriter::WriteSetFillRule(int32 fillRule)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
BeginOp(B_PIC_SET_FILL_RULE);
|
||||||
|
Write<int32>(fillRule);
|
||||||
|
EndOp();
|
||||||
|
} catch (status_t& status) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
PictureDataWriter::WriteSetScale(const float& scale)
|
PictureDataWriter::WriteSetScale(const float& scale)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -605,6 +605,15 @@ draw_shape_gradient(void* _context, const BShape& shape, BGradient& gradient, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_fill_rule(void* _context, int32 fillRule)
|
||||||
|
{
|
||||||
|
adapter_context* context = reinterpret_cast<adapter_context*>(_context);
|
||||||
|
((void (*)(void*, int32))context->function_table[70])(
|
||||||
|
context->user_data, fillRule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if DEBUG > 1
|
#if DEBUG > 1
|
||||||
static const char *
|
static const char *
|
||||||
@@ -747,7 +756,8 @@ PicturePlayer::Play(void** callBackTable, int32 tableEntries, void* userData)
|
|||||||
draw_arc_gradient,
|
draw_arc_gradient,
|
||||||
draw_ellipse_gradient,
|
draw_ellipse_gradient,
|
||||||
draw_polygon_gradient,
|
draw_polygon_gradient,
|
||||||
draw_shape_gradient
|
draw_shape_gradient,
|
||||||
|
set_fill_rule
|
||||||
};
|
};
|
||||||
|
|
||||||
// We don't check if the functions in the table are NULL, but we
|
// We don't check if the functions in the table are NULL, but we
|
||||||
@@ -1545,6 +1555,18 @@ PicturePlayer::_Play(const picture_player_callbacks& callbacks, void* userData,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case B_PIC_SET_FILL_RULE:
|
||||||
|
{
|
||||||
|
const uint32* fillRule;
|
||||||
|
if (callbacks.set_fill_rule == NULL
|
||||||
|
|| !reader.Get(fillRule)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
callbacks.set_fill_rule(userData, *fillRule);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case B_PIC_SET_TRANSFORM:
|
case B_PIC_SET_TRANSFORM:
|
||||||
{
|
{
|
||||||
const BAffineTransform* transform;
|
const BAffineTransform* transform;
|
||||||
|
|||||||
@@ -896,6 +896,15 @@ set_blending_mode(void* _canvas, source_alpha alphaSrcMode,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_fill_rule(void* _canvas, int32 fillRule)
|
||||||
|
{
|
||||||
|
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
|
||||||
|
canvas->CurrentState()->SetFillRule(fillRule);
|
||||||
|
canvas->GetDrawingEngine()->SetFillRule(fillRule);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
set_transform(void* _canvas, const BAffineTransform& transform)
|
set_transform(void* _canvas, const BAffineTransform& transform)
|
||||||
{
|
{
|
||||||
@@ -1062,7 +1071,8 @@ static const BPrivate::picture_player_callbacks kPicturePlayerCallbacks = {
|
|||||||
draw_arc_gradient,
|
draw_arc_gradient,
|
||||||
draw_ellipse_gradient,
|
draw_ellipse_gradient,
|
||||||
draw_polygon_gradient,
|
draw_polygon_gradient,
|
||||||
draw_shape_gradient
|
draw_shape_gradient,
|
||||||
|
set_fill_rule
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3303,6 +3303,19 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver& link)
|
|||||||
info.lineJoin, info.miterLimit);
|
info.lineJoin, info.miterLimit);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case AS_VIEW_SET_FILL_RULE:
|
||||||
|
{
|
||||||
|
int32 fillRule;
|
||||||
|
if (link.Read<int32>(&fillRule) != B_OK)
|
||||||
|
break;
|
||||||
|
|
||||||
|
picture->WriteSetFillRule(fillRule);
|
||||||
|
|
||||||
|
fCurrentView->CurrentState()->SetFillRule(fillRule);
|
||||||
|
fWindow->GetDrawingEngine()->SetFillRule(fillRule);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case AS_VIEW_SET_SCALE:
|
case AS_VIEW_SET_SCALE:
|
||||||
{
|
{
|
||||||
float scale;
|
float scale;
|
||||||
|
|||||||
Reference in New Issue
Block a user