Skip to content

Commit

Permalink
OpenGL Video: Clear the framebuffer from the VideoOutput object.
Browse files Browse the repository at this point in the history
This simplifies the code a little by handling the buffer clearing in the
master video object but also paves the way for allowing the video object
to paint widgets for the main UI when embedding.
  • Loading branch information
mark-kendall committed May 2, 2011
1 parent aec1764 commit 5b6eda3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 30 deletions.
22 changes: 3 additions & 19 deletions mythtv/libs/libmythtv/openglvideo.cpp
Expand Up @@ -87,8 +87,7 @@ OpenGLVideo::OpenGLVideo() :
inputUpdated(false), refsNeeded(0),
textureRects(false), textureType(GL_TEXTURE_2D),
helperTexture(0), defaultUpsize(kGLFilterResize),
gl_features(0), videoTextureType(GL_BGRA),
gl_letterbox_colour(kLetterBoxColour_Black)
gl_features(0), videoTextureType(GL_BGRA)
{
}

Expand Down Expand Up @@ -118,8 +117,7 @@ void OpenGLVideo::Teardown(void)
* \fn OpenGLVideo::Init(MythRenderOpenGL *glcontext, bool colour_control,
QSize videoDim, QRect displayVisibleRect,
QRect displayVideoRect, QRect videoRect,
bool viewport_control, QString options, bool osd,
LetterBoxColour letterbox_colour)
bool viewport_control, QString options, bool osd)
* \param glcontext the MythRenderOpenGL object responsible for lower
* levelwindow and OpenGL context integration
* \param colour_control if true, manipulation of video attributes
Expand All @@ -135,17 +133,14 @@ void OpenGLVideo::Teardown(void)
* \param options a string defining OpenGL features to disable
* \param hw_accel if true, a GPU decoder will copy frames directly
to an RGBA texture
* \param letterbox_colour the colour used to clear unused areas of the
window
*/

bool OpenGLVideo::Init(MythRenderOpenGL *glcontext, VideoColourSpace *colourspace,
QSize videoDim, QSize videoDispDim,
QRect displayVisibleRect,
QRect displayVideoRect, QRect videoRect,
bool viewport_control, QString options,
bool hw_accel,
LetterBoxColour letterbox_colour)
bool hw_accel)
{
if (!glcontext)
return false;
Expand All @@ -167,7 +162,6 @@ bool OpenGLVideo::Init(MythRenderOpenGL *glcontext, VideoColourSpace *colourspac
inputTextureSize = QSize(0,0);
currentFrameNum = -1;
inputUpdated = false;
gl_letterbox_colour = letterbox_colour;

// Set OpenGL feature support
gl_features = gl_context->GetFeatures();
Expand Down Expand Up @@ -962,26 +956,16 @@ void OpenGLVideo::PrepareFrame(bool topfieldfirst, FrameScanType scan,
vrect.adjust(0, bob, 0, bob);
}

gl_context->SetBackground(0, 0, 0, 0);
uint target = 0;
// bind correct frame buffer (default onscreen) and set viewport
switch (filter->outputBuffer)
{
case kDefaultBuffer:
gl_context->BindFramebuffer(0);
// clear the buffer
if (viewportControl)
{
if (gl_letterbox_colour == kLetterBoxColour_Gray25)
gl_context->SetBackground(127, 127, 127, 127);
gl_context->ClearFramebuffer();
gl_context->SetViewPort(QRect(QPoint(), display_visible_rect.size()));
}
else
{
gl_context->SetViewPort(QRect(QPoint(), masterViewportSize));
}

break;

case kFrameBufferObject:
Expand Down
4 changes: 1 addition & 3 deletions mythtv/libs/libmythtv/openglvideo.h
Expand Up @@ -44,8 +44,7 @@ class OpenGLVideo
QSize videoDim, QSize videoDispDim, QRect displayVisibleRect,
QRect displayVideoRect, QRect videoRect,
bool viewport_control, QString options,
bool hwaccel,
LetterBoxColour letterbox_colour = kLetterBoxColour_Black);
bool hwaccel);

uint GetInputTexture(void);
uint GetTextureType(void);
Expand Down Expand Up @@ -131,6 +130,5 @@ class OpenGLVideo
OpenGLFilterType defaultUpsize;
uint gl_features;
uint videoTextureType;
LetterBoxColour gl_letterbox_colour;
};
#endif // _OPENGL_VIDEO_H__
16 changes: 8 additions & 8 deletions mythtv/libs/libmythtv/videoout_opengl.cpp
Expand Up @@ -272,8 +272,7 @@ bool VideoOutputOpenGL::SetupOpenGL(void)
window.GetVideoDispDim(), dvr,
window.GetDisplayVideoRect(),
window.GetVideoRect(), true,
GetFilters(), !codec_is_std(video_codec_id),
db_letterbox_colour);
GetFilters(), !codec_is_std(video_codec_id));
if (success)
{
bool temp_deinterlacing = m_deinterlacing;
Expand Down Expand Up @@ -417,6 +416,13 @@ void VideoOutputOpenGL::PrepareFrame(VideoFrame *buffer, FrameScanType t,
framesPlayed = buffer->frameNumber + 1;
gl_context_lock.unlock();

gl_context->BindFramebuffer(0);
if (db_letterbox_colour == kLetterBoxColour_Gray25)
gl_context->SetBackground(127, 127, 127, 255);
else
gl_context->SetBackground(0, 0, 0, 255);
gl_context->ClearFramebuffer();

if (gl_videochain)
{
gl_videochain->SetVideoRect(vsz_enabled ? vsz_desired_display_rect :
Expand All @@ -425,12 +431,6 @@ void VideoOutputOpenGL::PrepareFrame(VideoFrame *buffer, FrameScanType t,
gl_videochain->PrepareFrame(buffer->top_field_first, t,
m_deinterlacing, framesPlayed);
}
else
{
gl_context->BindFramebuffer(0);
gl_context->SetBackground(0, 0, 0, 0);
gl_context->ClearFramebuffer();
}

QMap<MythPlayer*,OpenGLVideo*>::iterator it = gl_pipchains.begin();
for (; it != gl_pipchains.end(); ++it)
Expand Down

0 comments on commit 5b6eda3

Please sign in to comment.