forked from wang-bin/QtAV
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate needDrawFrame() and needUpdateBackground(). Introduce backgroundRegion() thus only draw each rect in the region is enough.
- Loading branch information
Showing
18 changed files
with
81 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2014-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2014-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -49,7 +49,6 @@ class Q_AV_EXPORT OpenGLRendererBase : public VideoRenderer | |
virtual bool isSupported(VideoFormat::PixelFormat pixfmt) const; | ||
protected: | ||
virtual bool receiveFrame(const VideoFrame& frame); | ||
virtual bool needUpdateBackground() const; | ||
//called in paintEvent before drawFrame() when required | ||
virtual void drawBackground(); | ||
//draw the current frame using the current paint engine. called by paintEvent() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2012-2013 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -33,12 +33,12 @@ class Q_AV_EXPORT QPainterRenderer : public VideoRenderer | |
DPTR_DECLARE_PRIVATE(QPainterRenderer) | ||
public: | ||
QPainterRenderer(); | ||
virtual bool isSupported(VideoFormat::PixelFormat pixfmt) const; | ||
//virtual QImage currentFrameImage() const; | ||
bool isSupported(VideoFormat::PixelFormat pixfmt) const Q_DECL_OVERRIDE; | ||
protected: | ||
bool prepareFrame(const VideoFrame& frame); | ||
void drawBackground() Q_DECL_OVERRIDE; | ||
//draw the current frame using the current paint engine. called by paintEvent() | ||
virtual void drawFrame(); | ||
void drawFrame() Q_DECL_OVERRIDE; | ||
|
||
QPainterRenderer(QPainterRendererPrivate& d); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2012-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -73,17 +73,13 @@ class Direct2DRenderer : public QWidget, public VideoRenderer | |
virtual QWidget* widget() { return this; } | ||
protected: | ||
virtual bool receiveFrame(const VideoFrame& frame); | ||
virtual bool needUpdateBackground() const; | ||
//called in paintEvent before drawFrame() when required | ||
virtual void drawBackground(); | ||
virtual bool needDrawFrame() const; | ||
//draw the current frame using the current paint engine. called by paintEvent() | ||
virtual void drawFrame(); | ||
/*usually you don't need to reimplement paintEvent, just drawXXX() is ok. unless you want do all | ||
*things yourself totally*/ | ||
virtual void paintEvent(QPaintEvent *); | ||
virtual void resizeEvent(QResizeEvent *); | ||
//stay on top will change parent, hide then show(windows). we need GetDC() again | ||
//stay on top will change parent, hide then show(windows) | ||
virtual void showEvent(QShowEvent *); | ||
}; | ||
typedef Direct2DRenderer VideoRendererDirect2D; | ||
|
@@ -335,12 +331,6 @@ QPaintEngine* Direct2DRenderer::paintEngine() const | |
return 0; //use native engine | ||
} | ||
|
||
bool Direct2DRenderer::needUpdateBackground() const | ||
{ | ||
DPTR_D(const Direct2DRenderer); | ||
return (d.update_background && d.out_rect != rect()) || !d.video_frame.isValid(); | ||
} | ||
|
||
void Direct2DRenderer::drawBackground() | ||
{ | ||
DPTR_D(Direct2DRenderer); | ||
|
@@ -352,11 +342,6 @@ void Direct2DRenderer::drawBackground() | |
//d.render_target->FillRectangle(D2D1::RectF(0, 0, width(), height()), brush); | ||
} | ||
|
||
bool Direct2DRenderer::needDrawFrame() const | ||
{ | ||
return true; | ||
} | ||
|
||
void Direct2DRenderer::drawFrame() | ||
{ | ||
DPTR_D(Direct2DRenderer); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2012-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -57,10 +57,7 @@ class GDIRenderer : public QWidget, public VideoRenderer | |
virtual QWidget* widget() { return this; } | ||
protected: | ||
virtual bool receiveFrame(const VideoFrame& frame); | ||
virtual bool needUpdateBackground() const; | ||
//called in paintEvent before drawFrame() when required | ||
virtual void drawBackground(); | ||
//draw the current frame using the current paint engine. called by paintEvent() | ||
virtual void drawFrame(); | ||
/*usually you don't need to reimplement paintEvent, just drawXXX() is ok. unless you want do all | ||
*things yourself totally*/ | ||
|
@@ -231,19 +228,18 @@ bool GDIRenderer::receiveFrame(const VideoFrame& frame) | |
return true; | ||
} | ||
|
||
bool GDIRenderer::needUpdateBackground() const | ||
{ | ||
DPTR_D(const GDIRenderer); | ||
return (d.update_background && d.out_rect != rect()) || !d.video_frame.isValid(); | ||
} | ||
|
||
void GDIRenderer::drawBackground() | ||
{ | ||
DPTR_D(GDIRenderer); | ||
//HDC hdc = d.device_context; | ||
Graphics g(d.device_context); | ||
SolidBrush brush(Color(255, 0, 0, 0)); //argb | ||
g.FillRectangle(&brush, 0, 0, width(), height()); | ||
const QVector<QRect> bg(backgroundRegion().rects()); | ||
if (!bg.isEmpty()) { | ||
foreach (const QRect& r, bg) { | ||
g.FillRectangle(&brush, r.x(), r.y(), r.width(), r.height()); | ||
} | ||
} | ||
} | ||
|
||
void GDIRenderer::drawFrame() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2012-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -169,18 +169,18 @@ void GraphicsItemRenderer::paint(QPainter *painter, const QStyleOptionGraphicsIt | |
ctx->painter = 0; | ||
} | ||
|
||
bool GraphicsItemRenderer::needUpdateBackground() const | ||
{ | ||
DPTR_D(const GraphicsItemRenderer); | ||
return d.out_rect != boundingRect() || !d.video_frame.isValid(); | ||
} | ||
|
||
void GraphicsItemRenderer::drawBackground() | ||
{ | ||
DPTR_D(GraphicsItemRenderer); | ||
if (!d.painter) | ||
#if QTAV_HAVE(OPENGL) | ||
if (d.checkGL()) { | ||
// d.glv.fill(QColor(0, 0, 0)); //FIXME: fill boundingRect | ||
return; | ||
d.painter->fillRect(boundingRect(), QColor(0, 0, 0)); | ||
} else | ||
#endif | ||
{ | ||
QPainterRenderer::drawBackground(); | ||
} | ||
} | ||
|
||
void GraphicsItemRenderer::drawFrame() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2014-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2014-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -79,11 +79,6 @@ bool OpenGLRendererBase::receiveFrame(const VideoFrame& frame) | |
return true; | ||
} | ||
|
||
bool OpenGLRendererBase::needUpdateBackground() const | ||
{ | ||
return true; | ||
} | ||
|
||
void OpenGLRendererBase::drawBackground() | ||
{ | ||
d_func().glv.fill(QColor(Qt::black)); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/****************************************************************************** | ||
QtAV: Media play library based on Qt and FFmpeg | ||
Copyright (C) 2012-2015 Wang Bin <[email protected]> | ||
Copyright (C) 2012-2016 Wang Bin <[email protected]> | ||
* This file is part of QtAV | ||
|
@@ -75,15 +75,33 @@ bool QPainterRenderer::prepareFrame(const VideoFrame &frame) | |
return true; | ||
} | ||
|
||
void QPainterRenderer::drawFrame() | ||
void QPainterRenderer::drawBackground() | ||
{ | ||
DPTR_D(QPainterRenderer); | ||
if (!d.painter) | ||
return; | ||
if (d.image.isNull()) { | ||
d.image = QImage(rendererSize(), QImage::Format_RGB32); | ||
d.image.fill(Qt::black); //maemo 4.7.0: QImage.fill(uint) | ||
#if 0 | ||
d.painter->save(); | ||
d.painter->setClipRegion(backgroundRegion()); | ||
d.painter->fillRect(QRect(QPoint(), rendererSize()), QColor(0, 0, 0)); | ||
d.painter->restore(); | ||
#else | ||
const QVector<QRect> bg(backgroundRegion().rects()); | ||
if (!bg.isEmpty()) { | ||
foreach (const QRect& r, bg) { | ||
d.painter->fillRect(r, QColor(0, 0, 0)); | ||
} | ||
} | ||
#endif | ||
} | ||
|
||
void QPainterRenderer::drawFrame() | ||
{ | ||
DPTR_D(QPainterRenderer); | ||
if (!d.painter) | ||
return; | ||
if (d.image.isNull()) | ||
return; | ||
QRect roi = realROI(); | ||
if (orientation() == 0) { | ||
//assume that the image data is already scaled to out_size(NOT renderer size!) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.