2 * Copyright (C) 2016 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "GlesErrorCheckWrapper.h"
22 namespace uirenderer {
25 void GlesErrorCheckWrapper::assertNoErrors(const char* apicall) {
26 GLenum status = GL_NO_ERROR;
27 GLenum lastError = GL_NO_ERROR;
28 const char* lastErrorName = nullptr;
29 while ((status = mBase.glGetError_()) != GL_NO_ERROR) {
33 ALOGE("GL error: GL_INVALID_ENUM");
34 lastErrorName = "GL_INVALID_ENUM";
36 case GL_INVALID_VALUE:
37 ALOGE("GL error: GL_INVALID_VALUE");
38 lastErrorName = "GL_INVALID_VALUE";
40 case GL_INVALID_OPERATION:
41 ALOGE("GL error: GL_INVALID_OPERATION");
42 lastErrorName = "GL_INVALID_OPERATION";
44 case GL_OUT_OF_MEMORY:
45 ALOGE("GL error: Out of memory!");
46 lastErrorName = "GL_OUT_OF_MEMORY";
49 ALOGE("GL error: 0x%x", status);
50 lastErrorName = "UNKNOWN";
53 ALOGE_IF(lastError != GL_NO_ERROR,
54 "%s error! %s (0x%x)", apicall, lastErrorName, lastError);
57 #define API_ENTRY(x) GlesErrorCheckWrapper::x##_
58 #define CALL_GL_API(x, ...) \
59 mBase.x##_(__VA_ARGS__); assertNoErrors(#x)
61 #define CALL_GL_API_RETURN(x, ...) \
62 auto ret = mBase.x##_(__VA_ARGS__); \
66 #include "gles_stubs.in"
70 #undef CALL_GL_API_RETURN
73 } // namespace uirenderer
74 } // namespace android