Commit b4af9f7b by Nicolas Capens

Fix memory leaks.

Change-Id: I668c4295fd13d028fa53f6aa75ac6c6d4c6de44f Reviewed-on: https://swiftshader-review.googlesource.com/4531Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 9185981d
......@@ -56,7 +56,7 @@ Surface::Surface(const Display *display, const Config *config) : display(display
Surface::~Surface()
{
deleteResources();
Surface::deleteResources();
}
bool Surface::initialize()
......@@ -230,6 +230,11 @@ WindowSurface::WindowSurface(Display *display, const Config *config, EGLNativeWi
frameBuffer = nullptr;
}
WindowSurface::~WindowSurface()
{
WindowSurface::deleteResources();
}
bool WindowSurface::initialize()
{
ASSERT(!frameBuffer && !backBuffer && !depthStencil);
......@@ -343,6 +348,11 @@ PBufferSurface::PBufferSurface(Display *display, const Config *config, EGLint wi
this->largestPBuffer = largestPBuffer;
}
PBufferSurface::~PBufferSurface()
{
PBufferSurface::deleteResources();
}
void PBufferSurface::swap()
{
// No effect
......@@ -355,4 +365,8 @@ EGLNativeWindowType PBufferSurface::getWindowHandle() const
return 0;
}
void PBufferSurface::deleteResources()
{
}
}
......@@ -33,7 +33,7 @@ class Surface : public gl::Object
public:
virtual bool initialize();
virtual void swap() = 0;
virtual egl::Image *getRenderTarget();
virtual egl::Image *getDepthStencil();
......@@ -73,7 +73,7 @@ protected:
Texture *texture;
bool reset(int backbufferWidth, int backbufferHeight);
const Config *const config; // EGL config surface was created with
EGLint height; // Height of surface
EGLint width; // Width of surface
......@@ -97,6 +97,7 @@ class WindowSurface : public Surface
{
public:
WindowSurface(Display *display, const egl::Config *config, EGLNativeWindowType window);
~WindowSurface() override;
bool initialize() override;
......@@ -118,11 +119,15 @@ class PBufferSurface : public Surface
{
public:
PBufferSurface(Display *display, const egl::Config *config, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget, EGLBoolean largestPBuffer);
~PBufferSurface() override;
bool isPBufferSurface() const override { return true; }
void swap() override;
EGLNativeWindowType getWindowHandle() const override;
private:
void deleteResources() override;
};
}
......
......@@ -30,6 +30,7 @@ namespace sw
struct Registers
{
Registers();
virtual ~Registers() {};
Pointer<Byte> constants;
......
......@@ -75,7 +75,7 @@ namespace sw
Float4 &operator[](int i);
Vector4f &operator=(const Vector4f &rhs);
Float4 x;
Float4 y;
Float4 z;
......@@ -200,10 +200,20 @@ namespace sw
~RegisterArray()
{
delete[] x;
delete[] y;
delete[] z;
delete[] w;
if(dynamic)
{
delete x;
delete y;
delete z;
delete w;
}
else
{
delete[] x;
delete[] y;
delete[] z;
delete[] w;
}
}
Register operator[](int i)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment