Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(414)

Side by Side Diff: gpu/command_buffer/client/gles2_c_lib.cc

Issue 5254006: Initialize destinations variables before calling GL functions... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
7 #include "../client/gles2_lib.h" 8 #include "../client/gles2_lib.h"
8 9
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
9 extern "C" { 37 extern "C" {
10 // Include the auto-generated part of this file. We split this because it means 38 // Include the auto-generated part of this file. We split this because it means
11 // we can easily edit the non-auto generated parts right here in this file 39 // we can easily edit the non-auto generated parts right here in this file
12 // instead of having to edit some template or the code generator. 40 // instead of having to edit some template or the code generator.
13 #include "../client/gles2_c_lib_autogen.h" 41 #include "../client/gles2_c_lib_autogen.h"
14 } // extern "C" 42 } // extern "C"
15 43
16 44
OLDNEW
« no previous file with comments | « gpu/command_buffer/build_gles2_cmd_buffer.py ('k') | gpu/command_buffer/client/gles2_c_lib_autogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698