@@ -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+
348374static 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
894921void nativeClassInit (JNIEnv* env, jclass clazz)
0 commit comments