diff options
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/view/HardwareRenderer.java | 90 | ||||
| -rwxr-xr-x | core/java/android/view/InputDevice.java | 10 | ||||
| -rw-r--r-- | core/java/android/view/KeyCharacterMap.java | 15 | ||||
| -rw-r--r-- | core/java/android/view/WindowManagerImpl.java | 3 | ||||
| -rw-r--r-- | core/java/android/webkit/WebView.java | 28 | ||||
| -rw-r--r-- | core/java/android/widget/TextView.java | 35 |
6 files changed, 100 insertions, 81 deletions
diff --git a/core/java/android/view/HardwareRenderer.java b/core/java/android/view/HardwareRenderer.java index e0167d8..8e39d6e 100644 --- a/core/java/android/view/HardwareRenderer.java +++ b/core/java/android/view/HardwareRenderer.java @@ -22,6 +22,9 @@ import android.graphics.Paint; import android.graphics.Rect; import android.graphics.SurfaceTexture; import android.opengl.GLUtils; +import android.opengl.ManagedEGLContext; +import android.os.Handler; +import android.os.Looper; import android.os.SystemClock; import android.os.SystemProperties; import android.util.Log; @@ -409,7 +412,8 @@ public abstract class HardwareRenderer { static final Object[] sEglLock = new Object[0]; int mWidth = -1, mHeight = -1; - static final ThreadLocal<EGLContext> sEglContextStorage = new ThreadLocal<EGLContext>(); + static final ThreadLocal<Gl20Renderer.MyEGLContext> sEglContextStorage + = new ThreadLocal<Gl20Renderer.MyEGLContext>(); EGLContext mEglContext; Thread mEglThread; @@ -561,12 +565,13 @@ public abstract class HardwareRenderer { } } - mEglContext = sEglContextStorage.get(); + Gl20Renderer.MyEGLContext managedContext = sEglContextStorage.get(); + mEglContext = managedContext != null ? managedContext.getContext() : null; mEglThread = Thread.currentThread(); if (mEglContext == null) { mEglContext = createContext(sEgl, sEglDisplay, sEglConfig); - sEglContextStorage.set(mEglContext); + sEglContextStorage.set(new Gl20Renderer.MyEGLContext(mEglContext)); } } @@ -904,6 +909,51 @@ public abstract class HardwareRenderer { private static EGLSurface sPbuffer; private static final Object[] sPbufferLock = new Object[0]; + static class MyEGLContext extends ManagedEGLContext { + final Handler mHandler = new Handler(); + + public MyEGLContext(EGLContext context) { + super(context); + } + + @Override + public void onTerminate(final EGLContext eglContext) { + // Make sure we do this on the correct thread. + if (mHandler.getLooper() != Looper.myLooper()) { + mHandler.post(new Runnable() { + @Override public void run() { + onTerminate(eglContext); + } + }); + return; + } + + synchronized (sEglLock) { + if (sEgl == null) return; + + if (EGLImpl.getInitCount(sEglDisplay) == 1) { + usePbufferSurface(eglContext); + GLES20Canvas.terminateCaches(); + + sEgl.eglDestroyContext(sEglDisplay, eglContext); + sEglContextStorage.remove(); + + sEgl.eglDestroySurface(sEglDisplay, sPbuffer); + sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + + sEgl.eglReleaseThread(); + sEgl.eglTerminate(sEglDisplay); + + sEgl = null; + sEglDisplay = null; + sEglConfig = null; + sPbuffer = null; + sEglContextStorage.set(null); + } + } + } + } + Gl20Renderer(boolean translucent) { super(2, translucent); } @@ -1020,12 +1070,12 @@ public abstract class HardwareRenderer { static void trimMemory(int level) { if (sEgl == null || sEglConfig == null) return; - EGLContext eglContext = sEglContextStorage.get(); + Gl20Renderer.MyEGLContext managedContext = sEglContextStorage.get(); // We do not have OpenGL objects - if (eglContext == null) { + if (managedContext == null) { return; } else { - usePbufferSurface(eglContext); + usePbufferSurface(managedContext.getContext()); } switch (level) { @@ -1052,33 +1102,5 @@ public abstract class HardwareRenderer { } sEgl.eglMakeCurrent(sEglDisplay, sPbuffer, sPbuffer, eglContext); } - - static void terminate() { - synchronized (sEglLock) { - if (sEgl == null) return; - - if (EGLImpl.getInitCount(sEglDisplay) == 1) { - EGLContext eglContext = sEglContextStorage.get(); - if (eglContext == null) return; - - usePbufferSurface(eglContext); - GLES20Canvas.terminateCaches(); - - sEgl.eglDestroyContext(sEglDisplay, eglContext); - sEglContextStorage.remove(); - - sEgl.eglDestroySurface(sEglDisplay, sPbuffer); - sEgl.eglMakeCurrent(sEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - - sEgl.eglReleaseThread(); - sEgl.eglTerminate(sEglDisplay); - - sEgl = null; - sEglDisplay = null; - sEglConfig = null; - sPbuffer = null; - } - } - } } } diff --git a/core/java/android/view/InputDevice.java b/core/java/android/view/InputDevice.java index bfc7c31..8115b36 100755 --- a/core/java/android/view/InputDevice.java +++ b/core/java/android/view/InputDevice.java @@ -19,7 +19,6 @@ package android.view; import android.os.Parcel; import android.os.Parcelable; import android.os.RemoteException; -import android.os.ServiceManager; import java.util.ArrayList; import java.util.List; @@ -44,6 +43,7 @@ public final class InputDevice implements Parcelable { private String mName; private int mSources; private int mKeyboardType; + private String mKeyCharacterMapFile; private final ArrayList<MotionRange> mMotionRanges = new ArrayList<MotionRange>(); @@ -360,6 +360,10 @@ public final class InputDevice implements Parcelable { return KeyCharacterMap.load(mId); } + String getKeyCharacterMapFile() { + return mKeyCharacterMapFile; + } + /** * Gets information about the range of values for a particular {@link MotionEvent} axis. * If the device supports multiple sources, the same axis may have different meanings @@ -532,6 +536,7 @@ public final class InputDevice implements Parcelable { mName = in.readString(); mSources = in.readInt(); mKeyboardType = in.readInt(); + mKeyCharacterMapFile = in.readString(); for (;;) { int axis = in.readInt(); @@ -549,6 +554,7 @@ public final class InputDevice implements Parcelable { out.writeString(mName); out.writeInt(mSources); out.writeInt(mKeyboardType); + out.writeString(mKeyCharacterMapFile); final int numRanges = mMotionRanges.size(); for (int i = 0; i < numRanges; i++) { @@ -587,6 +593,8 @@ public final class InputDevice implements Parcelable { } description.append("\n"); + description.append(" Key Character Map: ").append(mKeyCharacterMapFile).append("\n"); + description.append(" Sources: 0x").append(Integer.toHexString(mSources)).append(" ("); appendSourceDescriptionIfApplicable(description, SOURCE_KEYBOARD, "keyboard"); appendSourceDescriptionIfApplicable(description, SOURCE_DPAD, "dpad"); diff --git a/core/java/android/view/KeyCharacterMap.java b/core/java/android/view/KeyCharacterMap.java index 885a75f..575af3b 100644 --- a/core/java/android/view/KeyCharacterMap.java +++ b/core/java/android/view/KeyCharacterMap.java @@ -20,7 +20,6 @@ import android.text.method.MetaKeyKeyListener; import android.util.AndroidRuntimeException; import android.util.SparseIntArray; import android.os.RemoteException; -import android.os.ServiceManager; import android.util.SparseArray; import java.lang.Character; @@ -140,7 +139,7 @@ public class KeyCharacterMap { private final int mDeviceId; private int mPtr; - private static native int nativeLoad(int id); + private static native int nativeLoad(String file); private static native void nativeDispose(int ptr); private static native char nativeGetCharacter(int ptr, int keyCode, int metaState); @@ -178,7 +177,17 @@ public class KeyCharacterMap { synchronized (sInstances) { KeyCharacterMap map = sInstances.get(deviceId); if (map == null) { - int ptr = nativeLoad(deviceId); // might throw + String kcm = null; + if (deviceId != VIRTUAL_KEYBOARD) { + InputDevice device = InputDevice.getDevice(deviceId); + if (device != null) { + kcm = device.getKeyCharacterMapFile(); + } + } + if (kcm == null || kcm.length() == 0) { + kcm = "/system/usr/keychars/Virtual.kcm"; + } + int ptr = nativeLoad(kcm); // might throw map = new KeyCharacterMap(deviceId, ptr); sInstances.put(deviceId, map); } diff --git a/core/java/android/view/WindowManagerImpl.java b/core/java/android/view/WindowManagerImpl.java index d89bc36..660e3f4 100644 --- a/core/java/android/view/WindowManagerImpl.java +++ b/core/java/android/view/WindowManagerImpl.java @@ -21,6 +21,7 @@ import android.content.ComponentCallbacks2; import android.content.res.CompatibilityInfo; import android.content.res.Configuration; import android.graphics.PixelFormat; +import android.opengl.ManagedEGLContext; import android.os.IBinder; import android.util.AndroidRuntimeException; import android.util.Log; @@ -428,7 +429,7 @@ public class WindowManagerImpl implements WindowManager { } } // Terminate the hardware renderer to free all resources - HardwareRenderer.terminate(); + ManagedEGLContext.doTerminate(); break; } // high end gfx devices fall through to next case diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java index 7249497..ec2f55b 100644 --- a/core/java/android/webkit/WebView.java +++ b/core/java/android/webkit/WebView.java @@ -3097,10 +3097,7 @@ public class WebView extends AbsoluteLayout // Special-case layer scrolling so that we do not trigger normal scroll // updating. if (mTouchMode == TOUCH_DRAG_LAYER_MODE) { - nativeScrollLayer(mScrollingLayer, scrollX, scrollY); - mScrollingLayerRect.left = scrollX; - mScrollingLayerRect.top = scrollY; - invalidate(); + scrollLayerTo(scrollX, scrollY); return; } mInOverScrollMode = false; @@ -3603,9 +3600,7 @@ public class WebView extends AbsoluteLayout mScrollY = y; } else { // Update the layer position instead of WebView. - nativeScrollLayer(mScrollingLayer, x, y); - mScrollingLayerRect.left = x; - mScrollingLayerRect.top = y; + scrollLayerTo(x, y); } abortAnimation(); nativeSetIsScrolling(false); @@ -3624,6 +3619,17 @@ public class WebView extends AbsoluteLayout } } + private void scrollLayerTo(int x, int y) { + if (x == mScrollingLayerRect.left && y == mScrollingLayerRect.top) { + return; + } + nativeScrollLayer(mScrollingLayer, x, y); + mScrollingLayerRect.left = x; + mScrollingLayerRect.top = y; + onScrollChanged(mScrollX, mScrollY, mScrollX, mScrollY); + invalidate(); + } + private static int computeDuration(int dx, int dy) { int distance = Math.max(Math.abs(dx), Math.abs(dy)); int duration = distance * 1000 / STD_SPEED; @@ -8309,12 +8315,8 @@ public class WebView extends AbsoluteLayout if (mScrollingLayer == 0) { pinScrollBy(mAutoScrollX, mAutoScrollY, true, 0); } else { - mScrollingLayerRect.left += mAutoScrollX; - mScrollingLayerRect.top += mAutoScrollY; - nativeScrollLayer(mScrollingLayer, - mScrollingLayerRect.left, - mScrollingLayerRect.top); - invalidate(); + scrollLayerTo(mScrollingLayerRect.left + mAutoScrollX, + mScrollingLayerRect.top + mAutoScrollY); } sendEmptyMessageDelayed( SCROLL_SELECT_TEXT, SELECT_SCROLL_INTERVAL); diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b106cc5..185cfa9 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -131,7 +131,6 @@ import android.view.inputmethod.ExtractedText; import android.view.inputmethod.ExtractedTextRequest; import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputMethodManager; -import android.view.inputmethod.InputMethodSubtype; import android.view.textservice.SpellCheckerSubtype; import android.view.textservice.TextServicesManager; import android.widget.AdapterView.OnItemClickListener; @@ -3786,7 +3785,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return; } } - + // This is the handling for some default action. // Note that for backwards compatibility we don't do this // default handling if explicit ime options have not been given, @@ -5342,7 +5341,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener switch (keyCode) { case KeyEvent.KEYCODE_ENTER: - mEnterKeyIsDown = true; if (event.hasNoModifiers()) { // When mInputContentType is set, we know that we are // running in a "modern" cupcake environment, so don't need @@ -5374,7 +5372,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener break; case KeyEvent.KEYCODE_DPAD_CENTER: - mDPadCenterIsDown = true; if (event.hasNoModifiers()) { if (shouldAdvanceFocusOnEnter()) { return 0; @@ -5488,7 +5485,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener switch (keyCode) { case KeyEvent.KEYCODE_DPAD_CENTER: - mDPadCenterIsDown = false; if (event.hasNoModifiers()) { /* * If there is a click listener, just call through to @@ -5513,7 +5509,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener return super.onKeyUp(keyCode, event); case KeyEvent.KEYCODE_ENTER: - mEnterKeyIsDown = false; if (event.hasNoModifiers()) { if (mInputContentType != null && mInputContentType.onEditorActionListener != null @@ -5599,6 +5594,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener outAttrs.extras = mInputContentType.extras; } else { outAttrs.imeOptions = EditorInfo.IME_NULL; + // May not be defined otherwise and needed by onEditorAction + mInputContentType = new InputContentType(); } if (focusSearch(FOCUS_DOWN) != null) { outAttrs.imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT; @@ -8972,17 +8969,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } private long getLastTouchOffsets() { - int minOffset, maxOffset; - - if (mContextMenuTriggeredByKey) { - minOffset = getSelectionStart(); - maxOffset = getSelectionEnd(); - } else { - SelectionModifierCursorController selectionController = getSelectionController(); - minOffset = selectionController.getMinTouchOffset(); - maxOffset = selectionController.getMaxTouchOffset(); - } - + SelectionModifierCursorController selectionController = getSelectionController(); + final int minOffset = selectionController.getMinTouchOffset(); + final int maxOffset = selectionController.getMaxTouchOffset(); return packRangeInLong(minOffset, maxOffset); } @@ -9075,12 +9064,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private static final int ID_COPY = android.R.id.copy; private static final int ID_PASTE = android.R.id.paste; - private class MenuHandler implements MenuItem.OnMenuItemClickListener { - public boolean onMenuItemClick(MenuItem item) { - return onTextContextMenuItem(item.getItemId()); - } - } - /** * Called when a context menu option for the text view is selected. Currently * this will be one of {@link android.R.id#selectAll}, {@link android.R.id#cut}, @@ -11480,12 +11463,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private boolean mSelectionControllerEnabled; private boolean mInBatchEditControllers; - // These are needed to desambiguate a long click. If the long click comes from ones of these, we - // select from the current cursor position. Otherwise, select from long pressed position. - private boolean mDPadCenterIsDown = false; - private boolean mEnterKeyIsDown = false; - private boolean mContextMenuTriggeredByKey = false; - private boolean mSelectAllOnFocus = false; private int mGravity = Gravity.TOP | Gravity.START; |
