blob: bf27300029c6333927e7f84ac0ae38d26daf0bd3 [file] [log] [blame]
Chris Craike4aa95e2014-05-08 13:57:05 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Chris Craike4aa95e2014-05-08 13:57:05 -070017#include <GLES2/gl2.h>
18#include <GLES2/gl2ext.h>
19
20#include <utils/Log.h>
21
22#include "GLUtils.h"
23
John Reck975591a2016-01-22 16:28:07 -080024#if DEBUG_OPENGL >= DEBUG_LEVEL_HIGH && !defined(HWUI_GLES_WRAP_ENABLED)
25#error Setting DEBUG_OPENGL to HIGH requires setting HWUI_ENABLE_OPENGL_VALIDATION to true in the Android.mk!
26#endif
27
Chris Craike4aa95e2014-05-08 13:57:05 -070028namespace android {
29namespace uirenderer {
30
Chris Craik5686bae2015-06-23 10:33:46 -070031bool GLUtils::dumpGLErrors() {
John Reck975591a2016-01-22 16:28:07 -080032#if DEBUG_OPENGL >= DEBUG_LEVEL_HIGH
33 // If DEBUG_LEVEL_HIGH is set then every GLES call is already wrapped
34 // and asserts that there was no error. So this can just return success.
35 return false;
36#else
Chris Craik5686bae2015-06-23 10:33:46 -070037 bool errorObserved = false;
Chris Craike4aa95e2014-05-08 13:57:05 -070038 GLenum status = GL_NO_ERROR;
39 while ((status = glGetError()) != GL_NO_ERROR) {
Chris Craik5686bae2015-06-23 10:33:46 -070040 errorObserved = true;
Chris Craike4aa95e2014-05-08 13:57:05 -070041 switch (status) {
John Reck1bcacfd2017-11-03 10:12:19 -070042 case GL_INVALID_ENUM:
43 ALOGE("GL error: GL_INVALID_ENUM");
44 break;
45 case GL_INVALID_VALUE:
46 ALOGE("GL error: GL_INVALID_VALUE");
47 break;
48 case GL_INVALID_OPERATION:
49 ALOGE("GL error: GL_INVALID_OPERATION");
50 break;
51 case GL_OUT_OF_MEMORY:
52 ALOGE("GL error: Out of memory!");
53 break;
54 default:
55 ALOGE("GL error: 0x%x", status);
Chris Craike4aa95e2014-05-08 13:57:05 -070056 }
57 }
Chris Craik5686bae2015-06-23 10:33:46 -070058 return errorObserved;
John Reck975591a2016-01-22 16:28:07 -080059#endif
Chris Craike4aa95e2014-05-08 13:57:05 -070060}
61
John Reck1bcacfd2017-11-03 10:12:19 -070062}; // namespace uirenderer
63}; // namespace android