Skip to content

Commit

Permalink
Refactor|libappfw|Client: Cleanup of the window draw operation
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 13, 2014
1 parent f32ca73 commit 048f17e
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
3 changes: 2 additions & 1 deletion doomsday/client/include/ui/clientwindow.h
Expand Up @@ -157,12 +157,13 @@ class ClientWindow : public de::BaseWindow,
void closeEvent(QCloseEvent *);
void canvasGLReady(de::Canvas &);
void canvasGLInit(de::Canvas &);
void canvasGLDraw(de::Canvas &);
void canvasGLResized(de::Canvas &);

// Implements BaseWindow:
de::Vector2f windowContentSize();
void drawWindowContent();
void preDraw();
void postDraw();

static ClientWindow &main();

Expand Down
28 changes: 15 additions & 13 deletions doomsday/client/src/ui/clientwindow.cpp
Expand Up @@ -685,15 +685,6 @@ Vector2f ClientWindow::windowContentSize()
return Vector2f(root().viewWidth().value(), root().viewHeight().value());
}

void ClientWindow::drawWindowContent()
{
LIBGUI_ASSERT_GL_OK();

root().draw();

LIBGUI_ASSERT_GL_OK();
}

ClientRootWidget &ClientWindow::root()
{
return d->root;
Expand Down Expand Up @@ -788,9 +779,10 @@ void ClientWindow::canvasGLInit(Canvas &)
GL_Init2DState();
}

void ClientWindow::canvasGLDraw(Canvas &canvas)
void ClientWindow::preDraw()
{
// All of this occurs during the Canvas paintGL event.
// NOTE: This occurs during the Canvas paintGL event.
BaseWindow::preDraw();

ClientApp::app().preFrame(); /// @todo what about multiwindow?

Expand All @@ -805,17 +797,27 @@ void ClientWindow::canvasGLDraw(Canvas &canvas)
d->updateRootSize();
}
d->updateCompositor();
}

d->contentXf.drawTransformed();
void ClientWindow::drawWindowContent()
{
root().draw();
LIBGUI_ASSERT_GL_OK();
}

void ClientWindow::postDraw()
{
// NOTE: This occurs during the Canvas paintGL event.

// Finish GL drawing and swap it on to the screen. Blocks until buffers
// swapped.
GL_DoUpdate();

ClientApp::app().postFrame(); /// @todo what about multiwindow?

BaseWindow::canvasGLDraw(canvas);
d->updateFpsNotification(frameRate());

BaseWindow::postDraw();
}

void ClientWindow::canvasGLResized(Canvas &canvas)
Expand Down
5 changes: 5 additions & 0 deletions doomsday/libappfw/include/de/framework/basewindow.h
Expand Up @@ -81,6 +81,8 @@ class BaseWindow : public PersistentCanvasWindow
*/
virtual void draw();

void canvasGLDraw(Canvas &);

DENG2_AS_IS_METHODS()

protected:
Expand All @@ -93,6 +95,9 @@ class BaseWindow : public PersistentCanvasWindow
*/
virtual bool prepareForDraw();

virtual void preDraw();
virtual void postDraw();

private:
DENG2_PRIVATE(d)
};
Expand Down
15 changes: 15 additions & 0 deletions doomsday/libappfw/src/basewindow.cpp
Expand Up @@ -92,4 +92,19 @@ void BaseWindow::draw()
}
}

void BaseWindow::canvasGLDraw(Canvas &cv)
{
preDraw();
d->xf->drawTransformed();
postDraw();

PersistentCanvasWindow::canvasGLDraw(cv);
}

void BaseWindow::preDraw()
{}

void BaseWindow::postDraw()
{}

} // namespace de

0 comments on commit 048f17e

Please sign in to comment.