From b971358df3dacc249cefbd9e39ae6b0fc92eb1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 1 Feb 2014 22:35:19 +0100 Subject: [PATCH] AlphaMasks: Use correct DrawState when playing picture The current drawing state when the picture starts playing is the base state that drawing commands in the picture itself should not be able to modify. In the ClipToPicture test, the nested state test now at least draws the last picture at the correctly scaled location. --- src/servers/app/AlphaMask.cpp | 6 ++++-- src/servers/app/DrawingContext.cpp | 21 ++++++++++++++++++++- src/servers/app/DrawingContext.h | 6 +++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/servers/app/AlphaMask.cpp b/src/servers/app/AlphaMask.cpp index 6cf33d9867..0c6ab9babc 100644 --- a/src/servers/app/AlphaMask.cpp +++ b/src/servers/app/AlphaMask.cpp @@ -116,9 +116,9 @@ AlphaMask::_RenderPicture() const return NULL; } - engine->SetDrawState(&fDrawState); + OffscreenContext context(engine, fDrawState); + context.PushState(); - OffscreenContext context(engine); if (engine->LockParallelAccess()) { // FIXME ConstrainClippingRegion docs says passing NULL disables // all clipping. This doesn't work and will crash in Painter. @@ -128,6 +128,8 @@ AlphaMask::_RenderPicture() const fPicture->Play(&context); engine->UnlockParallelAccess(); } + + context.PopState(); delete engine; if (!fInverse) diff --git a/src/servers/app/DrawingContext.cpp b/src/servers/app/DrawingContext.cpp index 28de180324..676a00e79c 100644 --- a/src/servers/app/DrawingContext.cpp +++ b/src/servers/app/DrawingContext.cpp @@ -23,12 +23,20 @@ #include #include +#include "DrawingEngine.h" #include "DrawState.h" DrawingContext::DrawingContext() : - fDrawState(new (std::nothrow) DrawState) + fDrawState(new(std::nothrow) DrawState()) +{ +} + + +DrawingContext::DrawingContext(const DrawState& state) + : + fDrawState(new(std::nothrow) DrawState(state)) { } @@ -304,3 +312,14 @@ DrawingContext::ConvertFromScreenForDrawing(BPoint* point) const } +// #pragma mark - OffscreenContext + + +OffscreenContext::OffscreenContext(DrawingEngine* engine, + const DrawState& state) + : + DrawingContext(state), + fDrawingEngine(engine) +{ + fDrawingEngine->SetDrawState(fDrawState); +} diff --git a/src/servers/app/DrawingContext.h b/src/servers/app/DrawingContext.h index f791efb50e..f2aa499aaf 100644 --- a/src/servers/app/DrawingContext.h +++ b/src/servers/app/DrawingContext.h @@ -30,6 +30,7 @@ class ServerPicture; class DrawingContext { public: DrawingContext(); + DrawingContext(const DrawState& state); virtual ~DrawingContext(); status_t InitCheck() const; @@ -83,9 +84,8 @@ protected: class OffscreenContext: public DrawingContext { public: - OffscreenContext(DrawingEngine* engine) - : fDrawingEngine(engine) - {}; + OffscreenContext(DrawingEngine* engine, + const DrawState& state); // Screen and View coordinates are the same for us. // DrawState already takes care of World<>View