diff options
Diffstat (limited to 'core/java/android/view/SurfaceView.java')
-rw-r--r-- | core/java/android/view/SurfaceView.java | 53 |
1 files changed, 11 insertions, 42 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 95bba97..9cf7092 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -140,7 +140,7 @@ public class SurfaceView extends View { int mType = -1; final Rect mSurfaceFrame = new Rect(); private Translator mTranslator; - + public SurfaceView(Context context) { super(context); setWillNotDraw(true); @@ -253,23 +253,6 @@ public class SurfaceView extends View { } @Override - public boolean dispatchTouchEvent(MotionEvent event) { - // SurfaceView uses pre-scaled size unless fixed size is requested. This hook - // scales the event back to the pre-scaled coordinates for such surface. - if (mScaled) { - MotionEvent scaledBack = MotionEvent.obtain(event); - mTranslator.translateEventInScreenToAppWindow(event); - try { - return super.dispatchTouchEvent(scaledBack); - } finally { - scaledBack.recycle(); - } - } else { - return super.dispatchTouchEvent(event); - } - } - - @Override protected void dispatchDraw(Canvas canvas) { // if SKIP_DRAW is cleared, draw() has already punched a hole if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) { @@ -291,8 +274,6 @@ public class SurfaceView extends View { mWindowType = type; } - boolean mScaled = false; - private void updateWindow(boolean force) { if (!mHaveFrame) { return; @@ -300,11 +281,9 @@ public class SurfaceView extends View { ViewRoot viewRoot = (ViewRoot) getRootView().getParent(); mTranslator = viewRoot.mTranslator; - float appScale = mTranslator == null ? 1.0f : mTranslator.applicationScale; - Resources res = getContext().getResources(); if (mTranslator != null || !res.getCompatibilityInfo().supportsScreen()) { - mSurface.setCompatibleDisplayMetrics(res.getDisplayMetrics()); + mSurface.setCompatibleDisplayMetrics(res.getDisplayMetrics(), mTranslator); } int myWidth = mRequestedWidth; @@ -312,16 +291,6 @@ public class SurfaceView extends View { int myHeight = mRequestedHeight; if (myHeight <= 0) myHeight = getHeight(); - // Use original size if the app specified the size of the view, - // and let the flinger to scale up. - if (mRequestedWidth <= 0 && mTranslator != null) { - myWidth = (int) (myWidth * appScale + 0.5f); - myHeight = (int) (myHeight * appScale + 0.5f); - mScaled = true; - } else { - mScaled = false; - } - getLocationInWindow(mLocation); final boolean creating = mWindow == null; final boolean formatChanged = mFormat != mRequestedFormat; @@ -394,10 +363,17 @@ public class SurfaceView extends View { if (localLOGV) Log.i(TAG, "New surface: " + mSurface + ", vis=" + visible + ", frame=" + mWinFrame); + mSurfaceFrame.left = 0; mSurfaceFrame.top = 0; - mSurfaceFrame.right = mWinFrame.width(); - mSurfaceFrame.bottom = mWinFrame.height(); + if (mTranslator == null) { + mSurfaceFrame.right = mWinFrame.width(); + mSurfaceFrame.bottom = mWinFrame.height(); + } else { + float appInvertedScale = mTranslator.applicationInvertedScale; + mSurfaceFrame.right = (int) (mWinFrame.width() * appInvertedScale + 0.5f); + mSurfaceFrame.bottom = (int) (mWinFrame.height() * appInvertedScale + 0.5f); + } mSurfaceLock.unlock(); try { @@ -641,10 +617,6 @@ public class SurfaceView extends View { if (localLOGV) Log.i(TAG, "Returned canvas: " + c); if (c != null) { mLastLockTime = SystemClock.uptimeMillis(); - if (mScaled) { - mSaveCount = c.save(); - mTranslator.translateCanvas(c); - } return c; } @@ -667,9 +639,6 @@ public class SurfaceView extends View { } public void unlockCanvasAndPost(Canvas canvas) { - if (mScaled) { - canvas.restoreToCount(mSaveCount); - } mSurface.unlockCanvasAndPost(canvas); mSurfaceLock.unlock(); } |