| Index: gpu/command_buffer/client/gles2_c_lib.cc
|
| ===================================================================
|
| --- gpu/command_buffer/client/gles2_c_lib.cc (revision 67161)
|
| +++ gpu/command_buffer/client/gles2_c_lib.cc (working copy)
|
| @@ -4,8 +4,36 @@
|
|
|
| // These functions emluate GLES2 over command buffers for C.
|
|
|
| +#include <assert.h>
|
| #include "../client/gles2_lib.h"
|
|
|
| +// Check that destination pointers point to initialized memory.
|
| +// When the context is lost, calling GL function has no effect so if destination
|
| +// pointers point to initialized memory it can often lead to crash bugs. eg.
|
| +//
|
| +// GLsizei len;
|
| +// glGetShaderSource(shader, max_size, &len, buffer);
|
| +// std::string src(buffer, buffer + len); // len can be uninitialized here!!!
|
| +//
|
| +// Because this check is not official GL this check happens only on Chrome code,
|
| +// not Pepper.
|
| +//
|
| +// If it was up to us we'd just always write to the destination but the OpenGL
|
| +// spec defines the behavior of OpenGL function, not us. :-(
|
| +#if defined(__native_client__)
|
| + #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v)
|
| +#elif defined(GPU_DCHECK)
|
| + #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) GPU_DCHECK(v)
|
| +#elif defined(DCHECK)
|
| + #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) DCHECK(v)
|
| +#else
|
| + #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) ASSERT(v)
|
| +#endif
|
| +
|
| +#define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(type, ptr) \
|
| + GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(ptr && \
|
| + (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1)));
|
| +
|
| extern "C" {
|
| // Include the auto-generated part of this file. We split this because it means
|
| // we can easily edit the non-auto generated parts right here in this file
|
|
|