summaryrefslogtreecommitdiffstats
path: root/core/java/android/view
diff options
context:
space:
mode:
authorMitsuru Oshima <oshima@google.com>2009-07-23 23:58:16 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2009-07-23 23:58:16 -0700
commit30b06eb8b98b6e6dc685cf65ad4faa25a85008c5 (patch)
tree64ce39112fed9564c0c71cff7bd6182b8366d68a /core/java/android/view
parent08f89ed9a44ae9262a6c2063878bde44bedb0e37 (diff)
parent589cebe2d58591403de4a77077941c0454bc91bc (diff)
downloadframeworks_base-30b06eb8b98b6e6dc685cf65ad4faa25a85008c5.zip
frameworks_base-30b06eb8b98b6e6dc685cf65ad4faa25a85008c5.tar.gz
frameworks_base-30b06eb8b98b6e6dc685cf65ad4faa25a85008c5.tar.bz2
am 589cebe2: * Use the scaled size for surface view instead of native. The surface will be always scaled by surface flinger in compatiblity mode. The original approach confused the app because the surface size and the view size were different. * a few clean up. remo
Merge commit '589cebe2d58591403de4a77077941c0454bc91bc' * commit '589cebe2d58591403de4a77077941c0454bc91bc': * Use the scaled size for surface view instead of native. The surface will be always scaled
Diffstat (limited to 'core/java/android/view')
-rw-r--r--core/java/android/view/SurfaceView.java60
-rw-r--r--core/java/android/view/ViewRoot.java2
2 files changed, 10 insertions, 52 deletions
diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java
index ae5968e..4546572 100644
--- a/core/java/android/view/SurfaceView.java
+++ b/core/java/android/view/SurfaceView.java
@@ -142,13 +142,6 @@ public class SurfaceView extends View {
final Rect mSurfaceFrame = new Rect();
private Translator mTranslator;
- // A flag to indicate that the Canvas has to be scaled
- private boolean mScaleCanvas = false;
- // A flag to indicate that the Canvas is in use and being scaled.
- // This may remain to be false even if mScaleCanvas is true if the applicatio
- // does not use the canvas (such as GLSurfaceView, VideoView).
- private boolean mCanvasScaled = false;
-
public SurfaceView(Context context) {
super(context);
setWillNotDraw(true);
@@ -261,26 +254,6 @@ public class SurfaceView extends View {
}
@Override
- public boolean dispatchTouchEvent(MotionEvent event) {
- if (mTranslator == null || mCanvasScaled) {
- // Use the event as is if no scaling is required, or the surface's canvas
- // is scaled too.
- return super.dispatchTouchEvent(event);
- } else {
- // The surface is in native size, so we need to scale the event
- // back to native location.
- MotionEvent scaledBack = MotionEvent.obtain(event);
- // scale back to original
- scaledBack.scale(mTranslator.applicationScale);
- try {
- return super.dispatchTouchEvent(scaledBack);
- } finally {
- scaledBack.recycle();
- }
- }
- }
-
- @Override
protected void dispatchDraw(Canvas canvas) {
// if SKIP_DRAW is cleared, draw() has already punched a hole
if ((mPrivateFlags & SKIP_DRAW) == SKIP_DRAW) {
@@ -309,8 +282,6 @@ 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(), mTranslator);
@@ -321,17 +292,6 @@ public class SurfaceView extends View {
int myHeight = mRequestedHeight;
if (myHeight <= 0) myHeight = getHeight();
- // Use requested size if the app specified the size of the view
- // and let the flinger to scale up. Otherwise, use the native size
- // (* appScale) and assume the application can handle it.
- if (mRequestedWidth <= 0 && mTranslator != null) {
- myWidth = (int) (myWidth * appScale + 0.5f);
- myHeight = (int) (myHeight * appScale + 0.5f);
- mScaleCanvas = true;
- } else {
- mScaleCanvas = false;
- }
-
getLocationInWindow(mLocation);
final boolean creating = mWindow == null;
final boolean formatChanged = mFormat != mRequestedFormat;
@@ -404,10 +364,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 {
@@ -651,12 +618,6 @@ public class SurfaceView extends View {
if (localLOGV) Log.i(TAG, "Returned canvas: " + c);
if (c != null) {
mLastLockTime = SystemClock.uptimeMillis();
- if (mScaleCanvas) {
- // When the canvas is scaled, don't scale back the event's location.
- mCanvasScaled = true;
- mSaveCount = c.save();
- mTranslator.translateCanvas(c);
- }
return c;
}
@@ -679,9 +640,6 @@ public class SurfaceView extends View {
}
public void unlockCanvasAndPost(Canvas canvas) {
- if (mCanvasScaled) {
- canvas.restoreToCount(mSaveCount);
- }
mSurface.unlockCanvasAndPost(canvas);
mSurfaceLock.unlock();
}
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java
index 7429a89..0003eb7 100644
--- a/core/java/android/view/ViewRoot.java
+++ b/core/java/android/view/ViewRoot.java
@@ -396,7 +396,7 @@ public final class ViewRoot extends Handler implements ViewParent,
attrs = mWindowAttributes;
Resources resources = mView.getContext().getResources();
CompatibilityInfo compatibilityInfo = resources.getCompatibilityInfo();
- mTranslator = compatibilityInfo.getTranslator(attrs);
+ mTranslator = compatibilityInfo.getTranslator();
if (mTranslator != null || !compatibilityInfo.supportsScreen()) {
mSurface.setCompatibleDisplayMetrics(resources.getDisplayMetrics(),