From 2d69e313a8ed80986fb84b8b1bc04b03aa4b91cd Mon Sep 17 00:00:00 2001 From: waddlesplash Date: Wed, 10 Jun 2020 01:19:51 +0000 Subject: [PATCH] Revert "app_server: fix transformations in BPicture" This reverts commit b8e5671d5318e59ad4e36f047940521d18d1f5ed. Reason for revert: Broke all builds. Change-Id: Ie7c5b4a3c877894a1dc49a9de7a19f79e7eb2ab7 Reviewed-on: https://review.haiku-os.org/c/haiku/+/2897 Reviewed-by: waddlesplash --- src/servers/app/ServerPicture.cpp | 53 ++++------------------- src/servers/app/ServerWindow.cpp | 24 ++++++---- src/servers/app/drawing/DrawingEngine.cpp | 5 +-- src/servers/app/drawing/DrawingEngine.h | 3 +- src/servers/app/drawing/Painter/Painter.h | 3 +- 5 files changed, 29 insertions(+), 59 deletions(-) diff --git a/src/servers/app/ServerPicture.cpp b/src/servers/app/ServerPicture.cpp index 9a5f8c3136..162f641a3b 100644 --- a/src/servers/app/ServerPicture.cpp +++ b/src/servers/app/ServerPicture.cpp @@ -208,18 +208,10 @@ ShapePainter::Draw(BRect frame, bool filled) fPtStack.pop(); } - // this might seem a bit weird, but under R5, the shapes - // are always offset by the current pen location - BPoint screenOffset - = fCanvas->CurrentState()->PenLocation(); - frame.OffsetBy(screenOffset); - - const SimpleTransform transform = fCanvas->PenToScreenTransform(); - transform.Apply(&screenOffset); - transform.Apply(&frame); - + BPoint offset(fCanvas->CurrentState()->PenLocation()); + fCanvas->PenToScreenTransform().Apply(&offset); fCanvas->GetDrawingEngine()->DrawShape(frame, opCount, opList, - ptCount, ptList, filled, screenOffset, fCanvas->Scale()); + ptCount, ptList, filled, offset, fCanvas->Scale()); delete[] opList; delete[] ptList; @@ -415,18 +407,9 @@ draw_string(void* _canvas, const char* string, size_t length, float deltaSpace, static void 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); - BStackOrHeapArray 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, locations); @@ -775,13 +758,8 @@ static void set_transform(void* _canvas, const BAffineTransform& transform) { Canvas* const canvas = reinterpret_cast(_canvas); - - BPoint leftTop(0, 0); - canvas->PenToScreenTransform().Apply(&leftTop); - canvas->CurrentState()->SetTransform(transform); - canvas->GetDrawingEngine()->SetTransform( - canvas->CurrentState()->CombinedTransform(), leftTop.x, leftTop.y); + canvas->GetDrawingEngine()->SetTransform(transform); } @@ -789,15 +767,10 @@ static void translate_by(void* _canvas, double x, double y) { Canvas* const canvas = reinterpret_cast(_canvas); - - BPoint leftTop(0, 0); - canvas->PenToScreenTransform().Apply(&leftTop); - BAffineTransform transform = canvas->CurrentState()->Transform(); transform.PreTranslateBy(x, y); canvas->CurrentState()->SetTransform(transform); - canvas->GetDrawingEngine()->SetTransform( - canvas->CurrentState()->CombinedTransform(), leftTop.x, leftTop.y); + canvas->GetDrawingEngine()->SetTransform(transform); } @@ -805,15 +778,10 @@ static void scale_by(void* _canvas, double x, double y) { Canvas* const canvas = reinterpret_cast(_canvas); - - BPoint leftTop(0, 0); - canvas->PenToScreenTransform().Apply(&leftTop); - BAffineTransform transform = canvas->CurrentState()->Transform(); transform.PreScaleBy(x, y); canvas->CurrentState()->SetTransform(transform); - canvas->GetDrawingEngine()->SetTransform( - canvas->CurrentState()->CombinedTransform(), leftTop.x, leftTop.y); + canvas->GetDrawingEngine()->SetTransform(transform); } @@ -821,15 +789,10 @@ static void rotate_by(void* _canvas, double angleRadians) { Canvas* const canvas = reinterpret_cast(_canvas); - - BPoint leftTop(0, 0); - canvas->PenToScreenTransform().Apply(&leftTop); - BAffineTransform transform = canvas->CurrentState()->Transform(); transform.PreRotateBy(angleRadians); canvas->CurrentState()->SetTransform(transform); - canvas->GetDrawingEngine()->SetTransform( - canvas->CurrentState()->CombinedTransform(), leftTop.x, leftTop.y); + canvas->GetDrawingEngine()->SetTransform(transform); } diff --git a/src/servers/app/ServerWindow.cpp b/src/servers/app/ServerWindow.cpp index 16a4ad7b6a..f236c10969 100644 --- a/src/servers/app/ServerWindow.cpp +++ b/src/servers/app/ServerWindow.cpp @@ -3671,16 +3671,24 @@ ServerWindow::_DispatchPictureMessage(int32 code, BPrivate::LinkReceiver& link) link.Read(&opCount); link.Read(&ptCount); - BStackOrHeapArray opList(opCount); - BStackOrHeapArray ptList(ptCount); - if (!opList.IsValid() || !ptList.IsValid() - || link.Read(opList, opCount * sizeof(uint32)) < B_OK - || link.Read(ptList, ptCount * sizeof(BPoint)) < B_OK) { - break; + uint32* opList = new(std::nothrow) uint32[opCount]; + BPoint* ptList = new(std::nothrow) BPoint[ptCount]; + if (opList != NULL && ptList != NULL + && link.Read(opList, opCount * sizeof(uint32)) >= B_OK + && link.Read(ptList, ptCount * sizeof(BPoint)) >= B_OK) { + // 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; } diff --git a/src/servers/app/drawing/DrawingEngine.cpp b/src/servers/app/drawing/DrawingEngine.cpp index 8d50de84a5..c4e50f6da0 100644 --- a/src/servers/app/drawing/DrawingEngine.cpp +++ b/src/servers/app/drawing/DrawingEngine.cpp @@ -323,10 +323,9 @@ DrawingEngine::SetFont(const DrawState* state) void -DrawingEngine::SetTransform(const BAffineTransform& transform, int32 xOffset, - int32 yOffset) +DrawingEngine::SetTransform(const BAffineTransform& transform) { - fPainter->SetTransform(transform, xOffset, yOffset); + fPainter->SetTransform(transform); } diff --git a/src/servers/app/drawing/DrawingEngine.h b/src/servers/app/drawing/DrawingEngine.h index 763e8f995d..dc010bb925 100644 --- a/src/servers/app/drawing/DrawingEngine.h +++ b/src/servers/app/drawing/DrawingEngine.h @@ -86,8 +86,7 @@ public: alpha_function alphaFunc); virtual void SetFont(const ServerFont& font); virtual void SetFont(const DrawState* state); - virtual void SetTransform(const BAffineTransform& transform, - int32 xOffset, int32 yOffset); + virtual void SetTransform(const BAffineTransform& transform); void SuspendAutoSync(); void Sync(); diff --git a/src/servers/app/drawing/Painter/Painter.h b/src/servers/app/drawing/Painter/Painter.h index c997dfd00e..fc22b08193 100644 --- a/src/servers/app/drawing/Painter/Painter.h +++ b/src/servers/app/drawing/Painter/Painter.h @@ -68,7 +68,8 @@ public: // object settings void SetTransform(BAffineTransform transform, - int32 xOffset, int32 yOffset); + int32 xOffset = 0, + int32 yOffset = 0); inline bool IsIdentityTransform() const { return fIdentityTransform; }