UIFrameBufferQuartz2D.cpp revision e64031e20c39650a7bc902a3e1aba613b9415dee
/* $Id$ */
/** @file
*
* VBox frontends: Qt GUI ("VirtualBox"):
* UIFrameBufferQuartz2D class implementation
*/
/*
* Copyright (C) 2006-2010 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.
*/
#if defined (VBOX_GUI_USE_QUARTZ2D)
# include "precomp.h"
#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
/* Global includes */
#include <QApplication>
/* Local includes */
#include "UIFrameBufferQuartz2D.h"
#include "UIMachineView.h"
#include "UIMachineLogic.h"
#include "VBoxUtils.h"
#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
//#define COMP_WITH_SHADOW
//#define OVERLAY_CLIPRECTS
/** @class UIFrameBufferQuartz2D
*
* The UIFrameBufferQuartz2D class is a class that implements the IFrameBuffer
* interface and uses Apples Quartz2D to store and render VM display data.
*/
{
Log (("Quartz2D: Creating\n"));
resizeEvent (&event);
}
{
Log (("Quartz2D: Deleting\n"));
clean();
}
/** @note This method is called on EMT from under this object's lock */
{
/* Log (("Quartz2D: NotifyUpdate %d,%d %dx%d\n", aX, aY, aW, aH));*/
return S_OK;
}
{
if (!rects)
return E_POINTER;
/** @todo r=bird: Is this thread safe? If I remember the code flow correctly, the
* GUI thread could be happily jogging along paintEvent now on another cpu core.
* This function is called on the EMT (emulation thread). Which means, blocking
* execution waiting for a lock is out of the question. A quick solution using
* ASMAtomic(Cmp)XchgPtr and a struct { cAllocated; cRects; aRects[1]; }
* *mRegion, *mUnusedRegion; should suffice (and permit you to reuse allocations). */
{
}
if (!rgnRcts)
{
if (!rgnRcts)
return E_OUTOFMEMORY;
}
// printf ("Region rects follow...\n");
{
/* QRect are inclusive */
/* The rect should intersect with the vm screen. */
++ rects;
/* Make sure only valid rects are distributed */
/* todo: Test if the other framebuffer implementation have the same
else
continue;
// printf ("Region rect[%d - %d]: %d %d %d %d\n", rgnRcts->used, aCount, rect.x(), rect.y(), rect.height(), rect.width());
}
// printf ("..................................\n");
if ( pvOld
return S_OK;
}
{
/* For debugging /Developer/Applications/Performance Tools/Quartz
* Debug.app is a nice tool to see which parts of the screen are
* updated.*/
/* Get the dimensions of the viewport */
/* Get the context of this window from Qt */
/* Flip the context */
/* We handle the seamless mode as a special case. */
{
/* Here we paint the windows without any wallpaper.
* So the background would be set transparently. */
/* Create a subimage of the current view.
* Currently this subimage is the whole screen. */
{
subImage = CGImageCreateWithImageInRect(pauseImg, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
}
else
subImage = CGImageCreateWithImageInRect(m_image, CGRectMake (m_pMachineView->contentsX(), m_pMachineView->contentsY(), m_pMachineView->visibleWidth(), m_pMachineView->visibleHeight()));
/* Clear the background (Make the rect fully transparent) */
#ifdef OVERLAY_CLIPRECTS
#endif
#ifdef COMP_WITH_SHADOW
/* Enable shadows */
#endif
/* Grab the current visible region. */
if (rgnRcts)
{
{
/* Add the clipping rects all at once. They are defined in
* SetVisibleRegion. */
/* Now convert the path to a clipping path. */
}
/* Put back the visible region, free if we cannot (2+ SetVisibleRegion calls). */
}
/* In any case clip the drawing to the view window */
/* At this point draw the real vm image */
#ifdef COMP_WITH_SHADOW
#endif
#ifdef OVERLAY_CLIPRECTS
{
}
#endif
}
else
{
/* Here we paint if we didn't care about any masks */
/* Create a subimage of the current view in the size
* of the bounding box of the current paint event */
QRect is = QRect (ir.x() + m_pMachineView->contentsX(), ir.y() + m_pMachineView->contentsY(), ir.width(), ir.height());
{
}
else
/* Ok, for more performance we set a clipping path of the
* regions given by this paint event. */
if (!a.isEmpty())
{
/* Add all region rects to the current context as path components */
for (int i = 0; i < a.size(); ++i)
/* Now convert the path to a clipping path. */
}
/* In any case clip the drawing to the view window */
/* At this point draw the real vm image */
}
}
{
#if 0
printf ("fmt=%lu, vram=%X, bpp=%lu, bpl=%lu, width=%lu, height=%lu\n",
#endif
/* Clean out old stuff */
clean();
bool remind = false;
/* We need a color space in any case */
/* Check if we support the pixel format/colordepth and can use the guest VRAM directly.
* Mac OS X supports 16 bit also but not in the 565 mode. So we could use
* 32 bit only. */
{
// printf ("VRAM\n");
/* Create the image copy of the framebuffer */
CGDataProviderRef dp = CGDataProviderCreateWithData(NULL, aEvent->VRAM(), aEvent->bitsPerPixel() / 8 * m_width * m_height, NULL);
}
else
{
remind = true;
// printf ("No VRAM\n");
/* Create the memory we need for our image copy
* Read somewhere that an alignment of 16 is
* best for optimal performance. So why not. */
// int bitmapBytesPerRow = RT_ALIGN (m_width * 4, 16);
}
#ifdef VBOX_WITH_ICHAT_THEATER
#endif
// if (remind)
// {
// class RemindEvent : public VBoxAsyncEvent
// {
// ulong mRealBPP;
// public:
// RemindEvent (ulong aRealBPP)
// : mRealBPP (aRealBPP) {}
// void handle()
// {
// vboxProblem().remindAboutWrongColorDepth (mRealBPP, 32);
// }
// };
// (new RemindEvent (aEvent->bitsPerPixel()))->post();
// }
}
void UIFrameBufferQuartz2D::clean()
{
if (m_image)
{
}
if (m_pBitmapData)
{
}
if (mRegion)
{
}
if (mRegionUnused)
{
RTMemFree((void *)mRegionUnused);
}
}
#endif /* defined (VBOX_GUI_USE_QUARTZ2D) */