Build fix.

Some code in a just merged patch needs another one that's still being
discussed on Gerrit. Extract just the parts we need to get things
building again.
This commit is contained in:
Adrien Destugues 2020-12-02 20:05:20 +01:00
parent 60d3078585
commit 5f51a74f1a
2 changed files with 15 additions and 10 deletions

View File

@ -57,7 +57,7 @@ Canvas::~Canvas()
status_t
Canvas::InitCheck() const
{
if (fDrawState == NULL)
if (fDrawState.Get() == NULL)
return B_NO_MEMORY;
return B_OK;
@ -67,9 +67,12 @@ Canvas::InitCheck() const
void
Canvas::PushState()
{
DrawState* newState = fDrawState->PushState();
if (newState)
fDrawState = newState;
DrawState* previous = fDrawState.Detach();
DrawState* newState = previous->PushState();
if (newState == NULL)
newState = previous;
fDrawState.SetTo(newState);
}
@ -81,7 +84,7 @@ Canvas::PopState()
bool rebuildClipping = fDrawState->HasAdditionalClipping();
fDrawState = fDrawState->PopState();
fDrawState.SetTo(fDrawState->PopState());
// rebuild clipping
// (the clipping from the popped state is not effective anymore)
@ -93,7 +96,7 @@ Canvas::PopState()
void
Canvas::SetDrawState(DrawState* newState)
{
fDrawState = newState;
fDrawState.SetTo(newState);
}
@ -293,14 +296,13 @@ OffscreenCanvas::OffscreenCanvas(DrawingEngine* engine,
OffscreenCanvas::~OffscreenCanvas()
{
delete fDrawState;
}
void
OffscreenCanvas::ResyncDrawState()
{
fDrawingEngine->SetDrawState(fDrawState);
fDrawingEngine->SetDrawState(fDrawState.Get());
}

View File

@ -15,6 +15,7 @@
#define CANVAS_H
#include <AutoDeleter.h>
#include <Point.h>
#include "SimpleTransform.h"
@ -42,8 +43,9 @@ public:
virtual void PushState();
virtual void PopState();
DrawState* CurrentState() const { return fDrawState; }
DrawState* CurrentState() const { return fDrawState.Get(); }
void SetDrawState(DrawState* newState);
DrawState* DetachDrawState() { return fDrawState.Detach(); }
void SetDrawingOrigin(BPoint origin);
BPoint DrawingOrigin() const;
@ -83,7 +85,8 @@ protected:
SimpleTransform& transform) const = 0;
protected:
DrawState* fDrawState;
ObjectDeleter<DrawState>
fDrawState;
};