diff options
author | Bjorn Bringert <bringert@android.com> | 2010-10-13 17:24:27 +0100 |
---|---|---|
committer | Bjorn Bringert <bringert@android.com> | 2010-10-14 09:39:25 +0100 |
commit | c9332fa3e9e9e0897482a9c26cf9d997e57376b7 (patch) | |
tree | fb17ed06dd901359b93bbd5853bde34761ed0aeb | |
parent | d3a8f33be11aac17bda8c7c0c7cb968a542a0396 (diff) | |
download | frameworks_base-c9332fa3e9e9e0897482a9c26cf9d997e57376b7.zip frameworks_base-c9332fa3e9e9e0897482a9c26cf9d997e57376b7.tar.gz frameworks_base-c9332fa3e9e9e0897482a9c26cf9d997e57376b7.tar.bz2 |
Delete unused WebView drag tracking code
This also removes android.graphics.utils.BoundaryPatch
which was only used by the Browser for the unused drag
tracking (and by a demo app that I'm also removing).
Change-Id: I48253ae005ab11cb4c70d132bc1ea4f2692e2bd2
-rw-r--r-- | core/java/android/webkit/DebugFlags.java | 2 | ||||
-rw-r--r-- | core/java/android/webkit/WebView.java | 232 | ||||
-rw-r--r-- | core/jni/android/graphics/Canvas.cpp | 38 | ||||
-rw-r--r-- | graphics/java/android/graphics/utils/BoundaryPatch.java | 173 | ||||
-rw-r--r-- | preloaded-classes | 1 |
5 files changed, 1 insertions, 445 deletions
diff --git a/core/java/android/webkit/DebugFlags.java b/core/java/android/webkit/DebugFlags.java index dca52f6..8e25395 100644 --- a/core/java/android/webkit/DebugFlags.java +++ b/core/java/android/webkit/DebugFlags.java @@ -32,8 +32,6 @@ class DebugFlags { public static final boolean CALLBACK_PROXY = false; public static final boolean COOKIE_MANAGER = false; public static final boolean COOKIE_SYNC_MANAGER = false; - public static final boolean DRAG_TRACKER = false; - public static final String DRAG_TRACKER_LOGTAG = "skia"; public static final boolean FRAME_LOADER = false; public static final boolean J_WEB_CORE_JAVA_BRIDGE = false;// HIGHLY VERBOSE public static final boolean LOAD_LISTENER = false; diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index ea29d5e..a7e51a4 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -33,7 +33,6 @@ import android.graphics.Canvas; import android.graphics.Color; import android.graphics.CornerPathEffect; import android.graphics.DrawFilter; -import android.graphics.Interpolator; import android.graphics.Paint; import android.graphics.PaintFlagsDrawFilter; import android.graphics.Picture; @@ -48,7 +47,6 @@ import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Message; -import android.os.SystemClock; import android.provider.Settings; import android.speech.tts.TextToSpeech; import android.text.Selection; @@ -93,8 +91,6 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStreamReader; import java.net.URLDecoder; import java.util.ArrayList; import java.util.HashMap; @@ -309,8 +305,6 @@ public class WebView extends AbsoluteLayout implements ViewTreeObserver.OnGlobalFocusChangeListener, ViewGroup.OnHierarchyChangeListener { - // enable debug output for drag trackers - private static final boolean DEBUG_DRAG_TRACKER = false; // if AUTO_REDRAW_HACK is true, then the CALL key will toggle redrawing // the screen all-the-time. Good for profiling our drawing code static private final boolean AUTO_REDRAW_HACK = false; @@ -3464,17 +3458,7 @@ public class WebView extends AbsoluteLayout if (mTitleBar != null) { canvas.translate(0, (int) mTitleBar.getHeight()); } - if (mDragTrackerHandler == null) { - drawContent(canvas); - } else { - if (!mDragTrackerHandler.draw(canvas)) { - // sometimes the tracker doesn't draw, even though its active - drawContent(canvas); - } - if (mDragTrackerHandler.isFinished()) { - mDragTrackerHandler = null; - } - } + drawContent(canvas); canvas.restoreToCount(saveCount); // Now draw the shadow. @@ -4724,207 +4708,6 @@ public class WebView extends AbsoluteLayout private static final float MAX_SLOPE_FOR_DIAG = 1.5f; private static final int MIN_BREAK_SNAP_CROSS_DISTANCE = 80; - private static int sign(float x) { - return x > 0 ? 1 : (x < 0 ? -1 : 0); - } - - // if the page can scroll <= this value, we won't allow the drag tracker - // to have any effect. - private static final int MIN_SCROLL_AMOUNT_TO_DISABLE_DRAG_TRACKER = 4; - - private class DragTrackerHandler { - private final DragTracker mProxy; - private final float mStartY, mStartX; - private final float mMinDY, mMinDX; - private final float mMaxDY, mMaxDX; - private float mCurrStretchY, mCurrStretchX; - private int mSX, mSY; - private Interpolator mInterp; - private float[] mXY = new float[2]; - - // inner (non-state) classes can't have enums :( - private static final int DRAGGING_STATE = 0; - private static final int ANIMATING_STATE = 1; - private static final int FINISHED_STATE = 2; - private int mState; - - public DragTrackerHandler(float x, float y, DragTracker proxy) { - mProxy = proxy; - - int docBottom = computeVerticalScrollRange() + getTitleHeight(); - int viewTop = getScrollY(); - int viewBottom = viewTop + getHeight(); - - mStartY = y; - mMinDY = -viewTop; - mMaxDY = docBottom - viewBottom; - - if (DebugFlags.DRAG_TRACKER || DEBUG_DRAG_TRACKER) { - Log.d(DebugFlags.DRAG_TRACKER_LOGTAG, " dragtracker y= " + y + - " up/down= " + mMinDY + " " + mMaxDY); - } - - int docRight = computeHorizontalScrollRange(); - int viewLeft = getScrollX(); - int viewRight = viewLeft + getWidth(); - mStartX = x; - mMinDX = -viewLeft; - mMaxDX = docRight - viewRight; - - mState = DRAGGING_STATE; - mProxy.onStartDrag(x, y); - - // ensure we buildBitmap at least once - mSX = -99999; - } - - private float computeStretch(float delta, float min, float max) { - float stretch = 0; - if (max - min > MIN_SCROLL_AMOUNT_TO_DISABLE_DRAG_TRACKER) { - if (delta < min) { - stretch = delta - min; - } else if (delta > max) { - stretch = delta - max; - } - } - return stretch; - } - - public void dragTo(float x, float y) { - float sy = computeStretch(mStartY - y, mMinDY, mMaxDY); - float sx = computeStretch(mStartX - x, mMinDX, mMaxDX); - - if ((mSnapScrollMode & SNAP_X) != 0) { - sy = 0; - } else if ((mSnapScrollMode & SNAP_Y) != 0) { - sx = 0; - } - - if (mCurrStretchX != sx || mCurrStretchY != sy) { - mCurrStretchX = sx; - mCurrStretchY = sy; - if (DebugFlags.DRAG_TRACKER || DEBUG_DRAG_TRACKER) { - Log.d(DebugFlags.DRAG_TRACKER_LOGTAG, "---- stretch " + sx + - " " + sy); - } - if (mProxy.onStretchChange(sx, sy)) { - invalidate(); - } - } - } - - public void stopDrag() { - final int DURATION = 200; - int now = (int)SystemClock.uptimeMillis(); - mInterp = new Interpolator(2); - mXY[0] = mCurrStretchX; - mXY[1] = mCurrStretchY; - // float[] blend = new float[] { 0.5f, 0, 0.75f, 1 }; - float[] blend = new float[] { 0, 0.5f, 0.75f, 1 }; - mInterp.setKeyFrame(0, now, mXY, blend); - float[] zerozero = new float[] { 0, 0 }; - mInterp.setKeyFrame(1, now + DURATION, zerozero, null); - mState = ANIMATING_STATE; - - if (DebugFlags.DRAG_TRACKER || DEBUG_DRAG_TRACKER) { - Log.d(DebugFlags.DRAG_TRACKER_LOGTAG, "----- stopDrag, starting animation"); - } - } - - // Call this after each draw. If it ruturns null, the tracker is done - public boolean isFinished() { - return mState == FINISHED_STATE; - } - - private int hiddenHeightOfTitleBar() { - return getTitleHeight() - getVisibleTitleHeight(); - } - - // need a way to know if 565 or 8888 is the right config for - // capturing the display and giving it to the drag proxy - private Bitmap.Config offscreenBitmapConfig() { - // hard code 565 for now - return Bitmap.Config.RGB_565; - } - - /* If the tracker draws, then this returns true, otherwise it will - return false, and draw nothing. - */ - public boolean draw(Canvas canvas) { - if (mCurrStretchX != 0 || mCurrStretchY != 0) { - int sx = getScrollX(); - int sy = getScrollY() - hiddenHeightOfTitleBar(); - if (mSX != sx || mSY != sy) { - buildBitmap(sx, sy); - mSX = sx; - mSY = sy; - } - - if (mState == ANIMATING_STATE) { - Interpolator.Result result = mInterp.timeToValues(mXY); - if (result == Interpolator.Result.FREEZE_END) { - mState = FINISHED_STATE; - return false; - } else { - mProxy.onStretchChange(mXY[0], mXY[1]); - invalidate(); - // fall through to the draw - } - } - int count = canvas.save(Canvas.MATRIX_SAVE_FLAG); - canvas.translate(sx, sy); - mProxy.onDraw(canvas); - canvas.restoreToCount(count); - return true; - } - if (DebugFlags.DRAG_TRACKER || DEBUG_DRAG_TRACKER) { - Log.d(DebugFlags.DRAG_TRACKER_LOGTAG, " -- draw false " + - mCurrStretchX + " " + mCurrStretchY); - } - return false; - } - - private void buildBitmap(int sx, int sy) { - int w = getWidth(); - int h = getViewHeight(); - Bitmap bm = Bitmap.createBitmap(w, h, offscreenBitmapConfig()); - Canvas canvas = new Canvas(bm); - canvas.translate(-sx, -sy); - drawContent(canvas); - - if (DebugFlags.DRAG_TRACKER || DEBUG_DRAG_TRACKER) { - Log.d(DebugFlags.DRAG_TRACKER_LOGTAG, "--- buildBitmap " + sx + - " " + sy + " " + w + " " + h); - } - mProxy.onBitmapChange(bm); - } - } - - /** @hide */ - public static class DragTracker { - public void onStartDrag(float x, float y) {} - public boolean onStretchChange(float sx, float sy) { - // return true to have us inval the view - return false; - } - public void onStopDrag() {} - public void onBitmapChange(Bitmap bm) {} - public void onDraw(Canvas canvas) {} - } - - /** @hide */ - public DragTracker getDragTracker() { - return mDragTracker; - } - - /** @hide */ - public void setDragTracker(DragTracker tracker) { - mDragTracker = tracker; - } - - private DragTracker mDragTracker; - private DragTrackerHandler mDragTrackerHandler; - private boolean hitFocusedPlugin(int contentX, int contentY) { if (DebugFlags.WEB_VIEW) { Log.v(LOGTAG, "nativeFocusIsPlugin()=" + nativeFocusIsPlugin()); @@ -5330,10 +5113,6 @@ public class WebView extends AbsoluteLayout startDrag(); } - if (mDragTrackerHandler != null) { - mDragTrackerHandler.dragTo(x, y); - } - // do pan if (mTouchMode != TOUCH_DRAG_LAYER_MODE) { int newScrollX = pinLocX(mScrollX + deltaX); @@ -5607,9 +5386,6 @@ public class WebView extends AbsoluteLayout mLastTouchTime = eventTime; mVelocityTracker = VelocityTracker.obtain(); mSnapScrollMode = SNAP_NONE; - if (mDragTracker != null) { - mDragTrackerHandler = new DragTrackerHandler(x, y, mDragTracker); - } } private void startDrag() { @@ -5642,9 +5418,6 @@ public class WebView extends AbsoluteLayout } private void stopTouch() { - if (mDragTrackerHandler != null) { - mDragTrackerHandler.stopDrag(); - } // we also use mVelocityTracker == null to tell us that we are // not "moving around", so we can take the slower/prettier // mode in the drawing code @@ -5655,9 +5428,6 @@ public class WebView extends AbsoluteLayout } private void cancelTouch() { - if (mDragTrackerHandler != null) { - mDragTrackerHandler.stopDrag(); - } // we also use mVelocityTracker == null to tell us that we are // not "moving around", so we can take the slower/prettier // mode in the drawing code diff --git a/core/jni/android/graphics/Canvas.cpp b/core/jni/android/graphics/Canvas.cpp index bf150a9..8944d47 100644 --- a/core/jni/android/graphics/Canvas.cpp +++ b/core/jni/android/graphics/Canvas.cpp @@ -26,9 +26,6 @@ #include "SkShader.h" #include "SkTemplates.h" -#include "SkBoundaryPatch.h" -#include "SkMeshUtils.h" - #include "TextLayout.h" #include "unicode/ubidi.h" @@ -968,40 +965,6 @@ static JNINativeMethod gCanvasMethods[] = { /////////////////////////////////////////////////////////////////////////////// -static void BoundaryPatch_computeCubic(JNIEnv* env, jobject, jfloatArray jpts, - int texW, int texH, int rows, int cols, - jfloatArray jverts, jshortArray jidx) { - AutoJavaFloatArray ptsArray(env, jpts, 24, kRO_JNIAccess); - - int vertCount = rows * cols; - AutoJavaFloatArray vertsArray(env, jverts, vertCount * 4, kRW_JNIAccess); - SkPoint* verts = (SkPoint*)vertsArray.ptr(); - SkPoint* texs = verts + vertCount; - - int idxCount = (rows - 1) * (cols - 1) * 6; - AutoJavaShortArray idxArray(env, jidx, idxCount, kRW_JNIAccess); - uint16_t* idx = (uint16_t*)idxArray.ptr(); // cast from int16_t* - - SkCubicBoundary cubic; - memcpy(cubic.fPts, ptsArray.ptr(), 12 * sizeof(SkPoint)); - - SkBoundaryPatch patch; - patch.setBoundary(&cubic); - // generate our verts - patch.evalPatch(verts, rows, cols); - - SkMeshIndices mesh; - // generate our texs and idx - mesh.init(texs, idx, texW, texH, rows, cols); -} - -static JNINativeMethod gBoundaryPatchMethods[] = { - {"nativeComputeCubicPatch", "([FIIII[F[S)V", - (void*)BoundaryPatch_computeCubic }, -}; - -/////////////////////////////////////////////////////////////////////////////// - #include <android_runtime/AndroidRuntime.h> #define REG(env, name, array) \ @@ -1013,7 +976,6 @@ int register_android_graphics_Canvas(JNIEnv* env) { int result; REG(env, "android/graphics/Canvas", gCanvasMethods); - REG(env, "android/graphics/utils/BoundaryPatch", gBoundaryPatchMethods); return result; } diff --git a/graphics/java/android/graphics/utils/BoundaryPatch.java b/graphics/java/android/graphics/utils/BoundaryPatch.java deleted file mode 100644 index 1cd5e13..0000000 --- a/graphics/java/android/graphics/utils/BoundaryPatch.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2009 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package android.graphics.utils; - -import android.graphics.Bitmap; -import android.graphics.BitmapShader; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.graphics.Shader; -import android.graphics.Xfermode; - -/** - * @hide - */ -public class BoundaryPatch { - private Paint mPaint; - private Bitmap mTexture; - private int mRows; - private int mCols; - private float[] mCubicPoints; - private boolean mDirty; - // these are the computed output of the native code - private float[] mVerts; - private short[] mIndices; - - public BoundaryPatch() { - mRows = mCols = 2; // default minimum - mCubicPoints = new float[24]; - mPaint = new Paint(); - mPaint.setDither(true); - mPaint.setFilterBitmap(true); - mDirty = true; - } - - /** - * Set the boundary to be 4 cubics. This takes a single array of floats, - * and picks up the 12 pairs starting at offset, and treats them as - * the x,y coordinates of the cubic control points. The points wrap around - * a patch, as follows. For documentation purposes, pts[i] will mean the - * x,y pair of floats, as if pts[] were an array of "points". - * - * Top: pts[0..3] - * Right: pts[3..6] - * Bottom: pts[6..9] - * Right: pts[9..11], pts[0] - * - * The coordinates are copied from the input array, so subsequent changes - * to pts[] will not be reflected in the boundary. - * - * @param pts The src array of x,y pairs for the boundary cubics - * @param offset The index into pts of the first pair - * @param rows The number of points across to approximate the boundary. - * Must be >= 2, though very large values may slow down drawing - * @param cols The number of points down to approximate the boundary. - * Must be >= 2, though very large values may slow down drawing - */ - public void setCubicBoundary(float[] pts, int offset, int rows, int cols) { - if (rows < 2 || cols < 2) { - throw new RuntimeException("rows and cols must be >= 2"); - } - System.arraycopy(pts, offset, mCubicPoints, 0, 24); - if (mRows != rows || mCols != cols) { - mRows = rows; - mCols = cols; - } - mDirty = true; - } - - /** - * Reference a bitmap texture to be mapped onto the patch. - */ - public void setTexture(Bitmap texture) { - if (mTexture != texture) { - if (mTexture == null || - mTexture.getWidth() != texture.getWidth() || - mTexture.getHeight() != texture.getHeight()) { - // need to recompute texture coordinates - mDirty = true; - } - mTexture = texture; - mPaint.setShader(new BitmapShader(texture, - Shader.TileMode.CLAMP, - Shader.TileMode.CLAMP)); - } - } - - /** - * Return the paint flags for the patch - */ - public int getPaintFlags() { - return mPaint.getFlags(); - } - - /** - * Set the paint flags for the patch - */ - public void setPaintFlags(int flags) { - mPaint.setFlags(flags); - } - - /** - * Set the xfermode for the patch - */ - public void setXfermode(Xfermode mode) { - mPaint.setXfermode(mode); - } - - /** - * Set the alpha for the patch - */ - public void setAlpha(int alpha) { - mPaint.setAlpha(alpha); - } - - /** - * Draw the patch onto the canvas. - * - * setCubicBoundary() and setTexture() must be called before drawing. - */ - public void draw(Canvas canvas) { - if (mDirty) { - buildCache(); - mDirty = false; - } - - // cut the count in half, since mVerts.length is really the length of - // the verts[] and tex[] arrays combined - // (tex[] are stored after verts[]) - int vertCount = mVerts.length >> 1; - canvas.drawVertices(Canvas.VertexMode.TRIANGLES, vertCount, - mVerts, 0, mVerts, vertCount, null, 0, - mIndices, 0, mIndices.length, - mPaint); - } - - private void buildCache() { - // we need mRows * mCols points, for verts and another set for textures - // so *2 for going from points -> floats, and *2 for verts and textures - int vertCount = mRows * mCols * 4; - if (mVerts == null || mVerts.length != vertCount) { - mVerts = new float[vertCount]; - } - - int indexCount = (mRows - 1) * (mCols - 1) * 6; - if (mIndices == null || mIndices.length != indexCount) { - mIndices = new short[indexCount]; - } - - nativeComputeCubicPatch(mCubicPoints, - mTexture.getWidth(), mTexture.getHeight(), - mRows, mCols, mVerts, mIndices); - } - - private static native - void nativeComputeCubicPatch(float[] cubicPoints, - int texW, int texH, int rows, int cols, - float[] verts, short[] indices); -} - diff --git a/preloaded-classes b/preloaded-classes index ee82a2c..21c5df8 100644 --- a/preloaded-classes +++ b/preloaded-classes @@ -254,7 +254,6 @@ android.graphics.drawable.StateListDrawable android.graphics.drawable.StateListDrawable$StateListState android.graphics.drawable.TransitionDrawable android.graphics.drawable.TransitionDrawable$TransitionState -android.graphics.utils.BoundaryPatch android.hardware.Camera android.hardware.Camera$Parameters android.hardware.GeomagneticField |