summaryrefslogtreecommitdiffstats
path: root/libs/hwui
diff options
context:
space:
mode:
authorRomain Guy <romainguy@google.com>2010-09-16 14:16:48 -0700
committerRomain Guy <romainguy@google.com>2010-09-16 14:16:48 -0700
commitb025b9c8b4efefadb01937db61a1f8ee7d2452bf (patch)
treedabed85e1e6b4aad2363925c779b783855b02d7e /libs/hwui
parent857d7cf80ee37fc3b1d55ecfa4c27029672f5114 (diff)
downloadframeworks_base-b025b9c8b4efefadb01937db61a1f8ee7d2452bf.zip
frameworks_base-b025b9c8b4efefadb01937db61a1f8ee7d2452bf.tar.gz
frameworks_base-b025b9c8b4efefadb01937db61a1f8ee7d2452bf.tar.bz2
Better error handling in the OpenGL renderer.
Add a glGetError() check on every frame Don't attempt to create textures larger than the maximum size allowed Change-Id: Iee4afae16089406dbe8bf10fc93b674f1271a0ca
Diffstat (limited to 'libs/hwui')
-rw-r--r--libs/hwui/LayerCache.cpp2
-rw-r--r--libs/hwui/OpenGLRenderer.cpp16
-rw-r--r--libs/hwui/OpenGLRenderer.h10
3 files changed, 25 insertions, 3 deletions
diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp
index 1a18766..39c3111 100644
--- a/libs/hwui/LayerCache.cpp
+++ b/libs/hwui/LayerCache.cpp
@@ -110,11 +110,9 @@ Layer* LayerCache::get(LayerSize& size) {
layer = new Layer;
layer->blend = true;
- // Generate the texture in which the FBO will draw
glGenTextures(1, &layer->texture);
glBindTexture(GL_TEXTURE_2D, layer->texture);
- // The FBO will not be scaled, so we can use lower quality filtering
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp
index f187d3e..670d049 100644
--- a/libs/hwui/OpenGLRenderer.cpp
+++ b/libs/hwui/OpenGLRenderer.cpp
@@ -124,6 +124,8 @@ OpenGLRenderer::OpenGLRenderer(): mCaches(Caches::getInstance()) {
if (maxTextureUnits < REQUIRED_TEXTURE_UNITS_COUNT) {
LOGW("At least %d texture units are required!", REQUIRED_TEXTURE_UNITS_COUNT);
}
+
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &mMaxTextureSize);
}
OpenGLRenderer::~OpenGLRenderer() {
@@ -161,6 +163,15 @@ void OpenGLRenderer::prepare() {
mSnapshot->setClip(0.0f, 0.0f, mWidth, mHeight);
}
+void OpenGLRenderer::finish() {
+#if DEBUG_OPENGL
+ GLenum status = GL_NO_ERROR;
+ while ((status = glGetError()) != GL_NO_ERROR) {
+ LOGD("GL error from OpenGLRenderer: 0x%x", status);
+ }
+#endif
+}
+
void OpenGLRenderer::acquireContext() {
if (mCaches.currentProgram) {
if (mCaches.currentProgram->isInUse()) {
@@ -342,7 +353,10 @@ bool OpenGLRenderer::createLayer(sp<Snapshot> snapshot, float left, float top,
// Layers only make sense if they are in the framebuffer's bounds
bounds.intersect(*mSnapshot->clipRect);
- if (bounds.isEmpty()) return false;
+ if (bounds.isEmpty() || bounds.getWidth() > mMaxTextureSize ||
+ bounds.getHeight() > mMaxTextureSize) {
+ return false;
+ }
LayerSize size(bounds.getWidth(), bounds.getHeight());
Layer* layer = mCaches.layerCache.get(size);
diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h
index 49a69f9..387fb12 100644
--- a/libs/hwui/OpenGLRenderer.h
+++ b/libs/hwui/OpenGLRenderer.h
@@ -45,6 +45,13 @@ namespace android {
namespace uirenderer {
///////////////////////////////////////////////////////////////////////////////
+// Defines
+///////////////////////////////////////////////////////////////////////////////
+
+// Debug
+#define DEBUG_OPENGL 1
+
+///////////////////////////////////////////////////////////////////////////////
// Renderer
///////////////////////////////////////////////////////////////////////////////
@@ -59,6 +66,7 @@ public:
void setViewport(int width, int height);
void prepare();
+ void finish();
void acquireContext();
void releaseContext();
@@ -395,6 +403,8 @@ private:
// List of rectangles to clear due to calls to saveLayer()
Vector<Rect*> mLayers;
+ GLint mMaxTextureSize;
+
}; // class OpenGLRenderer
}; // namespace uirenderer