1
/*  This file is part of the KDE project.
2
3
    Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4
5
    This library is free software: you can redistribute it and/or modify
6
    it under the terms of the GNU Lesser General Public License as published by
7
    the Free Software Foundation, either version 2.1 or 3 of the License.
8
9
    This library is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
    GNU Lesser General Public License for more details.
13
14
    You should have received a copy of the GNU Lesser General Public License
15
    along with this library.  If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef Phonon_QT7_VIDEOFRAME_H
19
#define Phonon_QT7_VIDEOFRAME_H
20
21
#import <QuartzCore/CVOpenGLTexture.h>
22
#import <AppKit/NSImage.h>
23
#undef check // avoid name clash;
24
25
#include <QtCore/QRect>
26
#include <QtGui/QPainter>
27
#include <QtGui/QImage>
28
29
QT_BEGIN_NAMESPACE
30
31
class QGLContext;
32
33
namespace Phonon
34
{
35
namespace QT7
36
{
37
    class QuickTimeVideoPlayer;
38
	class QNSBitmapImage;
39
40
    class VideoFrame
41
    {
42
        public:
43
            VideoFrame();
44
            VideoFrame(QuickTimeVideoPlayer *videoPlayer);
45
            VideoFrame(const VideoFrame& frame);
46
            void operator=(const VideoFrame& frame);
47
            ~VideoFrame();
48
49
50
            CVOpenGLTextureRef cachedCVTexture() const;
51
			void *cachedCIImage() const;
52
            GLuint glTextureRef() const;
53
54
			void drawQImage(QPainter *p, const QRect &rect) const;
55
			void drawCIImage(const CGRect &rect, float opacity = 1.0f) const;
56
			void drawCIImage(const QRect &rect, float opacity = 1.0f) const;
57
            void drawCVTexture(const QRect &rect, float opacity = 1.0f) const;
58
            void drawGLTexture(const QRect &rect, float opacity = 1.0f) const;
59
60
            void applyCoreImageFilter(void *filter);
61
            void setColors(qreal brightness, qreal contrast, qreal hue, qreal saturation);
62
			bool hasColorAdjustments();
63
            void setBaseOpacity(qreal opacity);
64
            void setBackgroundFrame(const VideoFrame &frame);
65
66
            bool isEmpty();
67
            QRect frameRect() const;
68
            QuickTimeVideoPlayer *videoPlayer();
69
70
            void retain() const;
71
            void release() const;
72
73
			static CGRect QRectToCGRect(const QRect & qrect);
74
75
        private:
76
            CVOpenGLTextureRef m_cachedCVTextureRef;
77
            void *m_cachedCIImage;
78
			QImage m_cachedQImage;
79
            NSBitmapImageRep *m_cachedNSBitmap;
80
81
            QuickTimeVideoPlayer *m_videoPlayer;
82
            VideoFrame *m_backgroundFrame;
83
84
            qreal m_brightness;
85
            qreal m_contrast;
86
            qreal m_hue;
87
            qreal m_saturation;
88
            qreal m_opacity;
89
90
            void initMembers();
91
            void copyMembers(const VideoFrame& frame);
92
            void invalidateImage() const;
93
    };
94
95
}} //namespace Phonon::QT7
96
97
QT_END_NAMESPACE
98
#endif // Phonon_QT7_VIDEOFRAME_H