Commit c30c424f by Jamie Madill

Make egl::Surface ref-counted.

This will let us store references to Surface in FBO attachments, even after the surface is destroyed. BUG=angleproject:963 Change-Id: I7e1cb161d1e08f78b1c4d730a32ad09ac7e61e30 Reviewed-on: https://chromium-review.googlesource.com/263482Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent d1f5ef2e
......@@ -12,9 +12,9 @@
#include "RefCountObject.h"
RefCountObject::RefCountObject(GLuint id)
: mId(id),
mRefCount(0)
{
mId = id;
mRefCount = 0;
}
RefCountObject::~RefCountObject()
......
......@@ -20,7 +20,8 @@ namespace egl
{
Surface::Surface(rx::SurfaceImpl *impl, EGLint surfaceType, const egl::Config *config, const AttributeMap &attributes)
: mImplementation(impl),
: RefCountObject(0), // id unused
mImplementation(impl),
mType(surfaceType),
mConfig(config),
mPostSubBufferRequested(false),
......@@ -35,6 +36,8 @@ Surface::Surface(rx::SurfaceImpl *impl, EGLint surfaceType, const egl::Config *c
mSwapBehavior(EGL_BUFFER_PRESERVED),
mTexture(NULL)
{
addRef();
mPostSubBufferRequested = (attributes.get(EGL_POST_SUB_BUFFER_SUPPORTED_NV, EGL_FALSE) == EGL_TRUE);
mFixedSize = (attributes.get(EGL_FIXED_SIZE_ANGLE, EGL_FALSE) == EGL_TRUE);
......
......@@ -11,10 +11,11 @@
#ifndef LIBANGLE_SURFACE_H_
#define LIBANGLE_SURFACE_H_
#include <EGL/egl.h>
#include "common/angleutils.h"
#include "libANGLE/Error.h"
#include <EGL/egl.h>
#include "libANGLE/RefCountObject.h"
namespace gl
{
......@@ -32,11 +33,10 @@ class AttributeMap;
class Display;
struct Config;
class Surface final : angle::NonCopyable
class Surface final : public RefCountObject
{
public:
Surface(rx::SurfaceImpl *impl, EGLint surfaceType, const egl::Config *config, const AttributeMap &attributes);
~Surface();
rx::SurfaceImpl *getImplementation() { return mImplementation; }
const rx::SurfaceImpl *getImplementation() const { return mImplementation; }
......@@ -69,6 +69,8 @@ class Surface final : angle::NonCopyable
EGLint isFixedSize() const;
private:
virtual ~Surface();
rx::SurfaceImpl *mImplementation;
EGLint mType;
......
......@@ -45,7 +45,7 @@ class SurfaceTest : public testing::Test
virtual void TearDown()
{
delete mSurface;
mSurface->release();
}
MockSurfaceImpl *mImpl;
......@@ -59,7 +59,7 @@ TEST_F(SurfaceTest, DestructionDeletesImpl)
EXPECT_CALL(*impl, destroy()).Times(1).RetiresOnSaturation();
egl::Surface *surface = new egl::Surface(impl, EGL_WINDOW_BIT, &mConfig, egl::AttributeMap());
delete surface;
surface->release();
// Only needed because the mock is leaked if bugs are present,
// which logs an error, but does not cause the test to fail.
......
......@@ -30,7 +30,7 @@ DisplayImpl::~DisplayImpl()
void DisplayImpl::destroySurface(egl::Surface *surface)
{
mSurfaceSet.erase(surface);
SafeDelete(surface);
surface->release();
}
const egl::DisplayExtensions &DisplayImpl::getExtensions() const
......
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