summaryrefslogtreecommitdiffstats
path: root/carousel
diff options
context:
space:
mode:
authorJim Shuma <jshuma@google.com>2011-01-23 14:35:30 -0800
committerJim Shuma <jshuma@google.com>2011-01-23 17:09:13 -0800
commit0de20d1ebd3dc8e766f7f4f4dbc3f77dd7326e30 (patch)
tree106ac0ca03ff582c46d3d8730f69f21dd786f334 /carousel
parent86018e0266578b120b9ad4133a6f189d2a3eac47 (diff)
downloadandroid_frameworks_ex-0de20d1ebd3dc8e766f7f4f4dbc3f77dd7326e30.tar.gz
android_frameworks_ex-0de20d1ebd3dc8e766f7f4f4dbc3f77dd7326e30.tar.bz2
android_frameworks_ex-0de20d1ebd3dc8e766f7f4f4dbc3f77dd7326e30.zip
Invalidate unloaded textures to unloaded
When invalidateTexture() is told to continue drawing the current texture until a replacement is found (STATE_STALE), but the texture was not there in the first place since it hadn't loaded yet, later attempts to draw the texture based on the assumption of its being there (by virtue of being in STATE_STALE or STATE_UPDATING) would result in rendering problems due to trying to bind a nonexistent texture. The fix is to make invalidateTexture() only set STATE_STALE if a valid texture had been there in the first place. As an added precautionary measure, this change also has a stopgap solution that will draw the placeholder image if the state machine indicates the texture is valid but it is not actually valid. This case should never be encountered. Bug: 3356101 Change-Id: Ia87e9e651f8ac3138faced3cf0f6199c58ee51e0
Diffstat (limited to 'carousel')
-rw-r--r--carousel/java/com/android/ex/carousel/carousel.rs19
1 files changed, 13 insertions, 6 deletions
diff --git a/carousel/java/com/android/ex/carousel/carousel.rs b/carousel/java/com/android/ex/carousel/carousel.rs
index 7468c6f..483c502 100644
--- a/carousel/java/com/android/ex/carousel/carousel.rs
+++ b/carousel/java/com/android/ex/carousel/carousel.rs
@@ -464,6 +464,13 @@ static void loadLookatMatrix(rs_matrix4x4* matrix, float3 eye, float3 center, fl
rsMatrixTranslate(matrix, -eye.x, -eye.y, -eye.z);
}
+/*
+ * Returns true if a state represents a texture that is loaded enough to draw
+ */
+static bool textureEverLoaded(int state) {
+ return (state == STATE_LOADED) || (state == STATE_STALE) || (state == STATE_UPDATING);
+}
+
void setTexture(int n, rs_allocation texture)
{
if (n < 0 || n >= cardCount) return;
@@ -497,7 +504,8 @@ void invalidateTexture(int n, bool eraseCurrent)
cards[n].textureState = STATE_INVALID;
rsClearObject(&cards[n].texture);
} else {
- cards[n].textureState = STATE_STALE;
+ cards[n].textureState =
+ textureEverLoaded(cards[n].textureState) ? STATE_STALE : STATE_INVALID;
}
}
@@ -508,7 +516,8 @@ void invalidateDetailTexture(int n, bool eraseCurrent)
cards[n].detailTextureState = STATE_INVALID;
rsClearObject(&cards[n].detailTexture);
} else {
- cards[n].detailTextureState = STATE_STALE;
+ cards[n].detailTextureState =
+ textureEverLoaded(cards[n].detailTextureState) ? STATE_STALE : STATE_INVALID;
}
}
@@ -682,8 +691,7 @@ static bool drawCards(int64_t currentTime)
// Bind the appropriate shader network. If there's no alpha blend, then
// switch to single shader for better performance.
const int state = cards[i].textureState;
- const bool loaded = (state == STATE_LOADED) || (state == STATE_STALE) ||
- (state == STATE_UPDATING);
+ bool loaded = textureEverLoaded(state) && rsIsObject(cards[i].texture);
if (shaderConstants->fadeAmount == 1.0f || shaderConstants->fadeAmount < 0.01f) {
if (overallAlpha < 1.0) {
rsgBindProgramFragment(singleTextureBlendingFragmentProgram);
@@ -790,8 +798,7 @@ static bool drawDetails(int64_t currentTime)
for (int i = cardCount-1; i >= 0; --i) {
if (cards[i].cardVisible) {
const int state = cards[i].detailTextureState;
- const bool isLoaded = (state == STATE_LOADED) || (state == STATE_STALE) ||
- (state == STATE_UPDATING);
+ const bool isLoaded = textureEverLoaded(state);
if (isLoaded && cards[i].detailTexture.p != 0) {
const float lineWidth = rsAllocationGetDimX(detailLineTexture);