657 surfaceProps.removeValue(EGL_VG_ALPHA_FORMAT); |
657 surfaceProps.removeValue(EGL_VG_ALPHA_FORMAT); |
658 } |
658 } |
659 #endif |
659 #endif |
660 windowSurface = context->createSurface(widget, &surfaceProps); |
660 windowSurface = context->createSurface(widget, &surfaceProps); |
661 isPaintingActive = false; |
661 isPaintingActive = false; |
|
662 needToSwap = true; |
662 } |
663 } |
663 #else |
664 #else |
664 if (context && size != newSize) { |
665 if (context && size != newSize) { |
665 // The surface size has changed, so we need to recreate |
666 // The surface size has changed, so we need to recreate |
666 // the EGL context for the widget. We also need to recreate |
667 // the EGL context for the widget. We also need to recreate |
708 EGL_RENDER_BUFFER, &buffer) && |
709 EGL_RENDER_BUFFER, &buffer) && |
709 buffer == EGL_SINGLE_BUFFER) { |
710 buffer == EGL_SINGLE_BUFFER) { |
710 needToSwap = false; |
711 needToSwap = false; |
711 } |
712 } |
712 #endif |
713 #endif |
713 #if !defined(QVG_NO_PRESERVED_SWAP) |
|
714 // Try to force the surface back buffer to preserve its contents. |
|
715 if (needToSwap) { |
|
716 eglGetError(); // Clear error state first. |
|
717 eglSurfaceAttrib(QEglContext::display(), surface, |
|
718 EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); |
|
719 if (eglGetError() != EGL_SUCCESS) { |
|
720 qWarning("QVG: could not enable preserved swap"); |
|
721 } |
|
722 } |
|
723 #endif |
|
724 windowSurface = surface; |
714 windowSurface = surface; |
725 isPaintingActive = false; |
715 isPaintingActive = false; |
726 } |
716 } |
|
717 |
|
718 #if !defined(QVG_NO_PRESERVED_SWAP) |
|
719 // Try to force the surface back buffer to preserve its contents. |
|
720 if (needToSwap) { |
|
721 eglGetError(); // Clear error state first. |
|
722 eglSurfaceAttrib(QEglContext::display(), windowSurface, |
|
723 EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED); |
|
724 if (eglGetError() != EGL_SUCCESS) { |
|
725 qWarning("QVG: could not enable preserved swap"); |
|
726 } |
|
727 } |
|
728 #endif |
727 return context; |
729 return context; |
728 } |
730 } |
729 |
731 |
730 void QVGEGLWindowSurfaceDirect::beginPaint(QWidget *widget) |
732 void QVGEGLWindowSurfaceDirect::beginPaint(QWidget *widget) |
731 { |
733 { |
754 } |
756 } |
755 isPaintingActive = false; |
757 isPaintingActive = false; |
756 } |
758 } |
757 } |
759 } |
758 |
760 |
|
761 bool QVGEGLWindowSurfaceDirect::supportsStaticContents() const |
|
762 { |
|
763 #if defined(QVG_BUFFER_SCROLLING) && !defined(QVG_NO_PRESERVED_SWAP) |
|
764 return true; |
|
765 #else |
|
766 return QVGEGLWindowSurfacePrivate::supportsStaticContents(); |
|
767 #endif |
|
768 } |
|
769 |
|
770 bool QVGEGLWindowSurfaceDirect::scroll(QWidget *widget, const QRegion& area, int dx, int dy) |
|
771 { |
|
772 #ifdef QVG_BUFFER_SCROLLING |
|
773 QEglContext *context = ensureContext(widget); |
|
774 if (context) { |
|
775 context->makeCurrent(windowSurface); |
|
776 QRect scrollRect = area.boundingRect(); |
|
777 int sx = scrollRect.x(); |
|
778 int sy = size.height() - scrollRect.y() - scrollRect.height(); |
|
779 vgSeti(VG_SCISSORING, VG_FALSE); |
|
780 vgCopyPixels(sx + dx, sy - dy, sx, sy, scrollRect.width(), scrollRect.height()); |
|
781 context->lazyDoneCurrent(); |
|
782 return true; |
|
783 } |
|
784 #endif |
|
785 return false; |
|
786 } |
|
787 |
759 QT_END_NAMESPACE |
788 QT_END_NAMESPACE |
760 |
789 |
761 #endif |
790 #endif |