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 ...@@ -56,7 +56,7 @@ Surface::Surface(const Display *display, const Config *config) : display(display
Surface::~Surface() Surface::~Surface()
{ {
deleteResources(); Surface::deleteResources();
} }
bool Surface::initialize() bool Surface::initialize()
...@@ -230,6 +230,11 @@ WindowSurface::WindowSurface(Display *display, const Config *config, EGLNativeWi ...@@ -230,6 +230,11 @@ WindowSurface::WindowSurface(Display *display, const Config *config, EGLNativeWi
frameBuffer = nullptr; frameBuffer = nullptr;
} }
WindowSurface::~WindowSurface()
{
WindowSurface::deleteResources();
}
bool WindowSurface::initialize() bool WindowSurface::initialize()
{ {
ASSERT(!frameBuffer && !backBuffer && !depthStencil); ASSERT(!frameBuffer && !backBuffer && !depthStencil);
...@@ -343,6 +348,11 @@ PBufferSurface::PBufferSurface(Display *display, const Config *config, EGLint wi ...@@ -343,6 +348,11 @@ PBufferSurface::PBufferSurface(Display *display, const Config *config, EGLint wi
this->largestPBuffer = largestPBuffer; this->largestPBuffer = largestPBuffer;
} }
PBufferSurface::~PBufferSurface()
{
PBufferSurface::deleteResources();
}
void PBufferSurface::swap() void PBufferSurface::swap()
{ {
// No effect // No effect
...@@ -355,4 +365,8 @@ EGLNativeWindowType PBufferSurface::getWindowHandle() const ...@@ -355,4 +365,8 @@ EGLNativeWindowType PBufferSurface::getWindowHandle() const
return 0; return 0;
} }
void PBufferSurface::deleteResources()
{
}
} }
...@@ -33,7 +33,7 @@ class Surface : public gl::Object ...@@ -33,7 +33,7 @@ class Surface : public gl::Object
public: public:
virtual bool initialize(); virtual bool initialize();
virtual void swap() = 0; virtual void swap() = 0;
virtual egl::Image *getRenderTarget(); virtual egl::Image *getRenderTarget();
virtual egl::Image *getDepthStencil(); virtual egl::Image *getDepthStencil();
...@@ -73,7 +73,7 @@ protected: ...@@ -73,7 +73,7 @@ protected:
Texture *texture; Texture *texture;
bool reset(int backbufferWidth, int backbufferHeight); bool reset(int backbufferWidth, int backbufferHeight);
const Config *const config; // EGL config surface was created with const Config *const config; // EGL config surface was created with
EGLint height; // Height of surface EGLint height; // Height of surface
EGLint width; // Width of surface EGLint width; // Width of surface
...@@ -97,6 +97,7 @@ class WindowSurface : public Surface ...@@ -97,6 +97,7 @@ class WindowSurface : public Surface
{ {
public: public:
WindowSurface(Display *display, const egl::Config *config, EGLNativeWindowType window); WindowSurface(Display *display, const egl::Config *config, EGLNativeWindowType window);
~WindowSurface() override;
bool initialize() override; bool initialize() override;
...@@ -118,11 +119,15 @@ class PBufferSurface : public Surface ...@@ -118,11 +119,15 @@ class PBufferSurface : public Surface
{ {
public: public:
PBufferSurface(Display *display, const egl::Config *config, EGLint width, EGLint height, EGLenum textureFormat, EGLenum textureTarget, EGLBoolean largestPBuffer); 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; } bool isPBufferSurface() const override { return true; }
void swap() override; void swap() override;
EGLNativeWindowType getWindowHandle() const override; EGLNativeWindowType getWindowHandle() const override;
private:
void deleteResources() override;
}; };
} }
......
...@@ -30,6 +30,7 @@ namespace sw ...@@ -30,6 +30,7 @@ namespace sw
struct Registers struct Registers
{ {
Registers(); Registers();
virtual ~Registers() {};
Pointer<Byte> constants; Pointer<Byte> constants;
......
...@@ -75,7 +75,7 @@ namespace sw ...@@ -75,7 +75,7 @@ namespace sw
Float4 &operator[](int i); Float4 &operator[](int i);
Vector4f &operator=(const Vector4f &rhs); Vector4f &operator=(const Vector4f &rhs);
Float4 x; Float4 x;
Float4 y; Float4 y;
Float4 z; Float4 z;
...@@ -200,10 +200,20 @@ namespace sw ...@@ -200,10 +200,20 @@ namespace sw
~RegisterArray() ~RegisterArray()
{ {
delete[] x; if(dynamic)
delete[] y; {
delete[] z; delete x;
delete[] w; delete y;
delete z;
delete w;
}
else
{
delete[] x;
delete[] y;
delete[] z;
delete[] w;
}
} }
Register operator[](int i) 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