app_server: plug DrawState instance leak, other minor fixes

* OffscreenCanvas was not deleting its DrawState. Found thanks to
  the allocation tracking feature in libroot_debug (thanks mmlr!)

* Also a missing nothrow and a missing ref release in an error case
This commit is contained in:
Julian Harnath
2015-11-14 16:09:45 +01:00
parent bcc5cf7d29
commit 2193dcd799
2 changed files with 9 additions and 1 deletions
+8 -1
View File
@@ -262,9 +262,10 @@ Canvas::BlendLayer(Layer* layer)
fDrawState->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); fDrawState->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);
fDrawState->SetTransformEnabled(false); fDrawState->SetTransformEnabled(false);
AlphaMask* mask = new UniformAlphaMask(layer->Opacity()); AlphaMask* mask = new(std::nothrow) UniformAlphaMask(layer->Opacity());
if (mask == NULL) { if (mask == NULL) {
layerBitmap->ReleaseReference(); layerBitmap->ReleaseReference();
layer->ReleaseReference();
return; return;
} }
@@ -299,6 +300,12 @@ OffscreenCanvas::OffscreenCanvas(DrawingEngine* engine,
} }
OffscreenCanvas::~OffscreenCanvas()
{
delete fDrawState;
}
void void
OffscreenCanvas::ResyncDrawState() OffscreenCanvas::ResyncDrawState()
{ {
+1
View File
@@ -91,6 +91,7 @@ class OffscreenCanvas : public Canvas {
public: public:
OffscreenCanvas(DrawingEngine* engine, OffscreenCanvas(DrawingEngine* engine,
const DrawState& state, const IntRect& bounds); const DrawState& state, const IntRect& bounds);
virtual ~OffscreenCanvas();
virtual DrawingEngine* GetDrawingEngine() const { return fDrawingEngine; } virtual DrawingEngine* GetDrawingEngine() const { return fDrawingEngine; }