Bug 728631 - Don't disable blending inside our Java rendering code, because we rely on it remaining set from LayerManagerOGL. r=dougt
authorJoe Drew <joe@drew.ca>
Mon, 20 Feb 2012 14:48:36 -0800
changeset 89216 b5879891f58c518fc2b8b5e8f1821da797c02c98
parent 89215 be009e74d30f1bdde8f64e9e7c7522367055970b
child 89217 eff263ee7c827484255e08d56f1e8c20331fc472
push id7119
push usereakhgari@mozilla.com
push dateWed, 14 Mar 2012 17:40:57 +0000
treeherdermozilla-inbound@10d7baa4aff0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdougt
bugs728631
milestone13.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 728631 - Don't disable blending inside our Java rendering code, because we rely on it remaining set from LayerManagerOGL. r=dougt
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextProviderEGL.cpp
mobile/android/base/gfx/LayerRenderer.java
mobile/android/base/gfx/NinePatchTileLayer.java
mobile/android/base/gfx/ScrollbarLayer.java
mobile/android/base/gfx/SurfaceTextureLayer.java
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -57,17 +57,17 @@
 #include "mozilla/Preferences.h"
 #include "mozilla/Util.h" // for DebugOnly
 
 using namespace mozilla::gfx;
 
 namespace mozilla {
 namespace gl {
 
-#ifdef DEBUG
+#if 1
 // see comment near declaration in GLContext.h. Should be thread-local.
 GLContext* GLContext::sCurrentGLContext = nsnull;
 #endif
 
 PRUint32 GLContext::sDebugMode = 0;
 
 // define this here since it's global to GLContextProvider, not any
 // specific implementation
@@ -421,17 +421,17 @@ GLContext::InitWithPrefix(const char *pr
             if (DoesStringMatch(glRendererString, rendererMatchStrings[i])) {
                 mRenderer = i;
                 break;
             }
         }
     }
 
     if (mInitialized) {
-#ifdef DEBUG
+#if 1
         static bool once = false;
         if (!once) {
             const char *vendors[VendorOther] = {
                 "Intel",
                 "NVIDIA",
                 "ATI",
                 "Qualcomm"
             };
@@ -540,17 +540,17 @@ GLContext::InitWithPrefix(const char *pr
                 if (auxFormat == LOCAL_GL_BGRA && auxType == LOCAL_GL_UNSIGNED_BYTE)
                     mSupport_ES_ReadPixels_BGRA_UByte = true;
             }
         }
 
         UpdateActualFormat();
     }
 
-#ifdef DEBUG
+#if 1
     if (PR_GetEnv("MOZ_GL_DEBUG"))
         sDebugMode |= DebugEnabled;
 
     // enables extra verbose output, informing of the start and finish of every GL call.
     // useful e.g. to record information to investigate graphics system crashes/lockups
     if (PR_GetEnv("MOZ_GL_DEBUG_VERBOSE"))
         sDebugMode |= DebugTrace;
 
@@ -571,17 +571,17 @@ GLContext::InitWithPrefix(const char *pr
 
 void
 GLContext::InitExtensions()
 {
     MakeCurrent();
     const GLubyte *extensions = fGetString(LOCAL_GL_EXTENSIONS);
     char *exts = strdup((char *)extensions);
 
-#ifdef DEBUG
+#if 1
     static bool once = false;
 #else
     const bool once = true;
 #endif
 
     if (!once) {
         printf_stderr("GL extensions: %s\n", exts);
     }
@@ -605,17 +605,17 @@ GLContext::InitExtensions()
             }
         }
 
         s = space+1;
     }
 
     free(exts);
 
-#ifdef DEBUG
+#if 1
     once = true;
 #endif
 }
 
 // Take texture data in a given buffer and copy it into a larger buffer,
 // padding out the edge pixels for filtering if necessary
 static void
 CopyAndPadTextureData(const GLvoid* srcBuffer,
@@ -1454,27 +1454,27 @@ GLContext::ResizeOffscreenFBO(const gfxI
     // We should be all resized.  Check for framebuffer completeness.
     GLenum status;
     bool framebuffersComplete = true;
 
     fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, newOffscreenDrawFBO);
     status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
     if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
         NS_WARNING("DrawFBO: Incomplete");
-#ifdef DEBUG
+#if 1
         printf_stderr("Framebuffer status: %X\n", status);
 #endif
         framebuffersComplete = false;
     }
 
     fBindFramebuffer(LOCAL_GL_FRAMEBUFFER, newOffscreenReadFBO);
     status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
     if (status != LOCAL_GL_FRAMEBUFFER_COMPLETE) {
         NS_WARNING("ReadFBO: Incomplete");
-#ifdef DEBUG
+#if 1
         printf_stderr("Framebuffer status: %X\n", status);
 #endif
         framebuffersComplete = false;
     }
 
     if (!framebuffersComplete) {
         NS_WARNING("Error resizing offscreen framebuffer -- framebuffer(s) not complete");
 
@@ -1526,17 +1526,17 @@ GLContext::ResizeOffscreenFBO(const gfxI
     mOffscreenDepthRB = newOffscreenDepthRB;
     mOffscreenStencilRB = newOffscreenStencilRB;
 
     mOffscreenSize = aSize;
     mOffscreenActualSize = aSize;
 
     mActualFormat = cf;
 
-#ifdef DEBUG
+#if 1
     if (DebugMode()) {
         printf_stderr("Resized %dx%d offscreen FBO: r: %d g: %d b: %d a: %d depth: %d stencil: %d samples: %d\n",
                       mOffscreenActualSize.width, mOffscreenActualSize.height,
                       mActualFormat.red, mActualFormat.green, mActualFormat.blue, mActualFormat.alpha,
                       mActualFormat.depth, mActualFormat.stencil, mActualFormat.samples);
     }
 #endif
 
@@ -2714,17 +2714,17 @@ GLContext::SetBlitFramebufferForDestText
         // Note: if you are hitting this, it is likely that
         // your texture is not texture complete -- that is, you
         // allocated a texture name, but didn't actually define its
         // size via a call to TexImage2D.
         NS_RUNTIMEABORT(msg.get());
     }
 }
 
-#ifdef DEBUG
+#if 1
 
 void
 GLContext::CreatedProgram(GLContext *aOrigin, GLuint aName)
 {
     mTrackedPrograms.AppendElement(NamedResource(aOrigin, aName));
 }
 
 void
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -564,26 +564,26 @@ public:
         mFlipped(false),
         mBlitProgram(0),
         mBlitFramebuffer(0),
         mOffscreenDrawFBO(0),
         mOffscreenReadFBO(0),
         mOffscreenColorRB(0),
         mOffscreenDepthRB(0),
         mOffscreenStencilRB(0)
-#ifdef DEBUG
+#if 1
         , mGLError(LOCAL_GL_NO_ERROR)
 #endif
     {
         mUserData.Init();
     }
 
     virtual ~GLContext() {
         NS_ASSERTION(IsDestroyed(), "GLContext implementation must call MarkDestroyed in destructor!");
-#ifdef DEBUG
+#if 1
         if (mSharedContext) {
             GLContext *tip = mSharedContext;
             while (tip->mSharedContext)
                 tip = tip->mSharedContext;
             tip->SharedContextDestroyed(this);
             tip->ReportOutstandingNames();
         }
 #endif
@@ -598,17 +598,17 @@ public:
         ContextTypeOSMesa
     };
 
     virtual GLContextType GetContextType() { return ContextTypeUnknown; }
 
     virtual bool MakeCurrentImpl(bool aForce = false) = 0;
 
     bool MakeCurrent(bool aForce = false) {
-#ifdef DEBUG
+#if 1
         sCurrentGLContext = this;
 #endif
         return MakeCurrentImpl(aForce);
     }
 
     bool IsContextLost() { return mContextLost; }
 
     virtual bool SetupLookupFunction() = 0;
@@ -928,17 +928,17 @@ public:
 
           default:
             raw_fBindFramebuffer(target, framebuffer);
             break;
         }
     }
 
     GLuint GetBoundDrawFBO() {
-#ifdef DEBUG
+#if 1
         GLint ret = 0;
         // Don't need a branch here, because:
         // LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT == LOCAL_GL_FRAMEBUFFER_BINDING == 0x8CA6
         // We use raw_ here because this is debug code and we need to see what
         // the driver thinks.
         raw_fGetIntegerv(LOCAL_GL_DRAW_FRAMEBUFFER_BINDING_EXT, &ret);
 
         if (mInternalBoundDrawFBO != (GLuint)ret) {
@@ -947,17 +947,17 @@ public:
         }
 #endif
 
         // We only ever expose the user's bound FBOs
         return mUserBoundDrawFBO;
     }
 
     GLuint GetBoundReadFBO() {
-#ifdef DEBUG
+#if 1
         GLint ret = 0;
         // We use raw_ here because this is debug code and we need to see what
         // the driver thinks.
         if (SupportsOffscreenSplit())
             raw_fGetIntegerv(LOCAL_GL_READ_FRAMEBUFFER_BINDING_EXT, &ret);
         else
             raw_fGetIntegerv(LOCAL_GL_FRAMEBUFFER_BINDING, &ret);
 
@@ -1489,31 +1489,31 @@ public:
         DebugEnabled = 1 << 0,
         DebugTrace = 1 << 1,
         DebugAbortOnError = 1 << 2
     };
 
     static PRUint32 sDebugMode;
 
     static PRUint32 DebugMode() {
-#ifdef DEBUG
+#if 1
         return sDebugMode;
 #else
         return 0;
 #endif
     }
 
 protected:
 
     ContextFormat mCreationFormat;
     nsRefPtr<GLContext> mSharedContext;
 
     GLContextSymbols mSymbols;
 
-#ifdef DEBUG
+#if 1
     // this should be thread-local, but that is slightly annoying to implement because on Mac
     // we don't have any __thread-like keyword. So for now, MOZ_GL_DEBUG assumes (and asserts)
     // that only the main thread is doing OpenGL calls.
     static THEBES_API GLContext* sCurrentGLContext;
 #endif
 
     void UpdateActualFormat();
     ContextFormat mActualFormat;
@@ -1612,17 +1612,17 @@ public:
         if (error) {
             // clear all pending errors
             while(fGetError()) {}
         }
         
         return error;
     }
 
-#ifdef DEBUG
+#if 1
 
 #ifndef MOZ_FUNCTION_NAME
 # ifdef __GNUC__
 #  define MOZ_FUNCTION_NAME __PRETTY_FUNCTION__
 # elif defined(_MSC_VER)
 #  define MOZ_FUNCTION_NAME __FUNCTION__
 # else
 #  define MOZ_FUNCTION_NAME __func__  // defined in C99, supported in various C++ compilers. Just raw function name.
@@ -1713,17 +1713,17 @@ public:
 #define BEFORE_GL_CALL do { } while (0)
 #define AFTER_GL_CALL do { } while (0)
 
 #endif
 
     /*** In GL debug mode, we completely override glGetError ***/
 
     GLenum fGetError() {
-#ifdef DEBUG
+#if 1
         // debug mode ends up eating the error in AFTER_GL_CALL
         if (DebugMode()) {
             GLenum err = mGLError;
             mGLError = LOCAL_GL_NO_ERROR;
             return err;
         }
 #endif
 
@@ -2641,17 +2641,17 @@ public:
     realGLboolean fUnmapBuffer(GLenum target) {
         BEFORE_GL_CALL;
         realGLboolean ret = mSymbols.fUnmapBuffer(target);
         AFTER_GL_CALL;
         return ret;
     }
 
 
-#ifdef DEBUG
+#if 1
      GLContext *TrackingContext() {
          GLContext *tip = this;
          while (tip->mSharedContext)
              tip = tip->mSharedContext;
          return tip;
      }
 
 #define TRACKING_CONTEXT(a) do { TrackingContext()->a; } while (0)
@@ -2751,17 +2751,17 @@ public:
 
      GLenum GLAPIENTRY fGetGraphicsResetStatus() {
          BEFORE_GL_CALL;
          GLenum ret = mHasRobustness ? mSymbols.fGetGraphicsResetStatus() : 0;
          AFTER_GL_CALL;
          return ret;
      }
 
-#ifdef DEBUG
+#if 1
     void THEBES_API CreatedProgram(GLContext *aOrigin, GLuint aName);
     void THEBES_API CreatedShader(GLContext *aOrigin, GLuint aName);
     void THEBES_API CreatedBuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
     void THEBES_API CreatedTextures(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
     void THEBES_API CreatedFramebuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
     void THEBES_API CreatedRenderbuffers(GLContext *aOrigin, GLsizei aCount, GLuint *aNames);
     void THEBES_API DeletedProgram(GLContext *aOrigin, GLuint aName);
     void THEBES_API DeletedShader(GLContext *aOrigin, GLuint aName);
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -247,17 +247,17 @@ is_power_of_two(int v)
     NS_ASSERTION(v >= 0, "bad value");
 
     if (v == 0)
         return true;
 
     return (v & (v-1)) == 0;
 }
 
-#ifdef DEBUG
+#if 1
 #undef BEFORE_GL_CALL
 #undef AFTER_GL_CALL
 
 #define BEFORE_GL_CALL do {          \
     BeforeGLCall(MOZ_FUNCTION_NAME); \
 } while (0)
 
 #define AFTER_GL_CALL do {           \
@@ -992,32 +992,32 @@ public:
         , mBound(false)
         , mIsPBuffer(false)
         , mIsDoubleBuffered(false)
         , mPBufferCanBindToTexture(false)
     {
         // any EGL contexts will always be GLESv2
         SetIsGLES2(true);
 
-#ifdef DEBUG
+#if 1
         printf_stderr("Initializing context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
 #endif
     }
 
     ~GLContextEGL()
     {
         MarkDestroyed();
 
         // If mGLWidget is non-null, then we've been given it by the GL context provider,
         // and it's managed by the widget implementation. In this case, We can't destroy
         // our contexts.
         if (mPlatformContext)
             return;
 
-#ifdef DEBUG
+#if 1
         printf_stderr("Destroying context %p surface %p on display %p\n", mContext, mSurface, EGL_DISPLAY());
 #endif
 
         sEGLLibrary.fDestroyContext(EGL_DISPLAY(), mContext);
         if (mSurface && !mPlatformContext) {
             sEGLLibrary.fDestroySurface(EGL_DISPLAY(), mSurface);
         }
     }
@@ -2211,17 +2211,17 @@ CreateConfig(EGLConfig* aConfig)
     return false;
 }
 
 static EGLSurface
 CreateSurfaceForWindow(nsIWidget *aWidget, EGLConfig config)
 {
     EGLSurface surface;
 
-#ifdef DEBUG
+#if 1
     sEGLLibrary.DumpEGLConfig(config);
 #endif
 
 #ifdef MOZ_JAVA_COMPOSITOR
     printf_stderr("... requesting window surface from bridge\n");
     surface = mozilla::AndroidBridge::Bridge()->ProvideEGLSurface();
     printf_stderr("got surface %p\n", surface);
     return surface;
@@ -2420,17 +2420,17 @@ TRY_ATTRIBS_AGAIN:
 
         // no configs? no pbuffers!
         return nsnull;
     }
 
     // XXX do some smarter matching here, perhaps instead of the more complex
     // minimum overrides above
     config = configs[0];
-#ifdef DEBUG
+#if 1
     sEGLLibrary.DumpEGLConfig(config);
 #endif
 
     gfxIntSize pbsize(aSize);
     surface = GLContextEGL::CreatePBufferSurfaceTryingPowerOfTwo(config,
                                                                  configCanBindToTexture
                                                                  ? (aFormat.minAlpha
                                                                     ? LOCAL_EGL_TEXTURE_RGBA
--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -650,23 +650,19 @@ public class LayerRenderer implements GL
                     printCheckerboardStats();
                 }
             }
 
             /* Draw the FPS. */
             if (mShowFrameRate) {
                 updateDroppedFrames(mFrameStartTime);
 
-                try {
-                    GLES20.glEnable(GLES20.GL_BLEND);
-                    GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
-                    mFrameRateLayer.draw(mScreenContext);
-                } finally {
-                    GLES20.glDisable(GLES20.GL_BLEND);
-                }
+		GLES20.glEnable(GLES20.GL_BLEND);
+		GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
+		mFrameRateLayer.draw(mScreenContext);
             }
         }
 
         public void endDrawing() {
             // If a layer update requires further work, schedule another redraw
             if (!mUpdated)
                 mView.requestRender();
 
--- a/mobile/android/base/gfx/NinePatchTileLayer.java
+++ b/mobile/android/base/gfx/NinePatchTileLayer.java
@@ -63,22 +63,18 @@ public class NinePatchTileLayer extends 
     @Override
     public void draw(RenderContext context) {
         if (!initialized())
             return;
 
         GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
         GLES20.glEnable(GLES20.GL_BLEND);
 
-        try {
-            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, getTextureID());
-            drawPatches(context);
-        } finally {
-            GLES20.glDisable(GLES20.GL_BLEND);
-        }
+	GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, getTextureID());
+	drawPatches(context);
     }
 
     private void drawPatches(RenderContext context) {
         /*
          * We divide the nine-patch bitmap up as follows:
          *
          *    +---+---+---+
          *    | 0 | 1 | 2 |
--- a/mobile/android/base/gfx/ScrollbarLayer.java
+++ b/mobile/android/base/gfx/ScrollbarLayer.java
@@ -204,208 +204,204 @@ public class ScrollbarLayer extends Tile
         mBitmap.copyPixelsToBuffer(mBuffer.asIntBuffer());
     }
 
     @Override
     public void draw(RenderContext context) {
         if (!initialized())
             return;
 
-        try {
-            GLES20.glEnable(GLES20.GL_BLEND);
-            GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
+        GLES20.glEnable(GLES20.GL_BLEND);
+        GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
+
+        Rect rect = RectUtils.round(mVertical
+                ? getVerticalRect(context)
+                : getHorizontalRect(context));
+        GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, getTextureID());
+
+        float viewWidth = context.viewport.width();
+        float viewHeight = context.viewport.height();
+
+        float top = viewHeight - rect.top;
+        float bot = viewHeight - rect.bottom;
 
-            Rect rect = RectUtils.round(mVertical
-                                        ? getVerticalRect(context)
-                                        : getHorizontalRect(context));
-            GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, getTextureID());
+        // Coordinates for the scrollbar's body combined with the texture coordinates
+        float[] bodyCoords = {
+            // x, y, z, texture_x, texture_y
+            rect.left/viewWidth, bot/viewHeight, 0,
+            BODY_TEX_COORDS[0], BODY_TEX_COORDS[1],
+
+            rect.left/viewWidth, (bot+rect.height())/viewHeight, 0,
+            BODY_TEX_COORDS[2], BODY_TEX_COORDS[3],
 
-            float viewWidth = context.viewport.width();
-            float viewHeight = context.viewport.height();
+            (rect.left+rect.width())/viewWidth, bot/viewHeight, 0,
+            BODY_TEX_COORDS[4], BODY_TEX_COORDS[5],
 
-            float top = viewHeight - rect.top;
-            float bot = viewHeight - rect.bottom;
+            (rect.left+rect.width())/viewWidth, (bot+rect.height())/viewHeight, 0,
+            BODY_TEX_COORDS[6], BODY_TEX_COORDS[7]
+        };
+
+        // Get the buffer and handles from the context
+        FloatBuffer coordBuffer = context.coordBuffer;
+        int positionHandle = context.positionHandle;
+        int textureHandle = context.textureHandle;
 
-            // Coordinates for the scrollbar's body combined with the texture coordinates
-            float[] bodyCoords = {
-                // x, y, z, texture_x, texture_y
-                rect.left/viewWidth, bot/viewHeight, 0,
-                BODY_TEX_COORDS[0], BODY_TEX_COORDS[1],
+        // Make sure we are at position zero in the buffer in case other draw methods did not
+        // clean up after themselves
+        coordBuffer.position(0);
+        coordBuffer.put(bodyCoords);
+
+        // Vertex coordinates are x,y,z starting at position 0 into the buffer.
+        coordBuffer.position(0);
+        GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20,
+                coordBuffer);
+
+        // Texture coordinates are texture_x, texture_y starting at position 3 into the buffer.
+        coordBuffer.position(3);
+        GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20,
+                coordBuffer);
+
+        GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
 
-                rect.left/viewWidth, (bot+rect.height())/viewHeight, 0,
-                BODY_TEX_COORDS[2], BODY_TEX_COORDS[3],
+        // Reset the position in the buffer for the next set of vertex and texture coordinates.
+        coordBuffer.position(0);
 
-                (rect.left+rect.width())/viewWidth, bot/viewHeight, 0,
-                BODY_TEX_COORDS[4], BODY_TEX_COORDS[5],
+        if (mVertical) {
+            // top endcap
+            float[] topCap = {
+                // x, y, z, texture_x, texture_y
+                rect.left/viewWidth, top/viewHeight, 0,
+                TOP_CAP_TEX_COORDS[0], TOP_CAP_TEX_COORDS[1],
 
-                (rect.left+rect.width())/viewWidth, (bot+rect.height())/viewHeight, 0,
-                BODY_TEX_COORDS[6], BODY_TEX_COORDS[7]
+                rect.left/viewWidth, (top+CAP_RADIUS)/viewHeight, 0,
+                TOP_CAP_TEX_COORDS[2], TOP_CAP_TEX_COORDS[3],
+
+                (rect.left+BAR_SIZE)/viewWidth, top/viewHeight, 0,
+                TOP_CAP_TEX_COORDS[4], TOP_CAP_TEX_COORDS[5],
+
+                (rect.left+BAR_SIZE)/viewWidth, (top+CAP_RADIUS)/viewHeight, 0,
+                TOP_CAP_TEX_COORDS[6], TOP_CAP_TEX_COORDS[7]
             };
 
-            // Get the buffer and handles from the context
-            FloatBuffer coordBuffer = context.coordBuffer;
-            int positionHandle = context.positionHandle;
-            int textureHandle = context.textureHandle;
-
-            // Make sure we are at position zero in the buffer in case other draw methods did not
-            // clean up after themselves
-            coordBuffer.position(0);
-            coordBuffer.put(bodyCoords);
+            coordBuffer.put(topCap);
 
             // Vertex coordinates are x,y,z starting at position 0 into the buffer.
             coordBuffer.position(0);
             GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20,
-                                         coordBuffer);
+                    coordBuffer);
 
-            // Texture coordinates are texture_x, texture_y starting at position 3 into the buffer.
+            // Texture coordinates are texture_x, texture_y starting at position 3 into the
+            // buffer.
             coordBuffer.position(3);
             GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20,
-                                         coordBuffer);
+                    coordBuffer);
+
+            GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
+
+            // Reset the position in the buffer for the next set of vertex and texture
+            // coordinates.
+            coordBuffer.position(0);
+
+            // bottom endcap
+            float[] botCap = {
+                // x, y, z, texture_x, texture_y
+                rect.left/viewWidth, (bot-CAP_RADIUS)/viewHeight, 0,
+                BOT_CAP_TEX_COORDS[0], BOT_CAP_TEX_COORDS[1],
+
+                rect.left/viewWidth, (bot)/viewHeight, 0,
+                BOT_CAP_TEX_COORDS[2], BOT_CAP_TEX_COORDS[3],
+
+                (rect.left+BAR_SIZE)/viewWidth, (bot-CAP_RADIUS)/viewHeight, 0,
+                BOT_CAP_TEX_COORDS[4], BOT_CAP_TEX_COORDS[5],
+
+                (rect.left+BAR_SIZE)/viewWidth, (bot)/viewHeight, 0,
+                BOT_CAP_TEX_COORDS[6], BOT_CAP_TEX_COORDS[7]
+            };
+
+            coordBuffer.put(botCap);
+
+            // Vertex coordinates are x,y,z starting at position 0 into the buffer.
+            coordBuffer.position(0);
+            GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20,
+                    coordBuffer);
+
+            // Texture coordinates are texture_x, texture_y starting at position 3 into the
+            // buffer.
+            coordBuffer.position(3);
+            GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20,
+                    coordBuffer);
 
             GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
 
-            // Reset the position in the buffer for the next set of vertex and texture coordinates.
+            // Reset the position in the buffer for the next set of vertex and texture
+            // coordinates.
+            coordBuffer.position(0);
+        } else {
+            // left endcap
+            float[] leftCap = {
+                // x, y, z, texture_x, texture_y
+                (rect.left-CAP_RADIUS)/viewWidth, bot/viewHeight, 0,
+                LEFT_CAP_TEX_COORDS[0], LEFT_CAP_TEX_COORDS[1],
+                (rect.left-CAP_RADIUS)/viewWidth, (bot+BAR_SIZE)/viewHeight, 0,
+                LEFT_CAP_TEX_COORDS[2], LEFT_CAP_TEX_COORDS[3],
+                (rect.left)/viewWidth, bot/viewHeight, 0, LEFT_CAP_TEX_COORDS[4],
+                LEFT_CAP_TEX_COORDS[5],
+                (rect.left)/viewWidth, (bot+BAR_SIZE)/viewHeight, 0,
+                LEFT_CAP_TEX_COORDS[6], LEFT_CAP_TEX_COORDS[7]
+            };
+
+            coordBuffer.put(leftCap);
+
+            // Vertex coordinates are x,y,z starting at position 0 into the buffer.
+            coordBuffer.position(0);
+            GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20,
+                    coordBuffer);
+
+            // Texture coordinates are texture_x, texture_y starting at position 3 into the
+            // buffer.
+            coordBuffer.position(3);
+            GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20,
+                    coordBuffer);
+
+            GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
+
+            // Reset the position in the buffer for the next set of vertex and texture
+            // coordinates.
             coordBuffer.position(0);
 
-            if (mVertical) {
-                // top endcap
-                float[] topCap = {
-                    // x, y, z, texture_x, texture_y
-                    rect.left/viewWidth, top/viewHeight, 0,
-                    TOP_CAP_TEX_COORDS[0], TOP_CAP_TEX_COORDS[1],
-
-                    rect.left/viewWidth, (top+CAP_RADIUS)/viewHeight, 0,
-                    TOP_CAP_TEX_COORDS[2], TOP_CAP_TEX_COORDS[3],
-
-                    (rect.left+BAR_SIZE)/viewWidth, top/viewHeight, 0,
-                    TOP_CAP_TEX_COORDS[4], TOP_CAP_TEX_COORDS[5],
-
-                    (rect.left+BAR_SIZE)/viewWidth, (top+CAP_RADIUS)/viewHeight, 0,
-                    TOP_CAP_TEX_COORDS[6], TOP_CAP_TEX_COORDS[7]
-                };
-
-                coordBuffer.put(topCap);
-
-                // Vertex coordinates are x,y,z starting at position 0 into the buffer.
-                coordBuffer.position(0);
-                GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20,
-                                             coordBuffer);
-
-                // Texture coordinates are texture_x, texture_y starting at position 3 into the
-                // buffer.
-                coordBuffer.position(3);
-                GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20,
-                                             coordBuffer);
-
-                GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
+            // right endcap
+            float[] rightCap = {
+                // x, y, z, texture_x, texture_y
+                rect.right/viewWidth, (bot)/viewHeight, 0,
+                RIGHT_CAP_TEX_COORDS[0], RIGHT_CAP_TEX_COORDS[1],
 
-                // Reset the position in the buffer for the next set of vertex and texture
-                // coordinates.
-                coordBuffer.position(0);
-
-                // bottom endcap
-                float[] botCap = {
-                    // x, y, z, texture_x, texture_y
-                    rect.left/viewWidth, (bot-CAP_RADIUS)/viewHeight, 0,
-                    BOT_CAP_TEX_COORDS[0], BOT_CAP_TEX_COORDS[1],
-
-                    rect.left/viewWidth, (bot)/viewHeight, 0,
-                    BOT_CAP_TEX_COORDS[2], BOT_CAP_TEX_COORDS[3],
-
-                    (rect.left+BAR_SIZE)/viewWidth, (bot-CAP_RADIUS)/viewHeight, 0,
-                    BOT_CAP_TEX_COORDS[4], BOT_CAP_TEX_COORDS[5],
+                rect.right/viewWidth, (bot+BAR_SIZE)/viewHeight, 0,
+                RIGHT_CAP_TEX_COORDS[2], RIGHT_CAP_TEX_COORDS[3],
 
-                    (rect.left+BAR_SIZE)/viewWidth, (bot)/viewHeight, 0,
-                    BOT_CAP_TEX_COORDS[6], BOT_CAP_TEX_COORDS[7]
-                };
-
-                coordBuffer.put(botCap);
-
-                // Vertex coordinates are x,y,z starting at position 0 into the buffer.
-                coordBuffer.position(0);
-                GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20,
-                                             coordBuffer);
-
-                // Texture coordinates are texture_x, texture_y starting at position 3 into the
-                // buffer.
-                coordBuffer.position(3);
-                GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20,
-                                             coordBuffer);
-
-                GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
+                (rect.right+CAP_RADIUS)/viewWidth, (bot)/viewHeight, 0,
+                RIGHT_CAP_TEX_COORDS[4], RIGHT_CAP_TEX_COORDS[5],
 
-                // Reset the position in the buffer for the next set of vertex and texture
-                // coordinates.
-                coordBuffer.position(0);
-            } else {
-                // left endcap
-                float[] leftCap = {
-                    // x, y, z, texture_x, texture_y
-                    (rect.left-CAP_RADIUS)/viewWidth, bot/viewHeight, 0,
-                        LEFT_CAP_TEX_COORDS[0], LEFT_CAP_TEX_COORDS[1],
-                    (rect.left-CAP_RADIUS)/viewWidth, (bot+BAR_SIZE)/viewHeight, 0,
-                        LEFT_CAP_TEX_COORDS[2], LEFT_CAP_TEX_COORDS[3],
-                    (rect.left)/viewWidth, bot/viewHeight, 0, LEFT_CAP_TEX_COORDS[4],
-                        LEFT_CAP_TEX_COORDS[5],
-                    (rect.left)/viewWidth, (bot+BAR_SIZE)/viewHeight, 0,
-                        LEFT_CAP_TEX_COORDS[6], LEFT_CAP_TEX_COORDS[7]
-                };
+                (rect.right+CAP_RADIUS)/viewWidth, (bot+BAR_SIZE)/viewHeight, 0,
+                RIGHT_CAP_TEX_COORDS[6], RIGHT_CAP_TEX_COORDS[7]
+            };
 
-                coordBuffer.put(leftCap);
-
-                // Vertex coordinates are x,y,z starting at position 0 into the buffer.
-                coordBuffer.position(0);
-                GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20,
-                                             coordBuffer);
-
-                // Texture coordinates are texture_x, texture_y starting at position 3 into the
-                // buffer.
-                coordBuffer.position(3);
-                GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20,
-                                             coordBuffer);
-
-                GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
+            coordBuffer.put(rightCap);
 
-                // Reset the position in the buffer for the next set of vertex and texture
-                // coordinates.
-                coordBuffer.position(0);
-
-                // right endcap
-                float[] rightCap = {
-                    // x, y, z, texture_x, texture_y
-                    rect.right/viewWidth, (bot)/viewHeight, 0,
-                    RIGHT_CAP_TEX_COORDS[0], RIGHT_CAP_TEX_COORDS[1],
-
-                    rect.right/viewWidth, (bot+BAR_SIZE)/viewHeight, 0,
-                    RIGHT_CAP_TEX_COORDS[2], RIGHT_CAP_TEX_COORDS[3],
-
-                    (rect.right+CAP_RADIUS)/viewWidth, (bot)/viewHeight, 0,
-                    RIGHT_CAP_TEX_COORDS[4], RIGHT_CAP_TEX_COORDS[5],
+            // Vertex coordinates are x,y,z starting at position 0 into the buffer.
+            coordBuffer.position(0);
+            GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20,
+                    coordBuffer);
 
-                    (rect.right+CAP_RADIUS)/viewWidth, (bot+BAR_SIZE)/viewHeight, 0,
-                    RIGHT_CAP_TEX_COORDS[6], RIGHT_CAP_TEX_COORDS[7]
-                };
-
-                coordBuffer.put(rightCap);
-
-                // Vertex coordinates are x,y,z starting at position 0 into the buffer.
-                coordBuffer.position(0);
-                GLES20.glVertexAttribPointer(positionHandle, 3, GLES20.GL_FLOAT, false, 20,
-                                             coordBuffer);
+            // Texture coordinates are texture_x, texture_y starting at position 3 into the
+            // buffer.
+            coordBuffer.position(3);
+            GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20,
+                    coordBuffer);
 
-                // Texture coordinates are texture_x, texture_y starting at position 3 into the
-                // buffer.
-                coordBuffer.position(3);
-                GLES20.glVertexAttribPointer(textureHandle, 2, GLES20.GL_FLOAT, false, 20,
-                                             coordBuffer);
-
-                GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
-            }
-        } finally {
-            GLES20.glDisable(GLES20.GL_BLEND);
+            GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
         }
     }
 
     private RectF getVerticalRect(RenderContext context) {
         RectF viewport = context.viewport;
         FloatSize pageSize = context.pageSize;
         float barStart = (viewport.height() * viewport.top / pageSize.height) + CAP_RADIUS;
         float barEnd = (viewport.height() * viewport.bottom / pageSize.height) - CAP_RADIUS;
--- a/mobile/android/base/gfx/SurfaceTextureLayer.java
+++ b/mobile/android/base/gfx/SurfaceTextureLayer.java
@@ -253,20 +253,16 @@ public class SurfaceTextureLayer extends
         // Draw the vertices as triangle strip
         GLES11.glDrawArrays(GL10.GL_TRIANGLE_STRIP, 0, vertices.length / 2);
 
         // Clean up
         GLES11.glDisableClientState(GL10.GL_VERTEX_ARRAY);
         GLES11.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
         GLES11.glDisable(LOCAL_GL_TEXTURE_EXTERNAL_OES);
         GLES11.glLoadIdentity();
-
-        if (mBlend) {
-            GLES11.glDisable(GL10.GL_BLEND);
-        }
     }
 
     public SurfaceTexture getSurfaceTexture() {
         return mSurfaceTexture;
     }
 
     public Surface getSurface() {
         return mSurface;