diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2010-11-27 00:00:12 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2010-11-27 00:00:12 (GMT) |
commit | 1111ad218d6f54434570a8e3141eb37b7370ce01 (patch) | |
tree | 1d7b9f69b335a44315b89c15fce5fbb1b0008cb0 /src | |
parent | 4ccef56d692e549e00b0c381f1ceb8e9191a3b15 (diff) | |
parent | 66ca4c949adaae5e3e07bbb776646bee283effdc (diff) | |
download | Qt-1111ad218d6f54434570a8e3141eb37b7370ce01.zip Qt-1111ad218d6f54434570a8e3141eb37b7370ce01.tar.gz Qt-1111ad218d6f54434570a8e3141eb37b7370ce01.tar.bz2 |
Merge branch 'master-upstream' into master-water
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qfilesystemwatcher.cpp | 10 | ||||
-rw-r--r-- | src/corelib/io/qfilesystemwatcher_kqueue.cpp | 194 | ||||
-rw-r--r-- | src/gui/dialogs/dialogs.pri | 2 | ||||
-rw-r--r-- | src/gui/kernel/qcocoaview_mac.mm | 2 | ||||
-rw-r--r-- | src/gui/painting/qpaintengine_mac.cpp | 3 | ||||
-rw-r--r-- | src/gui/painting/qunifiedtoolbarsurface_mac.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qwindowsurface_mac.cpp | 2 | ||||
-rw-r--r-- | src/gui/painting/qwindowsurface_raster.cpp | 3 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject.cpp | 40 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject.h | 3 | ||||
-rw-r--r-- | src/opengl/qglframebufferobject_p.h | 13 |
11 files changed, 158 insertions, 116 deletions
diff --git a/src/corelib/io/qfilesystemwatcher.cpp b/src/corelib/io/qfilesystemwatcher.cpp index 3a7d795..4d0d495 100644 --- a/src/corelib/io/qfilesystemwatcher.cpp +++ b/src/corelib/io/qfilesystemwatcher.cpp @@ -228,8 +228,14 @@ void QPollingFileSystemWatcherEngine::timeout() dit.remove(); emit directoryChanged(path, true); } else if (x.value() != fi) { - x.value() = fi; - emit directoryChanged(path, false); + fi.refresh(); + if (!fi.exists()) { + dit.remove(); + emit directoryChanged(path, true); + } else { + x.value() = fi; + emit directoryChanged(path, false); + } } } diff --git a/src/corelib/io/qfilesystemwatcher_kqueue.cpp b/src/corelib/io/qfilesystemwatcher_kqueue.cpp index 7960792..68994d2 100644 --- a/src/corelib/io/qfilesystemwatcher_kqueue.cpp +++ b/src/corelib/io/qfilesystemwatcher_kqueue.cpp @@ -119,67 +119,77 @@ QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths, QStringList *files, QStringList *directories) { - QMutexLocker locker(&mutex); - QStringList p = paths; - QMutableListIterator<QString> it(p); - while (it.hasNext()) { - QString path = it.next(); - int fd; + { + QMutexLocker locker(&mutex); + + QMutableListIterator<QString> it(p); + while (it.hasNext()) { + QString path = it.next(); + int fd; #if defined(O_EVTONLY) - fd = qt_safe_open(QFile::encodeName(path), O_EVTONLY); + fd = qt_safe_open(QFile::encodeName(path), O_EVTONLY); #else - fd = qt_safe_open(QFile::encodeName(path), O_RDONLY); + fd = qt_safe_open(QFile::encodeName(path), O_RDONLY); #endif - if (fd == -1) { - perror("QKqueueFileSystemWatcherEngine::addPaths: open"); - continue; - } + if (fd == -1) { + perror("QKqueueFileSystemWatcherEngine::addPaths: open"); + continue; + } + if (fd >= (int)FD_SETSIZE / 2 && fd < (int)FD_SETSIZE) { + int fddup = fcntl(fd, F_DUPFD, FD_SETSIZE); + if (fddup != -1) { + ::close(fd); + fd = fddup; + } + } + fcntl(fd, F_SETFD, FD_CLOEXEC); - QT_STATBUF st; - if (QT_FSTAT(fd, &st) == -1) { - perror("QKqueueFileSystemWatcherEngine::addPaths: fstat"); - ::close(fd); - continue; - } - int id = (S_ISDIR(st.st_mode)) ? -fd : fd; - if (id < 0) { - if (directories->contains(path)) { + QT_STATBUF st; + if (QT_FSTAT(fd, &st) == -1) { + perror("QKqueueFileSystemWatcherEngine::addPaths: fstat"); ::close(fd); continue; } - } else { - if (files->contains(path)) { + int id = (S_ISDIR(st.st_mode)) ? -fd : fd; + if (id < 0) { + if (directories->contains(path)) { + ::close(fd); + continue; + } + } else { + if (files->contains(path)) { + ::close(fd); + continue; + } + } + + struct kevent kev; + EV_SET(&kev, + fd, + EVFILT_VNODE, + EV_ADD | EV_ENABLE | EV_CLEAR, + NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE, + 0, + 0); + if (kevent(kqfd, &kev, 1, 0, 0, 0) == -1) { + perror("QKqueueFileSystemWatcherEngine::addPaths: kevent"); ::close(fd); continue; } - } - struct kevent kev; - EV_SET(&kev, - fd, - EVFILT_VNODE, - EV_ADD | EV_ENABLE | EV_ONESHOT, - NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE, - 0, - 0); - if (kevent(kqfd, &kev, 1, 0, 0, 0) == -1) { - perror("QKqueueFileSystemWatcherEngine::addPaths: kevent"); - ::close(fd); - continue; - } + it.remove(); + if (id < 0) { + DEBUG() << "QKqueueFileSystemWatcherEngine: added directory path" << path; + directories->append(path); + } else { + DEBUG() << "QKqueueFileSystemWatcherEngine: added file path" << path; + files->append(path); + } - it.remove(); - if (id < 0) { - DEBUG() << "QKqueueFileSystemWatcherEngine: added directory path" << path; - directories->append(path); - } else { - DEBUG() << "QKqueueFileSystemWatcherEngine: added file path" << path; - files->append(path); + pathToID.insert(path, id); + idToPath.insert(id, path); } - - pathToID.insert(path, id); - idToPath.insert(id, path); } if (!isRunning()) @@ -194,43 +204,35 @@ QStringList QKqueueFileSystemWatcherEngine::removePaths(const QStringList &paths QStringList *files, QStringList *directories) { - QMutexLocker locker(&mutex); - + bool isEmpty; QStringList p = paths; - QMutableListIterator<QString> it(p); - while (it.hasNext()) { - QString path = it.next(); - int id = pathToID.take(path); - QString x = idToPath.take(id); - if (x.isEmpty() || x != path) - continue; - - int fd = id < 0 ? -id : id; - struct kevent kev; - EV_SET(&kev, - fd, - EVFILT_VNODE, - EV_DELETE, - NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE, - 0, - 0); - if (kevent(kqfd, &kev, 1, 0, 0, 0) == -1) { - perror("QKqueueFileSystemWatcherEngine::removeWatch: kevent"); - } - ::close(fd); + { + QMutexLocker locker(&mutex); + if (pathToID.isEmpty()) + return p; + + QMutableListIterator<QString> it(p); + while (it.hasNext()) { + QString path = it.next(); + int id = pathToID.take(path); + QString x = idToPath.take(id); + if (x.isEmpty() || x != path) + continue; - it.remove(); - if (id < 0) - directories->removeAll(path); - else - files->removeAll(path); + ::close(id < 0 ? -id : id); + + it.remove(); + if (id < 0) + directories->removeAll(path); + else + files->removeAll(path); + } + isEmpty = pathToID.isEmpty(); } - if (pathToID.isEmpty()) { + if (isEmpty) { stop(); - locker.unlock(); wait(); - locker.relock(); } else { write(kqpipe[1], "@", 1); } @@ -245,19 +247,15 @@ void QKqueueFileSystemWatcherEngine::stop() void QKqueueFileSystemWatcherEngine::run() { - static const struct timespec ZeroTimeout = { 0, 0 }; - forever { + int r; struct kevent kev; DEBUG() << "QKqueueFileSystemWatcherEngine: waiting for kevents..."; - int r = kevent(kqfd, 0, 0, &kev, 1, 0); + EINTR_LOOP(r, kevent(kqfd, 0, 0, &kev, 1, 0)); if (r < 0) { perror("QKqueueFileSystemWatcherEngine: error during kevent wait"); return; - } - - QMutexLocker locker(&mutex); - do { + } else { int fd = kev.ident; DEBUG() << "QKqueueFileSystemWatcherEngine: processing kevent" << kev.ident << kev.filter; @@ -289,6 +287,8 @@ void QKqueueFileSystemWatcherEngine::run() break; } } else { + QMutexLocker locker(&mutex); + int id = fd; QString path = idToPath.value(id); if (path.isEmpty()) { @@ -297,12 +297,12 @@ void QKqueueFileSystemWatcherEngine::run() path = idToPath.value(id); if (path.isEmpty()) { DEBUG() << "QKqueueFileSystemWatcherEngine: received a kevent for a file we're not watching"; - goto process_next_event; + continue; } } if (kev.filter != EVFILT_VNODE) { DEBUG() << "QKqueueFileSystemWatcherEngine: received a kevent with the wrong filter"; - goto process_next_event; + continue; } if ((kev.fflags & (NOTE_DELETE | NOTE_REVOKE | NOTE_RENAME)) != 0) { @@ -317,31 +317,15 @@ void QKqueueFileSystemWatcherEngine::run() else emit fileChanged(path, true); } else { - DEBUG() << path << "changed, re-enabling watch"; + DEBUG() << path << "changed"; if (id < 0) emit directoryChanged(path, false); else emit fileChanged(path, false); - - // renable the watch - EV_SET(&kev, - fd, - EVFILT_VNODE, - EV_ADD | EV_ENABLE | EV_ONESHOT, - NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE, - 0, - 0); - if (kevent(kqfd, &kev, 1, 0, 0, 0) == -1) { - perror("QKqueueFileSystemWatcherEngine::processKqueueEvents: kevent EV_ADD"); - } } } - - // are there any more? -process_next_event: - r = kevent(kqfd, 0, 0, &kev, 1, &ZeroTimeout); - } while (r > 0); + } } } diff --git a/src/gui/dialogs/dialogs.pri b/src/gui/dialogs/dialogs.pri index fc1ea9e..6ba707c 100644 --- a/src/gui/dialogs/dialogs.pri +++ b/src/gui/dialogs/dialogs.pri @@ -109,7 +109,7 @@ SOURCES += \ dialogs/qprintpreviewdialog.cpp symbian:contains(QT_CONFIG, s60) { - LIBS += -lcommondialogs + LIBS += -lCommonDialogs SOURCES += dialogs/qfiledialog_symbian.cpp \ dialogs/qcolordialog_symbian.cpp } diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index d5363bd..e02cf11 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -554,6 +554,7 @@ static int qCocoaViewCount = 0; } CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; + CGContextRetain(cg); qwidgetprivate->hd = cg; // We steal the CGContext for flushing in the unified toolbar with the raster engine. @@ -653,6 +654,7 @@ static int qCocoaViewCount = 0; } qwidgetprivate->hd = 0; CGContextRestoreGState(cg); + CGContextRelease(cg); } - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent diff --git a/src/gui/painting/qpaintengine_mac.cpp b/src/gui/painting/qpaintengine_mac.cpp index e5323d8..601cf86 100644 --- a/src/gui/painting/qpaintengine_mac.cpp +++ b/src/gui/painting/qpaintengine_mac.cpp @@ -131,8 +131,9 @@ QMacCGContext::QMacCGContext(QPainter *p) CGContextTranslateCTM(context, native.dx(), native.dy()); } + } else { + CGContextRetain(context); } - CGContextRetain(context); } diff --git a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp index b25757b..ace0a46 100644 --- a/src/gui/painting/qunifiedtoolbarsurface_mac.cpp +++ b/src/gui/painting/qunifiedtoolbarsurface_mac.cpp @@ -188,6 +188,8 @@ void QUnifiedToolbarSurface::flush(QWidget *widget, const QRegion &rgn, const QP // Restore context. CGContextRestoreGState(context); + CGContextRelease(context); + widget->d_func()->cgContext = 0; widget->d_func()->hasOwnContext = false; } diff --git a/src/gui/painting/qwindowsurface_mac.cpp b/src/gui/painting/qwindowsurface_mac.cpp index 1c97ebb..9f24532 100644 --- a/src/gui/painting/qwindowsurface_mac.cpp +++ b/src/gui/painting/qwindowsurface_mac.cpp @@ -82,6 +82,7 @@ void QMacWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint extern CGContextRef qt_mac_graphicsContextFor(QWidget *); CGContextRef context = qt_mac_graphicsContextFor(widget); #endif + CGContextRetain(context); CGContextSaveGState(context); // Flip context. @@ -109,6 +110,7 @@ void QMacWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoint #else CGContextFlush(context); #endif + CGContextRelease(context); } void QMacWindowSurface::setGeometry(const QRect &rect) diff --git a/src/gui/painting/qwindowsurface_raster.cpp b/src/gui/painting/qwindowsurface_raster.cpp index ae73d7d..2b4e125 100644 --- a/src/gui/painting/qwindowsurface_raster.cpp +++ b/src/gui/painting/qwindowsurface_raster.cpp @@ -285,6 +285,7 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi extern CGContextRef qt_mac_graphicsContextFor(QWidget *); CGContextRef context = qt_mac_graphicsContextFor(widget); #endif + CGContextRetain(context); CGContextSaveGState(context); // Flip context. @@ -317,6 +318,8 @@ void QRasterWindowSurface::flush(QWidget *widget, const QRegion &rgn, const QPoi // Restore context. CGContextRestoreGState(context); + CGContextRelease(context); + #endif // Q_WS_MAC diff --git a/src/opengl/qglframebufferobject.cpp b/src/opengl/qglframebufferobject.cpp index 8915b5e..a7e81b2 100644 --- a/src/opengl/qglframebufferobject.cpp +++ b/src/opengl/qglframebufferobject.cpp @@ -202,6 +202,35 @@ int QGLFramebufferObjectFormat::samples() const } /*! + \since 4.8 + + Enables or disables mipmapping. Mipmapping is disabled by default. + If mipmapping is enabled, additional memory will be allocated for + the mipmap levels. The mipmap levels can be updated by binding the + texture and calling glGenerateMipmap(). Mipmapping cannot be enabled + for multisampled framebuffer objects. + + \sa mipmap(), texture() +*/ +void QGLFramebufferObjectFormat::setMipmap(bool enabled) +{ + detach(); + d->mipmap = enabled; +} + +/*! + \since 4.8 + + Returns true if mipmapping is enabled. + + \sa setMipmap() +*/ +bool QGLFramebufferObjectFormat::mipmap() const +{ + return d->mipmap; +} + +/*! Sets the attachment configuration of a framebuffer object to \a attachment. \sa attachment() @@ -398,7 +427,8 @@ bool QGLFramebufferObjectPrivate::checkFramebufferStatus() const void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, QGLFramebufferObject::Attachment attachment, - GLenum texture_target, GLenum internal_format, GLint samples) + GLenum texture_target, GLenum internal_format, + GLint samples, bool mipmap) { QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext()); fbo_guard.setContext(ctx); @@ -426,6 +456,8 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, glBindTexture(target, texture); glTexImage2D(target, 0, internal_format, size.width(), size.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + if (mipmap) + glGenerateMipmap(GL_TEXTURE_2D); #ifndef QT_OPENGL_ES glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); @@ -446,6 +478,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, color_buffer = 0; } else { + mipmap = false; GLint maxSamples; glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples); @@ -606,6 +639,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz, format.setSamples(int(samples)); format.setAttachment(fbo_attachment); format.setInternalTextureFormat(internal_format); + format.setMipmap(mipmap); } /*! @@ -777,7 +811,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, const QGLFramebuff { Q_D(QGLFramebufferObject); d->init(this, size, format.attachment(), format.textureTarget(), format.internalTextureFormat(), - format.samples()); + format.samples(), format.mipmap()); } /*! \overload @@ -791,7 +825,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, const QGLFrame { Q_D(QGLFramebufferObject); d->init(this, QSize(width, height), format.attachment(), format.textureTarget(), - format.internalTextureFormat(), format.samples()); + format.internalTextureFormat(), format.samples(), format.mipmap()); } #ifdef Q_MAC_COMPAT_GL_FUNCTIONS diff --git a/src/opengl/qglframebufferobject.h b/src/opengl/qglframebufferobject.h index 6ff6645..70d6eb2 100644 --- a/src/opengl/qglframebufferobject.h +++ b/src/opengl/qglframebufferobject.h @@ -148,6 +148,9 @@ public: void setSamples(int samples); int samples() const; + void setMipmap(bool enabled); + bool mipmap() const; + void setAttachment(QGLFramebufferObject::Attachment attachment); QGLFramebufferObject::Attachment attachment() const; diff --git a/src/opengl/qglframebufferobject_p.h b/src/opengl/qglframebufferobject_p.h index 58b4e9e..3738780 100644 --- a/src/opengl/qglframebufferobject_p.h +++ b/src/opengl/qglframebufferobject_p.h @@ -77,7 +77,8 @@ public: samples(0), attachment(QGLFramebufferObject::NoAttachment), target(GL_TEXTURE_2D), - internal_format(DEFAULT_FORMAT) + internal_format(DEFAULT_FORMAT), + mipmap(false) { } QGLFramebufferObjectFormatPrivate @@ -86,7 +87,8 @@ public: samples(other->samples), attachment(other->attachment), target(other->target), - internal_format(other->internal_format) + internal_format(other->internal_format), + mipmap(other->mipmap) { } bool equals(const QGLFramebufferObjectFormatPrivate *other) @@ -94,7 +96,8 @@ public: return samples == other->samples && attachment == other->attachment && target == other->target && - internal_format == other->internal_format; + internal_format == other->internal_format && + mipmap == other->mipmap; } QAtomicInt ref; @@ -102,6 +105,7 @@ public: QGLFramebufferObject::Attachment attachment; GLenum target; GLenum internal_format; + uint mipmap : 1; }; class QGLFBOGLPaintDevice : public QGLPaintDevice @@ -132,7 +136,8 @@ public: void init(QGLFramebufferObject *q, const QSize& sz, QGLFramebufferObject::Attachment attachment, - GLenum internal_format, GLenum texture_target, GLint samples = 0); + GLenum internal_format, GLenum texture_target, + GLint samples = 0, bool mipmap = false); bool checkFramebufferStatus() const; QGLSharedResourceGuard fbo_guard; GLuint texture; |