window.cpp revision e87d84b3934b13646759ccebb60b6fd1a45697b8
/* $Id$ */
/** @file
* Presenter API: window class implementation.
*/
/*
* Copyright (C) 2014 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "server_presenter.h"
mSpuWindow(0),
mcUpdates(0),
mxPos(0),
myPos(0),
mWidth(0),
mHeight(0),
{
Create();
}
bool CrFbWindow::IsVisivle() const
{
}
{
crDebug("CrFbWindow: reparent to %p (current mxPos=%d, myPos=%d, mWidth=%u, mHeight=%u)",
if (!checkInitedUpdating())
{
WARN(("err"));
return VERR_INVALID_STATE;
}
if (mSpuWindow)
{
if (parentId)
{
}
}
return VINF_SUCCESS;
}
{
if (!checkInitedUpdating())
{
WARN(("err"));
return VERR_INVALID_STATE;
}
{
if (mSpuWindow && mParentId)
{
if (fVisible)
}
}
return VINF_SUCCESS;
}
{
if (!checkInitedUpdating())
{
WARN(("err"));
return VERR_INVALID_STATE;
}
{
if (mSpuWindow)
}
return VINF_SUCCESS;
}
{
if (!checkInitedUpdating())
{
WARN(("err"));
return VERR_INVALID_STATE;
}
LOG(("CrWIN: Pos [%d ; %d]", x, y));
// always do WindowPosition to ensure window is adjusted properly
// if (x != mxPos || y != myPos)
{
mxPos = x;
myPos = y;
if (mSpuWindow)
}
return VINF_SUCCESS;
}
{
if (!checkInitedUpdating())
{
WARN(("err"));
return VERR_INVALID_STATE;
}
return VINF_SUCCESS;
}
{
if (!checkInitedUpdating())
{
WARN(("err"));
return VERR_INVALID_STATE;
}
return VINF_SUCCESS;
}
int CrFbWindow::UpdateBegin()
{
++mcUpdates;
if (mcUpdates > 1)
return VINF_SUCCESS;
if (mFlags.fDataPresented)
{
}
return VINF_SUCCESS;
}
void CrFbWindow::UpdateEnd()
{
--mcUpdates;
if (mcUpdates)
return;
checkRegions();
if (mSpuWindow)
{
bool fPresentNeeded = isPresentNeeded();
{
mFlags.fForcePresentOnReenable = false;
if (mpCompositor)
else
{
/* this is a cleanup operation
* empty compositor is guarantid to be released on VBoxPresentComposition return */
}
}
/* even if the above branch is entered due to mFlags.fForcePresentOnReenable,
* the backend should clean up the compositor as soon as presentation is performed */
}
else
{
}
}
{
return mParentId;
}
int CrFbWindow::Create()
{
if (mSpuWindow)
{
WARN(("window already created"));
return VINF_ALREADY_INITIALIZED;
}
if (mSpuWindow < 0) {
WARN(("WindowCreate failed"));
return VERR_GENERAL_FAILURE;
}
checkRegions();
crDebug("CrFbWindow: create window with parent %p (mxPos=%d, myPos=%d, mWidth=%u, mHeight=%u)",
return VINF_SUCCESS;
}
CrFbWindow::~CrFbWindow()
{
Destroy();
}
void CrFbWindow::checkRegions()
{
if (!mSpuWindow)
return;
return;
if (mpCompositor)
{
if (!RT_SUCCESS(rc))
{
cRects = 0;
}
}
else
{
cRects = 0;
}
}
bool CrFbWindow::isPresentNeeded()
{
return mFlags.fVisible && mWidth && mHeight && mpCompositor && !CrVrScrCompositorIsEmpty(mpCompositor);
}
bool CrFbWindow::checkInitedUpdating()
{
if (!mcUpdates)
{
WARN(("not updating"));
return false;
}
return true;
}
void CrFbWindow::Destroy()
{
if (!mSpuWindow)
return;
mSpuWindow = 0;
mFlags.fDataPresented = 0;
}