@@ -2351,22 +2351,6 @@ void OMXCodec::onEvent(OMX_EVENTTYPE event, OMX_U32 data1, OMX_U32 data2) {
23512351 formatHasNotablyChanged (oldOutputFormat, mOutputFormat )) {
23522352 mOutputPortSettingsHaveChanged = true ;
23532353
2354- if (mNativeWindow != NULL ) {
2355- int32_t left, top, right, bottom;
2356- CHECK (mOutputFormat ->findRect (
2357- kKeyCropRect ,
2358- &left, &top, &right, &bottom));
2359-
2360- android_native_rect_t crop;
2361- crop.left = left;
2362- crop.top = top;
2363- crop.right = right + 1 ;
2364- crop.bottom = bottom + 1 ;
2365-
2366- // We'll ignore any errors here, if the surface is
2367- // already invalid, we'll know soon enough.
2368- native_window_set_crop (mNativeWindow .get (), &crop);
2369- }
23702354 } else if (data2 == OMX_IndexConfigCommonScale) {
23712355 OMX_CONFIG_SCALEFACTORTYPE scale;
23722356 InitOMXParams (&scale);
@@ -4183,6 +4167,24 @@ status_t OMXCodec::initNativeWindow() {
41834167 return OK;
41844168}
41854169
4170+ void OMXCodec::initNativeWindowCrop () {
4171+ int32_t left, top, right, bottom;
4172+
4173+ CHECK (mOutputFormat ->findRect (
4174+ kKeyCropRect ,
4175+ &left, &top, &right, &bottom));
4176+
4177+ android_native_rect_t crop;
4178+ crop.left = left;
4179+ crop.top = top;
4180+ crop.right = right + 1 ;
4181+ crop.bottom = bottom + 1 ;
4182+
4183+ // We'll ignore any errors here, if the surface is
4184+ // already invalid, we'll know soon enough.
4185+ native_window_set_crop (mNativeWindow .get (), &crop);
4186+ }
4187+
41864188void OMXCodec::initOutputFormat (const sp<MetaData> &inputFormat) {
41874189 mOutputFormat = new MetaData;
41884190 mOutputFormat ->setCString (kKeyDecoderComponent , mComponentName );
@@ -4366,6 +4368,10 @@ void OMXCodec::initOutputFormat(const sp<MetaData> &inputFormat) {
43664368 video_def->nFrameWidth - 1 ,
43674369 video_def->nFrameHeight - 1 );
43684370 }
4371+
4372+ if (mNativeWindow != NULL ) {
4373+ initNativeWindowCrop ();
4374+ }
43694375 }
43704376 break ;
43714377 }
0 commit comments