diff options
author | Mitsuru Oshima <oshima@google.com> | 2009-07-17 09:57:28 -0700 |
---|---|---|
committer | Mitsuru Oshima <oshima@google.com> | 2009-07-17 10:11:05 -0700 |
commit | 34bf2ee9e695c620e0a4b9a790f1f6ccb8a77234 (patch) | |
tree | 0cc6ad71fe3ac72b5e4bb99f7737e10756a89ca7 /core | |
parent | 54f09101381fa63dca35ae4ea0ba3802ee863236 (diff) | |
download | frameworks_base-34bf2ee9e695c620e0a4b9a790f1f6ccb8a77234.zip frameworks_base-34bf2ee9e695c620e0a4b9a790f1f6ccb8a77234.tar.gz frameworks_base-34bf2ee9e695c620e0a4b9a790f1f6ccb8a77234.tar.bz2 |
* scale surface view's canvas
This will not affect GL/Video views as they're directly using surfce but not canvas.
Diffstat (limited to 'core')
-rw-r--r-- | core/java/android/view/SurfaceView.java | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index ff1eb53..28c1fe1 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -17,7 +17,6 @@ package android.view; import android.content.Context; -import android.content.res.CompatibilityInfo; import android.content.res.CompatibilityInfo.Translator; import android.graphics.Canvas; import android.graphics.PixelFormat; @@ -256,7 +255,7 @@ public class SurfaceView extends View { 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 (mRequestedWidth < 0 && mTranslator != null) { + if (mScaled) { MotionEvent scaledBack = MotionEvent.obtain(event); scaledBack.scale(mTranslator.applicationScale); try { @@ -290,6 +289,8 @@ public class SurfaceView extends View { public void setWindowType(int type) { mWindowType = type; } + + boolean mScaled = false; private void updateWindow(boolean force) { if (!mHaveFrame) { @@ -309,6 +310,9 @@ public class SurfaceView extends View { if (mRequestedWidth <= 0 && mTranslator != null) { myWidth *= appScale; myHeight *= appScale; + mScaled = true; + } else { + mScaled = false; } getLocationInWindow(mLocation); @@ -533,6 +537,7 @@ public class SurfaceView extends View { private SurfaceHolder mSurfaceHolder = new SurfaceHolder() { private static final String LOG_TAG = "SurfaceHolder"; + private int mSaveCount; public boolean isCreating() { return mIsCreating; @@ -627,6 +632,10 @@ 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; } @@ -649,6 +658,9 @@ public class SurfaceView extends View { } public void unlockCanvasAndPost(Canvas canvas) { + if (mScaled) { + canvas.restoreToCount(mSaveCount); + } mSurface.unlockCanvasAndPost(canvas); mSurfaceLock.unlock(); } |