Ticket #6211: fix.QuartzOutput-0.23-r24879.patch
File fix.QuartzOutput-0.23-r24879.patch, 14.8 KB (added by , 15 years ago) |
---|
-
mythtv/libs/libmythtv/videoout_quartz.cpp
diff --git a/mythtv/libs/libmythtv/videoout_quartz.cpp b/mythtv/libs/libmythtv/videoout_quartz.cpp index 458f15a..d43d5eb 100644
a b class VideoOutputQuartzView 86 86 virtual void Show(void); 87 87 88 88 virtual void InputChanged(int width, int height, float aspect, 89 89 MythCodecID av_codec_id); 90 virtual void MoveResize( QRect newRect);90 virtual void MoveResize(); 91 91 92 92 virtual void EmbedChanged(bool embedded); 93 93 94 94 protected: 95 95 virtual bool Begin(void); 96 96 virtual void End(void); 97 virtual void Transform( QRect newRect);97 virtual void Transform(); 98 98 virtual void BlankScreen(bool deferred); 99 99 100 100 // Subclasses implement the following methods: 101 101 virtual bool BeginPort(void) = 0; // Set up a valid thePort object … … class VideoOutputQuartzView 105 105 106 106 QuartzData * parentData; // information about video source is here 107 107 108 108 CGrafPtr thePort; // QuickDraw graphics port 109 QRect m_desired; // Desired output size characteristics110 109 ImageSequence theCodec; // QuickTime sequence ID 111 110 RgnHandle theMask; // clipping region 112 111 113 112 int frameSkip; // do we skip frames? … … class QuartzData 178 177 WindowRef window; // MythTV window 179 178 Rect windowBounds; // dimensions, to restore size later 180 179 CGDirectDisplayID screen; // screen containing main window 181 180 float refreshRate; // for screen above 181 QRect display_rect; 182 182 183 183 // Global preferences: 184 184 bool drawInWindow; // Fullscreen or in GUI view? 185 185 bool windowedMode; // GUI runs in window? … … bool VideoOutputQuartzView::Begin(void) 221 221 viewLock.unlock(); 222 222 return false; 223 223 } 224 224 225 // Set initial output size226 Rect portBounds;227 GetPortBounds(thePort, &portBounds);228 VERBOSE(VB_PLAYBACK, QString("%0Viewport currently %1,%2 -> %3,%4")229 .arg(name).arg(portBounds.left).arg(portBounds.top)230 .arg(portBounds.right).arg(portBounds.bottom));231 m_desired.setWidth(portBounds.right);232 m_desired.setHeight(portBounds.bottom);233 225 #if 0 234 226 // The clipping mask 235 227 theMask = NewRgn(); 236 228 SetRectRgn(theMask, m_desired.left(), m_desired.top(), … … bool VideoOutputQuartzView::Begin(void) 269 261 codecDSequenceFlushInsteadOfDirtying); 270 262 viewLock.unlock(); 271 263 272 264 // set transformation matrix 273 Transform( m_desired);265 Transform(); 274 266 275 267 return true; 276 268 } 277 269 … … void VideoOutputQuartzView::End(void) 293 285 viewLock.unlock(); 294 286 } 295 287 296 288 /// Build the transformation matrix to scale the video appropriately. 297 void VideoOutputQuartzView::Transform( QRect newRect)289 void VideoOutputQuartzView::Transform() 298 290 { 299 291 MatrixRecord matrix; 300 292 SetIdentityMatrix(&matrix); 301 293 302 int x, y, w, h, sw, sh; 303 x = newRect.left(); 304 y = newRect.top(); 305 w = newRect.width(); 306 h = newRect.height(); 307 sw = parentData->srcWidth; 308 sh = parentData->srcHeight; 309 310 // constants for transformation operations 311 Fixed one, zero; 312 one = Long2Fix(1); 313 zero = Long2Fix(0); 314 315 VERBOSE(VB_PLAYBACK, QString("%0Viewport is %1 x %2") 316 .arg(name).arg(w).arg(h)); 317 VERBOSE(VB_PLAYBACK, QString("%0Image is %1 x %2") 318 .arg(name).arg(sw).arg(sh)); 319 320 double hscale = (double) w / sw; 321 double vscale = (double) h / sh; 322 323 // cap zooming if we requested it 324 if (!parentData->scaleUpVideo) 325 { 326 double maxScale = fmax(hscale, vscale); 327 hscale /= maxScale; 328 vscale /= maxScale; 329 } 294 Rect Rsrc, Rdst; 295 QRect display_rect; 330 296 331 if ((hscale < 0.99) || (hscale > 1.01) || 332 (vscale < 0.99) || (vscale > 1.01)) 333 { 334 VERBOSE(VB_PLAYBACK, QString("%0Scaling to %1 x %2 of original") 335 .arg(name).arg(hscale).arg(vscale)); 336 ScaleMatrix(&matrix, 337 X2Fix(hscale), 338 X2Fix(vscale), 339 zero, zero); 297 Rsrc.left = 0; 298 Rsrc.top = 0; 299 Rsrc.right = parentData->srcWidth; 300 Rsrc.bottom = parentData->srcHeight; 340 301 341 // reset sw, sh for new apparent width/height 342 sw = (int)(sw * hscale); 343 sh = (int)(sh * vscale); 344 } 302 display_rect= parentData->display_rect; 303 Rdst.left = display_rect.left(); 304 Rdst.top = display_rect.top(); 305 Rdst.right = display_rect.right(); 306 Rdst.bottom = display_rect.bottom(); 345 307 346 // center image in viewport 347 if ((h != sh) || (w != sw)) 348 { 349 VERBOSE(VB_PLAYBACK, QString("%0Centering with %1, %2") 350 .arg(name).arg((w - sw)/2.0).arg((h - sh)/2.0)); 351 TranslateMatrix(&matrix, X2Fix((w - sw) / 2.0), X2Fix((h - sh) / 2.0)); 352 } 353 354 // apply the basic sizing to DVDV 355 #ifdef USING_DVDV 356 if (parentData->dvdv) 357 { 358 parentData->dvdv->MoveResize( 359 0, 0, parentData->srcWidth, parentData->srcHeight, 360 (int)((w - sw) / 2.0), (int)((h - sh) / 2.0), sw, sh); 361 } 362 #endif // USING_DVDV 363 364 // apply graphics port or embedding offset 365 if (x || y) 366 { 367 VERBOSE(VB_PLAYBACK, QString("%0Translating to %1, %2") 368 .arg(name).arg(x).arg(y)); 369 TranslateMatrix(&matrix, Long2Fix(x), Long2Fix(y)); 370 } 371 372 // Apply the transformation 308 MapMatrix(&matrix, &Rsrc, &Rdst); 309 #if 0 310 VERBOSE(VB_PLAYBACK, QString("%0Viewport is now %1 / %2 / %3 / %4") 311 .arg(name) 312 .arg(Rdst.left) 313 .arg(Rdst.top) 314 .arg(Rdst.right) 315 .arg(Rdst.bottom) 316 ); 317 #endif 373 318 viewLock.lock(); 374 319 SetDSequenceMatrix(theCodec, &matrix); 375 320 viewLock.unlock(); 376 321 BlankScreen(true); // clean up screen of artifacts at next Show … … void VideoOutputQuartzView::BlankScreen(bool deferred) 387 332 viewLock.lock(); 388 333 if (thePort) 389 334 { 390 335 SetPort(thePort); 391 336 #if 0 392 337 // set clipping rectangle 393 338 Rect clipRect; 394 339 if (m_desired.width() && m_desired.height()) 395 340 { … … void VideoOutputQuartzView::BlankScreen(bool deferred) 401 346 else 402 347 { 403 348 GetPortBounds(thePort, &clipRect); 404 349 } 350 #endif 351 Rect clipRect; 352 GetPortBounds(thePort, &clipRect); 353 405 354 RgnHandle clipRgn = NewRgn(); 406 355 RectRgn(clipRgn, &clipRect); 407 356 408 357 // erase our rectangle to black … … void VideoOutputQuartzView::InputChanged(int width, int height, float aspect, 471 420 End(); 472 421 Begin(); 473 422 } 474 423 475 void VideoOutputQuartzView::MoveResize( QRect newRect)424 void VideoOutputQuartzView::MoveResize() 476 425 { 477 426 if (applyMoveResize) 478 Transform( newRect);427 Transform(); 479 428 } 480 429 481 430 /// Subclasses that block the main window should suspend 482 431 /// playback, hide windows, etc by overriding this method. … … class VoqvEmbedded : public VideoOutputQuartzView 575 524 public: 576 525 VoqvEmbedded(QuartzData *pData, int x, int y, int w, int h) 577 526 : VideoOutputQuartzView(pData) 578 527 { 579 m_desired = QRect(x, y, w, h);528 // m_desired = QRect(x, y, w, h); 580 529 name = "Embedded window: "; 581 530 }; 582 531 583 532 ~VoqvEmbedded() … … class VoqvDock : public VideoOutputQuartzView 740 689 VERBOSE(VB_IMPORTANT, "VoqvDock::BeginPort() - " 741 690 "BeginQDContextForApplicationDockTile failed"); 742 691 return false; 743 692 } 693 744 694 return true; 745 695 }; 746 696 747 697 void EndPort(void) … … class VoqvFloater : public VideoOutputQuartzView 789 739 { 790 740 // Resize complete, reset the window drawing transformation 791 741 Rect curBounds; 792 742 GetPortBounds(thePort, &curBounds); 793 m_desired.setWidth(curBounds.right - curBounds.left); 794 m_desired.setHeight(curBounds.bottom - curBounds.top); 795 SetRectRgn(theMask, m_desired.left(), m_desired.top(), 796 m_desired.width(), m_desired.height()); 797 Transform(m_desired); 743 744 VERBOSE(VB_IMPORTANT, "Fixme: resizing window"); 745 746 // m_desired.setWidth(curBounds.right - curBounds.left); 747 // m_desired.setHeight(curBounds.bottom - curBounds.top); 748 // SetRectRgn(theMask, m_desired.left(), m_desired.top(), 749 // m_desired.width(), m_desired.height()); 750 Transform(); 798 751 } 799 752 resizing = startResizing; 800 753 } 801 754 … … class VoqvDesktop : public VideoOutputQuartzView 1055 1008 "VoqvDesktop::BeginPort() - GetWindowPort failed"); 1056 1009 viewLock.unlock(); 1057 1010 return false; 1058 1011 } 1012 1059 1013 viewLock.unlock(); 1060 1014 ShowWindow(window); 1061 1015 // don't lose focus from main window 1062 1016 SelectWindow(parentData->window); … … VideoOutputQuartz::~VideoOutputQuartz() 1131 1085 void VideoOutputQuartz::VideoAspectRatioChanged(float aspect) 1132 1086 { 1133 1087 VERBOSE(VB_PLAYBACK, (LOC + "VideoAspectRatioChanged(aspect=%1) [was %2]") 1134 1088 .arg(aspect).arg(data->srcAspect)); 1089 VERBOSE(VB_PLAYBACK, "QU: VideoAspectRatioChanged"); 1135 1090 1136 1091 VideoOutput::VideoAspectRatioChanged(aspect); 1137 1092 1138 1093 data->srcAspect = aspect; … … void VideoOutputQuartz::ToggleAdjustFill(AdjustFillMode adjustFill) 1154 1109 VideoOutput::ToggleAdjustFill(adjustFill); 1155 1110 1156 1111 // We could change all the views, but the user probably only 1157 1112 // wants the main one (window or fullscreen) to change. 1158 data->views[0]->MoveResize( windows[0].GetDisplayVideoRect());1113 data->views[0]->MoveResize(); 1159 1114 } 1160 1115 1161 1116 void VideoOutputQuartz::MoveResize(void) 1162 1117 { 1163 1118 // This recalculates the desired output rectangle, based on 1164 1119 // the user's current aspect/fill/letterbox/zoom settings. 1165 1120 VideoOutput::MoveResize(); 1166 1121 1167 QRect newRect = windows[0].GetDisplayVideoRect(); 1122 const QSize video_dim = windows[0].GetVideoDim(); 1123 data->srcWidth = video_dim.width(); 1124 data->srcHeight = video_dim.height(); 1125 data->srcAspect = windows[0].GetVideoAspect(); 1126 data->srcMode = db_aspectoverride; 1127 data->display_rect = windows[0].GetDisplayVideoRect(); 1168 1128 1169 1129 vector<VideoOutputQuartzView*>::iterator it; 1170 1130 for (it = data->views.begin(); it != data->views.end(); ++it) 1171 1131 { 1172 (*it)->MoveResize( newRect);1132 (*it)->MoveResize(); 1173 1133 } 1174 1134 } 1175 1135 1136 void VideoOutputQuartz::ToggleAspectOverride(AspectOverrideMode aspectMode) { 1137 VideoOutput::ToggleAspectOverride(aspectMode); 1138 MoveResize(); 1139 } 1140 1176 1141 bool VideoOutputQuartz::InputChanged(const QSize &input_size, 1177 1142 float aspect, 1178 1143 MythCodecID av_codec_id, 1179 1144 void *codec_private, … … bool VideoOutputQuartz::InputChanged(const QSize &input_size, 1223 1188 DeleteQuartzBuffers(); 1224 1189 1225 1190 data->srcWidth = video_dim.width(); 1226 1191 data->srcHeight = video_dim.height(); 1227 data->srcAspect = aspect;1192 data->srcAspect = windows[0].GetVideoAspect(); 1228 1193 data->srcMode = db_aspectoverride; 1194 data->display_rect = windows[0].GetDisplayVideoRect(); 1229 1195 1230 1196 CreateQuartzBuffers(); 1231 1197 1232 1198 vector<VideoOutputQuartzView*>::iterator it = data->views.begin(); … … bool VideoOutputQuartz::Init(int width, int height, float aspect, 1279 1245 data->srcWidth = video_dim.width(); 1280 1246 data->srcHeight = video_dim.height(); 1281 1247 data->srcAspect = aspect; 1282 1248 data->srcMode = db_aspectoverride; 1249 data->display_rect = windows[0].GetDisplayVideoRect(); 1283 1250 1284 1251 // Initialize QuickTime 1285 1252 if (EnterMovies()) 1286 1253 { … … void VideoOutputQuartz::DeleteQuartzBuffers() 1597 1564 1598 1565 vbuffers.DeleteBuffers(); 1599 1566 } 1600 1567 1601 void VideoOutputQuartz::EmbedInWidget( WId wid,int x, int y, int w, int h)1568 void VideoOutputQuartz::EmbedInWidget(int x, int y, int w, int h) 1602 1569 { 1603 1570 VERBOSE(VB_PLAYBACK, 1604 (LOC + "EmbedInWidget( wid=%1, x=%2, y=%3, w=%4, h=%5)")1605 .arg( wid).arg(x).arg(y).arg(w).arg(h));1571 (LOC + "EmbedInWidget(x=%1, y=%2, w=%3, h=%4)") 1572 .arg(x).arg(y).arg(w).arg(h)); 1606 1573 1607 1574 if (windows[0].IsEmbedding()) 1608 1575 return; 1609 1576 1610 1577 VideoOutput::EmbedInWidget(x, y, w, h); 1611 1578 1612 1579 data->pixelLock.lock(); 1580 data->display_rect = windows[0].GetDisplayVideoRect(); 1613 1581 1614 1582 // warn other views that embedding is starting 1615 1583 vector<VideoOutputQuartzView*>::iterator it = data->views.begin(); 1616 1584 for (; it != data->views.end(); ++it) … … void VideoOutputQuartz::StopEmbedding(void) 1638 1606 1639 1607 VideoOutput::StopEmbedding(); 1640 1608 1641 1609 data->pixelLock.lock(); 1610 data->display_rect = windows[0].GetDisplayVideoRect(); 1642 1611 1643 1612 // delete embedded widget 1644 1613 if (data->embeddedView) 1645 1614 { -
mythtv/libs/libmythtv/videoout_quartz.h
diff --git a/mythtv/libs/libmythtv/videoout_quartz.h b/mythtv/libs/libmythtv/videoout_quartz.h index 0a249d9..6ed8da6 100644
a b class VideoOutputQuartz : public VideoOutput 30 30 void *codec_private, 31 31 bool &aspect_only); 32 32 void VideoAspectRatioChanged(float aspect); 33 33 void MoveResize(void); 34 void ToggleAspectOverride(AspectOverrideMode aspectMode); 34 35 void Zoom(ZoomDirection direction); 35 36 void ToggleAdjustFill(AdjustFillMode adjustFill); 36 37 37 void EmbedInWidget( WId wid,int x, int y, int w, int h);38 void EmbedInWidget(int x, int y, int w, int h); 38 39 void StopEmbedding(void); 39 40 40 41 DisplayInfo GetDisplayInfo(void); 41 42 void MoveResizeWindow(QRect new_rect) {;} -
mythtv/libs/libmythtv/videooutbase.h
diff --git a/mythtv/libs/libmythtv/videooutbase.h b/mythtv/libs/libmythtv/videooutbase.h index 8455f27..43c8d24 100644
a b class VideoOutput 109 109 110 110 /// \brief Returns current aspect override mode 111 111 /// \sa ToggleAspectOverride(AspectOverrideMode) 112 112 AspectOverrideMode GetAspectOverride(void) const; 113 v oid ToggleAspectOverride(113 virtual void ToggleAspectOverride( 114 114 AspectOverrideMode aspectOverrideMode = kAspect_Toggle); 115 115 116 116 /// \brief Returns current adjust fill mode 117 117 /// \sa ToggleAdjustFill(AdjustFillMode) -
mythtv/programs/programs.pro
diff --git a/mythtv/programs/programs.pro b/mythtv/programs/programs.pro index 7604c45..9cf268b 100644
a b using_frontend:using_backend { 17 17 SUBDIRS += mythtranscode 18 18 } 19 19 20 20 mingw: SUBDIRS -= mythtranscode mythtranscode/replex 21 # Nigel's speedup hack: 22 SUBDIRS = mythfrontend mythavtest