--- a/mobile/android/base/gfx/LayerRenderer.java
+++ b/mobile/android/base/gfx/LayerRenderer.java
@@ -51,17 +51,16 @@ 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 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;
@@ -180,19 +179,16 @@ public class LayerRenderer implements Ta
}
public void destroy() {
DirectBufferAllocator.free(mCoordByteBuffer);
mCoordByteBuffer = null;
mCoordBuffer = null;
mHorizScrollLayer.destroy();
mVertScrollLayer.destroy();
- if (mFrameRateLayer != null) {
- mFrameRateLayer.destroy();
- }
Tabs.unregisterOnTabsChangedListener(this);
}
void onSurfaceCreated(EGLConfig config) {
checkMonitoringEnabled();
createDefaultProgram();
activateDefaultProgram();
}
@@ -354,53 +350,20 @@ public class LayerRenderer implements Ta
mFrameTimingsSum += frameElapsedTime;
mDroppedFrames -= (mFrameTimings[mCurrentFrame] + 1) / MAX_FRAME_TIME;
mDroppedFrames += (frameElapsedTime + 1) / MAX_FRAME_TIME;
mFrameTimings[mCurrentFrame] = frameElapsedTime;
mCurrentFrame = (mCurrentFrame + 1) % mFrameTimings.length;
int averageTime = mFrameTimingsSum / mFrameTimings.length;
- mFrameRateLayer.beginTransaction(); // called on compositor thread
- try {
- mFrameRateLayer.setText(averageTime + " ms/" + mDroppedFrames);
- } finally {
- mFrameRateLayer.endTransaction();
- }
- }
-
- /* Given the new dimensions for the surface, moves the frame rate layer appropriately. */
- private void moveFrameRateLayer(int width, int height) {
- mFrameRateLayer.beginTransaction(); // called on compositor thread
- try {
- Rect position = new Rect(width - FRAME_RATE_METER_WIDTH - 8,
- height - FRAME_RATE_METER_HEIGHT + 8,
- width - 8,
- height + 8);
- mFrameRateLayer.setPosition(position);
- } finally {
- mFrameRateLayer.endTransaction();
- }
}
void checkMonitoringEnabled() {
- /* Do this I/O off the main thread to minimize its impact on startup time. */
- new Thread(new Runnable() {
- @Override
- public void run() {
- Context context = mView.getContext();
- SharedPreferences preferences = context.getSharedPreferences("GeckoApp", 0);
- if (preferences.getBoolean("showFrameRate", false)) {
- IntSize frameRateLayerSize = new IntSize(FRAME_RATE_METER_WIDTH, FRAME_RATE_METER_HEIGHT);
- mFrameRateLayer = TextLayer.create(frameRateLayerSize, "-- ms/--");
- moveFrameRateLayer(mView.getWidth(), mView.getHeight());
- }
- mProfileRender = Log.isLoggable(PROFTAG, Log.DEBUG);
- }
- }).start();
+ mProfileRender = Log.isLoggable(PROFTAG, Log.DEBUG);
}
/*
* create a vertex shader type (GLES20.GL_VERTEX_SHADER)
* or a fragment shader type (GLES20.GL_FRAGMENT_SHADER)
*/
public static int loadShader(int type, String shaderCode) {
int shader = GLES20.glCreateShader(type);
@@ -534,21 +497,16 @@ public class LayerRenderer implements Ta
mLastPageContext = mPageContext;
/* Update layers. */
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) {
mUpdated &= layer.update(mPageContext); // called on compositor thread
}
}
@@ -621,24 +579,16 @@ public class LayerRenderer implements Ta
if (mFrameStartTime - mProfileOutputTime > NANOS_PER_SECOND) {
mProfileOutputTime = mFrameStartTime;
printCheckerboardStats();
}
}
runRenderTasks(mTasks, true, mFrameStartTime);
- /* Draw the FPS. */
- if (mFrameRateLayer != null) {
- updateDroppedFrames(mFrameStartTime);
-
- GLES20.glEnable(GLES20.GL_BLEND);
- GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
- mFrameRateLayer.draw(mScreenContext);
- }
}
/** This function is invoked via JNI; be careful when modifying signature. */
@JNITarget
public void endDrawing() {
// If a layer update requires further work, schedule another redraw
if (!mUpdated)
mView.requestRender();
deleted file mode 100644
--- a/mobile/android/base/gfx/NinePatchTileLayer.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/* -*- 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 android.graphics.RectF;
-import android.opengl.GLES20;
-
-import java.nio.FloatBuffer;
-
-/**
- * Encapsulates the logic needed to draw a nine-patch bitmap using OpenGL ES.
- *
- * For more information on nine-patch bitmaps, see the following document:
- * http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch
- */
-public class NinePatchTileLayer extends TileLayer {
- private static final int PATCH_SIZE = 16;
- private static final int TEXTURE_SIZE = 64;
-
- public NinePatchTileLayer(CairoImage image) {
- super(image, TileLayer.PaintMode.NORMAL);
- }
-
- @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);
-
- GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
- 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 |
- * +---+---+---+
- * | 3 | | 4 |
- * +---+---+---+
- * | 5 | 6 | 7 |
- * +---+---+---+
- */
-
- // page is the rect of the "missing" center spot in the picture above
- RectF page = context.pageRect;
-
- drawPatch(context, 0, PATCH_SIZE * 3, /* 0 */
- page.left - PATCH_SIZE, page.top - PATCH_SIZE, PATCH_SIZE, PATCH_SIZE);
- drawPatch(context, PATCH_SIZE, PATCH_SIZE * 3, /* 1 */
- page.left, page.top - PATCH_SIZE, page.width(), PATCH_SIZE);
- drawPatch(context, PATCH_SIZE * 2, PATCH_SIZE * 3, /* 2 */
- page.right, page.top - PATCH_SIZE, PATCH_SIZE, PATCH_SIZE);
- drawPatch(context, 0, PATCH_SIZE * 2, /* 3 */
- page.left - PATCH_SIZE, page.top, PATCH_SIZE, page.height());
- drawPatch(context, PATCH_SIZE * 2, PATCH_SIZE * 2, /* 4 */
- page.right, page.top, PATCH_SIZE, page.height());
- drawPatch(context, 0, PATCH_SIZE, /* 5 */
- page.left - PATCH_SIZE, page.bottom, PATCH_SIZE, PATCH_SIZE);
- drawPatch(context, PATCH_SIZE, PATCH_SIZE, /* 6 */
- page.left, page.bottom, page.width(), PATCH_SIZE);
- drawPatch(context, PATCH_SIZE * 2, PATCH_SIZE, /* 7 */
- page.right, page.bottom, PATCH_SIZE, PATCH_SIZE);
- }
-
- private void drawPatch(RenderContext context, int textureX, int textureY,
- float tileX, float tileY, float tileWidth, float tileHeight) {
- RectF viewport = context.viewport;
- float viewportHeight = viewport.height();
- float drawX = tileX - viewport.left - context.offset.x;
- float drawY = viewportHeight - (tileY + tileHeight - viewport.top) - context.offset.y;
-
- float[] coords = {
- //x, y, z, texture_x, texture_y
- drawX/viewport.width(), drawY/viewport.height(), 0,
- textureX/(float)TEXTURE_SIZE, textureY/(float)TEXTURE_SIZE,
-
- drawX/viewport.width(), (drawY+tileHeight)/viewport.height(), 0,
- textureX/(float)TEXTURE_SIZE, (textureY+PATCH_SIZE)/(float)TEXTURE_SIZE,
-
- (drawX+tileWidth)/viewport.width(), drawY/viewport.height(), 0,
- (textureX+PATCH_SIZE)/(float)TEXTURE_SIZE, textureY/(float)TEXTURE_SIZE,
-
- (drawX+tileWidth)/viewport.width(), (drawY+tileHeight)/viewport.height(), 0,
- (textureX+PATCH_SIZE)/(float)TEXTURE_SIZE, (textureY+PATCH_SIZE)/(float)TEXTURE_SIZE
-
- };
-
- // 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(coords);
-
- // Unbind any the current array buffer so we can use client side buffers
- GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
-
- // 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.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
- GLES20.GL_CLAMP_TO_EDGE);
- GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
- GLES20.GL_CLAMP_TO_EDGE);
-
- // Use bilinear filtering for both magnification and minimization of the texture. This
- // applies only to the shadow layer so we do not incur a high overhead.
- GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
- GLES20.GL_LINEAR);
- GLES20.glTexParameteri(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
- GLES20.GL_LINEAR);
-
- GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
- }
-}
deleted file mode 100644
--- a/mobile/android/base/gfx/SingleTileLayer.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/* -*- 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 android.graphics.Rect;
-import android.graphics.RectF;
-import android.graphics.Region;
-import android.graphics.RegionIterator;
-import android.opengl.GLES20;
-
-import java.nio.FloatBuffer;
-
-/**
- * Encapsulates the logic needed to draw a single textured tile.
- *
- * TODO: Repeating textures really should be their own type of layer.
- */
-public class SingleTileLayer extends TileLayer {
- private static final String LOGTAG = "GeckoSingleTileLayer";
-
- private Rect mMask;
-
- // To avoid excessive GC, declare some objects here that would otherwise
- // be created and destroyed frequently during draw().
- private final RectF mBounds;
- private final RectF mTextureBounds;
- private final RectF mViewport;
- private final Rect mIntBounds;
- private final Rect mSubRect;
- private final RectF mSubRectF;
- private final Region mMaskedBounds;
- private final Rect mCropRect;
- private final RectF mObjRectF;
- private final float[] mCoords;
-
- public SingleTileLayer(CairoImage image) {
- this(false, image);
- }
-
- public SingleTileLayer(boolean repeat, CairoImage image) {
- this(image, repeat ? TileLayer.PaintMode.REPEAT : TileLayer.PaintMode.NORMAL);
- }
-
- public SingleTileLayer(CairoImage image, TileLayer.PaintMode paintMode) {
- super(image, paintMode);
-
- mBounds = new RectF();
- mTextureBounds = new RectF();
- mViewport = new RectF();
- mIntBounds = new Rect();
- mSubRect = new Rect();
- mSubRectF = new RectF();
- mMaskedBounds = new Region();
- mCropRect = new Rect();
- mObjRectF = new RectF();
- mCoords = new float[20];
- }
-
- /**
- * Set an area to mask out when rendering.
- */
- public void setMask(Rect aMaskRect) {
- mMask = aMaskRect;
- }
-
- @Override
- public void draw(RenderContext context) {
- // mTextureIDs may be null here during startup if Layer.java's draw method
- // failed to acquire the transaction lock and call performUpdates.
- if (!initialized())
- return;
-
- mViewport.set(context.viewport);
-
- if (repeats()) {
- // If we're repeating, we want to adjust the texture bounds so that
- // the texture repeats the correct number of times when drawn at
- // the size of the viewport.
- mBounds.set(getBounds(context));
- mTextureBounds.set(0.0f, 0.0f, mBounds.width(), mBounds.height());
- mBounds.set(0.0f, 0.0f, mViewport.width(), mViewport.height());
- } else if (stretches()) {
- // If we're stretching, we just want the bounds and texture bounds
- // to fit to the page.
- mBounds.set(context.pageRect);
- mTextureBounds.set(mBounds);
- } else {
- mBounds.set(getBounds(context));
- mTextureBounds.set(mBounds);
- }
-
- mBounds.roundOut(mIntBounds);
- mMaskedBounds.set(mIntBounds);
- if (mMask != null) {
- mMaskedBounds.op(mMask, Region.Op.DIFFERENCE);
- if (mMaskedBounds.isEmpty())
- return;
- }
-
- // XXX Possible optimisation here, form this array so we can draw it in
- // a single call.
- RegionIterator i = new RegionIterator(mMaskedBounds);
- while (i.next(mSubRect)) {
- // Compensate for rounding errors at the edge of the tile caused by
- // the roundOut above
- mSubRectF.set(Math.max(mBounds.left, (float)mSubRect.left),
- Math.max(mBounds.top, (float)mSubRect.top),
- Math.min(mBounds.right, (float)mSubRect.right),
- Math.min(mBounds.bottom, (float)mSubRect.bottom));
-
- // This is the left/top/right/bottom of the rect, relative to the
- // bottom-left of the layer, to use for texture coordinates.
- mCropRect.set(Math.round(mSubRectF.left - mBounds.left),
- Math.round(mBounds.bottom - mSubRectF.top),
- Math.round(mSubRectF.right - mBounds.left),
- Math.round(mBounds.bottom - mSubRectF.bottom));
-
- mObjRectF.set(mSubRectF.left - mViewport.left,
- mViewport.bottom - mSubRectF.bottom,
- mSubRectF.right - mViewport.left,
- mViewport.bottom - mSubRectF.top);
-
- fillRectCoordBuffer(mCoords, mObjRectF, mViewport.width(), mViewport.height(),
- mCropRect, mTextureBounds.width(), mTextureBounds.height());
-
- FloatBuffer coordBuffer = context.coordBuffer;
- int positionHandle = context.positionHandle;
- int textureHandle = context.textureHandle;
-
- GLES20.glActiveTexture(GLES20.GL_TEXTURE0);
- GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, getTextureID());
-
- // Make sure we are at position zero in the buffer
- coordBuffer.position(0);
- coordBuffer.put(mCoords);
-
- // Unbind any the current array buffer so we can use client side buffers
- GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
-
- // 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);
- }
- }
-}
deleted file mode 100644
--- a/mobile/android/base/gfx/TextLayer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- 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.mozglue.DirectBufferAllocator;
-
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Typeface;
-
-import java.nio.ByteBuffer;
-
-/**
- * Draws text on a layer. This is used for the frame rate meter.
- */
-public class TextLayer extends SingleTileLayer {
- private final ByteBuffer mBuffer; // this buffer is owned by the BufferedCairoImage
- private final IntSize mSize;
-
- /*
- * This awkward pattern is necessary due to Java's restrictions on when one can call superclass
- * constructors.
- */
- private TextLayer(ByteBuffer buffer, BufferedCairoImage image, IntSize size, String text) {
- super(false, image);
- mBuffer = buffer;
- mSize = size;
- renderText(text);
- }
-
- public static TextLayer create(IntSize size, String text) {
- ByteBuffer buffer = DirectBufferAllocator.allocate(size.width * size.height * 4);
- BufferedCairoImage image = new BufferedCairoImage(buffer, size.width, size.height,
- CairoImage.FORMAT_ARGB32);
- return new TextLayer(buffer, image, size, text);
- }
-
- public void setText(String text) {
- renderText(text);
- invalidate();
- }
-
- private void renderText(String text) {
- Bitmap bitmap = Bitmap.createBitmap(mSize.width, mSize.height, Bitmap.Config.ARGB_8888);
- Canvas canvas = new Canvas(bitmap);
-
- Paint textPaint = new Paint();
- textPaint.setAntiAlias(true);
- textPaint.setColor(Color.WHITE);
- textPaint.setFakeBoldText(true);
- textPaint.setTextSize(18.0f);
- textPaint.setTypeface(Typeface.DEFAULT_BOLD);
- float width = textPaint.measureText(text) + 18.0f;
-
- Paint backgroundPaint = new Paint();
- backgroundPaint.setColor(Color.argb(127, 0, 0, 0));
- canvas.drawRect(0.0f, 0.0f, width, 18.0f + 6.0f, backgroundPaint);
-
- canvas.drawText(text, 6.0f, 18.0f, textPaint);
-
- bitmap.copyPixelsToBuffer(mBuffer.asIntBuffer());
- }
-}
-
--- a/mobile/android/base/moz.build
+++ b/mobile/android/base/moz.build
@@ -222,32 +222,29 @@ gbjar.sources += [
'gfx/InputConnectionHandler.java',
'gfx/IntSize.java',
'gfx/JavaPanZoomController.java',
'gfx/Layer.java',
'gfx/LayerMarginsAnimator.java',
'gfx/LayerRenderer.java',
'gfx/LayerView.java',
'gfx/NativePanZoomController.java',
- 'gfx/NinePatchTileLayer.java',
'gfx/Overscroll.java',
'gfx/OverscrollEdgeEffect.java',
'gfx/PanningPerfAPI.java',
'gfx/PanZoomController.java',
'gfx/PanZoomTarget.java',
'gfx/PluginLayer.java',
'gfx/PointUtils.java',
'gfx/ProgressiveUpdateData.java',
'gfx/RectUtils.java',
'gfx/RenderTask.java',
'gfx/ScrollbarLayer.java',
'gfx/SimpleScaleGestureDetector.java',
- 'gfx/SingleTileLayer.java',
'gfx/SubdocumentScrollHelper.java',
- 'gfx/TextLayer.java',
'gfx/TextureGenerator.java',
'gfx/TextureReaper.java',
'gfx/TileLayer.java',
'gfx/TouchEventHandler.java',
'gfx/ViewTransform.java',
'gfx/VirtualLayer.java',
'GlobalHistory.java',
'GuestSession.java',