@@ -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-
374348static 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
778774static 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
921917void nativeClassInit (JNIEnv* env, jclass clazz)
0 commit comments