BPicture: fix DRAW_STRING command escapement_delta fields order

Change-Id: I4af041faf108c80c8232928b9bd39f43397aaada
Reviewed-on: https://review.haiku-os.org/c/haiku/+/10586
Tested-by: Commit checker robot <[email protected]>
Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
X512
2026-04-05 14:50:48 +00:00
committed by Adrien Destugues
parent ab25c31526
commit 29323c568f
7 changed files with 18 additions and 25 deletions
+3 -2
View File
@@ -21,6 +21,8 @@
#include <Region.h>
struct escapement_delta;
class BAffineTransform;
class BGradient;
class BList;
@@ -153,8 +155,7 @@ public:
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 DrawString(const char* string, size_t length, const escapement_delta& delta) {}
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) {}
+1 -1
View File
@@ -494,8 +494,8 @@ PictureDataWriter::WriteDrawString(const BPoint& where, const char* string,
BeginOp(B_PIC_DRAW_STRING);
Write<int32>(length);
WriteData(string, length);
Write<float>(escapement.space);
Write<float>(escapement.nonspace);
Write<float>(escapement.space);
EndOp();
} catch (status_t& status) {
return status;
+7 -10
View File
@@ -19,6 +19,7 @@
#include <AffineTransform.h>
#include <DataIO.h>
#include <Font.h>
#include <Gradient.h>
#include <PictureProtocol.h>
#include <Shape.h>
@@ -47,8 +48,7 @@ public:
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 DrawString(const char* string, size_t length, const escapement_delta& delta);
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);
@@ -224,11 +224,11 @@ CallbackAdapterPlayer::DrawShape(const BShape& shape, bool fill)
void
CallbackAdapterPlayer::DrawString(const char* _string, size_t length,
float deltaSpace, float deltaNonSpace)
const escapement_delta& delta)
{
char* string = strndup(_string, length);
fCallbacks->draw_string(fUserData, string, deltaSpace, deltaNonSpace);
fCallbacks->draw_string(fUserData, string, delta.nonspace, delta.space);
free(string);
}
@@ -1162,17 +1162,14 @@ PicturePlayer::_Play(PicturePlayerCallbacks& callbacks,
{
const int32* length;
const char* string;
const float* escapementSpace;
const float* escapementNonSpace;
const escapement_delta* delta;
if (!reader.Get(length)
|| !reader.Get(string, *length)
|| !reader.Get(escapementSpace)
|| !reader.Get(escapementNonSpace)) {
|| !reader.Get(delta)) {
break;
}
callbacks.DrawString(string, *length,
*escapementSpace, *escapementNonSpace);
callbacks.DrawString(string, *length, *delta);
break;
}
+2 -4
View File
@@ -157,8 +157,7 @@ public:
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 DrawString(const char* string, size_t length, const escapement_delta& delta);
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);
@@ -445,13 +444,12 @@ BoundingBoxCallbacks::DrawShape(const BShape& shape, bool fill)
void
BoundingBoxCallbacks::DrawString(const char* string, size_t length,
float deltaSpace, float deltaNonSpace)
const escapement_delta& delta)
{
TRACE_BB("%p string '%s'\n", fState, string);
ServerFont font = fState->GetDrawState()->Font();
escapement_delta delta = { deltaSpace, deltaNonSpace };
BRect rect;
font.GetBoundingBoxesForStrings((char**)&string, &length, 1, &rect,
B_SCREEN_METRIC, &delta);
+1 -1
View File
@@ -1029,7 +1029,7 @@ ServerFont::GetBoundingBoxes(const char* string, int32 numBytes, int32 numChars,
status_t
ServerFont::GetBoundingBoxesForStrings(char *charArray[], size_t lengthArray[],
int32 numStrings, BRect rectArray[], font_metric_mode mode,
escapement_delta deltaArray[])
const escapement_delta deltaArray[])
{
// TODO: The font_metric_mode is never used
if (charArray == NULL || lengthArray == NULL || numStrings <= 0
+1 -1
View File
@@ -150,7 +150,7 @@ class ServerFont {
status_t GetBoundingBoxesForStrings(char *charArray[],
size_t lengthArray[], int32 numStrings,
BRect rectArray[], font_metric_mode mode,
escapement_delta deltaArray[]);
const escapement_delta deltaArray[]);
float StringWidth(const char *string,
int32 numBytes,
+3 -6
View File
@@ -251,8 +251,7 @@ public:
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 DrawString(const char* string, size_t length, const escapement_delta& delta);
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);
@@ -589,18 +588,16 @@ CanvasCallbacks::StrokeLineGradient(const BPoint& _start, const BPoint& _end,
void
CanvasCallbacks::DrawString(const char* string, size_t length, float deltaSpace,
float deltaNonSpace)
CanvasCallbacks::DrawString(const char* string, size_t length, const escapement_delta& delta)
{
// NOTE: the picture data was recorded with a "set pen location"
// command inserted before the "draw string" command, so we can
// use PenLocation()
BPoint location = fCanvas->CurrentState()->PenLocation();
escapement_delta delta = { deltaSpace, deltaNonSpace };
fCanvas->PenToScreenTransform().Apply(&location);
location = fCanvas->GetDrawingEngine()->DrawString(string, length,
location, &delta);
location, const_cast<escapement_delta*>(&delta));
fCanvas->PenToScreenTransform().Apply(&location);
fCanvas->CurrentState()->SetPenLocation(location);