Commit 90b0ba8d by Nicolas Capens

Fix rendering to a destroyed gralloc buffer.

Wait for draw calls that use the Android native image to finish before dereferencing the buffer and potentially destroying it. Bug 20885669 Change-Id: I1c8f56e5065ad4c77d7b950feec4505c2e109a47 Reviewed-on: https://swiftshader-review.googlesource.com/3074Reviewed-by: 's avatarGreg Hartman <ghartman@google.com> Tested-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent 6881301e
......@@ -183,12 +183,13 @@ public:
private:
ANativeWindowBuffer *nativeBuffer;
virtual ~AndroidNativeImage() { }
void setNativeBuffer(ANativeWindowBuffer* buffer)
virtual ~AndroidNativeImage()
{
nativeBuffer = buffer;
nativeBuffer->common.incRef(&nativeBuffer->common);
// Wait for any draw calls that use this image to finish
resource->lock(sw::DESTRUCT);
resource->unlock();
nativeBuffer->common.decRef(&nativeBuffer->common);
}
virtual void *lockInternal(int x, int y, int z, sw::Lock lock, sw::Accessor client)
......@@ -255,15 +256,6 @@ private:
{
GrallocModule::getInstance()->unlock(nativeBuffer->handle);
}
virtual void destroyShared() // Release a shared image
{
if(nativeBuffer)
{
nativeBuffer->common.decRef(&nativeBuffer->common);
}
egl::Image::destroyShared();
}
};
#endif // __ANDROID__
......
......@@ -244,6 +244,9 @@ namespace sw
static void setTexturePalette(unsigned int *palette);
protected:
sw::Resource *resource;
private:
typedef unsigned char byte;
typedef unsigned short word;
......@@ -365,7 +368,6 @@ namespace sw
static unsigned int *palette; // FIXME: Not multi-device safe
static unsigned int paletteID;
sw::Resource *resource;
bool hasParent;
};
}
......
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