Revert "app_server: fix transformations in BPicture"

This reverts commit b8e5671d53.

Reason for revert: Broke all builds.

Change-Id: Ie7c5b4a3c877894a1dc49a9de7a19f79e7eb2ab7
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2897
Reviewed-by: waddlesplash <waddlesplash@gmail.com>
This commit is contained in:
waddlesplash 2020-06-10 01:19:51 +00:00
parent b8e5671d53
commit 2d69e313a8
5 changed files with 29 additions and 59 deletions

View File

@ -208,18 +208,10 @@ ShapePainter::Draw(BRect frame, bool filled)
fPtStack.pop(); fPtStack.pop();
} }
// this might seem a bit weird, but under R5, the shapes BPoint offset(fCanvas->CurrentState()->PenLocation());
// are always offset by the current pen location fCanvas->PenToScreenTransform().Apply(&offset);
BPoint screenOffset
= fCanvas->CurrentState()->PenLocation();
frame.OffsetBy(screenOffset);
const SimpleTransform transform = fCanvas->PenToScreenTransform();
transform.Apply(&screenOffset);
transform.Apply(&frame);
fCanvas->GetDrawingEngine()->DrawShape(frame, opCount, opList, fCanvas->GetDrawingEngine()->DrawShape(frame, opCount, opList,
ptCount, ptList, filled, screenOffset, fCanvas->Scale()); ptCount, ptList, filled, offset, fCanvas->Scale());
delete[] opList; delete[] opList;
delete[] ptList; delete[] ptList;
@ -415,18 +407,9 @@ draw_string(void* _canvas, const char* string, size_t length, float deltaSpace,
static void static void
draw_string_locations(void* _canvas, const char* string, size_t length, draw_string_locations(void* _canvas, const char* string, size_t length,
const BPoint* _locations, size_t locationsCount) const BPoint* locations, size_t locationsCount)
{ {
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas); Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
BStackOrHeapArray<BPoint, 200> locations(locationsCount);
if (!locations.IsValid())
return;
const SimpleTransform transform = canvas->PenToScreenTransform();
for (size_t i = 0; i < locationsCount; i++) {
locations[i] = _locations[i];
transform.Apply(&locations[i]);
}
BPoint location = canvas->GetDrawingEngine()->DrawString(string, length, BPoint location = canvas->GetDrawingEngine()->DrawString(string, length,
locations); locations);
@ -775,13 +758,8 @@ static void
set_transform(void* _canvas, const BAffineTransform& transform) set_transform(void* _canvas, const BAffineTransform& transform)
{ {
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas); Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
BPoint leftTop(0, 0);
canvas->PenToScreenTransform().Apply(&leftTop);
canvas->CurrentState()->SetTransform(transform); canvas->CurrentState()->SetTransform(transform);
canvas->GetDrawingEngine()->SetTransform( canvas->GetDrawingEngine()->SetTransform(transform);
canvas->CurrentState()->CombinedTransform(), leftTop.x, leftTop.y);
} }
@ -789,15 +767,10 @@ static void
translate_by(void* _canvas, double x, double y) translate_by(void* _canvas, double x, double y)
{ {
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas); Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
BPoint leftTop(0, 0);
canvas->PenToScreenTransform().Apply(&leftTop);
BAffineTransform transform = canvas->CurrentState()->Transform(); BAffineTransform transform = canvas->CurrentState()->Transform();
transform.PreTranslateBy(x, y); transform.PreTranslateBy(x, y);
canvas->CurrentState()->SetTransform(transform); canvas->CurrentState()->SetTransform(transform);
canvas->GetDrawingEngine()->SetTransform( canvas->GetDrawingEngine()->SetTransform(transform);
canvas->CurrentState()->CombinedTransform(), leftTop.x, leftTop.y);
} }
@ -805,15 +778,10 @@ static void
scale_by(void* _canvas, double x, double y) scale_by(void* _canvas, double x, double y)
{ {
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas); Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
BPoint leftTop(0, 0);
canvas->PenToScreenTransform().Apply(&leftTop);
BAffineTransform transform = canvas->CurrentState()->Transform(); BAffineTransform transform = canvas->CurrentState()->Transform();
transform.PreScaleBy(x, y); transform.PreScaleBy(x, y);
canvas->CurrentState()->SetTransform(transform); canvas->CurrentState()->SetTransform(transform);
canvas->GetDrawingEngine()->SetTransform( canvas->GetDrawingEngine()->SetTransform(transform);
canvas->CurrentState()->CombinedTransform(), leftTop.x, leftTop.y);
} }
@ -821,15 +789,10 @@ static void
rotate_by(void* _canvas, double angleRadians) rotate_by(void* _canvas, double angleRadians)
{ {
Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas); Canvas* const canvas = reinterpret_cast<Canvas*>(_canvas);
BPoint leftTop(0, 0);
canvas->PenToScreenTransform().Apply(&leftTop);
BAffineTransform transform = canvas->CurrentState()->Transform(); BAffineTransform transform = canvas->CurrentState()->Transform();
transform.PreRotateBy(angleRadians); transform.PreRotateBy(angleRadians);
canvas->CurrentState()->SetTransform(transform); canvas->CurrentState()->SetTransform(transform);
canvas->GetDrawingEngine()->SetTransform( canvas->GetDrawingEngine()->SetTransform(transform);
canvas->CurrentState()->CombinedTransform(), leftTop.x, leftTop.y);
} }

View File

@ -3671,16 +3671,24 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver& link)
link.Read<int32>(&opCount); link.Read<int32>(&opCount);
link.Read<int32>(&ptCount); link.Read<int32>(&ptCount);
BStackOrHeapArray<uint32, 512> opList(opCount); uint32* opList = new(std::nothrow) uint32[opCount];
BStackOrHeapArray<BPoint, 512> ptList(ptCount); BPoint* ptList = new(std::nothrow) BPoint[ptCount];
if (!opList.IsValid() || !ptList.IsValid() if (opList != NULL && ptList != NULL
|| link.Read(opList, opCount * sizeof(uint32)) < B_OK && link.Read(opList, opCount * sizeof(uint32)) >= B_OK
|| link.Read(ptList, ptCount * sizeof(BPoint)) < B_OK) { && link.Read(ptList, ptCount * sizeof(BPoint)) >= B_OK) {
break; // This might seem a bit weird, but under BeOS, the shapes
// are always offset by the current pen location
BPoint penLocation
= fCurrentView->CurrentState()->PenLocation();
for (int32 i = 0; i < ptCount; i++) {
ptList[i] += penLocation;
}
const bool fill = (code == AS_FILL_SHAPE);
picture->WriteDrawShape(opCount, opList, ptCount, ptList, fill);
} }
picture->WriteDrawShape(opCount, opList, ptCount,
ptList, code == AS_FILL_SHAPE);
delete[] opList;
delete[] ptList;
break; break;
} }

View File

@ -323,10 +323,9 @@ DrawingEngine::SetFont(const DrawState* state)
void void
DrawingEngine::SetTransform(const BAffineTransform& transform, int32 xOffset, DrawingEngine::SetTransform(const BAffineTransform& transform)
int32 yOffset)
{ {
fPainter->SetTransform(transform, xOffset, yOffset); fPainter->SetTransform(transform);
} }

View File

@ -86,8 +86,7 @@ public:
alpha_function alphaFunc); alpha_function alphaFunc);
virtual void SetFont(const ServerFont& font); virtual void SetFont(const ServerFont& font);
virtual void SetFont(const DrawState* state); virtual void SetFont(const DrawState* state);
virtual void SetTransform(const BAffineTransform& transform, virtual void SetTransform(const BAffineTransform& transform);
int32 xOffset, int32 yOffset);
void SuspendAutoSync(); void SuspendAutoSync();
void Sync(); void Sync();

View File

@ -68,7 +68,8 @@ public:
// object settings // object settings
void SetTransform(BAffineTransform transform, void SetTransform(BAffineTransform transform,
int32 xOffset, int32 yOffset); int32 xOffset = 0,
int32 yOffset = 0);
inline bool IsIdentityTransform() const inline bool IsIdentityTransform() const
{ return fIdentityTransform; } { return fIdentityTransform; }