rsContext.h revision 9e0afb5a2b3e476c42a373e7cd89cef4a34f8195
1326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams/*
2a04e30dbb5ab11592b03666bb3d102070759c58eAlex Sakhartchouk * Copyright (C) 2011 The Android Open Source Project
3326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *
4326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * Licensed under the Apache License, Version 2.0 (the "License");
5326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * you may not use this file except in compliance with the License.
6326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * You may obtain a copy of the License at
7326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *
8326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *      http://www.apache.org/licenses/LICENSE-2.0
9326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams *
10326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * Unless required by applicable law or agreed to in writing, software
11326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * distributed under the License is distributed on an "AS IS" BASIS,
12326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * See the License for the specific language governing permissions and
14326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams * limitations under the License.
15326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams */
16326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
17326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#ifndef ANDROID_RS_CONTEXT_H
18326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#define ANDROID_RS_CONTEXT_H
19326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
20a5577808737a394bdb156fbeb80018d0a4d8438dJason Sams#include "rsUtils.h"
21326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsType.h"
22326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsAllocation.h"
23a89371c6f144b9049efe7689105feee2c4a38384Jason Sams#include "rsMesh.h"
2477d9f4bd05b2d2a161f30c12a2248f9c97eaac42Alex Sakhartchouk
25bad807405b2b9764372af1ad24bcfd4fb1f33d8eJason Sams#include "rs_hal.h"
26bad807405b2b9764372af1ad24bcfd4fb1f33d8eJason Sams
2777d9f4bd05b2d2a161f30c12a2248f9c97eaac42Alex Sakhartchouk#include "rsMutex.h"
2877d9f4bd05b2d2a161f30c12a2248f9c97eaac42Alex Sakhartchouk#include "rsThreadIO.h"
2987fe59a2f4d4c74539bfa0bff5f9a7e320e99415Jason Sams#include "rsMatrix4x4.h"
30326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsDevice.h"
31326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsScriptC.h"
32326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsAdapter.h"
33326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsSampler.h"
34d3e0ad43dc758c409fc23d1893dab67b18520c24Alex Sakhartchouk#include "rsFont.h"
359e0afb5a2b3e476c42a373e7cd89cef4a34f8195Jason Sams#include "rsPath.h"
36326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsProgramFragment.h"
37ccc010bb7c0f89e162bf60033968a20be90a903aJason Sams#include "rsProgramStore.h"
385fd09d847586f9680b4f495413b6ca5fbb69af6eJason Sams#include "rsProgramRaster.h"
39326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsProgramVertex.h"
407d9c5ffccb7a5e682860f752403e5a03aed587beAlex Sakhartchouk#include "rsFBOCache.h"
41326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
42326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsgApiStructs.h"
43326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#include "rsLocklessFifo.h"
44326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
45326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams// ---------------------------------------------------------------------------
46326e0ddf89e8df2837752fbfd7a014814b32082cJason Samsnamespace android {
47d4c25e3c197bc79c8508b76b20611b67ef883138Mathias Agopian
48326e0ddf89e8df2837752fbfd7a014814b32082cJason Samsnamespace renderscript {
49326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
50605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams#if 0
51605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams#define CHECK_OBJ(o) { \
52605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams    GET_TLS(); \
53afb743aca56c18beb7ab924e75cb6e070ef3e55aAlex Sakhartchouk    if (!ObjectBase::isValid(rsc, (const ObjectBase *)o)) {  \
54605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams        LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__);  \
55605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams    } \
56605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams}
57605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams#define CHECK_OBJ_OR_NULL(o) { \
58605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams    GET_TLS(); \
59afb743aca56c18beb7ab924e75cb6e070ef3e55aAlex Sakhartchouk    if (o && !ObjectBase::isValid(rsc, (const ObjectBase *)o)) {  \
60605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams        LOGE("Bad object %p at %s, %i", o, __FILE__, __LINE__);  \
61605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams    } \
62605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams}
63605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams#else
64605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams#define CHECK_OBJ(o)
65605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams#define CHECK_OBJ_OR_NULL(o)
66605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams#endif
67605048a9f9af925782f6c90bc1cdc5af59e337d8Jason Sams
68afb743aca56c18beb7ab924e75cb6e070ef3e55aAlex Sakhartchoukclass Context {
69326e0ddf89e8df2837752fbfd7a014814b32082cJason Samspublic:
70bad807405b2b9764372af1ad24bcfd4fb1f33d8eJason Sams    struct Hal {
71bad807405b2b9764372af1ad24bcfd4fb1f33d8eJason Sams        void * drv;
72bad807405b2b9764372af1ad24bcfd4fb1f33d8eJason Sams
73bad807405b2b9764372af1ad24bcfd4fb1f33d8eJason Sams        RsdHalFunctions funcs;
74bad807405b2b9764372af1ad24bcfd4fb1f33d8eJason Sams    };
75bad807405b2b9764372af1ad24bcfd4fb1f33d8eJason Sams    Hal mHal;
76bad807405b2b9764372af1ad24bcfd4fb1f33d8eJason Sams
775c1c79a54c63b9de8c391f7ed890c02f280ec17fJason Sams    static Context * createContext(Device *, const RsSurfaceConfig *sc);
78b81a0eb8180791e4eaab1253b59fa8bd562b046bAlex Sakhartchouk    static Context * createContextLite();
79326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ~Context();
80326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
81fb03a22ad2adadc1ff50a8b50d43ad7fcc3fa6edJason Sams    static pthread_mutex_t gInitMutex;
82ca3f09c0924e9515901dfd47fa5f95385d53cf80Stephen Hines    // Library mutex (for providing thread-safe calls from the runtime)
83ca3f09c0924e9515901dfd47fa5f95385d53cf80Stephen Hines    static pthread_mutex_t gLibMutex;
84fb03a22ad2adadc1ff50a8b50d43ad7fcc3fa6edJason Sams
8560709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    class PushState {
8660709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    public:
8760709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams        PushState(Context *);
8860709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams        ~PushState();
8960709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams
9060709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    private:
9160709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams        ObjectBaseRef<ProgramFragment> mFragment;
9260709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams        ObjectBaseRef<ProgramVertex> mVertex;
9360709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams        ObjectBaseRef<ProgramStore> mStore;
9460709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams        ObjectBaseRef<ProgramRaster> mRaster;
9560709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams        ObjectBaseRef<Font> mFont;
9660709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams        Context *mRsc;
9760709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    };
9860709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams
996b8552a4f6a44848255d77222e66aa92dd21b1b5Jason Sams    RsSurfaceConfig mUserSurfaceConfig;
100e57691037aea219562ac686429b4b98202aab7bcJason Sams
101326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ElementState mStateElement;
102326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    TypeState mStateType;
103326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    SamplerState mStateSampler;
104326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ProgramFragmentState mStateFragment;
105ccc010bb7c0f89e162bf60033968a20be90a903aJason Sams    ProgramStoreState mStateFragmentStore;
1065fd09d847586f9680b4f495413b6ca5fbb69af6eJason Sams    ProgramRasterState mStateRaster;
107326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ProgramVertexState mStateVertex;
108d3e0ad43dc758c409fc23d1893dab67b18520c24Alex Sakhartchouk    FontState mStateFont;
109326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
110326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ScriptCState mScriptC;
1117d9c5ffccb7a5e682860f752403e5a03aed587beAlex Sakhartchouk    FBOCache mFBOCache;
112326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
113326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    void swapBuffers();
114326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    void setRootScript(Script *);
11560709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    void setProgramRaster(ProgramRaster *);
11660709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    void setProgramVertex(ProgramVertex *);
11760709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    void setProgramFragment(ProgramFragment *);
11860709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    void setProgramStore(ProgramStore *);
119d3e0ad43dc758c409fc23d1893dab67b18520c24Alex Sakhartchouk    void setFont(Font *);
120326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
121326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    void updateSurface(void *sur);
122326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
12360709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    ProgramFragment * getProgramFragment() {return mFragment.get();}
12460709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    ProgramStore * getProgramStore() {return mFragmentStore.get();}
12560709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    ProgramRaster * getProgramRaster() {return mRaster.get();}
12660709257bbdeb0c50f39b9c8969dc76264d6e142Jason Sams    ProgramVertex * getProgramVertex() {return mVertex.get();}
127d3e0ad43dc758c409fc23d1893dab67b18520c24Alex Sakhartchouk    Font * getFont() {return mFont.get();}
128326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
129a2cf755a28a1e7ffff2955df656d714f40e4d715Jason Sams    bool setupCheck();
130889fe50e7aaebed8cb8284b16a0e51e64e8a3a9cAlex Sakhartchouk    void setupProgramStore();
131326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
13286f1b23aaaf9b8822a009d8c3e585e46768abb6aJason Sams    void pause();
13386f1b23aaaf9b8822a009d8c3e585e46768abb6aJason Sams    void resume();
1347257c7ee4b66f00c43d9235f3ac600061ae79968Alex Sakhartchouk    void setSurface(uint32_t w, uint32_t h, RsNativeWindow sur);
135158324456b8dbf40f684dd0a4af3493b9549f3f5Jason Sams    void setPriority(int32_t p);
136741aac95b777b2e6cb90f484a05e489a79a6ef05Jason Sams    void destroyWorkerThreadResources();
13786f1b23aaaf9b8822a009d8c3e585e46768abb6aJason Sams
138a4a54e42fc710a62b47cbcb9d64c34a190429d9eJason Sams    void assignName(ObjectBase *obj, const char *name, uint32_t len);
139a0a1b6fbece2eb8d72d788422ab3e5f58d5a9216Jason Sams    void removeName(ObjectBase *obj);
1408ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams
1411a4efa363916977ef9aeab756725b3bdc880a15bJason Sams    RsMessageToClientType peekMessageToClient(size_t *receiveLen, uint32_t *subID);
1421a4efa363916977ef9aeab756725b3bdc880a15bJason Sams    RsMessageToClientType getMessageToClient(void *data, size_t *receiveLen, uint32_t *subID, size_t bufferLen);
14387319de2b16a185cf360827c96a42cf1fcaae744Jason Sams    bool sendMessageToClient(const void *data, RsMessageToClientType cmdID, uint32_t subID, size_t len, bool waitForSpace) const;
144c61346b91434307c5003029017b54ce9c49112beJason Sams    uint32_t runScript(Script *s);
1458c401effb0837155fc39ca0364f57a882d127d38Jason Sams
1468c401effb0837155fc39ca0364f57a882d127d38Jason Sams    void initToClient();
1478c401effb0837155fc39ca0364f57a882d127d38Jason Sams    void deinitToClient();
1488c401effb0837155fc39ca0364f57a882d127d38Jason Sams
1498ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams    ProgramFragment * getDefaultProgramFragment() const {
1508ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams        return mStateFragment.mDefault.get();
1518ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams    }
1528ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams    ProgramVertex * getDefaultProgramVertex() const {
1538ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams        return mStateVertex.mDefault.get();
1548ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams    }
155ccc010bb7c0f89e162bf60033968a20be90a903aJason Sams    ProgramStore * getDefaultProgramStore() const {
1568ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams        return mStateFragmentStore.mDefault.get();
1578ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams    }
1585fd09d847586f9680b4f495413b6ca5fbb69af6eJason Sams    ProgramRaster * getDefaultProgramRaster() const {
1595fd09d847586f9680b4f495413b6ca5fbb69af6eJason Sams        return mStateRaster.mDefault.get();
1605fd09d847586f9680b4f495413b6ca5fbb69af6eJason Sams    }
161d3e0ad43dc758c409fc23d1893dab67b18520c24Alex Sakhartchouk    Font* getDefaultFont() const {
162d3e0ad43dc758c409fc23d1893dab67b18520c24Alex Sakhartchouk        return mStateFont.mDefault.get();
163d3e0ad43dc758c409fc23d1893dab67b18520c24Alex Sakhartchouk    }
1648ce125be69531dbf3a7e856d5e59d1b8e2789db0Jason Sams
165771565f47fc44608444c00aa8fa3bda769ceaeceJason Sams    uint32_t getWidth() const {return mWidth;}
166771565f47fc44608444c00aa8fa3bda769ceaeceJason Sams    uint32_t getHeight() const {return mHeight;}
167e579df42e85d9e00f53c42ef1b78dbd209dba989Jason Sams
16887319de2b16a185cf360827c96a42cf1fcaae744Jason Sams    mutable ThreadIO mIO;
169fcd3192ebff8ab58d841836b7e94361d0998338cJason Sams
17024371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    // Timers
17124371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    enum Timers {
17224371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams        RS_TIMER_IDLE,
17324371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams        RS_TIMER_INTERNAL,
17424371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams        RS_TIMER_SCRIPT,
17524371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams        RS_TIMER_CLEAR_SWAP,
17624371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams        _RS_TIMER_TOTAL
17724371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    };
17824371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    uint64_t getTime() const;
17924371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    void timerInit();
18024371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    void timerReset();
18124371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    void timerSet(Timers);
18224371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    void timerPrint();
1831d54f10f3c23e0d7ec57e52ec3b0701a2a5ed24eJason Sams    void timerFrame();
18424371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams
1851fddd90849deaae89b546ff492c345d485bbce42Jason Sams    struct {
1861fddd90849deaae89b546ff492c345d485bbce42Jason Sams        bool mLogTimes;
1871fddd90849deaae89b546ff492c345d485bbce42Jason Sams        bool mLogScripts;
1881fddd90849deaae89b546ff492c345d485bbce42Jason Sams        bool mLogObjects;
189cd50653f99c960e1a47c2c30e53b369b8805344aJason Sams        bool mLogShaders;
190886f11ade9dde05485cb11c0d67d87f76a428f6cAlex Sakhartchouk        bool mLogShadersAttr;
191886f11ade9dde05485cb11c0d67d87f76a428f6cAlex Sakhartchouk        bool mLogShadersUniforms;
1920cae59f7d8dd63d1bf0ca4abedecb4cfa3ab1921Alex Sakhartchouk        bool mLogVisual;
1931fddd90849deaae89b546ff492c345d485bbce42Jason Sams    } props;
19476371fff76412fd020e24ddb8bf1ddb5c75f0ed1Joe Onorato
1952382aba4a55c6ae74789c478eead8fbd96593321Jason Sams    mutable struct {
1962382aba4a55c6ae74789c478eead8fbd96593321Jason Sams        bool inRoot;
1972382aba4a55c6ae74789c478eead8fbd96593321Jason Sams        const char *command;
1982382aba4a55c6ae74789c478eead8fbd96593321Jason Sams        const char *file;
1992382aba4a55c6ae74789c478eead8fbd96593321Jason Sams        uint32_t line;
2002382aba4a55c6ae74789c478eead8fbd96593321Jason Sams    } watchdog;
2012382aba4a55c6ae74789c478eead8fbd96593321Jason Sams    static void printWatchdogInfo(void *ctx);
2022382aba4a55c6ae74789c478eead8fbd96593321Jason Sams    void setWatchdogGL(const char *cmd, uint32_t line, const char *file) const {
2032382aba4a55c6ae74789c478eead8fbd96593321Jason Sams        watchdog.command = cmd;
2042382aba4a55c6ae74789c478eead8fbd96593321Jason Sams        watchdog.file = file;
2052382aba4a55c6ae74789c478eead8fbd96593321Jason Sams        watchdog.line = line;
2062382aba4a55c6ae74789c478eead8fbd96593321Jason Sams    }
2072382aba4a55c6ae74789c478eead8fbd96593321Jason Sams
20813e2634a71a30d289ed8d821aef61c7d1687460eJason Sams    void dumpDebug() const;
20987319de2b16a185cf360827c96a42cf1fcaae744Jason Sams    void setError(RsError e, const char *msg = NULL) const;
21013e2634a71a30d289ed8d821aef61c7d1687460eJason Sams
211e514b45de8561fbc6ef6770845102ca10b0a69d7Jason Sams    mutable const ObjectBase * mObjHead;
212e514b45de8561fbc6ef6770845102ca10b0a69d7Jason Sams
2137b3e9bd825901e33661e3c385e3e7c6f40ca6000Alex Sakhartchouk    uint32_t getDPI() const {return mDPI;}
2147b3e9bd825901e33661e3c385e3e7c6f40ca6000Alex Sakhartchouk    void setDPI(uint32_t dpi) {mDPI = dpi;}
2157bf29ddc35450d8064541c42c99a1f48be6cf0ddJason Sams
216cbb0b8aceedb9146ba901cba1fbd6d1e9ca88f51Stephen Hines    uint32_t getTargetSdkVersion() const {return mTargetSdkVersion;}
217cbb0b8aceedb9146ba901cba1fbd6d1e9ca88f51Stephen Hines    void setTargetSdkVersion(uint32_t sdkVer) {mTargetSdkVersion = sdkVer;}
218cbb0b8aceedb9146ba901cba1fbd6d1e9ca88f51Stephen Hines
219326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    Device *mDev;
2204b3de47071d875faaa7d419d050a464b09538797Jason Samsprotected:
221326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
222cbb0b8aceedb9146ba901cba1fbd6d1e9ca88f51Stephen Hines    uint32_t mTargetSdkVersion;
2237b3e9bd825901e33661e3c385e3e7c6f40ca6000Alex Sakhartchouk    uint32_t mDPI;
224613cad1702dbb76eb2a6ba0cfcb43b9fe207cebcJason Sams    uint32_t mWidth;
225613cad1702dbb76eb2a6ba0cfcb43b9fe207cebcJason Sams    uint32_t mHeight;
2262dca84dd6c07992f78ad050177975f16486dd77eJason Sams    int32_t mThreadPriority;
2274820e8bb83b1f78e6232ebe853221f737da2a1eaJason Sams    bool mIsGraphicsContext;
228613cad1702dbb76eb2a6ba0cfcb43b9fe207cebcJason Sams
229326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    bool mRunning;
230326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    bool mExit;
23186f1b23aaaf9b8822a009d8c3e585e46768abb6aJason Sams    bool mPaused;
23287319de2b16a185cf360827c96a42cf1fcaae744Jason Sams    mutable RsError mError;
233326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
234326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    pthread_t mThreadId;
235158324456b8dbf40f684dd0a4af3493b9549f3f5Jason Sams    pid_t mNativeThreadId;
236326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
237326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ObjectBaseRef<Script> mRootScript;
238326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ObjectBaseRef<ProgramFragment> mFragment;
239326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    ObjectBaseRef<ProgramVertex> mVertex;
240ccc010bb7c0f89e162bf60033968a20be90a903aJason Sams    ObjectBaseRef<ProgramStore> mFragmentStore;
2415fd09d847586f9680b4f495413b6ca5fbb69af6eJason Sams    ObjectBaseRef<ProgramRaster> mRaster;
242d3e0ad43dc758c409fc23d1893dab67b18520c24Alex Sakhartchouk    ObjectBaseRef<Font> mFont;
2435086938044e0a9b6b1138f915d0d252fe046e102Jason Sams
2440cae59f7d8dd63d1bf0ca4abedecb4cfa3ab1921Alex Sakhartchouk    void displayDebugStats();
2450cae59f7d8dd63d1bf0ca4abedecb4cfa3ab1921Alex Sakhartchouk
246326e0ddf89e8df2837752fbfd7a014814b32082cJason Samsprivate:
247326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    Context();
2485c1c79a54c63b9de8c391f7ed890c02f280ec17fJason Sams    bool initContext(Device *, const RsSurfaceConfig *sc);
249326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
2505c1c79a54c63b9de8c391f7ed890c02f280ec17fJason Sams
2515c1c79a54c63b9de8c391f7ed890c02f280ec17fJason Sams    bool initGLThread();
25233b6e3b91329080e5cdd0b8fdbcd3e6a906032aeJason Sams    void deinitEGL();
253326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
2542dca84dd6c07992f78ad050177975f16486dd77eJason Sams    uint32_t runRootScript();
255326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
256326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams    static void * threadProc(void *);
2577bf29ddc35450d8064541c42c99a1f48be6cf0ddJason Sams    static void * helperThreadProc(void *);
258326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
2597257c7ee4b66f00c43d9235f3ac600061ae79968Alex Sakhartchouk    bool mHasSurface;
260b81a0eb8180791e4eaab1253b59fa8bd562b046bAlex Sakhartchouk    bool mIsContextLite;
261a0a1b6fbece2eb8d72d788422ab3e5f58d5a9216Jason Sams
262a0a1b6fbece2eb8d72d788422ab3e5f58d5a9216Jason Sams    Vector<ObjectBase *> mNames;
26324371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams
26424371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    uint64_t mTimers[_RS_TIMER_TOTAL];
26524371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    Timers mTimerActive;
26624371d93cdb6999971c4058f78974da3c3d5fc64Jason Sams    uint64_t mTimeLast;
2671d54f10f3c23e0d7ec57e52ec3b0701a2a5ed24eJason Sams    uint64_t mTimeFrame;
2681d54f10f3c23e0d7ec57e52ec3b0701a2a5ed24eJason Sams    uint64_t mTimeLastFrame;
2692dca84dd6c07992f78ad050177975f16486dd77eJason Sams    uint32_t mTimeMSLastFrame;
2702dca84dd6c07992f78ad050177975f16486dd77eJason Sams    uint32_t mTimeMSLastScript;
2712dca84dd6c07992f78ad050177975f16486dd77eJason Sams    uint32_t mTimeMSLastSwap;
272c8fb69e4a3e01501a3d38a6d3ea185e583d3f493Alex Sakhartchouk    uint32_t mAverageFPSFrameCount;
273c8fb69e4a3e01501a3d38a6d3ea185e583d3f493Alex Sakhartchouk    uint64_t mAverageFPSStartTime;
274c8fb69e4a3e01501a3d38a6d3ea185e583d3f493Alex Sakhartchouk    uint32_t mAverageFPS;
275326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams};
276326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams
27777d9f4bd05b2d2a161f30c12a2248f9c97eaac42Alex Sakhartchouk} // renderscript
27877d9f4bd05b2d2a161f30c12a2248f9c97eaac42Alex Sakhartchouk} // android
279326e0ddf89e8df2837752fbfd7a014814b32082cJason Sams#endif
280