Merge "Restore the ability to track native Surface changes Bug #8230990" into jb-mr2-dev
This commit is contained in:
@@ -74,17 +74,13 @@ public class Surface implements Parcelable {
|
||||
int mNativeObject; // package scope only for SurfaceControl access
|
||||
|
||||
private int mGenerationId; // incremented each time mNativeSurface changes
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
private final Canvas mCanvas = new CompatibleCanvas();
|
||||
|
||||
// The Translator for density compatibility mode. This is used for scaling
|
||||
// the canvas to perform the appropriate density transformation.
|
||||
private Translator mCompatibilityTranslator;
|
||||
|
||||
// A matrix to scale the matrix set by application. This is set to null for
|
||||
// non compatibility mode.
|
||||
private Matrix mCompatibleMatrix;
|
||||
|
||||
|
||||
/**
|
||||
* Rotation constant: 0 degree rotation (natural orientation)
|
||||
*/
|
||||
@@ -105,8 +101,6 @@ public class Surface implements Parcelable {
|
||||
*/
|
||||
public static final int ROTATION_270 = 3;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Create an empty surface, which will later be filled in by readFromParcel().
|
||||
* @hide
|
||||
@@ -169,6 +163,7 @@ public class Surface implements Parcelable {
|
||||
if (mNativeObject != 0) {
|
||||
nativeRelease(mNativeObject);
|
||||
mNativeObject = 0;
|
||||
mGenerationId++;
|
||||
}
|
||||
mCloseGuard.close();
|
||||
}
|
||||
@@ -183,6 +178,7 @@ public class Surface implements Parcelable {
|
||||
if (mNativeObject != 0) {
|
||||
nativeDestroy(mNativeObject);
|
||||
mNativeObject = 0;
|
||||
mGenerationId++;
|
||||
}
|
||||
mCloseGuard.close();
|
||||
}
|
||||
@@ -291,6 +287,7 @@ public class Surface implements Parcelable {
|
||||
"SurfaceControl native object is null. Are you using a released SurfaceControl?");
|
||||
}
|
||||
mNativeObject = nativeCopyFrom(mNativeObject, other.mNativeObject);
|
||||
mGenerationId++;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -312,7 +309,10 @@ public class Surface implements Parcelable {
|
||||
}
|
||||
// transfer the reference from other to us
|
||||
mNativeObject = other.mNativeObject;
|
||||
mGenerationId++;
|
||||
|
||||
other.mNativeObject = 0;
|
||||
other.mGenerationId++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -327,6 +327,7 @@ public class Surface implements Parcelable {
|
||||
}
|
||||
mName = source.readString();
|
||||
mNativeObject = nativeReadFromParcel(mNativeObject, source);
|
||||
mGenerationId++;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -404,24 +405,6 @@ public class Surface implements Parcelable {
|
||||
// A temp matrix to remember what an application obtained via {@link getMatrix}
|
||||
private Matrix mOrigMatrix = null;
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
int w = super.getWidth();
|
||||
if (mCompatibilityTranslator != null) {
|
||||
w = (int)(w * mCompatibilityTranslator.applicationInvertedScale + .5f);
|
||||
}
|
||||
return w;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
int h = super.getHeight();
|
||||
if (mCompatibilityTranslator != null) {
|
||||
h = (int)(h * mCompatibilityTranslator.applicationInvertedScale + .5f);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMatrix(Matrix matrix) {
|
||||
if (mCompatibleMatrix == null || mOrigMatrix == null || mOrigMatrix.equals(matrix)) {
|
||||
@@ -435,6 +418,7 @@ public class Surface implements Parcelable {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void getMatrix(Matrix m) {
|
||||
super.getMatrix(m);
|
||||
|
||||
@@ -53,7 +53,6 @@ static const char* const OutOfResourcesException =
|
||||
static struct {
|
||||
jclass clazz;
|
||||
jfieldID mNativeObject;
|
||||
jfieldID mGenerationId;
|
||||
jfieldID mCanvas;
|
||||
jmethodID ctor;
|
||||
} gSurfaceClassInfo;
|
||||
@@ -384,8 +383,6 @@ int register_android_view_Surface(JNIEnv* env)
|
||||
gSurfaceClassInfo.clazz = jclass(env->NewGlobalRef(clazz));
|
||||
gSurfaceClassInfo.mNativeObject =
|
||||
env->GetFieldID(gSurfaceClassInfo.clazz, "mNativeObject", "I");
|
||||
gSurfaceClassInfo.mGenerationId =
|
||||
env->GetFieldID(gSurfaceClassInfo.clazz, "mGenerationId", "I");
|
||||
gSurfaceClassInfo.mCanvas =
|
||||
env->GetFieldID(gSurfaceClassInfo.clazz, "mCanvas", "Landroid/graphics/Canvas;");
|
||||
gSurfaceClassInfo.ctor = env->GetMethodID(gSurfaceClassInfo.clazz, "<init>", "(I)V");
|
||||
|
||||
Reference in New Issue
Block a user