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>
|
#include <Region.h>
|
||||||
|
|
||||||
|
|
||||||
|
struct escapement_delta;
|
||||||
|
|
||||||
class BAffineTransform;
|
class BAffineTransform;
|
||||||
class BGradient;
|
class BGradient;
|
||||||
class BList;
|
class BList;
|
||||||
@@ -153,8 +155,7 @@ public:
|
|||||||
virtual void DrawEllipse(const BRect& rect, 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 DrawPolygon(size_t numPoints, const BPoint points[], bool isClosed, bool fill) {}
|
||||||
virtual void DrawShape(const BShape& shape, bool fill) {}
|
virtual void DrawShape(const BShape& shape, bool fill) {}
|
||||||
virtual void DrawString(const char* string, size_t length, float spaceEscapement,
|
virtual void DrawString(const char* string, size_t length, const escapement_delta& delta) {}
|
||||||
float nonSpaceEscapement) {}
|
|
||||||
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
||||||
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
||||||
size_t length) {}
|
size_t length) {}
|
||||||
|
|||||||
@@ -494,8 +494,8 @@ PictureDataWriter::WriteDrawString(const BPoint& where, const char* string,
|
|||||||
BeginOp(B_PIC_DRAW_STRING);
|
BeginOp(B_PIC_DRAW_STRING);
|
||||||
Write<int32>(length);
|
Write<int32>(length);
|
||||||
WriteData(string, length);
|
WriteData(string, length);
|
||||||
Write<float>(escapement.space);
|
|
||||||
Write<float>(escapement.nonspace);
|
Write<float>(escapement.nonspace);
|
||||||
|
Write<float>(escapement.space);
|
||||||
EndOp();
|
EndOp();
|
||||||
} catch (status_t& status) {
|
} catch (status_t& status) {
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <AffineTransform.h>
|
#include <AffineTransform.h>
|
||||||
#include <DataIO.h>
|
#include <DataIO.h>
|
||||||
|
#include <Font.h>
|
||||||
#include <Gradient.h>
|
#include <Gradient.h>
|
||||||
#include <PictureProtocol.h>
|
#include <PictureProtocol.h>
|
||||||
#include <Shape.h>
|
#include <Shape.h>
|
||||||
@@ -47,8 +48,7 @@ public:
|
|||||||
virtual void DrawEllipse(const BRect& rect, 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 DrawPolygon(size_t numPoints, const BPoint points[], bool isClosed, bool fill);
|
||||||
virtual void DrawShape(const BShape& shape, bool fill);
|
virtual void DrawShape(const BShape& shape, bool fill);
|
||||||
virtual void DrawString(const char* string, size_t length, float spaceEscapement,
|
virtual void DrawString(const char* string, size_t length, const escapement_delta& delta);
|
||||||
float nonSpaceEscapement);
|
|
||||||
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
||||||
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
||||||
size_t length);
|
size_t length);
|
||||||
@@ -224,11 +224,11 @@ CallbackAdapterPlayer::DrawShape(const BShape& shape, bool fill)
|
|||||||
|
|
||||||
void
|
void
|
||||||
CallbackAdapterPlayer::DrawString(const char* _string, size_t length,
|
CallbackAdapterPlayer::DrawString(const char* _string, size_t length,
|
||||||
float deltaSpace, float deltaNonSpace)
|
const escapement_delta& delta)
|
||||||
{
|
{
|
||||||
char* string = strndup(_string, length);
|
char* string = strndup(_string, length);
|
||||||
|
|
||||||
fCallbacks->draw_string(fUserData, string, deltaSpace, deltaNonSpace);
|
fCallbacks->draw_string(fUserData, string, delta.nonspace, delta.space);
|
||||||
|
|
||||||
free(string);
|
free(string);
|
||||||
}
|
}
|
||||||
@@ -1162,17 +1162,14 @@ PicturePlayer::_Play(PicturePlayerCallbacks& callbacks,
|
|||||||
{
|
{
|
||||||
const int32* length;
|
const int32* length;
|
||||||
const char* string;
|
const char* string;
|
||||||
const float* escapementSpace;
|
const escapement_delta* delta;
|
||||||
const float* escapementNonSpace;
|
|
||||||
if (!reader.Get(length)
|
if (!reader.Get(length)
|
||||||
|| !reader.Get(string, *length)
|
|| !reader.Get(string, *length)
|
||||||
|| !reader.Get(escapementSpace)
|
|| !reader.Get(delta)) {
|
||||||
|| !reader.Get(escapementNonSpace)) {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
callbacks.DrawString(string, *length,
|
callbacks.DrawString(string, *length, *delta);
|
||||||
*escapementSpace, *escapementNonSpace);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -157,8 +157,7 @@ public:
|
|||||||
virtual void DrawEllipse(const BRect& rect, 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 DrawPolygon(size_t numPoints, const BPoint points[], bool isClosed, bool fill);
|
||||||
virtual void DrawShape(const BShape& shape, bool fill);
|
virtual void DrawShape(const BShape& shape, bool fill);
|
||||||
virtual void DrawString(const char* string, size_t length, float spaceEscapement,
|
virtual void DrawString(const char* string, size_t length, const escapement_delta& delta);
|
||||||
float nonSpaceEscapement);
|
|
||||||
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
||||||
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
||||||
size_t length);
|
size_t length);
|
||||||
@@ -445,13 +444,12 @@ BoundingBoxCallbacks::DrawShape(const BShape& shape, bool fill)
|
|||||||
|
|
||||||
void
|
void
|
||||||
BoundingBoxCallbacks::DrawString(const char* string, size_t length,
|
BoundingBoxCallbacks::DrawString(const char* string, size_t length,
|
||||||
float deltaSpace, float deltaNonSpace)
|
const escapement_delta& delta)
|
||||||
{
|
{
|
||||||
TRACE_BB("%p string '%s'\n", fState, string);
|
TRACE_BB("%p string '%s'\n", fState, string);
|
||||||
|
|
||||||
ServerFont font = fState->GetDrawState()->Font();
|
ServerFont font = fState->GetDrawState()->Font();
|
||||||
|
|
||||||
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);
|
||||||
|
|||||||
@@ -1029,7 +1029,7 @@ ServerFont::GetBoundingBoxes(const char* string, int32 numBytes, int32 numChars,
|
|||||||
status_t
|
status_t
|
||||||
ServerFont::GetBoundingBoxesForStrings(char *charArray[], size_t lengthArray[],
|
ServerFont::GetBoundingBoxesForStrings(char *charArray[], size_t lengthArray[],
|
||||||
int32 numStrings, BRect rectArray[], font_metric_mode mode,
|
int32 numStrings, BRect rectArray[], font_metric_mode mode,
|
||||||
escapement_delta deltaArray[])
|
const escapement_delta deltaArray[])
|
||||||
{
|
{
|
||||||
// TODO: The font_metric_mode is never used
|
// TODO: The font_metric_mode is never used
|
||||||
if (charArray == NULL || lengthArray == NULL || numStrings <= 0
|
if (charArray == NULL || lengthArray == NULL || numStrings <= 0
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ class ServerFont {
|
|||||||
status_t GetBoundingBoxesForStrings(char *charArray[],
|
status_t GetBoundingBoxesForStrings(char *charArray[],
|
||||||
size_t lengthArray[], int32 numStrings,
|
size_t lengthArray[], int32 numStrings,
|
||||||
BRect rectArray[], font_metric_mode mode,
|
BRect rectArray[], font_metric_mode mode,
|
||||||
escapement_delta deltaArray[]);
|
const escapement_delta deltaArray[]);
|
||||||
|
|
||||||
float StringWidth(const char *string,
|
float StringWidth(const char *string,
|
||||||
int32 numBytes,
|
int32 numBytes,
|
||||||
|
|||||||
@@ -251,8 +251,7 @@ public:
|
|||||||
virtual void DrawEllipse(const BRect& rect, 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 DrawPolygon(size_t numPoints, const BPoint points[], bool isClosed, bool fill);
|
||||||
virtual void DrawShape(const BShape& shape, bool fill);
|
virtual void DrawShape(const BShape& shape, bool fill);
|
||||||
virtual void DrawString(const char* string, size_t length, float spaceEscapement,
|
virtual void DrawString(const char* string, size_t length, const escapement_delta& delta);
|
||||||
float nonSpaceEscapement);
|
|
||||||
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
virtual void DrawPixels(const BRect& source, const BRect& destination, uint32 width,
|
||||||
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
uint32 height, size_t bytesPerRow, color_space pixelFormat, uint32 flags, const void* data,
|
||||||
size_t length);
|
size_t length);
|
||||||
@@ -589,18 +588,16 @@ CanvasCallbacks::StrokeLineGradient(const BPoint& _start, const BPoint& _end,
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
CanvasCallbacks::DrawString(const char* string, size_t length, float deltaSpace,
|
CanvasCallbacks::DrawString(const char* string, size_t length, const escapement_delta& delta)
|
||||||
float deltaNonSpace)
|
|
||||||
{
|
{
|
||||||
// NOTE: the picture data was recorded with a "set pen location"
|
// NOTE: the picture data was recorded with a "set pen location"
|
||||||
// command inserted before the "draw string" command, so we can
|
// command inserted before the "draw string" command, so we can
|
||||||
// use PenLocation()
|
// use PenLocation()
|
||||||
BPoint location = fCanvas->CurrentState()->PenLocation();
|
BPoint location = fCanvas->CurrentState()->PenLocation();
|
||||||
|
|
||||||
escapement_delta delta = { deltaSpace, deltaNonSpace };
|
|
||||||
fCanvas->PenToScreenTransform().Apply(&location);
|
fCanvas->PenToScreenTransform().Apply(&location);
|
||||||
location = fCanvas->GetDrawingEngine()->DrawString(string, length,
|
location = fCanvas->GetDrawingEngine()->DrawString(string, length,
|
||||||
location, &delta);
|
location, const_cast<escapement_delta*>(&delta));
|
||||||
|
|
||||||
fCanvas->PenToScreenTransform().Apply(&location);
|
fCanvas->PenToScreenTransform().Apply(&location);
|
||||||
fCanvas->CurrentState()->SetPenLocation(location);
|
fCanvas->CurrentState()->SetPenLocation(location);
|
||||||
|
|||||||
Reference in New Issue
Block a user