Change RS to use the passed surface size rather than EGL size.
Its possible that during a resize the EGL information could be stale so
caching this is bad. The surface size should always be correct.
Change-Id: Ifd479e1ea70b1cada1a8690c7c82e91aa391b685
Conflicts:
libs/rs/rsProgramStore.cpp
libs/rs/rsProgramStore.h
diff --git a/rsContext.cpp b/rsContext.cpp
index f802a7f..da85f83 100644
--- a/rsContext.cpp
+++ b/rsContext.cpp
@@ -111,6 +111,9 @@
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 @@
{
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 @@
}
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 @@
mWndSurface = sur;
if (mWndSurface != NULL) {
+ mWidth = w;
+ mHeight = h;
bool first = false;
if (!mEGL.mContext) {
first = true;
@@ -510,11 +512,7 @@
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/rsContext.h b/rsContext.h
index c8f0be5..4a6072d 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -125,8 +125,8 @@
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/rsProgramFragment.cpp b/rsProgramFragment.cpp
index d192195..aaa9a08 100644
--- a/rsProgramFragment.cpp
+++ b/rsProgramFragment.cpp
@@ -300,7 +300,7 @@
}
-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/rsProgramFragment.h b/rsProgramFragment.h
index 9fa565d..db91524 100644
--- a/rsProgramFragment.h
+++ b/rsProgramFragment.h
@@ -57,7 +57,7 @@
~ProgramFragmentState();
ProgramFragment *mPF;
- void init(Context *rsc, int32_t w, int32_t h);
+ void init(Context *rsc);
void deinit(Context *rsc);
ObjectBaseRef<Type> mTextureTypes[ProgramFragment::MAX_TEXTURE];
diff --git a/rsProgramRaster.cpp b/rsProgramRaster.cpp
index 13887d1..c095635 100644
--- a/rsProgramRaster.cpp
+++ b/rsProgramRaster.cpp
@@ -102,7 +102,7 @@
{
}
-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/rsProgramRaster.h b/rsProgramRaster.h
index c3a9c90..04eaaa8 100644
--- a/rsProgramRaster.h
+++ b/rsProgramRaster.h
@@ -56,7 +56,7 @@
public:
ProgramRasterState();
~ProgramRasterState();
- void init(Context *rsc, int32_t w, int32_t h);
+ void init(Context *rsc);
void deinit(Context *rsc);
ObjectBaseRef<ProgramRaster> mDefault;
diff --git a/rsProgramStore.cpp b/rsProgramStore.cpp
index 2e5114f..ff70509 100644
--- a/rsProgramStore.cpp
+++ b/rsProgramStore.cpp
@@ -247,7 +247,7 @@
}
-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/rsProgramStore.h b/rsProgramStore.h
index 1b5543c..d686aa8 100644
--- a/rsProgramStore.h
+++ b/rsProgramStore.h
@@ -65,7 +65,7 @@
public:
ProgramStoreState();
~ProgramStoreState();
- void init(Context *rsc, int32_t w, int32_t h);
+ void init(Context *rsc);
void deinit(Context *rsc);
ObjectBaseRef<ProgramStore> mDefault;
diff --git a/rsProgramVertex.cpp b/rsProgramVertex.cpp
index a2b2df4..c3264ae 100644
--- a/rsProgramVertex.cpp
+++ b/rsProgramVertex.cpp
@@ -362,7 +362,7 @@
{
}
-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 @@
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/rsProgramVertex.h b/rsProgramVertex.h
index 28554cc..bdac978 100644
--- a/rsProgramVertex.h
+++ b/rsProgramVertex.h
@@ -71,9 +71,9 @@
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<ProgramVertex> mDefault;
ObjectBaseRef<ProgramVertex> mLast;
diff --git a/rsScript.cpp b/rsScript.cpp
index 1c63c11..1dd9554 100644
--- a/rsScript.cpp
+++ b/rsScript.cpp
@@ -145,7 +145,7 @@
}
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: