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