0
|
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 |
|
|
19 |
#include "utils.h"
|
|
20 |
#include "videooutput.h"
|
|
21 |
#include "videooutputobserver.h"
|
|
22 |
|
|
23 |
#ifndef QT_NO_DEBUG
|
|
24 |
#include "objectdump.h"
|
|
25 |
#endif
|
|
26 |
|
|
27 |
#include <QPaintEvent>
|
|
28 |
#include <QPainter>
|
|
29 |
#include <QMoveEvent>
|
|
30 |
#include <QResizeEvent>
|
|
31 |
|
|
32 |
#include <QtGui/private/qwidget_p.h> // to access QWExtra
|
|
33 |
|
|
34 |
QT_BEGIN_NAMESPACE
|
|
35 |
|
|
36 |
using namespace Phonon;
|
|
37 |
using namespace Phonon::MMF;
|
|
38 |
|
|
39 |
/*! \class MMF::VideoOutput
|
|
40 |
\internal
|
|
41 |
*/
|
|
42 |
|
|
43 |
//-----------------------------------------------------------------------------
|
|
44 |
// Constructor / destructor
|
|
45 |
//-----------------------------------------------------------------------------
|
|
46 |
|
|
47 |
MMF::VideoOutput::VideoOutput(QWidget* parent)
|
|
48 |
: QWidget(parent)
|
|
49 |
, m_observer(0)
|
|
50 |
{
|
|
51 |
TRACE_CONTEXT(VideoOutput::VideoOutput, EVideoInternal);
|
|
52 |
TRACE_ENTRY("parent 0x%08x", parent);
|
|
53 |
|
|
54 |
setPalette(QPalette(Qt::black));
|
|
55 |
setAttribute(Qt::WA_OpaquePaintEvent, true);
|
|
56 |
setAttribute(Qt::WA_NoSystemBackground, true);
|
|
57 |
setAutoFillBackground(false);
|
|
58 |
|
|
59 |
// Causes QSymbianControl::Draw not to BitBlt this widget's region of the
|
|
60 |
// backing store. Since the backing store is (by default) a 16MU bitmap,
|
|
61 |
// blitting it results in this widget's screen region in the final
|
|
62 |
// framebuffer having opaque alpha values. This in turn causes the video
|
|
63 |
// to be invisible when running on the target device.
|
|
64 |
qt_widget_private(this)->extraData()->disableBlit = true;
|
|
65 |
|
|
66 |
dump();
|
|
67 |
|
|
68 |
TRACE_EXIT_0();
|
|
69 |
}
|
|
70 |
|
|
71 |
MMF::VideoOutput::~VideoOutput()
|
|
72 |
{
|
|
73 |
TRACE_CONTEXT(VideoOutput::~VideoOutput, EVideoInternal);
|
|
74 |
TRACE_ENTRY_0();
|
|
75 |
|
|
76 |
TRACE_EXIT_0();
|
|
77 |
}
|
|
78 |
|
|
79 |
void MMF::VideoOutput::setFrameSize(const QSize& frameSize)
|
|
80 |
{
|
|
81 |
TRACE_CONTEXT(VideoOutput::setFrameSize, EVideoInternal);
|
|
82 |
TRACE("oldSize %d %d newSize %d %d",
|
|
83 |
m_frameSize.width(), m_frameSize.height(),
|
|
84 |
frameSize.width(), frameSize.height());
|
|
85 |
|
|
86 |
if (frameSize != m_frameSize) {
|
|
87 |
m_frameSize = frameSize;
|
|
88 |
updateGeometry();
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
void MMF::VideoOutput::setObserver(VideoOutputObserver* observer)
|
|
93 |
{
|
|
94 |
TRACE_CONTEXT(VideoOutput::setObserver, EVideoInternal);
|
|
95 |
TRACE("observer 0x%08x", observer);
|
|
96 |
|
|
97 |
m_observer = observer;
|
|
98 |
}
|
|
99 |
|
|
100 |
|
|
101 |
//-----------------------------------------------------------------------------
|
|
102 |
// QWidget
|
|
103 |
//-----------------------------------------------------------------------------
|
|
104 |
|
|
105 |
QSize MMF::VideoOutput::sizeHint() const
|
|
106 |
{
|
|
107 |
// TODO: replace this with a more sensible default
|
|
108 |
QSize result(320, 240);
|
|
109 |
|
|
110 |
if (!m_frameSize.isNull()) {
|
|
111 |
result = m_frameSize;
|
|
112 |
}
|
|
113 |
|
|
114 |
return result;
|
|
115 |
}
|
|
116 |
|
|
117 |
void MMF::VideoOutput::paintEvent(QPaintEvent* event)
|
|
118 |
{
|
|
119 |
TRACE_CONTEXT(VideoOutput::paintEvent, EVideoInternal);
|
|
120 |
TRACE("rect %d %d - %d %d",
|
|
121 |
event->rect().left(), event->rect().top(),
|
|
122 |
event->rect().right(), event->rect().bottom());
|
|
123 |
TRACE("regions %d", event->region().numRects());
|
|
124 |
TRACE("type %d", event->type());
|
|
125 |
|
|
126 |
// Do nothing
|
|
127 |
}
|
|
128 |
|
|
129 |
void MMF::VideoOutput::resizeEvent(QResizeEvent* event)
|
|
130 |
{
|
|
131 |
TRACE_CONTEXT(VideoOutput::resizeEvent, EVideoInternal);
|
|
132 |
TRACE("%d %d -> %d %d",
|
|
133 |
event->oldSize().width(), event->oldSize().height(),
|
|
134 |
event->size().width(), event->size().height());
|
|
135 |
|
|
136 |
videoOutputRegionChanged();
|
|
137 |
}
|
|
138 |
|
|
139 |
void MMF::VideoOutput::moveEvent(QMoveEvent* event)
|
|
140 |
{
|
|
141 |
TRACE_CONTEXT(VideoOutput::moveEvent, EVideoInternal);
|
|
142 |
TRACE("%d %d -> %d %d",
|
|
143 |
event->oldPos().x(), event->oldPos().y(),
|
|
144 |
event->pos().x(), event->pos().y());
|
|
145 |
|
|
146 |
videoOutputRegionChanged();
|
|
147 |
}
|
|
148 |
|
|
149 |
bool MMF::VideoOutput::event(QEvent* event)
|
|
150 |
{
|
|
151 |
TRACE_CONTEXT(VideoOutput::event, EVideoInternal);
|
|
152 |
|
|
153 |
if (event->type() == QEvent::WinIdChange) {
|
|
154 |
TRACE_0("WinIdChange");
|
|
155 |
videoOutputRegionChanged();
|
|
156 |
return true;
|
|
157 |
}
|
|
158 |
else
|
|
159 |
return QWidget::event(event);
|
|
160 |
}
|
|
161 |
|
|
162 |
|
|
163 |
//-----------------------------------------------------------------------------
|
|
164 |
// Private functions
|
|
165 |
//-----------------------------------------------------------------------------
|
|
166 |
|
|
167 |
void MMF::VideoOutput::videoOutputRegionChanged()
|
|
168 |
{
|
|
169 |
dump();
|
|
170 |
if (m_observer)
|
|
171 |
m_observer->videoOutputRegionChanged();
|
|
172 |
}
|
|
173 |
|
|
174 |
void MMF::VideoOutput::dump() const
|
|
175 |
{
|
|
176 |
#ifndef QT_NO_DEBUG
|
|
177 |
TRACE_CONTEXT(VideoOutput::dump, EVideoInternal);
|
|
178 |
QScopedPointer<ObjectDump::QVisitor> visitor(new ObjectDump::QVisitor);
|
|
179 |
visitor->setPrefix("Phonon::MMF"); // to aid searchability of logs
|
|
180 |
ObjectDump::addDefaultAnnotators(*visitor);
|
|
181 |
TRACE("Dumping tree from leaf 0x%08x:", this);
|
|
182 |
//ObjectDump::dumpAncestors(*this, *visitor);
|
|
183 |
ObjectDump::dumpTreeFromLeaf(*this, *visitor);
|
|
184 |
#endif
|
|
185 |
}
|
|
186 |
|
|
187 |
|
|
188 |
QT_END_NAMESPACE
|
|
189 |
|