VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/runtime/UIFrameBufferQGL.cpp@ 43138

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette