summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMitsuru Oshima <oshima@google.com>2009-05-11 21:14:03 -0700
committerMitsuru Oshima <oshima@google.com>2009-05-12 18:08:20 -0700
commit001a6e52445b2744b4f2eb00099b98a17f4245c9 (patch)
tree17ab06af250b19f7cc3e4be6f1395f991f67a739 /core
parent7e3e04c144182c6807c66646b3f988beaba1720e (diff)
downloadframeworks_base-001a6e52445b2744b4f2eb00099b98a17f4245c9.zip
frameworks_base-001a6e52445b2744b4f2eb00099b98a17f4245c9.tar.gz
frameworks_base-001a6e52445b2744b4f2eb00099b98a17f4245c9.tar.bz2
Density Compatibility mode for SurfaceView
* use fixed size when requested. Otherwise, give the original size instead of scaled down size. * scale back the motion event to original size when surface view is using the orignal size.
Diffstat (limited to 'core')
-rw-r--r--core/java/android/view/SurfaceView.java27
1 files changed, 25 insertions, 2 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index 61dca4c..40b03c8 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -256,6 +256,23 @@ 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 (mRequestedWidth < 0 && mAppScale != 1.0f) {
+ MotionEvent scaledBack = MotionEvent.obtain(event);
+ scaledBack.scale(mAppScale);
+ 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) {
@@ -277,7 +294,13 @@ public class SurfaceView extends View {
if (myWidth <= 0) myWidth = getWidth();
int myHeight = mRequestedHeight;
if (myHeight <= 0) myHeight = getHeight();
-
+
+ // Use original size for surface unless fixed size is requested.
+ if (mRequestedWidth <= 0) {
+ myWidth *= mAppScale;
+ myHeight *= mAppScale;
+ }
+
getLocationInWindow(mLocation);
final boolean creating = mWindow == null;
final boolean formatChanged = mFormat != mRequestedFormat;
@@ -333,7 +356,7 @@ public class SurfaceView extends View {
mSurfaceLock.lock();
mDrawingStopped = !visible;
final int relayoutResult = mSession.relayout(
- mWindow, mLayout, (int) (mWidth * mAppScale), (int) (mHeight * mAppScale),
+ mWindow, mLayout, mWidth, mHeight,
visible ? VISIBLE : GONE, false, mWinFrame, mContentInsets,
mVisibleInsets, mSurface);