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:
@@ -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) {}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user