[22641] | 1 | /* $Id: VBoxFBQGL.cpp 29794 2010-05-25 16:06:59Z vboxsync $ */
|
---|
| 2 | /** @file
|
---|
| 3 | * VBoxFBQGL Opengl-based FrameBuffer implementation
|
---|
| 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[28800] | 7 | * Copyright (C) 2009 Oracle Corporation
|
---|
[22641] | 8 | *
|
---|
[22652] | 9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
| 11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
| 12 | * General Public License (GPL) as published by the Free Software
|
---|
| 13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
[22641] | 16 | */
|
---|
[27682] | 17 | #if defined (VBOX_GUI_USE_QGLFB)
|
---|
[22641] | 18 |
|
---|
[25526] | 19 | #ifdef VBOX_WITH_PRECOMPILED_HEADERS
|
---|
| 20 | # include "precomp.h"
|
---|
| 21 | #else /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
[22776] | 22 | #define LOG_GROUP LOG_GROUP_GUI
|
---|
| 23 |
|
---|
[22641] | 24 | #include "VBoxFrameBuffer.h"
|
---|
| 25 |
|
---|
| 26 | /* Qt includes */
|
---|
| 27 | #include <QGLWidget>
|
---|
| 28 |
|
---|
| 29 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
| 30 | #include <VBox/VBoxVideo.h>
|
---|
| 31 | #endif
|
---|
[25526] | 32 | #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
|
---|
[22641] | 33 |
|
---|
| 34 |
|
---|
| 35 | /** @class VBoxQGLFrameBuffer
|
---|
| 36 | *
|
---|
| 37 | * The VBoxQImageFrameBuffer class is a class that implements the IFrameBuffer
|
---|
| 38 | * interface and uses QImage as the direct storage for VM display data. QImage
|
---|
| 39 | * is then converted to QPixmap and blitted to the console view widget.
|
---|
| 40 | */
|
---|
| 41 |
|
---|
| 42 | /** @note This method is called on EMT from under this object's lock */
|
---|
| 43 | STDMETHODIMP VBoxQGLFrameBuffer::NotifyUpdate (ULONG aX, ULONG aY,
|
---|
| 44 | ULONG aW, ULONG aH)
|
---|
| 45 | {
|
---|
| 46 | // /* We're not on the GUI thread and update() isn't thread safe in
|
---|
| 47 | // * Qt 4.3.x on the Win, Qt 3.3.x on the Mac (4.2.x is),
|
---|
| 48 | // * on Linux (didn't check Qt 4.x there) and probably on other
|
---|
| 49 | // * non-DOS platforms, so post the event instead. */
|
---|
| 50 | #ifdef VBOXQGL_PROF_BASE
|
---|
| 51 | QApplication::postEvent (mView,
|
---|
| 52 | new VBoxRepaintEvent (aX, aY, aW, aH));
|
---|
| 53 | #else
|
---|
[22675] | 54 | QRect r(aX, aY, aW, aH);
|
---|
[22836] | 55 | mCmdPipe.postCmd(VBOXVHWA_PIPECMD_PAINT, &r, 0);
|
---|
[22641] | 56 | #endif
|
---|
| 57 | return S_OK;
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | #ifdef VBOXQGL_PROF_BASE
|
---|
| 61 | STDMETHODIMP VBoxQGLFrameBuffer::RequestResize (ULONG aScreenId, ULONG aPixelFormat,
|
---|
| 62 | BYTE *aVRAM, ULONG aBitsPerPixel, ULONG aBytesPerLine,
|
---|
| 63 | ULONG aWidth, ULONG aHeight,
|
---|
| 64 | BOOL *aFinished)
|
---|
| 65 | {
|
---|
[26509] | 66 | aWidth = VBOXQGL_PROF_WIDTH;
|
---|
| 67 | aHeight = VBOXQGL_PROF_HEIGHT;
|
---|
[22641] | 68 | VBoxFrameBuffer::RequestResize (aScreenId, aPixelFormat,
|
---|
| 69 | aVRAM, aBitsPerPixel, aBytesPerLine,
|
---|
| 70 | aWidth, aHeight,
|
---|
| 71 | aFinished);
|
---|
| 72 |
|
---|
| 73 | // if(aVRAM)
|
---|
| 74 | {
|
---|
| 75 | for(;;)
|
---|
| 76 | {
|
---|
| 77 | ULONG aX = 0;
|
---|
| 78 | ULONG aY = 0;
|
---|
| 79 | ULONG aW = aWidth;
|
---|
| 80 | ULONG aH = aHeight;
|
---|
| 81 | NotifyUpdate (aX, aY, aW, aH);
|
---|
| 82 | RTThreadSleep(40);
|
---|
| 83 | }
|
---|
| 84 | }
|
---|
| 85 | return S_OK;
|
---|
| 86 | }
|
---|
| 87 | #endif
|
---|
| 88 |
|
---|
| 89 | VBoxGLWidget* VBoxQGLFrameBuffer::vboxWidget()
|
---|
| 90 | {
|
---|
| 91 | return (VBoxGLWidget*)mView->viewport();
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | void VBoxQGLFrameBuffer::paintEvent (QPaintEvent *pe)
|
---|
| 95 | {
|
---|
[22826] | 96 | Q_UNUSED(pe);
|
---|
[22794] | 97 | VBoxGLWidget * pw = vboxWidget();
|
---|
| 98 | pw->makeCurrent();
|
---|
| 99 |
|
---|
| 100 | QRect vp(mView->contentsX(), mView->contentsY(), pw->width(), pw->height());
|
---|
| 101 | if(vp != pw->vboxViewport())
|
---|
| 102 | {
|
---|
[22797] | 103 | pw->vboxDoUpdateViewport(vp);
|
---|
[22794] | 104 | }
|
---|
| 105 |
|
---|
[22852] | 106 | pw->performDisplayAndSwap(true);
|
---|
[22641] | 107 | }
|
---|
| 108 |
|
---|
| 109 | void VBoxQGLFrameBuffer::resizeEvent (VBoxResizeEvent *re)
|
---|
| 110 | {
|
---|
| 111 | mWdt = re->width();
|
---|
| 112 | mHgt = re->height();
|
---|
| 113 |
|
---|
| 114 | vboxWidget()->vboxResizeEvent(re);
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | /* processing the VHWA command, called from the GUI thread */
|
---|
| 118 | void VBoxQGLFrameBuffer::doProcessVHWACommand(QEvent * pEvent)
|
---|
| 119 | {
|
---|
[22826] | 120 | Q_UNUSED(pEvent);
|
---|
[22796] | 121 | vboxWidget()->vboxProcessVHWACommands(&mCmdPipe);
|
---|
[22641] | 122 | }
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | #ifdef VBOX_WITH_VIDEOHWACCEL
|
---|
| 126 |
|
---|
| 127 | STDMETHODIMP VBoxQGLFrameBuffer::ProcessVHWACommand(BYTE *pCommand)
|
---|
| 128 | {
|
---|
| 129 | VBOXVHWACMD * pCmd = (VBOXVHWACMD*)pCommand;
|
---|
| 130 | // Assert(0);
|
---|
| 131 | /* indicate that we process and complete the command asynchronously */
|
---|
| 132 | pCmd->Flags |= VBOXVHWACMD_FLAG_HG_ASYNCH;
|
---|
| 133 | /* post the command to the GUI thread for processing */
|
---|
| 134 | // QApplication::postEvent (mView,
|
---|
| 135 | // new VBoxVHWACommandProcessEvent (pCmd));
|
---|
[22836] | 136 | mCmdPipe.postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd, 0);
|
---|
[22641] | 137 | return S_OK;
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | #endif
|
---|
[22796] | 141 |
|
---|
[22794] | 142 | #endif
|
---|
[26719] | 143 |
|
---|