Skip to content

Commit b40696c

Browse files
author
Jamie Gennis
committed
Surface: add JNI plumbing for setActiveRect.
Bug: 6299171 Change-Id: If26e63ebe7def645626af251bed899ff9389f8e5
1 parent 459e459 commit b40696c

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

core/java/android/view/Surface.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,8 @@ public static void setOrientation(int display, int orientation) {
510510
public native void setFreezeTint(int tint);
511511
/** @hide */
512512
public native void setFlags(int flags, int mask);
513+
/** @hide */
514+
public native void setActiveRect(Rect activeRect);
513515

514516

515517

core/jni/android_view_Surface.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,32 @@ 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+
348374
static jobject Surface_lockCanvas(JNIEnv* env, jobject clazz, jobject dirtyRect)
349375
{
350376
const sp<Surface>& surface(getSurface(env, clazz));
@@ -889,6 +915,7 @@ static JNINativeMethod gSurfaceMethods[] = {
889915
{"readFromParcel", "(Landroid/os/Parcel;)V", (void*)Surface_readFromParcel },
890916
{"writeToParcel", "(Landroid/os/Parcel;I)V", (void*)Surface_writeToParcel },
891917
{"isConsumerRunningBehind", "()Z", (void*)Surface_isConsumerRunningBehind },
918+
{"setActiveRect", "(Landroid/graphics/Rect;)V", (void*)Surface_setActiveRect },
892919
};
893920

894921
void nativeClassInit(JNIEnv* env, jclass clazz)

0 commit comments

Comments
 (0)