Qt 4.8
Classes | Functions
qscreenqnx_qws.cpp File Reference
#include "qscreenqnx_qws.h"
#include <qapplication.h>
#include <qregexp.h>
#include <gf/gf.h>

Go to the source code of this file.

Classes

struct  QQnxScreenContext
 

Functions

static bool attachDevice (QQnxScreenContext *const d, const char *name)
 Attaches to the named device name. More...
 
static bool attachDisplay (QQnxScreenContext *const d, int displayIndex)
 Attaches to the display at index displayIndex. More...
 
static bool attachLayer (QQnxScreenContext *const d, int layerIndex)
 Attaches to the layer layerIndex. More...
 
static bool createHwSurface (QQnxScreenContext *const d, int w, int h)
 
static bool createMemSurface (QQnxScreenContext *const d, int w, int h)
 

Function Documentation

◆ attachDevice()

static bool attachDevice ( QQnxScreenContext *const  d,
const char *  name 
)
inlinestatic

Attaches to the named device name.

Warning
This function is not part of the public interface.

Definition at line 177 of file qscreenqnx_qws.cpp.

Referenced by QQnxScreen::connect().

178 {
179  int ret = gf_dev_attach(&d->device, name, &d->deviceInfo);
180  if (ret != GF_ERR_OK) {
181  qWarning("QQnxScreen: gf_dev_attach(%s) failed with error code %d", name, ret);
182  return false;
183  }
184  return true;
185 }
const char * name
Q_CORE_EXPORT void qWarning(const char *,...)
gf_dev_info_t deviceInfo

◆ attachDisplay()

static bool attachDisplay ( QQnxScreenContext *const  d,
int  displayIndex 
)
inlinestatic

Attaches to the display at index displayIndex.

Warning
This function is not part of the public interface.

Definition at line 194 of file qscreenqnx_qws.cpp.

Referenced by QQnxScreen::connect().

195 {
196  int ret = gf_display_attach(&d->display, d->device, displayIndex, &d->displayInfo);
197  if (ret != GF_ERR_OK) {
198  qWarning("QQnxScreen: gf_display_attach(%d) failed with error code %d", displayIndex, ret);
199  return false;
200  }
201  return true;
202 }
Q_CORE_EXPORT void qWarning(const char *,...)
gf_display_t display
gf_display_info_t displayInfo

◆ attachLayer()

static bool attachLayer ( QQnxScreenContext *const  d,
int  layerIndex 
)
inlinestatic

Attaches to the layer layerIndex.

Warning
This function is not part of the public interface.

Definition at line 211 of file qscreenqnx_qws.cpp.

Referenced by QQnxScreen::connect().

212 {
213  unsigned flags = QApplication::type() != QApplication::GuiServer ? GF_LAYER_ATTACH_PASSIVE : 0;
214  int ret = gf_layer_attach(&d->layer, d->display, layerIndex, flags);
215  if (ret != GF_ERR_OK) {
216  qWarning("QQnxScreen: gf_layer_attach(%d) failed with error code %d", layerIndex, ret);
217  return false;
218  }
219 
220  return true;
221 }
Q_CORE_EXPORT void qWarning(const char *,...)
gf_display_t display
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).

◆ createHwSurface()

static bool createHwSurface ( QQnxScreenContext *const  d,
int  w,
int  h 
)
inlinestatic
Warning
This function is not part of the public interface. Creates a new hardware surface (usually on the Gfx card memory) with the dimensions w * h.

Definition at line 227 of file qscreenqnx_qws.cpp.

Referenced by QQnxScreen::connect().

228 {
229  int ret = gf_surface_create_layer(&d->hwSurface, &d->layer, 1, 0,
230  w, h, d->displayInfo.format, 0, 0);
231  if (ret != GF_ERR_OK) {
232  qWarning("QQnxScreen: gf_surface_create_layer(%dx%d) failed with error code %d", w, h, ret);
233  return false;
234  }
235 
236  gf_layer_set_surfaces(d->layer, &d->hwSurface, 1);
237 
238  gf_layer_enable(d->layer);
239 
240  ret = gf_layer_update(d->layer, 0);
241  if (ret != GF_ERR_OK) {
242  qWarning("QQnxScreen: gf_layer_update() failed with error code %d\n", ret);
243  return false;
244  }
245 
246  ret = gf_context_create(&d->context);
247  if (ret != GF_ERR_OK) {
248  qWarning("QQnxScreen: gf_context_create() failed with error code %d", ret);
249  return false;
250  }
251 
252  ret = gf_context_set_surface(d->context, d->hwSurface);
253  if (ret != GF_ERR_OK) {
254  qWarning("QQnxScreen: gf_context_set_surface() failed with error code %d", ret);
255  return false;
256  }
257 
258  return true;
259 }
gf_surface_t hwSurface
Q_CORE_EXPORT void qWarning(const char *,...)
gf_context_t context
gf_display_info_t displayInfo

◆ createMemSurface()

static bool createMemSurface ( QQnxScreenContext *const  d,
int  w,
int  h 
)
inlinestatic
Warning
This function is not part of the public interface. Creates an in-memory, linear accessible surface of dimensions w * h. This is the main surface that QWS blits to.

Definition at line 266 of file qscreenqnx_qws.cpp.

Referenced by QQnxScreen::connect().

267 {
268 #ifndef QT_NO_QWS_MULTIPROCESS
270  unsigned sidlist[64];
271  int n = gf_surface_sidlist(d->device, sidlist); // undocumented API
272  for (int i = 0; i < n; ++i) {
273  int ret = gf_surface_attach_by_sid(&d->memSurface, d->device, sidlist[i]);
274  if (ret == GF_ERR_OK) {
275  gf_surface_get_info(d->memSurface, &d->memSurfaceInfo);
276  if (d->memSurfaceInfo.sid != unsigned(GF_SID_INVALID)) {
277  // can we use the surface's vaddr?
278  unsigned flags = GF_SURFACE_CPU_LINEAR_READABLE | GF_SURFACE_CPU_LINEAR_WRITEABLE;
279  if ((d->memSurfaceInfo.flags & flags) == flags)
280  return true;
281  }
282 
283  gf_surface_free(d->memSurface);
284  d->memSurface = 0;
285  }
286  }
287  qWarning("QQnxScreen: cannot attach to an usable surface; create a new one.");
288  }
289 #endif
290  int ret = gf_surface_create(&d->memSurface, d->device, w, h, d->displayInfo.format, 0,
291  GF_SURFACE_CREATE_CPU_FAST_ACCESS | GF_SURFACE_CREATE_CPU_LINEAR_ACCESSIBLE
292  | GF_SURFACE_CREATE_PHYS_CONTIG | GF_SURFACE_CREATE_SHAREABLE);
293  if (ret != GF_ERR_OK) {
294  qWarning("QQnxScreen: gf_surface_create(%dx%d) failed with error code %d",
295  w, h, ret);
296  return false;
297  }
298 
299  gf_surface_get_info(d->memSurface, &d->memSurfaceInfo);
300 
301  if (d->memSurfaceInfo.sid == unsigned(GF_SID_INVALID)) {
302  qWarning("QQnxScreen: gf_surface_get_info() failed.");
303  return false;
304  }
305 
306  return true;
307 }
Q_CORE_EXPORT void qWarning(const char *,...)
gf_surface_t memSurface
gf_surface_info_t memSurfaceInfo
gf_display_info_t displayInfo
static Type type()
Returns the type of application (Tty , GuiClient, or GuiServer).