Fix glReadPixels and glClear memory leaks.

Bug 26486408

Change-Id: Iec34ee0034695950163e8e40082d1ad7128490f8
Reviewed-on: https://swiftshader-review.googlesource.com/4533
Reviewed-by: Alexis Hétu <sugoi@google.com>
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Common/Version.h b/src/Common/Version.h
index 0fc640c..7268708 100644
--- a/src/Common/Version.h
+++ b/src/Common/Version.h
@@ -1,7 +1,7 @@
 #define MAJOR_VERSION 3
 #define MINOR_VERSION 2
 #define BUILD_VERSION 10
-#define BUILD_REVISION 47660
+#define BUILD_REVISION 47661
 
 #define STRINGIFY(x) #x
 #define MACRO_STRINGIFY(x) STRINGIFY(x)
diff --git a/src/OpenGL/libEGL/Surface.cpp b/src/OpenGL/libEGL/Surface.cpp
index 7cae134..345454f 100644
--- a/src/OpenGL/libEGL/Surface.cpp
+++ b/src/OpenGL/libEGL/Surface.cpp
@@ -367,6 +367,7 @@
 

 void PBufferSurface::deleteResources()

 {

+	Surface::deleteResources();

 }

 

 }

diff --git a/src/OpenGL/libGLESv2/Context.cpp b/src/OpenGL/libGLESv2/Context.cpp
index 4731c13..1982b33 100644
--- a/src/OpenGL/libGLESv2/Context.cpp
+++ b/src/OpenGL/libGLESv2/Context.cpp
@@ -3300,6 +3300,8 @@
 	sw::SliceRect sliceRect(rect);

 	sw::SliceRect dstSliceRect(dstRect);

 	device->blit(renderTarget, sliceRect, &externalSurface, dstSliceRect, false);

+

+	renderTarget->release();

 }

 

 void Context::clear(GLbitfield mask)

@@ -3358,6 +3360,8 @@
 		{

 			device->clear(value, format, image, sliceRect, rgbaMask);

 		}

+

+		image->release();

 	}

 }

 

@@ -3385,6 +3389,8 @@
 

 		float depth = clamp01(value[0]);

 		image->clearDepthBuffer(depth, x0, y0, width, height);

+

+		image->release();

 	}

 }

 

@@ -3397,6 +3403,8 @@
 

 		unsigned char stencil = value[0] < 0 ? 0 : static_cast<unsigned char>(value[0] & 0x000000FF);

 		image->clearStencilBuffer(stencil, static_cast<unsigned char>(mState.stencilWritemask), x0, y0, width, height);

+

+		image->release();

 	}

 }

 

@@ -3416,6 +3424,8 @@
 		{

 			image->clearDepthBuffer(clamp01(depth), x0, y0, width, height);

 		}

+

+		image->release();

 	}

 }