OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // These functions emluate GLES2 over command buffers for C. | 5 // These functions emluate GLES2 over command buffers for C. |
6 | 6 |
7 #include <assert.h> | |
8 #include "../client/gles2_lib.h" | 7 #include "../client/gles2_lib.h" |
9 | 8 |
10 // Check that destination pointers point to initialized memory. | |
11 // When the context is lost, calling GL function has no effect so if destination | |
12 // pointers point to initialized memory it can often lead to crash bugs. eg. | |
13 // | |
14 // GLsizei len; | |
15 // glGetShaderSource(shader, max_size, &len, buffer); | |
16 // std::string src(buffer, buffer + len); // len can be uninitialized here!!! | |
17 // | |
18 // Because this check is not official GL this check happens only on Chrome code, | |
19 // not Pepper. | |
20 // | |
21 // If it was up to us we'd just always write to the destination but the OpenGL | |
22 // spec defines the behavior of OpenGL function, not us. :-( | |
23 #if defined(__native_client__) | |
24 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) | |
25 #elif defined(GPU_DCHECK) | |
26 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) GPU_DCHECK(v) | |
27 #elif defined(DCHECK) | |
28 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) DCHECK(v) | |
29 #else | |
30 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(v) ASSERT(v) | |
31 #endif | |
32 | |
33 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(type, ptr) \ | |
34 GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION_ASSERT(ptr && \ | |
35 (ptr[0] == static_cast<type>(0) || ptr[0] == static_cast<type>(-1))); | |
36 | |
37 extern "C" { | 9 extern "C" { |
38 // Include the auto-generated part of this file. We split this because it means | 10 // Include the auto-generated part of this file. We split this because it means |
39 // we can easily edit the non-auto generated parts right here in this file | 11 // we can easily edit the non-auto generated parts right here in this file |
40 // instead of having to edit some template or the code generator. | 12 // instead of having to edit some template or the code generator. |
41 #include "../client/gles2_c_lib_autogen.h" | 13 #include "../client/gles2_c_lib_autogen.h" |
42 } // extern "C" | 14 } // extern "C" |
43 | 15 |
44 | 16 |
OLD | NEW |