summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-01-29 12:53:38 -0800
committerJohn Reck <jreck@google.com>2015-01-29 12:53:38 -0800
commit49bc4acfadf9c5b1e520217278ccb38010d38c89 (patch)
tree2731146935070300785f256599ed69a83a9afdab /libs
parent293b7b4fe510bf7df879e89bf748c0b8695f4310 (diff)
parentfe5ac4fc31ee671721f98cf28cf1bd32ac119998 (diff)
downloadframeworks_base-49bc4acfadf9c5b1e520217278ccb38010d38c89.zip
frameworks_base-49bc4acfadf9c5b1e520217278ccb38010d38c89.tar.gz
frameworks_base-49bc4acfadf9c5b1e520217278ccb38010d38c89.tar.bz2
resolved conflicts for merge of fe5ac4fc to master
Change-Id: I6c0cc82db14b56297586469f940e408c0e218b3b
Diffstat (limited to 'libs')
-rw-r--r--libs/hwui/Caches.cpp2
-rw-r--r--libs/hwui/Layer.cpp14
-rw-r--r--libs/hwui/Layer.h6
-rw-r--r--libs/hwui/renderstate/RenderState.cpp6
-rw-r--r--libs/hwui/renderstate/RenderState.h6
5 files changed, 27 insertions, 7 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp
index dee0dcd..1fb8092 100644
--- a/libs/hwui/Caches.cpp
+++ b/libs/hwui/Caches.cpp
@@ -250,7 +250,7 @@ void Caches::dumpMemoryUsage(String8 &log) {
layerCache.getSize(), layerCache.getMaxSize(), layerCache.getCount());
if (mRenderState) {
int memused = 0;
- for (std::set<const Layer*>::iterator it = mRenderState->mActiveLayers.begin();
+ for (std::set<Layer*>::iterator it = mRenderState->mActiveLayers.begin();
it != mRenderState->mActiveLayers.end(); it++) {
const Layer* layer = *it;
log.appendFormat(" Layer size %dx%d; isTextureLayer()=%d; texid=%u fbo=%u; refs=%d\n",
diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp
index ee6154f..7a4b830 100644
--- a/libs/hwui/Layer.cpp
+++ b/libs/hwui/Layer.cpp
@@ -68,15 +68,23 @@ Layer::Layer(Type layerType, RenderState& renderState, const uint32_t layerWidth
}
Layer::~Layer() {
- renderState.requireGLContext();
renderState.unregisterLayer(this);
SkSafeUnref(colorFilter);
- removeFbo();
- deleteTexture();
+
+ if (stencil || fbo || texture.id) {
+ renderState.requireGLContext();
+ removeFbo();
+ deleteTexture();
+ }
delete[] mesh;
}
+void Layer::onGlContextLost() {
+ removeFbo();
+ deleteTexture();
+}
+
uint32_t Layer::computeIdealWidth(uint32_t layerWidth) {
return uint32_t(ceilf(layerWidth / float(LAYER_SIZE)) * LAYER_SIZE);
}
diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h
index 3b4f293..84ff021 100644
--- a/libs/hwui/Layer.h
+++ b/libs/hwui/Layer.h
@@ -288,6 +288,12 @@ public:
void postDecStrong();
/**
+ * Lost the GL context but the layer is still around, mark it invalid internally
+ * so the dtor knows not to do any GL work
+ */
+ void onGlContextLost();
+
+ /**
* Bounds of the layer.
*/
Rect layer;
diff --git a/libs/hwui/renderstate/RenderState.cpp b/libs/hwui/renderstate/RenderState.cpp
index 4b190f0..e4c8745 100644
--- a/libs/hwui/renderstate/RenderState.cpp
+++ b/libs/hwui/renderstate/RenderState.cpp
@@ -51,6 +51,10 @@ void RenderState::onGLContextCreated() {
mCaches->textureCache.setAssetAtlas(&mAssetAtlas);
}
+static void layerLostGlContext(Layer* layer) {
+ layer->onGlContextLost();
+}
+
void RenderState::onGLContextDestroyed() {
/*
size_t size = mActiveLayers.size();
@@ -83,7 +87,9 @@ void RenderState::onGLContextDestroyed() {
LOG_ALWAYS_FATAL("%d layers have survived gl context destruction", size);
}
*/
+
// TODO: reset all cached state in state objects
+ std::for_each(mActiveLayers.begin(), mActiveLayers.end(), layerLostGlContext);
mAssetAtlas.terminate();
delete mMeshState;
diff --git a/libs/hwui/renderstate/RenderState.h b/libs/hwui/renderstate/RenderState.h
index 501d76f..d1ee64a 100644
--- a/libs/hwui/renderstate/RenderState.h
+++ b/libs/hwui/renderstate/RenderState.h
@@ -62,10 +62,10 @@ public:
void debugOverdraw(bool enable, bool clear);
- void registerLayer(const Layer* layer) {
+ void registerLayer(Layer* layer) {
mActiveLayers.insert(layer);
}
- void unregisterLayer(const Layer* layer) {
+ void unregisterLayer(Layer* layer) {
mActiveLayers.erase(layer);
}
@@ -107,7 +107,7 @@ private:
Stencil* mStencil;
AssetAtlas mAssetAtlas;
- std::set<const Layer*> mActiveLayers;
+ std::set<Layer*> mActiveLayers;
std::set<renderthread::CanvasContext*> mRegisteredContexts;
GLsizei mViewportWidth;