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 @@ ...@@ -6,8 +6,8 @@
namespace sw namespace sw
{ {
FrameBufferAndroid::FrameBufferAndroid(ANativeWindow* window, int width, int height) FrameBufferAndroid::FrameBufferAndroid(ANativeWindow* window, int width, int height)
: FrameBuffer(width, height, false, false), : FrameBuffer(width, height, false, false),
nativeWindow(window), buffer(0), gralloc(0) nativeWindow(window), buffer(0), gralloc(0)
{ {
hw_module_t const* pModule; hw_module_t const* pModule;
hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &pModule); hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &pModule);
...@@ -31,15 +31,14 @@ namespace sw ...@@ -31,15 +31,14 @@ namespace sw
void FrameBufferAndroid::blit(void *source, const Rect *sourceRect, const Rect *destRect, Format format) void FrameBufferAndroid::blit(void *source, const Rect *sourceRect, const Rect *destRect, Format format)
{ {
copy(source, format); copy(source, format);
nativeWindow->queueBuffer(nativeWindow, buffer, -1); nativeWindow->queueBuffer(nativeWindow, buffer, -1);
if (buffer && locked)
if (buffer && locked) {
{ locked = 0;
locked = 0; unlock(buffer);
unlock(buffer); }
}
buffer->common.decRef(&buffer->common); buffer->common.decRef(&buffer->common);
} }
void* FrameBufferAndroid::lock() void* FrameBufferAndroid::lock()
...@@ -65,6 +64,13 @@ namespace sw ...@@ -65,6 +64,13 @@ namespace sw
return NULL; 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) switch(buffer->format)
{ {
default: ALOGE("Unsupported buffer format %d", buffer->format); ASSERT(false); 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