60 { |
61 { |
61 DEBUG_PRINTF("CMediaClientVideoDisplayBody::ConstructL +++"); |
62 DEBUG_PRINTF("CMediaClientVideoDisplayBody::ConstructL +++"); |
62 |
63 |
63 SetWindowArrayPtr2Client(); |
64 SetWindowArrayPtr2Client(); |
64 |
65 |
65 CreateExtDisplayPluginL(); |
66 // External display switching and wserv events are only possible if there is |
66 |
67 // an active scheduler in client thread |
67 // Try and enable display switching by default. If this leaves then do so quietly. |
68 if(CActiveScheduler::Current()) |
68 // Either the client has no scheduler installed or the device does not support external |
69 { |
69 // switching (i.e. no plugin was found) |
70 CreateExtDisplayPluginL(); |
70 TRAPD(err, SetExternalDisplaySwitchingL(aExtDisplaySwitchingControl)); |
71 iWsEventObserver = CMediaClientWsEventObserver::NewL(*this); |
71 err = err; // remove compile warning |
72 |
72 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::ConstructL SetExternalDisplaySwitchingL returned with %d", err); |
73 iServerClient = CMediaClientPolicyServerClient::NewL(); |
73 |
74 if(iServerClient->Connect() != KErrNone) |
|
75 { |
|
76 delete iServerClient; |
|
77 iServerClient = NULL; |
|
78 } |
|
79 |
|
80 if(IsSurfaceCreated() && iServerClient) |
|
81 { |
|
82 iServerClient->SetSurface(iSurfaceId); |
|
83 } |
|
84 |
|
85 // Try and enable display switching by default. If this leaves then do so quietly. |
|
86 // Either the client has no scheduler installed or the device does not support external |
|
87 // switching (i.e. no plugin was found) |
|
88 TRAPD(err, SetExternalDisplaySwitchingL(aExtDisplaySwitchingControl)); |
|
89 err = err; // remove compile warning |
|
90 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::ConstructL SetExternalDisplaySwitchingL returned with %d", err); |
|
91 } |
|
92 else |
|
93 { |
|
94 DEBUG_PRINTF("CMediaClientVideoDisplayBody::ConstructL No CActiveScheduler - ext display and focus features disabled "); |
|
95 } |
74 DEBUG_PRINTF("CMediaClientVideoDisplayBody::ConstructL ---"); |
96 DEBUG_PRINTF("CMediaClientVideoDisplayBody::ConstructL ---"); |
75 } |
97 } |
76 |
98 |
77 CMediaClientVideoDisplayBody::CMediaClientVideoDisplayBody(TInt aDisplayId, const TSurfaceId& aSurfaceId, |
99 CMediaClientVideoDisplayBody::CMediaClientVideoDisplayBody(TInt aDisplayId, const TSurfaceId& aSurfaceId, |
78 const TRect& aCropRect, TVideoAspectRatio aAspectRatio) : |
100 const TRect& aCropRect, TVideoAspectRatio aAspectRatio) : |
127 } |
153 } |
128 |
154 |
129 void CMediaClientVideoDisplayBody::AddDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent, |
155 void CMediaClientVideoDisplayBody::AddDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent, |
130 TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, |
156 TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, |
131 TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2) |
157 TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2) |
132 { |
158 { |
133 DEBUG_PRINTF("CMediaClientVideoDisplayBody::AddDisplayWindowL +++"); |
159 DEBUG_PRINTF("CMediaClientVideoDisplayBody::AddDisplayWindowL +++"); |
134 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::AddDisplayWindowL - aWindow WsHandle 0x%X", aWindow->WsHandle()); |
160 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::AddDisplayWindowL - aWindow WsHandle 0x%X", aWindow->WsHandle()); |
135 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::AddDisplayWindowL - aClipRect %d,%d - %d,%d", aClipRect.iTl.iX, aClipRect.iTl.iY, aClipRect.iBr.iX, aClipRect.iBr.iY); |
161 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::AddDisplayWindowL - aClipRect %d,%d - %d,%d", aClipRect.iTl.iX, aClipRect.iTl.iY, aClipRect.iBr.iX, aClipRect.iBr.iY); |
136 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::AddDisplayWindowL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
162 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::AddDisplayWindowL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
137 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::AddDisplayWindowL - aVideoExtent %d,%d - %d,%d", aVideoExtent.iTl.iX, aVideoExtent.iTl.iY, aVideoExtent.iBr.iX, aVideoExtent.iBr.iY); |
163 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::AddDisplayWindowL - aVideoExtent %d,%d - %d,%d", aVideoExtent.iTl.iX, aVideoExtent.iTl.iY, aVideoExtent.iBr.iX, aVideoExtent.iBr.iY); |
138 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::AddDisplayWindowL - aScaleWidth %f, aScaleHeight %f", aScaleWidth, aScaleHeight); |
164 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::AddDisplayWindowL - aScaleWidth %f, aScaleHeight %f", aScaleWidth, aScaleHeight); |
139 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::AddDisplayWindowL - aRotation %d", aRotation); |
165 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::AddDisplayWindowL - aRotation %d", aRotation); |
140 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::AddDisplayWindowL - aAutoScaleType %d", aAutoScaleType); |
166 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::AddDisplayWindowL - aAutoScaleType %d", aAutoScaleType); |
141 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::AddDisplayWindowL - aHorizPos %d, aVertPos %d", aHorizPos, aVertPos); |
167 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::AddDisplayWindowL - aHorizPos %d, aVertPos %d", aHorizPos, aVertPos); |
142 |
168 |
|
169 if (!IsRotationValid(aRotation)) |
|
170 { |
|
171 User::Leave(KErrArgument); |
|
172 } |
|
173 |
|
174 if (!IsAutoScaleTypeValid(aAutoScaleType)) |
|
175 { |
|
176 User::Leave(KErrArgument); |
|
177 } |
|
178 |
143 TInt pos = iClientWindows.Find(aWindow->WsHandle(), TWindowData::CompareByWsHandle); |
179 TInt pos = iClientWindows.Find(aWindow->WsHandle(), TWindowData::CompareByWsHandle); |
144 |
180 |
145 if (pos != KErrNotFound) |
181 if (pos != KErrNotFound) |
146 { |
182 { |
147 User::Leave(KErrInUse); |
183 User::Leave(KErrInUse); |
150 TWindowData winData(aWindow, aClipRect, aVideoExtent, aScaleWidth, aScaleHeight, aRotation, aAutoScaleType, aHorizPos, aVertPos, aWindow2); |
186 TWindowData winData(aWindow, aClipRect, aVideoExtent, aScaleWidth, aScaleHeight, aRotation, aAutoScaleType, aHorizPos, aVertPos, aWindow2); |
151 iClientWindows.AppendL(winData); |
187 iClientWindows.AppendL(winData); |
152 |
188 |
153 iCropRegion = aCropRegion; |
189 iCropRegion = aCropRegion; |
154 |
190 |
|
191 TBool prevClientWindowIsInFocus = iClientWindowIsInFocus; |
|
192 UpdateFocus(); |
|
193 |
155 if (IsSurfaceCreated()) |
194 if (IsSurfaceCreated()) |
156 { |
195 { |
157 // first client window just added |
196 // if first window was just added OR the new window has moved us from out of focus to in focus |
158 if((iClientWindows.Count() == 1) && iClientRequestedExtDisplaySwitching) |
197 if(((iClientWindows.Count() == 1) || !prevClientWindowIsInFocus) && iClientRequestedExtDisplaySwitching && |
159 { |
198 iClientWindowIsInFocus && iExtDisplayConnected) |
160 if(iExtDisplayConnected) |
199 { |
|
200 TRAPD(err, CreateExtDisplayHandlerL()); |
|
201 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::AddDisplayWindowL CreateExtDisplayHandlerL error %d", err); |
|
202 if(err == KErrNone) |
161 { |
203 { |
162 TRAPD(err, CreateExtDisplayHandlerL()); |
204 SetWindowArrayPtr2Ext(); |
163 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::AddDisplayWindowL CreateExtDisplayHandlerL error %d", err); |
205 User::LeaveIfError(RedrawWindows(aCropRegion)); |
164 if(err == KErrNone) |
|
165 { |
|
166 SetWindowArrayPtr2Ext(); |
|
167 User::LeaveIfError(RedrawWindows(aCropRegion)); |
|
168 } |
|
169 } |
206 } |
170 } |
207 } |
171 |
208 |
172 if(!iExtDisplayConnected || !iExtDisplayHandler) |
209 if(!iSwitchedToExternalDisplay) |
173 { |
210 { |
174 User::LeaveIfError(SetBackgroundSurface(winData, aCropRegion)); |
211 User::LeaveIfError(SetBackgroundSurface(winData, aCropRegion)); |
175 } |
212 } |
176 } |
213 } |
177 DEBUG_PRINTF("CMediaClientVideoDisplayBody::AddDisplayWindowL ---"); |
214 DEBUG_PRINTF("CMediaClientVideoDisplayBody::AddDisplayWindowL ---"); |
313 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SurfaceCreated - aCropRect %d,%d - %d,%d", aCropRect.iTl.iX, aCropRect.iTl.iY, aCropRect.iBr.iX, aCropRect.iBr.iY); |
362 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SurfaceCreated - aCropRect %d,%d - %d,%d", aCropRect.iTl.iX, aCropRect.iTl.iY, aCropRect.iBr.iX, aCropRect.iBr.iY); |
314 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::SurfaceCreated - aAspectRatio %d/%d", aAspectRatio.iNumerator, aAspectRatio.iDenominator); |
363 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::SurfaceCreated - aAspectRatio %d/%d", aAspectRatio.iNumerator, aAspectRatio.iDenominator); |
315 |
364 |
316 if (!IsSurfaceCreated()) |
365 if (!IsSurfaceCreated()) |
317 { |
366 { |
|
367 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SurfaceParametersChanged --- Return error KErrNotSupproted"); |
318 return KErrNotSupported; |
368 return KErrNotSupported; |
319 } |
369 } |
320 |
370 |
321 if (iSurfaceId != aSurfaceId) |
371 if (iSurfaceId != aSurfaceId) |
322 { |
372 { |
|
373 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SurfaceParametersChanged --- Return error KErrInUse"); |
323 return KErrInUse; |
374 return KErrInUse; |
324 } |
375 } |
325 |
376 |
326 iCropRect = aCropRect; |
|
327 iAspectRatio = aAspectRatio; |
|
328 |
|
329 if (iEventHandler) |
377 if (iEventHandler) |
330 { |
378 { |
331 iEventHandler->MmsehSurfaceParametersChanged(iSurfaceId, iCropRect, iAspectRatio); |
379 iEventHandler->MmsehSurfaceParametersChanged(iSurfaceId, aCropRect, aAspectRatio); |
332 } |
380 } |
333 |
381 |
334 RedrawWindows(iCropRegion); |
382 TInt error = KErrNone; |
335 |
383 if (iCropRect != aCropRect || iAspectRatio != aAspectRatio) |
336 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SurfaceParametersChanged ---"); |
384 { |
337 return KErrNone; |
385 // We only need to redraw if the aspect ratio has changed, or the area of the video to |
|
386 // display (i.e the intersection of client crop region and surface crop rectangle) has changed. |
|
387 TBool redraw = EFalse; |
|
388 if (iAspectRatio != aAspectRatio || SurfaceCropRectChangeRequiresRedraw(iCropRect, aCropRect, iCropRegion)) |
|
389 { |
|
390 redraw = ETrue; |
|
391 } |
|
392 |
|
393 iCropRect = aCropRect; |
|
394 iAspectRatio = aAspectRatio; |
|
395 |
|
396 if (redraw) |
|
397 { |
|
398 error = RedrawWindows(iCropRegion); |
|
399 } |
|
400 } |
|
401 else |
|
402 { |
|
403 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SurfaceParametersChanged - Surface parameters have not changed"); |
|
404 } |
|
405 |
|
406 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SurfaceParametersChanged --- Return error %d", error); |
|
407 return error; |
338 } |
408 } |
339 |
409 |
340 TInt CMediaClientVideoDisplayBody::RedrawWindows(const TRect& aCropRegion) |
410 TInt CMediaClientVideoDisplayBody::RedrawWindows(const TRect& aCropRegion) |
341 { |
411 { |
342 DEBUG_PRINTF("CMediaClientVideoDisplayBody::RedrawWindows +++"); |
412 DEBUG_PRINTF("CMediaClientVideoDisplayBody::RedrawWindows +++"); |
393 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetAutoScaleL - aWindow WsHandle 0x%X", aWindow.WsHandle()); |
468 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetAutoScaleL - aWindow WsHandle 0x%X", aWindow.WsHandle()); |
394 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetAutoScaleL - aScaleType %d", aScaleType); |
469 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetAutoScaleL - aScaleType %d", aScaleType); |
395 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::SetAutoScaleL - aHorizPos %d, aVertPos %d", aHorizPos, aVertPos); |
470 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::SetAutoScaleL - aHorizPos %d, aVertPos %d", aHorizPos, aVertPos); |
396 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetAutoScaleL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
471 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetAutoScaleL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
397 |
472 |
|
473 if (!IsAutoScaleTypeValid(aScaleType)) |
|
474 { |
|
475 User::Leave(KErrArgument); |
|
476 } |
|
477 |
398 TInt pos = iClientWindows.Find(aWindow.WsHandle(), TWindowData::CompareByWsHandle); |
478 TInt pos = iClientWindows.Find(aWindow.WsHandle(), TWindowData::CompareByWsHandle); |
399 User::LeaveIfError(pos); |
479 User::LeaveIfError(pos); |
400 |
480 |
401 iClientWindows[pos].iAutoScaleType = aScaleType; |
481 TBool parameterChanged = EFalse; |
402 iClientWindows[pos].iHorizPos = aHorizPos; |
482 if (aScaleType != iClientWindows[pos].iAutoScaleType || aHorizPos != iClientWindows[pos].iHorizPos || aVertPos != iClientWindows[pos].iVertPos) |
403 iClientWindows[pos].iVertPos = aVertPos; |
483 { |
404 |
484 iClientWindows[pos].iAutoScaleType = aScaleType; |
405 UpdateCropRegionL(aCropRegion, pos); |
485 iClientWindows[pos].iHorizPos = aHorizPos; |
406 |
486 iClientWindows[pos].iVertPos = aVertPos; |
|
487 parameterChanged = ETrue; |
|
488 } |
|
489 else |
|
490 { |
|
491 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetAutoScaleL - Scale parameters have not changed"); |
|
492 } |
|
493 |
|
494 UpdateCropRegionL(aCropRegion, pos, parameterChanged); |
|
495 |
407 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetAutoScaleL ---"); |
496 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetAutoScaleL ---"); |
408 } |
497 } |
409 |
498 |
410 |
499 |
411 void CMediaClientVideoDisplayBody::SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion) |
500 void CMediaClientVideoDisplayBody::SetRotationL(const RWindowBase& aWindow, TVideoRotation aRotation, const TRect& aCropRegion) |
413 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetRotationL +++"); |
502 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetRotationL +++"); |
414 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetRotationL - aWindow WsHandle 0x%X", aWindow.WsHandle()); |
503 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetRotationL - aWindow WsHandle 0x%X", aWindow.WsHandle()); |
415 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetRotationL - aRotation %d", aRotation); |
504 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetRotationL - aRotation %d", aRotation); |
416 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetRotationL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
505 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetRotationL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
417 |
506 |
|
507 if (!IsRotationValid(aRotation)) |
|
508 { |
|
509 User::Leave(KErrArgument); |
|
510 } |
|
511 |
418 TInt pos = iClientWindows.Find(aWindow.WsHandle(), TWindowData::CompareByWsHandle); |
512 TInt pos = iClientWindows.Find(aWindow.WsHandle(), TWindowData::CompareByWsHandle); |
419 User::LeaveIfError(pos); |
513 User::LeaveIfError(pos); |
420 |
514 |
421 iClientWindows[pos].iRotation = aRotation; |
515 TBool parameterChanged = EFalse; |
422 |
516 if (aRotation != iClientWindows[pos].iRotation) |
423 UpdateCropRegionL(aCropRegion, pos); |
517 { |
|
518 iClientWindows[pos].iRotation = aRotation; |
|
519 parameterChanged = ETrue; |
|
520 } |
|
521 else |
|
522 { |
|
523 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetRotationL - Rotation has not changed"); |
|
524 } |
|
525 |
|
526 UpdateCropRegionL(aCropRegion, pos, parameterChanged); |
424 |
527 |
425 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetRotationL ---"); |
528 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetRotationL ---"); |
426 } |
529 } |
427 |
530 |
428 TVideoRotation CMediaClientVideoDisplayBody::RotationL(const RWindowBase& aWindow) |
531 TVideoRotation CMediaClientVideoDisplayBody::RotationL(const RWindowBase& aWindow) |
474 { |
588 { |
475 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetAutoScaleL +++"); |
589 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetAutoScaleL +++"); |
476 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetAutoScaleL - aScaleType %d", aScaleType); |
590 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetAutoScaleL - aScaleType %d", aScaleType); |
477 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::SetAutoScaleL - aHorizPos %d, aVertPos %d", aHorizPos, aVertPos); |
591 DEBUG_PRINTF3("CMediaClientVideoDisplayBody::SetAutoScaleL - aHorizPos %d, aVertPos %d", aHorizPos, aVertPos); |
478 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetAutoScaleL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
592 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetAutoScaleL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
479 |
593 |
|
594 if (!IsAutoScaleTypeValid(aScaleType)) |
|
595 { |
|
596 User::Leave(KErrArgument); |
|
597 } |
|
598 |
480 TRect prevCropRegion(iCropRegion); |
599 TRect prevCropRegion(iCropRegion); |
481 iCropRegion = aCropRegion; |
600 iCropRegion = aCropRegion; |
|
601 |
|
602 TBool parameterChanged; |
482 TInt count = iClientWindows.Count(); |
603 TInt count = iClientWindows.Count(); |
483 |
604 |
484 for (TInt i = 0; i < count; ++i) |
605 for (TInt i = 0; i < count; ++i) |
485 { |
606 { |
486 iClientWindows[i].iAutoScaleType = aScaleType; |
607 parameterChanged = EFalse; |
487 iClientWindows[i].iHorizPos = aHorizPos; |
608 if (aScaleType != iClientWindows[i].iAutoScaleType || aHorizPos != iClientWindows[i].iHorizPos || aVertPos != iClientWindows[i].iVertPos) |
488 iClientWindows[i].iVertPos = aVertPos; |
609 { |
489 if (IsSurfaceCreated() && (!iExtDisplayConnected || !iExtDisplayHandler)) |
610 iClientWindows[i].iAutoScaleType = aScaleType; |
|
611 iClientWindows[i].iHorizPos = aHorizPos; |
|
612 iClientWindows[i].iVertPos = aVertPos; |
|
613 parameterChanged = ETrue; |
|
614 } |
|
615 else |
|
616 { |
|
617 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetAutoScaleL - Scale parameters for window pos %d have not changed", i); |
|
618 } |
|
619 |
|
620 // We only need to redraw if the scale parameters have changed, or the area of the video |
|
621 // to display (i.e the intersection of client crop region and surface crop rectangle) has changed. |
|
622 if (IsSurfaceCreated() && !iSwitchedToExternalDisplay && (parameterChanged || ClientCropRegionChangeRequiresRedraw(prevCropRegion, aCropRegion, iCropRect))) |
490 { |
623 { |
491 User::LeaveIfError(SetBackgroundSurface(iClientWindows[i], aCropRegion)); |
624 User::LeaveIfError(SetBackgroundSurface(iClientWindows[i], aCropRegion)); |
492 } |
625 } |
493 } |
626 } |
494 |
627 |
495 if (IsSurfaceCreated() && iExtDisplayConnected && iExtDisplayHandler && (aCropRegion != prevCropRegion)) |
628 // We only need to redraw if the area of the video to display (i.e the |
|
629 // intersection of client crop region and surface crop rectangle) has changed. |
|
630 if (IsSurfaceCreated() && iSwitchedToExternalDisplay && ClientCropRegionChangeRequiresRedraw(prevCropRegion, aCropRegion, iCropRect)) |
496 { |
631 { |
497 User::LeaveIfError(RedrawWindows(aCropRegion)); |
632 User::LeaveIfError(RedrawWindows(aCropRegion)); |
498 } |
633 } |
499 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetAutoScaleL ---"); |
634 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetAutoScaleL ---"); |
500 } |
635 } |
504 { |
639 { |
505 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetRotationL +++"); |
640 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetRotationL +++"); |
506 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetRotationL - aRotation %d", aRotation); |
641 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetRotationL - aRotation %d", aRotation); |
507 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetRotationL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
642 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetRotationL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
508 |
643 |
|
644 if (!IsRotationValid(aRotation)) |
|
645 { |
|
646 User::Leave(KErrArgument); |
|
647 } |
|
648 |
509 TRect prevCropRegion(iCropRegion); |
649 TRect prevCropRegion(iCropRegion); |
510 iCropRegion = aCropRegion; |
650 iCropRegion = aCropRegion; |
|
651 |
|
652 TBool parameterChanged; |
511 TInt count = iClientWindows.Count(); |
653 TInt count = iClientWindows.Count(); |
512 |
654 |
513 for (TInt i = 0; i < count; ++i) |
655 for (TInt i = 0; i < count; ++i) |
514 { |
656 { |
515 iClientWindows[i].iRotation = aRotation; |
657 parameterChanged = EFalse; |
516 if (IsSurfaceCreated() && (!iExtDisplayConnected || !iExtDisplayHandler)) |
658 if (aRotation != iClientWindows[i].iRotation) |
|
659 { |
|
660 iClientWindows[i].iRotation = aRotation; |
|
661 parameterChanged = ETrue; |
|
662 } |
|
663 else |
|
664 { |
|
665 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetRotationL - Rotation for window pos %d has not changed", i); |
|
666 } |
|
667 |
|
668 // We only need to redraw if the scale parameters have changed, or the area of the video |
|
669 // to display (i.e the intersection of client crop region and surface crop rectangle) has changed. |
|
670 if (IsSurfaceCreated() && !iSwitchedToExternalDisplay && (parameterChanged || ClientCropRegionChangeRequiresRedraw(prevCropRegion, aCropRegion, iCropRect))) |
517 { |
671 { |
518 User::LeaveIfError(SetBackgroundSurface(iClientWindows[i], aCropRegion)); |
672 User::LeaveIfError(SetBackgroundSurface(iClientWindows[i], aCropRegion)); |
519 } |
673 } |
520 } |
674 } |
521 |
675 |
522 if (IsSurfaceCreated() && iExtDisplayConnected && iExtDisplayHandler && (aCropRegion != prevCropRegion)) |
676 // We only need to redraw if the area of the video to display (i.e the |
|
677 // intersection of client crop region and surface crop rectangle) has changed. |
|
678 if (IsSurfaceCreated() && iSwitchedToExternalDisplay && ClientCropRegionChangeRequiresRedraw(prevCropRegion, aCropRegion, iCropRect)) |
523 { |
679 { |
524 User::LeaveIfError(RedrawWindows(aCropRegion)); |
680 User::LeaveIfError(RedrawWindows(aCropRegion)); |
525 } |
681 } |
526 |
682 |
527 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetRotationL ---"); |
683 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetRotationL ---"); |
538 User::Leave(KErrArgument); |
694 User::Leave(KErrArgument); |
539 } |
695 } |
540 |
696 |
541 TRect prevCropRegion(iCropRegion); |
697 TRect prevCropRegion(iCropRegion); |
542 iCropRegion = aCropRegion; |
698 iCropRegion = aCropRegion; |
|
699 |
|
700 TBool parameterChanged; |
543 TInt count = iClientWindows.Count(); |
701 TInt count = iClientWindows.Count(); |
544 |
702 |
545 for (TInt i = 0; i < count; ++i) |
703 for (TInt i = 0; i < count; ++i) |
546 { |
704 { |
547 iClientWindows[i].iScaleWidth = aWidthPercentage; |
705 parameterChanged = EFalse; |
548 iClientWindows[i].iScaleHeight = aHeightPercentage; |
706 |
549 iClientWindows[i].iAutoScaleType = EAutoScaleNone; |
707 if (aWidthPercentage != iClientWindows[i].iScaleWidth || |
550 if (IsSurfaceCreated() && (!iExtDisplayConnected || !iExtDisplayHandler)) |
708 aHeightPercentage != iClientWindows[i].iScaleHeight || |
|
709 EAutoScaleNone != iClientWindows[i].iAutoScaleType) |
|
710 { |
|
711 iClientWindows[i].iScaleWidth = aWidthPercentage; |
|
712 iClientWindows[i].iScaleHeight = aHeightPercentage; |
|
713 iClientWindows[i].iAutoScaleType = EAutoScaleNone; |
|
714 parameterChanged = ETrue; |
|
715 } |
|
716 else |
|
717 { |
|
718 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SetScaleFactorL - Scale parameters for window pos %d have not changed", i); |
|
719 } |
|
720 |
|
721 // We only need to redraw if the scale parameters have changed, or the area of the video to |
|
722 // display (i.e the intersection of client crop region and surface crop rectangle) has changed. |
|
723 if (IsSurfaceCreated() && !iSwitchedToExternalDisplay && (parameterChanged || ClientCropRegionChangeRequiresRedraw(prevCropRegion, aCropRegion, iCropRect))) |
551 { |
724 { |
552 User::LeaveIfError(SetBackgroundSurface(iClientWindows[i], aCropRegion)); |
725 User::LeaveIfError(SetBackgroundSurface(iClientWindows[i], aCropRegion)); |
553 } |
726 } |
554 } |
727 } |
555 |
728 |
556 if (IsSurfaceCreated() && iExtDisplayConnected && iExtDisplayHandler && (aCropRegion != prevCropRegion)) |
729 // We only need to redraw if the area of the video to display (i.e the |
|
730 // intersection of client crop region and surface crop rectangle) has changed. |
|
731 if (IsSurfaceCreated() && iSwitchedToExternalDisplay && ClientCropRegionChangeRequiresRedraw(prevCropRegion, aCropRegion, iCropRect)) |
557 { |
732 { |
558 User::LeaveIfError(RedrawWindows(aCropRegion)); |
733 User::LeaveIfError(RedrawWindows(aCropRegion)); |
559 } |
734 } |
560 |
735 |
561 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetScaleFactorL ---"); |
736 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetScaleFactorL ---"); |
568 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetWindowClipRectL - aWindowClipRect %d,%d - %d,%d", aWindowClipRect.iTl.iX, aWindowClipRect.iTl.iY, aWindowClipRect.iBr.iX, aWindowClipRect.iBr.iY); |
743 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetWindowClipRectL - aWindowClipRect %d,%d - %d,%d", aWindowClipRect.iTl.iX, aWindowClipRect.iTl.iY, aWindowClipRect.iBr.iX, aWindowClipRect.iBr.iY); |
569 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetWindowClipRectL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
744 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetWindowClipRectL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
570 |
745 |
571 TInt pos = iClientWindows.Find(aWindow.WsHandle(), TWindowData::CompareByWsHandle); |
746 TInt pos = iClientWindows.Find(aWindow.WsHandle(), TWindowData::CompareByWsHandle); |
572 User::LeaveIfError(pos); |
747 User::LeaveIfError(pos); |
573 |
748 |
574 iClientWindows[pos].iClipRect = aWindowClipRect; |
749 TBool parameterChanged = EFalse; |
575 |
750 if (aWindowClipRect != iClientWindows[pos].iClipRect) |
576 UpdateCropRegionL(aCropRegion, pos); |
751 { |
|
752 // We only want to redraw if the change in the clipping rectangle would result |
|
753 // in a change to the area of the display used for the video. |
|
754 // The video is always displayed in the intersection of the clipping rectangle |
|
755 // and the video extent, so check if this has changed. |
|
756 parameterChanged = IntersectionAreaChanged(iClientWindows[pos].iClipRect, aWindowClipRect, iClientWindows[pos].iVideoExtent); |
|
757 |
|
758 iClientWindows[pos].iClipRect = aWindowClipRect; |
|
759 } |
|
760 else |
|
761 { |
|
762 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetWindowClipRectL - Clip rect parameter has not changed"); |
|
763 } |
|
764 |
|
765 UpdateCropRegionL(aCropRegion, pos, parameterChanged); |
577 |
766 |
578 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetWindowClipRectL ---"); |
767 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetWindowClipRectL ---"); |
579 } |
768 } |
580 |
769 |
581 void CMediaClientVideoDisplayBody::SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion) |
770 void CMediaClientVideoDisplayBody::SetVideoExtentL(const RWindowBase& aWindow, const TRect& aVideoExtent, const TRect& aCropRegion) |
585 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetVideoExtentL - aVideoExtent %d,%d - %d,%d", aVideoExtent.iTl.iX, aVideoExtent.iTl.iY, aVideoExtent.iBr.iX, aVideoExtent.iBr.iY); |
774 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetVideoExtentL - aVideoExtent %d,%d - %d,%d", aVideoExtent.iTl.iX, aVideoExtent.iTl.iY, aVideoExtent.iBr.iX, aVideoExtent.iBr.iY); |
586 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetVideoExtentL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
775 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::SetVideoExtentL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY); |
587 |
776 |
588 TInt pos = iClientWindows.Find(aWindow.WsHandle(), TWindowData::CompareByWsHandle); |
777 TInt pos = iClientWindows.Find(aWindow.WsHandle(), TWindowData::CompareByWsHandle); |
589 User::LeaveIfError(pos); |
778 User::LeaveIfError(pos); |
590 |
779 |
591 iClientWindows[pos].iVideoExtent = aVideoExtent; |
780 TBool parameterChanged = EFalse; |
592 |
781 if (aVideoExtent != iClientWindows[pos].iVideoExtent) |
593 UpdateCropRegionL(aCropRegion, pos); |
782 { |
|
783 iClientWindows[pos].iVideoExtent = aVideoExtent; |
|
784 parameterChanged = ETrue; |
|
785 } |
|
786 else |
|
787 { |
|
788 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetVideoExtentL - Video extent parameter has not changed"); |
|
789 } |
|
790 |
|
791 UpdateCropRegionL(aCropRegion, pos, parameterChanged); |
594 |
792 |
595 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetVideoExtentL ---"); |
793 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SetVideoExtentL ---"); |
596 } |
794 } |
597 |
795 |
598 TBool CMediaClientVideoDisplayBody::HasWindows() const |
796 TBool CMediaClientVideoDisplayBody::HasWindows() const |
1134 iExtDisplaySwitchingSupported = EFalse; |
1288 iExtDisplaySwitchingSupported = EFalse; |
1135 iExtDisplayConnected = EFalse; |
1289 iExtDisplayConnected = EFalse; |
1136 } |
1290 } |
1137 DEBUG_PRINTF("CMediaClientVideoDisplayBody::RemoveExtDisplayPlugin ---"); |
1291 DEBUG_PRINTF("CMediaClientVideoDisplayBody::RemoveExtDisplayPlugin ---"); |
1138 } |
1292 } |
|
1293 |
|
1294 void CMediaClientVideoDisplayBody::MmcweoFocusWindowGroupChanged() |
|
1295 { |
|
1296 DEBUG_PRINTF("CMediaClientVideoDisplayBody::MweocFocusWindowGroupChanged +++"); |
|
1297 |
|
1298 TBool prevClientWindowIsInFocus = iClientWindowIsInFocus; |
|
1299 UpdateFocus(); |
|
1300 |
|
1301 if(prevClientWindowIsInFocus != iClientWindowIsInFocus) |
|
1302 { |
|
1303 SwitchSurface(); |
|
1304 } |
|
1305 |
|
1306 DEBUG_PRINTF("CMediaClientVideoDisplayBody::MweocFocusWindowGroupChanged ---"); |
|
1307 } |
|
1308 |
|
1309 TBool CMediaClientVideoDisplayBody::MmcweoIgnoreProcess(TSecureId aId) |
|
1310 { |
|
1311 DEBUG_PRINTF("CMediaClientVideoDisplayBody::MmcweoIgnoreProcess +++"); |
|
1312 |
|
1313 TBool ignore = ETrue; |
|
1314 if (iServerClient) |
|
1315 { |
|
1316 ignore = iServerClient->IgnoreProcess(aId); |
|
1317 } |
|
1318 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::MmcweoIgnoreProcess --- return %d", ignore); |
|
1319 return ignore; |
|
1320 } |
|
1321 |
|
1322 void CMediaClientVideoDisplayBody::UpdateFocus() |
|
1323 { |
|
1324 DEBUG_PRINTF("CMediaClientVideoDisplayBody::UpdateFocus +++"); |
|
1325 |
|
1326 if(!iWsEventObserver) |
|
1327 { |
|
1328 iClientWindowIsInFocus = ETrue; |
|
1329 DEBUG_PRINTF("CMediaClientVideoDisplayBody::UpdateFocus Event Observer is NULL"); |
|
1330 DEBUG_PRINTF("CMediaClientVideoDisplayBody::UpdateFocus ---"); |
|
1331 return; |
|
1332 } |
|
1333 |
|
1334 TBool prevClientWindowIsInFocus = iClientWindowIsInFocus; |
|
1335 |
|
1336 TInt focusGroupId; |
|
1337 if(iWsEventObserver->FocusWindowGroupId(focusGroupId) == KErrNone) |
|
1338 { |
|
1339 iClientWindowIsInFocus = EFalse; |
|
1340 TInt count = iClientWindows.Count(); |
|
1341 for(TInt i = 0; i < count; i++) |
|
1342 { |
|
1343 if(iClientWindows[i].iWindow->WindowGroupId() == focusGroupId) |
|
1344 { |
|
1345 iClientWindowIsInFocus = ETrue; |
|
1346 break; |
|
1347 } |
|
1348 } |
|
1349 } |
|
1350 else |
|
1351 { |
|
1352 DEBUG_PRINTF("CMediaClientVideoDisplayBody::UpdateFocus Error retrieving focus WgId from observer"); |
|
1353 iClientWindowIsInFocus = ETrue; |
|
1354 } |
|
1355 |
|
1356 if(iServerClient && (prevClientWindowIsInFocus != iClientWindowIsInFocus)) |
|
1357 { |
|
1358 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::MweocFocusWindowGroupChanged calling server, focus %d", iClientWindowIsInFocus); |
|
1359 iServerClient->FocusChanged(iClientWindowIsInFocus); |
|
1360 } |
|
1361 |
|
1362 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::UpdateFocus Client window in focus %d", iClientWindowIsInFocus); |
|
1363 DEBUG_PRINTF("CMediaClientVideoDisplayBody::UpdateFocus ---"); |
|
1364 } |
|
1365 |
|
1366 void CMediaClientVideoDisplayBody::SwitchSurface() |
|
1367 { |
|
1368 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SwitchSurface +++"); |
|
1369 |
|
1370 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SwitchSurface SurfaceCreated %d", IsSurfaceCreated()); |
|
1371 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SwitchSurface Client window count %d", iClientWindows.Count()); |
|
1372 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SwitchSurface Client Requested Ext Display Switching %d", iClientRequestedExtDisplaySwitching); |
|
1373 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SwitchSurface Client Window in Focus %d", iClientWindowIsInFocus); |
|
1374 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SwitchSurface External Display Connected %d", iExtDisplayConnected); |
|
1375 |
|
1376 if(IsSurfaceCreated() && (iClientWindows.Count() > 0) && iClientRequestedExtDisplaySwitching && |
|
1377 iClientWindowIsInFocus && iExtDisplayConnected) |
|
1378 { |
|
1379 TRAPD(err, CreateExtDisplayHandlerL()); |
|
1380 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SwitchSurface CreateExtDisplayHandlerL error %d", err); |
|
1381 if(err == KErrNone) |
|
1382 { |
|
1383 // Set background surface for external display window before removing from client windows. |
|
1384 // Required for switching of paused video |
|
1385 SetWindowArrayPtr2Ext(); |
|
1386 RedrawWindows(iCropRegion); |
|
1387 SetWindowArrayPtr2Client(); |
|
1388 RemoveBackgroundSurface(ETrue); |
|
1389 SetWindowArrayPtr2Ext(); |
|
1390 } |
|
1391 } |
|
1392 else if(iSwitchedToExternalDisplay) |
|
1393 { |
|
1394 // Set background surface for clientwindows before removing from external display window. |
|
1395 // Required for switching of paused video |
|
1396 SetWindowArrayPtr2Client(); |
|
1397 RedrawWindows(iCropRegion); |
|
1398 SetWindowArrayPtr2Ext(); |
|
1399 RemoveBackgroundSurface(ETrue); |
|
1400 RemoveExtDisplayHandler(); |
|
1401 SetWindowArrayPtr2Client(); |
|
1402 } |
|
1403 |
|
1404 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SwitchSurface ---"); |
|
1405 } |
|
1406 |
|
1407 TBool CMediaClientVideoDisplayBody::IsRotationValid(TVideoRotation aVideoRotation) |
|
1408 { |
|
1409 if (aVideoRotation == EVideoRotationNone || |
|
1410 aVideoRotation == EVideoRotationClockwise90 || |
|
1411 aVideoRotation == EVideoRotationClockwise180 || |
|
1412 aVideoRotation == EVideoRotationClockwise270) |
|
1413 { |
|
1414 return ETrue; |
|
1415 } |
|
1416 |
|
1417 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::IsRotationValid - Rotation %d not valid", aVideoRotation); |
|
1418 return EFalse; |
|
1419 } |
|
1420 |
|
1421 TBool CMediaClientVideoDisplayBody::IsAutoScaleTypeValid(TAutoScaleType aAutoScaleType) |
|
1422 { |
|
1423 if (aAutoScaleType == EAutoScaleNone || |
|
1424 aAutoScaleType == EAutoScaleBestFit || |
|
1425 aAutoScaleType == EAutoScaleClip || |
|
1426 aAutoScaleType == EAutoScaleStretch) |
|
1427 { |
|
1428 return ETrue; |
|
1429 } |
|
1430 |
|
1431 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::IsAutoScaleTypeValid - Auto scale %d not valid", aAutoScaleType); |
|
1432 return EFalse; |
|
1433 } |
|
1434 |
|
1435 /** |
|
1436 Check whether a change in the surface crop rectangle would mean that the surface viewport calculated in SetBackgroundSurface would change. |
|
1437 The surface viewport is the intersection of the surface crop rectangle and the client crop region |
|
1438 */ |
|
1439 TBool CMediaClientVideoDisplayBody::SurfaceCropRectChangeRequiresRedraw(TRect aOldSurfaceCropRect, TRect aNewSurfaceCropRect, TRect aClientCropRegion) |
|
1440 { |
|
1441 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SurfaceCropRectChangeRequiresRedraw +++"); |
|
1442 |
|
1443 // If aClientCropRegion is empty then it is not currently being used in the SetBackgroundSurface calculations. |
|
1444 // This means that only aOldSurfaceCropRect is being used to decide which part of the video is displayed. |
|
1445 // By setting aClientCropRect to the same as aOldSurfaceCropRect we ensure that only aOldSurfaceCropRect is |
|
1446 // used in the subsequent intersection area checks. |
|
1447 if (aClientCropRegion.IsEmpty()) |
|
1448 { |
|
1449 DEBUG_PRINTF("CMediaClientVideoDisplayBody::SurfaceCropRectChangeRequiresRedraw - Client crop region is empty"); |
|
1450 aClientCropRegion = aOldSurfaceCropRect; |
|
1451 } |
|
1452 |
|
1453 TBool ret = IntersectionAreaChanged(aOldSurfaceCropRect, aNewSurfaceCropRect, aClientCropRegion); |
|
1454 |
|
1455 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::SurfaceCropRectChangeRequiresRedraw --- ret = %d", ret); |
|
1456 |
|
1457 return ret; |
|
1458 } |
|
1459 |
|
1460 /** |
|
1461 Check whether a change in the client crop region would mean that the surface viewport calculated in SetBackgroundSurface would change. |
|
1462 The surface viewport is the intersection of the surface crop rectangle and the client crop region |
|
1463 */ |
|
1464 TBool CMediaClientVideoDisplayBody::ClientCropRegionChangeRequiresRedraw(TRect aOldClientCropRegion, TRect aNewClientCropRegion, TRect aSurfaceCropRect) |
|
1465 { |
|
1466 DEBUG_PRINTF("CMediaClientVideoDisplayBody::ClientCropRegionChangeRequiresRedraw +++"); |
|
1467 |
|
1468 // If aOldClientCropRegion is empty then it is not currently being used in the SetBackgroundSurface calculations. |
|
1469 // This means that only aSurfaceCropRect is being used to decide which part of the video is displayed. By |
|
1470 // setting aOldClientCropRegion to the same as aSurfaceCropRect we ensure that only aSurfaceCropRect is |
|
1471 // used in the subsequent intersection area checks. |
|
1472 if (aOldClientCropRegion.IsEmpty()) |
|
1473 { |
|
1474 DEBUG_PRINTF("CMediaClientVideoDisplayBody::ClientCropRegionChangeRequiresRedraw - Old client crop region is empty"); |
|
1475 aOldClientCropRegion = aSurfaceCropRect; |
|
1476 } |
|
1477 |
|
1478 // If aNewClientCropRegion is empty then it will not be used in the SetBackgroundSurface calculations. |
|
1479 // This means that only aSurfaceCropRect will impact which part of the video is displayed. By |
|
1480 // setting aNewClientCropRegion to the same as aSurfaceCropRect we ensure that only aSurfaceCropRect is |
|
1481 // used in the subsequent intersection area checks. |
|
1482 if (aNewClientCropRegion.IsEmpty()) |
|
1483 { |
|
1484 DEBUG_PRINTF("CMediaClientVideoDisplayBody::ClientCropRegionChangeRequiresRedraw - New client crop region is empty"); |
|
1485 aNewClientCropRegion = aSurfaceCropRect; |
|
1486 } |
|
1487 |
|
1488 TBool ret = IntersectionAreaChanged(aOldClientCropRegion, aNewClientCropRegion, aSurfaceCropRect); |
|
1489 |
|
1490 DEBUG_PRINTF2("CMediaClientVideoDisplayBody::ClientCropRegionChangeRequiresRedraw --- ret = %d", ret); |
|
1491 |
|
1492 return ret; |
|
1493 } |
|
1494 |
|
1495 /** |
|
1496 Check whether the change in size of a rectangle means its intersection with another rectangle has changed. |
|
1497 This is used to check whether changes in things like the surface crop rectangle, client crop region, and window clip rectangle, would mean |
|
1498 the area of video displayed would change. |
|
1499 */ |
|
1500 TBool CMediaClientVideoDisplayBody::IntersectionAreaChanged(TRect aOldRect, TRect aNewRect, TRect aOtherRect) |
|
1501 { |
|
1502 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::IntersectionAreaChanged - aOldRect %d,%d - %d,%d", aOldRect.iTl.iX, aOldRect.iTl.iY, aOldRect.iBr.iX, aOldRect.iBr.iY); |
|
1503 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::IntersectionAreaChanged - aNewRect %d,%d - %d,%d", aNewRect.iTl.iX, aNewRect.iTl.iY, aNewRect.iBr.iX, aNewRect.iBr.iY); |
|
1504 DEBUG_PRINTF5("CMediaClientVideoDisplayBody::IntersectionAreaChanged - aOtherRect %d,%d - %d,%d", aOtherRect.iTl.iX, aOtherRect.iTl.iY, aOtherRect.iBr.iX, aOtherRect.iBr.iY); |
|
1505 |
|
1506 aOldRect.Intersection(aOtherRect); |
|
1507 aNewRect.Intersection(aOtherRect); |
|
1508 |
|
1509 if (aOldRect != aNewRect) |
|
1510 { |
|
1511 DEBUG_PRINTF("CMediaClientVideoDisplayBody::IntersectionAreaChanged - Intersection area has changed"); |
|
1512 return ETrue; |
|
1513 } |
|
1514 |
|
1515 DEBUG_PRINTF("CMediaClientVideoDisplayBody::IntersectionAreaChanged - Intersection area has not changed"); |
|
1516 return EFalse; |
|
1517 } |