Bug 840346 - Make the overscroll background area a solid color. r=cwiis
authorKartikaya Gupta <kgupta@mozilla.com>
Thu, 14 Feb 2013 10:00:23 -0800
changeset 131817 a119a9b9d39028f5acc3aaa0f66148fec9da2688
parent 131816 c302bf84325c8481971a77d9923d2cace7cf77ad
child 131818 8c0f88c09869875d52325cb86daf94bb6f0b9be6
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscwiis
bugs840346
milestone21.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 840346 - Make the overscroll background area a solid color. r=cwiis
mobile/android/base/gfx/LayerRenderer.java
mobile/android/base/gfx/LayerView.java
--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -1,16 +1,17 @@
 /* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
  * This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.gfx;
 
 import org.mozilla.gecko.GeckoAppShell;
+import org.mozilla.gecko.R;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.gfx.Layer.RenderContext;
 import org.mozilla.gecko.mozglue.DirectBufferAllocator;
 
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.graphics.Bitmap;
@@ -44,27 +45,27 @@ public class LayerRenderer implements Ta
      * frame.
      */
     private static final int MAX_FRAME_TIME = 16;   /* 1000 ms / 60 FPS */
 
     private static final int FRAME_RATE_METER_WIDTH = 128;
     private static final int FRAME_RATE_METER_HEIGHT = 32;
 
     private final LayerView mView;
-    private final SingleTileLayer mBackgroundLayer;
     private final NinePatchTileLayer mShadowLayer;
     private TextLayer mFrameRateLayer;
     private final ScrollbarLayer mHorizScrollLayer;
     private final ScrollbarLayer mVertScrollLayer;
     private final FadeRunnable mFadeRunnable;
     private ByteBuffer mCoordByteBuffer;
     private FloatBuffer mCoordBuffer;
     private RenderContext mLastPageContext;
     private int mMaxTextureSize;
     private int mBackgroundColor;
+    private int mOverscrollColor;
 
     private CopyOnWriteArrayList<Layer> mExtraLayers = new CopyOnWriteArrayList<Layer>();
 
     // Dropped frames display
     private int[] mFrameTimings;
     private int mCurrentFrame, mFrameTimingsSum, mDroppedFrames;
 
     // Render profiling output
@@ -123,19 +124,17 @@ public class LayerRenderer implements Ta
         "varying vec2 vTexCoord;\n" +
         "uniform sampler2D sTexture;\n" +
         "void main() {\n" +
         "    gl_FragColor = texture2D(sTexture, vTexCoord);\n" +
         "}\n";
 
     public LayerRenderer(LayerView view) {
         mView = view;
-
-        CairoImage backgroundImage = new BufferedCairoImage(view.getBackgroundPattern());
-        mBackgroundLayer = new SingleTileLayer(true, backgroundImage);
+        mOverscrollColor = view.getContext().getResources().getColor(R.color.background_normal);
 
         CairoImage shadowImage = new BufferedCairoImage(view.getShadowPattern());
         mShadowLayer = new NinePatchTileLayer(shadowImage);
 
         Bitmap scrollbarImage = view.getScrollbarImage();
         IntSize size = new IntSize(scrollbarImage.getWidth(), scrollbarImage.getHeight());
         scrollbarImage = expandCanvasToPowerOfTwo(scrollbarImage, size);
         mVertScrollLayer = new ScrollbarLayer(this, scrollbarImage, size, true);
@@ -171,17 +170,16 @@ public class LayerRenderer implements Ta
         Bitmap rotated = Bitmap.createBitmap(image, 0, 0, image.getWidth(), image.getHeight(), rotation, true);
         return rotated;
     }
 
     public void destroy() {
         DirectBufferAllocator.free(mCoordByteBuffer);
         mCoordByteBuffer = null;
         mCoordBuffer = null;
-        mBackgroundLayer.destroy();
         mShadowLayer.destroy();
         mHorizScrollLayer.destroy();
         mVertScrollLayer.destroy();
         if (mFrameRateLayer != null) {
             mFrameRateLayer.destroy();
         }
         Tabs.unregisterOnTabsChangedListener(this);
     }
@@ -465,17 +463,16 @@ public class LayerRenderer implements Ta
                 if (stillFading) {
                     mFadeRunnable.scheduleNextFadeFrame();
                 }
             }
             mLastPageContext = mPageContext;
 
             /* Update layers. */
             if (rootLayer != null) mUpdated &= rootLayer.update(mPageContext);  // called on compositor thread
-            mUpdated &= mBackgroundLayer.update(mScreenContext);    // called on compositor thread
             mUpdated &= mShadowLayer.update(mPageContext);  // called on compositor thread
             if (mFrameRateLayer != null) mUpdated &= mFrameRateLayer.update(mScreenContext); // called on compositor thread
             mUpdated &= mVertScrollLayer.update(mPageContext);  // called on compositor thread
             mUpdated &= mHorizScrollLayer.update(mPageContext); // called on compositor thread
 
             for (Layer layer : mExtraLayers)
                 mUpdated &= layer.update(mPageContext); // called on compositor thread
         }
@@ -514,38 +511,43 @@ public class LayerRenderer implements Ta
             }
             if (mask.bottom >= pageBottom - 2) {
                 mask.bottom = pageBottom + 1;
             }
 
             return mask;
         }
 
+        private void clear(int color) {
+            GLES20.glClearColor(((color >> 16) & 0xFF) / 255.0f,
+                                ((color >> 8) & 0xFF) / 255.0f,
+                                (color & 0xFF) / 255.0f,
+                                0.0f);
+            // The bits set here need to match up with those used
+            // in gfx/layers/opengl/LayerManagerOGL.cpp.
+            GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT |
+                           GLES20.GL_DEPTH_BUFFER_BIT);
+        }
+
         /** This function is invoked via JNI; be careful when modifying signature. */
         public void drawBackground() {
             GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
 
-            /* Update background color. */
+            // Draw the overscroll background area as a solid color
+            clear(mOverscrollColor);
+
+            // Update background color.
             mBackgroundColor = mView.getBackgroundColor();
 
-            /* Clear to the page background colour. The bits set here need to
-             * match up with those used in gfx/layers/opengl/LayerManagerOGL.cpp.
-             */
-            GLES20.glClearColor(((mBackgroundColor>>16)&0xFF) / 255.0f,
-                                ((mBackgroundColor>>8)&0xFF) / 255.0f,
-                                (mBackgroundColor&0xFF) / 255.0f,
-                                0.0f);
-            GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT |
-                           GLES20.GL_DEPTH_BUFFER_BIT);
+            // Clear the page area to the page background colour.
+            setScissorRect();
+            clear(mBackgroundColor);
+            GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
 
-            /* Draw the background. */
-            mBackgroundLayer.setMask(mPageRect);
-            mBackgroundLayer.draw(mScreenContext);
-
-            /* Draw the drop shadow, if we need to. */
+            // Draw the drop shadow, if we need to.
             if (!new RectF(mAbsolutePageRect).contains(mFrameMetrics.getViewport()))
                 mShadowLayer.draw(mPageContext);
         }
 
         // Draws the layer the client added to us.
         void drawRootLayer() {
             Layer rootLayer = mView.getLayerClient().getRoot();
             if (rootLayer == null) {
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -340,20 +340,16 @@ public class LayerView extends FrameLayo
     }
 
     private Bitmap getDrawable(int resId) {
         BitmapFactory.Options options = new BitmapFactory.Options();
         options.inScaled = false;
         return BitmapFactory.decodeResource(getContext().getResources(), resId, options);
     }
 
-    Bitmap getBackgroundPattern() {
-        return getDrawable(R.drawable.abouthome_bg);
-    }
-
     Bitmap getShadowPattern() {
         return getDrawable(R.drawable.shadow);
     }
 
     Bitmap getScrollbarImage() {
         return getDrawable(R.drawable.scrollbar);
     }