diff --git a/libs/rs/rsContext.cpp b/libs/rs/rsContext.cpp index f802a7f98a162..da85f83ac60ec 100644 --- a/libs/rs/rsContext.cpp +++ b/libs/rs/rsContext.cpp @@ -111,6 +111,9 @@ void Context::initEGL(bool useGL2) LOGE("eglCreateContext returned EGL_NO_CONTEXT"); } gGLContextCount++; + + eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth); + eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight); } void Context::deinitEGL() @@ -155,11 +158,8 @@ uint32_t Context::runRootScript() { timerSet(RS_TIMER_CLEAR_SWAP); - eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth); - eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight); - glViewport(0, 0, mEGL.mWidth, mEGL.mHeight); + glViewport(0, 0, mWidth, mHeight); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glClearColor(mRootScript->mEnviroment.mClearColor[0], mRootScript->mEnviroment.mClearColor[1], mRootScript->mEnviroment.mClearColor[2], @@ -299,13 +299,13 @@ void * Context::threadProc(void *vrsc) } if (rsc->mIsGraphicsContext) { - rsc->mStateRaster.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight); + rsc->mStateRaster.init(rsc); rsc->setRaster(NULL); - rsc->mStateVertex.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight); + rsc->mStateVertex.init(rsc); rsc->setVertex(NULL); - rsc->mStateFragment.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight); + rsc->mStateFragment.init(rsc); rsc->setFragment(NULL); - rsc->mStateFragmentStore.init(rsc, rsc->mEGL.mWidth, rsc->mEGL.mHeight); + rsc->mStateFragmentStore.init(rsc); rsc->setFragmentStore(NULL); rsc->mStateVertexArray.init(rsc); } @@ -493,6 +493,8 @@ void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur) mWndSurface = sur; if (mWndSurface != NULL) { + mWidth = w; + mHeight = h; bool first = false; if (!mEGL.mContext) { first = true; @@ -510,11 +512,7 @@ void Context::setSurface(uint32_t w, uint32_t h, android_native_window_t *sur) ret = eglMakeCurrent(mEGL.mDisplay, mEGL.mSurface, mEGL.mSurface, mEGL.mContext); checkEglError("eglMakeCurrent", ret); - eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_WIDTH, &mEGL.mWidth); - eglQuerySurface(mEGL.mDisplay, mEGL.mSurface, EGL_HEIGHT, &mEGL.mHeight); - mWidth = w; - mHeight = h; - mStateVertex.updateSize(this, w, h); + mStateVertex.updateSize(this); if ((int)mWidth != mEGL.mWidth || (int)mHeight != mEGL.mHeight) { LOGE("EGL/Surface mismatch EGL (%i x %i) SF (%i x %i)", mEGL.mWidth, mEGL.mHeight, mWidth, mHeight); diff --git a/libs/rs/rsContext.h b/libs/rs/rsContext.h index c8f0be569ae34..4a6072d6093af 100644 --- a/libs/rs/rsContext.h +++ b/libs/rs/rsContext.h @@ -125,8 +125,8 @@ public: return mStateRaster.mDefault.get(); } - uint32_t getWidth() const {return mEGL.mWidth;} - uint32_t getHeight() const {return mEGL.mHeight;} + uint32_t getWidth() const {return mWidth;} + uint32_t getHeight() const {return mHeight;} ThreadIO mIO; diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index d192195e5f17b..aaa9a084bb441 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -300,7 +300,7 @@ ProgramFragmentState::~ProgramFragmentState() } -void ProgramFragmentState::init(Context *rsc, int32_t w, int32_t h) +void ProgramFragmentState::init(Context *rsc) { uint32_t tmp[5] = { RS_TEX_ENV_MODE_NONE, 0, diff --git a/libs/rs/rsProgramFragment.h b/libs/rs/rsProgramFragment.h index 9fa565d4cf8db..db91524744509 100644 --- a/libs/rs/rsProgramFragment.h +++ b/libs/rs/rsProgramFragment.h @@ -57,7 +57,7 @@ public: ~ProgramFragmentState(); ProgramFragment *mPF; - void init(Context *rsc, int32_t w, int32_t h); + void init(Context *rsc); void deinit(Context *rsc); ObjectBaseRef mTextureTypes[ProgramFragment::MAX_TEXTURE]; diff --git a/libs/rs/rsProgramRaster.cpp b/libs/rs/rsProgramRaster.cpp index 13887d15e74e6..c095635652c4c 100644 --- a/libs/rs/rsProgramRaster.cpp +++ b/libs/rs/rsProgramRaster.cpp @@ -102,7 +102,7 @@ ProgramRasterState::~ProgramRasterState() { } -void ProgramRasterState::init(Context *rsc, int32_t w, int32_t h) +void ProgramRasterState::init(Context *rsc) { ProgramRaster *pr = new ProgramRaster(rsc, false, false, false); mDefault.set(pr); diff --git a/libs/rs/rsProgramRaster.h b/libs/rs/rsProgramRaster.h index c3a9c9077866e..04eaaa8f5edc8 100644 --- a/libs/rs/rsProgramRaster.h +++ b/libs/rs/rsProgramRaster.h @@ -56,7 +56,7 @@ class ProgramRasterState public: ProgramRasterState(); ~ProgramRasterState(); - void init(Context *rsc, int32_t w, int32_t h); + void init(Context *rsc); void deinit(Context *rsc); ObjectBaseRef mDefault; diff --git a/libs/rs/rsProgramStore.cpp b/libs/rs/rsProgramStore.cpp index 2e5114f1f5db6..ff70509ad9c9e 100644 --- a/libs/rs/rsProgramStore.cpp +++ b/libs/rs/rsProgramStore.cpp @@ -247,7 +247,7 @@ ProgramStoreState::~ProgramStoreState() } -void ProgramStoreState::init(Context *rsc, int32_t w, int32_t h) +void ProgramStoreState::init(Context *rsc) { ProgramStore *pfs = new ProgramStore(rsc); mDefault.set(pfs); diff --git a/libs/rs/rsProgramStore.h b/libs/rs/rsProgramStore.h index 1b5543caea03a..d686aa85c8201 100644 --- a/libs/rs/rsProgramStore.h +++ b/libs/rs/rsProgramStore.h @@ -65,7 +65,7 @@ class ProgramStoreState public: ProgramStoreState(); ~ProgramStoreState(); - void init(Context *rsc, int32_t w, int32_t h); + void init(Context *rsc); void deinit(Context *rsc); ObjectBaseRef mDefault; diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index a2b2df4d967e4..c3264aed76bd6 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -362,7 +362,7 @@ ProgramVertexState::~ProgramVertexState() { } -void ProgramVertexState::init(Context *rsc, int32_t w, int32_t h) +void ProgramVertexState::init(Context *rsc) { RsElement e = (RsElement) Element::create(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 1); @@ -382,13 +382,13 @@ void ProgramVertexState::init(Context *rsc, int32_t w, int32_t h) color[2] = 1.f; color[3] = 1.f; - updateSize(rsc, w, h); + updateSize(rsc); } -void ProgramVertexState::updateSize(Context *rsc, int32_t w, int32_t h) +void ProgramVertexState::updateSize(Context *rsc) { Matrix m; - m.loadOrtho(0,w, h,0, -1,1); + m.loadOrtho(0,rsc->getWidth(), rsc->getHeight(),0, -1,1); mDefaultAlloc->subData(RS_PROGRAM_VERTEX_PROJECTION_OFFSET, 16, &m.m[0], 16*4); m.loadIdentity(); diff --git a/libs/rs/rsProgramVertex.h b/libs/rs/rsProgramVertex.h index 28554cc813d6c..bdac978530f16 100644 --- a/libs/rs/rsProgramVertex.h +++ b/libs/rs/rsProgramVertex.h @@ -71,9 +71,9 @@ public: ProgramVertexState(); ~ProgramVertexState(); - void init(Context *rsc, int32_t w, int32_t h); + void init(Context *rsc); void deinit(Context *rsc); - void updateSize(Context *rsc, int32_t w, int32_t h); + void updateSize(Context *rsc); ObjectBaseRef mDefault; ObjectBaseRef mLast; diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp index 1c63c115b80ee..1dd9554f20152 100644 --- a/libs/rs/rsScript.cpp +++ b/libs/rs/rsScript.cpp @@ -145,7 +145,7 @@ void rsi_ScriptInvokeV(Context *rsc, RsScript vs, uint32_t slot, const void *dat } s->setupScript(); - LOGE("rsi_ScriptInvokeV, len=%i", len); + //LOGE("rsi_ScriptInvokeV, len=%i", len); const uint32_t * dPtr = (const uint32_t *)data; switch(len) { case 0: