VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/VBoxFBQGL.cpp@ 28800

Last change on this file since 28800 was 28800, checked in by vboxsync, 14 years ago

Automated rebranding to Oracle copyright/license strings via filemuncher

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.7 KB
Line 
1/* $Id: VBoxFBQGL.cpp 28800 2010-04-27 08:22:32Z vboxsync $ */
2/** @file
3 * VBoxFBQGL Opengl-based FrameBuffer implementation
4 */
5
6/*
7 * Copyright (C) 2009 Oracle Corporation
8 *
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.
16 */
17#if defined (VBOX_GUI_USE_QGLFB)
18
19#ifdef VBOX_WITH_PRECOMPILED_HEADERS
20# include "precomp.h"
21#else /* !VBOX_WITH_PRECOMPILED_HEADERS */
22#define LOG_GROUP LOG_GROUP_GUI
23
24#include "VBoxFrameBuffer.h"
25
26#include "VBoxConsoleView.h"
27//#include "VBoxProblemReporter.h"
28//#include "VBoxGlobal.h"
29
30/* Qt includes */
31#include <QGLWidget>
32
33//#include <iprt/asm.h>
34//
35#ifdef VBOX_WITH_VIDEOHWACCEL
36#include <VBox/VBoxVideo.h>
37//#include <VBox/types.h>
38//#include <VBox/ssm.h>
39#endif
40//#include <iprt/semaphore.h>
41//
42//#include <QFile>
43//#include <QTextStream>
44#endif /* !VBOX_WITH_PRECOMPILED_HEADERS */
45
46
47/** @class VBoxQGLFrameBuffer
48 *
49 * The VBoxQImageFrameBuffer class is a class that implements the IFrameBuffer
50 * interface and uses QImage as the direct storage for VM display data. QImage
51 * is then converted to QPixmap and blitted to the console view widget.
52 */
53
54VBoxQGLFrameBuffer::VBoxQGLFrameBuffer (VBoxConsoleView *aView) :
55 VBoxFrameBuffer (aView),
56 mCmdPipe(aView)
57{
58// mWidget = new GLWidget(aView->viewport());
59#ifndef VBOXQGL_PROF_BASE
60 resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_Opaque,
61 NULL, 0, 0, 640, 480));
62#else
63 resizeEvent (new VBoxResizeEvent (FramebufferPixelFormat_Opaque,
64 NULL, 0, 0, VBOXQGL_PROF_WIDTH, VBOXQGL_PROF_HEIGHT));
65#endif
66}
67
68/** @note This method is called on EMT from under this object's lock */
69STDMETHODIMP VBoxQGLFrameBuffer::NotifyUpdate (ULONG aX, ULONG aY,
70 ULONG aW, ULONG aH)
71{
72// /* We're not on the GUI thread and update() isn't thread safe in
73// * Qt 4.3.x on the Win, Qt 3.3.x on the Mac (4.2.x is),
74// * on Linux (didn't check Qt 4.x there) and probably on other
75// * non-DOS platforms, so post the event instead. */
76#ifdef VBOXQGL_PROF_BASE
77 QApplication::postEvent (mView,
78 new VBoxRepaintEvent (aX, aY, aW, aH));
79#else
80 QRect r(aX, aY, aW, aH);
81 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_PAINT, &r, 0);
82#endif
83 return S_OK;
84}
85
86#ifdef VBOXQGL_PROF_BASE
87STDMETHODIMP VBoxQGLFrameBuffer::RequestResize (ULONG aScreenId, ULONG aPixelFormat,
88 BYTE *aVRAM, ULONG aBitsPerPixel, ULONG aBytesPerLine,
89 ULONG aWidth, ULONG aHeight,
90 BOOL *aFinished)
91{
92 aWidth = VBOXQGL_PROF_WIDTH;
93 aHeight = VBOXQGL_PROF_HEIGHT;
94 VBoxFrameBuffer::RequestResize (aScreenId, aPixelFormat,
95 aVRAM, aBitsPerPixel, aBytesPerLine,
96 aWidth, aHeight,
97 aFinished);
98
99// if(aVRAM)
100 {
101 for(;;)
102 {
103 ULONG aX = 0;
104 ULONG aY = 0;
105 ULONG aW = aWidth;
106 ULONG aH = aHeight;
107 NotifyUpdate (aX, aY, aW, aH);
108 RTThreadSleep(40);
109 }
110 }
111 return S_OK;
112}
113#endif
114
115VBoxGLWidget* VBoxQGLFrameBuffer::vboxWidget()
116{
117 return (VBoxGLWidget*)mView->viewport();
118}
119
120void VBoxQGLFrameBuffer::paintEvent (QPaintEvent *pe)
121{
122 Q_UNUSED(pe);
123 VBoxGLWidget * pw = vboxWidget();
124 pw->makeCurrent();
125
126 QRect vp(mView->contentsX(), mView->contentsY(), pw->width(), pw->height());
127 if(vp != pw->vboxViewport())
128 {
129 pw->vboxDoUpdateViewport(vp);
130 }
131
132 pw->performDisplayAndSwap(true);
133}
134
135void VBoxQGLFrameBuffer::resizeEvent (VBoxResizeEvent *re)
136{
137 mWdt = re->width();
138 mHgt = re->height();
139
140 vboxWidget()->vboxResizeEvent(re);
141}
142
143/* processing the VHWA command, called from the GUI thread */
144void VBoxQGLFrameBuffer::doProcessVHWACommand(QEvent * pEvent)
145{
146 Q_UNUSED(pEvent);
147 vboxWidget()->vboxProcessVHWACommands(&mCmdPipe);
148}
149
150
151#ifdef VBOX_WITH_VIDEOHWACCEL
152
153STDMETHODIMP VBoxQGLFrameBuffer::ProcessVHWACommand(BYTE *pCommand)
154{
155 VBOXVHWACMD * pCmd = (VBOXVHWACMD*)pCommand;
156// Assert(0);
157 /* indicate that we process and complete the command asynchronously */
158 pCmd->Flags |= VBOXVHWACMD_FLAG_HG_ASYNCH;
159 /* post the command to the GUI thread for processing */
160// QApplication::postEvent (mView,
161// new VBoxVHWACommandProcessEvent (pCmd));
162 mCmdPipe.postCmd(VBOXVHWA_PIPECMD_VHWA, pCmd, 0);
163 return S_OK;
164}
165
166#endif
167
168#endif
169
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use