Bug 952878 - Eliminate shadow layer. r=kats
authorRichard Newman <rnewman@mozilla.com>
Thu, 26 Dec 2013 00:39:23 -0800
changeset 161802 b0b40893a1b4dff26a6781363589669b890e8288
parent 161789 cd3e9359fd64de26b86c256c5f35f8dee61bda19
child 161803 5350c1ac435d63e6a4a2c30acb2e5333b7c58bf7
push id37991
push userphilringnalda@gmail.com
push dateFri, 27 Dec 2013 03:32:46 +0000
treeherdermozilla-inbound@451f47a70238 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskats
bugs952878
milestone29.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 952878 - Eliminate shadow layer. r=kats
mobile/android/base/gfx/LayerRenderer.java
mobile/android/base/gfx/LayerView.java
mobile/android/base/resources/drawable-mdpi/shadow.png
--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -50,27 +50,25 @@ public class LayerRenderer implements Ta
 
     private static final int FRAME_RATE_METER_WIDTH = 128;
     private static final int FRAME_RATE_METER_HEIGHT = 32;
 
     private static final long NANOS_PER_MS = 1000000;
     private static final int NANOS_PER_SECOND = 1000000000;
 
     private final LayerView mView;
-    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 long mLastFrameTime;
     private final CopyOnWriteArrayList<RenderTask> mTasks;
 
     private CopyOnWriteArrayList<Layer> mExtraLayers = new CopyOnWriteArrayList<Layer>();
 
     // Dropped frames display
     private int[] mFrameTimings;
@@ -131,20 +129,16 @@ 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;
-        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);
 
         mTasks = new CopyOnWriteArrayList<RenderTask>();
         mLastFrameTime = System.nanoTime();
 
@@ -181,17 +175,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;
-        mShadowLayer.destroy();
         mHorizScrollLayer.destroy();
         mVertScrollLayer.destroy();
         if (mFrameRateLayer != null) {
             mFrameRateLayer.destroy();
         }
         Tabs.unregisterOnTabsChangedListener(this);
     }
 
@@ -513,24 +506,32 @@ public class LayerRenderer implements Ta
                 boolean stillFading = mVertScrollLayer.fade() | mHorizScrollLayer.fade();
                 if (stillFading) {
                     mFadeRunnable.scheduleNextFadeFrame();
                 }
             }
             mLastPageContext = mPageContext;
 
             /* Update layers. */
-            if (rootLayer != null) mUpdated &= rootLayer.update(mPageContext);  // called on compositor thread
-            mUpdated &= mShadowLayer.update(mPageContext);  // called on compositor thread
-            if (mFrameRateLayer != null) mUpdated &= mFrameRateLayer.update(mScreenContext); // called on compositor thread
+            if (rootLayer != null) {
+                // Called on compositor thread.
+                mUpdated &= rootLayer.update(mPageContext);
+            }
+
+            if (mFrameRateLayer != null) {
+                // Called on compositor thread.
+                mUpdated &= mFrameRateLayer.update(mScreenContext);
+            }
+
             mUpdated &= mVertScrollLayer.update(mPageContext);  // called on compositor thread
             mUpdated &= mHorizScrollLayer.update(mPageContext); // called on compositor thread
 
-            for (Layer layer : mExtraLayers)
+            for (Layer layer : mExtraLayers) {
                 mUpdated &= layer.update(mPageContext); // called on compositor thread
+            }
         }
 
         /** Retrieves the bounds for the layer, rounded in such a way that it
          * can be used as a mask for something that will render underneath it.
          * This will round the bounds inwards, but stretch the mask towards any
          * near page edge, where near is considered to be 'within 2 pixels'.
          * Returns null if the given layer is null.
          */
@@ -581,32 +582,23 @@ public class LayerRenderer implements Ta
         /** This function is invoked via JNI; be careful when modifying signature. */
         @JNITarget
         public void drawBackground() {
             // Any GL state which is changed here must be restored in
             // CompositorOGL::RestoreState
 
             GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
 
-            // Draw the overscroll background area as a solid color
-            clear(mOverscrollColor);
-
             // Update background color.
             mBackgroundColor = mView.getBackgroundColor();
 
             // Clear the page area to the page background colour.
             setScissorRect();
             clear(mBackgroundColor);
             GLES20.glDisable(GLES20.GL_SCISSOR_TEST);
-
-            // Draw the drop shadow, if we need to.
-            RectF offsetAbsPageRect = new RectF(mAbsolutePageRect);
-            offsetAbsPageRect.offset(mRenderOffset.x, mRenderOffset.y);
-            if (!offsetAbsPageRect.contains(mFrameMetrics.getViewport()))
-                mShadowLayer.draw(mPageContext);
         }
 
         // Draws the layer the client added to us.
         void drawRootLayer() {
             Layer rootLayer = mView.getLayerClient().getRoot();
             if (rootLayer == null) {
                 return;
             }
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -495,20 +495,16 @@ public class LayerView extends FrameLayo
     private Bitmap getDrawable(String name) {
         BitmapFactory.Options options = new BitmapFactory.Options();
         options.inScaled = false;
         Context context = getContext();
         int resId = context.getResources().getIdentifier(name, "drawable", context.getPackageName());
         return BitmapUtils.decodeResource(context, resId, options);
     }
 
-    Bitmap getShadowPattern() {
-        return getDrawable("shadow");
-    }
-
     Bitmap getScrollbarImage() {
         return getDrawable("scrollbar");
     }
 
     /* When using a SurfaceView (mSurfaceView != null), resizing happens in two
      * phases. First, the LayerView changes size, then, often some frames later,
      * the SurfaceView changes size. Because of this, we need to split the
      * resize into two phases to avoid jittering.
deleted file mode 100644
index 3ce69155c6b5181f33caf4be2083a87b74554135..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
GIT binary patch
literal 0
Hc$@<O00001