Commit 4d614fd8 by Greg Hartman

Detect undersize buffers being delivered by ANativeWindow

Change-Id: I02f328e7a2ad46877d00d5bc1de1439bebb23802 Reviewed-on: https://swiftshader-review.googlesource.com/3012Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarGreg Hartman <ghartman@google.com>
parent 05e0cd36
......@@ -6,8 +6,8 @@
namespace sw
{
FrameBufferAndroid::FrameBufferAndroid(ANativeWindow* window, int width, int height)
: FrameBuffer(width, height, false, false),
nativeWindow(window), buffer(0), gralloc(0)
: FrameBuffer(width, height, false, false),
nativeWindow(window), buffer(0), gralloc(0)
{
hw_module_t const* pModule;
hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &pModule);
......@@ -31,15 +31,14 @@ namespace sw
void FrameBufferAndroid::blit(void *source, const Rect *sourceRect, const Rect *destRect, Format format)
{
copy(source, format);
nativeWindow->queueBuffer(nativeWindow, buffer, -1);
if (buffer && locked)
{
locked = 0;
unlock(buffer);
}
nativeWindow->queueBuffer(nativeWindow, buffer, -1);
if (buffer && locked)
{
locked = 0;
unlock(buffer);
}
buffer->common.decRef(&buffer->common);
buffer->common.decRef(&buffer->common);
}
void* FrameBufferAndroid::lock()
......@@ -65,6 +64,13 @@ namespace sw
return NULL;
}
if ((buffer->width < width) || (buffer->height < height))
{
ALOGI("lock failed: buffer of %dx%d too small for window of %dx%d",
buffer->width, buffer->height, width, height);
return NULL;
}
switch(buffer->format)
{
default: ALOGE("Unsupported buffer format %d", buffer->format); ASSERT(false);
......
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