David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 1 | /* |
| 2 | ** Copyright 2011, 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 | |
| 17 | #include <stdlib.h> |
| 18 | #include <ctype.h> |
| 19 | #include <string.h> |
| 20 | #include <errno.h> |
| 21 | |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 22 | #include <GLES2/gl2.h> |
| 23 | #include <GLES2/gl2ext.h> |
| 24 | |
| 25 | #include <cutils/log.h> |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 26 | #include <utils/Timers.h> |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 27 | #include <../../../libcore/include/StaticAssert.h> |
| 28 | |
| 29 | #define EGL_TRACE 1 |
| 30 | #include "hooks.h" |
| 31 | |
| 32 | #define GL_ENTRY(_r, _api, ...) _r Debug_##_api ( __VA_ARGS__ ); |
| 33 | #include "../include/glesv2_dbg.h" |
| 34 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 35 | #include "debugger_message.pb.h" |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 36 | |
| 37 | using namespace android; |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 38 | using namespace com::android; |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 39 | |
| 40 | #define API_ENTRY(_api) Debug_##_api |
| 41 | |
| 42 | #ifndef __location__ |
| 43 | #define __HIERALLOC_STRING_0__(s) #s |
| 44 | #define __HIERALLOC_STRING_1__(s) __HIERALLOC_STRING_0__(s) |
| 45 | #define __HIERALLOC_STRING_2__ __HIERALLOC_STRING_1__(__LINE__) |
| 46 | #define __location__ __FILE__ ":" __HIERALLOC_STRING_2__ |
| 47 | #endif |
| 48 | |
| 49 | #define ASSERT(expr) if (!(expr)) { LOGD("\n*\n*\n* ASSERT FAILED: %s at %s \n*\n*", #expr, __location__); exit(1); } |
| 50 | #undef assert |
| 51 | #define assert(expr) ASSERT(expr) |
| 52 | //#undef LOGD |
| 53 | //#define LOGD(...) |
| 54 | |
| 55 | namespace android |
| 56 | { |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 57 | struct FunctionCall { |
| 58 | virtual const int * operator()(gl_hooks_t::gl_t const * const _c, glesv2debugger::Message & msg) = 0; |
| 59 | virtual ~FunctionCall() {} |
| 60 | }; |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 61 | |
David Li | 55c94cc | 2011-03-04 17:50:48 -0800 | [diff] [blame] | 62 | extern bool capture; |
| 63 | extern int timeMode; // SYSTEM_TIME_ |
| 64 | |
| 65 | extern int clientSock, serverSock; |
| 66 | |
| 67 | unsigned GetBytesPerPixel(const GLenum format, const GLenum type); |
| 68 | |
| 69 | int * MessageLoop(FunctionCall & functionCall, glesv2debugger::Message & msg, |
| 70 | const bool expectResponse, const glesv2debugger::Message_Function function); |
| 71 | void Receive(glesv2debugger::Message & cmd); |
| 72 | float Send(const glesv2debugger::Message & msg, glesv2debugger::Message & cmd); |
| 73 | void SetProp(const glesv2debugger::Message & cmd); |
David Li | 28ca2ab | 2011-03-01 16:08:10 -0800 | [diff] [blame] | 74 | }; // namespace android { |