From cf51a4199835e9604aa4c8b3854306f8fbabbf33 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 8 Apr 2013 19:40:31 -0700 Subject: Introduce PixelBuffer API to enable PBOs PBOs (Pixel Buffer Objects) can be used on OpenGL ES 3.0 to perform asynchronous texture uploads to free up the CPU. This change does not enable the use of PBOs unless a specific property is set (Adreno drivers have issues with PBOs at the moment, Mali drivers work just fine.) This change also cleans up Font/FontRenderer a little bit and improves performance of drop shadows generations by using memcpy() instead of a manual byte-by-byte copy. On GL ES 2.0 devices, or when PBOs are disabled, a PixelBuffer instance behaves like a simple byte array. The extra APIs introduced for PBOs (map/unmap and bind/unbind) are pretty much no-ops for CPU pixel buffers and won't introduce any significant overhead. This change also fixes a bug with text drop shadows: if the drop shadow is larger than the max texture size, the renderer would leave the GL context in a bad state and generate 0x501 errors. This change simply skips drop shadows if they are too large. Change-Id: I2700aadb0c6093431dc5dee3d587d689190c4e23 --- libs/hwui/OpenGLRenderer.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'libs/hwui/OpenGLRenderer.cpp') diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index e18d92223ed4..dcd1eb834fcb 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -2644,6 +2644,9 @@ void OpenGLRenderer::drawTextShadow(SkPaint* paint, const char* text, int bytesC mCaches.dropShadowCache.setFontRenderer(fontRenderer); const ShadowTexture* shadow = mCaches.dropShadowCache.get( paint, text, bytesCount, count, mDrawModifiers.mShadowRadius, positions); + // If the drop shadow exceeds the max texture size or couldn't be + // allocated, skip drawing + if (!shadow) return; const AutoTexture autoCleanup(shadow); const float sx = x - shadow->left + mDrawModifiers.mShadowDx; -- cgit v1.2.3-59-g8ed1b