Skip to content

Commit 78b8ef3

Browse files
author
Jamie Gennis
committed
Surface: replace active rect with window crop
This change replaces the setActiveRectCrop method on Surface, which was called from app processes, with the setWindowCrop method that is to be called from the window manager. Bug: 6299171 Change-Id: Ica51efcd8c488a526e7013b83d80df4856694519
1 parent 304521b commit 78b8ef3

File tree

3 files changed

+24
-37
lines changed

3 files changed

+24
-37
lines changed

core/java/android/view/Surface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ public static void setOrientation(int display, int orientation) {
511511
/** @hide */
512512
public native void setFlags(int flags, int mask);
513513
/** @hide */
514-
public native void setActiveRect(Rect activeRect);
514+
public native void setWindowCrop(Rect crop);
515515

516516

517517

core/java/android/view/ViewRootImpl.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ public final class ViewRootImpl implements ViewParent,
263263
final Rect mPendingVisibleInsets = new Rect();
264264
final Rect mPendingContentInsets = new Rect();
265265
final Rect mPendingSystemInsets = new Rect();
266-
final Rect mActiveRect = new Rect();
267266
final ViewTreeObserver.InternalInsetsInfo mLastGivenInsets
268267
= new ViewTreeObserver.InternalInsetsInfo();
269268

@@ -1698,14 +1697,6 @@ private void performTraversals() {
16981697
}
16991698
}
17001699

1701-
if (activeRectChanged && mSurface.isValid()) {
1702-
mActiveRect.set(attachInfo.mSystemInsets.left, attachInfo.mSystemInsets.top,
1703-
mWidth - attachInfo.mSystemInsets.right,
1704-
mHeight - attachInfo.mSystemInsets.bottom);
1705-
//Log.i(TAG, "Active rect " + mWindowAttributes.getTitle() + ": " + mActiveRect);
1706-
mSurface.setActiveRect(mActiveRect);
1707-
}
1708-
17091700
final boolean didLayout = layoutRequested && !mStopped;
17101701
boolean triggerGlobalLayoutListener = didLayout
17111702
|| attachInfo.mRecomputeGlobalAttributes;

core/jni/android_view_Surface.cpp

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -345,32 +345,6 @@ static inline SkBitmap::Config convertPixelFormat(PixelFormat format)
345345
}
346346
}
347347

348-
static void Surface_setActiveRect(JNIEnv* env, jobject thiz, jobject activeRect)
349-
{
350-
const sp<Surface>& surface(getSurface(env, thiz));
351-
if (!Surface::isValid(surface)) {
352-
doThrowIAE(env);
353-
return;
354-
}
355-
356-
android_native_rect_t nativeRect;
357-
if (activeRect) {
358-
nativeRect.left = env->GetIntField(activeRect, ro.l);
359-
nativeRect.top = env->GetIntField(activeRect, ro.t);
360-
nativeRect.right = env->GetIntField(activeRect, ro.r);
361-
nativeRect.bottom= env->GetIntField(activeRect, ro.b);
362-
} else {
363-
doThrowIAE(env, "activeRect may not be null");
364-
return;
365-
}
366-
367-
int err = native_window_set_active_rect(surface.get(), &nativeRect);
368-
if (err != NO_ERROR) {
369-
doThrowRE(env, String8::format(
370-
"Surface::setActiveRect returned an error: %d", err).string());
371-
}
372-
}
373-
374348
static jobject Surface_lockCanvas(JNIEnv* env, jobject clazz, jobject dirtyRect)
375349
{
376350
const sp<Surface>& surface(getSurface(env, clazz));
@@ -773,6 +747,28 @@ static void Surface_setFreezeTint(
773747
}
774748
}
775749

750+
static void Surface_setWindowCrop(JNIEnv* env, jobject thiz, jobject crop)
751+
{
752+
const sp<SurfaceControl>& surface(getSurfaceControl(env, thiz));
753+
if (surface == 0) return;
754+
755+
Rect nativeCrop;
756+
if (crop) {
757+
nativeCrop.left = env->GetIntField(crop, ro.l);
758+
nativeCrop.top = env->GetIntField(crop, ro.t);
759+
nativeCrop.right = env->GetIntField(crop, ro.r);
760+
nativeCrop.bottom= env->GetIntField(crop, ro.b);
761+
} else {
762+
nativeCrop.left = nativeCrop.top = nativeCrop.right =
763+
nativeCrop.bottom = 0;
764+
}
765+
766+
status_t err = surface->setCrop(nativeCrop);
767+
if (err<0 && err!=NO_INIT) {
768+
doThrowIAE(env);
769+
}
770+
}
771+
776772
// ----------------------------------------------------------------------------
777773

778774
static void Surface_copyFrom(
@@ -915,7 +911,7 @@ static JNINativeMethod gSurfaceMethods[] = {
915911
{"readFromParcel", "(Landroid/os/Parcel;)V", (void*)Surface_readFromParcel },
916912
{"writeToParcel", "(Landroid/os/Parcel;I)V", (void*)Surface_writeToParcel },
917913
{"isConsumerRunningBehind", "()Z", (void*)Surface_isConsumerRunningBehind },
918-
{"setActiveRect", "(Landroid/graphics/Rect;)V", (void*)Surface_setActiveRect },
914+
{"setWindowCrop", "(Landroid/graphics/Rect;)V", (void*)Surface_setWindowCrop },
919915
};
920916

921917
void nativeClassInit(JNIEnv* env, jclass clazz)

0 commit comments

Comments
 (0)