Qt 4.8
Classes | Typedefs | Enumerations | Functions
pvrqwsdrawable.h File Reference

Go to the source code of this file.

Classes

struct  PvrQwsRect
 

Typedefs

typedef struct _PvrQwsDrawable PvrQwsDrawable
 
typedef void(* PvrQwsSwapFunction) (PvrQwsDrawable *drawable, void *userData, int repaintOnly)
 

Enumerations

enum  PvrQwsDrawableType { PvrQwsScreen, PvrQwsWindow, PvrQwsPixmap }
 
enum  PvrQwsPixelFormat {
  PvrQws_1BPP = 0, PvrQws_RGB565, PvrQws_ARGB4444, PvrQws_RGB888,
  PvrQws_ARGB8888, PvrQws_VGAEMU
}
 

Functions

int pvrQwsAllocBuffers (PvrQwsDrawable *drawable)
 
void pvrQwsClearVisibleRegion (PvrQwsDrawable *drawable)
 
PvrQwsDrawablepvrQwsCreatePixmap (int width, int height, int screen)
 
PvrQwsDrawablepvrQwsCreateWindow (int screen, long winId, const PvrQwsRect *rect)
 
void pvrQwsDestroyDrawable (PvrQwsDrawable *drawable)
 
void pvrQwsDisplayClose (void)
 
int pvrQwsDisplayIsOpen (void)
 
int pvrQwsDisplayOpen (void)
 
PvrQwsDrawablepvrQwsFetchWindow (long winId)
 
void pvrQwsFreeBuffers (PvrQwsDrawable *drawable)
 
PvrQwsDrawableType pvrQwsGetDrawableType (PvrQwsDrawable *drawable)
 
void pvrQwsGetGeometry (PvrQwsDrawable *drawable, PvrQwsRect *rect)
 
PvrQwsPixelFormat pvrQwsGetPixelFormat (PvrQwsDrawable *drawable)
 
void * pvrQwsGetRenderBuffer (PvrQwsDrawable *drawable)
 
int pvrQwsGetStride (PvrQwsDrawable *drawable)
 
void pvrQwsInvalidateBuffers (PvrQwsDrawable *drawable)
 
int pvrQwsReleaseWindow (PvrQwsDrawable *drawable)
 
PvrQwsDrawablepvrQwsScreenWindow (int screen)
 
void pvrQwsSetGeometry (PvrQwsDrawable *drawable, const PvrQwsRect *rect)
 
void pvrQwsSetRotation (PvrQwsDrawable *drawable, int angle)
 
void pvrQwsSetSwapFunction (PvrQwsDrawable *drawable, PvrQwsSwapFunction func, void *userData)
 
void pvrQwsSetVisibleRegion (PvrQwsDrawable *drawable, const PvrQwsRect *rects, int numRects)
 
int pvrQwsSwapBuffers (PvrQwsDrawable *drawable, int repaintOnly)
 

Typedef Documentation

◆ PvrQwsDrawable

Definition at line 72 of file pvrqwsdrawable.h.

◆ PvrQwsSwapFunction

typedef void(* PvrQwsSwapFunction) (PvrQwsDrawable *drawable, void *userData, int repaintOnly)

Definition at line 75 of file pvrqwsdrawable.h.

Enumeration Type Documentation

◆ PvrQwsDrawableType

Enumerator
PvrQwsScreen 
PvrQwsWindow 
PvrQwsPixmap 

Definition at line 53 of file pvrqwsdrawable.h.

◆ PvrQwsPixelFormat

Enumerator
PvrQws_1BPP 
PvrQws_RGB565 
PvrQws_ARGB4444 
PvrQws_RGB888 
PvrQws_ARGB8888 
PvrQws_VGAEMU 

Definition at line 61 of file pvrqwsdrawable.h.

Function Documentation

◆ pvrQwsAllocBuffers()

int pvrQwsAllocBuffers ( PvrQwsDrawable drawable)

Definition at line 651 of file pvrqwsdrawable.c.

Referenced by wseglCreatePixmapDrawable(), and wseglCreateWindowDrawable().

652 {
653  int index;
654  int numBuffers = PVRQWS_MAX_BACK_BUFFERS;
655  if (drawable->type == PvrQwsPixmap)
656  numBuffers = 1;
657  if (drawable->backBuffers[0]) {
658  if (drawable->backBuffersValid)
659  return 1;
660  if (!drawable->usingFlipBuffers) {
661  for (index = 0; index < numBuffers; ++index)
662  PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
663  }
664  }
665  drawable->stridePixels = (drawable->rect.width + 31) & ~31;
666  drawable->strideBytes =
667  drawable->stridePixels *
669  drawable->usingFlipBuffers =
670  (pvrQwsDisplay.numFlipBuffers > 0 && drawable->isFullScreen);
671  if (drawable->usingFlipBuffers) {
672  if (numBuffers > (int)(pvrQwsDisplay.numFlipBuffers))
673  numBuffers = pvrQwsDisplay.numFlipBuffers;
674  for (index = 0; index < numBuffers; ++index)
675  drawable->backBuffers[index] = pvrQwsDisplay.flipBuffers[index];
676  } else {
677  for (index = 0; index < numBuffers; ++index) {
678  if (PVR2DMemAlloc(pvrQwsDisplay.context,
679  drawable->strideBytes * drawable->rect.height,
680  128, 0,
681  &(drawable->backBuffers[index])) != PVR2D_OK) {
682  while (--index >= 0)
683  PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
684  memset(drawable->backBuffers, 0, sizeof(drawable->backBuffers));
685  drawable->backBuffersValid = 0;
686  return 0;
687  }
688  }
689  }
690  for (index = numBuffers; index < PVRQWS_MAX_BACK_BUFFERS; ++index) {
691  drawable->backBuffers[index] = drawable->backBuffers[0];
692  }
693  drawable->backBuffersValid = 1;
694  drawable->currentBackBuffer = 0;
695  return 1;
696 }
PVR2DMEMINFO * backBuffers[PVRQWS_MAX_BACK_BUFFERS]
PVR2DCONTEXTHANDLE context
#define PVRQWS_MAX_BACK_BUFFERS
PvrQwsDisplay pvrQwsDisplay
PvrQwsDrawableType type
PVR2DMEMINFO * flipBuffers[PVRQWS_MAX_FLIP_BUFFERS]
unsigned long numFlipBuffers
quint16 index
PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS]

◆ pvrQwsClearVisibleRegion()

void pvrQwsClearVisibleRegion ( PvrQwsDrawable drawable)

Definition at line 583 of file pvrqwsdrawable.c.

Referenced by PvrEglWindowSurface::setDirectRegion().

584 {
585  if (drawable->type != PvrQwsPixmap)
586  drawable->numVisibleRects = 0;
587 }
PvrQwsDrawableType type

◆ pvrQwsCreatePixmap()

PvrQwsDrawable* pvrQwsCreatePixmap ( int  width,
int  height,
int  screen 
)

Definition at line 465 of file pvrqwsdrawable.c.

466 {
467  PvrQwsDrawable *drawable;
468 
469  if (!pvrQwsEnsureScreen(screen))
470  return 0;
471 
472  drawable = (PvrQwsDrawable *)calloc(1, sizeof(PvrQwsDrawable));
473  if (!drawable)
474  return 0;
475 
476  drawable->type = PvrQwsPixmap;
477  drawable->screen = screen;
478  drawable->pixelFormat = pvrQwsDisplay.screens[screen].pixelFormat;
479  drawable->rect.x = 0;
480  drawable->rect.y = 0;
481  drawable->rect.width = width;
482  drawable->rect.height = height;
483 
484  if (!pvrQwsAddDrawable()) {
485  free(drawable);
486  return 0;
487  }
488 
489  return drawable;
490 }
PVR2DFORMAT pixelFormat
PvrQwsDisplay pvrQwsDisplay
PvrQwsDrawableType type
#define calloc(a, b)
PVR2DFORMAT pixelFormat
PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS]
static int pvrQwsAddDrawable(void)
static int pvrQwsEnsureScreen(int screen)

◆ pvrQwsCreateWindow()

PvrQwsDrawable* pvrQwsCreateWindow ( int  screen,
long  winId,
const PvrQwsRect rect 
)

Definition at line 417 of file pvrqwsdrawable.c.

Referenced by PvrEglWindowSurface::PvrEglWindowSurface().

418 {
419  PvrQwsDrawable *drawable;
420 
421  if (!pvrQwsEnsureScreen(screen))
422  return 0;
423 
424  drawable = (PvrQwsDrawable *)calloc(1, sizeof(PvrQwsDrawable));
425  if (!drawable)
426  return 0;
427 
428  drawable->type = PvrQwsWindow;
429  drawable->winId = winId;
430  drawable->refCount = 1;
431  drawable->screen = screen;
432  drawable->pixelFormat = pvrQwsDisplay.screens[screen].pixelFormat;
433  drawable->rect = *rect;
434 
435  if (!pvrQwsAddDrawable()) {
436  free(drawable);
437  return 0;
438  }
439 
440  drawable->nextWinId = pvrQwsDisplay.firstWinId;
441  pvrQwsDisplay.firstWinId = drawable;
442 
443  return drawable;
444 }
PVR2DFORMAT pixelFormat
PvrQwsDisplay pvrQwsDisplay
PvrQwsDrawableType type
PvrQwsDrawable * nextWinId
#define calloc(a, b)
PVR2DFORMAT pixelFormat
PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS]
static int pvrQwsAddDrawable(void)
static int pvrQwsEnsureScreen(int screen)
PvrQwsDrawable * firstWinId

◆ pvrQwsDestroyDrawable()

void pvrQwsDestroyDrawable ( PvrQwsDrawable drawable)

Definition at line 516 of file pvrqwsdrawable.c.

Referenced by wseglDeleteDrawable(), and PvrEglWindowSurface::~PvrEglWindowSurface().

517 {
518  if (drawable && drawable->type != PvrQwsScreen)
519  pvrQwsDestroyDrawableForced(drawable);
520 }
PvrQwsDrawableType type
static void pvrQwsDestroyDrawableForced(PvrQwsDrawable *drawable)

◆ pvrQwsDisplayClose()

void pvrQwsDisplayClose ( void  )

Definition at line 338 of file pvrqwsdrawable.c.

Referenced by PvrEglScreen::connect(), PvrEglScreen::disconnect(), wseglCloseDisplay(), and wseglInitializeDisplay().

339 {
340  int screen;
341 
342  if (pvrQwsDisplay.refCount == 0)
343  return;
344  if (--(pvrQwsDisplay.refCount) > 0)
345  return;
346 
347  /* Prevent pvrQwsDestroyContext from being called for the time being */
349 
350  /* Free the screens */
351  for (screen = 0; screen < PVRQWS_MAX_SCREENS; ++screen) {
353  if (info->screenDrawable)
355  if (info->frameBuffer)
356  PVR2DMemFree(pvrQwsDisplay.context, info->frameBuffer);
357  if (info->mapped && info->needsUnmap)
358  munmap(info->mapped, info->mappedLength);
359  }
360 
361  /* Now it is safe to destroy the PVR2D context */
364  PVR2DDestroyDeviceContext(pvrQwsDisplay.context);
365 
366  memset(&pvrQwsDisplay, 0, sizeof(pvrQwsDisplay));
367 }
PVR2DMEMINFO * frameBuffer
static mach_timebase_info_data_t info
PVR2DCONTEXTHANDLE context
PvrQwsDisplay pvrQwsDisplay
#define PVRQWS_MAX_SCREENS
static void pvrQwsDestroyDrawableForced(PvrQwsDrawable *drawable)
PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS]
PvrQwsDrawable * screenDrawable

◆ pvrQwsDisplayIsOpen()

int pvrQwsDisplayIsOpen ( void  )

Definition at line 369 of file pvrqwsdrawable.c.

370 {
371  return (pvrQwsDisplay.refCount > 0);
372 }
PvrQwsDisplay pvrQwsDisplay

◆ pvrQwsDisplayOpen()

int pvrQwsDisplayOpen ( void  )

Definition at line 313 of file pvrqwsdrawable.c.

Referenced by PvrEglScreen::connect(), and wseglInitializeDisplay().

314 {
315  int screen;
316 
317  /* If the display is already open, increase reference count and return */
318  if (pvrQwsDisplay.refCount > 0) {
320  return 1;
321  }
322 
323  /* Open the framebuffer and map it directly */
324  if (!pvrQwsInitFbScreen(0)) {
326  return 0;
327  }
328 
329  /* Clear the other screens. We will create them if they are referenced */
330  for (screen = 1; screen < PVRQWS_MAX_SCREENS; ++screen)
331  memset(&(pvrQwsDisplay.screens[screen]), 0, sizeof(PvrQwsScreenInfo));
332 
333  /* The display is open and ready */
335  return 1;
336 }
static int pvrQwsInitFbScreen(int screen)
PvrQwsDisplay pvrQwsDisplay
#define PVRQWS_MAX_SCREENS
PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS]

◆ pvrQwsFetchWindow()

PvrQwsDrawable* pvrQwsFetchWindow ( long  winId)

Definition at line 446 of file pvrqwsdrawable.c.

Referenced by PvrEglWindowSurface::PvrEglWindowSurface(), and wseglCreateWindowDrawable().

447 {
449  while (drawable != 0 && drawable->winId != winId)
450  drawable = drawable->nextWinId;
451 
452  if (drawable)
453  ++(drawable->refCount);
454  return drawable;
455 }
PvrQwsDisplay pvrQwsDisplay
PvrQwsDrawable * nextWinId
PvrQwsDrawable * firstWinId

◆ pvrQwsFreeBuffers()

void pvrQwsFreeBuffers ( PvrQwsDrawable drawable)

Definition at line 698 of file pvrqwsdrawable.c.

Referenced by pvrQwsDestroyDrawableForced(), and wseglDeleteDrawable().

699 {
700  int index;
701  int numBuffers = PVRQWS_MAX_BACK_BUFFERS;
702  if (drawable->type == PvrQwsPixmap)
703  numBuffers = 1;
704  if (!drawable->usingFlipBuffers) {
705  for (index = 0; index < numBuffers; ++index) {
706  if (drawable->backBuffers[index])
707  PVR2DMemFree(pvrQwsDisplay.context, drawable->backBuffers[index]);
708  }
709  }
710  memset(drawable->backBuffers, 0, sizeof(drawable->backBuffers));
711  drawable->backBuffersValid = 0;
712  drawable->usingFlipBuffers = 0;
713 }
PVR2DMEMINFO * backBuffers[PVRQWS_MAX_BACK_BUFFERS]
PVR2DCONTEXTHANDLE context
#define PVRQWS_MAX_BACK_BUFFERS
PvrQwsDisplay pvrQwsDisplay
PvrQwsDrawableType type
quint16 index

◆ pvrQwsGetDrawableType()

PvrQwsDrawableType pvrQwsGetDrawableType ( PvrQwsDrawable drawable)

Definition at line 522 of file pvrqwsdrawable.c.

523 {
524  return drawable->type;
525 }
PvrQwsDrawableType type

◆ pvrQwsGetGeometry()

void pvrQwsGetGeometry ( PvrQwsDrawable drawable,
PvrQwsRect rect 
)

Definition at line 615 of file pvrqwsdrawable.c.

Referenced by PvrEglWindowSurface::image().

616 {
617  *rect = drawable->rect;
618 }

◆ pvrQwsGetPixelFormat()

PvrQwsPixelFormat pvrQwsGetPixelFormat ( PvrQwsDrawable drawable)

Definition at line 638 of file pvrqwsdrawable.c.

639 {
640  return (PvrQwsPixelFormat)(drawable->pixelFormat);
641 }
PvrQwsPixelFormat
PVR2DFORMAT pixelFormat

◆ pvrQwsGetRenderBuffer()

void* pvrQwsGetRenderBuffer ( PvrQwsDrawable drawable)

Definition at line 643 of file pvrqwsdrawable.c.

Referenced by PvrEglWindowSurface::image().

644 {
645  if (drawable->backBuffersValid)
646  return drawable->backBuffers[drawable->currentBackBuffer]->pBase;
647  else
648  return 0;
649 }
PVR2DMEMINFO * backBuffers[PVRQWS_MAX_BACK_BUFFERS]

◆ pvrQwsGetStride()

int pvrQwsGetStride ( PvrQwsDrawable drawable)

Definition at line 630 of file pvrqwsdrawable.c.

Referenced by PvrEglWindowSurface::image().

631 {
632  if (drawable->backBuffersValid)
633  return drawable->strideBytes;
634  else
635  return 0;
636 }

◆ pvrQwsInvalidateBuffers()

void pvrQwsInvalidateBuffers ( PvrQwsDrawable drawable)

Definition at line 715 of file pvrqwsdrawable.c.

Referenced by pvrQwsSetGeometry(), and pvrQwsSetRotation().

716 {
717  drawable->backBuffersValid = 0;
718 }

◆ pvrQwsReleaseWindow()

int pvrQwsReleaseWindow ( PvrQwsDrawable drawable)

Definition at line 457 of file pvrqwsdrawable.c.

Referenced by wseglDeleteDrawable(), and PvrEglWindowSurface::~PvrEglWindowSurface().

458 {
459  if (drawable->type == PvrQwsWindow)
460  return (--(drawable->refCount) <= 0);
461  else
462  return 0;
463 }
PvrQwsDrawableType type

◆ pvrQwsScreenWindow()

PvrQwsDrawable* pvrQwsScreenWindow ( int  screen)

Definition at line 384 of file pvrqwsdrawable.c.

Referenced by PvrEglScreen::PvrEglScreen(), and wseglCreateWindowDrawable().

385 {
386  PvrQwsDrawable *drawable;
387 
388  if (!pvrQwsEnsureScreen(screen))
389  return 0;
390 
391  drawable = pvrQwsDisplay.screens[screen].screenDrawable;
392  if (drawable)
393  return drawable;
394 
395  drawable = (PvrQwsDrawable *)calloc(1, sizeof(PvrQwsDrawable));
396  if (!drawable)
397  return 0;
398 
399  drawable->type = PvrQwsScreen;
400  drawable->screen = screen;
401  drawable->pixelFormat = pvrQwsDisplay.screens[screen].pixelFormat;
402  drawable->rect = pvrQwsDisplay.screens[screen].screenRect;
403  drawable->visibleRects[0] = drawable->rect;
404  drawable->numVisibleRects = 1;
405  drawable->isFullScreen = 1;
406 
407  if (!pvrQwsAddDrawable()) {
408  free(drawable);
409  return 0;
410  }
411 
412  pvrQwsDisplay.screens[screen].screenDrawable = drawable;
413 
414  return drawable;
415 }
PVR2DFORMAT pixelFormat
PvrQwsDisplay pvrQwsDisplay
PvrQwsRect screenRect
PvrQwsRect visibleRects[PVRQWS_MAX_VISIBLE_RECTS]
PvrQwsDrawableType type
#define calloc(a, b)
PVR2DFORMAT pixelFormat
PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS]
static int pvrQwsAddDrawable(void)
PvrQwsDrawable * screenDrawable
static int pvrQwsEnsureScreen(int screen)

◆ pvrQwsSetGeometry()

void pvrQwsSetGeometry ( PvrQwsDrawable drawable,
const PvrQwsRect rect 
)

Definition at line 589 of file pvrqwsdrawable.c.

Referenced by PvrEglWindowSurface::move(), PvrEglWindowSurface::PvrEglWindowSurface(), and PvrEglWindowSurface::setGeometry().

590 {
591  /* We can only change the geometry of window drawables */
592  if (drawable->type != PvrQwsWindow)
593  return;
594 
595  /* If the position has changed, then clear the visible region */
596  if (drawable->rect.x != rect->x || drawable->rect.y != rect->y) {
597  drawable->rect.x = rect->x;
598  drawable->rect.y = rect->y;
599  drawable->numVisibleRects = 0;
600  }
601 
602  /* If the size has changed, then clear the visible region and
603  invalidate the drawable's buffers. Invalidating the buffers
604  will force EGL to recreate the drawable, which will then
605  allocate new buffers for the new size */
606  if (drawable->rect.width != rect->width ||
607  drawable->rect.height != rect->height) {
608  drawable->rect.width = rect->width;
609  drawable->rect.height = rect->height;
610  drawable->numVisibleRects = 0;
611  pvrQwsInvalidateBuffers(drawable);
612  }
613 }
PvrQwsDrawableType type
void pvrQwsInvalidateBuffers(PvrQwsDrawable *drawable)

◆ pvrQwsSetRotation()

void pvrQwsSetRotation ( PvrQwsDrawable drawable,
int  angle 
)

Definition at line 620 of file pvrqwsdrawable.c.

Referenced by PvrEglWindowSurface::move(), PvrEglWindowSurface::PvrEglWindowSurface(), PvrEglWindowSurface::setDirectRegion(), and PvrEglWindowSurface::setGeometry().

621 {
622  if (drawable->rotationAngle != angle) {
623  drawable->rotationAngle = angle;
624 
625  /* Force the buffers to be recreated if the rotation angle changes */
626  pvrQwsInvalidateBuffers(drawable);
627  }
628 }
void pvrQwsInvalidateBuffers(PvrQwsDrawable *drawable)
qreal angle(const QPointF &p1, const QPointF &p2)

◆ pvrQwsSetSwapFunction()

void pvrQwsSetSwapFunction ( PvrQwsDrawable drawable,
PvrQwsSwapFunction  func,
void *  userData 
)

Definition at line 826 of file pvrqwsdrawable.c.

Referenced by pvrQwsSwapBuffers().

827 {
828  drawable->swapFunction = func;
829  drawable->userData = userData;
830 }
PvrQwsSwapFunction swapFunction

◆ pvrQwsSetVisibleRegion()

void pvrQwsSetVisibleRegion ( PvrQwsDrawable drawable,
const PvrQwsRect rects,
int  numRects 
)

Definition at line 528 of file pvrqwsdrawable.c.

Referenced by pvrQwsGetDrawableType(), and PvrEglWindowSurface::setDirectRegion().

529 {
530  int index, indexOut;
531  PvrQwsRect *rect;
532  PvrQwsRect *screenRect;
533 
534  /* Visible regions don't make sense for pixmaps */
535  if (drawable->type == PvrQwsPixmap)
536  return;
537 
538  /* Restrict the number of rectangles to prevent buffer overflow */
539  if (numRects > PVRQWS_MAX_VISIBLE_RECTS)
540  numRects = PVRQWS_MAX_VISIBLE_RECTS;
541  if (numRects > 0)
542  memcpy(drawable->visibleRects, rects, numRects * sizeof(PvrQwsRect));
543 
544  /* Convert the rectangles into screen-relative co-ordinates and
545  then clamp them to the screen boundaries. If any of the
546  clamped rectangles are empty, remove them from the list */
547  screenRect = &(pvrQwsDisplay.screens[drawable->screen].screenRect);
548  indexOut = 0;
549  for (index = 0, rect = drawable->visibleRects; index < numRects; ++index, ++rect) {
550  if (rect->x < 0) {
551  rect->width += rect->x;
552  rect->x = 0;
553  if (rect->width < 0)
554  rect->width = 0;
555  } else if (rect->x >= screenRect->width) {
556  rect->x = screenRect->width;
557  rect->width = 0;
558  }
559  if ((rect->x + rect->width) > screenRect->width) {
560  rect->width = screenRect->width - rect->x;
561  }
562  if (rect->y < 0) {
563  rect->height += rect->y;
564  rect->y = 0;
565  if (rect->height < 0)
566  rect->height = 0;
567  } else if (rect->y >= screenRect->height) {
568  rect->y = screenRect->height;
569  rect->height = 0;
570  }
571  if ((rect->y + rect->height) > screenRect->height) {
572  rect->height = screenRect->height - rect->y;
573  }
574  if (rect->width > 0 && rect->height > 0) {
575  if (index != indexOut)
576  drawable->visibleRects[indexOut] = *rect;
577  ++indexOut;
578  }
579  }
580  drawable->numVisibleRects = indexOut;
581 }
PvrQwsDisplay pvrQwsDisplay
PvrQwsRect screenRect
PvrQwsRect visibleRects[PVRQWS_MAX_VISIBLE_RECTS]
PvrQwsDrawableType type
quint16 index
#define PVRQWS_MAX_VISIBLE_RECTS
PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS]

◆ pvrQwsSwapBuffers()

int pvrQwsSwapBuffers ( PvrQwsDrawable drawable,
int  repaintOnly 
)

Definition at line 732 of file pvrqwsdrawable.c.

Referenced by PvrEglWindowSurface::setDirectRegion(), and wseglSwapDrawable().

733 {
734  PVR2DMEMINFO *buffer;
735  PvrQwsRect *rect;
736  int index;
737 
738  /* Bail out if the back buffers have been invalidated */
739  if (!drawable->backBuffersValid)
740  return 0;
741 
742  /* If there is a swap function, then use that instead */
743  if (drawable->swapFunction) {
744  (*(drawable->swapFunction))(drawable, drawable->userData, repaintOnly);
745  if (!repaintOnly) {
746  drawable->currentBackBuffer
747  = (drawable->currentBackBuffer + 1) % PVRQWS_MAX_BACK_BUFFERS;
748  }
749  return 1;
750  }
751 
752  /* Iterate through the visible rectangles and blit them to the screen */
753  if (!repaintOnly) {
754  index = drawable->currentBackBuffer;
755  } else {
756  index = (drawable->currentBackBuffer + PVRQWS_MAX_BACK_BUFFERS - 1)
758  }
759  buffer = drawable->backBuffers[index];
760  rect = drawable->visibleRects;
761  if (drawable->usingFlipBuffers) {
762  PVR2DPresentFlip(pvrQwsDisplay.context, pvrQwsDisplay.flipChain, buffer, 0);
763  } else if (pvrQwsDisplay.usePresentBlit && drawable->numVisibleRects > 0) {
764  PVR2DRECT pvrRects[PVRQWS_MAX_VISIBLE_RECTS];
765  for (index = 0; index < drawable->numVisibleRects; ++index, ++rect) {
766  pvrRects[index].left = rect->x;
767  pvrRects[index].top = rect->y;
768  pvrRects[index].right = rect->x + rect->width;
769  pvrRects[index].bottom = rect->y + rect->height;
770  }
771  for (index = 0; index < drawable->numVisibleRects; index += 4) {
772  int numClip = drawable->numVisibleRects - index;
773  if (numClip > 4) /* No more than 4 clip rects at a time */
774  numClip = 4;
775  PVR2DSetPresentBltProperties
777  PVR2D_PRESENT_PROPERTY_SRCSTRIDE |
778  PVR2D_PRESENT_PROPERTY_DSTSIZE |
779  PVR2D_PRESENT_PROPERTY_DSTPOS |
780  PVR2D_PRESENT_PROPERTY_CLIPRECTS,
781  drawable->strideBytes,
782  drawable->rect.width, drawable->rect.height,
783  drawable->rect.x, drawable->rect.y,
784  numClip, pvrRects + index, 0);
785  PVR2DPresentBlt(pvrQwsDisplay.context, buffer, 0);
786  }
787  PVR2DQueryBlitsComplete(pvrQwsDisplay.context, buffer, 1);
788  } else {
789  /* TODO: use PVR2DBltClipped for faster transfers of clipped windows */
790  PVR2DBLTINFO blit;
791  for (index = 0; index < drawable->numVisibleRects; ++index, ++rect) {
792  memset(&blit, 0, sizeof(blit));
793 
794  blit.CopyCode = PVR2DROPcopy;
795  blit.BlitFlags = PVR2D_BLIT_DISABLE_ALL;
796 
797  blit.pSrcMemInfo = buffer;
798  blit.SrcStride = drawable->strideBytes;
799  blit.SrcX = rect->x - drawable->rect.x;
800  blit.SrcY = rect->y - drawable->rect.y;
801  blit.SizeX = rect->width;
802  blit.SizeY = rect->height;
803  blit.SrcFormat = drawable->pixelFormat;
804 
805  blit.pDstMemInfo = pvrQwsDisplay.screens[drawable->screen].frameBuffer;
806  blit.DstStride = pvrQwsDisplay.screens[drawable->screen].screenStride;
807  blit.DstX = rect->x;
808  blit.DstY = rect->y;
809  blit.DSizeX = rect->width;
810  blit.DSizeY = rect->height;
811  blit.DstFormat = pvrQwsDisplay.screens[drawable->screen].pixelFormat;
812 
813  PVR2DBlt(pvrQwsDisplay.context, &blit);
814  }
815  }
816 
817  /* Swap the buffers */
818  if (!repaintOnly) {
819  drawable->currentBackBuffer
820  = (drawable->currentBackBuffer + 1) % PVRQWS_MAX_BACK_BUFFERS;
821  }
822  return 1;
823 }
PVR2DMEMINFO * backBuffers[PVRQWS_MAX_BACK_BUFFERS]
PVR2DMEMINFO * frameBuffer
PVR2DFORMAT pixelFormat
PVR2DFLIPCHAINHANDLE flipChain
PVR2DCONTEXTHANDLE context
#define PVRQWS_MAX_BACK_BUFFERS
PvrQwsDisplay pvrQwsDisplay
PvrQwsRect visibleRects[PVRQWS_MAX_VISIBLE_RECTS]
PvrQwsSwapFunction swapFunction
PVR2DFORMAT pixelFormat
quint16 index
#define PVRQWS_MAX_VISIBLE_RECTS
PvrQwsScreenInfo screens[PVRQWS_MAX_SCREENS]