Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | #ifndef ANDROID_RS_CONTEXT_H |
| 18 | #define ANDROID_RS_CONTEXT_H |
| 19 | |
Jason Sams | 399bfce | 2009-07-13 12:20:31 -0700 | [diff] [blame] | 20 | #include "rsUtils.h" |
Jason Sams | c1d726c | 2010-03-18 11:39:44 -0700 | [diff] [blame] | 21 | #include "rsMutex.h" |
Jason Sams | 399bfce | 2009-07-13 12:20:31 -0700 | [diff] [blame] | 22 | |
Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 23 | #include "rsThreadIO.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 24 | #include "rsType.h" |
| 25 | #include "rsMatrix.h" |
| 26 | #include "rsAllocation.h" |
Jason Sams | 7c878f3 | 2009-06-30 14:13:04 -0700 | [diff] [blame] | 27 | #include "rsMesh.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 28 | #include "rsDevice.h" |
| 29 | #include "rsScriptC.h" |
| 30 | #include "rsAllocation.h" |
| 31 | #include "rsAdapter.h" |
| 32 | #include "rsSampler.h" |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 33 | #include "rsFont.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 34 | #include "rsProgramFragment.h" |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 35 | #include "rsProgramStore.h" |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 36 | #include "rsProgramRaster.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 37 | #include "rsProgramVertex.h" |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 38 | #include "rsShaderCache.h" |
| 39 | #include "rsVertexArray.h" |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 40 | |
| 41 | #include "rsgApiStructs.h" |
| 42 | #include "rsLocklessFifo.h" |
| 43 | |
Mathias Agopian | 5cbb940 | 2010-02-12 12:00:38 -0800 | [diff] [blame] | 44 | #include <ui/egl/android_natives.h> |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 45 | |
| 46 | // --------------------------------------------------------------------------- |
| 47 | namespace android { |
Mathias Agopian | 000479f | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 48 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 49 | namespace renderscript { |
| 50 | |
Jason Sams | f166d9b | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 51 | #if 0 |
| 52 | #define CHECK_OBJ(o) { \ |
| 53 | GET_TLS(); \ |
| 54 | if(!ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \ |
| 55 | LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \ |
| 56 | } \ |
| 57 | } |
| 58 | #define CHECK_OBJ_OR_NULL(o) { \ |
| 59 | GET_TLS(); \ |
| 60 | if(o && !ObjectBase::isValid(rsc, (const ObjectBase *)o)) { \ |
| 61 | LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__); \ |
| 62 | } \ |
| 63 | } |
| 64 | #else |
| 65 | #define CHECK_OBJ(o) |
| 66 | #define CHECK_OBJ_OR_NULL(o) |
| 67 | #endif |
| 68 | |
Jason Sams | 9bee51c | 2009-08-05 13:57:03 -0700 | [diff] [blame] | 69 | class Context |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 70 | { |
| 71 | public: |
Jason Sams | d5f0630 | 2010-11-03 14:27:11 -0700 | [diff] [blame^] | 72 | static Context * createContext(Device *, const RsSurfaceConfig *sc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 73 | ~Context(); |
| 74 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 75 | static pthread_key_t gThreadTLSKey; |
Jason Sams | 41c19db9 | 2009-10-15 16:47:31 -0700 | [diff] [blame] | 76 | static uint32_t gThreadTLSKeyCount; |
Jason Sams | 7136220 | 2009-10-27 14:44:31 -0700 | [diff] [blame] | 77 | static uint32_t gGLContextCount; |
Jason Sams | 41c19db9 | 2009-10-15 16:47:31 -0700 | [diff] [blame] | 78 | static pthread_mutex_t gInitMutex; |
| 79 | |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 80 | struct ScriptTLSStruct { |
| 81 | Context * mContext; |
| 82 | Script * mScript; |
| 83 | }; |
Jason Sams | f166d9b | 2010-09-30 18:15:52 -0700 | [diff] [blame] | 84 | ScriptTLSStruct *mTlsStruct; |
Jason Sams | 11c8af9 | 2010-10-13 15:31:10 -0700 | [diff] [blame] | 85 | RsSurfaceConfig mUserSurfaceConfig; |
Jason Sams | 462d11b | 2009-06-19 16:03:18 -0700 | [diff] [blame] | 86 | |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 87 | typedef void (*WorkerCallback_t)(void *usr, uint32_t idx); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 88 | |
| 89 | //StructuredAllocationContext mStateAllocation; |
| 90 | ElementState mStateElement; |
| 91 | TypeState mStateType; |
| 92 | SamplerState mStateSampler; |
| 93 | ProgramFragmentState mStateFragment; |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 94 | ProgramStoreState mStateFragmentStore; |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 95 | ProgramRasterState mStateRaster; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 96 | ProgramVertexState mStateVertex; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 97 | VertexArrayState mStateVertexArray; |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 98 | FontState mStateFont; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 99 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 100 | ScriptCState mScriptC; |
Jason Sams | bb51c40 | 2009-11-25 13:22:07 -0800 | [diff] [blame] | 101 | ShaderCache mShaderCache; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 102 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 103 | void swapBuffers(); |
| 104 | void setRootScript(Script *); |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 105 | void setRaster(ProgramRaster *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 106 | void setVertex(ProgramVertex *); |
| 107 | void setFragment(ProgramFragment *); |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 108 | void setFragmentStore(ProgramStore *); |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 109 | void setFont(Font *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 110 | |
| 111 | void updateSurface(void *sur); |
| 112 | |
| 113 | const ProgramFragment * getFragment() {return mFragment.get();} |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 114 | const ProgramStore * getFragmentStore() {return mFragmentStore.get();} |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 115 | const ProgramRaster * getRaster() {return mRaster.get();} |
Jason Sams | b0ec1b4 | 2009-07-28 12:02:16 -0700 | [diff] [blame] | 116 | const ProgramVertex * getVertex() {return mVertex.get();} |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 117 | Font * getFont() {return mFont.get();} |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 118 | |
Jason Sams | 156cce6 | 2010-03-03 13:03:18 -0800 | [diff] [blame] | 119 | bool setupCheck(); |
Alex Sakhartchouk | feede2a | 2010-10-01 10:54:06 -0700 | [diff] [blame] | 120 | void setupProgramStore(); |
Jason Sams | 3b7d39b | 2009-12-14 12:57:40 -0800 | [diff] [blame] | 121 | bool checkDriver() const {return mEGL.mSurface != 0;} |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 122 | |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 123 | void pause(); |
| 124 | void resume(); |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 125 | void setSurface(uint32_t w, uint32_t h, ANativeWindow *sur); |
Jason Sams | 7d787b4 | 2009-11-15 12:14:26 -0800 | [diff] [blame] | 126 | void setPriority(int32_t p); |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 127 | |
Jason Sams | d5680f9 | 2009-06-10 18:39:40 -0700 | [diff] [blame] | 128 | void assignName(ObjectBase *obj, const char *name, uint32_t len); |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 129 | void removeName(ObjectBase *obj); |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 130 | |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 131 | uint32_t getMessageToClient(void *data, size_t *receiveLen, size_t bufferLen, bool wait); |
| 132 | bool sendMessageToClient(void *data, uint32_t cmdID, size_t len, bool waitForSpace); |
Jason Sams | f17bccc | 2010-05-28 18:23:22 -0700 | [diff] [blame] | 133 | uint32_t runScript(Script *s); |
Jason Sams | 516c319 | 2009-10-06 13:58:47 -0700 | [diff] [blame] | 134 | |
| 135 | void initToClient(); |
| 136 | void deinitToClient(); |
| 137 | |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 138 | ProgramFragment * getDefaultProgramFragment() const { |
| 139 | return mStateFragment.mDefault.get(); |
| 140 | } |
| 141 | ProgramVertex * getDefaultProgramVertex() const { |
| 142 | return mStateVertex.mDefault.get(); |
| 143 | } |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 144 | ProgramStore * getDefaultProgramStore() const { |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 145 | return mStateFragmentStore.mDefault.get(); |
| 146 | } |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 147 | ProgramRaster * getDefaultProgramRaster() const { |
| 148 | return mStateRaster.mDefault.get(); |
| 149 | } |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 150 | Font* getDefaultFont() const { |
| 151 | return mStateFont.mDefault.get(); |
| 152 | } |
Jason Sams | 9c54bdb | 2009-06-17 16:52:59 -0700 | [diff] [blame] | 153 | |
Jason Sams | f603d21 | 2010-05-14 15:30:29 -0700 | [diff] [blame] | 154 | uint32_t getWidth() const {return mWidth;} |
| 155 | uint32_t getHeight() const {return mHeight;} |
Jason Sams | 40a29e8 | 2009-08-10 14:55:26 -0700 | [diff] [blame] | 156 | |
Jason Sams | bc948de | 2009-08-17 18:35:48 -0700 | [diff] [blame] | 157 | |
| 158 | ThreadIO mIO; |
| 159 | |
Jason Sams | f4d1606 | 2009-08-19 12:17:14 -0700 | [diff] [blame] | 160 | // Timers |
| 161 | enum Timers { |
| 162 | RS_TIMER_IDLE, |
| 163 | RS_TIMER_INTERNAL, |
| 164 | RS_TIMER_SCRIPT, |
| 165 | RS_TIMER_CLEAR_SWAP, |
| 166 | _RS_TIMER_TOTAL |
| 167 | }; |
| 168 | uint64_t getTime() const; |
| 169 | void timerInit(); |
| 170 | void timerReset(); |
| 171 | void timerSet(Timers); |
| 172 | void timerPrint(); |
Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 173 | void timerFrame(); |
Jason Sams | f4d1606 | 2009-08-19 12:17:14 -0700 | [diff] [blame] | 174 | |
Jason Sams | 66b2771 | 2009-09-25 15:25:00 -0700 | [diff] [blame] | 175 | struct { |
| 176 | bool mLogTimes; |
| 177 | bool mLogScripts; |
| 178 | bool mLogObjects; |
Jason Sams | 5dad8b4 | 2009-12-15 19:10:11 -0800 | [diff] [blame] | 179 | bool mLogShaders; |
Alex Sakhartchouk | 4378f11 | 2010-09-29 09:49:13 -0700 | [diff] [blame] | 180 | bool mLogShadersAttr; |
| 181 | bool mLogShadersUniforms; |
Alex Sakhartchouk | 6de5550 | 2010-08-03 12:03:16 -0700 | [diff] [blame] | 182 | bool mLogVisual; |
Jason Sams | 66b2771 | 2009-09-25 15:25:00 -0700 | [diff] [blame] | 183 | } props; |
Joe Onorato | 9ac2c66 | 2009-09-23 16:37:36 -0700 | [diff] [blame] | 184 | |
Jason Sams | 9dab667 | 2009-11-24 12:26:35 -0800 | [diff] [blame] | 185 | void dumpDebug() const; |
Jason Sams | 718cd1f | 2009-12-23 14:35:29 -0800 | [diff] [blame] | 186 | void checkError(const char *) const; |
Jason Sams | 156cce6 | 2010-03-03 13:03:18 -0800 | [diff] [blame] | 187 | const char * getError(RsError *); |
Jason Sams | f468700 | 2010-03-10 17:30:41 -0800 | [diff] [blame] | 188 | void setError(RsError e, const char *msg = NULL); |
Jason Sams | 9dab667 | 2009-11-24 12:26:35 -0800 | [diff] [blame] | 189 | |
Jason Sams | a9e7a05 | 2009-09-25 14:51:22 -0700 | [diff] [blame] | 190 | mutable const ObjectBase * mObjHead; |
| 191 | |
Jason Sams | 2978bfc | 2010-02-22 15:37:51 -0800 | [diff] [blame] | 192 | bool ext_OES_texture_npot() const {return mGL.OES_texture_npot;} |
Alex Sakhartchouk | 581cc64 | 2010-10-27 14:10:07 -0700 | [diff] [blame] | 193 | bool ext_GL_NV_texture_npot_2D_mipmap() const {return mGL.GL_NV_texture_npot_2D_mipmap;} |
Alex Sakhartchouk | 4378f11 | 2010-09-29 09:49:13 -0700 | [diff] [blame] | 194 | float ext_texture_max_aniso() const {return mGL.EXT_texture_max_aniso; } |
Alex Sakhartchouk | b89aaac | 2010-09-23 16:16:33 -0700 | [diff] [blame] | 195 | uint32_t getMaxFragmentTextures() const {return mGL.mMaxFragmentTextureImageUnits;} |
| 196 | uint32_t getMaxFragmentUniformVectors() const {return mGL.mMaxFragmentUniformVectors;} |
| 197 | uint32_t getMaxVertexUniformVectors() const {return mGL.mMaxVertexUniformVectors;} |
Jason Sams | 2978bfc | 2010-02-22 15:37:51 -0800 | [diff] [blame] | 198 | |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 199 | void launchThreads(WorkerCallback_t cbk, void *data); |
Jason Sams | f3470ed | 2010-09-28 14:41:22 -0700 | [diff] [blame] | 200 | uint32_t getWorkerPoolSize() const {return (uint32_t)mWorkers.mCount;} |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 201 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 202 | protected: |
| 203 | Device *mDev; |
| 204 | |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 205 | struct { |
| 206 | EGLint mNumConfigs; |
| 207 | EGLint mMajorVersion; |
| 208 | EGLint mMinorVersion; |
| 209 | EGLConfig mConfig; |
| 210 | EGLContext mContext; |
| 211 | EGLSurface mSurface; |
Jason Sams | 11c8af9 | 2010-10-13 15:31:10 -0700 | [diff] [blame] | 212 | EGLSurface mSurfaceDefault; |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 213 | EGLDisplay mDisplay; |
| 214 | } mEGL; |
| 215 | |
| 216 | struct { |
| 217 | const uint8_t * mVendor; |
| 218 | const uint8_t * mRenderer; |
| 219 | const uint8_t * mVersion; |
| 220 | const uint8_t * mExtensions; |
| 221 | |
| 222 | uint32_t mMajorVersion; |
| 223 | uint32_t mMinorVersion; |
| 224 | |
Jason Sams | 0011bcf | 2009-12-15 12:58:36 -0800 | [diff] [blame] | 225 | int32_t mMaxVaryingVectors; |
| 226 | int32_t mMaxTextureImageUnits; |
| 227 | |
| 228 | int32_t mMaxFragmentTextureImageUnits; |
| 229 | int32_t mMaxFragmentUniformVectors; |
| 230 | |
| 231 | int32_t mMaxVertexAttribs; |
| 232 | int32_t mMaxVertexUniformVectors; |
| 233 | int32_t mMaxVertexTextureUnits; |
Jason Sams | 2978bfc | 2010-02-22 15:37:51 -0800 | [diff] [blame] | 234 | |
| 235 | bool OES_texture_npot; |
Alex Sakhartchouk | 581cc64 | 2010-10-27 14:10:07 -0700 | [diff] [blame] | 236 | bool GL_NV_texture_npot_2D_mipmap; |
Alex Sakhartchouk | 4378f11 | 2010-09-29 09:49:13 -0700 | [diff] [blame] | 237 | float EXT_texture_max_aniso; |
Jason Sams | b13ada5 | 2009-08-25 11:34:49 -0700 | [diff] [blame] | 238 | } mGL; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 239 | |
Jason Sams | 3bc47d4 | 2009-11-12 15:10:25 -0800 | [diff] [blame] | 240 | uint32_t mWidth; |
| 241 | uint32_t mHeight; |
Jason Sams | b9d5c57 | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 242 | int32_t mThreadPriority; |
Jason Sams | 704ff64 | 2010-02-09 16:05:07 -0800 | [diff] [blame] | 243 | bool mIsGraphicsContext; |
Jason Sams | 3bc47d4 | 2009-11-12 15:10:25 -0800 | [diff] [blame] | 244 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 245 | bool mRunning; |
| 246 | bool mExit; |
Jason Sams | 65e7aa5 | 2009-09-24 17:38:20 -0700 | [diff] [blame] | 247 | bool mPaused; |
Jason Sams | 156cce6 | 2010-03-03 13:03:18 -0800 | [diff] [blame] | 248 | RsError mError; |
| 249 | const char *mErrorMsg; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 250 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 251 | pthread_t mThreadId; |
Jason Sams | 7d787b4 | 2009-11-15 12:14:26 -0800 | [diff] [blame] | 252 | pid_t mNativeThreadId; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 253 | |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 254 | struct Workers { |
| 255 | volatile int mRunningCount; |
| 256 | volatile int mLaunchCount; |
| 257 | uint32_t mCount; |
| 258 | pthread_t *mThreadId; |
| 259 | pid_t *mNativeThreadId; |
| 260 | Signal mCompleteSignal; |
| 261 | |
| 262 | Signal *mLaunchSignals; |
| 263 | WorkerCallback_t mLaunchCallback; |
| 264 | void *mLaunchData; |
| 265 | }; |
| 266 | Workers mWorkers; |
| 267 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 268 | ObjectBaseRef<Script> mRootScript; |
| 269 | ObjectBaseRef<ProgramFragment> mFragment; |
| 270 | ObjectBaseRef<ProgramVertex> mVertex; |
Jason Sams | 54db59c | 2010-05-13 18:30:11 -0700 | [diff] [blame] | 271 | ObjectBaseRef<ProgramStore> mFragmentStore; |
Jason Sams | ebfb436 | 2009-09-23 13:57:02 -0700 | [diff] [blame] | 272 | ObjectBaseRef<ProgramRaster> mRaster; |
Alex Sakhartchouk | 9b949fc | 2010-06-24 17:15:34 -0700 | [diff] [blame] | 273 | ObjectBaseRef<Font> mFont; |
Jason Sams | 730ee65 | 2009-08-18 17:07:09 -0700 | [diff] [blame] | 274 | |
Alex Sakhartchouk | 6de5550 | 2010-08-03 12:03:16 -0700 | [diff] [blame] | 275 | void displayDebugStats(); |
| 276 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 277 | private: |
| 278 | Context(); |
Jason Sams | d5f0630 | 2010-11-03 14:27:11 -0700 | [diff] [blame^] | 279 | bool initContext(Device *, const RsSurfaceConfig *sc); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 280 | |
Jason Sams | d5f0630 | 2010-11-03 14:27:11 -0700 | [diff] [blame^] | 281 | |
| 282 | bool initGLThread(); |
Jason Sams | 7136220 | 2009-10-27 14:44:31 -0700 | [diff] [blame] | 283 | void deinitEGL(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 284 | |
Jason Sams | b9d5c57 | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 285 | uint32_t runRootScript(); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 286 | |
| 287 | static void * threadProc(void *); |
Jason Sams | 8e6c17f | 2010-07-19 15:38:19 -0700 | [diff] [blame] | 288 | static void * helperThreadProc(void *); |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 289 | |
Dianne Hackborn | 8b49bd1 | 2010-06-30 13:56:17 -0700 | [diff] [blame] | 290 | ANativeWindow *mWndSurface; |
Jason Sams | 3eaa338 | 2009-06-10 15:04:38 -0700 | [diff] [blame] | 291 | |
| 292 | Vector<ObjectBase *> mNames; |
Jason Sams | f4d1606 | 2009-08-19 12:17:14 -0700 | [diff] [blame] | 293 | |
| 294 | uint64_t mTimers[_RS_TIMER_TOTAL]; |
| 295 | Timers mTimerActive; |
| 296 | uint64_t mTimeLast; |
Jason Sams | 2525a81 | 2009-09-03 15:43:13 -0700 | [diff] [blame] | 297 | uint64_t mTimeFrame; |
| 298 | uint64_t mTimeLastFrame; |
Jason Sams | b9d5c57 | 2009-12-09 11:05:45 -0800 | [diff] [blame] | 299 | uint32_t mTimeMSLastFrame; |
| 300 | uint32_t mTimeMSLastScript; |
| 301 | uint32_t mTimeMSLastSwap; |
Alex Sakhartchouk | 76322af | 2010-10-05 13:23:55 -0700 | [diff] [blame] | 302 | uint32_t mAverageFPSFrameCount; |
| 303 | uint64_t mAverageFPSStartTime; |
| 304 | uint32_t mAverageFPS; |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 305 | }; |
| 306 | |
Jason Sams | d19f10d | 2009-05-22 14:03:28 -0700 | [diff] [blame] | 307 | } |
| 308 | } |
| 309 | #endif |