Merge change 7707 into donut
* changes: * scale surface view's canvas This will not affect GL/Video views as they're directly using surfce but not canvas.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user