equal
deleted
inserted
replaced
71 |
71 |
72 GLVideoWidget(QWidget *parent, const QGLFormat &format) |
72 GLVideoWidget(QWidget *parent, const QGLFormat &format) |
73 : QGLWidget(format, parent), |
73 : QGLWidget(format, parent), |
74 m_texRef(0), |
74 m_texRef(0), |
75 m_nativeSize(640,480), |
75 m_nativeSize(640,480), |
76 m_aspectRatioMode(QVideoWidget::KeepAspectRatio) |
76 m_aspectRatioMode(Qt::KeepAspectRatio) |
77 { |
77 { |
78 setAutoFillBackground(false); |
78 setAutoFillBackground(false); |
79 } |
79 } |
80 |
80 |
81 void initializeGL() |
81 void initializeGL() |
150 void setNativeSize(const QSize &size) |
150 void setNativeSize(const QSize &size) |
151 { |
151 { |
152 m_nativeSize = size; |
152 m_nativeSize = size; |
153 } |
153 } |
154 |
154 |
155 void setAspectRatioMode(QVideoWidget::AspectRatioMode mode) |
155 void setAspectRatioMode(Qt::AspectRatioMode mode) |
156 { |
156 { |
157 if (m_aspectRatioMode != mode) { |
157 if (m_aspectRatioMode != mode) { |
158 m_aspectRatioMode = mode; |
158 m_aspectRatioMode = mode; |
159 update(); |
159 update(); |
160 } |
160 } |
163 private: |
163 private: |
164 QRect displayRect() const |
164 QRect displayRect() const |
165 { |
165 { |
166 QRect displayRect = rect(); |
166 QRect displayRect = rect(); |
167 |
167 |
168 if (m_aspectRatioMode == QVideoWidget::KeepAspectRatio) { |
168 if (m_aspectRatioMode == Qt::KeepAspectRatio) { |
169 QSize size = m_nativeSize; |
169 QSize size = m_nativeSize; |
170 size.scale(displayRect.size(), Qt::KeepAspectRatio); |
170 size.scale(displayRect.size(), Qt::KeepAspectRatio); |
171 |
171 |
172 displayRect = QRect(QPoint(0, 0), size); |
172 displayRect = QRect(QPoint(0, 0), size); |
173 displayRect.moveCenter(rect().center()); |
173 displayRect.moveCenter(rect().center()); |
175 return displayRect; |
175 return displayRect; |
176 } |
176 } |
177 |
177 |
178 CVOpenGLTextureRef m_texRef; |
178 CVOpenGLTextureRef m_texRef; |
179 QSize m_nativeSize; |
179 QSize m_nativeSize; |
180 QVideoWidget::AspectRatioMode m_aspectRatioMode; |
180 Qt::AspectRatioMode m_aspectRatioMode; |
181 }; |
181 }; |
182 |
182 |
183 QT7MovieVideoWidget::QT7MovieVideoWidget(QObject *parent) |
183 QT7MovieVideoWidget::QT7MovieVideoWidget(QObject *parent) |
184 :QT7VideoWidgetControl(parent), |
184 :QT7VideoWidgetControl(parent), |
185 m_movie(0), |
185 m_movie(0), |
186 m_videoWidget(0), |
186 m_videoWidget(0), |
187 m_fullscreen(false), |
187 m_fullscreen(false), |
188 m_aspectRatioMode(QVideoWidget::KeepAspectRatio), |
188 m_aspectRatioMode(Qt::KeepAspectRatio), |
189 m_brightness(0), |
189 m_brightness(0), |
190 m_contrast(0), |
190 m_contrast(0), |
191 m_hue(0), |
191 m_hue(0), |
192 m_saturation(0) |
192 m_saturation(0) |
193 { |
193 { |
215 AutoReleasePool pool; |
215 AutoReleasePool pool; |
216 CGLContextObj cglContext = CGLGetCurrentContext(); |
216 CGLContextObj cglContext = CGLGetCurrentContext(); |
217 NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; |
217 NSOpenGLPixelFormat *nsglPixelFormat = [NSOpenGLView defaultPixelFormat]; |
218 CGLPixelFormatObj cglPixelFormat = static_cast<CGLPixelFormatObj>([nsglPixelFormat CGLPixelFormatObj]); |
218 CGLPixelFormatObj cglPixelFormat = static_cast<CGLPixelFormatObj>([nsglPixelFormat CGLPixelFormatObj]); |
219 |
219 |
220 CFTypeRef keys[] = { kQTVisualContextWorkingColorSpaceKey }; |
220 CFTypeRef keys[] = { kQTVisualContextOutputColorSpaceKey }; |
221 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); |
221 CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); |
222 CFDictionaryRef textureContextAttributes = CFDictionaryCreate(kCFAllocatorDefault, |
222 CFDictionaryRef textureContextAttributes = CFDictionaryCreate(kCFAllocatorDefault, |
223 (const void **)keys, |
223 (const void **)keys, |
224 (const void **)&colorSpace, 1, |
224 (const void **)&colorSpace, 1, |
225 &kCFTypeDictionaryKeyCallBacks, |
225 &kCFTypeDictionaryKeyCallBacks, |
310 QSize QT7MovieVideoWidget::nativeSize() const |
310 QSize QT7MovieVideoWidget::nativeSize() const |
311 { |
311 { |
312 return m_nativeSize; |
312 return m_nativeSize; |
313 } |
313 } |
314 |
314 |
315 QVideoWidget::AspectRatioMode QT7MovieVideoWidget::aspectRatioMode() const |
315 Qt::AspectRatioMode QT7MovieVideoWidget::aspectRatioMode() const |
316 { |
316 { |
317 return m_aspectRatioMode; |
317 return m_aspectRatioMode; |
318 } |
318 } |
319 |
319 |
320 void QT7MovieVideoWidget::setAspectRatioMode(QVideoWidget::AspectRatioMode mode) |
320 void QT7MovieVideoWidget::setAspectRatioMode(Qt::AspectRatioMode mode) |
321 { |
321 { |
322 m_aspectRatioMode = mode; |
322 m_aspectRatioMode = mode; |
323 m_videoWidget->setAspectRatioMode(mode); |
323 m_videoWidget->setAspectRatioMode(mode); |
324 } |
324 } |
325 |
325 |