BPicture: remove point count argument from private draw bezier callback
Fill/StrokeBezier always have 4 points so passing point count is not needed. Point count is not passed to BView drawing API and not stored in BPicture data. Change-Id: Iddb32bd493143d4450acfb76bdc56fc02136448e Reviewed-on: https://review.haiku-os.org/c/haiku/+/8560 Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
@@ -37,8 +37,7 @@ struct picture_player_callbacks {
|
|||||||
void (*draw_rect)(void* userData, const BRect& rect, bool fill);
|
void (*draw_rect)(void* userData, const BRect& rect, bool fill);
|
||||||
void (*draw_round_rect)(void* userData, const BRect& rect,
|
void (*draw_round_rect)(void* userData, const BRect& rect,
|
||||||
const BPoint& radii, bool fill);
|
const BPoint& radii, bool fill);
|
||||||
void (*draw_bezier)(void* userData, size_t numControlPoints,
|
void (*draw_bezier)(void* userData, const BPoint controlPoints[4], bool fill);
|
||||||
const BPoint controlPoints[], bool fill);
|
|
||||||
void (*draw_arc)(void* userData, const BPoint& center, const BPoint& radii,
|
void (*draw_arc)(void* userData, const BPoint& center, const BPoint& radii,
|
||||||
float startTheta, float arcTheta, bool fill);
|
float startTheta, float arcTheta, bool fill);
|
||||||
void (*draw_ellipse)(void* userData, const BRect& rect, bool fill);
|
void (*draw_ellipse)(void* userData, const BRect& rect, bool fill);
|
||||||
@@ -97,7 +96,7 @@ struct picture_player_callbacks {
|
|||||||
size_t length, const BPoint locations[], size_t locationCount);
|
size_t length, const BPoint locations[], size_t locationCount);
|
||||||
void (*draw_rect_gradient)(void* userData, const BRect& rect, BGradient& gradient, bool fill);
|
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_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_bezier_gradient)(void* userData, const BPoint controlPoints[4], 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_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_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);
|
||||||
|
|||||||
@@ -81,11 +81,9 @@ draw_round_rect(void* _context, const BRect& rect, const BPoint& radii,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_bezier(void* _context, size_t numPoints, const BPoint _points[], bool fill)
|
draw_bezier(void* _context, const BPoint _points[4], bool fill)
|
||||||
{
|
{
|
||||||
adapter_context* context = reinterpret_cast<adapter_context*>(_context);
|
adapter_context* context = reinterpret_cast<adapter_context*>(_context);
|
||||||
if (numPoints != 4)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BPoint points[4] = { _points[0], _points[1], _points[2], _points[3] };
|
BPoint points[4] = { _points[0], _points[1], _points[2], _points[3] };
|
||||||
((void (*)(void*, BPoint*))context->function_table[fill ? 8 : 7])(
|
((void (*)(void*, BPoint*))context->function_table[fill ? 8 : 7])(
|
||||||
@@ -544,11 +542,9 @@ draw_round_rect_gradient(void* _context, const BRect& rect, const BPoint& radii,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_bezier_gradient(void* _context, size_t numPoints, const BPoint _points[], BGradient& gradient, bool fill)
|
draw_bezier_gradient(void* _context, const BPoint _points[4], BGradient& gradient, bool fill)
|
||||||
{
|
{
|
||||||
adapter_context* context = reinterpret_cast<adapter_context*>(_context);
|
adapter_context* context = reinterpret_cast<adapter_context*>(_context);
|
||||||
if (numPoints != 4)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BPoint points[4] = { _points[0], _points[1], _points[2], _points[3] };
|
BPoint points[4] = { _points[0], _points[1], _points[2], _points[3] };
|
||||||
((void (*)(void*, BPoint*, BGradient&))context->function_table[fill ? 60 : 61])(
|
((void (*)(void*, BPoint*, BGradient&))context->function_table[fill ? 60 : 61])(
|
||||||
@@ -989,8 +985,7 @@ PicturePlayer::_Play(const picture_player_callbacks& callbacks, void* userData,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
callbacks.draw_bezier(userData, kNumControlPoints,
|
callbacks.draw_bezier(userData, controlPoints, header->op == B_PIC_FILL_BEZIER);
|
||||||
controlPoints, header->op == B_PIC_FILL_BEZIER);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1113,8 +1108,8 @@ PicturePlayer::_Play(const picture_player_callbacks& callbacks, void* userData,
|
|||||||
}
|
}
|
||||||
ObjectDeleter<BGradient> gradientDeleter(gradient);
|
ObjectDeleter<BGradient> gradientDeleter(gradient);
|
||||||
|
|
||||||
callbacks.draw_bezier_gradient(userData, kNumControlPoints,
|
callbacks.draw_bezier_gradient(userData, controlPoints, *gradient,
|
||||||
controlPoints, *gradient, header->op == B_PIC_FILL_BEZIER_GRADIENT);
|
header->op == B_PIC_FILL_BEZIER_GRADIENT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -256,7 +256,7 @@ determine_bounds_draw_round_rect(void* _state, const BRect& _rect,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
determine_bounds_bezier(BoundingBoxState* state, const BPoint* viewPoints,
|
determine_bounds_bezier(BoundingBoxState* state, const BPoint viewPoints[4],
|
||||||
BRect& outRect)
|
BRect& outRect)
|
||||||
{
|
{
|
||||||
// Note: this is an approximation which results in a rectangle which
|
// Note: this is an approximation which results in a rectangle which
|
||||||
@@ -281,8 +281,8 @@ determine_bounds_bezier(BoundingBoxState* state, const BPoint* viewPoints,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
determine_bounds_draw_bezier(void* _state, size_t numPoints,
|
determine_bounds_draw_bezier(void* _state,
|
||||||
const BPoint viewPoints[], 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",
|
||||||
@@ -295,10 +295,6 @@ determine_bounds_draw_bezier(void* _state, size_t numPoints,
|
|||||||
BoundingBoxState* const state =
|
BoundingBoxState* const state =
|
||||||
reinterpret_cast<BoundingBoxState*>(_state);
|
reinterpret_cast<BoundingBoxState*>(_state);
|
||||||
|
|
||||||
const size_t kSupportedPoints = 4;
|
|
||||||
if (numPoints != kSupportedPoints)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BRect rect;
|
BRect rect;
|
||||||
determine_bounds_bezier(state, viewPoints, rect);
|
determine_bounds_bezier(state, viewPoints, rect);
|
||||||
if (!fill)
|
if (!fill)
|
||||||
|
|||||||
@@ -323,17 +323,14 @@ draw_round_rect(void* _canvas, const BRect& _rect, const BPoint& radii,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_bezier(void* _canvas, size_t numPoints, const BPoint viewPoints[],
|
draw_bezier(void* _canvas, const BPoint viewPoints[4], bool fill)
|
||||||
bool fill)
|
|
||||||
{
|
{
|
||||||
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
|
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
|
||||||
|
|
||||||
const size_t kSupportedPoints = 4;
|
const size_t kNumPoints = 4;
|
||||||
if (numPoints != kSupportedPoints)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BPoint points[kSupportedPoints];
|
BPoint points[kNumPoints];
|
||||||
canvas->PenToScreenTransform().Apply(points, viewPoints, kSupportedPoints);
|
canvas->PenToScreenTransform().Apply(points, viewPoints, kNumPoints);
|
||||||
canvas->GetDrawingEngine()->DrawBezier(points, fill);
|
canvas->GetDrawingEngine()->DrawBezier(points, fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,19 +426,16 @@ draw_round_rect_gradient(void* _canvas, const BRect& _rect, const BPoint& radii,
|
|||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
draw_bezier_gradient(void* _canvas, size_t numPoints, const BPoint viewPoints[], BGradient& gradient,
|
draw_bezier_gradient(void* _canvas, const BPoint viewPoints[4], BGradient& gradient, bool fill)
|
||||||
bool fill)
|
|
||||||
{
|
{
|
||||||
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
|
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
|
||||||
|
|
||||||
const size_t kSupportedPoints = 4;
|
const size_t kNumPoints = 4;
|
||||||
if (numPoints != kSupportedPoints)
|
|
||||||
return;
|
|
||||||
|
|
||||||
BPoint points[kSupportedPoints];
|
BPoint points[kNumPoints];
|
||||||
const SimpleTransform transform =
|
const SimpleTransform transform =
|
||||||
canvas->PenToScreenTransform();
|
canvas->PenToScreenTransform();
|
||||||
transform.Apply(points, viewPoints, kSupportedPoints);
|
transform.Apply(points, viewPoints, kNumPoints);
|
||||||
transform.Apply(&gradient);
|
transform.Apply(&gradient);
|
||||||
canvas->GetDrawingEngine()->FillBezier(points, gradient);
|
canvas->GetDrawingEngine()->FillBezier(points, gradient);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user