Bug 1172831 - Use static scrollbar resource reference. r=liuche
authorMichael Comella <michael.l.comella@gmail.com>
Tue, 23 Jun 2015 17:17:02 -0700
changeset 250905 661c1c9fac9d7f8c03bbb946ef4ef18af529e6fa
parent 250904 6d13ec6fac602c4510d18396e3bfb7750bfcb1b3
child 250906 135789f735cc650931f6a2ecbffb4bdbf6b25062
push id13805
push usermichael.l.comella@gmail.com
push dateWed, 01 Jul 2015 17:19:12 +0000
treeherderfx-team@2fc104758bb5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersliuche
bugs1172831
milestone42.0a1
Bug 1172831 - Use static scrollbar resource reference. r=liuche
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
@@ -12,16 +12,17 @@ import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.gfx.Layer.RenderContext;
 import org.mozilla.gecko.gfx.RenderTask;
 import org.mozilla.gecko.mozglue.DirectBufferAllocator;
 
 import android.content.Context;
 import android.content.SharedPreferences;
 import android.content.res.Resources;
 import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
 import android.graphics.Canvas;
 import android.graphics.Color;
 import android.graphics.Matrix;
 import android.graphics.PointF;
 import android.graphics.Rect;
 import android.graphics.RectF;
 import android.opengl.GLES20;
 import android.os.SystemClock;
@@ -142,17 +143,20 @@ public class LayerRenderer implements Ta
         "void main() {\n" +
         "    gl_FragColor = texture2D(sTexture, vTexCoord);\n" +
         "}\n";
 
     public LayerRenderer(LayerView view) {
         mView = view;
         setOverscrollColor(R.color.toolbar_grey);
 
-        Bitmap scrollbarImage = view.getScrollbarImage();
+        final BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
+        bitmapOptions.inScaled = false;
+        Bitmap scrollbarImage =
+                BitmapUtils.decodeResource(view.getContext(), R.drawable.scrollbar, bitmapOptions);
         IntSize size = new IntSize(scrollbarImage.getWidth(), scrollbarImage.getHeight());
         scrollbarImage = expandCanvasToPowerOfTwo(scrollbarImage, size);
 
         mTasks = new CopyOnWriteArrayList<RenderTask>();
         mLastFrameTime = System.nanoTime();
 
         mVertScrollLayer = new ScrollbarLayer(this, scrollbarImage, size, true);
         mHorizScrollLayer = new ScrollbarLayer(this, diagonalFlip(scrollbarImage), new IntSize(size.height, size.width), false);
--- a/mobile/android/base/gfx/LayerView.java
+++ b/mobile/android/base/gfx/LayerView.java
@@ -454,28 +454,16 @@ public class LayerView extends FrameLayo
     Listener getListener() {
         return mListener;
     }
 
     public GLController getGLController() {
         return mGLController;
     }
 
-    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 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.
      *
      * The first phase is the LayerView size change. mListener is notified so
      * that a synchronous draw can be performed (otherwise a blank frame will
      * appear).