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.
This commit is contained in:
Stephan Aßmus
2014-02-01 22:35:19 +01:00
parent ce2c561521
commit b971358df3
3 changed files with 27 additions and 6 deletions
+4 -2
View File
@@ -116,9 +116,9 @@ AlphaMask::_RenderPicture() const
return NULL; return NULL;
} }
engine->SetDrawState(&fDrawState); OffscreenContext context(engine, fDrawState);
context.PushState();
OffscreenContext context(engine);
if (engine->LockParallelAccess()) { if (engine->LockParallelAccess()) {
// FIXME ConstrainClippingRegion docs says passing NULL disables // FIXME ConstrainClippingRegion docs says passing NULL disables
// all clipping. This doesn't work and will crash in Painter. // all clipping. This doesn't work and will crash in Painter.
@@ -128,6 +128,8 @@ AlphaMask::_RenderPicture() const
fPicture->Play(&context); fPicture->Play(&context);
engine->UnlockParallelAccess(); engine->UnlockParallelAccess();
} }
context.PopState();
delete engine; delete engine;
if (!fInverse) if (!fInverse)
+20 -1
View File
@@ -23,12 +23,20 @@
#include <GradientConic.h> #include <GradientConic.h>
#include <Region.h> #include <Region.h>
#include "DrawingEngine.h"
#include "DrawState.h" #include "DrawState.h"
DrawingContext::DrawingContext() 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);
}
+3 -3
View File
@@ -30,6 +30,7 @@ class ServerPicture;
class DrawingContext { class DrawingContext {
public: public:
DrawingContext(); DrawingContext();
DrawingContext(const DrawState& state);
virtual ~DrawingContext(); virtual ~DrawingContext();
status_t InitCheck() const; status_t InitCheck() const;
@@ -83,9 +84,8 @@ protected:
class OffscreenContext: public DrawingContext { class OffscreenContext: public DrawingContext {
public: public:
OffscreenContext(DrawingEngine* engine) OffscreenContext(DrawingEngine* engine,
: fDrawingEngine(engine) const DrawState& state);
{};
// Screen and View coordinates are the same for us. // Screen and View coordinates are the same for us.
// DrawState already takes care of World<>View // DrawState already takes care of World<>View