Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/openvg/qwindowsurface_vgegl.cpp

    r651 r769  
    178178    } else {
    179179        QVGSharedContext *shared = sharedContext();
    180         shared->firstPixmap = pd->next;
     180        if (shared)
     181           shared->firstPixmap = pd->next;
    181182    }
    182183}
     
    226227    context = new QEglContext();
    227228    context->setApi(QEgl::OpenVG);
    228     if (!context->openDisplay(device)) {
    229         delete context;
    230         return 0;
    231     }
    232229
    233230    // Set the swap interval for the display.
    234231    QByteArray interval = qgetenv("QT_VG_SWAP_INTERVAL");
    235232    if (!interval.isEmpty())
    236         eglSwapInterval(context->display(), interval.toInt());
     233        eglSwapInterval(QEglContext::display(), interval.toInt());
    237234    else
    238         eglSwapInterval(context->display(), 1);
     235        eglSwapInterval(QEglContext::display(), 1);
    239236
    240237#ifdef EGL_RENDERABLE_TYPE
     
    250247        EGLConfig cfg;
    251248        if (eglChooseConfig
    252                     (context->display(), properties, &cfg, 1, &matching) &&
     249                    (QEglContext::display(), properties, &cfg, 1, &matching) &&
    253250                matching > 0) {
    254251            // Check that the selected configuration actually supports OpenVG
     
    257254            EGLint type = 0;
    258255            eglGetConfigAttrib
    259                 (context->display(), cfg, EGL_CONFIG_ID, &id);
     256                (QEglContext::display(), cfg, EGL_CONFIG_ID, &id);
    260257            eglGetConfigAttrib
    261                 (context->display(), cfg, EGL_RENDERABLE_TYPE, &type);
     258                (QEglContext::display(), cfg, EGL_RENDERABLE_TYPE, &type);
    262259            if (cfgId == id && (type & EGL_OPENVG_BIT) != 0) {
    263260                context->setConfig(cfg);
     
    338335    shared->context->doneCurrent();
    339336    if (shared->surface != EGL_NO_SURFACE) {
    340         eglDestroySurface(shared->context->display(), shared->surface);
     337        eglDestroySurface(QEglContext::display(), shared->surface);
    341338        shared->surface = EGL_NO_SURFACE;
    342339    }
     
    416413        }
    417414        shared->surface = eglCreatePbufferSurface
    418             (shared->context->display(), shared->context->config(), attribs);
     415            (QEglContext::display(), shared->context->config(), attribs);
    419416    }
    420417    return shared->surface;
     
    559556            recreateBackBuffer = false;
    560557            if (backBufferSurface != EGL_NO_SURFACE) {
    561                 eglDestroySurface(context->display(), backBufferSurface);
     558                eglDestroySurface(QEglContext::display(), backBufferSurface);
    562559                backBufferSurface = EGL_NO_SURFACE;
    563560            }
     
    572569                // Create an EGL surface for rendering into the VGImage.
    573570                backBufferSurface = eglCreatePbufferFromClientBuffer
    574                     (context->display(), EGL_OPENVG_IMAGE,
     571                    (QEglContext::display(), EGL_OPENVG_IMAGE,
    575572                     (EGLClientBuffer)(backBuffer),
    576573                     context->config(), NULL);
     
    663660        windowSurface = context->createSurface(widget, &surfaceProps);
    664661        isPaintingActive = false;
     662        needToSwap = true;
    665663    }
    666664#else
     
    708706        // Did we get a direct to window rendering surface?
    709707        EGLint buffer = 0;
    710         if (eglQueryContext(context->display(), context->context(),
     708        if (eglQueryContext(QEglContext::display(), context->context(),
    711709                            EGL_RENDER_BUFFER, &buffer) &&
    712710                buffer == EGL_SINGLE_BUFFER) {
     
    714712        }
    715713#endif
    716 #if !defined(QVG_NO_PRESERVED_SWAP)
    717         // Try to force the surface back buffer to preserve its contents.
    718         if (needToSwap) {
    719             eglGetError();  // Clear error state first.
    720             eglSurfaceAttrib(context->display(), surface,
    721                              EGL_SWAP_BEHAVIOR, EGL_BUFFER_PRESERVED);
    722             if (eglGetError() != EGL_SUCCESS) {
    723                 qWarning("QVG: could not enable preserved swap");
    724             }
    725         }
    726 #endif
    727714        windowSurface = surface;
    728715        isPaintingActive = false;
    729716    }
     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
    730729    return context;
    731730}
     
    760759}
    761760
     761bool 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
     770bool 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
    762788QT_END_NAMESPACE
    763789
Note: See TracChangeset for help on using the changeset viewer.