From 31f1ff91028dd7f90925d5b3737e4d88b5fb07aa Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 16 Oct 2009 16:18:36 +0200 Subject: Send posted events in response to WM_QT_SENDPOSTEDEVENTS (which is just WM_USER+1) Delay the next WM_QT_SENDPOSTEDEVENTS iff there is a WM_TIMER or input event pending We also need to break out of processEvents() after seeing this message, to prevent livelocking in the prescence of fast timers. I also took the liberty of defining WM_QT_SOCKETNOTIFIER (WM_USER) at the same time (to give clear meaning to what WM_USER and WM_USER+1 are used for). Reviewed-by: Prasanth Ullattil --- src/corelib/kernel/qeventdispatcher_win.cpp | 178 +++++++++++++++------------- 1 file changed, 94 insertions(+), 84 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 1e6402f..f7de29d 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -64,6 +64,11 @@ extern uint qGlobalPostedEventsCount(); # define TIME_KILL_SYNCHRONOUS 0x0100 #endif +enum { + WM_QT_SOCKETNOTIFIER = WM_USER, + WM_QT_SENDPOSTEDEVENTS = WM_USER + 1 +}; + #if defined(Q_OS_WINCE) QT_BEGIN_INCLUDE_NAMESPACE #include @@ -327,6 +332,11 @@ public: // internal window handle used for socketnotifiers/timers/etc HWND internalHwnd; + // for controlling when to send posted events + QAtomicInt serialNumber; + int lastSerialNumber; + QAtomicInt wakeUps; + // timers WinTimerVec timerVec; WinTimerDict timerDict; @@ -340,9 +350,6 @@ public: QSNDict sn_except; void doWsaAsyncSelect(int socket); - // event notifier - QWinEventNotifier wakeUpNotifier; - QList winEventNotifierList; void activateEventNotifier(QWinEventNotifier * wen); @@ -351,19 +358,13 @@ public: }; QEventDispatcherWin32Private::QEventDispatcherWin32Private() - : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0) + : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), serialNumber(0), lastSerialNumber(0), wakeUps(0) { resolveTimerAPI(); - - wakeUpNotifier.setHandle(CreateEvent(0, FALSE, FALSE, 0)); - if (!wakeUpNotifier.handle()) - qWarning("QEventDispatcher: Creating QEventDispatcherWin32Private wakeup event failed"); } QEventDispatcherWin32Private::~QEventDispatcherWin32Private() { - wakeUpNotifier.setEnabled(false); - CloseHandle(wakeUpNotifier.handle()); if (internalHwnd) DestroyWindow(internalHwnd); QString className = QLatin1String("QEventDispatcherWin32_Internal_Widget") + QString::number(quintptr(qt_internal_proc)); @@ -408,22 +409,35 @@ void WINAPI CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/, DWORD_P LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) { - if (message == WM_NCCREATE) { - return true; - } else if (message == WM_USER) { + if (message == WM_NCCREATE) + return true; - // socket notifier message - MSG msg; - msg.hwnd = hwnd; - msg.message = message; - msg.wParam = wp; - msg.lParam = lp; + MSG msg; + msg.hwnd = hwnd; + msg.message = message; + msg.wParam = wp; + msg.lParam = lp; + QCoreApplication *app = QCoreApplication::instance(); + long result; + if (!app) { + if (message == WM_TIMER) + KillTimer(hwnd, wp); + return 0; + } else if (app->filterEvent(&msg, &result)) { + return result; + } - QCoreApplication *app = QCoreApplication::instance(); - long result; - if (app && app->filterEvent(&msg, &result)) - return result; +#ifdef GWLP_USERDATA + QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLongPtr(hwnd, GWLP_USERDATA); +#else + QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLong(hwnd, GWL_USERDATA); +#endif + QEventDispatcherWin32Private *d = 0; + if (q != 0) + d = q->d_func(); + if (message == WM_QT_SOCKETNOTIFIER) { + // socket notifier message int type = -1; switch (WSAGETSELECTEVENT(lp)) { case FD_READ: @@ -440,56 +454,52 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) break; } if (type >= 0) { - - #ifdef GWLP_USERDATA - QEventDispatcherWin32 *eventDispatcher = - (QEventDispatcherWin32 *) GetWindowLongPtr(hwnd, GWLP_USERDATA); - #else - QEventDispatcherWin32 *eventDispatcher = - (QEventDispatcherWin32 *) GetWindowLong(hwnd, GWL_USERDATA); - #endif - if (eventDispatcher) { - QEventDispatcherWin32Private *d = eventDispatcher->d_func(); - QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except }; - QSNDict *dict = sn_vec[type]; - - QSockNot *sn = dict ? dict->value(wp) : 0; - if (sn) { - QEvent event(QEvent::SockAct); - QCoreApplication::sendEvent(sn->obj, &event); - } + Q_ASSERT(d != 0); + QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except }; + QSNDict *dict = sn_vec[type]; + + QSockNot *sn = dict ? dict->value(wp) : 0; + if (sn) { + QEvent event(QEvent::SockAct); + QCoreApplication::sendEvent(sn->obj, &event); } } return 0; - - } else if (message == WM_TIMER) { - - MSG msg; - msg.hwnd = hwnd; - msg.message = message; - msg.wParam = wp; - msg.lParam = lp; - - QCoreApplication *app = QCoreApplication::instance(); - Q_ASSERT_X(app, "qt_interal_proc", "Timer fired, but no QCoreApplication"); - if (!app) { - KillTimer(hwnd, wp); - return 0; + } else if (message == WM_TIMER) { + if (wp == ~0u) { + KillTimer(d->internalHwnd, wp); + int localSerialNumber = d->serialNumber; + (void) d->wakeUps.fetchAndStoreRelease(0); + if (localSerialNumber != d->lastSerialNumber) { + PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); + } + } else { + Q_ASSERT(d != 0); + d->sendTimerEvent(wp); + } + return 0; + } else if (message == WM_QT_SENDPOSTEDEVENTS) { + int localSerialNumber = d->serialNumber; + + MSG peeked; + if (PeekMessage(&peeked, d->internalHwnd, WM_TIMER, WM_TIMER, PM_NOREMOVE) + || PeekMessage(&peeked, NULL, 0, 0, PM_NOREMOVE | PM_QS_INPUT)) { + // delay the next pass of sendPostedEvents() until we get the special + // WM_TIMER, which allows all pending Windows messages to be processed + SetTimer(d->internalHwnd, ~0u, 0, 0); + } else { + // nothing pending in the queue, let sendPostedEvents go through + d->wakeUps.fetchAndStoreRelease(0); } - long result; - if (app->filterEvent(&msg, &result)) - return result; - - QEventDispatcherWin32 *eventDispatcher = - qobject_cast(QAbstractEventDispatcher::instance()); - Q_ASSERT(eventDispatcher != 0); - QEventDispatcherWin32Private *d = eventDispatcher->d_func(); - d->sendTimerEvent(wp); + if (localSerialNumber != d->lastSerialNumber) { + d->lastSerialNumber = localSerialNumber; + QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); + } return 0; } - return DefWindowProc(hwnd, message, wp, lp); + return DefWindowProc(hwnd, message, wp, lp); } static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher) @@ -538,11 +548,6 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) Q_Q(QEventDispatcherWin32); int ok = 0; - - //in the animation api, we delay the start of the animation - //for the dock widgets, we need to use a system timer because dragging a native window - //makes Windows start its own event loop. - //So if this threshold changes, please change STARTSTOP_TIMER_DELAY in qabstractanimation.cpp accordingly. if (t->interval > 15 || !t->interval || !qtimeSetEvent) { ok = 1; if (!t->interval) // optimization for single-shot-zero-timer @@ -608,7 +613,7 @@ void QEventDispatcherWin32Private::doWsaAsyncSelect(int socket) sn_event |= FD_OOB; // BoundsChecker may emit a warning for WSAAsyncSelect when sn_event == 0 // This is a BoundsChecker bug and not a Qt bug - WSAAsyncSelect(socket, internalHwnd, sn_event ? WM_USER : 0, sn_event); + WSAAsyncSelect(socket, internalHwnd, sn_event ? WM_QT_SOCKETNOTIFIER : 0, sn_event); } void QEventDispatcherWin32::createInternalHwnd() @@ -630,6 +635,9 @@ void QEventDispatcherWin32::createInternalHwnd() // start all normal timers for (int i = 0; i < d->timerVec.count(); ++i) d->registerTimer(d->timerVec.at(i)); + + // trigger a call to sendPostedEvents() + wakeUp(); } QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent) @@ -654,11 +662,10 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) bool canWait; bool retVal = false; do { - QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData); - DWORD waitRet = 0; HANDLE pHandles[MAXIMUM_WAIT_OBJECTS - 1]; QVarLengthArray processedTimers; + bool seenWM_QT_SENDPOSTEDEVENTS = false; while (!d->interrupt) { DWORD nCount = d->winEventNotifierList.count(); Q_ASSERT(nCount < MAXIMUM_WAIT_OBJECTS - 1); @@ -689,7 +696,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) d->queuedUserInputEvents.append(msg); } if (haveMessage && (flags & QEventLoop::ExcludeSocketNotifiers) - && (msg.message == WM_USER && msg.hwnd == d->internalHwnd)) { + && (msg.message == WM_QT_SOCKETNOTIFIER && msg.hwnd == d->internalHwnd)) { // queue socket events for later processing haveMessage = false; d->queuedSocketEvents.append(msg); @@ -706,7 +713,13 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } } if (haveMessage) { - if (msg.message == WM_TIMER) { + if (msg.message == WM_QT_SENDPOSTEDEVENTS && !(flags & QEventLoop::EventLoopExec)) { + if (seenWM_QT_SENDPOSTEDEVENTS) { + PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); + break; + } + seenWM_QT_SENDPOSTEDEVENTS = true; + } else if (msg.message == WM_TIMER) { // avoid live-lock by keeping track of the timers we've already sent bool found = false; for (int i = 0; !found && i < processedTimers.count(); ++i) { @@ -736,9 +749,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } // still nothing - wait for message or signalled objects - QThreadData *data = d->threadData; canWait = (!retVal - && data->canWait && !d->interrupt && (flags & QEventLoop::WaitForMoreEvents)); if (canWait) { @@ -990,7 +1001,11 @@ void QEventDispatcherWin32::activateEventNotifiers() void QEventDispatcherWin32::wakeUp() { Q_D(QEventDispatcherWin32); - SetEvent(d->wakeUpNotifier.handle()); + d->serialNumber.ref(); + if (d->internalHwnd && d->wakeUps.testAndSetAcquire(0, 1)) { + // post a WM_QT_SENDPOSTEDEVENTS to this thread if there isn't one already pending + PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); + } } void QEventDispatcherWin32::interrupt() @@ -1003,13 +1018,8 @@ void QEventDispatcherWin32::interrupt() void QEventDispatcherWin32::flush() { } - void QEventDispatcherWin32::startingUp() -{ - Q_D(QEventDispatcherWin32); - - if (d->wakeUpNotifier.handle()) d->wakeUpNotifier.setEnabled(true); -} +{ } void QEventDispatcherWin32::closingDown() { -- cgit v0.12 From 4e22238ac86eb7ddb88b7dec73d419767da72323 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 19 Oct 2009 16:14:13 +0200 Subject: Remove workarounds for Win32 event dispatcher bugs This includes the startstop timer delay in QAbstractAnimation, and the inSizeMove workaround for paint events. Reviewed-by: Prasanth Ullattil --- src/corelib/animation/qabstractanimation.cpp | 12 ------------ src/gui/kernel/qapplication.cpp | 3 --- src/gui/kernel/qapplication_p.h | 3 --- src/gui/kernel/qapplication_win.cpp | 2 -- src/gui/painting/qbackingstore.cpp | 12 ------------ 5 files changed, 32 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index c775a00..df8b548 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -157,19 +157,7 @@ #ifndef QT_NO_ANIMATION #define DEFAULT_TIMER_INTERVAL 16 - -#ifdef Q_WS_WIN - /// Fix for Qt 4.7 - //on windows if you're currently dragging a widget an inner eventloop was started by the system - //to make sure that this timer is getting fired, we need to make sure to use the system timers - //that will send a WM_TIMER event. We do that by settings the timer interval to 11 - //It is 16 because QEventDispatcherWin32Private::registerTimer specifically checks if the interval - //is greater than 11 to determine if it should use a system timer (or the multimedia timer). -#define STARTSTOP_TIMER_DELAY 16 -#else #define STARTSTOP_TIMER_DELAY 0 -#endif - QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index f48c551..9658f5e 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -474,9 +474,6 @@ bool QApplicationPrivate::fade_tooltip = false; bool QApplicationPrivate::animate_toolbox = false; bool QApplicationPrivate::widgetCount = false; bool QApplicationPrivate::load_testability = false; -#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE) -bool QApplicationPrivate::inSizeMove = false; -#endif #ifdef QT_KEYPAD_NAVIGATION # ifdef Q_OS_SYMBIAN Qt::NavigationMode QApplicationPrivate::navigationMode = Qt::NavigationModeKeypadDirectional; diff --git a/src/gui/kernel/qapplication_p.h b/src/gui/kernel/qapplication_p.h index 2d3d18c..92b07c7 100644 --- a/src/gui/kernel/qapplication_p.h +++ b/src/gui/kernel/qapplication_p.h @@ -441,9 +441,6 @@ public: #ifdef Q_WS_MAC static bool native_modal_dialog_active; #endif -#if defined(Q_WS_WIN) && !defined(Q_WS_WINCE) - static bool inSizeMove; -#endif static void setSystemPalette(const QPalette &pal); static void setPalette_helper(const QPalette &palette, const char* className, bool clearWidgetPaletteHash); diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 5bb25fa..522f1ac 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -1916,11 +1916,9 @@ LRESULT CALLBACK QtWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam #ifndef Q_WS_WINCE case WM_ENTERSIZEMOVE: autoCaptureWnd = hwnd; - QApplicationPrivate::inSizeMove = true; break; case WM_EXITSIZEMOVE: autoCaptureWnd = 0; - QApplicationPrivate::inSizeMove = false; break; #endif case WM_MOVE: // move window diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 7c07df8..7facd91 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -497,18 +497,6 @@ static inline void sendUpdateRequest(QWidget *widget, bool updateImmediately) if (!widget) return; -#if defined(Q_WS_WIN) && !defined(Q_OS_WINCE) - if (QApplicationPrivate::inSizeMove && widget->internalWinId() && !updateImmediately - && !widget->testAttribute(Qt::WA_DontShowOnScreen)) { - // Tell Windows to send us a paint event if we're in WM_SIZE/WM_MOVE; posted events - // are blocked until the mouse button is released. See task 146849. - const QRegion rgn(qt_dirtyRegion(widget)); - InvalidateRgn(widget->internalWinId(), rgn.handle(), false); - qt_widget_private(widget)->dirty = QRegion(); - return; - } -#endif - if (updateImmediately) { QEvent event(QEvent::UpdateRequest); QApplication::sendEvent(widget, &event); -- cgit v0.12 From e28e6772e79df9b2adf70e21969af8cac28dc9cf Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Oct 2009 12:33:35 +0200 Subject: Use GetStatusQueue() to look for timer and input messages This function works more reliably than PeekMessage() with different flags. --- src/corelib/kernel/qeventdispatcher_win.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index f7de29d..eca94fc 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -482,8 +482,7 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) int localSerialNumber = d->serialNumber; MSG peeked; - if (PeekMessage(&peeked, d->internalHwnd, WM_TIMER, WM_TIMER, PM_NOREMOVE) - || PeekMessage(&peeked, NULL, 0, 0, PM_NOREMOVE | PM_QS_INPUT)) { + if (GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER) != 0) { // delay the next pass of sendPostedEvents() until we get the special // WM_TIMER, which allows all pending Windows messages to be processed SetTimer(d->internalHwnd, ~0u, 0, 0); -- cgit v0.12 From 4279889ebebb9fdd026fc107f60f825fb2ad565e Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 21 Oct 2009 14:02:32 +0200 Subject: Compile on Windows when QS_RAWINPUT is not defined. --- src/corelib/kernel/qeventdispatcher_win.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index eca94fc..df4c02d 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -64,6 +64,10 @@ extern uint qGlobalPostedEventsCount(); # define TIME_KILL_SYNCHRONOUS 0x0100 #endif +#ifndef QS_RAWINPUT +# define QS_RAWINPUT 0x0400 +#endif + enum { WM_QT_SOCKETNOTIFIER = WM_USER, WM_QT_SENDPOSTEDEVENTS = WM_USER + 1 @@ -481,7 +485,6 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp) } else if (message == WM_QT_SENDPOSTEDEVENTS) { int localSerialNumber = d->serialNumber; - MSG peeked; if (GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER) != 0) { // delay the next pass of sendPostedEvents() until we get the special // WM_TIMER, which allows all pending Windows messages to be processed -- cgit v0.12 From 3481db791c3b48e28f1a9531b247adf6562edb71 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 22 Oct 2009 16:39:14 +0200 Subject: Remove internal widgets from QApplication::topLevelWidgets() We have some internal hidden widgets which should not come up in the QApplication::topLevelWidgets() list. So the known ones are being removed from the QWidgetPrivate::allWidgets set. Task-number: QTBUG-739 Reviewed-by: Denis Dzyubenko Reviewed-by: Bradley T. Hughes --- src/gui/kernel/qclipboard_win.cpp | 4 ++++ src/gui/kernel/qclipboard_x11.cpp | 9 +++++++++ src/gui/kernel/qwidget_win.cpp | 3 +++ src/gui/styles/qwindowsxpstyle.cpp | 5 +++++ src/opengl/qwindowsurface_gl.cpp | 5 ++++- tests/auto/qapplication/tst_qapplication.cpp | 22 ++++++++++++++++++++++ 6 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qclipboard_win.cpp b/src/gui/kernel/qclipboard_win.cpp index 7f7ef0c..0157052 100644 --- a/src/gui/kernel/qclipboard_win.cpp +++ b/src/gui/kernel/qclipboard_win.cpp @@ -51,6 +51,7 @@ #include "qmime.h" #include "qt_windows.h" #include "qdnd_p.h" +#include QT_BEGIN_NAMESPACE @@ -140,6 +141,9 @@ public: clipBoardViewer = new QWidget(); clipBoardViewer->createWinId(); clipBoardViewer->setObjectName(QLatin1String("internal clipboard owner")); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(clipBoardViewer); } ~QClipboardData() diff --git a/src/gui/kernel/qclipboard_x11.cpp b/src/gui/kernel/qclipboard_x11.cpp index 9621944..22d7c9e 100644 --- a/src/gui/kernel/qclipboard_x11.cpp +++ b/src/gui/kernel/qclipboard_x11.cpp @@ -78,6 +78,7 @@ #include "qimagewriter.h" #include "qvariant.h" #include "qdnd_p.h" +#include #ifndef QT_NO_XFIXES #include @@ -131,6 +132,11 @@ void setupOwner() requestor = new QWidget(0); requestor->createWinId(); requestor->setObjectName(QLatin1String("internal clipboard requestor")); + // We dont need this internal widgets to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) { + QWidgetPrivate::allWidgets->remove(owner); + QWidgetPrivate::allWidgets->remove(requestor); + } qAddPostRoutine(cleanup); } @@ -769,6 +775,9 @@ QByteArray QX11Data::clipboardReadIncrementalProperty(Window win, Atom property, delete requestor; requestor = new QWidget(0); requestor->setObjectName(QLatin1String("internal clipboard requestor")); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(requestor); return QByteArray(); } diff --git a/src/gui/kernel/qwidget_win.cpp b/src/gui/kernel/qwidget_win.cpp index 2b11bec..0672fee 100644 --- a/src/gui/kernel/qwidget_win.cpp +++ b/src/gui/kernel/qwidget_win.cpp @@ -161,6 +161,9 @@ static void qt_tablet_init() qt_tablet_widget = new QWidget(0); qt_tablet_widget->createWinId(); qt_tablet_widget->setObjectName(QLatin1String("Qt internal tablet widget")); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(qt_tablet_widget); LOGCONTEXT lcMine; qAddPostRoutine(qt_tablet_cleanup); struct tagAXIS tpOri[3]; diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 9ef30e5..2f00f07 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -47,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -299,7 +300,11 @@ HWND QWindowsXPStylePrivate::winId(const QWidget *widget) if (!limboWidget) { limboWidget = new QWidget(0); + limboWidget->createWinId(); limboWidget->setObjectName(QLatin1String("xp_limbo_widget")); + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(limboWidget); } return limboWidget->winId(); diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 4547416..dcbf021 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -49,12 +49,12 @@ #include #include #include +#include #include "qdebug.h" #ifdef Q_WS_X11 #include #include -#include #ifndef QT_OPENGL_ES #include @@ -195,6 +195,9 @@ public: if (!initializing && !widget && !cleanedUp) { initializing = true; widget = new QGLWidget; + // We dont need this internal widget to appear in QApplication::topLevelWidgets() + if (QWidgetPrivate::allWidgets) + QWidgetPrivate::allWidgets->remove(widget); initializing = false; } return widget; diff --git a/tests/auto/qapplication/tst_qapplication.cpp b/tests/auto/qapplication/tst_qapplication.cpp index 97aa092..e8e1ef0 100644 --- a/tests/auto/qapplication/tst_qapplication.cpp +++ b/tests/auto/qapplication/tst_qapplication.cpp @@ -129,6 +129,7 @@ private slots: void style(); void allWidgets(); + void topLevelWidgets(); void setAttribute(); @@ -1792,6 +1793,27 @@ void tst_QApplication::allWidgets() QVERIFY(!app.allWidgets().contains(w)); // removal test } +void tst_QApplication::topLevelWidgets() +{ + int argc = 1; + QApplication app(argc, &argv0, QApplication::GuiServer); + QWidget *w = new QWidget; + w->show(); +#ifndef QT_NO_CLIPBOARD + QClipboard *clipboard = QApplication::clipboard(); + QString originalText = clipboard->text(); + clipboard->setText(QString("newText")); +#endif + app.processEvents(); + QVERIFY(QApplication::topLevelWidgets().contains(w)); + QCOMPARE(QApplication::topLevelWidgets().count(), 1); + delete w; + w = 0; + app.processEvents(); + QCOMPARE(QApplication::topLevelWidgets().count(), 0); +} + + void tst_QApplication::setAttribute() { -- cgit v0.12 From 706c3f846b97c74c5e15395b6e2d306c522ba769 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 22 Oct 2009 22:09:03 +0200 Subject: Optimisation for filtering events for gestures in graphics view. We shouldn't add several graphicsobject contexts for the same gesture type when looking for the gesture-enabled QGraphicsObject under a hotspot. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index ed8e744..0601457 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -352,8 +352,10 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { if (it.value() == Qt::ItemWithChildrenGesture) { - if (!types.contains(it.key())) + if (!types.contains(it.key())) { + types.insert(it.key()); contexts.insertMulti(item, it.key()); + } } } item = item->parentObject(); -- cgit v0.12 From dc54674e9f8998b4aee3a58d06f6b5533ccd3cfe Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 22 Oct 2009 22:41:43 +0200 Subject: Implemented QGestureEvent::activeGestures and canceledGestures. Reviewed-by: Thomas Zander --- src/gui/kernel/qevent.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 065bd09..74dfa53 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4262,7 +4262,12 @@ QGesture *QGestureEvent::gesture(Qt::GestureType type) const */ QList QGestureEvent::activeGestures() const { - return d_func()->gestures; + QList gestures; + foreach (QGesture *gesture, d_func()->gestures) { + if (gesture->state() != Qt::GestureCanceled) + gestures.append(gesture); + } + return gestures; } /*! @@ -4270,7 +4275,12 @@ QList QGestureEvent::activeGestures() const */ QList QGestureEvent::canceledGestures() const { - return d_func()->gestures; + QList gestures; + foreach (QGesture *gesture, d_func()->gestures) { + if (gesture->state() == Qt::GestureCanceled) + gestures.append(gesture); + } + return gestures; } /*! -- cgit v0.12 From f3cbbd7b8388b4c7445a5fa56d59abdae6c532cb Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 22 Oct 2009 22:39:24 +0200 Subject: Added convenience functions QGestureEvent::setAccepted with a gesture type argument. Reviewed-by: Thomas Zander --- src/gui/kernel/qevent.cpp | 68 +++++++++++++++++++++++++++++++++++++++++++---- src/gui/kernel/qevent.h | 5 ++++ 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 74dfa53..ea05869 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4298,9 +4298,8 @@ QList QGestureEvent::canceledGestures() const */ void QGestureEvent::setAccepted(QGesture *gesture, bool value) { - setAccepted(false); if (gesture) - d_func()->accepted[gesture->gestureType()] = value; + setAccepted(gesture->gestureType(), value); } /*! @@ -4314,7 +4313,8 @@ void QGestureEvent::setAccepted(QGesture *gesture, bool value) */ void QGestureEvent::accept(QGesture *gesture) { - setAccepted(gesture, true); + if (gesture) + setAccepted(gesture->gestureType(), true); } /*! @@ -4328,7 +4328,8 @@ void QGestureEvent::accept(QGesture *gesture) */ void QGestureEvent::ignore(QGesture *gesture) { - setAccepted(gesture, false); + if (gesture) + setAccepted(gesture->gestureType(), false); } /*! @@ -4336,7 +4337,64 @@ void QGestureEvent::ignore(QGesture *gesture) */ bool QGestureEvent::isAccepted(QGesture *gesture) const { - return gesture ? d_func()->accepted.value(gesture->gestureType(), true) : false; + return gesture ? isAccepted(gesture->gestureType()) : false; +} + +/*! + Sets the accept flag of the given \a gestureType object to the specified + \a value. + + Setting the accept flag indicates that the event receiver wants the \a gesture. + Unwanted gestures may be propagated to the parent widget. + + By default, gestures in events of type QEvent::Gesture are accepted, and + gestures in QEvent::GestureOverride events are ignored. + + For convenience, the accept flag can also be set with + \l{QGestureEvent::accept()}{accept(gestureType)}, and cleared with + \l{QGestureEvent::ignore()}{ignore(gestureType)}. +*/ +void QGestureEvent::setAccepted(Qt::GestureType gestureType, bool value) +{ + setAccepted(false); + d_func()->accepted[gestureType] = value; +} + +/*! + Sets the accept flag of the given \a gestureType, the equivalent of calling + \l{QGestureEvent::setAccepted()}{setAccepted(gestureType, true)}. + + Setting the accept flag indicates that the event receiver wants the + gesture. Unwanted gestures may be propagated to the parent widget. + + \sa QGestureEvent::ignore() +*/ +void QGestureEvent::accept(Qt::GestureType gestureType) +{ + setAccepted(gestureType, true); +} + +/*! + Clears the accept flag parameter of the given \a gestureType, the equivalent + of calling \l{QGestureEvent::setAccepted()}{setAccepted(gesture, false)}. + + Clearing the accept flag indicates that the event receiver does not + want the gesture. Unwanted gestures may be propgated to the parent widget. + + \sa QGestureEvent::accept() +*/ +void QGestureEvent::ignore(Qt::GestureType gestureType) +{ + setAccepted(gestureType, false); +} + +/*! + Returns true if the gesture of type \a gestureType is accepted; otherwise + returns false. +*/ +bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const +{ + return d_func()->accepted.value(gestureType, true); } /*! diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index b7370fd..fb245c0 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -851,6 +851,11 @@ public: void ignore(QGesture *); bool isAccepted(QGesture *) const; + void setAccepted(Qt::GestureType, bool); + void accept(Qt::GestureType); + void ignore(Qt::GestureType); + bool isAccepted(Qt::GestureType) const; + void setWidget(QWidget *widget); QWidget *widget() const; -- cgit v0.12 From 20cddedfe5f422eb0607a5ac85870267b2788117 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Fri, 23 Oct 2009 13:04:19 +0200 Subject: Unregister the temporary gesture recognizer in the gestures autotest. Reviewed-by: trustme --- tests/auto/gestures/tst_gestures.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 92f979f..800af1b 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -341,6 +341,7 @@ void tst_Gestures::initTestCase() void tst_Gestures::cleanupTestCase() { + qApp->unregisterGestureRecognizer(CustomGesture::GestureType); } void tst_Gestures::init() @@ -547,6 +548,8 @@ void tst_Gestures::conflictingGestures() QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount); QCOMPARE(parent.gestureOverrideEventsReceived, 0); QCOMPARE(parent.gestureEventsReceived, 0); + + qApp->unregisterGestureRecognizer(ContinuousGesture); } void tst_Gestures::finishedWithoutStarted() @@ -978,6 +981,8 @@ void tst_Gestures::twoGesturesOnDifferentLevel() QCOMPARE(parent.events.all.size(), TotalGestureEventsCount); for(int i = 0; i < child->events.all.size(); ++i) QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType); + + qApp->unregisterGestureRecognizer(SecondGesture); } void tst_Gestures::multipleGesturesInTree() @@ -1046,6 +1051,9 @@ void tst_Gestures::multipleGesturesInTree() QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount); QCOMPARE(A->events.all.count(SecondGesture), 0); QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount); + + qApp->unregisterGestureRecognizer(SecondGesture); + qApp->unregisterGestureRecognizer(ThirdGesture); } void tst_Gestures::multipleGesturesInComplexTree() @@ -1139,6 +1147,13 @@ void tst_Gestures::multipleGesturesInComplexTree() QCOMPARE(A->events.all.count(FifthGesture), 0); QCOMPARE(A->events.all.count(SixthGesture), 0); QCOMPARE(A->events.all.count(SeventhGesture), 0); + + qApp->unregisterGestureRecognizer(SecondGesture); + qApp->unregisterGestureRecognizer(ThirdGesture); + qApp->unregisterGestureRecognizer(FourthGesture); + qApp->unregisterGestureRecognizer(FifthGesture); + qApp->unregisterGestureRecognizer(SixthGesture); + qApp->unregisterGestureRecognizer(SeventhGesture); } void tst_Gestures::testMapToScene() -- cgit v0.12 From 92d8b0e1d6ecce8214b24a08b8a199af4321bd88 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 21 Oct 2009 12:40:59 +0200 Subject: Implement QApplication::unregisterGestureRecognizer Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qapplication.cpp | 4 +++- src/gui/kernel/qgesturemanager.cpp | 42 +++++++++++++++++++++++++++++++++++--- src/gui/kernel/qgesturemanager_p.h | 9 ++++++-- 3 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 202d450..e64dfd2 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -5642,7 +5642,9 @@ Qt::GestureType QApplication::registerGestureRecognizer(QGestureRecognizer *reco */ void QApplication::unregisterGestureRecognizer(Qt::GestureType type) { - QGestureManager::instance()->unregisterGestureRecognizer(type); + QApplicationPrivate *d = qApp->d_func(); + if (d->gestureManager) + d->gestureManager->unregisterGestureRecognizer(type); } QT_END_NAMESPACE diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 0601457..dc76c3f 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -104,9 +104,29 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r return type; } -void QGestureManager::unregisterGestureRecognizer(Qt::GestureType) +void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { + QList list = recognizers.values(type); + recognizers.remove(type); + foreach (QGesture* g, gestureToRecognizer.keys()) { + QGestureRecognizer *recognizer = gestureToRecognizer.value(g); + if (list.contains(recognizer)) { + m_deletedRecognizers.insert(g, recognizer); + gestureToRecognizer.remove(g); + } + } + foreach (QGestureRecognizer *recognizer, list) { + QList obsoleteGestures; + QMap::Iterator iter = objectGestures.begin(); + while (iter != objectGestures.end()) { + ObjectGesture objectGesture = iter.key(); + if (objectGesture.gesture == type) + obsoleteGestures << iter.value(); + ++iter; + } + m_obsoleteGestures.insert(recognizer, obsoleteGestures); + } } QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) @@ -290,14 +310,28 @@ bool QGestureManager::filterEventThroughContexts(const QMap endedGestures = finishedGestures + canceledGestures + undeliveredGestures; foreach (QGesture *gesture, endedGestures) { - if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) { + if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) recognizer->reset(gesture); - } + else + cleanupGesturesForRemovedRecognizer(gesture); gestureTargets.remove(gesture); } return false; } +void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) +{ + QGestureRecognizer *recognizer = m_deletedRecognizers.value(gesture); + Q_ASSERT(recognizer); + m_deletedRecognizers.remove(gesture); + if (m_deletedRecognizers.keys(recognizer).isEmpty()) { + // no more active gestures, cleanup! + qDeleteAll(m_obsoleteGestures.value(recognizer)); + m_obsoleteGestures.remove(recognizer); + delete recognizer; + } +} + bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { QSet types; @@ -534,6 +568,8 @@ void QGestureManager::timerEvent(QTimerEvent *event) QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0); if (recognizer) recognizer->reset(gesture); + else + cleanupGesturesForRemovedRecognizer(gesture); } else { ++it; } diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index f0e7225..eef45d2 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -104,7 +104,7 @@ private: Qt::GestureType gesture; ObjectGesture(QObject *o, const Qt::GestureType &g) : object(o), gesture(g) { } - inline bool operator<(const ObjectGesture& rhs) const + inline bool operator<(const ObjectGesture &rhs) const { if (object.data() < rhs.object.data()) return true; @@ -114,7 +114,8 @@ private: } }; - QMap objectGestures; + // TODO rename all member vars to be m_ + QMap objectGestures; // TODO rename widgetGestures QMap gestureToRecognizer; QHash gestureOwners; @@ -122,6 +123,10 @@ private: int lastCustomGestureId; + QHash > m_obsoleteGestures; + QMap m_deletedRecognizers; + void cleanupGesturesForRemovedRecognizer(QGesture *gesture); + QGesture *getState(QObject *widget, Qt::GestureType gesture); void deliverEvents(const QSet &gestures, QSet *undeliveredGestures); -- cgit v0.12 From 25bc5c29db866d5abc3f9fbae7b5211e2e6b1f25 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 21 Oct 2009 13:58:24 +0200 Subject: Add QWidget::ungrabGesture Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qgesturemanager.cpp | 16 ++++++++ src/gui/kernel/qgesturemanager_p.h | 2 + src/gui/kernel/qwidget.cpp | 16 ++++++++ src/gui/kernel/qwidget.h | 1 + tests/auto/gestures/tst_gestures.cpp | 71 ++++++++++++++++++++++++++++++++++++ 5 files changed, 106 insertions(+) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index dc76c3f..df88f9e 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -129,6 +129,21 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) } } +void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType type) +{ + QMap::Iterator iter = objectGestures.begin(); + while (iter != objectGestures.end()) { + ObjectGesture objectGesture = iter.key(); + if (objectGesture.gesture == type && target == objectGesture.object.data()) { + delete iter.value(); + iter = objectGestures.erase(iter); + } else { + ++iter; + } + } +} + +// get or create a QGesture object that will represent the state for a given object, used by the recognizer QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) { // if the widget is being deleted we should be carefull and not to @@ -332,6 +347,7 @@ void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) } } +// return true if accepted (consumed) bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { QSet types; diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index eef45d2..96c2fb7 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -79,6 +79,8 @@ public: // declared in qapplication.cpp static QGestureManager* instance(); + void cleanupCachedGestures(QObject *target, Qt::GestureType type); + protected: void timerEvent(QTimerEvent *event); bool filterEventThroughContexts(const QMap &contexts, diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 5fa9a92..c10db90 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11708,6 +11708,22 @@ void QWidget::grabGesture(Qt::GestureType gesture, Qt::GestureContext context) (void)QGestureManager::instance(); // create a gesture manager } +/*! + Unsubscribes the widget to a given \a gesture type + + \sa QGestureEvent + \since 4.6 +*/ +void QWidget::ungrabGesture(Qt::GestureType gesture) +{ + Q_D(QWidget); + if (d->gestureContext.remove(gesture)) { + QGestureManager *manager = QGestureManager::instance(); + manager->cleanupCachedGestures(this, gesture); + } +} + + QT_END_NAMESPACE #include "moc_qwidget.cpp" diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index e603a1a..fce3f09 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -355,6 +355,7 @@ public: void setGraphicsEffect(QGraphicsEffect *effect); void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::WidgetWithChildrenGesture); + void ungrabGesture(Qt::GestureType type); public Q_SLOTS: void setWindowTitle(const QString &); diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 800af1b..6e52de3 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -280,6 +280,7 @@ protected: } }; +// TODO rename to sendGestureSequence static void sendCustomGesture(CustomEvent *event, QObject *object, QGraphicsScene *scene = 0) { for (int i = CustomGesture::SerialMaybeThreshold; @@ -322,6 +323,7 @@ private slots: void multipleGesturesInTree(); void multipleGesturesInComplexTree(); void testMapToScene(); + void ungrabGesture(); }; tst_Gestures::tst_Gestures() @@ -1181,5 +1183,74 @@ void tst_Gestures::testMapToScene() QCOMPARE(event.mapToScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200))); } +void tst_Gestures::ungrabGesture() // a method on QWidget +{ + class MockGestureWidget : public GestureWidget { + public: + MockGestureWidget(const char *name = 0, QWidget *parent = 0) + : GestureWidget(name, parent) { } + + + QSet gestures; + protected: + bool event(QEvent *event) + { + if (event->type() == QEvent::Gesture) { + QGestureEvent *gestureEvent = static_cast(event); + if (gestureEvent) + foreach (QGesture *g, gestureEvent->allGestures()) + gestures.insert(g); + } + return GestureWidget::event(event); + } + }; + + MockGestureWidget parent("A"); + MockGestureWidget *a = &parent; + MockGestureWidget *b = new MockGestureWidget("B", a); + + a->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + b->grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); + b->ignoredGestures << CustomGesture::GestureType; + + CustomEvent event; + // sending an event will cause the QGesture objects to be instantiated for the widgets + sendCustomGesture(&event, b); + + QCOMPARE(a->gestures.count(), 1); + QPointer customGestureA; + customGestureA = *(a->gestures.begin()); + QVERIFY(!customGestureA.isNull()); + QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType); + + QCOMPARE(b->gestures.count(), 1); + QPointer customGestureB; + customGestureB = *(b->gestures.begin()); + QVERIFY(!customGestureB.isNull()); + QVERIFY(customGestureA.data() == customGestureB.data()); + QCOMPARE(customGestureB->gestureType(), CustomGesture::GestureType); + + a->gestures.clear(); + // sending an event will cause the QGesture objects to be instantiated for the widget + sendCustomGesture(&event, a); + + QCOMPARE(a->gestures.count(), 1); + customGestureA = *(a->gestures.begin()); + QVERIFY(!customGestureA.isNull()); + QCOMPARE(customGestureA->gestureType(), CustomGesture::GestureType); + QVERIFY(customGestureA.data() != customGestureB.data()); + + a->ungrabGesture(CustomGesture::GestureType); + QVERIFY(customGestureA.isNull()); + QVERIFY(!customGestureB.isNull()); + + a->gestures.clear(); + a->reset(); + // send again to 'b' and make sure a never gets it. + sendCustomGesture(&event, b); + QCOMPARE(a->gestureEventsReceived, 0); + QCOMPARE(a->gestureOverrideEventsReceived, 0); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 487570340062a1165e0473e2557f844b097db526 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 23 Oct 2009 15:43:50 +0200 Subject: Fix memory leaks in the gesture manager Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qgesturemanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index df88f9e..0139533 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -82,7 +82,7 @@ QGestureManager::QGestureManager(QObject *parent) QGestureManager::~QGestureManager() { - + qDeleteAll(recognizers.values()); } Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer) @@ -166,6 +166,7 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) state = recognizer->createGesture(object); if (!state) return 0; + state->setParent(this); if (state->gestureType() == Qt::CustomGesture) { // if the recognizer didn't fill in the gesture type, then this // is a custom gesture with autogenerated it and we fill it. -- cgit v0.12 From 293ee52fce78b74fcfa2effbccf6df6f12e9daa5 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Fri, 23 Oct 2009 15:44:37 +0200 Subject: Fix the debug output to be correct again after refactoring Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qgesturemanager.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 0139533..9890a12 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -212,21 +212,21 @@ bool QGestureManager::filterEventThroughContexts(const QMapfilterEvent(state, target, event); QGestureRecognizer::Result type = result & QGestureRecognizer::ResultState_Mask; if (type == QGestureRecognizer::GestureTriggered) { - DEBUG() << "QGestureManager: gesture triggered: " << state; + DEBUG() << "QGestureManager:Recognizer: gesture triggered: " << state; triggeredGestures << state; } else if (type == QGestureRecognizer::GestureFinished) { - DEBUG() << "QGestureManager: gesture finished: " << state; + DEBUG() << "QGestureManager:Recognizer: gesture finished: " << state; finishedGestures << state; } else if (type == QGestureRecognizer::MaybeGesture) { - DEBUG() << "QGestureManager: maybe gesture: " << state; + DEBUG() << "QGestureManager:Recognizer: maybe gesture: " << state; newMaybeGestures << state; } else if (type == QGestureRecognizer::NotGesture) { - DEBUG() << "QGestureManager: not gesture: " << state; + DEBUG() << "QGestureManager:Recognizer: not gesture: " << state; notGestures << state; } else if (type == QGestureRecognizer::Ignore) { - DEBUG() << "QGestureManager: gesture ignored the event: " << state; + DEBUG() << "QGestureManager:Recognizer: ignored the event: " << state; } else { - DEBUG() << "QGestureManager: hm, lets assume the recognizer" + DEBUG() << "QGestureManager:Recognizer: hm, lets assume the recognizer" << "ignored the event: " << state; } if (result & QGestureRecognizer::ConsumeEventHint) { @@ -307,7 +307,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap Date: Mon, 26 Oct 2009 13:36:30 +0100 Subject: Removed the obsolete documentation reference from the QGesture. Reviewed-by: trustme --- src/gui/kernel/qgesture.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index ecdd661..a161876 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -142,12 +142,6 @@ QGesture::~QGesture() \brief whether the gesture has a hot-spot */ -/*! - \property QGesture::targetObject - \brief the target object which will receive the gesture event if the hotSpot is - not set -*/ - Qt::GestureType QGesture::gestureType() const { return d_func()->gestureType; -- cgit v0.12 From 3bc088fad760bd50eec05b323a056641247a9a59 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 27 Oct 2009 10:56:39 +0100 Subject: QTabbar is not behaving (painting) like native ones on Mac. When a tab is clicked and mouse is moved outside that tab, it should be drawn as normal (not in sunken state). Reviewed-by: MortenS --- src/gui/widgets/qtabbar.cpp | 18 +++++++++++++++++- src/gui/widgets/qtabbar_p.h | 10 ++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 6c9761c..4dffbdc 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1694,6 +1694,9 @@ void QTabBar::mousePressEvent(QMouseEvent *event) d->moveTabFinished(d->pressedIndex); d->pressedIndex = d->indexAtPos(event->pos()); +#ifdef Q_WS_MAC + d->previousPressedIndex = d->pressedIndex; +#endif if (d->validIndex(d->pressedIndex)) { QStyleOptionTabBarBaseV2 optTabBase; optTabBase.init(this); @@ -1774,6 +1777,17 @@ void QTabBar::mouseMoveEvent(QMouseEvent *event) update(); } +#ifdef Q_WS_MAC + } else if (!d->documentMode && event->buttons() == Qt::LeftButton && d->previousPressedIndex != -1) { + int newPressedIndex = d->indexAtPos(event->pos()); + if (d->pressedIndex == -1 && d->previousPressedIndex == newPressedIndex) { + d->pressedIndex = d->previousPressedIndex; + update(tabRect(d->pressedIndex)); + } else if(d->pressedIndex != newPressedIndex) { + d->pressedIndex = -1; + update(tabRect(d->previousPressedIndex)); + } +#endif } if (event->buttons() != Qt::LeftButton) { @@ -1865,7 +1879,9 @@ void QTabBar::mouseReleaseEvent(QMouseEvent *event) event->ignore(); return; } - +#ifdef Q_WS_MAC + d->previousPressedIndex = -1; +#endif if (d->movable && d->dragInProgress && d->validIndex(d->pressedIndex)) { int length = d->tabList[d->pressedIndex].dragOffset; int width = verticalTabs(d->shape) diff --git a/src/gui/widgets/qtabbar_p.h b/src/gui/widgets/qtabbar_p.h index 494a340..9f3285b 100644 --- a/src/gui/widgets/qtabbar_p.h +++ b/src/gui/widgets/qtabbar_p.h @@ -77,7 +77,11 @@ public: :currentIndex(-1), pressedIndex(-1), shape(QTabBar::RoundedNorth), layoutDirty(false), drawBase(true), scrollOffset(0), expanding(true), closeButtonOnTabs(false), selectionBehaviorOnRemove(QTabBar::SelectRightTab), paintWithOffsets(true), movable(false), - dragInProgress(false), documentMode(false), movingTab(0) {} + dragInProgress(false), documentMode(false), movingTab(0) +#ifdef Q_WS_MAC + , previousPressedIndex(-1) +#endif + {} int currentIndex; int pressedIndex; @@ -195,7 +199,9 @@ public: bool documentMode; QWidget *movingTab; - +#ifdef Q_WS_MAC + int previousPressedIndex; +#endif // shared by tabwidget and qtabbar static void initStyleBaseOption(QStyleOptionTabBarBaseV2 *optTabBase, QTabBar *tabbar, QSize size) { -- cgit v0.12 From 124df35db0be3ae7578635735b4e64c589d07cba Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Tue, 27 Oct 2009 14:01:58 +0100 Subject: Selected tab is drawn incorrectly on Snow Leopard. The default height of tab bar is 22 pixels in Snow Leopard. We used to draw tabs taller than 21 pixels to a pixmap and stretch to the required size. The limit is now changed to 22 pixels (which is the most common use case). The stretched drawing is not perfect in Snow Leopard due to some changes in how HITheme draws tabs. Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qmacstyle_mac.mm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 63ba641..4dcb469 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -3637,17 +3637,19 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter break; } } + bool stretchTabs = (!verticalTabs && tabRect.height() > 22 || verticalTabs && tabRect.width() > 22); + switch (tp) { case QStyleOptionTab::Beginning: tdi.position = kHIThemeTabPositionFirst; - if (sp != QStyleOptionTab::NextIsSelected) + if (sp != QStyleOptionTab::NextIsSelected || stretchTabs) tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator; break; case QStyleOptionTab::Middle: tdi.position = kHIThemeTabPositionMiddle; if (selected) tdi.adornment |= kHIThemeTabAdornmentLeadingSeparator; - if (sp != QStyleOptionTab::NextIsSelected) // Also when we're selected. + if (sp != QStyleOptionTab::NextIsSelected || stretchTabs) // Also when we're selected. tdi.adornment |= kHIThemeTabAdornmentTrailingSeparator; break; case QStyleOptionTab::End: @@ -3659,9 +3661,8 @@ void QMacStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter tdi.position = kHIThemeTabPositionOnly; break; } - // HITheme doesn't stretch its tabs. Therefore we have to cheat and do the job ourselves. - if ((!verticalTabs && tabRect.height() > 21 || verticalTabs && tabRect.width() > 21)) { + if (stretchTabs) { HIRect hirect = CGRectMake(0, 0, 23, 23); QPixmap pm(23, 23); pm.fill(Qt::transparent); -- cgit v0.12 From e5c87d92fa6380c13ff47ce1fe6d85a02dc92794 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 27 Oct 2009 15:05:22 +0100 Subject: Improved gesture autotest reliability on X11. Reviewed-by: trustme --- tests/auto/gestures/tst_gestures.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 6e52de3..edfbf32 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -715,6 +715,7 @@ void tst_Gestures::graphicsItemGesture() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item = new GestureItem("item"); scene.addItem(item); @@ -777,6 +778,7 @@ void tst_Gestures::graphicsItemTreeGesture() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item1 = new GestureItem("item1"); item1->setPos(100, 100); @@ -834,6 +836,7 @@ void tst_Gestures::explicitGraphicsObjectTarget() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item1 = new GestureItem("item1"); scene.addItem(item1); @@ -887,6 +890,7 @@ void tst_Gestures::gestureOverChildGraphicsItem() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item0 = new GestureItem("item0"); scene.addItem(item0); @@ -1168,6 +1172,7 @@ void tst_Gestures::testMapToScene() QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowFlags(Qt::X11BypassWindowManagerHint); GestureItem *item0 = new GestureItem; scene.addItem(item0); -- cgit v0.12 From fcd8edaf6e17463603d81525f2b57fc11f20216b Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 27 Oct 2009 10:41:32 +0100 Subject: Implemented QGestureRecognizer::ConsumeEventHint Reviewed-By: trustme --- src/gui/kernel/qgesturemanager.cpp | 6 ++++-- tests/auto/gestures/tst_gestures.cpp | 21 ++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 9890a12..52f8eef 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -196,6 +196,8 @@ bool QGestureManager::filterEventThroughContexts(const QMap::const_iterator ContextIterator; for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) { @@ -232,7 +234,7 @@ bool QGestureManager::filterEventThroughContexts(const QMaptype() == CustomEvent::EventType) { - QGestureRecognizer::Result result = QGestureRecognizer::ConsumeEventHint; + QGestureRecognizer::Result result = 0; + if (CustomGestureRecognizer::ConsumeEvents) + result |= QGestureRecognizer::ConsumeEventHint; CustomGesture *g = static_cast(state); CustomEvent *e = static_cast(event); g->serial = e->serial; @@ -143,6 +147,7 @@ public: QGestureRecognizer::reset(state); } }; +bool CustomGestureRecognizer::ConsumeEvents = false; // same as CustomGestureRecognizer but triggers early without the maybe state class CustomContinuousGestureRecognizer : public QGestureRecognizer @@ -324,6 +329,7 @@ private slots: void multipleGesturesInComplexTree(); void testMapToScene(); void ungrabGesture(); + void consumeEventHint(); }; tst_Gestures::tst_Gestures() @@ -375,6 +381,19 @@ void tst_Gestures::customGesture() QCOMPARE(widget.events.canceled.size(), 0); } +void tst_Gestures::consumeEventHint() +{ + GestureWidget widget; + widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + + CustomGestureRecognizer::ConsumeEvents = true; + CustomEvent event; + sendCustomGesture(&event, &widget); + CustomGestureRecognizer::ConsumeEvents = false; + + QCOMPARE(widget.customEventsReceived, 0); +} + void tst_Gestures::autoCancelingGestures() { GestureWidget widget; -- cgit v0.12 From 6efa1085b6a61cf2883b460e5b76bde9576dc4a7 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 27 Oct 2009 15:18:07 +0100 Subject: Renamed QGestureRecognizer::ResultFlags to ResultFlag Decided after review by David Boddie. Reviewed-by: trustme --- src/gui/kernel/qgesturerecognizer.cpp | 2 +- src/gui/kernel/qgesturerecognizer.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp index ba3a750..c2b26f0 100644 --- a/src/gui/kernel/qgesturerecognizer.cpp +++ b/src/gui/kernel/qgesturerecognizer.cpp @@ -100,7 +100,7 @@ QT_BEGIN_NAMESPACE */ /*! - \enum QGestureRecognizer::ResultFlags + \enum QGestureRecognizer::ResultFlag This enum describes the result of the current event filtering step in a gesture recognizer state machine. diff --git a/src/gui/kernel/qgesturerecognizer.h b/src/gui/kernel/qgesturerecognizer.h index efd8565..a3c990d 100644 --- a/src/gui/kernel/qgesturerecognizer.h +++ b/src/gui/kernel/qgesturerecognizer.h @@ -56,7 +56,7 @@ class QGesture; class Q_GUI_EXPORT QGestureRecognizer { public: - enum ResultFlags + enum ResultFlag { Ignore = 0x0001, NotGesture = 0x0002, @@ -73,7 +73,7 @@ public: ResultHint_Mask = 0xff00 }; - Q_DECLARE_FLAGS(Result, ResultFlags) + Q_DECLARE_FLAGS(Result, ResultFlag) QGestureRecognizer(); virtual ~QGestureRecognizer(); -- cgit v0.12 From 6c8c1c5322a26d789165783d7df3e29c672690cb Mon Sep 17 00:00:00 2001 From: Helio Chissini de Castro Date: Tue, 27 Oct 2009 18:07:56 +0100 Subject: Fill gap of X.org/XFree multimedia/special/launcher keys Qt up to 4.5.x is missing whole setup of multimedia keys already defined by X Merge-request: 1742 Reviewed-by: Denis Dzyubenko --- src/corelib/global/qnamespace.h | 97 ++++++++++++- src/corelib/global/qnamespace.qdoc | 92 ++++++++++++ src/gui/kernel/qkeymapper_x11.cpp | 286 ++++++++++++++++++++++++++++++------- src/gui/kernel/qkeysequence.cpp | 174 ++++++++++++++++------ 4 files changed, 553 insertions(+), 96 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index 2b62c6b..aeaca54 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -909,12 +909,10 @@ public: Key_Dead_Horn = 0x01001262, // multimedia/internet keys - ignored by default - see QKeyEvent c'tor - Key_Back = 0x01000061, Key_Forward = 0x01000062, Key_Stop = 0x01000063, Key_Refresh = 0x01000064, - Key_VolumeDown = 0x01000070, Key_VolumeMute = 0x01000071, Key_VolumeUp = 0x01000072, @@ -923,7 +921,6 @@ public: Key_BassDown = 0x01000075, Key_TrebleUp = 0x01000076, Key_TrebleDown = 0x01000077, - Key_MediaPlay = 0x01000080, Key_MediaStop = 0x01000081, Key_MediaPrevious = 0x01000082, @@ -932,13 +929,11 @@ public: #endif Key_MediaNext = 0x01000083, Key_MediaRecord = 0x01000084, - Key_HomePage = 0x01000090, Key_Favorites = 0x01000091, Key_Search = 0x01000092, Key_Standby = 0x01000093, Key_OpenUrl = 0x01000094, - Key_LaunchMail = 0x010000a0, Key_LaunchMedia = 0x010000a1, Key_Launch0 = 0x010000a2, @@ -957,6 +952,98 @@ public: Key_LaunchD = 0x010000af, Key_LaunchE = 0x010000b0, Key_LaunchF = 0x010000b1, + Key_MonBrightnessUp = 0x010000b2, + Key_MonBrightnessDown = 0x010000b3, + Key_KeyboardLightOnOff = 0x010000b4, + Key_KeyboardBrightnessUp = 0x010000b5, + Key_KeyboardBrightnessDown = 0x010000b6, + Key_PowerOff = 0x010000b7, + Key_WakeUp = 0x010000b8, + Key_Eject = 0x010000b9, + Key_ScreenSaver = 0x010000ba, + Key_WWW = 0x010000bb, + Key_Memo = 0x010000bc, + Key_LightBulb = 0x010000bd, + Key_Shop = 0x010000be, + Key_History = 0x010000bf, + Key_AddFavorite = 0x010000c0, + Key_HotLinks = 0x010000c1, + Key_BrightnessAdjust = 0x010000c2, + Key_Finance = 0x010000c3, + Key_Community = 0x010000c4, + Key_AudioRewind = 0x010000c5, + Key_BackForward = 0x010000c6, + Key_ApplicationLeft = 0x010000c7, + Key_ApplicationRight = 0x010000c8, + Key_Book = 0x010000c9, + Key_CD = 0x010000ca, + Key_Calculator = 0x010000cb, + Key_ToDoList = 0x010000cc, + Key_ClearGrab = 0x010000cd, + Key_Close = 0x010000ce, + Key_Copy = 0x010000cf, + Key_Cut = 0x010000d0, + Key_Display = 0x010000d1, + Key_DOS = 0x010000d2, + Key_Documents = 0x010000d3, + Key_Excel = 0x010000d4, + Key_Explorer = 0x010000d5, + Key_Game = 0x010000d6, + Key_Go = 0x010000d7, + Key_iTouch = 0x010000d8, + Key_LogOff = 0x010000d9, + Key_Market = 0x010000da, + Key_Meeting = 0x010000db, + Key_MenuKB = 0x010000dc, + Key_MenuPB = 0x010000dd, + Key_MySites = 0x010000de, + Key_News = 0x010000df, + Key_OfficeHome = 0x010000e0, + Key_Option = 0x010000e1, + Key_Paste = 0x010000e2, + Key_Phone = 0x010000e3, + Key_Calendar = 0x010000e4, + Key_Reply = 0x010000e5, + Key_Reload = 0x010000e6, + Key_RotateWindows = 0x010000e7, + Key_RotationPB = 0x010000e8, + Key_RotationKB = 0x010000e9, + Key_Save = 0x010000ea, + Key_Send = 0x010000eb, + Key_Spell = 0x010000ec, + Key_SplitScreen = 0x010000ed, + Key_Support = 0x010000ee, + Key_TaskPane = 0x010000ef, + Key_Terminal = 0x010000f0, + Key_Tools = 0x010000f1, + Key_Travel = 0x010000f2, + Key_Video = 0x010000f3, + Key_Word = 0x010000f4, + Key_Xfer = 0x010000f5, + Key_ZoomIn = 0x010000f6, + Key_ZoomOut = 0x010000f7, + Key_Away = 0x010000f8, + Key_Messenger = 0x010000f9, + Key_WebCam = 0x010000fa, + Key_MailForward = 0x010000fb, + Key_Pictures = 0x010000fc, + Key_Music = 0x010000fd, + Key_Battery = 0x010000fe, + Key_Bluetooth = 0x010000ff, + Key_WLAN = 0x01000100, + Key_UWB = 0x01000101, + Key_AudioForward = 0x01000102, + Key_AudioRepeat = 0x01000103, + Key_AudioRandomPlay = 0x01000104, + Key_Subtitle = 0x01000105, + Key_AudioCycleTrack = 0x01000106, + Key_Time = 0x01000107, + Key_Hibernate = 0x01000108, + Key_View = 0x01000109, + Key_TopMenu = 0x0100010a, + Key_PowerDown = 0x0100010b, + Key_Suspend = 0x0100010c, + Key_ContrastAdjust = 0x0100010d, Key_MediaLast = 0x0100ffff, diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index e8d6df0..4a48a8f 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1609,6 +1609,98 @@ \value Key_LaunchD \value Key_LaunchE \value Key_LaunchF + \value Key_MonBrightnessUp + \value Key_MonBrightnessDown + \value Key_KeyboardLightOnOff + \value Key_KeyboardBrightnessUp + \value Key_KeyboardBrightnessDown + \value Key_PowerOff + \value Key_WakeUp + \value Key_Eject + \value Key_ScreenSaver + \value Key_WWW + \value Key_Memo + \value Key_LightBulb + \value Key_Shop + \value Key_History + \value Key_AddFavorite + \value Key_HotLinks + \value Key_BrightnessAdjust + \value Key_Finance + \value Key_Community + \value Key_AudioRewind + \value Key_BackForward + \value Key_ApplicationLeft + \value Key_ApplicationRight + \value Key_Book + \value Key_CD + \value Key_Calculator + \value Key_ToDoList + \value Key_ClearGrab + \value Key_Close + \value Key_Copy + \value Key_Cut + \value Key_Display + \value Key_DOS + \value Key_Documents + \value Key_Excel + \value Key_Explorer + \value Key_Game + \value Key_Go + \value Key_iTouch + \value Key_LogOff + \value Key_Market + \value Key_Meeting + \value Key_MenuKB + \value Key_MenuPB + \value Key_MySites + \value Key_News + \value Key_OfficeHome + \value Key_Option + \value Key_Paste + \value Key_Phone + \value Key_Calendar + \value Key_Reply + \value Key_Reload + \value Key_RotateWindows + \value Key_RotationPB + \value Key_RotationKB + \value Key_Save + \value Key_Send + \value Key_Spell + \value Key_SplitScreen + \value Key_Support + \value Key_TaskPane + \value Key_Terminal + \value Key_Tools + \value Key_Travel + \value Key_Video + \value Key_Word + \value Key_Xfer + \value Key_ZoomIn + \value Key_ZoomOut + \value Key_Away + \value Key_Messenger + \value Key_WebCam + \value Key_MailForward + \value Key_Pictures + \value Key_Music + \value Key_Battery + \value Key_Bluetooth + \value Key_WLAN + \value Key_UWB + \value Key_AudioForward + \value Key_AudioRepeat + \value Key_AudioRandomPlay + \value Key_Subtitle + \value Key_AudioCycleTrack + \value Key_Time + \value Key_Hibernate + \value Key_View + \value Key_TopMenu + \value Key_PowerDown + \value Key_Suspend + \value Key_ContrastAdjust \value Key_MediaLast \value Key_unknown diff --git a/src/gui/kernel/qkeymapper_x11.cpp b/src/gui/kernel/qkeymapper_x11.cpp index 0ce77fe..8164589 100644 --- a/src/gui/kernel/qkeymapper_x11.cpp +++ b/src/gui/kernel/qkeymapper_x11.cpp @@ -714,47 +714,144 @@ extern bool qt_sm_blockUserInput; #define XK_KP_Delete 0xFF9F #endif -// the next lines are taken from XFree > 4.0 (X11/XF86keysyms.h), defining some special +// the next lines are taken on 10/2009 from X.org (X11/XF86keysym.h), defining some special // multimedia keys. They are included here as not every system has them. -#define XF86XK_Standby 0x1008FF10 -#define XF86XK_AudioLowerVolume 0x1008FF11 -#define XF86XK_AudioMute 0x1008FF12 -#define XF86XK_AudioRaiseVolume 0x1008FF13 -#define XF86XK_AudioPlay 0x1008FF14 -#define XF86XK_AudioStop 0x1008FF15 -#define XF86XK_AudioPrev 0x1008FF16 -#define XF86XK_AudioNext 0x1008FF17 -#define XF86XK_HomePage 0x1008FF18 -#define XF86XK_Calculator 0x1008FF1D -#define XF86XK_Mail 0x1008FF19 -#define XF86XK_Start 0x1008FF1A -#define XF86XK_Search 0x1008FF1B -#define XF86XK_AudioRecord 0x1008FF1C -#define XF86XK_Back 0x1008FF26 -#define XF86XK_Forward 0x1008FF27 -#define XF86XK_Stop 0x1008FF28 -#define XF86XK_Refresh 0x1008FF29 -#define XF86XK_Favorites 0x1008FF30 -#define XF86XK_AudioPause 0x1008FF31 -#define XF86XK_AudioMedia 0x1008FF32 -#define XF86XK_MyComputer 0x1008FF33 -#define XF86XK_OpenURL 0x1008FF38 -#define XF86XK_Launch0 0x1008FF40 -#define XF86XK_Launch1 0x1008FF41 -#define XF86XK_Launch2 0x1008FF42 -#define XF86XK_Launch3 0x1008FF43 -#define XF86XK_Launch4 0x1008FF44 -#define XF86XK_Launch5 0x1008FF45 -#define XF86XK_Launch6 0x1008FF46 -#define XF86XK_Launch7 0x1008FF47 -#define XF86XK_Launch8 0x1008FF48 -#define XF86XK_Launch9 0x1008FF49 -#define XF86XK_LaunchA 0x1008FF4A -#define XF86XK_LaunchB 0x1008FF4B -#define XF86XK_LaunchC 0x1008FF4C -#define XF86XK_LaunchD 0x1008FF4D -#define XF86XK_LaunchE 0x1008FF4E -#define XF86XK_LaunchF 0x1008FF4F +#define XF86XK_MonBrightnessUp 0x1008FF02 +#define XF86XK_MonBrightnessDown 0x1008FF03 +#define XF86XK_KbdLightOnOff 0x1008FF04 +#define XF86XK_KbdBrightnessUp 0x1008FF05 +#define XF86XK_KbdBrightnessDown 0x1008FF06 +#define XF86XK_Standby 0x1008FF10 +#define XF86XK_AudioLowerVolume 0x1008FF11 +#define XF86XK_AudioMute 0x1008FF12 +#define XF86XK_AudioRaiseVolume 0x1008FF13 +#define XF86XK_AudioPlay 0x1008FF14 +#define XF86XK_AudioStop 0x1008FF15 +#define XF86XK_AudioPrev 0x1008FF16 +#define XF86XK_AudioNext 0x1008FF17 +#define XF86XK_HomePage 0x1008FF18 +#define XF86XK_Mail 0x1008FF19 +#define XF86XK_Start 0x1008FF1A +#define XF86XK_Search 0x1008FF1B +#define XF86XK_AudioRecord 0x1008FF1C +#define XF86XK_Calculator 0x1008FF1D +#define XF86XK_Memo 0x1008FF1E +#define XF86XK_ToDoList 0x1008FF1F +#define XF86XK_Calendar 0x1008FF20 +#define XF86XK_PowerDown 0x1008FF21 +#define XF86XK_ContrastAdjust 0x1008FF22 +#define XF86XK_Back 0x1008FF26 +#define XF86XK_Forward 0x1008FF27 +#define XF86XK_Stop 0x1008FF28 +#define XF86XK_Refresh 0x1008FF29 +#define XF86XK_PowerOff 0x1008FF2A +#define XF86XK_WakeUp 0x1008FF2B +#define XF86XK_Eject 0x1008FF2C +#define XF86XK_ScreenSaver 0x1008FF2D +#define XF86XK_WWW 0x1008FF2E +#define XF86XK_Sleep 0x1008FF2F +#define XF86XK_Favorites 0x1008FF30 +#define XF86XK_AudioPause 0x1008FF31 +#define XF86XK_AudioMedia 0x1008FF32 +#define XF86XK_MyComputer 0x1008FF33 +#define XF86XK_LightBulb 0x1008FF35 +#define XF86XK_Shop 0x1008FF36 +#define XF86XK_History 0x1008FF37 +#define XF86XK_OpenURL 0x1008FF38 +#define XF86XK_AddFavorite 0x1008FF39 +#define XF86XK_HotLinks 0x1008FF3A +#define XF86XK_BrightnessAdjust 0x1008FF3B +#define XF86XK_Finance 0x1008FF3C +#define XF86XK_Community 0x1008FF3D +#define XF86XK_AudioRewind 0x1008FF3E +#define XF86XK_BackForward 0x1008FF3F +#define XF86XK_Launch0 0x1008FF40 +#define XF86XK_Launch1 0x1008FF41 +#define XF86XK_Launch2 0x1008FF42 +#define XF86XK_Launch3 0x1008FF43 +#define XF86XK_Launch4 0x1008FF44 +#define XF86XK_Launch5 0x1008FF45 +#define XF86XK_Launch6 0x1008FF46 +#define XF86XK_Launch7 0x1008FF47 +#define XF86XK_Launch8 0x1008FF48 +#define XF86XK_Launch9 0x1008FF49 +#define XF86XK_LaunchA 0x1008FF4A +#define XF86XK_LaunchB 0x1008FF4B +#define XF86XK_LaunchC 0x1008FF4C +#define XF86XK_LaunchD 0x1008FF4D +#define XF86XK_LaunchE 0x1008FF4E +#define XF86XK_LaunchF 0x1008FF4F +#define XF86XK_ApplicationLeft 0x1008FF50 +#define XF86XK_ApplicationRight 0x1008FF51 +#define XF86XK_Book 0x1008FF52 +#define XF86XK_CD 0x1008FF53 +#define XF86XK_Calculater 0x1008FF54 +#define XF86XK_Clear 0x1008FF55 +#define XF86XK_ClearGrab 0x1008FE21 +#define XF86XK_Close 0x1008FF56 +#define XF86XK_Copy 0x1008FF57 +#define XF86XK_Cut 0x1008FF58 +#define XF86XK_Display 0x1008FF59 +#define XF86XK_DOS 0x1008FF5A +#define XF86XK_Documents 0x1008FF5B +#define XF86XK_Excel 0x1008FF5C +#define XF86XK_Explorer 0x1008FF5D +#define XF86XK_Game 0x1008FF5E +#define XF86XK_Go 0x1008FF5F +#define XF86XK_iTouch 0x1008FF60 +#define XF86XK_LogOff 0x1008FF61 +#define XF86XK_Market 0x1008FF62 +#define XF86XK_Meeting 0x1008FF63 +#define XF86XK_MenuKB 0x1008FF65 +#define XF86XK_MenuPB 0x1008FF66 +#define XF86XK_MySites 0x1008FF67 +#define XF86XK_News 0x1008FF69 +#define XF86XK_OfficeHome 0x1008FF6A +#define XF86XK_Option 0x1008FF6C +#define XF86XK_Paste 0x1008FF6D +#define XF86XK_Phone 0x1008FF6E +#define XF86XK_Reply 0x1008FF72 +#define XF86XK_Reload 0x1008FF73 +#define XF86XK_RotateWindows 0x1008FF74 +#define XF86XK_RotationPB 0x1008FF75 +#define XF86XK_RotationKB 0x1008FF76 +#define XF86XK_Save 0x1008FF77 +#define XF86XK_Send 0x1008FF7B +#define XF86XK_Spell 0x1008FF7C +#define XF86XK_SplitScreen 0x1008FF7D +#define XF86XK_Support 0x1008FF7E +#define XF86XK_TaskPane 0x1008FF7F +#define XF86XK_Terminal 0x1008FF80 +#define XF86XK_Tools 0x1008FF81 +#define XF86XK_Travel 0x1008FF82 +#define XF86XK_Video 0x1008FF87 +#define XF86XK_Word 0x1008FF89 +#define XF86XK_Xfer 0x1008FF8A +#define XF86XK_ZoomIn 0x1008FF8B +#define XF86XK_ZoomOut 0x1008FF8C +#define XF86XK_Away 0x1008FF8D +#define XF86XK_Messenger 0x1008FF8E +#define XF86XK_WebCam 0x1008FF8F +#define XF86XK_MailForward 0x1008FF90 +#define XF86XK_Pictures 0x1008FF91 +#define XF86XK_Music 0x1008FF92 +#define XF86XK_Battery 0x1008FF93 +#define XF86XK_Bluetooth 0x1008FF94 +#define XF86XK_WLAN 0x1008FF95 +#define XF86XK_UWB 0x1008FF96 +#define XF86XK_AudioForward 0x1008FF97 +#define XF86XK_AudioRepeat 0x1008FF98 +#define XF86XK_AudioRandomPlay 0x1008FF99 +#define XF86XK_Subtitle 0x1008FF9A +#define XF86XK_AudioCycleTrack 0x1008FF9B +#define XF86XK_Time 0x1008FF9F +#define XF86XK_Select 0x1008FFA0 +#define XF86XK_View 0x1008FFA1 +#define XF86XK_TopMenu 0x1008FFA2 +#define XF86XK_Suspend 0x1008FFA7 +#define XF86XK_Hibernate 0x1008FFA8 + + // end of XF86keysyms.h // Special keys used by Qtopia, mapped into the X11 private keypad range. @@ -942,10 +1039,8 @@ static const unsigned int KeyTbl[] = { XK_dead_hook, Qt::Key_Dead_Hook, XK_dead_horn, Qt::Key_Dead_Horn, - // Special multimedia keys - // currently only tested with MS internet keyboard - - // browsing keys + // Special keys from X.org - This include multimedia keys, + // wireless/bluetooth/uwb keys, special launcher keys, etc. XF86XK_Back, Qt::Key_Back, XF86XK_Forward, Qt::Key_Forward, XF86XK_Stop, Qt::Key_Stop, @@ -955,8 +1050,6 @@ static const unsigned int KeyTbl[] = { XF86XK_OpenURL, Qt::Key_OpenUrl, XF86XK_HomePage, Qt::Key_HomePage, XF86XK_Search, Qt::Key_Search, - - // media keys XF86XK_AudioLowerVolume, Qt::Key_VolumeDown, XF86XK_AudioMute, Qt::Key_VolumeMute, XF86XK_AudioRaiseVolume, Qt::Key_VolumeUp, @@ -965,13 +1058,106 @@ static const unsigned int KeyTbl[] = { XF86XK_AudioPrev, Qt::Key_MediaPrevious, XF86XK_AudioNext, Qt::Key_MediaNext, XF86XK_AudioRecord, Qt::Key_MediaRecord, - - // launch keys XF86XK_Mail, Qt::Key_LaunchMail, XF86XK_MyComputer, Qt::Key_Launch0, - XF86XK_Calculator, Qt::Key_Launch1, + XF86XK_Calculator, Qt::Key_Calculator, + XF86XK_Memo, Qt::Key_Memo, + XF86XK_ToDoList, Qt::Key_ToDoList, + XF86XK_Calendar, Qt::Key_Calendar, + XF86XK_PowerDown, Qt::Key_PowerDown, + XF86XK_ContrastAdjust, Qt::Key_ContrastAdjust, XF86XK_Standby, Qt::Key_Standby, - + XF86XK_MonBrightnessUp, Qt::Key_MonBrightnessUp, + XF86XK_MonBrightnessDown, Qt::Key_MonBrightnessDown, + XF86XK_KbdLightOnOff, Qt::Key_KeyboardLightOnOff, + XF86XK_KbdBrightnessUp, Qt::Key_KeyboardBrightnessUp, + XF86XK_KbdBrightnessDown, Qt::Key_KeyboardBrightnessDown, + XF86XK_PowerOff, Qt::Key_PowerOff, + XF86XK_WakeUp, Qt::Key_WakeUp, + XF86XK_Eject, Qt::Key_Eject, + XF86XK_ScreenSaver, Qt::Key_ScreenSaver, + XF86XK_WWW, Qt::Key_WWW, + XF86XK_Sleep, Qt::Key_Sleep, + XF86XK_LightBulb, Qt::Key_LightBulb, + XF86XK_Shop, Qt::Key_Shop, + XF86XK_History, Qt::Key_History, + XF86XK_AddFavorite, Qt::Key_AddFavorite, + XF86XK_HotLinks, Qt::Key_HotLinks, + XF86XK_BrightnessAdjust, Qt::Key_BrightnessAdjust, + XF86XK_Finance, Qt::Key_Finance, + XF86XK_Community, Qt::Key_Community, + XF86XK_AudioRewind, Qt::Key_AudioRewind, + XF86XK_BackForward, Qt::Key_BackForward, + XF86XK_ApplicationLeft, Qt::Key_ApplicationLeft, + XF86XK_ApplicationRight, Qt::Key_ApplicationRight, + XF86XK_Book, Qt::Key_Book, + XF86XK_CD, Qt::Key_CD, + XF86XK_Calculater, Qt::Key_Calculator, + XF86XK_Clear, Qt::Key_Clear, + XF86XK_ClearGrab, Qt::Key_ClearGrab, + XF86XK_Close, Qt::Key_Close, + XF86XK_Copy, Qt::Key_Copy, + XF86XK_Cut, Qt::Key_Cut, + XF86XK_Display, Qt::Key_Display, + XF86XK_DOS, Qt::Key_DOS, + XF86XK_Documents, Qt::Key_Documents, + XF86XK_Excel, Qt::Key_Excel, + XF86XK_Explorer, Qt::Key_Explorer, + XF86XK_Game, Qt::Key_Game, + XF86XK_Go, Qt::Key_Go, + XF86XK_iTouch, Qt::Key_iTouch, + XF86XK_LogOff, Qt::Key_LogOff, + XF86XK_Market, Qt::Key_Market, + XF86XK_Meeting, Qt::Key_Meeting, + XF86XK_MenuKB, Qt::Key_MenuKB, + XF86XK_MenuPB, Qt::Key_MenuPB, + XF86XK_MySites, Qt::Key_MySites, + XF86XK_News, Qt::Key_News, + XF86XK_OfficeHome, Qt::Key_OfficeHome, + XF86XK_Option, Qt::Key_Option, + XF86XK_Paste, Qt::Key_Paste, + XF86XK_Phone, Qt::Key_Phone, + XF86XK_Reply, Qt::Key_Reply, + XF86XK_Reload, Qt::Key_Reload, + XF86XK_RotateWindows, Qt::Key_RotateWindows, + XF86XK_RotationPB, Qt::Key_RotationPB, + XF86XK_RotationKB, Qt::Key_RotationKB, + XF86XK_Save, Qt::Key_Save, + XF86XK_Send, Qt::Key_Send, + XF86XK_Spell, Qt::Key_Spell, + XF86XK_SplitScreen, Qt::Key_SplitScreen, + XF86XK_Support, Qt::Key_Support, + XF86XK_TaskPane, Qt::Key_TaskPane, + XF86XK_Terminal, Qt::Key_Terminal, + XF86XK_Tools, Qt::Key_Tools, + XF86XK_Travel, Qt::Key_Travel, + XF86XK_Video, Qt::Key_Video, + XF86XK_Word, Qt::Key_Word, + XF86XK_Xfer, Qt::Key_Xfer, + XF86XK_ZoomIn, Qt::Key_ZoomIn, + XF86XK_ZoomOut, Qt::Key_ZoomOut, + XF86XK_Away, Qt::Key_Away, + XF86XK_Messenger, Qt::Key_Messenger, + XF86XK_WebCam, Qt::Key_WebCam, + XF86XK_MailForward, Qt::Key_MailForward, + XF86XK_Pictures, Qt::Key_Pictures, + XF86XK_Music, Qt::Key_Music, + XF86XK_Battery, Qt::Key_Battery, + XF86XK_Bluetooth, Qt::Key_Bluetooth, + XF86XK_WLAN, Qt::Key_WLAN, + XF86XK_UWB, Qt::Key_UWB, + XF86XK_AudioForward, Qt::Key_AudioForward, + XF86XK_AudioRepeat, Qt::Key_AudioRepeat, + XF86XK_AudioRandomPlay, Qt::Key_AudioRandomPlay, + XF86XK_Subtitle, Qt::Key_Subtitle, + XF86XK_AudioCycleTrack, Qt::Key_AudioCycleTrack, + XF86XK_Time, Qt::Key_Time, + XF86XK_Select, Qt::Key_Select, + XF86XK_View, Qt::Key_View, + XF86XK_TopMenu, Qt::Key_TopMenu, + XF86XK_Bluetooth, Qt::Key_Bluetooth, + XF86XK_Suspend, Qt::Key_Suspend, + XF86XK_Hibernate, Qt::Key_Hibernate, XF86XK_Launch0, Qt::Key_Launch2, XF86XK_Launch1, Qt::Key_Launch3, XF86XK_Launch2, Qt::Key_Launch4, diff --git a/src/gui/kernel/qkeysequence.cpp b/src/gui/kernel/qkeysequence.cpp index b44ef7f..1a76083 100644 --- a/src/gui/kernel/qkeysequence.cpp +++ b/src/gui/kernel/qkeysequence.cpp @@ -416,47 +416,139 @@ static const struct { { Qt::Key_Menu, QT_TRANSLATE_NOOP("QShortcut", "Menu") }, { Qt::Key_Help, QT_TRANSLATE_NOOP("QShortcut", "Help") }, - // Multimedia keys - { Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") }, - { Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") }, - { Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") }, - { Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") }, - { Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") }, - { Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") }, - { Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") }, - { Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") }, - { Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") }, - { Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") }, - { Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") }, - { Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") }, - { Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") }, - { Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") }, - { Qt::Key_MediaPrevious,QT_TRANSLATE_NOOP("QShortcut", "Media Previous") }, - { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") }, - { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") }, - { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") }, - { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") }, - { Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") }, - { Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") }, - { Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") }, - { Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") }, - { Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") }, - { Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") }, - { Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") }, - { Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") }, - { Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") }, - { Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") }, - { Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") }, - { Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") }, - { Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") }, - { Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") }, - { Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") }, - { Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") }, - { Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") }, - { Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") }, - { Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") }, - { Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") }, - { Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") }, + // Special keys + // Includes multimedia, launcher, lan keys ( bluetooth, wireless ) + // window navigation + { Qt::Key_Back, QT_TRANSLATE_NOOP("QShortcut", "Back") }, + { Qt::Key_Forward, QT_TRANSLATE_NOOP("QShortcut", "Forward") }, + { Qt::Key_Stop, QT_TRANSLATE_NOOP("QShortcut", "Stop") }, + { Qt::Key_Refresh, QT_TRANSLATE_NOOP("QShortcut", "Refresh") }, + { Qt::Key_VolumeDown, QT_TRANSLATE_NOOP("QShortcut", "Volume Down") }, + { Qt::Key_VolumeMute, QT_TRANSLATE_NOOP("QShortcut", "Volume Mute") }, + { Qt::Key_VolumeUp, QT_TRANSLATE_NOOP("QShortcut", "Volume Up") }, + { Qt::Key_BassBoost, QT_TRANSLATE_NOOP("QShortcut", "Bass Boost") }, + { Qt::Key_BassUp, QT_TRANSLATE_NOOP("QShortcut", "Bass Up") }, + { Qt::Key_BassDown, QT_TRANSLATE_NOOP("QShortcut", "Bass Down") }, + { Qt::Key_TrebleUp, QT_TRANSLATE_NOOP("QShortcut", "Treble Up") }, + { Qt::Key_TrebleDown, QT_TRANSLATE_NOOP("QShortcut", "Treble Down") }, + { Qt::Key_MediaPlay, QT_TRANSLATE_NOOP("QShortcut", "Media Play") }, + { Qt::Key_MediaStop, QT_TRANSLATE_NOOP("QShortcut", "Media Stop") }, + { Qt::Key_MediaPrevious, QT_TRANSLATE_NOOP("QShortcut", "Media Previous") }, + { Qt::Key_MediaNext, QT_TRANSLATE_NOOP("QShortcut", "Media Next") }, + { Qt::Key_MediaRecord, QT_TRANSLATE_NOOP("QShortcut", "Media Record") }, + { Qt::Key_HomePage, QT_TRANSLATE_NOOP("QShortcut", "Home Page") }, + { Qt::Key_Favorites, QT_TRANSLATE_NOOP("QShortcut", "Favorites") }, + { Qt::Key_Search, QT_TRANSLATE_NOOP("QShortcut", "Search") }, + { Qt::Key_Standby, QT_TRANSLATE_NOOP("QShortcut", "Standby") }, + { Qt::Key_OpenUrl, QT_TRANSLATE_NOOP("QShortcut", "Open URL") }, + { Qt::Key_LaunchMail, QT_TRANSLATE_NOOP("QShortcut", "Launch Mail") }, + { Qt::Key_LaunchMedia, QT_TRANSLATE_NOOP("QShortcut", "Launch Media") }, + { Qt::Key_Launch0, QT_TRANSLATE_NOOP("QShortcut", "Launch (0)") }, + { Qt::Key_Launch1, QT_TRANSLATE_NOOP("QShortcut", "Launch (1)") }, + { Qt::Key_Launch2, QT_TRANSLATE_NOOP("QShortcut", "Launch (2)") }, + { Qt::Key_Launch3, QT_TRANSLATE_NOOP("QShortcut", "Launch (3)") }, + { Qt::Key_Launch4, QT_TRANSLATE_NOOP("QShortcut", "Launch (4)") }, + { Qt::Key_Launch5, QT_TRANSLATE_NOOP("QShortcut", "Launch (5)") }, + { Qt::Key_Launch6, QT_TRANSLATE_NOOP("QShortcut", "Launch (6)") }, + { Qt::Key_Launch7, QT_TRANSLATE_NOOP("QShortcut", "Launch (7)") }, + { Qt::Key_Launch8, QT_TRANSLATE_NOOP("QShortcut", "Launch (8)") }, + { Qt::Key_Launch9, QT_TRANSLATE_NOOP("QShortcut", "Launch (9)") }, + { Qt::Key_LaunchA, QT_TRANSLATE_NOOP("QShortcut", "Launch (A)") }, + { Qt::Key_LaunchB, QT_TRANSLATE_NOOP("QShortcut", "Launch (B)") }, + { Qt::Key_LaunchC, QT_TRANSLATE_NOOP("QShortcut", "Launch (C)") }, + { Qt::Key_LaunchD, QT_TRANSLATE_NOOP("QShortcut", "Launch (D)") }, + { Qt::Key_LaunchE, QT_TRANSLATE_NOOP("QShortcut", "Launch (E)") }, + { Qt::Key_LaunchF, QT_TRANSLATE_NOOP("QShortcut", "Launch (F)") }, + { Qt::Key_MonBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Up") }, + { Qt::Key_MonBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Monitor Brightness Down") }, + { Qt::Key_KeyboardLightOnOff, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Light On/Off") }, + { Qt::Key_KeyboardBrightnessUp, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Up") }, + { Qt::Key_KeyboardBrightnessDown, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Brightness Down") }, + { Qt::Key_PowerOff, QT_TRANSLATE_NOOP("QShortcut", "Power Off") }, + { Qt::Key_WakeUp, QT_TRANSLATE_NOOP("QShortcut", "Wake Up") }, + { Qt::Key_Eject, QT_TRANSLATE_NOOP("QShortcut", "Eject") }, + { Qt::Key_ScreenSaver, QT_TRANSLATE_NOOP("QShortcut", "Screensaver") }, + { Qt::Key_WWW, QT_TRANSLATE_NOOP("QShortcut", "WWW") }, + { Qt::Key_Sleep, QT_TRANSLATE_NOOP("QShortcut", "Sleep") }, + { Qt::Key_LightBulb, QT_TRANSLATE_NOOP("QShortcut", "LightBulb") }, + { Qt::Key_Shop, QT_TRANSLATE_NOOP("QShortcut", "Shop") }, + { Qt::Key_History, QT_TRANSLATE_NOOP("QShortcut", "History") }, + { Qt::Key_AddFavorite, QT_TRANSLATE_NOOP("QShortcut", "Add Favorite") }, + { Qt::Key_HotLinks, QT_TRANSLATE_NOOP("QShortcut", "Hot Links") }, + { Qt::Key_BrightnessAdjust, QT_TRANSLATE_NOOP("QShortcut", "Adjust Brightness") }, + { Qt::Key_Finance, QT_TRANSLATE_NOOP("QShortcut", "Finance") }, + { Qt::Key_Community, QT_TRANSLATE_NOOP("QShortcut", "Community") }, + { Qt::Key_AudioRewind, QT_TRANSLATE_NOOP("QShortcut", "Audio Rewind") }, + { Qt::Key_BackForward, QT_TRANSLATE_NOOP("QShortcut", "Back Forward") }, + { Qt::Key_ApplicationLeft, QT_TRANSLATE_NOOP("QShortcut", "Application Left") }, + { Qt::Key_ApplicationRight, QT_TRANSLATE_NOOP("QShortcut", "Application Right") }, + { Qt::Key_Book, QT_TRANSLATE_NOOP("QShortcut", "Book") }, + { Qt::Key_CD, QT_TRANSLATE_NOOP("QShortcut", "CD") }, + { Qt::Key_Calculator, QT_TRANSLATE_NOOP("QShortcut", "Calculator") }, + { Qt::Key_Clear, QT_TRANSLATE_NOOP("QShortcut", "Clear") }, + { Qt::Key_ClearGrab, QT_TRANSLATE_NOOP("QShortcut", "Clear Grab") }, + { Qt::Key_Close, QT_TRANSLATE_NOOP("QShortcut", "Close") }, + { Qt::Key_Copy, QT_TRANSLATE_NOOP("QShortcut", "Copy") }, + { Qt::Key_Cut, QT_TRANSLATE_NOOP("QShortcut", "Cut") }, + { Qt::Key_Display, QT_TRANSLATE_NOOP("QShortcut", "Display") }, + { Qt::Key_DOS, QT_TRANSLATE_NOOP("QShortcut", "DOS") }, + { Qt::Key_Documents, QT_TRANSLATE_NOOP("QShortcut", "Documents") }, + { Qt::Key_Excel, QT_TRANSLATE_NOOP("QShortcut", "Spreadsheet") }, + { Qt::Key_Explorer, QT_TRANSLATE_NOOP("QShortcut", "Browser") }, + { Qt::Key_Game, QT_TRANSLATE_NOOP("QShortcut", "Game") }, + { Qt::Key_Go, QT_TRANSLATE_NOOP("QShortcut", "Go") }, + { Qt::Key_iTouch, QT_TRANSLATE_NOOP("QShortcut", "iTouch") }, + { Qt::Key_LogOff, QT_TRANSLATE_NOOP("QShortcut", "Logoff") }, + { Qt::Key_Market, QT_TRANSLATE_NOOP("QShortcut", "Market") }, + { Qt::Key_Meeting, QT_TRANSLATE_NOOP("QShortcut", "Meeting") }, + { Qt::Key_MenuKB, QT_TRANSLATE_NOOP("QShortcut", "Keyboard Menu") }, + { Qt::Key_MenuPB, QT_TRANSLATE_NOOP("QShortcut", "Menu PB") }, + { Qt::Key_MySites, QT_TRANSLATE_NOOP("QShortcut", "My Sites") }, + { Qt::Key_News, QT_TRANSLATE_NOOP("QShortcut", "News") }, + { Qt::Key_OfficeHome, QT_TRANSLATE_NOOP("QShortcut", "Home Office") }, + { Qt::Key_Option, QT_TRANSLATE_NOOP("QShortcut", "Option") }, + { Qt::Key_Paste, QT_TRANSLATE_NOOP("QShortcut", "Paste") }, + { Qt::Key_Phone, QT_TRANSLATE_NOOP("QShortcut", "Phone") }, + { Qt::Key_Reply, QT_TRANSLATE_NOOP("QShortcut", "Reply") }, + { Qt::Key_Reload, QT_TRANSLATE_NOOP("QShortcut", "Reload") }, + { Qt::Key_RotateWindows, QT_TRANSLATE_NOOP("QShortcut", "Rotate Windows") }, + { Qt::Key_RotationPB, QT_TRANSLATE_NOOP("QShortcut", "Rotation PB") }, + { Qt::Key_RotationKB, QT_TRANSLATE_NOOP("QShortcut", "Rotation KB") }, + { Qt::Key_Save, QT_TRANSLATE_NOOP("QShortcut", "Save") }, + { Qt::Key_Send, QT_TRANSLATE_NOOP("QShortcut", "Send") }, + { Qt::Key_Spell, QT_TRANSLATE_NOOP("QShortcut", "Spellchecker") }, + { Qt::Key_SplitScreen, QT_TRANSLATE_NOOP("QShortcut", "Split Screen") }, + { Qt::Key_Support, QT_TRANSLATE_NOOP("QShortcut", "Support") }, + { Qt::Key_TaskPane, QT_TRANSLATE_NOOP("QShortcut", "Task Panel") }, + { Qt::Key_Terminal, QT_TRANSLATE_NOOP("QShortcut", "Terminal") }, + { Qt::Key_Tools, QT_TRANSLATE_NOOP("QShortcut", "Tools") }, + { Qt::Key_Travel, QT_TRANSLATE_NOOP("QShortcut", "Travel") }, + { Qt::Key_Video, QT_TRANSLATE_NOOP("QShortcut", "Video") }, + { Qt::Key_Word, QT_TRANSLATE_NOOP("QShortcut", "Word Processor") }, + { Qt::Key_Xfer, QT_TRANSLATE_NOOP("QShortcut", "XFer") }, + { Qt::Key_ZoomIn, QT_TRANSLATE_NOOP("QShortcut", "Zoom In") }, + { Qt::Key_ZoomOut, QT_TRANSLATE_NOOP("QShortcut", "Zoom Out") }, + { Qt::Key_Away, QT_TRANSLATE_NOOP("QShortcut", "Away") }, + { Qt::Key_Messenger, QT_TRANSLATE_NOOP("QShortcut", "Messenger") }, + { Qt::Key_WebCam, QT_TRANSLATE_NOOP("QShortcut", "WebCam") }, + { Qt::Key_MailForward, QT_TRANSLATE_NOOP("QShortcut", "Mail Forward") }, + { Qt::Key_Pictures, QT_TRANSLATE_NOOP("QShortcut", "Pictures") }, + { Qt::Key_Music, QT_TRANSLATE_NOOP("QShortcut", "Music") }, + { Qt::Key_Battery, QT_TRANSLATE_NOOP("QShortcut", "Battery") }, + { Qt::Key_Bluetooth, QT_TRANSLATE_NOOP("QShortcut", "Bluetooth") }, + { Qt::Key_WLAN, QT_TRANSLATE_NOOP("QShortcut", "Wireless") }, + { Qt::Key_UWB, QT_TRANSLATE_NOOP("QShortcut", "Ultra Wide Band") }, + { Qt::Key_AudioForward, QT_TRANSLATE_NOOP("QShortcut", "Audio Forward") }, + { Qt::Key_AudioRepeat, QT_TRANSLATE_NOOP("QShortcut", "Audio Repeat") }, + { Qt::Key_AudioRandomPlay, QT_TRANSLATE_NOOP("QShortcut", "Audio Random Play") }, + { Qt::Key_Subtitle, QT_TRANSLATE_NOOP("QShortcut", "Subtitle") }, + { Qt::Key_AudioCycleTrack, QT_TRANSLATE_NOOP("QShortcut", "Audio Cycle Track") }, + { Qt::Key_Time, QT_TRANSLATE_NOOP("QShortcut", "Time") }, + { Qt::Key_Select, QT_TRANSLATE_NOOP("QShortcut", "Select") }, + { Qt::Key_View, QT_TRANSLATE_NOOP("QShortcut", "View") }, + { Qt::Key_TopMenu, QT_TRANSLATE_NOOP("QShortcut", "Top Menu") }, + { Qt::Key_Suspend, QT_TRANSLATE_NOOP("QShortcut", "Suspend") }, + { Qt::Key_Hibernate, QT_TRANSLATE_NOOP("QShortcut", "Hibernate") }, // -------------------------------------------------------------- // More consistent namings -- cgit v0.12 From 0313ccbfaff690c5a8fc18a3a2c7d976a4a55aaf Mon Sep 17 00:00:00 2001 From: Gustavo Pichorim Boiko Date: Tue, 27 Oct 2009 18:16:11 +0100 Subject: Emit workAreaResized() in X11 when it changes Emit the QDesktopWidget::workAreaResized() signal when the _NET_WORKAREA property of the root window changes. Merge-request: 1111 Reviewed-by: Denis Dzyubenko --- src/gui/kernel/qapplication_x11.cpp | 6 ++++++ src/gui/kernel/qdesktopwidget_x11.cpp | 9 --------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qapplication_x11.cpp b/src/gui/kernel/qapplication_x11.cpp index bf95684..c6d188b 100644 --- a/src/gui/kernel/qapplication_x11.cpp +++ b/src/gui/kernel/qapplication_x11.cpp @@ -3750,6 +3750,12 @@ int QApplication::x11ProcessEvent(XEvent* event) qt_get_net_virtual_roots(); } else if (event->xproperty.atom == ATOM(_NET_WORKAREA)) { qt_desktopwidget_update_workarea(); + + // emit the workAreaResized() signal + QDesktopWidget *desktop = QApplication::desktop(); + int numScreens = desktop->numScreens(); + for (int i = 0; i < numScreens; ++i) + emit desktop->workAreaResized(i); } } else if (widget) { widget->translatePropertyEvent(event); diff --git a/src/gui/kernel/qdesktopwidget_x11.cpp b/src/gui/kernel/qdesktopwidget_x11.cpp index 02a2c82..14eb976 100644 --- a/src/gui/kernel/qdesktopwidget_x11.cpp +++ b/src/gui/kernel/qdesktopwidget_x11.cpp @@ -384,10 +384,8 @@ void QDesktopWidget::resizeEvent(QResizeEvent *event) Q_D(QDesktopWidget); int oldScreenCount = d->screenCount; QVector oldRects(oldScreenCount); - QVector oldWorks(oldScreenCount); for (int i = 0; i < oldScreenCount; ++i) { oldRects[i] = d->rects[i]; - oldWorks[i] = d->workareas[i]; } d->init(); @@ -397,13 +395,6 @@ void QDesktopWidget::resizeEvent(QResizeEvent *event) emit resized(i); } - // ### workareas are just reset by init, not filled with new values - // ### so this will not work correctly - for (int j = 0; j < qMin(oldScreenCount, d->screenCount); ++j) { - if (oldWorks.at(j) != d->workareas[j]) - emit workAreaResized(j); - } - if (oldScreenCount != d->screenCount) { emit screenCountChanged(d->screenCount); } -- cgit v0.12 From 0444453661df0f56fd034778028c7abdc0b621cc Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 28 Oct 2009 09:42:09 +0100 Subject: Don't stop event processing at the second WM_QT_SENDPOSTEDEVENTS We should continue processing as much as we can, and report the WM_QT_SENDPOSTEDEVENTS at the end of processEvents(). --- src/corelib/kernel/qeventdispatcher_win.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index df4c02d..d13e1d1 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -663,11 +663,12 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) bool canWait; bool retVal = false; + bool seenWM_QT_SENDPOSTEDEVENTS = false; + bool needWM_QT_SENDPOSTEDEVENTS = false; do { DWORD waitRet = 0; HANDLE pHandles[MAXIMUM_WAIT_OBJECTS - 1]; QVarLengthArray processedTimers; - bool seenWM_QT_SENDPOSTEDEVENTS = false; while (!d->interrupt) { DWORD nCount = d->winEventNotifierList.count(); Q_ASSERT(nCount < MAXIMUM_WAIT_OBJECTS - 1); @@ -717,8 +718,8 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) if (haveMessage) { if (msg.message == WM_QT_SENDPOSTEDEVENTS && !(flags & QEventLoop::EventLoopExec)) { if (seenWM_QT_SENDPOSTEDEVENTS) { - PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); - break; + needWM_QT_SENDPOSTEDEVENTS = true; + continue; } seenWM_QT_SENDPOSTEDEVENTS = true; } else if (msg.message == WM_TIMER) { @@ -770,6 +771,9 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags) } } while (canWait); + if (needWM_QT_SENDPOSTEDEVENTS) + PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0); + return retVal; } -- cgit v0.12 From 9a9cd7765bfe879b53488fe18bba75425e4c5c61 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 26 Oct 2009 14:20:49 +0100 Subject: add empty test method, should implement it fully when more important things are done --- tests/auto/gestures/tst_gestures.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index eba2616..6acfe70 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -330,6 +330,7 @@ private slots: void testMapToScene(); void ungrabGesture(); void consumeEventHint(); + void unregisterRecognizer(); }; tst_Gestures::tst_Gestures() @@ -1276,5 +1277,20 @@ void tst_Gestures::ungrabGesture() // a method on QWidget QCOMPARE(a->gestureOverrideEventsReceived, 0); } +void tst_Gestures::unregisterRecognizer() // a method on QApplication +{ + /* + The hardest usecase to get right is when we remove a recognizer while several + of the gestures it created are in active state and we immediately add a new recognizer + for the same type (thus replacing the old one). + The expected result is that all old gestures continue till they are finished/cancelled + and the new recognizer starts creating gestures immediately at registration. + + This implies that deleting of the recognizer happens only when there are no more gestures + that it created. (since gestures might have a pointer to the recognizer) + */ + +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 4470801f73b86d3ee06a866fbbdafcaeb9f294a6 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 27 Oct 2009 15:31:16 +0100 Subject: Introduce QGesture::GestureCancelPolicy, a way to auto-cancel gestures On accepting one gesture Qt can automatically cancel other gestures that belong to other targets. The policy is normally set to not cancel any other gestures and can be set to cancel all active gestures in the context. For example for all child widgets. Reviewed-By: Denis Dzyubenko --- src/gui/kernel/qgesture.cpp | 33 ++++++++++++++ src/gui/kernel/qgesture.h | 10 +++++ src/gui/kernel/qgesture_p.h | 10 +++-- src/gui/kernel/qgesturemanager.cpp | 85 ++++++++++++++++++++++++++++++++++-- src/gui/kernel/qgesturemanager_p.h | 2 + tests/auto/gestures/tst_gestures.cpp | 62 ++++++++++++++++++++++++++ 6 files changed, 195 insertions(+), 7 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index a161876..c302c51 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -175,6 +175,29 @@ void QGesture::unsetHotSpot() } /*! + \enum QGesture::GestureCancelPolicy + + This enum describes how accepting a gesture can cancel other gestures + automatically. + + \value CancelNone On accepting this gesture no other gestures will be affected. + \value CancelAllInContext On accepting this gesture all gestures that are active + in the context (Qt::GestureContext) will be cancelled. +*/ + +void QGesture::setGestureCancelPolicy(GestureCancelPolicy policy) +{ + Q_D(QGesture); + d->gestureCancelPolicy = static_cast(policy); +} + +QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const +{ + Q_D(const QGesture); + return static_cast(d->gestureCancelPolicy); +} + +/*! \class QPanGesture \since 4.6 \brief The QPanGesture class describes a panning gesture made by the user. @@ -195,6 +218,16 @@ void QGesture::unsetHotSpot() */ /*! + \property QGesture::GestureCancelPolicy + \brief the policy for deciding what happens on accepting a gesture + + On accepting one gesture Qt can automatically cancel other gestures + that belong to other targets. The policy is normally set to not cancel + any other gestures and can be set to cancel all active gestures in the + context. For example for all child widgets. +*/ + +/*! \property QPanGesture::lastOffset \brief the last offset recorded for this gesture diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 6469959..524d26e 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -65,6 +65,7 @@ class Q_GUI_EXPORT QGesture : public QObject Q_PROPERTY(Qt::GestureState state READ state) Q_PROPERTY(Qt::GestureType gestureType READ gestureType) + Q_PROPERTY(QGesture::GestureCancelPolicy gestureCancelPolicy READ gestureCancelPolicy WRITE setGestureCancelPolicy) Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot RESET unsetHotSpot) Q_PROPERTY(bool hasHotSpot READ hasHotSpot) @@ -81,6 +82,14 @@ public: bool hasHotSpot() const; void unsetHotSpot(); + enum GestureCancelPolicy { + CancelNone = 0, + CancelAllInContext + }; + + void setGestureCancelPolicy(GestureCancelPolicy policy); + GestureCancelPolicy gestureCancelPolicy() const; + protected: QGesture(QGesturePrivate &dd, QObject *parent); @@ -208,6 +217,7 @@ public: QT_END_NAMESPACE +Q_DECLARE_METATYPE(QGesture::GestureCancelPolicy) QT_END_HEADER #endif // QGESTURE_H diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index 975c0c9..d2ef8a7 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -67,16 +67,20 @@ class QGesturePrivate : public QObjectPrivate public: QGesturePrivate() - : gestureType(Qt::CustomGesture), state(Qt::NoGesture), isHotSpotSet(false), - targetObject(0) + : gestureType(Qt::CustomGesture), state(Qt::NoGesture), + targetObject(0), + isHotSpotSet(false), + gestureCancelPolicy(0) + { } Qt::GestureType gestureType; Qt::GestureState state; QPointF hotSpot; - bool isHotSpotSet; QObject *targetObject; + uint isHotSpotSet : 1; + uint gestureCancelPolicy : 2; }; class QPanGesturePrivate : public QGesturePrivate diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 52f8eef..fc7c8b2 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -322,21 +322,96 @@ bool QGestureManager::filterEventThroughContexts(const QMapgestureCancelPolicy() == QGesture::CancelAllInContext) { + DEBUG() << "lets try to cancel some"; + // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them + cancelGesturesForChildren(g); + } + } + activeGestures -= undeliveredGestures; // reset gestures that ended QSet endedGestures = finishedGestures + canceledGestures + undeliveredGestures; foreach (QGesture *gesture, endedGestures) { - if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) + if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) { + gesture->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(gesture); - else + } else { cleanupGesturesForRemovedRecognizer(gesture); + } gestureTargets.remove(gesture); } return ret; } +// Cancel all gestures of children of the widget that original is associated with +void QGestureManager::cancelGesturesForChildren(QGesture *original) +{ + Q_ASSERT(original); + QWidget *originatingWidget = gestureTargets.value(original); + Q_ASSERT(originatingWidget); + + // iterate over all active gestures and all maybe gestures + // for each find the owner + // if the owner is part of our sub-hierarchy, cancel it. + + QSet cancelledGestures; + QSet::Iterator iter = activeGestures.begin(); + while (iter != activeGestures.end()) { + QWidget *widget = gestureTargets.value(*iter); + // note that we don't touch the gestures for our originatingWidget + if (widget != originatingWidget && originatingWidget->isAncestorOf(widget)) { + DEBUG() << " found a gesture to cancel" << (*iter); + (*iter)->d_func()->state = Qt::GestureCanceled; + cancelledGestures << *iter; + iter = activeGestures.erase(iter); + } else { + ++iter; + } + } + + // TODO handle 'maybe' gestures too + + // sort them per target widget by cherry picking from almostCanceledGestures and delivering + QSet almostCanceledGestures = cancelledGestures; + while (!almostCanceledGestures.isEmpty()) { + QWidget *target = 0; + QSet gestures; + iter = almostCanceledGestures.begin(); + // sort per target widget + while (iter != almostCanceledGestures.end()) { + QWidget *widget = gestureTargets.value(*iter); + if (target == 0) + target = widget; + if (target == widget) { + gestures << *iter; + iter = almostCanceledGestures.erase(iter); + } else { + ++iter; + } + } + Q_ASSERT(target); + + QSet undeliveredGestures; + deliverEvents(gestures, &undeliveredGestures); + } + + for (iter = cancelledGestures.begin(); iter != cancelledGestures.end(); ++iter) { + QGestureRecognizer *recognizer = gestureToRecognizer.value(*iter, 0); + if (recognizer) { + (*iter)->setGestureCancelPolicy(QGesture::CancelNone); + recognizer->reset(*iter); + } else { + cleanupGesturesForRemovedRecognizer(*iter); + } + } +} + void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) { QGestureRecognizer *recognizer = m_deletedRecognizers.value(gesture); @@ -585,10 +660,12 @@ void QGestureManager::timerEvent(QTimerEvent *event) DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:" << gesture; QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0); - if (recognizer) + if (recognizer) { + gesture->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(gesture); - else + } else { cleanupGesturesForRemovedRecognizer(gesture); + } } else { ++it; } diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 96c2fb7..e6a1d50 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -135,6 +135,8 @@ private: void getGestureTargets(const QSet &gestures, QMap > *conflicts, QMap > *normal); + + void cancelGesturesForChildren(QGesture *originatingGesture); }; QT_END_NAMESPACE diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 6acfe70..39cdf63 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -331,6 +331,7 @@ private slots: void ungrabGesture(); void consumeEventHint(); void unregisterRecognizer(); + void autoCancelGestures(); }; tst_Gestures::tst_Gestures() @@ -1292,5 +1293,66 @@ void tst_Gestures::unregisterRecognizer() // a method on QApplication } +void tst_Gestures::autoCancelGestures() +{ + class MockRecognizer : public QGestureRecognizer { + public: + QGestureRecognizer::Result filterEvent(QGesture *gesture, QObject *watched, QEvent *event) + { + Q_UNUSED(gesture); + Q_UNUSED(watched); + if (event->type() == QEvent::MouseButtonPress) + return QGestureRecognizer::GestureTriggered; + if (event->type() == QEvent::MouseButtonRelease) + return QGestureRecognizer::GestureFinished; + return QGestureRecognizer::Ignore; + } + }; + + class MockWidget : public GestureWidget { + public: + MockWidget(const char *name) : GestureWidget(name) { } + + bool event(QEvent *event) + { + if (event->type() == QEvent::Gesture) { + QGestureEvent *ge = static_cast(event); + Q_ASSERT(ge->allGestures().count() == 1); // can't use QCOMPARE here... + ge->allGestures().first()->setGestureCancelPolicy(QGesture::CancelAllInContext); + } + return GestureWidget::event(event); + } + }; + + MockWidget parent("parent"); // this one sets the cancel policy to CancelAllInContext + parent.resize(300, 100); + GestureWidget *child = new GestureWidget("child", &parent); + child->setGeometry(10, 10, 100, 80); + + Qt::GestureType type = qApp->registerGestureRecognizer(new MockRecognizer()); + parent.grabGesture(type, Qt::WidgetWithChildrenGesture); + child->grabGesture(type, Qt::WidgetWithChildrenGesture); + + /* + An event is send to both the child and the parent, when the child gets it a gesture is triggered + and send to the child. + When the parent gets the event a new gesture is triggered and delivered to the parent. When the + parent gets it he accepts it and that causes the cancel policy to activate. + The cause of that is the gesture for the child is cancelled and send to the child as such. + */ + QMouseEvent event(QEvent::MouseButtonPress, QPoint(20,20), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier); + QApplication::sendEvent(child, &event); + QCOMPARE(child->events.started.count(), 1); + QCOMPARE(child->events.all.count(), 1); + QCOMPARE(parent.events.all.count(), 0); + child->reset(); + QApplication::sendEvent(&parent, &event); + QCOMPARE(parent.events.all.count(), 1); + QCOMPARE(parent.events.started.count(), 1); + QCOMPARE(child->events.started.count(), 0); + QCOMPARE(child->events.all.count(), 1); + QCOMPARE(child->events.canceled.count(), 1); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 3c2c1c21b41f600eeaa056b66fe44d5017f9b500 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 28 Oct 2009 10:55:19 +0100 Subject: Drag and drop of plain text doesnot work on Mac. While querying for the text in the pasteboard, it was looking in the wrong place. The helper function qt_mac_get_pasteboardString() always searched in generalPasteboard instead of the pasteboard referred by the QMacPasteboard. Reviewed-by: MortenS --- src/gui/kernel/qclipboard_mac.cpp | 2 +- src/gui/kernel/qt_cocoa_helpers_mac.mm | 19 +++++++++++++------ src/gui/kernel/qt_cocoa_helpers_mac_p.h | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/gui/kernel/qclipboard_mac.cpp b/src/gui/kernel/qclipboard_mac.cpp index 3db647b..8892269 100644 --- a/src/gui/kernel/qclipboard_mac.cpp +++ b/src/gui/kernel/qclipboard_mac.cpp @@ -532,7 +532,7 @@ QMacPasteboard::retrieveData(const QString &format, QVariant::Type) const // Try to get the NSStringPboardType from NSPasteboard, newlines are mapped // correctly (as '\n') in this data. The 'public.utf16-plain-text' type // usually maps newlines to '\r' instead. - QString str = qt_mac_get_pasteboardString(); + QString str = qt_mac_get_pasteboardString(paste); if (!str.isEmpty()) return str; } diff --git a/src/gui/kernel/qt_cocoa_helpers_mac.mm b/src/gui/kernel/qt_cocoa_helpers_mac.mm index 2b2259c..c0fb8aa 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac.mm +++ b/src/gui/kernel/qt_cocoa_helpers_mac.mm @@ -1152,16 +1152,23 @@ CGFloat qt_mac_get_scalefactor() #endif } -QString qt_mac_get_pasteboardString() +QString qt_mac_get_pasteboardString(OSPasteboardRef paste) { QMacCocoaAutoReleasePool pool; - NSPasteboard *pb = [NSPasteboard generalPasteboard]; - NSString *text = [pb stringForType:NSStringPboardType]; - if (text) { - return qt_mac_NSStringToQString(text); + NSPasteboard *pb = nil; + CFStringRef pbname; + if (PasteboardCopyName (paste, &pbname)) { + pb = [NSPasteboard generalPasteboard]; } else { - return QString(); + pb = [NSPasteboard pasteboardWithName:reinterpret_cast(pbname)]; + CFRelease (pbname); } + if (pb) { + NSString *text = [pb stringForType:NSStringPboardType]; + if (text) + return qt_mac_NSStringToQString(text); + } + return QString(); } QPixmap qt_mac_convert_iconref(const IconRef icon, int width, int height) diff --git a/src/gui/kernel/qt_cocoa_helpers_mac_p.h b/src/gui/kernel/qt_cocoa_helpers_mac_p.h index 62db064..ea35fb6 100644 --- a/src/gui/kernel/qt_cocoa_helpers_mac_p.h +++ b/src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -170,7 +170,7 @@ void *qt_mac_QStringListToNSMutableArrayVoid(const QStringList &list); void qt_syncCocoaTitleBarButtons(OSWindowRef window, QWidget *widgetForWindow); CGFloat qt_mac_get_scalefactor(); -QString qt_mac_get_pasteboardString(); +QString qt_mac_get_pasteboardString(OSPasteboardRef paste); #ifdef __OBJC__ inline NSMutableArray *qt_mac_QStringListToNSMutableArray(const QStringList &qstrlist) -- cgit v0.12 From 7f2d0fdf064f1e5625b784a5712d21545cf79ba1 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 28 Oct 2009 12:49:38 +0100 Subject: Rename private member variables to begin with m_ Reviewed-By: TrustMe --- src/gui/kernel/qgesturemanager.cpp | 116 ++++++++++++++++++------------------- src/gui/kernel/qgesturemanager_p.h | 17 +++--- 2 files changed, 66 insertions(+), 67 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index fc7c8b2..a90c299 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -65,7 +65,7 @@ QT_BEGIN_NAMESPACE QGestureManager::QGestureManager(QObject *parent) - : QObject(parent), state(NotGesture), lastCustomGestureId(0) + : QObject(parent), state(NotGesture), m_lastCustomGestureId(0) { qRegisterMetaType(); @@ -82,7 +82,7 @@ QGestureManager::QGestureManager(QObject *parent) QGestureManager::~QGestureManager() { - qDeleteAll(recognizers.values()); + qDeleteAll(m_recognizers.values()); } Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer) @@ -96,30 +96,30 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r Qt::GestureType type = dummy->gestureType(); if (type == Qt::CustomGesture) { // generate a new custom gesture id - ++lastCustomGestureId; - type = Qt::GestureType(Qt::CustomGesture + lastCustomGestureId); + ++m_lastCustomGestureId; + type = Qt::GestureType(Qt::CustomGesture + m_lastCustomGestureId); } - recognizers.insertMulti(type, recognizer); + m_recognizers.insertMulti(type, recognizer); delete dummy; return type; } void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { - QList list = recognizers.values(type); - recognizers.remove(type); - foreach (QGesture* g, gestureToRecognizer.keys()) { - QGestureRecognizer *recognizer = gestureToRecognizer.value(g); + QList list = m_recognizers.values(type); + m_recognizers.remove(type); + foreach (QGesture* g, m_gestureToRecognizer.keys()) { + QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { m_deletedRecognizers.insert(g, recognizer); - gestureToRecognizer.remove(g); + m_gestureToRecognizer.remove(g); } } foreach (QGestureRecognizer *recognizer, list) { QList obsoleteGestures; - QMap::Iterator iter = objectGestures.begin(); - while (iter != objectGestures.end()) { + QMap::Iterator iter = m_objectGestures.begin(); + while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type) obsoleteGestures << iter.value(); @@ -131,12 +131,12 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType type) { - QMap::Iterator iter = objectGestures.begin(); - while (iter != objectGestures.end()) { + QMap::Iterator iter = m_objectGestures.begin(); + while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type && target == objectGesture.object.data()) { delete iter.value(); - iter = objectGestures.erase(iter); + iter = m_objectGestures.erase(iter); } else { ++iter; } @@ -159,9 +159,9 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) } QGesture *state = - objectGestures.value(QGestureManager::ObjectGesture(object, type)); + m_objectGestures.value(QGestureManager::ObjectGesture(object, type)); if (!state) { - QGestureRecognizer *recognizer = recognizers.value(type); + QGestureRecognizer *recognizer = m_recognizers.value(type); if (recognizer) { state = recognizer->createGesture(object); if (!state) @@ -175,9 +175,9 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) state->setObjectName(QString::number((int)type)); #endif } - objectGestures.insert(QGestureManager::ObjectGesture(object, type), state); - gestureToRecognizer[state] = recognizer; - gestureOwners[state] = object; + m_objectGestures.insert(QGestureManager::ObjectGesture(object, type), state); + m_gestureToRecognizer[state] = recognizer; + m_gestureOwners[state] = object; } } return state; @@ -203,8 +203,8 @@ bool QGestureManager::filterEventThroughContexts(const QMap::const_iterator - rit = recognizers.lowerBound(gestureType), - re = recognizers.upperBound(gestureType); + rit = m_recognizers.lowerBound(gestureType), + re = m_recognizers.upperBound(gestureType); for (; rit != re; ++rit) { QGestureRecognizer *recognizer = rit.value(); QObject *target = cit.key(); @@ -239,20 +239,20 @@ bool QGestureManager::filterEventThroughContexts(const QMap startedGestures = triggeredGestures - activeGestures; - triggeredGestures &= activeGestures; + QSet startedGestures = triggeredGestures - m_activeGestures; + triggeredGestures &= m_activeGestures; // check if a running gesture switched back to maybe state - QSet activeToMaybeGestures = activeGestures & newMaybeGestures; + QSet activeToMaybeGestures = m_activeGestures & newMaybeGestures; // check if a running gesture switched back to not gesture state, // i.e. were canceled - QSet activeToCancelGestures = activeGestures & notGestures; + QSet activeToCancelGestures = m_activeGestures & notGestures; canceledGestures += activeToCancelGestures; // start timers for new gestures in maybe state foreach (QGesture *state, newMaybeGestures) { - QBasicTimer &timer = maybeGestures[state]; + QBasicTimer &timer = m_maybeGestures[state]; if (!timer.isActive()) timer.start(3000, this); } @@ -262,10 +262,10 @@ bool QGestureManager::filterEventThroughContexts(const QMap::iterator it = - maybeGestures.find(gesture); - if (it != maybeGestures.end()) { + m_maybeGestures.find(gesture); + if (it != m_maybeGestures.end()) { it.value().stop(); - maybeGestures.erase(it); + m_maybeGestures.erase(it); } } @@ -276,7 +276,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap notStarted = finishedGestures - activeGestures; + QSet notStarted = finishedGestures - m_activeGestures; if (!notStarted.isEmpty()) { // there are some gestures that claim to be finished, but never started. // probably those are "singleshot" gestures so we'll fake the started state. @@ -287,12 +287,12 @@ bool QGestureManager::filterEventThroughContexts(const QMapd_func()->state = Qt::GestureFinished; - if (!activeGestures.isEmpty() || !maybeGestures.isEmpty() || + if (!m_activeGestures.isEmpty() || !m_maybeGestures.isEmpty() || !startedGestures.isEmpty() || !triggeredGestures.isEmpty() || !finishedGestures.isEmpty() || !canceledGestures.isEmpty()) { DEBUG() << "QGestureManager::filterEventThroughContexts:" - << "\n\tactiveGestures:" << activeGestures - << "\n\tmaybeGestures:" << maybeGestures.keys() + << "\n\tactiveGestures:" << m_activeGestures + << "\n\tmaybeGestures:" << m_maybeGestures.keys() << "\n\tstarted:" << startedGestures << "\n\ttriggered:" << triggeredGestures << "\n\tfinished:" << finishedGestures @@ -332,19 +332,19 @@ bool QGestureManager::filterEventThroughContexts(const QMap endedGestures = finishedGestures + canceledGestures + undeliveredGestures; foreach (QGesture *gesture, endedGestures) { - if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) { + if (QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0)) { gesture->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(gesture); } else { cleanupGesturesForRemovedRecognizer(gesture); } - gestureTargets.remove(gesture); + m_gestureTargets.remove(gesture); } return ret; } @@ -353,7 +353,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap cancelledGestures; - QSet::Iterator iter = activeGestures.begin(); - while (iter != activeGestures.end()) { - QWidget *widget = gestureTargets.value(*iter); + QSet::Iterator iter = m_activeGestures.begin(); + while (iter != m_activeGestures.end()) { + QWidget *widget = m_gestureTargets.value(*iter); // note that we don't touch the gestures for our originatingWidget if (widget != originatingWidget && originatingWidget->isAncestorOf(widget)) { DEBUG() << " found a gesture to cancel" << (*iter); (*iter)->d_func()->state = Qt::GestureCanceled; cancelledGestures << *iter; - iter = activeGestures.erase(iter); + iter = m_activeGestures.erase(iter); } else { ++iter; } @@ -385,7 +385,7 @@ void QGestureManager::cancelGesturesForChildren(QGesture *original) iter = almostCanceledGestures.begin(); // sort per target widget while (iter != almostCanceledGestures.end()) { - QWidget *widget = gestureTargets.value(*iter); + QWidget *widget = m_gestureTargets.value(*iter); if (target == 0) target = widget; if (target == widget) { @@ -402,7 +402,7 @@ void QGestureManager::cancelGesturesForChildren(QGesture *original) } for (iter = cancelledGestures.begin(); iter != cancelledGestures.end(); ++iter) { - QGestureRecognizer *recognizer = gestureToRecognizer.value(*iter, 0); + QGestureRecognizer *recognizer = m_gestureToRecognizer.value(*iter, 0); if (recognizer) { (*iter)->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(*iter); @@ -507,7 +507,7 @@ void QGestureManager::getGestureTargets(const QSet &gestures, // sort gestures by types foreach (QGesture *gesture, gestures) { - QWidget *receiver = gestureTargets.value(gesture, 0); + QWidget *receiver = m_gestureTargets.value(gesture, 0); Q_ASSERT(receiver); gestureByTypes[gesture->gestureType()].insert(receiver, gesture); } @@ -556,7 +556,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, for (QSet::const_iterator it = gestures.begin(), e = gestures.end(); it != e; ++it) { QGesture *gesture = *it; - QWidget *target = gestureTargets.value(gesture, 0); + QWidget *target = m_gestureTargets.value(gesture, 0); if (!target) { // the gesture has just started and doesn't have a target yet. Q_ASSERT(gesture->state() == Qt::GestureStarted); @@ -568,12 +568,12 @@ void QGestureManager::deliverEvents(const QSet &gestures, } } else { // or use the context of the gesture - QObject *context = gestureOwners.value(gesture, 0); + QObject *context = m_gestureOwners.value(gesture, 0); if (context->isWidgetType()) target = static_cast(context); } if (target) - gestureTargets.insert(gesture, target); + m_gestureTargets.insert(gesture, target); } Qt::GestureType gestureType = gesture->gestureType(); @@ -625,7 +625,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, QList &gestures = normalStartedGestures[w]; gestures.append(gesture); // override the target - gestureTargets[gesture] = w; + m_gestureTargets[gesture] = w; } else { DEBUG() << "override event: gesture wasn't accepted. putting back:" << gesture; QList &gestures = normalStartedGestures[receiver]; @@ -648,18 +648,18 @@ void QGestureManager::deliverEvents(const QSet &gestures, void QGestureManager::timerEvent(QTimerEvent *event) { - QMap::iterator it = maybeGestures.begin(), - e = maybeGestures.end(); + QMap::iterator it = m_maybeGestures.begin(), + e = m_maybeGestures.end(); for (; it != e; ) { QBasicTimer &timer = it.value(); Q_ASSERT(timer.isActive()); if (timer.timerId() == event->timerId()) { timer.stop(); QGesture *gesture = it.key(); - it = maybeGestures.erase(it); + it = m_maybeGestures.erase(it); DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:" << gesture; - QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0); + QGestureRecognizer *recognizer = m_gestureToRecognizer.value(gesture, 0); if (recognizer) { gesture->setGestureCancelPolicy(QGesture::CancelNone); recognizer->reset(gesture); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index e6a1d50..5a2816c 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -87,10 +87,10 @@ protected: QEvent *event); private: - QMultiMap recognizers; + QMultiMap m_recognizers; - QSet activeGestures; - QMap maybeGestures; + QSet m_activeGestures; + QMap m_maybeGestures; enum State { Gesture, @@ -116,14 +116,13 @@ private: } }; - // TODO rename all member vars to be m_ - QMap objectGestures; // TODO rename widgetGestures - QMap gestureToRecognizer; - QHash gestureOwners; + QMap m_objectGestures; + QMap m_gestureToRecognizer; + QHash m_gestureOwners; - QHash gestureTargets; + QHash m_gestureTargets; - int lastCustomGestureId; + int m_lastCustomGestureId; QHash > m_obsoleteGestures; QMap m_deletedRecognizers; -- cgit v0.12 From 0dc77406ae05c6ad27406e91b230b177b97fbc7c Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 28 Oct 2009 12:56:59 +0100 Subject: Make the un/registerGestureRecognizer methods static As QApplication is a singleton this makes usage of these easier and also in line with many other methods on the class. --- src/gui/kernel/qapplication.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication.h b/src/gui/kernel/qapplication.h index 5a8e325..5877ba4 100644 --- a/src/gui/kernel/qapplication.h +++ b/src/gui/kernel/qapplication.h @@ -288,8 +288,8 @@ public: static Qt::NavigationMode navigationMode(); #endif - Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer); - void unregisterGestureRecognizer(Qt::GestureType type); + static Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer); + static void unregisterGestureRecognizer(Qt::GestureType type); Q_SIGNALS: void lastWindowClosed(); -- cgit v0.12 From 603d3fb41601e9c69e0f2f3afe4b3717b33f75e4 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 28 Oct 2009 12:59:51 +0100 Subject: Mark the QGestureEvent::setWidget as internal The widget() getter is still publicly documented, follow the lead of other events to make the setter internal. --- src/gui/kernel/qevent.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ea05869..ab43e79 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4398,6 +4398,8 @@ bool QGestureEvent::isAccepted(Qt::GestureType gestureType) const } /*! + \internal + Sets the widget for this event. */ void QGestureEvent::setWidget(QWidget *widget) -- cgit v0.12 From 244d8993c4aac6746306e58b1b766f804e2566f4 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 28 Oct 2009 13:36:43 +0100 Subject: Follow refactor; use QApplication:: instead of qApp-> Our tests now call the recently converted registerRecognizer using a proper static method. --- tests/auto/gestures/tst_gestures.cpp | 46 ++++++++++++++--------------- tests/manual/gestures/graphicsview/main.cpp | 4 +-- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 39cdf63..02c8232 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -344,14 +344,14 @@ tst_Gestures::~tst_Gestures() void tst_Gestures::initTestCase() { - CustomGesture::GestureType = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + CustomGesture::GestureType = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); QVERIFY(CustomGesture::GestureType != Qt::GestureType(0)); QVERIFY(CustomGesture::GestureType != Qt::CustomGesture); } void tst_Gestures::cleanupTestCase() { - qApp->unregisterGestureRecognizer(CustomGesture::GestureType); + QApplication::unregisterGestureRecognizer(CustomGesture::GestureType); } void tst_Gestures::init() @@ -558,7 +558,7 @@ void tst_Gestures::conflictingGestures() parent.reset(); child->reset(); - Qt::GestureType ContinuousGesture = qApp->registerGestureRecognizer(new CustomContinuousGestureRecognizer); + Qt::GestureType ContinuousGesture = QApplication::registerGestureRecognizer(new CustomContinuousGestureRecognizer); static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; child->grabGesture(ContinuousGesture); // child accepts override. And it also receives another custom gesture. @@ -572,7 +572,7 @@ void tst_Gestures::conflictingGestures() QCOMPARE(parent.gestureOverrideEventsReceived, 0); QCOMPARE(parent.gestureEventsReceived, 0); - qApp->unregisterGestureRecognizer(ContinuousGesture); + QApplication::unregisterGestureRecognizer(ContinuousGesture); } void tst_Gestures::finishedWithoutStarted() @@ -981,7 +981,7 @@ void tst_Gestures::twoGesturesOnDifferentLevel() GestureWidget *child = new GestureWidget("child"); l->addWidget(child); - Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); child->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); @@ -1009,7 +1009,7 @@ void tst_Gestures::twoGesturesOnDifferentLevel() for(int i = 0; i < child->events.all.size(); ++i) QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType); - qApp->unregisterGestureRecognizer(SecondGesture); + QApplication::unregisterGestureRecognizer(SecondGesture); } void tst_Gestures::multipleGesturesInTree() @@ -1021,8 +1021,8 @@ void tst_Gestures::multipleGesturesInTree() GestureWidget *D = new GestureWidget("D", C); Qt::GestureType FirstGesture = CustomGesture::GestureType; - Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType ThirdGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1 3] A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | @@ -1079,8 +1079,8 @@ void tst_Gestures::multipleGesturesInTree() QCOMPARE(A->events.all.count(SecondGesture), 0); QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount); - qApp->unregisterGestureRecognizer(SecondGesture); - qApp->unregisterGestureRecognizer(ThirdGesture); + QApplication::unregisterGestureRecognizer(SecondGesture); + QApplication::unregisterGestureRecognizer(ThirdGesture); } void tst_Gestures::multipleGesturesInComplexTree() @@ -1092,12 +1092,12 @@ void tst_Gestures::multipleGesturesInComplexTree() GestureWidget *D = new GestureWidget("D", C); Qt::GestureType FirstGesture = CustomGesture::GestureType; - Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType FourthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType FifthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType SixthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); - Qt::GestureType SeventhGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SecondGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType ThirdGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType FourthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType FifthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SixthGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SeventhGesture = QApplication::registerGestureRecognizer(new CustomGestureRecognizer); A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1,3,4] A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | @@ -1175,12 +1175,12 @@ void tst_Gestures::multipleGesturesInComplexTree() QCOMPARE(A->events.all.count(SixthGesture), 0); QCOMPARE(A->events.all.count(SeventhGesture), 0); - qApp->unregisterGestureRecognizer(SecondGesture); - qApp->unregisterGestureRecognizer(ThirdGesture); - qApp->unregisterGestureRecognizer(FourthGesture); - qApp->unregisterGestureRecognizer(FifthGesture); - qApp->unregisterGestureRecognizer(SixthGesture); - qApp->unregisterGestureRecognizer(SeventhGesture); + QApplication::unregisterGestureRecognizer(SecondGesture); + QApplication::unregisterGestureRecognizer(ThirdGesture); + QApplication::unregisterGestureRecognizer(FourthGesture); + QApplication::unregisterGestureRecognizer(FifthGesture); + QApplication::unregisterGestureRecognizer(SixthGesture); + QApplication::unregisterGestureRecognizer(SeventhGesture); } void tst_Gestures::testMapToScene() @@ -1329,7 +1329,7 @@ void tst_Gestures::autoCancelGestures() GestureWidget *child = new GestureWidget("child", &parent); child->setGeometry(10, 10, 100, 80); - Qt::GestureType type = qApp->registerGestureRecognizer(new MockRecognizer()); + Qt::GestureType type = QApplication::registerGestureRecognizer(new MockRecognizer()); parent.grabGesture(type, Qt::WidgetWithChildrenGesture); child->grabGesture(type, Qt::WidgetWithChildrenGesture); diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp index e9065eb..de92afe 100644 --- a/tests/manual/gestures/graphicsview/main.cpp +++ b/tests/manual/gestures/graphicsview/main.cpp @@ -152,8 +152,8 @@ private: MainWindow::MainWindow() { - (void)qApp->registerGestureRecognizer(new MousePanGestureRecognizer); - ThreeFingerSlideGesture::Type = qApp->registerGestureRecognizer(new ThreeFingerSlideGestureRecognizer); + (void)QApplication::registerGestureRecognizer(new MousePanGestureRecognizer); + ThreeFingerSlideGesture::Type = QApplication::registerGestureRecognizer(new ThreeFingerSlideGestureRecognizer); tabWidget = new QTabWidget; -- cgit v0.12 From 4f4c4fda9925f585128175796d04926863943dad Mon Sep 17 00:00:00 2001 From: dka Date: Mon, 19 Oct 2009 12:21:02 +0300 Subject: QLocale: AM/PM symbol support for symbian platform Reviewed-by: Denis Dzyubenko --- src/corelib/tools/qlocale_symbian.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp index 1660e95..1273d06 100644 --- a/src/corelib/tools/qlocale_symbian.cpp +++ b/src/corelib/tools/qlocale_symbian.cpp @@ -873,9 +873,11 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const } case NegativeSign: case PositiveSign: + break; case AMText: + return qt_TDes2QString(TAmPmName(TAmPm(EAm))); case PMText: - break; + return qt_TDes2QString(TAmPmName(TAmPm(EPm))); default: break; } -- cgit v0.12 From 7a215265994bca72bbc7fcc198048c2f6bb7527a Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 12:05:26 +0100 Subject: Removed obsolete private field from the QGesture and fixed the doc. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesture.cpp | 11 +++++------ src/gui/kernel/qgesture_p.h | 5 +---- src/gui/kernel/qgesturerecognizer.cpp | 2 +- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index c302c51..b72fae0 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -69,10 +69,9 @@ QT_BEGIN_NAMESPACE \section1 Lifecycle of a Gesture Object - A QGesture instance is created when the application calls QWidget::grabGesture() - or QGraphicsObject::grabGesture() to configure a widget or graphics object (the - target object) for gesture input. One gesture object is created for each target - object. + A QGesture instance is implicitely created when needed and is owned by Qt, + so application developer should never destroy them or store a pointer to a + QGesture object. The registered gesture recognizer monitors the input events for the target object via its \l{QGestureRecognizer::}{filterEvent()} function, updating the @@ -133,8 +132,8 @@ QGesture::~QGesture() QWidget::mapFromGlobal() or QGestureEvent::mapToScene() to get a local hot-spot. - If the hot-spot is not set, the targetObject is used as the receiver of the - gesture event. + The hot-spot should be set by the gesture recognizer to allow gesture event + delivery to a QGraphicsObject. */ /*! diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index d2ef8a7..34fbb26 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -68,9 +68,7 @@ class QGesturePrivate : public QObjectPrivate public: QGesturePrivate() : gestureType(Qt::CustomGesture), state(Qt::NoGesture), - targetObject(0), - isHotSpotSet(false), - gestureCancelPolicy(0) + isHotSpotSet(false), gestureCancelPolicy(0) { } @@ -78,7 +76,6 @@ public: Qt::GestureType gestureType; Qt::GestureState state; QPointF hotSpot; - QObject *targetObject; uint isHotSpotSet : 1; uint gestureCancelPolicy : 2; }; diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp index c2b26f0..2673be3 100644 --- a/src/gui/kernel/qgesturerecognizer.cpp +++ b/src/gui/kernel/qgesturerecognizer.cpp @@ -178,7 +178,7 @@ void QGestureRecognizer::reset(QGesture *gesture) QGesturePrivate *d = gesture->d_func(); d->state = Qt::NoGesture; d->hotSpot = QPointF(); - d->targetObject = 0; + d->isHotSpotSet = false; } } -- cgit v0.12 From a2b12363c96d4307444552eefc21eebf430dba5d Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 13:05:20 +0100 Subject: Fixed the scrollarea gesture manual test. Reviewed-by: trustme --- tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp | 2 +- tests/manual/gestures/scrollarea/mousepangesturerecognizer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp index 5f94dbc..63d3e76 100644 --- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp @@ -49,7 +49,7 @@ MousePanGestureRecognizer::MousePanGestureRecognizer() { } -QGesture* MousePanGestureRecognizer::createGesture(QObject *) const +QGesture* MousePanGestureRecognizer::createGesture(QObject *) { return new QPanGesture; } diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h index c92d477..b062fd0 100644 --- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h +++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.h @@ -49,7 +49,7 @@ class MousePanGestureRecognizer : public QGestureRecognizer public: MousePanGestureRecognizer(); - QGesture* createGesture(QObject *target) const; + QGesture* createGesture(QObject *target); QGestureRecognizer::Result filterEvent(QGesture *state, QObject *watched, QEvent *event); void reset(QGesture *state); }; -- cgit v0.12 From 3ce8fb5e754014ed29cabf9e33b71dabecb02e46 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 13:06:03 +0100 Subject: Fixed the gesture event filtering through multiple gesture recognizers. When there are several gesture recognizers registered for the same gesture type, we need to know which recognizer we need to get a state object for since those QGesture objects are tied to the recognizer that created them. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 49 ++++++++++++++++++++------------------ src/gui/kernel/qgesturemanager_p.h | 5 ++-- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index a90c299..04dcfe3 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -118,7 +118,7 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) foreach (QGestureRecognizer *recognizer, list) { QList obsoleteGestures; - QMap::Iterator iter = m_objectGestures.begin(); + QMap >::Iterator iter = m_objectGestures.begin(); while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type) @@ -131,11 +131,11 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType type) { - QMap::Iterator iter = m_objectGestures.begin(); + QMap >::Iterator iter = m_objectGestures.begin(); while (iter != m_objectGestures.end()) { ObjectGesture objectGesture = iter.key(); if (objectGesture.gesture == type && target == objectGesture.object.data()) { - delete iter.value(); + qDeleteAll(iter.value()); iter = m_objectGestures.erase(iter); } else { ++iter; @@ -144,7 +144,7 @@ void QGestureManager::cleanupCachedGestures(QObject *target, Qt::GestureType typ } // get or create a QGesture object that will represent the state for a given object, used by the recognizer -QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) +QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recognizer, Qt::GestureType type) { // if the widget is being deleted we should be carefull and not to // create a new state, as it will create QWeakPointer which doesnt work @@ -158,28 +158,31 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) Q_ASSERT(qobject_cast(object)); } - QGesture *state = + QList states = m_objectGestures.value(QGestureManager::ObjectGesture(object, type)); - if (!state) { - QGestureRecognizer *recognizer = m_recognizers.value(type); - if (recognizer) { - state = recognizer->createGesture(object); - if (!state) - return 0; - state->setParent(this); - if (state->gestureType() == Qt::CustomGesture) { - // if the recognizer didn't fill in the gesture type, then this - // is a custom gesture with autogenerated it and we fill it. - state->d_func()->gestureType = type; + // check if the QGesture for this recognizer has already been created + foreach (QGesture *state, states) { + if (m_gestureToRecognizer.value(state) == recognizer) + return state; + } + + Q_ASSERT(recognizer); + QGesture *state = recognizer->createGesture(object); + if (!state) + return 0; + state->setParent(this); + if (state->gestureType() == Qt::CustomGesture) { + // if the recognizer didn't fill in the gesture type, then this + // is a custom gesture with autogenerated id and we fill it. + state->d_func()->gestureType = type; #if defined(GESTURE_DEBUG) - state->setObjectName(QString::number((int)type)); + state->setObjectName(QString::number((int)type)); #endif - } - m_objectGestures.insert(QGestureManager::ObjectGesture(object, type), state); - m_gestureToRecognizer[state] = recognizer; - m_gestureOwners[state] = object; - } } + m_objectGestures[QGestureManager::ObjectGesture(object, type)].append(state); + m_gestureToRecognizer[state] = recognizer; + m_gestureOwners[state] = object; + return state; } @@ -208,7 +211,7 @@ bool QGestureManager::filterEventThroughContexts(const QMapfilterEvent(state, target, event); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 5a2816c..f128273 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -116,7 +116,7 @@ private: } }; - QMap m_objectGestures; + QMap > m_objectGestures; QMap m_gestureToRecognizer; QHash m_gestureOwners; @@ -128,7 +128,8 @@ private: QMap m_deletedRecognizers; void cleanupGesturesForRemovedRecognizer(QGesture *gesture); - QGesture *getState(QObject *widget, Qt::GestureType gesture); + QGesture *getState(QObject *widget, QGestureRecognizer *recognizer, + Qt::GestureType gesture); void deliverEvents(const QSet &gestures, QSet *undeliveredGestures); void getGestureTargets(const QSet &gestures, -- cgit v0.12 From 96b8e9f824daaf88cb8c153caa774a92b0261580 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 13:11:49 +0100 Subject: Delete all gesture objects and recognizers when gesture manager is deleted. When application closes and we haven't deleted the unregistered gestures and gesture recognizer, we should delete them. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 04dcfe3..3eb15cf 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -83,6 +83,11 @@ QGestureManager::QGestureManager(QObject *parent) QGestureManager::~QGestureManager() { qDeleteAll(m_recognizers.values()); + foreach (QGestureRecognizer *recognizer, m_obsoleteGestures.keys()) { + qDeleteAll(m_obsoleteGestures.value(recognizer)); + delete recognizer; + } + m_obsoleteGestures.clear(); } Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *recognizer) -- cgit v0.12 From 6efb1b7df725c74f265d0f315993542b0bd19b97 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 14:07:53 +0100 Subject: Tiny doc change by David Boddie. Reviewed-by: David Boddie --- src/gui/kernel/qgesture.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index b72fae0..850f22c 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -69,9 +69,9 @@ QT_BEGIN_NAMESPACE \section1 Lifecycle of a Gesture Object - A QGesture instance is implicitely created when needed and is owned by Qt, - so application developer should never destroy them or store a pointer to a - QGesture object. + A QGesture instance is implicitly created when needed and is owned by Qt. + Developers should never destroy them or store them for later use as Qt may + destroy particular instances of them and create new ones to replace them. The registered gesture recognizer monitors the input events for the target object via its \l{QGestureRecognizer::}{filterEvent()} function, updating the -- cgit v0.12 From 4b3ef85b499d9ec508acdf83d250e022161defbb Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 28 Oct 2009 14:30:11 +0100 Subject: Replaced QMap with QHash where possible in the gesture manager implementation. There is no reason to use QMap when the key is a pointer. Reviewed-by: Thomas Zander --- src/gui/kernel/qgesturemanager.cpp | 18 +++++++++--------- src/gui/kernel/qgesturemanager_p.h | 8 ++++---- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 3eb15cf..f1abc89 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -113,7 +113,7 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType type) { QList list = m_recognizers.values(type); m_recognizers.remove(type); - foreach (QGesture* g, m_gestureToRecognizer.keys()) { + foreach (QGesture *g, m_gestureToRecognizer.keys()) { QGestureRecognizer *recognizer = m_gestureToRecognizer.value(g); if (list.contains(recognizer)) { m_deletedRecognizers.insert(g, recognizer); @@ -191,7 +191,7 @@ QGesture *QGestureManager::getState(QObject *object, QGestureRecognizer *recogni return state; } -bool QGestureManager::filterEventThroughContexts(const QMap &contexts, QEvent *event) { @@ -207,7 +207,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap::const_iterator ContextIterator; + typedef QHash::const_iterator ContextIterator; for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) { Qt::GestureType gestureType = cit.value(); QMap::const_iterator @@ -269,7 +269,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap::iterator it = + QHash::iterator it = m_maybeGestures.find(gesture); if (it != m_maybeGestures.end()) { it.value().stop(); @@ -437,7 +437,7 @@ void QGestureManager::cleanupGesturesForRemovedRecognizer(QGesture *gesture) bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) { QSet types; - QMap contexts; + QMultiHash contexts; QWidget *w = receiver; typedef QMap::const_iterator ContextIterator; if (!w->d_func()->gestureContext.isEmpty()) { @@ -470,7 +470,7 @@ bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) { QSet types; - QMap contexts; + QMultiHash contexts; QGraphicsObject *item = receiver; if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { typedef QMap::const_iterator ContextIterator; @@ -501,7 +501,7 @@ bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) bool QGestureManager::filterEvent(QGesture *state, QEvent *event) { - QMap contexts; + QMultiHash contexts; contexts.insert(state, state->gestureType()); return filterEventThroughContexts(contexts, event); } @@ -656,8 +656,8 @@ void QGestureManager::deliverEvents(const QSet &gestures, void QGestureManager::timerEvent(QTimerEvent *event) { - QMap::iterator it = m_maybeGestures.begin(), - e = m_maybeGestures.end(); + QHash::iterator it = m_maybeGestures.begin(), + e = m_maybeGestures.end(); for (; it != e; ) { QBasicTimer &timer = it.value(); Q_ASSERT(timer.isActive()); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index f128273..4958cdb 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -83,14 +83,14 @@ public: protected: void timerEvent(QTimerEvent *event); - bool filterEventThroughContexts(const QMap &contexts, + bool filterEventThroughContexts(const QMultiHash &contexts, QEvent *event); private: QMultiMap m_recognizers; QSet m_activeGestures; - QMap m_maybeGestures; + QHash m_maybeGestures; enum State { Gesture, @@ -117,7 +117,7 @@ private: }; QMap > m_objectGestures; - QMap m_gestureToRecognizer; + QHash m_gestureToRecognizer; QHash m_gestureOwners; QHash m_gestureTargets; @@ -125,7 +125,7 @@ private: int m_lastCustomGestureId; QHash > m_obsoleteGestures; - QMap m_deletedRecognizers; + QHash m_deletedRecognizers; void cleanupGesturesForRemovedRecognizer(QGesture *gesture); QGesture *getState(QObject *widget, QGestureRecognizer *recognizer, -- cgit v0.12 From e4606e2d6491bd7020e8bfb12665c3addc24b7e3 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Wed, 28 Oct 2009 14:47:28 +0100 Subject: Wrong font used when moving a tab in document mode. Dragging is handled by a seperate window in document mode. The currently selected tabbar item is drawn to a pixmap for this purpose. That paintdevice was not initialized correctly. (e.g. font) Reviewed-by: Trond --- src/gui/widgets/qtabbar.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qtabbar.cpp b/src/gui/widgets/qtabbar.cpp index 4dffbdc..3935c55 100644 --- a/src/gui/widgets/qtabbar.cpp +++ b/src/gui/widgets/qtabbar.cpp @@ -1812,6 +1812,7 @@ void QTabBarPrivate::setupMovableTab() QPixmap grabImage(grabRect.size()); grabImage.fill(Qt::transparent); QStylePainter p(&grabImage, q); + p.initFrom(q); QStyleOptionTabV3 tab; q->initStyleOption(&tab, pressedIndex); -- cgit v0.12 From dbaa856d4d20840394baf8f4c9abf78051a6693a Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 7 Oct 2009 16:15:43 +0200 Subject: Fix split tool button drawing on Vista when not in a tool bar When a tool button is not in a tool bar on XP and Vista it will get a slightly different appearance from normal tool buttons. I resolved this by drawing a normal tool button with a divider line on top if the autoraise property is not set on the button. (which is by default enabled only for buttons in a tool bar). Task-number: QTBUG-5061 Reviewed-by: prasanth --- src/gui/styles/qwindowsxpstyle.cpp | 46 +++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index 2f00f07..b5dc647 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -2841,8 +2841,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo State bflags = toolbutton->state & ~State_Sunken; State mflags = bflags; - - if (bflags & State_AutoRaise) { + bool autoRaise = flags & State_AutoRaise; + if (autoRaise) { if (!(bflags & State_MouseOver) || !(bflags & State_Enabled)) { bflags &= ~State_Raised; } @@ -2861,8 +2861,8 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo QStyleOption tool(0); tool.palette = toolbutton->palette; if (toolbutton->subControls & SC_ToolButton) { - if (flags & (State_Sunken | State_On | State_Raised) || !(flags & State_AutoRaise)) { - if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) { + if (flags & (State_Sunken | State_On | State_Raised) || !autoRaise) { + if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup && autoRaise) { XPThemeData theme(widget, p, QLatin1String("TOOLBAR")); theme.partId = TP_SPLITBUTTON; theme.rect = button; @@ -2881,13 +2881,12 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo theme.stateId = stateId; d->drawBackground(theme); } else { - tool.rect = button; + tool.rect = option->rect; tool.state = bflags; - if (widget && !qobject_cast(widget->parentWidget()) - && !(bflags & State_AutoRaise)) - proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget); - else + if (autoRaise) // for tool bars proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); + else + proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, widget); } } } @@ -2904,13 +2903,40 @@ void QWindowsXPStyle::drawComplexControl(ComplexControl cc, const QStyleOptionCo QStyleOptionToolButton label = *toolbutton; label.state = bflags; int fw = 2; + if (!autoRaise) + label.state &= ~State_Sunken; label.rect = button.adjusted(fw, fw, -fw, -fw); proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); if (toolbutton->subControls & SC_ToolButtonMenu) { tool.rect = menuarea; tool.state = mflags; - proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); + if (autoRaise) { + proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); + } else { + tool.state = mflags; + menuarea.adjust(-2, 0, 0, 0); + // Draw menu button + if ((bflags & State_Sunken) != (mflags & State_Sunken)){ + p->save(); + p->setClipRect(menuarea); + tool.rect = option->rect; + proxy()->drawPrimitive(PE_PanelButtonBevel, &tool, p, 0); + p->restore(); + } + // Draw arrow + p->save(); + p->setPen(option->palette.dark()); + p->drawLine(menuarea.left(), menuarea.top() + 3, + menuarea.left(), menuarea.bottom() - 3); + p->setPen(option->palette.light()); + p->drawLine(menuarea.left() - 1, menuarea.top() + 3, + menuarea.left() - 1, menuarea.bottom() - 3); + + tool.rect = menuarea.adjusted(2, 3, -2, -1); + proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); + p->restore(); + } } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); QRect ir = toolbutton->rect; -- cgit v0.12 From 5eb2f63acda335aaf06e302ee4564259bc60222a Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Wed, 7 Oct 2009 18:29:46 +0200 Subject: Fix a combobox autotest on Vista The subcontrol rect offset was correctly reporting not to work on Vista style. The problem was that we were getting the size of the arrow by subtracting the xoffset. But this would mean that the Reviewed-by: ogoffart --- src/gui/styles/qwindowsvistastyle.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index 6cb8b40..974bce1 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -2217,14 +2217,15 @@ QRect QWindowsVistaStyle::subControlRect(ComplexControl control, const QStyleOpt int xpos = x; int margin = cb->frame ? 3 : 0; int bmarg = cb->frame ? 2 : 0; - xpos += wi - bmarg - 16; + int arrowButtonWidth = bmarg + 16; + xpos += wi - arrowButtonWidth; switch (subControl) { case SC_ComboBoxFrame: rect = cb->rect; break; case SC_ComboBoxArrow: - rect.setRect(xpos, y , wi - xpos, he); + rect.setRect(xpos, y , arrowButtonWidth, he); break; case SC_ComboBoxEditField: rect.setRect(x + margin, y + margin, wi - 2 * margin - 16, he - 2 * margin); -- cgit v0.12 From b1f9882fa52745c922eb0109daa011908214dcf7 Mon Sep 17 00:00:00 2001 From: Dean Dettman Date: Thu, 29 Oct 2009 11:29:08 +0100 Subject: Ensure that button returns 0 for mouse move events This was a platform regression for the cocoa platform Reviewed-by: Prasanth --- src/gui/kernel/qcocoaview_mac.mm | 7 ++- tests/auto/qmouseevent/tst_qmouseevent.cpp | 75 ++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index ecc6bc9..a16d1f8 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -745,7 +745,7 @@ extern "C" { { qMacDnDParams()->view = self; qMacDnDParams()->theEvent = theEvent; - bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::LeftButton); + bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton); if (!mouseOK) [super mouseDragged:theEvent]; @@ -755,7 +755,7 @@ extern "C" { { qMacDnDParams()->view = self; qMacDnDParams()->theEvent = theEvent; - bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::RightButton); + bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton); if (!mouseOK) [super rightMouseDragged:theEvent]; @@ -765,8 +765,7 @@ extern "C" { { qMacDnDParams()->view = self; qMacDnDParams()->theEvent = theEvent; - Qt::MouseButton mouseButton = cocoaButton2QtButton([theEvent buttonNumber]); - bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, mouseButton); + bool mouseOK = qt_mac_handleMouseEvent(self, theEvent, QEvent::MouseMove, Qt::NoButton); if (!mouseOK) [super otherMouseDragged:theEvent]; diff --git a/tests/auto/qmouseevent/tst_qmouseevent.cpp b/tests/auto/qmouseevent/tst_qmouseevent.cpp index b961851..d700181 100644 --- a/tests/auto/qmouseevent/tst_qmouseevent.cpp +++ b/tests/auto/qmouseevent/tst_qmouseevent.cpp @@ -62,6 +62,7 @@ public: } bool mousePressEventRecieved; bool mouseReleaseEventRecieved; + bool mouseMoveEventRecieved; #ifdef QT3_SUPPORT int mousePressStateBefore; int mousePressStateAfter; @@ -76,6 +77,13 @@ public: int mouseReleaseButton; int mouseReleaseButtons; int mouseReleaseModifiers; +#ifdef QT3_SUPPORT + int mouseMoveStateBefore; + int mouseMoveStateAfter; +#endif + int mouseMoveButton; + int mouseMoveButtons; + int mouseMoveModifiers; protected: void mousePressEvent(QMouseEvent *e) { @@ -103,6 +111,19 @@ protected: mouseReleaseEventRecieved = TRUE; e->accept(); } + void mouseMoveEvent(QMouseEvent *e) + { + QWidget::mouseMoveEvent(e); +#ifdef QT3_SUPPORT + mouseMoveStateBefore = e->state(); + mouseMoveStateAfter = e->stateAfter(); +#endif + mouseMoveButton = e->button(); + mouseMoveButtons = e->buttons(); + mouseMoveModifiers = e->modifiers(); + mouseMoveEventRecieved = TRUE; + e->accept(); + } }; class tst_QMouseEvent : public QObject @@ -124,6 +145,8 @@ private slots: void checkMousePressEvent(); void checkMouseReleaseEvent_data(); void checkMouseReleaseEvent(); + void checkMouseMoveEvent_data(); + void checkMouseMoveEvent(); void qt3supportConstructors(); @@ -157,11 +180,14 @@ void tst_QMouseEvent::init() { testMouseWidget->mousePressEventRecieved = FALSE; testMouseWidget->mouseReleaseEventRecieved = FALSE; + testMouseWidget->mouseMoveEventRecieved = FALSE; #ifdef QT3_SUPPORT testMouseWidget->mousePressStateBefore = 0; testMouseWidget->mousePressStateAfter = 0; testMouseWidget->mouseReleaseStateBefore = 0; testMouseWidget->mouseReleaseStateAfter = 0; + testMouseWidget->mouseMoveStateBefore = 0; + testMouseWidget->mouseMoveStateAfter = 0; #endif testMouseWidget->mousePressButton = 0; testMouseWidget->mousePressButtons = 0; @@ -169,6 +195,9 @@ void tst_QMouseEvent::init() testMouseWidget->mouseReleaseButton = 0; testMouseWidget->mouseReleaseButtons = 0; testMouseWidget->mouseReleaseModifiers = 0; + testMouseWidget->mouseMoveButton = 0; + testMouseWidget->mouseMoveButtons = 0; + testMouseWidget->mouseMoveModifiers = 0; } void tst_QMouseEvent::cleanup() @@ -265,6 +294,52 @@ void tst_QMouseEvent::checkMouseReleaseEvent() #endif } +void tst_QMouseEvent::checkMouseMoveEvent_data() +{ + QTest::addColumn("buttonMoved"); + QTest::addColumn("keyPressed"); + + QTest::newRow("leftButton-nokey") << int(Qt::LeftButton) << int(Qt::NoButton); + QTest::newRow("leftButton-shiftkey") << int(Qt::LeftButton) << int(Qt::ShiftModifier); + QTest::newRow("leftButton-controlkey") << int(Qt::LeftButton) << int(Qt::ControlModifier); + QTest::newRow("leftButton-altkey") << int(Qt::LeftButton) << int(Qt::AltModifier); + QTest::newRow("leftButton-metakey") << int(Qt::LeftButton) << int(Qt::MetaModifier); + QTest::newRow("rightButton-nokey") << int(Qt::RightButton) << int(Qt::NoButton); + QTest::newRow("rightButton-shiftkey") << int(Qt::RightButton) << int(Qt::ShiftModifier); + QTest::newRow("rightButton-controlkey") << int(Qt::RightButton) << int(Qt::ControlModifier); + QTest::newRow("rightButton-altkey") << int(Qt::RightButton) << int(Qt::AltModifier); + QTest::newRow("rightButton-metakey") << int(Qt::RightButton) << int(Qt::MetaModifier); + QTest::newRow("midButton-nokey") << int(Qt::MidButton) << int(Qt::NoButton); + QTest::newRow("midButton-shiftkey") << int(Qt::MidButton) << int(Qt::ShiftModifier); + QTest::newRow("midButton-controlkey") << int(Qt::MidButton) << int(Qt::ControlModifier); + QTest::newRow("midButton-altkey") << int(Qt::MidButton) << int(Qt::AltModifier); + QTest::newRow("midButton-metakey") << int(Qt::MidButton) << int(Qt::MetaModifier); +} + +void tst_QMouseEvent::checkMouseMoveEvent() +{ + QFETCH(int,buttonMoved); + QFETCH(int,keyPressed); + int button = (int)Qt::NoButton; + int buttons = buttonMoved; + int modifiers = keyPressed; + + QTest::mousePress(testMouseWidget, Qt::MouseButton(buttonMoved), Qt::KeyboardModifiers(keyPressed)); + QTest::mouseMove(testMouseWidget, QPoint(10,10)); + QVERIFY(testMouseWidget->mouseMoveEventRecieved); + QCOMPARE(testMouseWidget->mouseMoveButton, button); + QCOMPARE(testMouseWidget->mouseMoveButtons, buttons); + QCOMPARE(testMouseWidget->mouseMoveModifiers, modifiers); +#ifdef QT3_SUPPORT + int stateAfter = buttons|modifiers; + int stateBefore = stateAfter|button; + + QCOMPARE(testMouseWidget->mouseMoveStateBefore, stateBefore); + QCOMPARE(testMouseWidget->mouseMoveStateAfter, stateAfter); +#endif + QTest::mouseRelease(testMouseWidget, Qt::MouseButton(buttonMoved), Qt::KeyboardModifiers(keyPressed)); +} + void tst_QMouseEvent::qt3supportConstructors() { #if !defined(QT3_SUPPORT) -- cgit v0.12 From 9551b8c349ce4e15a57c24a2408ee1b73c2b7510 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 29 Oct 2009 13:46:45 +0100 Subject: Tabs with corner widgets are drawn incorrectly in document mode on Mac. While drawing the tabbar frame, mac style needs the QTabBar pointer to calculate the correct size. Since the QTabWidget also uses the PE_FrameTabBarBase to draw background of the corner widgets, the mac style has to use position passed with the style option. This only works with horizontal tabs. Reviewed-by: Jens Bache-Wiig --- src/gui/styles/qmacstyle_mac.mm | 10 +++++----- src/gui/widgets/qtabwidget.cpp | 4 ++-- tools/assistant/tools/assistant/centralwidget.cpp | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/styles/qmacstyle_mac.mm b/src/gui/styles/qmacstyle_mac.mm index 4dcb469..38c3feb 100644 --- a/src/gui/styles/qmacstyle_mac.mm +++ b/src/gui/styles/qmacstyle_mac.mm @@ -342,12 +342,12 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget borderHighlightTop = QColor(207, 207, 207); } p->setPen(borderHighlightTop); - p->drawLine(0, 0, width, 0); + p->drawLine(tabRect.x(), 0, width, 0); p->setPen(borderTop); - p->drawLine(0, 1, width, 1); + p->drawLine(tabRect.x(), 1, width, 1); // center block - QRect centralRect(0, 2, width, height - 2); + QRect centralRect(tabRect.x(), 2, width, height - 2); if (active) { QColor mainColor = QColor(120, 120, 120); p->fillRect(centralRect, mainColor); @@ -370,9 +370,9 @@ void drawTabBase(QPainter *p, const QStyleOptionTabBarBaseV2 *tbb, const QWidget borderBottom = QColor(127, 127, 127); } p->setPen(borderHighlightBottom); - p->drawLine(0, height - 2, width, height - 2); + p->drawLine(tabRect.x(), height - 2, width, height - 2); p->setPen(borderBottom); - p->drawLine(0, height - 1, width, height - 1); + p->drawLine(tabRect.x(), height - 1, width, height - 1); } /* diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 9aeb033..0c89a72 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -1167,8 +1167,8 @@ void QTabWidget::tabRemoved(int index) void QTabWidget::paintEvent(QPaintEvent *) { Q_D(QTabWidget); - QStylePainter p(this); if (documentMode()) { + QStylePainter p(this, tabBar()); if (QWidget *w = cornerWidget(Qt::TopLeftCorner)) { QStyleOptionTabBarBaseV2 opt; QTabBarPrivate::initStyleBaseOption(&opt, tabBar(), w->size()); @@ -1185,7 +1185,7 @@ void QTabWidget::paintEvent(QPaintEvent *) } return; } - + QStylePainter p(this); QStyleOptionTabWidgetFrame opt; initStyleOption(&opt); opt.rect = d->panelRect; diff --git a/tools/assistant/tools/assistant/centralwidget.cpp b/tools/assistant/tools/assistant/centralwidget.cpp index 04739d4..2722b2f 100644 --- a/tools/assistant/tools/assistant/centralwidget.cpp +++ b/tools/assistant/tools/assistant/centralwidget.cpp @@ -230,6 +230,7 @@ CentralWidget::CentralWidget(QHelpEngine *engine, MainWindow *parent) #endif tabWidget = new QTabWidget(this); + tabWidget->setDocumentMode(true); connect(tabWidget, SIGNAL(currentChanged(int)), this, SLOT(currentPageChanged(int))); -- cgit v0.12 From 8c4edbd04f350294462fd689748de2dd7cc84d47 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 8 Oct 2009 21:10:01 +0200 Subject: Fix tab widget painting in QGtkStyle with reverse This also adds QStyleOptionTabWidgetFrameV2 so that we do not have to do ugly hacks in the style to obtain it. Task-number: QTBUG-5187 Reviewed-by: ogoffart --- src/gui/styles/qgtkstyle.cpp | 43 ++++++-------- src/gui/styles/qstyleoption.cpp | 113 ++++++++++++++++++++++++++++++++++++ src/gui/styles/qstyleoption.h | 20 +++++++ src/gui/styles/qstylesheetstyle.cpp | 2 +- src/gui/styles/qwindowsxpstyle.cpp | 2 +- src/gui/widgets/qtabwidget.cpp | 14 ++++- 6 files changed, 166 insertions(+), 28 deletions(-) diff --git a/src/gui/styles/qgtkstyle.cpp b/src/gui/styles/qgtkstyle.cpp index d315c98..a7c291b 100644 --- a/src/gui/styles/qgtkstyle.cpp +++ b/src/gui/styles/qgtkstyle.cpp @@ -1004,32 +1004,27 @@ void QGtkStyle::drawPrimitive(PrimitiveElement element, gtkPainter.setAlphaSupport(false); GtkShadowType shadow = GTK_SHADOW_OUT; GtkStateType state = GTK_STATE_NORMAL; // Only state supported by gtknotebook - if (const QTabWidget *tabwidget = qobject_cast(widget)) { - // We should introduce QStyleOptionTabWidgetFrameV2 to obtain this information - // No gap if we do not show the actual tabs - QTabBar *tabBar = tabwidget->findChild(); - if (tabwidget->count() > 0 && tabBar->isVisible()) { - QRect tabRect = tabBar->tabRect(tabBar->currentIndex()); - int begin = 0, size = 0; - GtkPositionType frameType = GTK_POS_TOP; - QTabBar::Shape shape = frame->shape; - if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) { - begin = option->direction == Qt::LeftToRight ? - frame->leftCornerWidgetSize.width() + tabRect.left() : - frame->rect.width() - frame->tabBarSize.width() + tabRect.left() - - frame->rightCornerWidgetSize.width(); - size = tabRect.width(); - frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM; - } else { - begin = frame->leftCornerWidgetSize.height() + tabRect.top(); - size = tabRect.height(); - frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT; - } - gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType, - begin, size, style); - break; // done + bool reverse = (option->direction == Qt::RightToLeft); + QGtk::gtk_widget_set_direction(gtkNotebook, reverse ? GTK_TEXT_DIR_RTL : GTK_TEXT_DIR_LTR); + if (const QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast(option)) { + GtkPositionType frameType = GTK_POS_TOP; + QTabBar::Shape shape = frame->shape; + int gapStart = 0; + int gapSize = 0; + if (shape == QTabBar::RoundedNorth || shape == QTabBar::RoundedSouth) { + frameType = (shape == QTabBar::RoundedNorth) ? GTK_POS_TOP : GTK_POS_BOTTOM; + gapStart = tabframe->selectedTabRect.left(); + gapSize = tabframe->selectedTabRect.width(); + } else { + frameType = (shape == QTabBar::RoundedWest) ? GTK_POS_LEFT : GTK_POS_RIGHT; + gapStart = tabframe->selectedTabRect.y(); + gapSize = tabframe->selectedTabRect.height(); } + gtkPainter.paintBoxGap(gtkNotebook, "notebook", option->rect, state, shadow, frameType, + gapStart, gapSize, style); + break; // done } + // Note this is only the fallback option gtkPainter.paintBox(gtkNotebook, "notebook", option->rect, state, shadow, style); } diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index 061afcc..f5a2b94 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -4654,6 +4654,119 @@ QStyleOptionTabWidgetFrame::QStyleOptionTabWidgetFrame(int version) The default value is QSize(-1, -1), i.e. an invalid size. */ + + +/*! + + \class QStyleOptionTabWidgetFrameV2 + \brief The QStyleOptionTabWidgetFrameV2 class is used to describe the + parameters for drawing the frame around a tab widget. + + QStyleOptionTabWidgetFrameV2 contains all the information that + QStyle functions need to draw the frame around QTabWidget. + + For performance reasons, the access to the member variables is + direct (i.e., using the \c . or \c -> operator). This low-level feel + makes the structures straightforward to use and emphasizes that + these are simply parameters used by the style functions. + + For an example demonstrating how style options can be used, see + the \l {widgets/styles}{Styles} example. + + \sa QStyleOption, QTabWidget +*/ + + +/*! + \variable QStyleOptionTabWidgetFrameV2::tabBarRect + \brief the rectangle containing all the tabs + + The default value is a null rectangle, i.e. a rectangle with both + the width and the height set to 0. +*/ + +/*! + \variable QStyleOptionTabWidgetFrameV2::selectedTabRect + \brief the rectangle containing the selected tab + + This rectangle is contained within the tabBarRect. The default + value is a null rectangle, i.e. a rectangle with both the width + and the height set to 0. +*/ + + +/*! + Constructs a QStyleOptionTabWidgetFrameV2, initializing the members + variables to their default values. +*/ + +QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2() + : QStyleOptionTabWidgetFrame(Version) +{ +} + + +/*! \internal */ +QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2(int version) + : QStyleOptionTabWidgetFrame(version) +{ +} + + +/*! + Constructs a QStyleOptionTabWidgetFrameV2 copy of the \a other style option + which can be either of the QStyleOptionTabWidgetFrameV2 or + QStyleOptionTabWidgetFrame types. + + If the \a other style option's version is 1, the new style option's \l + selectedTabRect and tabBarRect will contain null rects + + \sa version +*/ +QStyleOptionTabWidgetFrameV2::QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrame &other) +{ + QStyleOptionTabWidgetFrameV2::operator=(other); + +} + + +/*! + Assigns the \a other style option to this style option. The \a + other style option can be either of the QStyleOptionFrameV2 or + QStyleOptionFrame types. + + If the \a{other} style option's version is 1, this style option's + \l FrameFeature value is set to \l QStyleOptionFrameV2::None. If + its version is 2, its \l FrameFeature value is simply copied to + this style option. +*/ +QStyleOptionTabWidgetFrameV2 &QStyleOptionTabWidgetFrameV2::operator=(const QStyleOptionTabWidgetFrame &other) +{ + QStyleOptionTabWidgetFrame::operator=(other); + if (const QStyleOptionTabWidgetFrameV2 *f2 = qstyleoption_cast(&other)) { + selectedTabRect = f2->selectedTabRect; + tabBarRect = f2->tabBarRect; + } + return *this; +} + + +/*! + \enum QStyleOptionTabWidgetFrameV2::StyleOptionVersion + + This enum is used to hold information about the version of the style option, and + is defined for each QStyleOption subclass. + + \value Version 2 + + The version is used by QStyleOption subclasses to implement + extensions without breaking compatibility. If you use + qstyleoption_cast(), you normally do not need to check it. + + \sa StyleOptionType +*/ + + #endif // QT_NO_TABWIDGET #ifndef QT_NO_TABBAR diff --git a/src/gui/styles/qstyleoption.h b/src/gui/styles/qstyleoption.h index bf8b479..abd52bf 100644 --- a/src/gui/styles/qstyleoption.h +++ b/src/gui/styles/qstyleoption.h @@ -192,8 +192,28 @@ public: protected: QStyleOptionTabWidgetFrame(int version); }; + +class Q_GUI_EXPORT QStyleOptionTabWidgetFrameV2 : public QStyleOptionTabWidgetFrame +{ +public: + enum StyleOptionVersion { Version = 2 }; + + QRect tabBarRect; + QRect selectedTabRect; + + QStyleOptionTabWidgetFrameV2(); + QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrameV2 &other) : + QStyleOptionTabWidgetFrame(Version) { *this = other; } + QStyleOptionTabWidgetFrameV2(const QStyleOptionTabWidgetFrame &other); + QStyleOptionTabWidgetFrameV2 &operator=(const QStyleOptionTabWidgetFrame &other); + +protected: + QStyleOptionTabWidgetFrameV2(int version); +}; + #endif + #ifndef QT_NO_TABBAR class Q_GUI_EXPORT QStyleOptionTabBarBase : public QStyleOption { diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 2d90aa1..ae1d33a 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4325,7 +4325,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op QRenderRule subRule = renderRule(w, opt, PseudoElement_TabWidgetPane); if (subRule.hasNativeBorder()) { subRule.drawBackground(p, opt->rect); - QStyleOptionTabWidgetFrame frmCopy(*frm); + QStyleOptionTabWidgetFrameV2 frmCopy(*frm); subRule.configurePalette(&frmCopy.palette, QPalette::WindowText, QPalette::Window); baseStyle()->drawPrimitive(pe, &frmCopy, p, w); } else { diff --git a/src/gui/styles/qwindowsxpstyle.cpp b/src/gui/styles/qwindowsxpstyle.cpp index b5dc647..9fd9ce9 100644 --- a/src/gui/styles/qwindowsxpstyle.cpp +++ b/src/gui/styles/qwindowsxpstyle.cpp @@ -1582,7 +1582,7 @@ case PE_Frame: // This should work, but currently there's an error in the ::drawBackgroundDirectly() // code, when using the HDC directly.. if (useGradient) { - QStyleOptionTabWidgetFrame frameOpt = *tab; + QStyleOptionTabWidgetFrameV2 frameOpt = *tab; frameOpt.rect = widget->rect(); QRect contentsRect = subElementRect(SE_TabWidgetTabContents, &frameOpt, widget); QRegion reg = option->rect; diff --git a/src/gui/widgets/qtabwidget.cpp b/src/gui/widgets/qtabwidget.cpp index 0c89a72..d22bd54 100644 --- a/src/gui/widgets/qtabwidget.cpp +++ b/src/gui/widgets/qtabwidget.cpp @@ -313,7 +313,16 @@ void QTabWidget::initStyleOption(QStyleOptionTabWidgetFrame *option) const : QTabBar::TriangularEast; break; } + option->tabBarSize = t; + + if (QStyleOptionTabWidgetFrameV2 *tabframe = qstyleoption_cast(option)) { + QRect tbRect = tabBar()->geometry(); + QRect selectedTabRect = tabBar()->tabRect(tabBar()->currentIndex()); + tabframe->tabBarRect = tbRect; + selectedTabRect.moveTopLeft(selectedTabRect.topLeft() + tbRect.topLeft()); + tabframe->selectedTabRect = selectedTabRect; + } } /*! @@ -756,7 +765,7 @@ void QTabWidget::setUpLayout(bool onlyCheck) if (onlyCheck && !d->dirty) return; // nothing to do - QStyleOptionTabWidgetFrame option; + QStyleOptionTabWidgetFrameV2 option; initStyleOption(&option); // this must be done immediately, because QWidgetItem relies on it (even if !isVisible()) @@ -1186,7 +1195,8 @@ void QTabWidget::paintEvent(QPaintEvent *) return; } QStylePainter p(this); - QStyleOptionTabWidgetFrame opt; + + QStyleOptionTabWidgetFrameV2 opt; initStyleOption(&opt); opt.rect = d->panelRect; p.drawPrimitive(QStyle::PE_FrameTabWidget, opt); -- cgit v0.12 From 8182dc12b88727c647f9bac4d9a19914e3cd8307 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Mon, 19 Oct 2009 12:17:34 +0200 Subject: Fixed slow QPixmap::fill() when the pixmap is sharing data. If the pixmap is sharing data with other pixmaps, it must be detached before it is filled. Instead of detaching by making a copy, create a new uninitialized data object since all pixels are overwritten by fill() anyway. Task-number: QTBUG-3228 Reviewed-by: Trond --- src/gui/image/qpixmap.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index c03a364..bf6c9ae 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -959,7 +959,17 @@ void QPixmap::fill(const QColor &color) return; } - detach(); + if (data->ref == 1) { + // detach() will also remove this pixmap from caches, so + // it has to be called even when ref == 1. + detach(); + } else { + // Don't bother to make a copy of the data object, since + // it will be filled with new pixel data anyway. + QPixmapData *d = data->createCompatiblePixmapData(); + d->resize(data->width(), data->height()); + data = d; + } data->fill(color); } -- cgit v0.12 From e1f691d84dad17c5ee47c97c31ae743093ad8bc9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Thu, 8 Oct 2009 09:15:20 +0200 Subject: Ensure that qmake doesn't lose the error code when processing subdirs When processing a project in a subdirs template failed for whatever reason then qmake would lose the result of that and would return an error code of 0 if the subdirs project file itself was processed fine. So now it ensures that any errors arising from processing a project referenced in a subdirs project file are not lost so that the error code returned from qmake will indicate an error actually occured. Task-number: QTBUG-4065 Reviewed-by: mariusSO Original-commit: c15b370c9db16fdbfd9e7bec89ee9bf8c1110827 --- qmake/generators/metamakefile.cpp | 17 ++++++++++++----- qmake/generators/metamakefile.h | 2 +- qmake/main.cpp | 6 +++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/qmake/generators/metamakefile.cpp b/qmake/generators/metamakefile.cpp index 5915fcf..819cdaf 100644 --- a/qmake/generators/metamakefile.cpp +++ b/qmake/generators/metamakefile.cpp @@ -291,6 +291,7 @@ SubdirsMetaMakefileGenerator::init() if(init_flag) return false; init_flag = true; + bool hasError = false; if(Option::recursive) { QString old_output_dir = Option::output_dir; @@ -336,14 +337,18 @@ SubdirsMetaMakefileGenerator::init() } qmake_setpwd(sub->input_dir); Option::output_dir = sub->output_dir; - sub_proj->read(subdir.fileName()); + bool tmpError = !sub_proj->read(subdir.fileName()); if(!sub_proj->variables()["QMAKE_FAILED_REQUIREMENTS"].isEmpty()) { fprintf(stderr, "Project file(%s) not recursed because all requirements not met:\n\t%s\n", subdir.fileName().toLatin1().constData(), sub_proj->values("QMAKE_FAILED_REQUIREMENTS").join(" ").toLatin1().constData()); delete sub; delete sub_proj; + Option::output_dir = old_output_dir; + qmake_setpwd(oldpwd); continue; + } else { + hasError |= tmpError; } sub->makefile = MetaMakefileGenerator::createMetaGenerator(sub_proj, sub_name); if(0 && sub->makefile->type() == SUBDIRSMETATYPE) { @@ -351,7 +356,7 @@ SubdirsMetaMakefileGenerator::init() } else { const QString output_name = Option::output.fileName(); Option::output.setFileName(sub->output_file); - sub->makefile->write(sub->output_dir); + hasError |= !sub->makefile->write(sub->output_dir); delete sub; qmakeClearCaches(); sub = 0; @@ -376,7 +381,7 @@ SubdirsMetaMakefileGenerator::init() self->makefile->init(); subs.append(self); - return true; + return !hasError; } bool @@ -482,7 +487,7 @@ MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO) } MetaMakefileGenerator * -MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &name, bool op) +MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &name, bool op, bool *success) { MetaMakefileGenerator *ret = 0; if ((Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || @@ -492,7 +497,9 @@ MetaMakefileGenerator::createMetaGenerator(QMakeProject *proj, const QString &na } if (!ret) ret = new BuildsMetaMakefileGenerator(proj, name, op); - ret->init(); + bool res = ret->init(); + if (success) + *success = res; return ret; } diff --git a/qmake/generators/metamakefile.h b/qmake/generators/metamakefile.h index e69304a..f74f4a2 100644 --- a/qmake/generators/metamakefile.h +++ b/qmake/generators/metamakefile.h @@ -62,7 +62,7 @@ public: virtual ~MetaMakefileGenerator(); - static MetaMakefileGenerator *createMetaGenerator(QMakeProject *proj, const QString &name, bool op=true); + static MetaMakefileGenerator *createMetaGenerator(QMakeProject *proj, const QString &name, bool op=true, bool *success = 0); static MakefileGenerator *createMakefileGenerator(QMakeProject *proj, bool noIO = false); inline QMakeProject *projectFile() const { return project; } diff --git a/qmake/main.cpp b/qmake/main.cpp index 73fdda9..a0346c5 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -168,7 +168,11 @@ int runQMake(int argc, char **argv) continue; } - MetaMakefileGenerator *mkfile = MetaMakefileGenerator::createMetaGenerator(&project, QString(), false); + bool success = true; + MetaMakefileGenerator *mkfile = MetaMakefileGenerator::createMetaGenerator(&project, QString(), false, &success); + if (!success) + exit_val = 3; + if(mkfile && !mkfile->write(oldpwd)) { if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) fprintf(stderr, "Unable to generate project file.\n"); -- cgit v0.12 From 4d94420184fa109286a9e4233010d5d7539a35a4 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Mon, 19 Oct 2009 14:20:26 +0200 Subject: Integrated new triangulating stroker into Qt --- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 195 ++++++++++---- .../gl2paintengineex/qpaintengineex_opengl2_p.h | 26 +- .../gl2paintengineex/qtriangulatingstroker.cpp | 299 +++++++++++++++++++++ .../gl2paintengineex/qtriangulatingstroker_p.h | 258 ++++++++++++++++++ src/opengl/opengl.pro | 6 +- 5 files changed, 730 insertions(+), 54 deletions(-) create mode 100644 src/opengl/gl2paintengineex/qtriangulatingstroker.cpp create mode 100644 src/opengl/gl2paintengineex/qtriangulatingstroker_p.h diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 13efbda..bcc6bdb 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -81,6 +81,8 @@ #include "qglengineshadermanager_p.h" #include "qgl2pexvertexarray_p.h" +#include "qtriangulatingstroker_p.h" + #include QT_BEGIN_NAMESPACE @@ -572,7 +574,6 @@ void QGL2PaintEngineExPrivate::updateMatrix() // // We expand out the multiplication to save the cost of a full 4x4 // matrix multiplication as most of the components are trivial. - const QTransform& transform = q->state()->matrix; if (mode == TextDrawingMode) { @@ -628,6 +629,9 @@ void QGL2PaintEngineExPrivate::updateMatrix() // The actual data has been updated so both shader program's uniforms need updating simpleShaderMatrixUniformDirty = true; shaderMatrixUniformDirty = true; + + dasher.setInvScale(inverseScale); + stroker.setInvScale(inverseScale); } @@ -838,28 +842,6 @@ void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) mode = newMode; } -void QGL2PaintEngineExPrivate::drawOutline(const QVectorPath& path) -{ - transferMode(BrushDrawingMode); - - // Might need to call updateMatrix to re-calculate inverseScale - if (matrixDirty) - updateMatrix(); - - vertexCoordinateArray.clear(); - vertexCoordinateArray.addPath(path, inverseScale); - - if (path.hasImplicitClose()) { - // Close the path's outline - vertexCoordinateArray.lineToArray(path.points()[0], path.points()[1]); - vertexCoordinateArray.stops().last() += 1; - } - - prepareForDraw(currentBrush->isOpaque()); - drawVertexArrays(vertexCoordinateArray, GL_LINE_STRIP); -} - - // Assumes everything is configured for the brush you want to use void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) { @@ -922,8 +904,14 @@ void QGL2PaintEngineExPrivate::fill(const QVectorPath& path) } -void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& vertexArray, bool useWindingFill) +void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(const float *data, + int count, + const QVector *stops, + const QGLRect &bounds, + StencilFillMode mode) { + Q_ASSERT(count || stops); + // qDebug("QGL2PaintEngineExPrivate::fillStencilWithVertexArray()"); glStencilMask(0xff); // Enable stencil writes @@ -955,19 +943,20 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& ve } #endif - if (useWindingFill) { + if (mode == WindingFillMode) { + Q_ASSERT(stops && !count); if (q->state()->clipTestEnabled) { // Flatten clip values higher than current clip, and set high bit to match current clip glStencilFunc(GL_LEQUAL, GL_STENCIL_HIGH_BIT | q->state()->currentClip, ~GL_STENCIL_HIGH_BIT); glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); - composite(vertexArray.boundingRect()); + composite(bounds); glStencilFunc(GL_EQUAL, GL_STENCIL_HIGH_BIT, GL_STENCIL_HIGH_BIT); } else if (!stencilClean) { // Clear stencil buffer within bounding rect glStencilFunc(GL_ALWAYS, 0, 0xff); glStencilOp(GL_ZERO, GL_ZERO, GL_ZERO); - composite(vertexArray.boundingRect()); + composite(bounds); } // Inc. for front-facing triangle @@ -975,19 +964,43 @@ void QGL2PaintEngineExPrivate::fillStencilWithVertexArray(QGL2PEXVertexArray& ve // Dec. for back-facing "holes" glStencilOpSeparate(GL_BACK, GL_KEEP, GL_DECR_WRAP, GL_DECR_WRAP); glStencilMask(~GL_STENCIL_HIGH_BIT); - drawVertexArrays(vertexArray, GL_TRIANGLE_FAN); + drawVertexArrays(data, stops, GL_TRIANGLE_FAN); if (q->state()->clipTestEnabled) { // Clear high bit of stencil outside of path glStencilFunc(GL_EQUAL, q->state()->currentClip, ~GL_STENCIL_HIGH_BIT); glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); glStencilMask(GL_STENCIL_HIGH_BIT); - composite(vertexArray.boundingRect()); + composite(bounds); } - } else { + } else if (mode == OddEvenFillMode) { + glStencilMask(GL_STENCIL_HIGH_BIT); + glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); // Simply invert the stencil bit + drawVertexArrays(data, stops, GL_TRIANGLE_FAN); + + } else { // TriStripStrokeFillMode + Q_ASSERT(count && !stops); // tristrips generated directly, so no vertexArray or stops glStencilMask(GL_STENCIL_HIGH_BIT); +#if 0 glStencilOp(GL_KEEP, GL_KEEP, GL_INVERT); // Simply invert the stencil bit - drawVertexArrays(vertexArray, GL_TRIANGLE_FAN); + glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); + glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, data); + glDrawArrays(GL_TRIANGLE_STRIP, 0, count); + glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); +#else + + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + if (q->state()->clipTestEnabled) { + glStencilFunc(GL_LEQUAL, q->state()->currentClip | GL_STENCIL_HIGH_BIT, + ~GL_STENCIL_HIGH_BIT); + } else { + glStencilFunc(GL_ALWAYS, GL_STENCIL_HIGH_BIT, 0xff); + } + glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); + glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, data); + glDrawArrays(GL_TRIANGLE_STRIP, 0, count); + glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); +#endif } // Enable color writes & disable stencil writes @@ -1122,14 +1135,15 @@ void QGL2PaintEngineExPrivate::composite(const QGLRect& boundingRect) } // Draws the vertex array as a set of triangle fans. -void QGL2PaintEngineExPrivate::drawVertexArrays(QGL2PEXVertexArray& vertexArray, GLenum primitive) +void QGL2PaintEngineExPrivate::drawVertexArrays(const float *data, const QVector *stops, + GLenum primitive) { // Now setup the pointer to the vertex array: glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); - glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, vertexArray.data()); + glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, GL_FALSE, 0, data); int previousStop = 0; - foreach(int stop, vertexArray.stops()) { + foreach(int stop, *stops) { /* qDebug("Drawing triangle fan for vertecies %d -> %d:", previousStop, stop-1); for (int i=previousStop; iinRenderText) ensureActive(); + + QOpenGL2PaintEngineState *s = state(); + bool doOffset = !(s->renderHints & QPainter::Antialiasing) && style == Qt::SolidPattern; + + if (doOffset) { + d->temporaryTransform = s->matrix; + QTransform tx = QTransform::fromTranslate(.49, .49); + s->matrix = s->matrix * tx; + d->matrixDirty = true; + } + d->setBrush(&brush); d->fill(path); + + if (doOffset) { + s->matrix = d->temporaryTransform; + d->matrixDirty = true; + } } void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) @@ -1197,23 +1228,89 @@ void QGL2PaintEngineEx::stroke(const QVectorPath &path, const QPen &pen) if (penStyle == Qt::NoPen || qbrush_style(penBrush) == Qt::NoBrush) return; + QOpenGL2PaintEngineState *s = state(); + ensureActive(); - qreal penWidth = qpen_widthf(pen); - if ( (pen.isCosmetic() && (penStyle == Qt::SolidLine)) && (penWidth < 2.5f) ) - { - // We only handle solid, cosmetic pens with a width of 1 pixel - const QBrush& brush = pen.brush(); - d->setBrush(&brush); + bool doOffset = !(s->renderHints & QPainter::Antialiasing); + if (doOffset) { + d->temporaryTransform = s->matrix; + QTransform tx = QTransform::fromTranslate(0.49, .49); + s->matrix = s->matrix * tx; + d->matrixDirty = true; + } - if (penWidth < 0.01f) - glLineWidth(1.0); - else - glLineWidth(penWidth); + bool opaque = penBrush.isOpaque() && s->opacity > 0.99; + d->setBrush(&penBrush); + d->transferMode(BrushDrawingMode); + + // updateMatrix() is responsible for setting the inverse scale on + // the strokers, so we need to call it here and not wait for + // prepareForDraw() down below. + d->updateMatrix(); + + if (penStyle == Qt::SolidLine) { + d->stroker.process(path, pen); + + } else { // Some sort of dash + d->dasher.process(path, pen); + + QVectorPath dashStroke(d->dasher.points(), + d->dasher.elementCount(), + d->dasher.elementTypes()); + d->stroker.process(dashStroke, pen); + } + + + QGLContext *ctx = d->ctx; + + if (opaque) { + d->prepareForDraw(opaque); + glEnableVertexAttribArray(QT_VERTEX_COORDS_ATTR); + glVertexAttribPointer(QT_VERTEX_COORDS_ATTR, 2, GL_FLOAT, false, 0, d->stroker.vertices()); + glDrawArrays(GL_TRIANGLE_STRIP, 0, d->stroker.vertexCount() / 2); + +// QBrush b(Qt::green); +// d->setBrush(&b); +// d->prepareForDraw(true); +// glDrawArrays(GL_LINE_STRIP, 0, d->stroker.vertexCount() / 2); - d->drawOutline(path); - } else - return QPaintEngineEx::stroke(path, pen); + glDisableVertexAttribArray(QT_VERTEX_COORDS_ATTR); + + } else { + qreal width = qpen_widthf(pen) / 2; + if (width == 0) + width = 0.5; + qreal extra = pen.joinStyle() == Qt::MiterJoin + ? qMax(pen.miterLimit() * width, width) + : width; + + if (pen.isCosmetic()) + extra = extra * d->inverseScale; + + QRectF bounds = path.controlPointRect().adjusted(-extra, -extra, extra, extra); + + d->fillStencilWithVertexArray(d->stroker.vertices(), d->stroker.vertexCount() / 2, + 0, bounds, QGL2PaintEngineExPrivate::TriStripStrokeFillMode); + + glStencilOp(GL_KEEP, GL_REPLACE, GL_REPLACE); + + // Pass when any bit is set, replace stencil value with 0 + glStencilFunc(GL_NOTEQUAL, 0, GL_STENCIL_HIGH_BIT); + d->prepareForDraw(false); + + // Stencil the brush onto the dest buffer + d->composite(bounds); + + glStencilMask(0); + + d->updateClipScissorTest(); + } + + if (doOffset) { + s->matrix = d->temporaryTransform; + d->matrixDirty = true; + } } void QGL2PaintEngineEx::penChanged() { } @@ -1542,7 +1639,7 @@ void QGL2PaintEngineEx::drawPixmaps(const QDrawPixmaps::Data *drawingData, int d s = qFastSin(drawingData[i].rotation * Q_PI / 180); c = qFastCos(drawingData[i].rotation * Q_PI / 180); } - + qreal right = 0.5 * drawingData[i].scaleX * drawingData[i].source.width(); qreal bottom = 0.5 * drawingData[i].scaleY * drawingData[i].source.height(); QGLPoint bottomRight(right * c - bottom * s, right * s + bottom * c); diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h index 5704a04..209cd36 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2_p.h @@ -62,6 +62,7 @@ #include #include #include +#include enum EngineMode { ImageDrawingMode, @@ -160,6 +161,12 @@ class QGL2PaintEngineExPrivate : public QPaintEngineExPrivate { Q_DECLARE_PUBLIC(QGL2PaintEngineEx) public: + enum StencilFillMode { + OddEvenFillMode, + WindingFillMode, + TriStripStrokeFillMode + }; + QGL2PaintEngineExPrivate(QGL2PaintEngineEx *q_ptr) : q(q_ptr), width(0), height(0), @@ -185,15 +192,24 @@ public: // fill, drawOutline, drawTexture & drawCachedGlyphs are the rendering entry points: void fill(const QVectorPath &path); - void drawOutline(const QVectorPath& path); void drawTexture(const QGLRect& dest, const QGLRect& src, const QSize &textureSize, bool opaque, bool pattern = false); void drawCachedGlyphs(const QPointF &p, QFontEngineGlyphCache::Type glyphType, const QTextItemInt &ti); - void drawVertexArrays(QGL2PEXVertexArray& vertexArray, GLenum primitive); + void drawVertexArrays(const float *data, const QVector *stops, GLenum primitive); + void drawVertexArrays(QGL2PEXVertexArray &vertexArray, GLenum primitive) { + drawVertexArrays((const float *) vertexArray.data(), &vertexArray.stops(), primitive); + } + // ^ draws whatever is in the vertex array void composite(const QGLRect& boundingRect); // ^ Composites the bounding rect onto dest buffer - void fillStencilWithVertexArray(QGL2PEXVertexArray& vertexArray, bool useWindingFill); + + void fillStencilWithVertexArray(const float *data, int count, const QVector *stops, const QGLRect &bounds, StencilFillMode mode); + void fillStencilWithVertexArray(QGL2PEXVertexArray& vertexArray, bool useWindingFill) { + fillStencilWithVertexArray((const float *) vertexArray.data(), 0, &vertexArray.stops(), + vertexArray.boundingRect(), + useWindingFill ? WindingFillMode : OddEvenFillMode); + } // ^ Calls drawVertexArrays to render into stencil buffer bool prepareForDraw(bool srcPixelsAreOpaque); @@ -266,6 +282,10 @@ public: float textureInvertedY; + QTriangulatingStroker stroker; + QDashedStrokeProcessor dasher; + QTransform temporaryTransform; + QScopedPointer convolutionFilter; QScopedPointer colorizeFilter; QScopedPointer blurFilter; diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp new file mode 100644 index 0000000..250dab6 --- /dev/null +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -0,0 +1,299 @@ +#include "qtriangulatingstroker_p.h" +#include + + +#define CURVE_FLATNESS Q_PI / 8 + + + + +void QTriangulatingStroker::endCapOrJoinClosed(const qreal *start, const qreal *cur, + bool implicitClose, bool endsAtStart) +{ + if (endsAtStart) { + join(start + 2); + } else if (implicitClose) { + join(start); + lineTo(start); + join(start+2); + } else { + endCap(cur); + } +} + + +void QTriangulatingStroker::process(const QVectorPath &path, const QPen &pen) +{ + const qreal *pts = path.points(); + const QPainterPath::ElementType *types = path.elements(); + int count = path.elementCount(); + if (count < 2) + return; + + float realWidth = qpen_widthf(pen); + if (realWidth == 0) + realWidth = 1; + + m_width = realWidth / 2; + + bool cosmetic = pen.isCosmetic(); + if (cosmetic) { + m_width = m_width * m_inv_scale; + } + + m_join_style = qpen_joinStyle(pen); + m_cap_style = qpen_capStyle(pen); + m_vertices.reset(); + m_miter_limit = pen.miterLimit() * qpen_widthf(pen); + + // The curvyness is based on the notion that I originally wanted + // roughly one line segment pr 4 pixels. This may seem little, but + // because we sample at constantly incrementing B(t) E [0(4, realWidth * CURVE_FLATNESS); + } else { + m_curvyness_add = m_width; + m_curvyness_mul = CURVE_FLATNESS / m_inv_scale; + m_roundness = qMax(4, realWidth * m_curvyness_mul); + } + + // Over this level of segmentation, there doesn't seem to be any + // benefit, even for huge penWidth + if (m_roundness > 24) + m_roundness = 24; + + m_sin_theta = qSin(Q_PI / m_roundness); // ### Use qFastSin + m_cos_theta = qCos(Q_PI / m_roundness); + + const qreal *endPts = pts + (count<<1); + const qreal *startPts; + + Qt::PenCapStyle cap = m_cap_style; + + if (!types) { + startPts = pts; + + bool endsAtStart = startPts[0] == *(endPts-2) && startPts[1] == *(endPts-1); + + Qt::PenCapStyle cap = m_cap_style; + if (endsAtStart || path.hasImplicitClose()) + m_cap_style = Qt::FlatCap; + moveTo(pts); + m_cap_style = cap; + pts += 2; + lineTo(pts); + pts += 2; + while (pts < endPts) { + join(pts); + lineTo(pts); + pts += 2; + } + + endCapOrJoinClosed(startPts, pts-2, path.hasImplicitClose(), endsAtStart); + + } else { + bool endsAtStart; + while (pts < endPts) { + switch (*types) { + case QPainterPath::MoveToElement: { + if (pts != path.points()) + endCapOrJoinClosed(startPts, pts, path.hasImplicitClose(), endsAtStart); + + startPts = pts; + int end = (endPts - pts) / 2; + int i = 2; // Start looking to ahead since we never have two moveto's in a row + while (i(64, (rad + m_curvyness_add) * m_curvyness_mul); + if (threshold < 4) + threshold = 4; + qreal threshold_minus_1 = threshold - 1; + float vx, vy; + + float cx = m_cx, cy = m_cy; + float x, y; + + for (int i=1; iaddElement(QPainterPath::MoveToElement, x, y); +} + +static void qdashprocessor_lineTo(qreal x, qreal y, void *data) +{ + ((QDashedStrokeProcessor *) data)->addElement(QPainterPath::LineToElement, x, y); +} + +static void qdashprocessor_cubicTo(qreal, qreal, qreal, qreal, qreal, qreal, void *) +{ + Q_ASSERT(0); // The dasher should not produce curves... +} + +QDashedStrokeProcessor::QDashedStrokeProcessor() + : m_dash_stroker(0), m_inv_scale(1) +{ + m_dash_stroker.setMoveToHook(qdashprocessor_moveTo); + m_dash_stroker.setLineToHook(qdashprocessor_lineTo); + m_dash_stroker.setCubicToHook(qdashprocessor_cubicTo); +} + +void QDashedStrokeProcessor::process(const QVectorPath &path, const QPen &pen) +{ + + const qreal *pts = path.points(); + const QPainterPath::ElementType *types = path.elements(); + int count = path.elementCount(); + + m_points.reset(); + m_types.reset(); + + qreal width = pen.width(); + if (width == 0) + width = 1; + + m_dash_stroker.setDashPattern(pen.dashPattern()); + m_dash_stroker.setStrokeWidth(width); + m_dash_stroker.setMiterLimit(pen.miterLimit()); + qreal curvyness = sqrt(width) * m_inv_scale / 8; + + if (count < 2) + return; + + const qreal *endPts = pts + (count<<1); + + m_dash_stroker.begin(this); + + if (!types) { + m_dash_stroker.moveTo(pts[0], pts[1]); + pts += 2; + while (pts < endPts) { + m_dash_stroker.lineTo(pts[0], pts[1]); + pts += 2; + } + } else { + while (pts < endPts) { + switch (*types) { + case QPainterPath::MoveToElement: + m_dash_stroker.moveTo(pts[0], pts[1]); + pts += 2; + ++types; + break; + case QPainterPath::LineToElement: + m_dash_stroker.lineTo(pts[0], pts[1]); + pts += 2; + ++types; + break; + case QPainterPath::CurveToElement: { + QBezier b = QBezier::fromPoints(*(((const QPointF *) pts) - 1), + *(((const QPointF *) pts)), + *(((const QPointF *) pts) + 1), + *(((const QPointF *) pts) + 2)); + QRectF bounds = b.bounds(); + int threshold = qMin(64, qMax(bounds.width(), bounds.height()) * curvyness); + if (threshold < 4) + threshold = 4; + qreal threshold_minus_1 = threshold - 1; + for (int i=0; i +#include +#include +#include +#include + + +class QTriangulatingStroker +{ +public: + void process(const QVectorPath &path, const QPen &pen); + + inline int vertexCount() const { return m_vertices.size(); } + inline const float *vertices() const { return m_vertices.data(); } + + inline void setInvScale(qreal invScale) { m_inv_scale = invScale; } + +private: + inline void emitLineSegment(float x, float y, float nx, float ny); + inline void moveTo(const qreal *pts); + inline void lineTo(const qreal *pts); + void cubicTo(const qreal *pts); + inline void join(const qreal *pts); + inline void normalVector(float x1, float y1, float x2, float y2, float *nx, float *ny); + inline void endCap(const qreal *pts); + inline void arc(float x, float y); + void endCapOrJoinClosed(const qreal *start, const qreal *cur, bool implicitClose, bool endsAtStart); + + + QDataBuffer m_vertices; + + float m_cx, m_cy; // current points + float m_nvx, m_nvy; // normal vector... + float m_width; + qreal m_miter_limit; + + int m_roundness; // Number of line segments in a round join + qreal m_sin_theta; // sin(m_roundness / 360); + qreal m_cos_theta; // cos(m_roundness / 360); + qreal m_inv_scale; + float m_curvyness_mul; + float m_curvyness_add; + + Qt::PenJoinStyle m_join_style; + Qt::PenCapStyle m_cap_style; +}; + +class QDashedStrokeProcessor +{ +public: + QDashedStrokeProcessor(); + + void process(const QVectorPath &path, const QPen &pen); + + inline void addElement(QPainterPath::ElementType type, qreal x, qreal y) { + m_points.add(x); + m_points.add(y); + m_types.add(type); + } + + inline int elementCount() const { return m_types.size(); } + inline qreal *points() const { return m_points.data(); } + inline QPainterPath::ElementType *elementTypes() const { return m_types.data(); } + + inline void setInvScale(qreal invScale) { m_inv_scale = invScale; } + +private: + QDataBuffer m_points; + QDataBuffer m_types; + QDashStroker m_dash_stroker; + qreal m_inv_scale; +}; + + + + + +inline void QTriangulatingStroker::normalVector(float x1, float y1, float x2, float y2, + float *nx, float *ny) +{ + float dx = x2 - x1; + float dy = y2 - y1; + float pw = m_width / sqrt(dx*dx + dy*dy); + *nx = -dy * pw; + *ny = dx * pw; +} + + + +inline void QTriangulatingStroker::emitLineSegment(float x, float y, float vx, float vy) +{ + m_vertices.add(x + vx); + m_vertices.add(y + vy); + m_vertices.add(x - vx); + m_vertices.add(y - vy); +} + + + +// We draw a full circle for any round join or round cap which is a +// bit of overkill... +inline void QTriangulatingStroker::arc(float x, float y) +{ + float dx = m_width; + float dy = 0; + for (int i=0; i<=m_roundness; ++i) { + float tmpx = dx * m_cos_theta - dy * m_sin_theta; + float tmpy = dx * m_sin_theta + dy * m_cos_theta; + dx = tmpx; + dy = tmpy; + emitLineSegment(x, y, dx, dy); + } +} + + + +inline void QTriangulatingStroker::endCap(const qreal *pts) +{ + switch (m_cap_style) { + case Qt::FlatCap: + break; + case Qt::SquareCap: { + float dx = m_cx - *(pts - 2); + float dy = m_cy - *(pts - 1); + + float len = m_width / sqrt(dx * dx + dy * dy); + dx = dx * len; + dy = dy * len; + + emitLineSegment(m_cx + dx, m_cy + dy, m_nvx, m_nvy); + break; } + case Qt::RoundCap: + arc(m_cx, m_cy); + break; + default: break; // to shut gcc up... + } + + int count = m_vertices.size(); + m_vertices.add(m_vertices.at(count-2)); + m_vertices.add(m_vertices.at(count-1)); +} + + +void QTriangulatingStroker::moveTo(const qreal *pts) +{ + m_cx = pts[0]; + m_cy = pts[1]; + + float x2 = pts[2]; + float y2 = pts[3]; + normalVector(m_cx, m_cy, x2, y2, &m_nvx, &m_nvy); + + + // To acheive jumps we insert zero-area tringles. This is done by + // adding two identical points in both the end of previous strip + // and beginning of next strip + bool invisibleJump = m_vertices.size(); + + switch (m_cap_style) { + case Qt::FlatCap: + if (invisibleJump) { + m_vertices.add(m_cx + m_nvx); + m_vertices.add(m_cy + m_nvy); + } + break; + case Qt::SquareCap: { + float dx = x2 - m_cx; + float dy = y2 - m_cy; + float len = m_width / sqrt(dx * dx + dy * dy); + dx = dx * len; + dy = dy * len; + float sx = m_cx - dx; + float sy = m_cy - dy; + if (invisibleJump) { + m_vertices.add(sx + m_nvx); + m_vertices.add(sy + m_nvy); + } + emitLineSegment(sx, sy, m_nvx, m_nvy); + break; } + case Qt::RoundCap: + if (invisibleJump) { + m_vertices.add(m_cx + m_nvx); + m_vertices.add(m_cy + m_nvy); + } + + // This emitLineSegment is not needed for the arc, but we need + // to start where we put the invisibleJump vertex, otherwise + // we'll have visible triangles between subpaths. + emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); + arc(m_cx, m_cy); + break; + default: break; // ssssh gcc... + } + emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); +} + + + +void QTriangulatingStroker::lineTo(const qreal *pts) +{ + emitLineSegment(pts[0], pts[1], m_nvx, m_nvy); + m_cx = pts[0]; + m_cy = pts[1]; +} + + + + + +void QTriangulatingStroker::join(const qreal *pts) +{ + // Creates a join to the next segment (m_cx, m_cy) -> (pts[0], pts[1]) + normalVector(m_cx, m_cy, pts[0], pts[1], &m_nvx, &m_nvy); + + switch (m_join_style) { + case Qt::BevelJoin: + break; + case Qt::MiterJoin: { + int p1 = m_vertices.size() - 6; + int p2 = m_vertices.size() - 2; + QLineF line(m_vertices.at(p1), m_vertices.at(p1+1), + m_vertices.at(p2), m_vertices.at(p2+1)); + QLineF nextLine(m_cx - m_nvx, m_cy - m_nvy, + pts[0] - m_nvx, pts[1] - m_nvy); + + QPointF isect; + if (line.intersect(nextLine, &isect) != QLineF::NoIntersection + && QLineF(line.p2(), isect).length() <= m_miter_limit) { + // The intersection point mirrored over the m_cx, m_cy point + m_vertices.add(m_cx - (isect.x() - m_cx)); + m_vertices.add(m_cy - (isect.y() - m_cy)); + + // The intersection point + m_vertices.add(isect.x()); + m_vertices.add(isect.y()); + } + // else + // Do a plain bevel join if the miter limit is exceeded or if + // the lines are parallel. This is not what the raster + // engine's stroker does, but it is both faster and similar to + // what some other graphics API's do. + + break; } + case Qt::RoundJoin: + arc(m_cx, m_cy); + break; + + default: break; // gcc warn-- + } + + emitLineSegment(m_cx, m_cy, m_nvx, m_nvy); +} + + +#endif diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index e561932..058016e 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -60,7 +60,8 @@ SOURCES += qgl.cpp \ gl2paintengineex/qgl2pexvertexarray_p.h \ gl2paintengineex/qpaintengineex_opengl2_p.h \ gl2paintengineex/qglengineshadersource_p.h \ - gl2paintengineex/qglcustomshaderstage_p.h + gl2paintengineex/qglcustomshaderstage_p.h \ + gl2paintengineex/qtriangulatingstroker_p.h SOURCES += qglshaderprogram.cpp \ qglpixmapfilter.cpp \ @@ -72,7 +73,8 @@ SOURCES += qgl.cpp \ gl2paintengineex/qglengineshadermanager.cpp \ gl2paintengineex/qgl2pexvertexarray.cpp \ gl2paintengineex/qpaintengineex_opengl2.cpp \ - gl2paintengineex/qglcustomshaderstage.cpp + gl2paintengineex/qglcustomshaderstage.cpp \ + gl2paintengineex/qtriangulatingstroker.cpp } -- cgit v0.12 From e2296ba010100d007a081e0faac8066adbeb7137 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Fri, 2 Oct 2009 11:13:30 +0200 Subject: Stop QEglContext destroying contexts it doesn't own Reviewed-By: Rhys Weatherley --- src/gui/egl/qegl.cpp | 3 ++- src/gui/egl/qegl_p.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/egl/qegl.cpp b/src/gui/egl/qegl.cpp index 840b9d6..39291d3 100644 --- a/src/gui/egl/qegl.cpp +++ b/src/gui/egl/qegl.cpp @@ -61,6 +61,7 @@ QEglContext::QEglContext() , cfg(0) , currentSurface(EGL_NO_SURFACE) , current(false) + , ownsContext(true) { } @@ -206,7 +207,7 @@ void QEglContext::destroySurface(EGLSurface surface) // Destroy the context. Note: this does not destroy the surface. void QEglContext::destroy() { - if (ctx != EGL_NO_CONTEXT) + if (ctx != EGL_NO_CONTEXT && ownsContext) eglDestroyContext(dpy, ctx); dpy = EGL_NO_DISPLAY; ctx = EGL_NO_CONTEXT; diff --git a/src/gui/egl/qegl_p.h b/src/gui/egl/qegl_p.h index dc399da..16b5b16 100644 --- a/src/gui/egl/qegl_p.h +++ b/src/gui/egl/qegl_p.h @@ -110,7 +110,7 @@ public: EGLDisplay display() const { return dpy; } EGLContext context() const { return ctx; } - void setContext(EGLContext context) { ctx = context; } + void setContext(EGLContext context) { ctx = context; ownsContext = false;} EGLConfig config() const { return cfg; } void setConfig(EGLConfig config) { cfg = config; } @@ -131,6 +131,7 @@ private: EGLConfig cfg; EGLSurface currentSurface; bool current; + bool ownsContext; static EGLDisplay getDisplay(QPaintDevice *device); -- cgit v0.12 From 22b9079040ae0d4f35781509fa6aea7e38ac47bb Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 12 Oct 2009 15:39:52 +0200 Subject: Separate modification & destruction pixmap cleanup hooks Before the QExplicitlySharedDataPointer change, the ref-count was 0 when calling the cleanup hooks from ~QPixmap. That enabled the hook to figure out if the pixmap is being modified or deleted. As the ref count is now 1 when calling the cleanup hooks in ~QPixmap, we need to seperate the hooks. This change should make using textre-from-pixmap faster as the EGL/glX surface wont get re-created everytime the pixmap is modified. Reviewed-By: Gunnar --- src/gui/image/qimagepixmapcleanuphooks.cpp | 35 ++++++++++++++++++++++++------ src/gui/image/qimagepixmapcleanuphooks_p.h | 17 +++++++++++---- src/gui/image/qpixmap.cpp | 7 +++--- src/opengl/qgl.cpp | 21 ++++++++++++++---- src/opengl/qgl_p.h | 6 ++++- 5 files changed, 67 insertions(+), 19 deletions(-) diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp index d08d3ef..138eb0d 100644 --- a/src/gui/image/qimagepixmapcleanuphooks.cpp +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -70,19 +70,30 @@ QImagePixmapCleanupHooks *QImagePixmapCleanupHooks::instance() return qt_image_and_pixmap_cleanup_hooks; } -void QImagePixmapCleanupHooks::addPixmapHook(_qt_pixmap_cleanup_hook_pm hook) +void QImagePixmapCleanupHooks::addPixmapModificationHook(_qt_pixmap_cleanup_hook_pm hook) { - pixmapHooks.append(hook); + pixmapModificationHooks.append(hook); } +void QImagePixmapCleanupHooks::addPixmapDestructionHook(_qt_pixmap_cleanup_hook_pm hook) +{ + pixmapDestructionHooks.append(hook); +} + + void QImagePixmapCleanupHooks::addImageHook(_qt_image_cleanup_hook_64 hook) { imageHooks.append(hook); } -void QImagePixmapCleanupHooks::removePixmapHook(_qt_pixmap_cleanup_hook_pm hook) +void QImagePixmapCleanupHooks::removePixmapModificationHook(_qt_pixmap_cleanup_hook_pm hook) +{ + pixmapModificationHooks.removeAll(hook); +} + +void QImagePixmapCleanupHooks::removePixmapDestructionHook(_qt_pixmap_cleanup_hook_pm hook) { - pixmapHooks.removeAll(hook); + pixmapDestructionHooks.removeAll(hook); } void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook) @@ -91,15 +102,25 @@ void QImagePixmapCleanupHooks::removeImageHook(_qt_image_cleanup_hook_64 hook) } -void QImagePixmapCleanupHooks::executePixmapHooks(QPixmap* pm) +void QImagePixmapCleanupHooks::executePixmapModificationHooks(QPixmap* pm) { - for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapHooks.count(); ++i) - qt_image_and_pixmap_cleanup_hooks->pixmapHooks[i](pm); + Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks->pixmapModificationHooks[i](pm); if (qt_pixmap_cleanup_hook_64) qt_pixmap_cleanup_hook_64(pm->cacheKey()); } +void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm) +{ + Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); + for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks.count(); ++i) + qt_image_and_pixmap_cleanup_hooks->pixmapDestructionHooks[i](pm); + + if (qt_pixmap_cleanup_hook_64) + qt_pixmap_cleanup_hook_64(pm->cacheKey()); +} void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) { diff --git a/src/gui/image/qimagepixmapcleanuphooks_p.h b/src/gui/image/qimagepixmapcleanuphooks_p.h index dd2d0f7..16c8974 100644 --- a/src/gui/image/qimagepixmapcleanuphooks_p.h +++ b/src/gui/image/qimagepixmapcleanuphooks_p.h @@ -70,18 +70,27 @@ public: static QImagePixmapCleanupHooks *instance(); - void addPixmapHook(_qt_pixmap_cleanup_hook_pm); + // Gets called when a pixmap is about to be modified: + void addPixmapModificationHook(_qt_pixmap_cleanup_hook_pm); + + // Gets called when a pixmap is about to be destroyed: + void addPixmapDestructionHook(_qt_pixmap_cleanup_hook_pm); + + // Gets called when an image is about to be modified or destroyed: void addImageHook(_qt_image_cleanup_hook_64); - void removePixmapHook(_qt_pixmap_cleanup_hook_pm); + void removePixmapModificationHook(_qt_pixmap_cleanup_hook_pm); + void removePixmapDestructionHook(_qt_pixmap_cleanup_hook_pm); void removeImageHook(_qt_image_cleanup_hook_64); - static void executePixmapHooks(QPixmap*); + static void executePixmapModificationHooks(QPixmap*); + static void executePixmapDestructionHooks(QPixmap*); static void executeImageHooks(qint64 key); private: QList<_qt_image_cleanup_hook_64> imageHooks; - QList<_qt_pixmap_cleanup_hook_pm> pixmapHooks; + QList<_qt_pixmap_cleanup_hook_pm> pixmapModificationHooks; + QList<_qt_pixmap_cleanup_hook_pm> pixmapDestructionHooks; }; QT_END_NAMESPACE diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index bf6c9ae..f94552d 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -322,8 +322,9 @@ QPixmap::QPixmap(const char * const xpm[]) QPixmap::~QPixmap() { - if (data->is_cached && data->ref == 1) - QImagePixmapCleanupHooks::executePixmapHooks(this); + Q_ASSERT(data->ref >= 1); // Catch if ref-counting changes again + if (data->is_cached && data->ref == 1) // ref will be decrememnted after destructor returns + QImagePixmapCleanupHooks::executePixmapDestructionHooks(this); } /*! @@ -1917,7 +1918,7 @@ void QPixmap::detach() } if (data->is_cached && data->ref == 1) - QImagePixmapCleanupHooks::executePixmapHooks(this); + QImagePixmapCleanupHooks::executePixmapModificationHooks(this); #if defined(Q_WS_MAC) QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast(data.data()) : 0; diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 39f04d4..97e3dad 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -1584,7 +1584,10 @@ QGLTextureCache::QGLTextureCache() Q_ASSERT(qt_gl_texture_cache == 0); qt_gl_texture_cache = this; - QImagePixmapCleanupHooks::instance()->addPixmapHook(pixmapCleanupHook); + QImagePixmapCleanupHooks::instance()->addPixmapModificationHook(cleanupTextures); +#ifdef Q_WS_X11 + QImagePixmapCleanupHooks::instance()->addPixmapDestructionHook(cleanupPixmapSurfaces); +#endif QImagePixmapCleanupHooks::instance()->addImageHook(imageCleanupHook); } @@ -1592,7 +1595,10 @@ QGLTextureCache::~QGLTextureCache() { qt_gl_texture_cache = 0; - QImagePixmapCleanupHooks::instance()->removePixmapHook(pixmapCleanupHook); + QImagePixmapCleanupHooks::instance()->removePixmapModificationHook(cleanupTextures); +#ifdef Q_WS_X11 + QImagePixmapCleanupHooks::instance()->removePixmapDestructionHook(cleanupPixmapSurfaces); +#endif QImagePixmapCleanupHooks::instance()->removeImageHook(imageCleanupHook); } @@ -1660,7 +1666,7 @@ void QGLTextureCache::imageCleanupHook(qint64 cacheKey) } -void QGLTextureCache::pixmapCleanupHook(QPixmap* pixmap) +void QGLTextureCache::cleanupTextures(QPixmap* pixmap) { // ### remove when the GL texture cache becomes thread-safe if (qApp->thread() == QThread::currentThread()) { @@ -1669,14 +1675,21 @@ void QGLTextureCache::pixmapCleanupHook(QPixmap* pixmap) if (texture && texture->options & QGLContext::MemoryManagedBindOption) instance()->remove(cacheKey); } +} + #if defined(Q_WS_X11) +void QGLTextureCache::cleanupPixmapSurfaces(QPixmap* pixmap) +{ + // Remove any bound textures first: + cleanupTextures(pixmap); + QPixmapData *pd = pixmap->data_ptr().data(); if (pd->classId() == QPixmapData::X11Class) { Q_ASSERT(pd->ref == 1); // Make sure reference counting isn't broken QGLContextPrivate::destroyGlSurfaceForPixmap(pd); } -#endif } +#endif void QGLTextureCache::deleteIfEmpty() { diff --git a/src/opengl/qgl_p.h b/src/opengl/qgl_p.h index 129e7f7..9a17c67 100644 --- a/src/opengl/qgl_p.h +++ b/src/opengl/qgl_p.h @@ -498,7 +498,11 @@ public: static QGLTextureCache *instance(); static void deleteIfEmpty(); static void imageCleanupHook(qint64 cacheKey); - static void pixmapCleanupHook(QPixmap* pixmap); + static void cleanupTextures(QPixmap* pixmap); +#ifdef Q_WS_X11 + // X11 needs to catch pixmap data destruction to delete EGL/GLX pixmap surfaces + static void cleanupPixmapSurfaces(QPixmap* pixmap); +#endif private: QCache m_cache; -- cgit v0.12 From 0d0cba294980c5fbb26a2fd3e930c94606e93d03 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 13 Oct 2009 14:21:51 +0200 Subject: Add a new QX11GLPixmapData which renders to X pixmaps using GL Enable it by setting QT_USE_X11GL_PIXMAPS environment variable while using the -graphicssystem opengl --- src/gui/image/qpixmap_x11_p.h | 1 + src/gui/painting/qpaintengine.h | 1 + src/opengl/opengl.pro | 7 +- src/opengl/qgl.h | 1 + src/opengl/qgl_x11egl.cpp | 5 +- src/opengl/qglpaintdevice.cpp | 14 ++- src/opengl/qgraphicssystem_gl.cpp | 9 ++ src/opengl/qpixmapdata_x11gl_egl.cpp | 183 +++++++++++++++++++++++++++++++++++ src/opengl/qpixmapdata_x11gl_p.h | 88 +++++++++++++++++ 9 files changed, 304 insertions(+), 5 deletions(-) create mode 100644 src/opengl/qpixmapdata_x11gl_egl.cpp create mode 100644 src/opengl/qpixmapdata_x11gl_p.h diff --git a/src/gui/image/qpixmap_x11_p.h b/src/gui/image/qpixmap_x11_p.h index 2d6672d..8ce7c0d 100644 --- a/src/gui/image/qpixmap_x11_p.h +++ b/src/gui/image/qpixmap_x11_p.h @@ -103,6 +103,7 @@ private: friend class QRasterWindowSurface; friend class QGLContextPrivate; // Needs to access xinfo, gl_surface & flags friend class QEglContext; // Needs gl_surface + friend class QX11GLPixmapData; // Needs gl_surface friend bool qt_createEGLSurfaceForPixmap(QPixmapData*, bool); // Needs gl_surface void release(); diff --git a/src/gui/painting/qpaintengine.h b/src/gui/painting/qpaintengine.h index 5b82e7b..bf4b4ea 100644 --- a/src/gui/painting/qpaintengine.h +++ b/src/gui/painting/qpaintengine.h @@ -278,6 +278,7 @@ private: friend class QWin32PaintEnginePrivate; friend class QMacCGContext; friend class QPreviewPaintEngine; + friend class QX11GLPixmapData; }; diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 058016e..961c781 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -82,9 +82,12 @@ x11 { contains(QT_CONFIG, opengles1)|contains(QT_CONFIG, opengles1cl)|contains(QT_CONFIG, opengles2) { SOURCES += qgl_x11egl.cpp \ qglpixelbuffer_egl.cpp \ - qgl_egl.cpp + qgl_egl.cpp \ + qpixmapdata_x11gl_egl.cpp + + HEADERS += qgl_egl_p.h \ + qpixmapdata_x11gl_p.h - HEADERS += qgl_egl_p.h } else { SOURCES += qgl_x11.cpp \ diff --git a/src/opengl/qgl.h b/src/opengl/qgl.h index b1c1317..e14e7fb 100644 --- a/src/opengl/qgl.h +++ b/src/opengl/qgl.h @@ -411,6 +411,7 @@ private: friend class QGLFramebufferObjectPrivate; friend class QGLFBOGLPaintDevice; friend class QGLPaintDevice; + friend class QX11GLPixmapData; private: Q_DISABLE_COPY(QGLContext) }; diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index 971a660..fb08741 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -513,8 +513,11 @@ bool Q_OPENGL_EXPORT qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnl pixmapConfig, (EGLNativePixmapType) pixmapData->handle(), pixmapAttribs.properties()); +// qDebug("qt_createEGLSurfaceForPixmap() created surface 0x%x for pixmap 0x%x", +// pixmapSurface, pixmapData->handle()); if (pixmapSurface == EGL_NO_SURFACE) { - qWarning("Failed to create a pixmap surface using config %d", (int)pixmapConfig); + qWarning() << "Failed to create a pixmap surface using config" << (int)pixmapConfig + << ":" << QEglContext::errorString(eglGetError()); return false; } diff --git a/src/opengl/qglpaintdevice.cpp b/src/opengl/qglpaintdevice.cpp index e68a4b9..2867de5 100644 --- a/src/opengl/qglpaintdevice.cpp +++ b/src/opengl/qglpaintdevice.cpp @@ -44,6 +44,9 @@ #include #include #include +#ifdef Q_WS_X11 +#include +#endif #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) #include @@ -81,6 +84,7 @@ void QGLPaintDevice::beginPaint() // explicitly unbind. Otherwise the painting will go into // the previous FBO instead of to the window. m_previousFBO = ctx->d_func()->current_fbo; + if (m_previousFBO != m_thisFBO) { ctx->d_ptr->current_fbo = m_thisFBO; glBindFramebuffer(GL_FRAMEBUFFER_EXT, m_thisFBO); @@ -186,8 +190,14 @@ QGLPaintDevice* QGLPaintDevice::getDevice(QPaintDevice* pd) case QInternal::Pixmap: { #if !defined(QT_OPENGL_ES_1) && !defined(QT_OPENGL_ES_1_CL) QPixmapData* pmd = static_cast(pd)->pixmapData(); - Q_ASSERT(pmd->classId() == QPixmapData::OpenGLClass); - glpd = static_cast(pmd)->glDevice(); + if (pmd->classId() == QPixmapData::OpenGLClass) + glpd = static_cast(pmd)->glDevice(); +#ifdef Q_WS_X11 + else if (pmd->classId() == QPixmapData::X11Class) + glpd = static_cast(pmd); +#endif + else + qWarning("Pixmap type not supported for GL rendering"); #else qWarning("Pixmap render targets not supported on OpenGL ES 1.x"); #endif diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp index 3e7fece..60d58a7 100644 --- a/src/opengl/qgraphicssystem_gl.cpp +++ b/src/opengl/qgraphicssystem_gl.cpp @@ -47,12 +47,21 @@ #include "private/qgl_p.h" #include +#ifdef Q_WS_X11 +#include "private/qpixmapdata_x11gl_p.h" +#endif + QT_BEGIN_NAMESPACE extern QGLWidget *qt_gl_getShareWidget(); QPixmapData *QGLGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { +#ifdef Q_WS_X11 + if (type == QPixmapData::PixmapType && QX11GLPixmapData::hasX11GLPixmaps()) + return new QX11GLPixmapData(); +#endif + return new QGLPixmapData(type); } diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp new file mode 100644 index 0000000..1590ba5 --- /dev/null +++ b/src/opengl/qpixmapdata_x11gl_egl.cpp @@ -0,0 +1,183 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +#include "qpixmapdata_x11gl_p.h" + +QT_BEGIN_NAMESPACE + +extern EGLConfig qt_chooseEGLConfigForPixmap(bool hasAlpha, bool readOnly); // in qgl_x11egl.cpp +extern bool qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnly); // in qgl_x11egl.cpp + +static EGLContext qPixmapSharedEglContext = EGL_NO_CONTEXT; + +void QX11GLPixmapData::createPixmapSharedContext(EGLConfig config) +{ + eglBindAPI(EGL_OPENGL_ES_API); + EGLint contextAttribs[] = { +#if defined(QT_OPENGL_ES_2) + EGL_CONTEXT_CLIENT_VERSION, 2, +#endif + EGL_NONE + }; + qPixmapSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0), config, 0, contextAttribs); +// qDebug("QX11GLPixmapData::createPixmapSharedContext() Created ctx 0x%x for config %d", qPixmapSharedEglContext, config); +} + +bool QX11GLPixmapData::hasX11GLPixmaps() +{ + static bool checkedForX11Pixmaps = false; + static bool haveX11Pixmaps = false; + + if (checkedForX11Pixmaps) + return haveX11Pixmaps; + + checkedForX11Pixmaps = true; + + do { + if (qgetenv("QT_USE_X11GL_PIXMAPS").isEmpty()) + break; + + // First, check we actually have an EGL config which supports pixmaps + EGLConfig config = qt_chooseEGLConfigForPixmap(true, false); + if (config == 0) + break; + + // Now try to actually create an EGL pixmap surface + QX11PixmapData *pd = new QX11PixmapData(QPixmapData::PixmapType); + pd->resize(100, 100); + bool success = qt_createEGLSurfaceForPixmap(pd, false); + if (!success) + break; + + createPixmapSharedContext(config); + + haveX11Pixmaps = eglMakeCurrent(QEglContext::defaultDisplay(0), + (EGLSurface)pd->gl_surface, (EGLSurface)pd->gl_surface, + qPixmapSharedEglContext); + + eglMakeCurrent(QEglContext::defaultDisplay(0), + EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + QGLContextPrivate::destroyGlSurfaceForPixmap(pd); + delete pd; + } while (0); + + if (haveX11Pixmaps) + qDebug("QX11GLPixmapData is supported"); + + return haveX11Pixmaps; +} + +QX11GLPixmapData::QX11GLPixmapData() + : QX11PixmapData(QPixmapData::PixmapType), + ctx(0) +{ +} + +QX11GLPixmapData::~QX11GLPixmapData() +{ +} + +static QGL2PaintEngineEx* qt_gl2_engine_for_pixmaps = 0; + +QPaintEngine* QX11GLPixmapData::paintEngine() const +{ + // We need to create the context before beginPaint - do it here: + if (!ctx) { + ctx = new QGLContext(glFormat()); + if (ctx->d_func()->eglContext == 0) + ctx->d_func()->eglContext = new QEglContext(); + ctx->d_func()->eglContext->openDisplay(0); // ;-) + ctx->d_func()->eglContext->setApi(QEgl::OpenGL); + ctx->d_func()->eglContext->setContext(qPixmapSharedEglContext); + } + + if (!qt_gl2_engine_for_pixmaps) + qt_gl2_engine_for_pixmaps = new QGL2PaintEngineEx(); + + // Support multiple painters on multiple pixmaps simultaniously + if (qt_gl2_engine_for_pixmaps->isActive()) { + QPaintEngine* engine = new QGL2PaintEngineEx(); + engine->setAutoDestruct(true); + return engine; + } + + return qt_gl2_engine_for_pixmaps; +} + +void QX11GLPixmapData::beginPaint() +{ + if ((EGLSurface)gl_surface == EGL_NO_SURFACE) { + qt_createEGLSurfaceForPixmap(this, false); + ctx->d_func()->eglSurface = (EGLSurface)gl_surface; + ctx->d_func()->valid = true; // ;-) + } + + QGLPaintDevice::beginPaint(); +} + +void QX11GLPixmapData::endPaint() +{ + glFinish(); + QGLPaintDevice::endPaint(); +} + +QGLContext* QX11GLPixmapData::context() const +{ + return ctx; +} + +QSize QX11GLPixmapData::size() const +{ + return QSize(w, h); +} + + +QGLFormat QX11GLPixmapData::glFormat() +{ + return QGLFormat::defaultFormat(); //### +} + +QT_END_NAMESPACE diff --git a/src/opengl/qpixmapdata_x11gl_p.h b/src/opengl/qpixmapdata_x11gl_p.h new file mode 100644 index 0000000..3e09ba9 --- /dev/null +++ b/src/opengl/qpixmapdata_x11gl_p.h @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPIXMAPDATA_X11GL_P_H +#define QPIXMAPDATA_X11GL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +#include + +QT_BEGIN_NAMESPACE + +class QX11GLPixmapData : public QX11PixmapData, public QGLPaintDevice +{ +public: + QX11GLPixmapData(); + virtual ~QX11GLPixmapData(); + + // Re-implemented from QGLPaintDevice + QPaintEngine* paintEngine() const; // Also re-implements QX11PixmapData::paintEngine + void beginPaint(); + void endPaint(); + QGLContext* context() const; + QSize size() const; + + + static bool hasX11GLPixmaps(); + static QGLFormat glFormat(); +private: + static void createPixmapSharedContext(EGLConfig config); + mutable QGLContext* ctx; +}; + + +QT_END_NAMESPACE + +#endif // QPIXMAPDATA_X11GL_P_H -- cgit v0.12 From 8e6c1d52ed9c233e753fc93bec93c8d909c95002 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Wed, 14 Oct 2009 14:25:09 +0200 Subject: Add an assert testing the cleanup hooks exist before executing them Reviewed-By: TrustMe --- src/gui/image/qimagepixmapcleanuphooks.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/image/qimagepixmapcleanuphooks.cpp b/src/gui/image/qimagepixmapcleanuphooks.cpp index 138eb0d..ac30646 100644 --- a/src/gui/image/qimagepixmapcleanuphooks.cpp +++ b/src/gui/image/qimagepixmapcleanuphooks.cpp @@ -124,6 +124,7 @@ void QImagePixmapCleanupHooks::executePixmapDestructionHooks(QPixmap* pm) void QImagePixmapCleanupHooks::executeImageHooks(qint64 key) { + Q_ASSERT(qt_image_and_pixmap_cleanup_hooks); for (int i = 0; i < qt_image_and_pixmap_cleanup_hooks->imageHooks.count(); ++i) qt_image_and_pixmap_cleanup_hooks->imageHooks[i](key); -- cgit v0.12 From 34e25637f11972c848f78757fe023a9b1360edc9 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Mon, 19 Oct 2009 13:30:50 +0200 Subject: Use different GL contexts for ARGB & RGB pixmaps On 16 bpp systems, RGB pixmaps are 16-bit whereas ARGB pixmaps are 32-bit. This means two different EGL configs are used which are incompatable with each other. As a result, we have to use 2 different EGL contexts - one for each config. Reviewed-By: Trustme --- src/opengl/qpixmapdata_x11gl_egl.cpp | 131 ++++++++++++++++++++++++++--------- 1 file changed, 100 insertions(+), 31 deletions(-) diff --git a/src/opengl/qpixmapdata_x11gl_egl.cpp b/src/opengl/qpixmapdata_x11gl_egl.cpp index 1590ba5..813e6c8 100644 --- a/src/opengl/qpixmapdata_x11gl_egl.cpp +++ b/src/opengl/qpixmapdata_x11gl_egl.cpp @@ -51,20 +51,10 @@ QT_BEGIN_NAMESPACE extern EGLConfig qt_chooseEGLConfigForPixmap(bool hasAlpha, bool readOnly); // in qgl_x11egl.cpp extern bool qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnly); // in qgl_x11egl.cpp -static EGLContext qPixmapSharedEglContext = EGL_NO_CONTEXT; - -void QX11GLPixmapData::createPixmapSharedContext(EGLConfig config) -{ - eglBindAPI(EGL_OPENGL_ES_API); - EGLint contextAttribs[] = { -#if defined(QT_OPENGL_ES_2) - EGL_CONTEXT_CLIENT_VERSION, 2, -#endif - EGL_NONE - }; - qPixmapSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0), config, 0, contextAttribs); -// qDebug("QX11GLPixmapData::createPixmapSharedContext() Created ctx 0x%x for config %d", qPixmapSharedEglContext, config); -} +// On 16bpp systems, RGB & ARGB pixmaps are different bit-depths and therefore need +// different contexts: +static EGLContext qPixmapARGBSharedEglContext = EGL_NO_CONTEXT; +static EGLContext qPixmapRGBSharedEglContext = EGL_NO_CONTEXT; bool QX11GLPixmapData::hasX11GLPixmaps() { @@ -76,36 +66,113 @@ bool QX11GLPixmapData::hasX11GLPixmaps() checkedForX11Pixmaps = true; + QX11PixmapData *argbPixmapData = 0; + QX11PixmapData *rgbPixmapData = 0; do { if (qgetenv("QT_USE_X11GL_PIXMAPS").isEmpty()) break; - // First, check we actually have an EGL config which supports pixmaps - EGLConfig config = qt_chooseEGLConfigForPixmap(true, false); - if (config == 0) - break; + // Check we actually have EGL configs which support pixmaps + EGLConfig argbConfig = qt_chooseEGLConfigForPixmap(true, false); + EGLConfig rgbConfig = qt_chooseEGLConfigForPixmap(false, false); - // Now try to actually create an EGL pixmap surface - QX11PixmapData *pd = new QX11PixmapData(QPixmapData::PixmapType); - pd->resize(100, 100); - bool success = qt_createEGLSurfaceForPixmap(pd, false); - if (!success) + if (argbConfig == 0 || rgbConfig == 0) break; - createPixmapSharedContext(config); + // Create the shared contexts: + eglBindAPI(EGL_OPENGL_ES_API); + EGLint contextAttribs[] = { +#if defined(QT_OPENGL_ES_2) + EGL_CONTEXT_CLIENT_VERSION, 2, +#endif + EGL_NONE + }; + qPixmapARGBSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0), + argbConfig, 0, contextAttribs); + + if (argbConfig == rgbConfig) { + // If the configs are the same, we can re-use the same context. + qPixmapRGBSharedEglContext = qPixmapARGBSharedEglContext; + } else { + qPixmapRGBSharedEglContext = eglCreateContext(QEglContext::defaultDisplay(0), + rgbConfig, 0, contextAttribs); + } + + argbPixmapData = new QX11PixmapData(QPixmapData::PixmapType); + argbPixmapData->resize(100, 100); + argbPixmapData->fill(Qt::transparent); // Force ARGB + + if (!qt_createEGLSurfaceForPixmap(argbPixmapData, false)) + break; haveX11Pixmaps = eglMakeCurrent(QEglContext::defaultDisplay(0), - (EGLSurface)pd->gl_surface, (EGLSurface)pd->gl_surface, - qPixmapSharedEglContext); + (EGLSurface)argbPixmapData->gl_surface, + (EGLSurface)argbPixmapData->gl_surface, + qPixmapARGBSharedEglContext); + if (!haveX11Pixmaps) { + EGLint err = eglGetError(); + qWarning() << "Unable to make pixmap config current:" << err << QEglContext::errorString(err); + break; + } + + // If the ARGB & RGB configs are the same, we don't need to check RGB too + if (haveX11Pixmaps && (argbConfig != rgbConfig)) { + rgbPixmapData = new QX11PixmapData(QPixmapData::PixmapType); + rgbPixmapData->resize(100, 100); + rgbPixmapData->fill(Qt::red); + + // Try to actually create an EGL pixmap surface + if (!qt_createEGLSurfaceForPixmap(rgbPixmapData, false)) + break; + + haveX11Pixmaps = eglMakeCurrent(QEglContext::defaultDisplay(0), + (EGLSurface)rgbPixmapData->gl_surface, + (EGLSurface)rgbPixmapData->gl_surface, + qPixmapRGBSharedEglContext); + if (!haveX11Pixmaps) { + EGLint err = eglGetError(); + qWarning() << "Unable to make pixmap config current:" << err << QEglContext::errorString(err); + break; + } + } + } while (0); + if (qPixmapARGBSharedEglContext || qPixmapRGBSharedEglContext) { eglMakeCurrent(QEglContext::defaultDisplay(0), EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - QGLContextPrivate::destroyGlSurfaceForPixmap(pd); - delete pd; - } while (0); + } + + if (argbPixmapData) { + if (argbPixmapData->gl_surface) + QGLContextPrivate::destroyGlSurfaceForPixmap(argbPixmapData); + delete argbPixmapData; + argbPixmapData = 0; + } + if (rgbPixmapData) { + if (rgbPixmapData->gl_surface) + QGLContextPrivate::destroyGlSurfaceForPixmap(rgbPixmapData); + delete rgbPixmapData; + rgbPixmapData = 0; + } + + if (!haveX11Pixmaps) { + // Clean up the context(s) if we can't use X11GL pixmaps + if (qPixmapARGBSharedEglContext != EGL_NO_CONTEXT) + eglDestroyContext(QEglContext::defaultDisplay(0), qPixmapARGBSharedEglContext); + + if (qPixmapRGBSharedEglContext != qPixmapARGBSharedEglContext && + qPixmapRGBSharedEglContext != EGL_NO_CONTEXT) + { + eglDestroyContext(QEglContext::defaultDisplay(0), qPixmapRGBSharedEglContext); + } + qPixmapRGBSharedEglContext = EGL_NO_CONTEXT; + qPixmapARGBSharedEglContext = EGL_NO_CONTEXT; + } if (haveX11Pixmaps) qDebug("QX11GLPixmapData is supported"); + else + qDebug("QX11GLPixmapData is *NOT* being used"); return haveX11Pixmaps; } @@ -131,7 +198,8 @@ QPaintEngine* QX11GLPixmapData::paintEngine() const ctx->d_func()->eglContext = new QEglContext(); ctx->d_func()->eglContext->openDisplay(0); // ;-) ctx->d_func()->eglContext->setApi(QEgl::OpenGL); - ctx->d_func()->eglContext->setContext(qPixmapSharedEglContext); + ctx->d_func()->eglContext->setContext(hasAlphaChannel() ? qPixmapARGBSharedEglContext + : qPixmapRGBSharedEglContext); } if (!qt_gl2_engine_for_pixmaps) @@ -139,6 +207,7 @@ QPaintEngine* QX11GLPixmapData::paintEngine() const // Support multiple painters on multiple pixmaps simultaniously if (qt_gl2_engine_for_pixmaps->isActive()) { + qWarning("Pixmap paint engine already active"); QPaintEngine* engine = new QGL2PaintEngineEx(); engine->setAutoDestruct(true); return engine; @@ -149,12 +218,12 @@ QPaintEngine* QX11GLPixmapData::paintEngine() const void QX11GLPixmapData::beginPaint() { +// qDebug("QX11GLPixmapData::beginPaint()"); if ((EGLSurface)gl_surface == EGL_NO_SURFACE) { qt_createEGLSurfaceForPixmap(this, false); ctx->d_func()->eglSurface = (EGLSurface)gl_surface; ctx->d_func()->valid = true; // ;-) } - QGLPaintDevice::beginPaint(); } -- cgit v0.12 From 43b3307bebb9600954e48b0a3b341d5d9b2b26de Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 20 Oct 2009 08:57:39 +0200 Subject: Fix build on desktop X11 Hash-Define out X11GL pixmap data until the GLX implementation is ready. --- src/opengl/qgraphicssystem_gl.cpp | 2 +- src/opengl/qpixmapdata_x11gl_p.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp index 60d58a7..0ee1e82 100644 --- a/src/opengl/qgraphicssystem_gl.cpp +++ b/src/opengl/qgraphicssystem_gl.cpp @@ -57,7 +57,7 @@ extern QGLWidget *qt_gl_getShareWidget(); QPixmapData *QGLGraphicsSystem::createPixmapData(QPixmapData::PixelType type) const { -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) if (type == QPixmapData::PixmapType && QX11GLPixmapData::hasX11GLPixmaps()) return new QX11GLPixmapData(); #endif diff --git a/src/opengl/qpixmapdata_x11gl_p.h b/src/opengl/qpixmapdata_x11gl_p.h index 3e09ba9..bba9bb3 100644 --- a/src/opengl/qpixmapdata_x11gl_p.h +++ b/src/opengl/qpixmapdata_x11gl_p.h @@ -74,11 +74,9 @@ public: QGLContext* context() const; QSize size() const; - static bool hasX11GLPixmaps(); static QGLFormat glFormat(); private: - static void createPixmapSharedContext(EGLConfig config); mutable QGLContext* ctx; }; -- cgit v0.12 From 9d91a56ad5e39ddb237e10819a371e78defdf359 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 19 Oct 2009 16:23:47 +0200 Subject: Backport benchmarks/qnetworkreply to 4.5 Reviewed-by: TrustMe --- tests/benchmarks/benchmarks.pro | 1 + tests/benchmarks/qnetworkreply/qnetworkreply.pro | 13 ++++ .../benchmarks/qnetworkreply/tst_qnetworkreply.cpp | 74 ++++++++++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 tests/benchmarks/qnetworkreply/qnetworkreply.pro create mode 100644 tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro index 8e2c243..fb2b9ea 100644 --- a/tests/benchmarks/benchmarks.pro +++ b/tests/benchmarks/benchmarks.pro @@ -8,6 +8,7 @@ SUBDIRS = containers-associative \ qpixmap \ blendbench \ qstringlist \ + qnetworkreply \ qobject \ qrect \ qregexp \ diff --git a/tests/benchmarks/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/qnetworkreply/qnetworkreply.pro new file mode 100644 index 0000000..1e67d81 --- /dev/null +++ b/tests/benchmarks/qnetworkreply/qnetworkreply.pro @@ -0,0 +1,13 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qnetworkreply +DEPENDPATH += . +INCLUDEPATH += . + +QT -= gui +QT += network + +CONFIG += release + +# Input +SOURCES += tst_qnetworkreply.cpp diff --git a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp new file mode 100644 index 0000000..666e4f1 --- /dev/null +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +// This file contains benchmarks for QNetworkReply functions. + +#include +#include +#include +#include +#include +#include +#include "../../auto/network-settings.h" + +class tst_qnetworkreply : public QObject +{ + Q_OBJECT +private slots: + void httpLatency(); + +}; + +void tst_qnetworkreply::httpLatency() +{ + QNetworkAccessManager manager; + QBENCHMARK{ + QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/")); + QNetworkReply* reply = manager.get(request); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + delete reply; + } +} + +QTEST_MAIN(tst_qnetworkreply) + +#include "main.moc" -- cgit v0.12 From 5fd8c58dde0c61a723ab124ac74c863f67288a14 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Mon, 19 Oct 2009 17:16:20 +0200 Subject: Add a up/down benchmark to benchmarks/qnetworkreply Reviewed-by: Peter Hartmann --- .../benchmarks/qnetworkreply/tst_qnetworkreply.cpp | 39 +++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp index 666e4f1..e622d62 100644 --- a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -53,7 +53,10 @@ class tst_qnetworkreply : public QObject Q_OBJECT private slots: void httpLatency(); - +#ifndef QT_NO_OPENSSL + void echoPerformance_data(); + void echoPerformance(); +#endif }; void tst_qnetworkreply::httpLatency() @@ -69,6 +72,40 @@ void tst_qnetworkreply::httpLatency() } } +#ifndef QT_NO_OPENSSL +void tst_qnetworkreply::echoPerformance_data() +{ + QTest::addColumn("ssl"); + QTest::newRow("no_ssl") << false; + QTest::newRow("ssl") << true; +} + +void tst_qnetworkreply::echoPerformance() +{ + QFETCH(bool, ssl); + QNetworkAccessManager manager; + QNetworkRequest request(QUrl((ssl ? "https://" : "http://") + QtNetworkSettings::serverName() + "/qtest/cgi-bin/echo.cgi")); + + QByteArray data; + data.resize(1024*1024*10); // 10 MB + // init with garbage. needed so ssl cannot compress it in an efficient way. + for (int i = 0; i < data.size() / sizeof(int); i++) { + int r = qrand(); + data.data()[i*sizeof(int)] = r; + } + + QBENCHMARK{ + QNetworkReply* reply = manager.post(request, data); + connect(reply, SIGNAL(sslErrors( const QList &)), reply, SLOT(ignoreSslErrors())); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + QVERIFY(reply->error() == QNetworkReply::NoError); + delete reply; + } +} +#endif + QTEST_MAIN(tst_qnetworkreply) #include "main.moc" -- cgit v0.12 From 23b058cdf3d98439ec784a3d430d54e5aed75c7b Mon Sep 17 00:00:00 2001 From: Trond Kjernaasen Date: Tue, 20 Oct 2009 10:37:09 +0200 Subject: Fixed a stencil clearing bug in the GL 1 engine. If the system clip changed the stencil buffer wasn't necessarily updated correctly. Use a region to keep track of the dirty areas in the stencil buffer, like we do in the GL 2 engine. Reviewed-by: Samuel --- src/opengl/qpaintengine_opengl.cpp | 40 ++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/opengl/qpaintengine_opengl.cpp b/src/opengl/qpaintengine_opengl.cpp index 80628a2..aa6b6c9 100644 --- a/src/opengl/qpaintengine_opengl.cpp +++ b/src/opengl/qpaintengine_opengl.cpp @@ -746,7 +746,6 @@ public: uint has_brush : 1; uint has_fast_pen : 1; uint use_stencil_method : 1; - uint dirty_stencil : 1; uint dirty_drawable_texture : 1; uint has_stencil_face_ext : 1; uint use_fragment_programs : 1; @@ -757,6 +756,8 @@ public: uint use_system_clip : 1; uint use_emulation : 1; + QRegion dirty_stencil; + void updateUseEmulation(); QTransform matrix; @@ -1259,7 +1260,9 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) d->matrix = QTransform(); d->has_antialiasing = false; d->high_quality_antialiasing = false; - d->dirty_stencil = true; + + QSize sz(d->device->size()); + d->dirty_stencil = QRect(0, 0, sz.width(), sz.height()); d->use_emulation = false; @@ -1347,7 +1350,6 @@ bool QOpenGLPaintEngine::begin(QPaintDevice *pdev) d->offscreen.begin(); - QSize sz(d->device->size()); glViewport(0, 0, sz.width(), sz.height()); // XXX (Embedded): We need a solution for GLWidgets that draw in a part or a bigger surface... glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -1949,34 +1951,34 @@ void QOpenGLPaintEnginePrivate::fillVertexArray(Qt::FillRule fillRule) { Q_Q(QOpenGLPaintEngine); - if (dirty_stencil) { - disableClipping(); + QRect rect = dirty_stencil.boundingRect(); - if (use_system_clip) { - glEnable(GL_SCISSOR_TEST); + if (use_system_clip) + rect = q->systemClip().intersected(dirty_stencil).boundingRect(); - QRect rect = q->systemClip().boundingRect(); + glStencilMask(~0); - const int left = rect.left(); - const int width = rect.width(); - const int bottom = device->size().height() - (rect.bottom() + 1); - const int height = rect.height(); + if (!rect.isEmpty()) { + disableClipping(); - glScissor(left, bottom, width, height); - } + glEnable(GL_SCISSOR_TEST); + + const int left = rect.left(); + const int width = rect.width(); + const int bottom = device->size().height() - (rect.bottom() + 1); + const int height = rect.height(); + + glScissor(left, bottom, width, height); glClearStencil(0); glClear(GL_STENCIL_BUFFER_BIT); - dirty_stencil = false; + dirty_stencil -= rect; - if (use_system_clip) - glDisable(GL_SCISSOR_TEST); + glDisable(GL_SCISSOR_TEST); enableClipping(); } - glStencilMask(~0); - // Enable stencil. glEnable(GL_STENCIL_TEST); -- cgit v0.12 From a210a1efb3a255235ab22e618c61d0aaccba3d9f Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 20 Oct 2009 10:39:56 +0200 Subject: QToolButton popup menu is shown at wrong position when embedded in a QGraphicsView. The main problem here is that QWidget assume that they are in the screen somewhere, which means inside the available geometry provided by QDesktopWidget. But in QGraphicsView the button can be in a position that is way bigger than the screen resolution. Lot of widgets make this assumption when positionning subpopups or submenus. Instead of applying the same code on tons of QWidgets, it's better to have an helper function in desktop widget which catch this case. It's not pretty (since it has nothing to do with QDesktopWidget) but we don't have better solution. Task-number:QTBUG-3822 Reviewed-by:brad --- src/gui/kernel/kernel.pri | 1 + src/gui/kernel/qdesktopwidget.cpp | 67 +++++++++++++++++++++++++++++++++++++++ src/gui/kernel/qdesktopwidget.h | 6 ++-- src/gui/kernel/qwidget.cpp | 22 ++----------- src/gui/kernel/qwidget_p.h | 53 +++++++++++++++++++++++++++++-- src/gui/widgets/qmenu.cpp | 31 +++++++++++++++--- src/gui/widgets/qmenu_p.h | 3 +- src/gui/widgets/qpushbutton.cpp | 4 +-- 8 files changed, 155 insertions(+), 32 deletions(-) create mode 100644 src/gui/kernel/qdesktopwidget.cpp diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 53c2611..8859358 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -84,6 +84,7 @@ SOURCES += \ kernel/qgesturerecognizer.cpp \ kernel/qgesturemanager.cpp \ kernel/qsoftkeymanager.cpp \ + kernel/qdesktopwidget.cpp \ kernel/qguiplatformplugin.cpp win32 { diff --git a/src/gui/kernel/qdesktopwidget.cpp b/src/gui/kernel/qdesktopwidget.cpp new file mode 100644 index 0000000..b1e1008 --- /dev/null +++ b/src/gui/kernel/qdesktopwidget.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qglobal.h" + +QT_BEGIN_NAMESPACE + +#include "qdesktopwidget.h" +#include "qwidget_p.h" + +const QRect QDesktopWidget::screenGeometry(const QWidget *widget) const +{ + QRect rect = QWidgetPrivate::screenGeometry(widget); + if (rect.isNull()) + return screenGeometry(screenNumber(widget)); + else return rect; +} + +const QRect QDesktopWidget::availableGeometry(const QWidget *widget) const +{ + QRect rect = QWidgetPrivate::screenGeometry(widget); + if (rect.isNull()) + return availableGeometry(screenNumber(widget)); + else + return rect; +} + +QT_END_NAMESPACE + diff --git a/src/gui/kernel/qdesktopwidget.h b/src/gui/kernel/qdesktopwidget.h index 85f479e..6e3447c 100644 --- a/src/gui/kernel/qdesktopwidget.h +++ b/src/gui/kernel/qdesktopwidget.h @@ -75,14 +75,12 @@ public: QWidget *screen(int screen = -1); const QRect screenGeometry(int screen = -1) const; - const QRect screenGeometry(const QWidget *widget) const - { return screenGeometry(screenNumber(widget)); } + const QRect screenGeometry(const QWidget *widget) const; const QRect screenGeometry(const QPoint &point) const { return screenGeometry(screenNumber(point)); } const QRect availableGeometry(int screen = -1) const; - const QRect availableGeometry(const QWidget *widget) const - { return availableGeometry(screenNumber(widget)); } + const QRect availableGeometry(const QWidget *widget) const; const QRect availableGeometry(const QPoint &point) const { return availableGeometry(screenNumber(point)); } diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 7dc3ae9..e561aca 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -149,24 +149,6 @@ static inline bool hasBackingStoreSupport() #endif } -/*! - \internal - - Returns true if \a p or any of its parents enable the - Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and - QWidget::setParent() to determine whether it's necessary to embed the - widget into a QGraphicsProxyWidget or not. -*/ -static inline bool bypassGraphicsProxyWidget(QWidget *p) -{ - while (p) { - if (p->windowFlags() & Qt::BypassGraphicsProxyWidget) - return true; - p = p->parentWidget(); - } - return false; -} - #ifdef Q_WS_MAC # define QT_NO_PAINT_DEBUG #endif @@ -5473,6 +5455,7 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * return pixmap; } +#ifndef QT_NO_GRAPHICSVIEW /*! \internal @@ -5481,7 +5464,7 @@ QPixmap QWidgetEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint * If successful, the function returns the proxy that embeds the widget, or 0 if no embedded widget was found. */ -QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(QWidget *origin) +QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(const QWidget *origin) { if (origin) { QWExtra *extra = origin->d_func()->extra; @@ -5491,6 +5474,7 @@ QGraphicsProxyWidget * QWidgetPrivate::nearestGraphicsProxyWidget(QWidget *origi } return 0; } +#endif /*! \property QWidget::locale diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index a549740..2132474 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -63,7 +63,9 @@ #include "QtGui/qstyle.h" #include "QtGui/qapplication.h" #include - +#include "QtGui/qgraphicsproxywidget.h" +#include "QtGui/qgraphicsscene.h" +#include "QtGui/qgraphicsview.h" #include #ifdef Q_WS_WIN @@ -180,7 +182,9 @@ struct QWExtra { // Regular pointers (keep them together to avoid gaps on 64 bits architectures). void *glContext; // if the widget is hijacked by QGLWindowSurface QTLWExtra *topextra; // only useful for TLWs +#ifndef QT_NO_GRAPHICSVIEW QGraphicsProxyWidget *proxyWidget; // if the widget is embedded +#endif #ifndef QT_NO_CURSOR QCursor *curs; #endif @@ -235,6 +239,24 @@ struct QWExtra { #endif }; +/*! + \internal + + Returns true if \a p or any of its parents enable the + Qt::BypassGraphicsProxyWidget window flag. Used in QWidget::show() and + QWidget::setParent() to determine whether it's necessary to embed the + widget into a QGraphicsProxyWidget or not. +*/ +static inline bool bypassGraphicsProxyWidget(const QWidget *p) +{ + while (p) { + if (p->windowFlags() & Qt::BypassGraphicsProxyWidget) + return true; + p = p->parentWidget(); + } + return false; +} + class Q_GUI_EXPORT QWidgetPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QWidget) @@ -344,7 +366,9 @@ public: QPainter *beginSharedPainter(); bool endSharedPainter(); - static QGraphicsProxyWidget * nearestGraphicsProxyWidget(QWidget *origin); +#ifndef QT_NO_GRAPHICSVIEW + static QGraphicsProxyWidget * nearestGraphicsProxyWidget(const QWidget *origin); +#endif QWindowSurface *createDefaultWindowSurface(); QWindowSurface *createDefaultWindowSurface_sys(); void repaint_sys(const QRegion &rgn); @@ -441,6 +465,31 @@ public: void setModal_sys(); + // This is an helper function that return the available geometry for + // a widget and takes care is this one is in QGraphicsView. + // If the widget is not embed in a scene then the geometry available is + // null, we let QDesktopWidget decide for us. + static QRect screenGeometry(const QWidget *widget) + { + QRect screen; +#ifndef QT_NO_GRAPHICSVIEW + QGraphicsProxyWidget *ancestorProxy = widget->d_func()->nearestGraphicsProxyWidget(widget); + //It's embedded if it has an ancestor + if (ancestorProxy) { + if (!bypassGraphicsProxyWidget(widget)) { + // One view, let be smart and return the viewport rect then the popup is aligned + if (ancestorProxy->scene()->views().size() == 1) { + QGraphicsView *view = ancestorProxy->scene()->views().at(0); + screen = view->mapToScene(view->viewport()->rect()).boundingRect().toRect(); + } else { + screen = ancestorProxy->scene()->sceneRect().toRect(); + } + } + } +#endif + return screen; + } + inline void setRedirected(QPaintDevice *replacement, const QPoint &offset) { Q_ASSERT(q_func()->testAttribute(Qt::WA_WState_InPaintEvent)); diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 687e1bc..324bc90 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -180,6 +180,21 @@ int QMenuPrivate::scrollerHeight() const } //Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't +QRect QMenuPrivate::popupGeometry(const QWidget *widget) const +{ +#ifdef Q_WS_WIN + return QApplication::desktop()->screenGeometry(widget); +#elif defined Q_WS_X11 + if (X11->desktopEnvironment == DE_KDE) + return QApplication::desktop()->screenGeometry(widget); + else + return QApplication::desktop()->availableGeometry(widget); +#else + return QApplication::desktop()->availableGeometry(widget); +#endif +} + +//Windows and KDE allows menus to cover the taskbar, while GNOME and Mac don't QRect QMenuPrivate::popupGeometry(int screen) const { #ifdef Q_WS_WIN @@ -234,7 +249,7 @@ void QMenuPrivate::updateActionRects() const } int max_column_width = 0, - dh = popupGeometry(QApplication::desktop()->screenNumber(q)).height(), + dh = popupGeometry(q).height(), y = 0; QStyle *style = q->style(); QStyleOption opt; @@ -744,7 +759,7 @@ void QMenuPrivate::scrollMenu(QAction *action, QMenuScroller::ScrollLocation loc if (newScrollFlags & QMenuScroller::ScrollUp) newOffset -= vmargin; - QRect screen = popupGeometry(QApplication::desktop()->screenNumber(q)); + QRect screen = popupGeometry(q); const int desktopFrame = q->style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, q); if (q->height() < screen.height()-(desktopFrame*2)-1) { QRect geom = q->geometry(); @@ -1789,7 +1804,15 @@ void QMenu::popup(const QPoint &p, QAction *atAction) d->updateActionRects(); QPoint pos = p; QSize size = sizeHint(); - QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(p)); + QRect screen; +#ifndef QT_NO_GRAPHICSVIEW + bool isEmbedded = d->nearestGraphicsProxyWidget(this); + if (isEmbedded) + screen = d->popupGeometry(this); + else +#endif + screen = d->popupGeometry(QApplication::desktop()->screenNumber(p)); + const int desktopFrame = style()->pixelMetric(QStyle::PM_MenuDesktopFrameWidth, 0, this); bool adjustToDesktop = !window()->testAttribute(Qt::WA_DontShowOnScreen); #ifdef QT_KEYPAD_NAVIGATION @@ -2927,7 +2950,7 @@ void QMenu::internalDelayedPopup() QPoint pos(rightPos); QMenu *caused = qobject_cast(d->activeMenu->d_func()->causedPopup.widget); - const QRect availGeometry(d->popupGeometry(QApplication::desktop()->screenNumber(caused))); + const QRect availGeometry(d->popupGeometry(caused)); if (isRightToLeft()) { pos = leftPos; if ((caused && caused->x() < x()) || pos.x() < availGeometry.left()) { diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index 9c4f260..6a8e4b0 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -192,7 +192,8 @@ public: mutable QVector actionRects; mutable QWidgetList widgetItems; void updateActionRects() const; - QRect popupGeometry(int screen=-1) const; + QRect popupGeometry(const QWidget *widget) const; + QRect popupGeometry(int screen = -1) const; mutable uint ncols : 4; //4 bits is probably plenty uint collapsibleSeparators : 1; diff --git a/src/gui/widgets/qpushbutton.cpp b/src/gui/widgets/qpushbutton.cpp index 1352e1b..eb34336 100644 --- a/src/gui/widgets/qpushbutton.cpp +++ b/src/gui/widgets/qpushbutton.cpp @@ -590,7 +590,7 @@ void QPushButtonPrivate::_q_popupPressed() int x = globalPos.x(); int y = globalPos.y(); if (horizontal) { - if (globalPos.y() + rect.height() + menuSize.height() <= QApplication::desktop()->height()) { + if (globalPos.y() + rect.height() + menuSize.height() <= QApplication::desktop()->availableGeometry(q).height()) { y += rect.height(); } else { y -= menuSize.height(); @@ -598,7 +598,7 @@ void QPushButtonPrivate::_q_popupPressed() if (q->layoutDirection() == Qt::RightToLeft) x += rect.width() - menuSize.width(); } else { - if (globalPos.x() + rect.width() + menu->sizeHint().width() <= QApplication::desktop()->width()) + if (globalPos.x() + rect.width() + menu->sizeHint().width() <= QApplication::desktop()->availableGeometry(q).width()) x += rect.width(); else x -= menuSize.width(); -- cgit v0.12 From 6c1388ee5a3c4796d7ce09f0cbbc1700ab574ce4 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 20 Oct 2009 10:39:42 +0200 Subject: Fixed wrong scrolling in QListView with hidden rows in ListMode The flow positions in ScrollPerItem mode did not take the hidden rows into account when configuring the vertical scroll bar. A mapping between the scroll bar value and the flow position has been added. Auto-test included. Task-number: QTBUG-2233 Reviewed-by: Thierry --- src/gui/itemviews/qlistview.cpp | 24 +++++++++++++++++------- src/gui/itemviews/qlistview_p.h | 1 + tests/auto/qlistview/tst_qlistview.cpp | 25 +++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 1d9b6e0..88002e0 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1900,7 +1900,7 @@ void QListModeViewBase::updateVerticalScrollBar(const QSize &step) if (verticalScrollMode() == QAbstractItemView::ScrollPerItem && ((flow() == QListView::TopToBottom && !isWrapping()) || (flow() == QListView::LeftToRight && isWrapping()))) { - const int steps = (flow() == QListView::TopToBottom ? flowPositions : segmentPositions).count() - 1; + const int steps = (flow() == QListView::TopToBottom ? scrollValueMap : segmentPositions).count() - 1; if (steps > 0) { const int pageSteps = perItemScrollingPageSteps(viewport()->height(), contentsSize.height(), isWrapping()); verticalScrollBar()->setSingleStep(1); @@ -1939,7 +1939,7 @@ int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hi bool above, bool below, const QRect &area, const QRect &rect) const { if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) { - int value = qBound(0, verticalScrollBar()->value(), flowPositions.count() - 1); + int value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()), flowPositions.count() - 1); if (above) hint = QListView::PositionAtTop; else if (below) @@ -1986,9 +1986,9 @@ int QListModeViewBase::verticalOffset() const } } else if (flow() == QListView::TopToBottom && !flowPositions.isEmpty()) { int value = verticalScrollBar()->value(); - if (value > flowPositions.count()) + if (value > scrollValueMap.count()) return 0; - return flowPositions.at(value) - spacing(); + return flowPositions.at(scrollValueMap.at(value)) - spacing(); } } return QCommonListViewBase::verticalOffset(); @@ -2043,8 +2043,8 @@ void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand) if (vertical && flow() == QListView::TopToBottom && dy != 0) { int currentValue = qBound(0, verticalValue, max); int previousValue = qBound(0, currentValue + dy, max); - int currentCoordinate = flowPositions.at(currentValue); - int previousCoordinate = flowPositions.at(previousValue); + int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue)); + int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue)); dy = previousCoordinate - currentCoordinate; } else if (horizontal && flow() == QListView::LeftToRight && dx != 0) { int currentValue = qBound(0, horizontalValue, max); @@ -2113,6 +2113,7 @@ QPoint QListModeViewBase::initStaticLayout(const QListViewLayoutInfo &info) segmentPositions.clear(); segmentStartRows.clear(); segmentExtents.clear(); + scrollValueMap.clear(); x = info.bounds.left() + info.spacing; y = info.bounds.top() + info.spacing; segmentPositions.append(info.flow == QListView::LeftToRight ? y : x); @@ -2204,6 +2205,7 @@ void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info) deltaSegPosition = 0; } // save the flow position of this item + scrollValueMap.append(flowPositions.count()); flowPositions.append(flowPosition); // prepare for the next item deltaSegPosition = qMax(deltaSegHint, deltaSegPosition); @@ -2229,6 +2231,7 @@ void QListModeViewBase::doStaticLayout(const QListViewLayoutInfo &info) // if it is the last batch, save the end of the segments if (info.last == info.max) { segmentExtents.append(flowPosition); + scrollValueMap.append(flowPositions.count()); flowPositions.append(flowPosition); segmentPositions.append(info.wrap ? segPosition + deltaSegPosition : INT_MAX); } @@ -2306,7 +2309,14 @@ QRect QListModeViewBase::mapToViewport(const QRect &rect) const int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wrap) const { - const QVector positions = (wrap ? segmentPositions : flowPositions); + QVector positions; + if (wrap) + positions = segmentPositions; + else { + positions.reserve(scrollValueMap.size()); + foreach (int itemShown, scrollValueMap) + positions.append(flowPositions.at(itemShown)); + } if (positions.isEmpty() || bounds <= length) return positions.count(); if (uniformItemSizes()) { diff --git a/src/gui/itemviews/qlistview_p.h b/src/gui/itemviews/qlistview_p.h index b6785da..de4c7f3 100644 --- a/src/gui/itemviews/qlistview_p.h +++ b/src/gui/itemviews/qlistview_p.h @@ -205,6 +205,7 @@ public: QVector segmentPositions; QVector segmentStartRows; QVector segmentExtents; + QVector scrollValueMap; // used when laying out in batches int batchSavedPosition; diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 3ee6889..ed02317 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -117,6 +117,7 @@ private slots: void shiftSelectionWithNonUniformItemSizes(); void clickOnViewportClearsSelection(); void task262152_setModelColumnNavigate(); + void taskQTBUG_2233_scrollHiddenRows(); }; // Testing get/set functions @@ -1790,7 +1791,31 @@ void tst_QListView::task262152_setModelColumnNavigate() } +void tst_QListView::taskQTBUG_2233_scrollHiddenRows() +{ + const int rowCount = 200; + + QListView view; + QStringListModel model(&view); + QStringList list; + for (int i = 0; i < rowCount; ++i) + list << QString::fromAscii("Item %1").arg(i); + + model.setStringList(list); + view.setModel(&model); + view.setViewMode(QListView::ListMode); + view.setFlow(QListView::TopToBottom); + for (int i = 0; i < rowCount / 2; ++i) + view.setRowHidden(2 * i, true); + view.resize(250, 130); + for (int i = 0; i < 10; ++i) { + view.verticalScrollBar()->setValue(i); + QModelIndex index = view.indexAt(QPoint(20,0)); + QVERIFY(index.isValid()); + QCOMPARE(index.row(), 2 * i + 1); + } +} QTEST_MAIN(tst_QListView) #include "tst_qlistview.moc" -- cgit v0.12 From 5651d2547261ccecbf50f8141c634f59c0adc00d Mon Sep 17 00:00:00 2001 From: Dean Dettman Date: Tue, 20 Oct 2009 11:13:02 +0200 Subject: Adds Key_Back and Key_Forward menu glyphs on mac(carbon) This change improves the behavior of QMenu when Key_Back and Key_Forward are used as shortcuts. A dotted arrow appears on carbon, and on Cocoa the image is blank, instead of undefined as it was before. Task-number: QTBUG-4873 Reviewed-by: msorvig --- src/gui/widgets/qmenu_mac.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 354161d..a7f6f0d 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -572,6 +572,10 @@ static void qt_mac_get_accel(quint32 accel_key, quint32 *modif, quint32 *key) { *key = kMenuNorthwestArrowGlyph; else if (accel_key == Qt::Key_End) *key = kMenuSoutheastArrowGlyph; + else if (accel_key == Qt::Key_Back) + *key = kMenuLeftArrowDashedGlyph; + else if (accel_key == Qt::Key_Forward) + *key = kMenuRightArrowDashedGlyph; } } #else // Cocoa @@ -1239,6 +1243,10 @@ NSString *keySequenceToKeyEqivalent(const QKeySequence &accel) keyEquiv[0] = NSHomeFunctionKey; else if (accel_key == Qt::Key_End) keyEquiv[0] = NSEndFunctionKey; + else if (accel_key == Qt::Key_Back) + keyEquiv[0] = kMenuLeftArrowDashedGlyph; // ### Cocoa has no equivalent - no icon is displayed + else if (accel_key == Qt::Key_Forward) + keyEquiv[0] = kMenuRightArrowDashedGlyph; // ### Cocoa has no equivalent - no icon is displayed else keyEquiv[0] = unichar(QChar(accel_key).toLower().unicode()); return [NSString stringWithCharacters:keyEquiv length:1]; -- cgit v0.12 From 63b574ee1539b34ac7df890a7941320deb1c258e Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Tue, 20 Oct 2009 11:52:38 +0200 Subject: Fix bug in embedded dialog demo with tab focus. On embedded dialog pressing tab stop changing the focus when the focus was given to QFontComboBox. It's because QFontComboBox embed a QLineEdit in order to allow editing. But this QLineEdit is a focus proxy so we need to special case that. The logic is the same in QApplication. Be careful when changing one of them. Task-number:QTBUG-4818 Reviewed-by:jan-arve Reviewed-by:ogoffart --- src/gui/graphicsview/qgraphicsproxywidget.cpp | 15 ++++++-- src/gui/kernel/qapplication.cpp | 1 + .../tst_qgraphicsproxywidget.cpp | 45 +++++++++++++++++++++- 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp index b7a3962..64c51ad 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget.cpp +++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp @@ -57,6 +57,9 @@ #include #include #include +#include +#include +#include QT_BEGIN_NAMESPACE @@ -86,7 +89,9 @@ QT_BEGIN_NAMESPACE of embedded widgets through creating a child proxy for each popup. This means that when an embedded QComboBox shows its popup list, a new QGraphicsProxyWidget is created automatically, embedding the popup, and - positioning it correctly. + positioning it correctly. This only works if the popup is child of the + embedded widget (for example QToolButton::setMenu() requires the QMenu instance + to be child of the QToolButton). \section1 Embedding a Widget with QGraphicsProxyWidget @@ -184,6 +189,7 @@ QT_BEGIN_NAMESPACE */ extern bool qt_sendSpontaneousEvent(QObject *, QEvent *); +extern bool qt_tab_all_widgets; /*! \internal @@ -369,6 +375,7 @@ QVariant QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(Qt::InputMethodQuer /*! \internal + Some of the logic is shared with QApplicationPrivate::focusNextPrevChild_helper */ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) const { @@ -382,14 +389,16 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) child = next ? child->d_func()->focus_next : child->d_func()->focus_prev; if ((next && child == widget) || (!next && child == widget->d_func()->focus_prev)) { return 0; - } + } } QWidget *oldChild = child; + uint focus_flag = qt_tab_all_widgets ? Qt::TabFocus : Qt::StrongFocus; do { if (child->isEnabled() && child->isVisibleTo(widget) - && (child->focusPolicy() & Qt::TabFocus)) { + && (child->focusPolicy() & focus_flag == focus_flag) + && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) { return child; } child = next ? child->d_func()->focus_next : child->d_func()->focus_prev; diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index f48c551..c4249d9 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -2495,6 +2495,7 @@ void QApplication::setActiveWindow(QWidget* act) /*!internal * Helper function that returns the new focus widget, but does not set the focus reason. * Returns 0 if a new focus widget could not be found. + * Shared with QGraphicsProxyWidgetPrivate::findFocusChild() */ QWidget *QApplicationPrivate::focusNextPrevChild_helper(QWidget *toplevel, bool next) { diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 2426ce9..9269164 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -2007,8 +2007,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() edit1->setText("QLineEdit 1"); QLineEdit *edit2 = new QLineEdit; edit2->setText("QLineEdit 2"); + QFontComboBox *fontComboBox = new QFontComboBox; QVBoxLayout *vlayout = new QVBoxLayout; vlayout->addWidget(edit1); + vlayout->addWidget(fontComboBox); vlayout->addWidget(edit2); QGroupBox *box = new QGroupBox("QGroupBox"); @@ -2020,8 +2022,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() edit1_2->setText("QLineEdit 1_2"); QLineEdit *edit2_2 = new QLineEdit; edit2_2->setText("QLineEdit 2_2"); + QFontComboBox *fontComboBox2 = new QFontComboBox; vlayout = new QVBoxLayout; vlayout->addWidget(edit1_2); + vlayout->addWidget(fontComboBox2); vlayout->addWidget(edit2_2); QGroupBox *box_2 = new QGroupBox("QGroupBox 2"); @@ -2062,8 +2066,10 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() EventSpy eventSpy(edit1); EventSpy eventSpy2(edit2); + EventSpy eventSpy3(fontComboBox); EventSpy eventSpy1_2(edit1_2); EventSpy eventSpy2_2(edit2_2); + EventSpy eventSpy2_3(fontComboBox2); EventSpy eventSpyBox(box); // Tab into group box @@ -2084,11 +2090,24 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy.counts[QEvent::FocusOut], 0); + // Tab to the font combobox + QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); + QApplication::processEvents(); + fontComboBox->hasFocus(); + QVERIFY(!edit2->hasFocus()); + QCOMPARE(eventSpy3.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 0); + QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1); + // Tab into line edit 2 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); QApplication::processEvents(); edit2->hasFocus(); QVERIFY(!edit1->hasFocus()); + QCOMPARE(eventSpy2.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy2.counts[QEvent::FocusOut], 0); + QCOMPARE(eventSpy3.counts[QEvent::FocusOut], 1); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy.counts[QEvent::FocusOut], 1); @@ -2106,6 +2125,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 0); + // Tab into right font combobox + QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); + QApplication::processEvents(); + QVERIFY(!edit1_2->hasFocus()); + fontComboBox2->hasFocus(); + QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1); + QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 0); + // Tab into right bottom line edit QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); QApplication::processEvents(); @@ -2113,6 +2142,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() edit2_2->hasFocus(); QCOMPARE(eventSpy1_2.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy1_2.counts[QEvent::FocusOut], 1); + QCOMPARE(eventSpy2_3.counts[QEvent::FocusIn], 1); + QCOMPARE(eventSpy2_3.counts[QEvent::FocusOut], 1); QCOMPARE(eventSpy2_2.counts[QEvent::FocusIn], 1); QCOMPARE(eventSpy2_2.counts[QEvent::FocusOut], 0); @@ -2129,6 +2160,12 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QVERIFY(!rightDial->hasFocus()); edit2_2->hasFocus(); + // Backtab into the right font combobox + QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); + QApplication::processEvents(); + QVERIFY(!edit2_2->hasFocus()); + fontComboBox2->hasFocus(); + // Backtab into line edit 1 QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); QApplication::processEvents(); @@ -2147,10 +2184,16 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QVERIFY(!rightDial->hasFocus()); edit2->hasFocus(); - // Backtab into line edit 1 + // Backtab into the font combobox QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); QApplication::processEvents(); QVERIFY(!edit2->hasFocus()); + fontComboBox->hasFocus(); + + // Backtab into line edit 1 + QTest::keyPress(QApplication::focusWidget(), Qt::Key_Backtab); + QApplication::processEvents(); + QVERIFY(!fontComboBox->hasFocus()); edit1->hasFocus(); // Backtab into line box -- cgit v0.12 From 6e1e26741e682c869c45e4cf8dfe4c79e37b9716 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Tue, 20 Oct 2009 11:52:42 +0200 Subject: Fixed the SVG paint engine to preserve whitespace when drawing text. Added xml:space="preserve" to the output text tag. This attribute tells the SVG user agent not to strip away excess whitespace in the text element. Reviewed-by: Trond --- src/svg/qsvggenerator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/svg/qsvggenerator.cpp b/src/svg/qsvggenerator.cpp index da3123f..2f80a92 100644 --- a/src/svg/qsvggenerator.cpp +++ b/src/svg/qsvggenerator.cpp @@ -1063,6 +1063,7 @@ void QSvgPaintEngine::drawTextItem(const QPointF &pt, const QTextItem &textItem) "fill=\"" << d->attributes.stroke << "\" " "fill-opacity=\"" << d->attributes.strokeOpacity << "\" " "stroke=\"none\" " + "xml:space=\"preserve\" " "x=\"" << pt.x() << "\" y=\"" << pt.y() << "\" "; qfontToSvg(textItem.font()); *d->stream << " >" -- cgit v0.12 From f779d9f7e317ff3e10f015a05d349e1fa3e7ab84 Mon Sep 17 00:00:00 2001 From: Dean Dettman Date: Tue, 20 Oct 2009 12:28:32 +0200 Subject: make missing Key_Back and Key_Forward menu glyphs return 0 on mac(cocoa) This is an addition to commit 5651d2547261ccecbf50f8141c634f59c0adc00d to make it obvious that in cocoa nothing is returned. Task-number: QTBUG-4873 Reviewed-by: MortenS --- src/gui/widgets/qmenu_mac.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qmenu_mac.mm b/src/gui/widgets/qmenu_mac.mm index 0f92ad9..ec9313f 100644 --- a/src/gui/widgets/qmenu_mac.mm +++ b/src/gui/widgets/qmenu_mac.mm @@ -1244,9 +1244,9 @@ NSString *keySequenceToKeyEqivalent(const QKeySequence &accel) else if (accel_key == Qt::Key_End) keyEquiv[0] = NSEndFunctionKey; else if (accel_key == Qt::Key_Back) - keyEquiv[0] = kMenuLeftArrowDashedGlyph; // ### Cocoa has no equivalent - no icon is displayed + keyEquiv[0] = 0 ; // ### could not find Cocoa equivalent to kMenuLeftArrowDashedGlyph else if (accel_key == Qt::Key_Forward) - keyEquiv[0] = kMenuRightArrowDashedGlyph; // ### Cocoa has no equivalent - no icon is displayed + keyEquiv[0] = 0 ; // ### could not find Cocoa equivalent to kMenuRightArrowDashedGlyph else keyEquiv[0] = unichar(QChar(accel_key).toLower().unicode()); return [NSString stringWithCharacters:keyEquiv length:1]; -- cgit v0.12 From 27df4f3fe6c290f22d509f677e46c7096156817b Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 20 Oct 2009 12:46:43 +0200 Subject: Make the total duration of animation be 0 if duration is 0 --- src/corelib/animation/qabstractanimation.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index c775a00..e83fad7 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -328,9 +328,9 @@ int QUnifiedTimer::closestPauseAnimationTimeToFinish() int timeToFinish; if (animation->direction() == QAbstractAnimation::Forward) - timeToFinish = animation->totalDuration() - QAbstractAnimationPrivate::get(animation)->totalCurrentTime; + timeToFinish = animation->duration() - animation->currentTime(); else - timeToFinish = QAbstractAnimationPrivate::get(animation)->totalCurrentTime; + timeToFinish = animation->currentTime(); if (timeToFinish < closestTimeToFinish) closestTimeToFinish = timeToFinish; @@ -648,13 +648,13 @@ int QAbstractAnimation::currentLoop() const */ int QAbstractAnimation::totalDuration() const { - Q_D(const QAbstractAnimation); - if (d->loopCount < 0) - return -1; int dura = duration(); - if (dura == -1) + if (dura <= 0) + return dura; + int loopcount = loopCount(); + if (loopcount < 0) return -1; - return dura * d->loopCount; + return dura * loopcount; } /*! @@ -685,7 +685,7 @@ void QAbstractAnimation::setCurrentTime(int msecs) // Calculate new time and loop. int dura = duration(); - int totalDura = (d->loopCount < 0 || dura == -1) ? -1 : dura * d->loopCount; + int totalDura = dura <= 0 ? dura : ((d->loopCount < 0) ? -1 : dura * d->loopCount); if (totalDura != -1) msecs = qMin(totalDura, msecs); d->totalCurrentTime = msecs; -- cgit v0.12 From 8b0e59706f0d7a68446b6ff5c646e2bbdef5f496 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 20 Oct 2009 12:48:24 +0200 Subject: Make the default duration of pause animations 250ms --- src/corelib/animation/qpauseanimation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/animation/qpauseanimation.cpp b/src/corelib/animation/qpauseanimation.cpp index d90f001..21e5b08 100644 --- a/src/corelib/animation/qpauseanimation.cpp +++ b/src/corelib/animation/qpauseanimation.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE class QPauseAnimationPrivate : public QAbstractAnimationPrivate { public: - QPauseAnimationPrivate() : QAbstractAnimationPrivate(), duration(0) + QPauseAnimationPrivate() : QAbstractAnimationPrivate(), duration(250) { isPause = true; } @@ -114,6 +114,7 @@ QPauseAnimation::~QPauseAnimation() \brief the duration of the pause. The duration of the pause. The duration should not be negative. + The default duration is 250 milliseconds. */ int QPauseAnimation::duration() const { -- cgit v0.12 From 462b2eae2386d22709943187820ec3f071399682 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 20 Oct 2009 12:53:04 +0200 Subject: adding autotests --- tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 51ef2da..7dd17e5 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -130,6 +130,7 @@ private slots: void valueChanged(); void twoAnimations(); void deletedInUpdateCurrentTime(); + void totalDuration(); }; tst_QPropertyAnimation::tst_QPropertyAnimation() @@ -1199,5 +1200,18 @@ void tst_QPropertyAnimation::deletedInUpdateCurrentTime() QCOMPARE(o.value(), 1000); } +void tst_QPropertyAnimation::totalDuration() +{ + QPropertyAnimation anim; + QCOMPARE(anim.totalDuration(), 250); + anim.setLoopCount(2); + QCOMPARE(anim.totalDuration(), 2*250); + anim.setLoopCount(-1); + QCOMPARE(anim.totalDuration(), -1); + anim.setDuration(0); + QCOMPARE(anim.totalDuration(), 0); +} + + QTEST_MAIN(tst_QPropertyAnimation) #include "tst_qpropertyanimation.moc" -- cgit v0.12 From e0aeecfa8cc41a476bef070b349683be9aec2243 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 20 Oct 2009 13:19:33 +0200 Subject: QPauseAnimation autotests fixed --- tests/auto/qpauseanimation/tst_qpauseanimation.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp index 62b43c4..b11efa0 100644 --- a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp +++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp @@ -169,7 +169,7 @@ void tst_QPauseAnimation::noTimerUpdates() animation.start(); QTest::qWait(animation.totalDuration() + 100); QVERIFY(animation.state() == QAbstractAnimation::Stopped); - QCOMPARE(animation.m_updateCurrentTimeCount, 2); + QCOMPARE(animation.m_updateCurrentTimeCount, 1 + loopCount); timer->setConsistentTiming(false); } @@ -399,6 +399,7 @@ void tst_QPauseAnimation::multipleSequentialGroups() void tst_QPauseAnimation::zeroDuration() { TestablePauseAnimation animation; + animation.setDuration(0); animation.start(); QTest::qWait(animation.totalDuration() + 100); QVERIFY(animation.state() == QAbstractAnimation::Stopped); -- cgit v0.12 From e64b5fa1312f42fa6377e28c11f8aa3a3413280f Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 20 Oct 2009 13:20:31 +0200 Subject: Fixed a bug in that could unregister not-registered animations --- src/corelib/animation/qabstractanimation.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index e83fad7..0d5f278 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -278,11 +278,11 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopL void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) { - unregisterRunningAnimation(animation); - if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer) return; + unregisterRunningAnimation(animation); + int idx = animations.indexOf(animation); if (idx != -1) { animations.removeAt(idx); @@ -318,6 +318,7 @@ void QUnifiedTimer::unregisterRunningAnimation(QAbstractAnimation *animation) runningPauseAnimations.removeOne(animation); else runningLeafAnimations--; + Q_ASSERT(runningLeafAnimations >= 0); } int QUnifiedTimer::closestPauseAnimationTimeToFinish() -- cgit v0.12 From f0a7e831394683190faf8a51bf724462f98568e9 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 20 Oct 2009 14:37:29 +0200 Subject: Add a new window surface which utilises QX11GLPixmapData The new surface uses XCopyArea to post updates to the window and thus, supports partial updates. --- src/opengl/opengl.pro | 7 +- src/opengl/qgraphicssystem_gl.cpp | 8 +- src/opengl/qwindowsurface_gl.cpp | 1 + src/opengl/qwindowsurface_x11gl.cpp | 146 ++++++++++++++++++++++++++++++++++++ src/opengl/qwindowsurface_x11gl_p.h | 81 ++++++++++++++++++++ 5 files changed, 239 insertions(+), 4 deletions(-) create mode 100644 src/opengl/qwindowsurface_x11gl.cpp create mode 100644 src/opengl/qwindowsurface_x11gl_p.h diff --git a/src/opengl/opengl.pro b/src/opengl/opengl.pro index 961c781..a212675 100644 --- a/src/opengl/opengl.pro +++ b/src/opengl/opengl.pro @@ -83,11 +83,12 @@ x11 { SOURCES += qgl_x11egl.cpp \ qglpixelbuffer_egl.cpp \ qgl_egl.cpp \ - qpixmapdata_x11gl_egl.cpp + qpixmapdata_x11gl_egl.cpp \ + qwindowsurface_x11gl.cpp HEADERS += qgl_egl_p.h \ - qpixmapdata_x11gl_p.h - + qpixmapdata_x11gl_p.h \ + qwindowsurface_x11gl_p.h } else { SOURCES += qgl_x11.cpp \ diff --git a/src/opengl/qgraphicssystem_gl.cpp b/src/opengl/qgraphicssystem_gl.cpp index 0ee1e82..c0d9233 100644 --- a/src/opengl/qgraphicssystem_gl.cpp +++ b/src/opengl/qgraphicssystem_gl.cpp @@ -47,8 +47,9 @@ #include "private/qgl_p.h" #include -#ifdef Q_WS_X11 +#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) #include "private/qpixmapdata_x11gl_p.h" +#include "private/qwindowsurface_x11gl_p.h" #endif QT_BEGIN_NAMESPACE @@ -75,6 +76,11 @@ QWindowSurface *QGLGraphicsSystem::createWindowSurface(QWidget *widget) const return new QRasterWindowSurface(widget); #endif +#if defined(Q_WS_X11) && defined(QT_OPENGL_ES) + if (QX11GLPixmapData::hasX11GLPixmaps()) + return new QX11GLWindowSurface(widget); +#endif + return new QGLWindowSurface(widget); } diff --git a/src/opengl/qwindowsurface_gl.cpp b/src/opengl/qwindowsurface_gl.cpp index 2816eca..4547416 100644 --- a/src/opengl/qwindowsurface_gl.cpp +++ b/src/opengl/qwindowsurface_gl.cpp @@ -364,6 +364,7 @@ void QGLWindowSurface::hijackWindow(QWidget *widget) if (ctxpriv->eglSurface == EGL_NO_SURFACE) { qWarning() << "hijackWindow() could not create EGL surface"; } + qDebug("QGLWindowSurface - using EGLConfig %d", ctxpriv->eglContext->config()); #endif widgetPrivate->extraData()->glContext = ctx; diff --git a/src/opengl/qwindowsurface_x11gl.cpp b/src/opengl/qwindowsurface_x11gl.cpp new file mode 100644 index 0000000..2e05ab3 --- /dev/null +++ b/src/opengl/qwindowsurface_x11gl.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +#include +#include + +#include "qwindowsurface_x11gl_p.h" +#include "qpixmapdata_x11gl_p.h" + +QT_BEGIN_NAMESPACE + +QX11GLWindowSurface::QX11GLWindowSurface(QWidget* window) + : QWindowSurface(window), m_GC(0), m_window(window) +{ + QImagePixmapCleanupHooks::instance(); +} + +QX11GLWindowSurface::~QX11GLWindowSurface() +{ + + if (m_GC) + XFree(m_GC); +} + +QPaintDevice *QX11GLWindowSurface::paintDevice() +{ + return &m_backBuffer; +} + +extern void *qt_getClipRects(const QRegion &r, int &num); // in qpaintengine_x11.cpp + +void QX11GLWindowSurface::flush(QWidget *widget, const QRegion &widgetRegion, const QPoint &offset) +{ +// qDebug("QX11GLWindowSurface::flush()"); + QTime startTime = QTime::currentTime(); + if (m_backBuffer.isNull()) { + qDebug("QHarmattanWindowSurface::flush() - backBuffer is null, not flushing anything"); + return; + } + + QPoint widgetOffset = qt_qwidget_data(widget)->wrect.topLeft(); + QRegion windowRegion(widgetRegion); + QRect boundingRect = widgetRegion.boundingRect(); + if (!widgetOffset.isNull()) + windowRegion.translate(-widgetOffset); + QRect windowBoundingRect = windowRegion.boundingRect(); + + int rectCount; + XRectangle *rects = (XRectangle *)qt_getClipRects(windowRegion, rectCount); + if (rectCount <= 0) + return; +// qDebug() << "XSetClipRectangles"; +// for (int i = 0; i < num; ++i) +// qDebug() << ' ' << i << rects[i].x << rects[i].x << rects[i].y << rects[i].width << rects[i].height; + + if (m_GC == 0) { + m_GC = XCreateGC(X11->display, m_window->handle(), 0, 0); + XSetGraphicsExposures(X11->display, m_GC, False); + } + + XSetClipRectangles(X11->display, m_GC, 0, 0, rects, rectCount, YXBanded); + XCopyArea(X11->display, m_backBuffer.handle(), m_window->handle(), m_GC, + boundingRect.x() + offset.x(), boundingRect.y() + offset.y(), + boundingRect.width(), boundingRect.height(), + windowBoundingRect.x(), windowBoundingRect.y()); +} + +void QX11GLWindowSurface::setGeometry(const QRect &rect) +{ + if (rect.width() > m_backBuffer.size().width() || rect.height() > m_backBuffer.size().height()) { + QSize newSize = rect.size(); +// QSize newSize(1024,512); + qDebug() << "QX11GLWindowSurface::setGeometry() - creating a pixmap of size" << newSize; + QX11GLPixmapData *pd = new QX11GLPixmapData; + pd->resize(newSize.width(), newSize.height()); + m_backBuffer = QPixmap(pd); + } + +// if (gc) +// XFreeGC(X11->display, gc); +// gc = XCreateGC(X11->display, d_ptr->device.handle(), 0, 0); +// XSetGraphicsExposures(X11->display, gc, False); + QWindowSurface::setGeometry(rect); +} + +bool QX11GLWindowSurface::scroll(const QRegion &area, int dx, int dy) +{ + return false; +} + +/* +void QX11GLWindowSurface::beginPaint(const QRegion ®ion) +{ +} + +void QX11GLWindowSurface::endPaint(const QRegion ®ion) +{ +} + +QImage *QX11GLWindowSurface::buffer(const QWidget *widget) +{ +} +*/ + +QT_END_NAMESPACE diff --git a/src/opengl/qwindowsurface_x11gl_p.h b/src/opengl/qwindowsurface_x11gl_p.h new file mode 100644 index 0000000..5ba4dc5 --- /dev/null +++ b/src/opengl/qwindowsurface_x11gl_p.h @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWINDOWSURFACE_X11GL_P_H +#define QWINDOWSURFACE_X11GL_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include + +QT_BEGIN_NAMESPACE + +class QX11GLWindowSurface : public QWindowSurface +{ +public: + QX11GLWindowSurface(QWidget* window); + virtual ~QX11GLWindowSurface(); + + // Inherreted from QWindowSurface + QPaintDevice *paintDevice(); + void flush(QWidget *widget, const QRegion ®ion, const QPoint &offset); + void setGeometry(const QRect &rect); + bool scroll(const QRegion &area, int dx, int dy); + +private: + GC m_GC; + QPixmap m_backBuffer; + QWidget *m_window; +}; + + +QT_END_NAMESPACE + +#endif // QWINDOWSURFACE_X11GL_P_H -- cgit v0.12 From bdb67474ece69a987379411f593d0b37c1400746 Mon Sep 17 00:00:00 2001 From: Tom Cooksey Date: Tue, 20 Oct 2009 14:54:22 +0200 Subject: Make sure QGLTextureCache exists when creating surfaces for pixmaps QGLTextureCache installs pixmap cleanup hooks which are used to clean up the EGL surfaces. Reviewed-By: Trustme --- src/opengl/qgl_x11egl.cpp | 8 ++++++++ src/opengl/qwindowsurface_x11gl.cpp | 2 -- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/opengl/qgl_x11egl.cpp b/src/opengl/qgl_x11egl.cpp index fb08741..3894ed1 100644 --- a/src/opengl/qgl_x11egl.cpp +++ b/src/opengl/qgl_x11egl.cpp @@ -521,6 +521,14 @@ bool Q_OPENGL_EXPORT qt_createEGLSurfaceForPixmap(QPixmapData* pmd, bool readOnl return false; } + static bool doneOnce = false; + if (!doneOnce) { + // Make sure QGLTextureCache is instanciated so it can install cleanup hooks + // which cleanup the EGL surface. + QGLTextureCache::instance(); + doneOnce = true; + } + Q_ASSERT(sizeof(Qt::HANDLE) >= sizeof(EGLSurface)); // Just to make totally sure! pixmapData->gl_surface = (Qt::HANDLE)pixmapSurface; pixmapData->is_cached = true; // Make sure the cleanup hook gets called diff --git a/src/opengl/qwindowsurface_x11gl.cpp b/src/opengl/qwindowsurface_x11gl.cpp index 2e05ab3..8ef239d 100644 --- a/src/opengl/qwindowsurface_x11gl.cpp +++ b/src/opengl/qwindowsurface_x11gl.cpp @@ -53,12 +53,10 @@ QT_BEGIN_NAMESPACE QX11GLWindowSurface::QX11GLWindowSurface(QWidget* window) : QWindowSurface(window), m_GC(0), m_window(window) { - QImagePixmapCleanupHooks::instance(); } QX11GLWindowSurface::~QX11GLWindowSurface() { - if (m_GC) XFree(m_GC); } -- cgit v0.12 From 77f055ab9474ec4d3311884c293af7ee4a2a7cb3 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 20 Oct 2009 15:52:38 +0200 Subject: Fixed QTreeView trying to animate when parent item has no child We now check that the item has children before animating. Reviewed-by: Alexis --- src/gui/itemviews/qtreeview.cpp | 6 +++--- tests/auto/qtreeview/tst_qtreeview.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index 210534e..d597f5c 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2908,15 +2908,15 @@ void QTreeViewPrivate::expand(int item, bool emitSignal) layout(item); q->setState(oldState); + if (model->canFetchMore(index)) + model->fetchMore(index); if (emitSignal) { emit q->expanded(index); #ifndef QT_NO_ANIMATION - if (animationsEnabled) + if (animationsEnabled && model->hasChildren(index)) beginAnimatedOperation(); #endif //QT_NO_ANIMATION } - if (model->canFetchMore(index)) - model->fetchMore(index); } void QTreeViewPrivate::collapse(int item, bool emitSignal) diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp index 91b2cc5..da58725 100644 --- a/tests/auto/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/qtreeview/tst_qtreeview.cpp @@ -172,6 +172,7 @@ private slots: void expandAndCollapse_data(); void expandAndCollapse(); void expandAndCollapseAll(); + void expandWithNoChildren(); void keyboardNavigation(); void headerSections(); void moveCursor_data(); @@ -1548,6 +1549,19 @@ void tst_QTreeView::expandAndCollapseAll() // QCOMPARE(collapsedSpy.count(), count); } +void tst_QTreeView::expandWithNoChildren() +{ + QTreeView tree; + QStandardItemModel model(1,1); + tree.setModel(&model); + tree.setAnimated(true); + tree.doItemsLayout(); + //this test should not output warnings + tree.expand(model.index(0,0)); +} + + + void tst_QTreeView::keyboardNavigation() { const int rows = 10; -- cgit v0.12 From d4dd08918082372d3df7be2d3a6671cbd7bc7fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 20 Oct 2009 15:52:56 +0200 Subject: Add some docs that explicitly mentions how we handle cycles in the tree This was reported for QGraphicsAnchorLayout, but affects all QGraphicsLayout subclasses. However, since it is not even handled properly in QGraphicsItem::setParentItem() it should be fine that we don't try to deal with this issue. Thus, the layouts are "consistent" with graphics items when it comes to detection of cycles in the tree. --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 3 +++ src/gui/graphicsview/qgraphicsitem.cpp | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index c39e8a6..cb8ccc1 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -215,6 +215,9 @@ QGraphicsAnchorLayout::~QGraphicsAnchorLayout() The spacing can also be set manually by using QGraphicsAnchor::setSpacing() method. + Calling this function where \a firstItem or \a secondItem are ancestors of the layout have + undefined behaviour. + \sa addCornerAnchors(), addAnchors() */ QGraphicsAnchor * diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 45627f6..1ebee45 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1511,6 +1511,8 @@ const QGraphicsObject *QGraphicsItem::toGraphicsObject() const the parent. You should not \l{QGraphicsScene::addItem()}{add} the item to the scene yourself. + Calling this function on an item that is an ancestor of \a parent have undefined behaviour. + \sa parentItem(), childItems() */ void QGraphicsItem::setParentItem(QGraphicsItem *parent) -- cgit v0.12 From 58574ea3590fbb28da5be73b983d83f0a8824d00 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Tue, 20 Oct 2009 15:03:56 +0200 Subject: tst_qsslsocket: new bigChunk testcase This new test is to find out if the BIO size of OpenSSL is limited or not. The test passes on my Linux, however the OpenSSL docu suggests that the BIO size is limited. From http://www.openssl.org/docs/crypto/BIO_s_bio.html "This is currently 17K". Reviewed-by: Peter Hartmann --- tests/auto/qsslsocket/tst_qsslsocket.cpp | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index 6b330e1..2f1c2e2 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -173,6 +173,7 @@ private slots: void disconnectFromHostWhenConnected(); void resetProxy(); void readFromClosedSocket(); + void writeBigChunk(); static void exitLoop() { @@ -1537,6 +1538,50 @@ void tst_QSslSocket::readFromClosedSocket() QVERIFY(!socket->bytesToWrite()); } +void tst_QSslSocket::writeBigChunk() +{ + if (!QSslSocket::supportsSsl()) + return; + + QSslSocketPtr socket = newSocket(); + this->socket = socket; + + connect(socket, SIGNAL(sslErrors(const QList &)), this, SLOT(ignoreErrorSlot())); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + + QByteArray data; + data.resize(1024*1024*10); // 10 MB + // init with garbage. needed so ssl cannot compress it in an efficient way. + for (int i = 0; i < data.size() / sizeof(int); i++) { + int r = qrand(); + data.data()[i*sizeof(int)] = r; + } + + QVERIFY(socket->waitForEncrypted(10000)); + QString errorBefore = socket->errorString(); + + int ret = socket->write(data.constData(), data.size()); + QVERIFY(data.size() == ret); + + // spin the event loop once so QSslSocket::transmit() gets called + QCoreApplication::processEvents(); + QString errorAfter = socket->errorString(); + + // no better way to do this right now since the error is the same as the default error. + if (socket->errorString().startsWith(QLatin1String("Unable to write data"))) + { + qWarning() << socket->error() << socket->errorString(); + QFAIL("Error while writing! Check if the OpenSSL BIO size is limited?!"); + } + // also check the error string. If another error (than UnknownError) occured, it should be different than before + QVERIFY(errorBefore == errorAfter); + + // check that everything has been written to OpenSSL + QVERIFY(socket->bytesToWrite() == 0); + + socket->close(); +} + #endif // QT_NO_OPENSSL QTEST_MAIN(tst_QSslSocket) -- cgit v0.12 From cbca69bb0c7e3c42bf7d2d964057f38263de0553 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Tue, 20 Oct 2009 15:59:40 +0200 Subject: fix for QTreeView to not animate if there are no visible children --- src/gui/itemviews/qtreeview.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index d597f5c..f37d8c7 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2913,7 +2913,7 @@ void QTreeViewPrivate::expand(int item, bool emitSignal) if (emitSignal) { emit q->expanded(index); #ifndef QT_NO_ANIMATION - if (animationsEnabled && model->hasChildren(index)) + if (animationsEnabled) beginAnimatedOperation(); #endif //QT_NO_ANIMATION } @@ -3005,10 +3005,12 @@ void QTreeViewPrivate::beginAnimatedOperation() animatedOperation.setEndValue(animatedOperation.top() + h); } - animatedOperation.after = renderTreeToPixmapForAnimation(rect); + if (!rect.isEmpty()) { + animatedOperation.after = renderTreeToPixmapForAnimation(rect); - q->setState(QAbstractItemView::AnimatingState); - animatedOperation.start(); //let's start the animation + q->setState(QAbstractItemView::AnimatingState); + animatedOperation.start(); //let's start the animation + } } void QTreeViewPrivate::drawAnimatedOperation(QPainter *painter) const -- cgit v0.12 From 6f5d69a0400229b0637242c2457b8cb88090785f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 20 Oct 2009 15:30:59 +0200 Subject: Extended commit 6c1388ee for LeftToRight flow Auto-test updated. As a bonus, stabilized tst_QListView::task262152_setModelColumnNavigate. Reviewed-by: Thierry --- src/gui/itemviews/qlistview.cpp | 12 ++++++------ tests/auto/qlistview/tst_qlistview.cpp | 30 +++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 88002e0..b6e0ab7 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1921,7 +1921,7 @@ void QListModeViewBase::updateHorizontalScrollBar(const QSize &step) if (horizontalScrollMode() == QAbstractItemView::ScrollPerItem && ((flow() == QListView::TopToBottom && isWrapping()) || (flow() == QListView::LeftToRight && !isWrapping()))) { - int steps = (flow() == QListView::TopToBottom ? segmentPositions : flowPositions).count() - 1; + int steps = (flow() == QListView::TopToBottom ? segmentPositions : scrollValueMap).count() - 1; if (steps > 0) { const int pageSteps = perItemScrollingPageSteps(viewport()->width(), contentsSize.width(), isWrapping()); horizontalScrollBar()->setSingleStep(1); @@ -1966,8 +1966,8 @@ int QListModeViewBase::horizontalOffset() const return (isRightToLeft() ? maximum - position : position); } } else if (flow() == QListView::LeftToRight && !flowPositions.isEmpty()) { - int position = flowPositions.at(horizontalScrollBar()->value()); - int maximum = flowPositions.at(horizontalScrollBar()->maximum()); + int position = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->value())); + int maximum = flowPositions.at(scrollValueMap.at(horizontalScrollBar()->maximum())); return (isRightToLeft() ? maximum - position : position); } } @@ -2000,7 +2000,7 @@ int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint if (horizontalScrollMode() != QAbstractItemView::ScrollPerItem) return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect); - int value = qBound(0, horizontalScrollBar()->value(), flowPositions.count() - 1); + int value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1); if (leftOf) hint = QListView::PositionAtTop; else if (rightOf) @@ -2049,8 +2049,8 @@ void QListModeViewBase::scrollContentsBy(int dx, int dy, bool scrollElasticBand) } else if (horizontal && flow() == QListView::LeftToRight && dx != 0) { int currentValue = qBound(0, horizontalValue, max); int previousValue = qBound(0, currentValue + dx, max); - int currentCoordinate = flowPositions.at(currentValue); - int previousCoordinate = flowPositions.at(previousValue); + int currentCoordinate = flowPositions.at(scrollValueMap.at(currentValue)); + int previousCoordinate = flowPositions.at(scrollValueMap.at(previousValue)); dx = previousCoordinate - currentCoordinate; } } diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index ed02317..6e211ae 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -117,7 +117,8 @@ private slots: void shiftSelectionWithNonUniformItemSizes(); void clickOnViewportClearsSelection(); void task262152_setModelColumnNavigate(); - void taskQTBUG_2233_scrollHiddenRows(); + void taskQTBUG_2233_scrollHiddenItems_data(); + void taskQTBUG_2233_scrollHiddenItems(); }; // Testing get/set functions @@ -1781,18 +1782,27 @@ void tst_QListView::task262152_setModelColumnNavigate() view.setModelColumn(1); view.show(); - QTest::qWait(30); + QTest::qWait(100); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(10); + QTest::qWait(100); QCOMPARE(view.currentIndex(), model.index(1,1)); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(10); + QTest::qWait(100); QCOMPARE(view.currentIndex(), model.index(2,1)); } -void tst_QListView::taskQTBUG_2233_scrollHiddenRows() +void tst_QListView::taskQTBUG_2233_scrollHiddenItems_data() { + QTest::addColumn("flow"); + + QTest::newRow("TopToBottom") << static_cast(QListView::TopToBottom); + QTest::newRow("LeftToRight") << static_cast(QListView::LeftToRight); +} + +void tst_QListView::taskQTBUG_2233_scrollHiddenItems() +{ + QFETCH(int, flow); const int rowCount = 200; QListView view; @@ -1804,14 +1814,16 @@ void tst_QListView::taskQTBUG_2233_scrollHiddenRows() model.setStringList(list); view.setModel(&model); view.setViewMode(QListView::ListMode); - view.setFlow(QListView::TopToBottom); for (int i = 0; i < rowCount / 2; ++i) view.setRowHidden(2 * i, true); - view.resize(250, 130); + view.setFlow(static_cast(flow)); + view.resize(130, 130); for (int i = 0; i < 10; ++i) { - view.verticalScrollBar()->setValue(i); - QModelIndex index = view.indexAt(QPoint(20,0)); + (view.flow() == QListView::TopToBottom + ? view.verticalScrollBar() + : view.horizontalScrollBar())->setValue(i); + QModelIndex index = view.indexAt(QPoint(0,0)); QVERIFY(index.isValid()); QCOMPARE(index.row(), 2 * i + 1); } -- cgit v0.12 From af17ea048179ea0c21a897f803e79f825a9d13b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 20 Oct 2009 13:04:56 +0200 Subject: Make adjustSize work even if there is a pending LayoutRequest event. The original report was that the customer did resize(main.sizeHint()) instead of the main.adjustSize(); Note that resize(main.sizeHint() still does not work. However, calling main.adjustSize() should now do what the original reporter wanted. The problem was that the resize did not work, because at the point of the resize the minimumHeight of main was still 22 (8+6+8), and we tried to resize it with a new height of 10. The resize would bound the height up to 22, and the main widget would then get a size of (200x22). The reason why it still had a minimumHeight of 22 was that it was the minimumSize of the previous layout configuration. Unfortunately the new minimumSize of the widget hadn't been updated yet because there was a LayoutRequest event in the queue that hadn't been processed yet. (This LayoutRequest was triggered by that we called invalidate() from hide()). Thus, processing the event queue immediately after the hide() could also have been a workaround for this issue. There is no really good fix for this issue (and it does not seem to be a common problem) without introducing a risk for regressions. Due to that we therefore decided to provide a fix in QWidget::adjustSize(). Reviewed-by: paul --- src/gui/kernel/qwidget.cpp | 4 ++++ tests/auto/qlayout/tst_qlayout.cpp | 28 ++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 7dc3ae9..64b18ce 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -7726,6 +7726,10 @@ void QWidget::adjustSize() Q_D(QWidget); ensurePolished(); QSize s = d->adjustedSize(); + + if (d->layout) + d->layout->activate(); + if (s.isValid()) resize(s); } diff --git a/tests/auto/qlayout/tst_qlayout.cpp b/tests/auto/qlayout/tst_qlayout.cpp index 9d6110d..efe14c3 100644 --- a/tests/auto/qlayout/tst_qlayout.cpp +++ b/tests/auto/qlayout/tst_qlayout.cpp @@ -83,6 +83,7 @@ private slots: void layoutItemRect(); void warnIfWrongParent(); void controlTypes(); + void adjustSizeShouldMakeSureLayoutIsActivated(); }; tst_QLayout::tst_QLayout() @@ -110,8 +111,8 @@ void tst_QLayout::getSetCheck() class SizeHinterFrame : public QFrame { public: - SizeHinterFrame(const QSize &s) - : QFrame(0), sh(s) { + SizeHinterFrame(const QSize &sh, const QSize &msh = QSize()) + : QFrame(0), sh(sh), msh(msh) { setFrameStyle(QFrame::Box | QFrame::Plain); } @@ -119,9 +120,11 @@ public: void setSizeHint(const QSize &s) { sh = s; } QSize sizeHint() const { return sh; } + QSize minimumSizeHint() const { return msh; } private: QSize sh; + QSize msh; }; @@ -333,5 +336,26 @@ void tst_QLayout::controlTypes() } +void tst_QLayout::adjustSizeShouldMakeSureLayoutIsActivated() +{ + QWidget main; + + QVBoxLayout *const layout = new QVBoxLayout(&main); + layout->setMargin(0); + SizeHinterFrame *frame = new SizeHinterFrame(QSize(200, 10), QSize(200, 8)); + frame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + layout->addWidget(frame); + + SizeHinterFrame *frame2 = new SizeHinterFrame(QSize(200, 10), QSize(200, 8)); + frame2->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); + layout->addWidget(frame2); + + main.show(); + + frame2->hide(); + main.adjustSize(); + QCOMPARE(main.size(), QSize(200, 10)); +} + QTEST_MAIN(tst_QLayout) #include "tst_qlayout.moc" -- cgit v0.12 From a6b0316c2418a90cb754132a678c38027009e875 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 20 Oct 2009 15:33:29 +0200 Subject: Moved private function to test which graphic items is in front of the other This function is moved to graphicsitem private because it is needed by multi-touch event handling and is not specific to bsptreeindex. Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- src/gui/graphicsview/qgraphicsitem_p.h | 68 +++++++++++++++++++++- .../graphicsview/qgraphicsscenebsptreeindex.cpp | 68 +--------------------- .../graphicsview/qgraphicsscenebsptreeindex_p.h | 2 - tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 43 ++++++++++++++ 5 files changed, 113 insertions(+), 70 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 1ebee45..4b2ff52 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4737,7 +4737,7 @@ bool QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const { if (!item) return false; - return QGraphicsSceneBspTreeIndexPrivate::closestItemFirst_withoutCache(item, this) + return qt_closestItemFirst(item, this) && qt_QGraphicsItem_isObscured(this, item, boundingRect()); } diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 6550362..38145ac 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -623,6 +623,72 @@ public: /*! + Returns true if \a item1 is on top of \a item2. + The items dont need to be siblings. + + \internal +*/ +inline bool qt_closestItemFirst(const QGraphicsItem *item1, const QGraphicsItem *item2) +{ + // Siblings? Just check their z-values. + const QGraphicsItemPrivate *d1 = item1->d_ptr.data(); + const QGraphicsItemPrivate *d2 = item2->d_ptr.data(); + if (d1->parent == d2->parent) + return qt_closestLeaf(item1, item2); + + // Find common ancestor, and each item's ancestor closest to the common + // ancestor. + int item1Depth = d1->depth(); + int item2Depth = d2->depth(); + const QGraphicsItem *p = item1; + const QGraphicsItem *t1 = item1; + while (item1Depth > item2Depth && (p = p->d_ptr->parent)) { + if (p == item2) { + // item2 is one of item1's ancestors; item1 is on top + return !(t1->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent); + } + t1 = p; + --item1Depth; + } + p = item2; + const QGraphicsItem *t2 = item2; + while (item2Depth > item1Depth && (p = p->d_ptr->parent)) { + if (p == item1) { + // item1 is one of item2's ancestors; item1 is not on top + return (t2->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent); + } + t2 = p; + --item2Depth; + } + + // item1Ancestor is now at the same level as item2Ancestor, but not the same. + const QGraphicsItem *a1 = t1; + const QGraphicsItem *a2 = t2; + while (a1) { + const QGraphicsItem *p1 = a1; + const QGraphicsItem *p2 = a2; + a1 = a1->parentItem(); + a2 = a2->parentItem(); + if (a1 && a1 == a2) + return qt_closestLeaf(p1, p2); + } + + // No common ancestor? Then just compare the items' toplevels directly. + return qt_closestLeaf(t1->topLevelItem(), t2->topLevelItem()); +} + +/*! + Returns true if \a item2 is on top of \a item1. + The items dont need to be siblings. + + \internal +*/ +inline bool qt_closestItemLast(const QGraphicsItem *item1, const QGraphicsItem *item2) +{ + return qt_closestItemFirst(item2, item1); +} + +/*! \internal */ inline bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2) @@ -642,7 +708,7 @@ inline bool qt_closestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item /*! \internal */ -static inline bool qt_notclosestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2) +inline bool qt_notclosestLeaf(const QGraphicsItem *item1, const QGraphicsItem *item2) { return qt_closestLeaf(item2, item1); } /* diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp index e21183a..47ae3f1 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex.cpp @@ -405,70 +405,6 @@ QList QGraphicsSceneBspTreeIndexPrivate::estimateItems(const QR } /*! - Returns true if \a item1 is on top of \a item2. - - \internal -*/ -bool QGraphicsSceneBspTreeIndexPrivate::closestItemFirst_withoutCache(const QGraphicsItem *item1, const QGraphicsItem *item2) -{ - // Siblings? Just check their z-values. - const QGraphicsItemPrivate *d1 = item1->d_ptr.data(); - const QGraphicsItemPrivate *d2 = item2->d_ptr.data(); - if (d1->parent == d2->parent) - return qt_closestLeaf(item1, item2); - - // Find common ancestor, and each item's ancestor closest to the common - // ancestor. - int item1Depth = d1->depth(); - int item2Depth = d2->depth(); - const QGraphicsItem *p = item1; - const QGraphicsItem *t1 = item1; - while (item1Depth > item2Depth && (p = p->d_ptr->parent)) { - if (p == item2) { - // item2 is one of item1's ancestors; item1 is on top - return !(t1->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent); - } - t1 = p; - --item1Depth; - } - p = item2; - const QGraphicsItem *t2 = item2; - while (item2Depth > item1Depth && (p = p->d_ptr->parent)) { - if (p == item1) { - // item1 is one of item2's ancestors; item1 is not on top - return (t2->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent); - } - t2 = p; - --item2Depth; - } - - // item1Ancestor is now at the same level as item2Ancestor, but not the same. - const QGraphicsItem *a1 = t1; - const QGraphicsItem *a2 = t2; - while (a1) { - const QGraphicsItem *p1 = a1; - const QGraphicsItem *p2 = a2; - a1 = a1->parentItem(); - a2 = a2->parentItem(); - if (a1 && a1 == a2) - return qt_closestLeaf(p1, p2); - } - - // No common ancestor? Then just compare the items' toplevels directly. - return qt_closestLeaf(t1->topLevelItem(), t2->topLevelItem()); -} - -/*! - Returns true if \a item2 is on top of \a item1. - - \internal -*/ -bool QGraphicsSceneBspTreeIndexPrivate::closestItemLast_withoutCache(const QGraphicsItem *item1, const QGraphicsItem *item2) -{ - return closestItemFirst_withoutCache(item2, item1); -} - -/*! Sort a list of \a itemList in a specific \a order and use the cache if requested. \internal @@ -495,9 +431,9 @@ void QGraphicsSceneBspTreeIndexPrivate::sortItems(QList *itemLi } } else { if (order == Qt::DescendingOrder) { - qSort(itemList->begin(), itemList->end(), closestItemFirst_withoutCache); + qSort(itemList->begin(), itemList->end(), qt_closestItemFirst); } else if (order == Qt::AscendingOrder) { - qSort(itemList->begin(), itemList->end(), closestItemLast_withoutCache); + qSort(itemList->begin(), itemList->end(), qt_closestItemLast); } } } diff --git a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h index 0a86bb7..c130190 100644 --- a/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h +++ b/src/gui/graphicsview/qgraphicsscenebsptreeindex_p.h @@ -145,8 +145,6 @@ public: QList estimateItems(const QRectF &, Qt::SortOrder, bool b = false); static void climbTree(QGraphicsItem *item, int *stackingOrder); - static bool closestItemFirst_withoutCache(const QGraphicsItem *item1, const QGraphicsItem *item2); - static bool closestItemLast_withoutCache(const QGraphicsItem *item1, const QGraphicsItem *item2); static inline bool closestItemFirst_withCache(const QGraphicsItem *item1, const QGraphicsItem *item2) { diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 0a6f60e..dcad8e1 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -398,6 +398,7 @@ private slots: void modality_mouseGrabber(); void modality_clickFocus(); void modality_keyEvents(); + void itemIsInFront(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -9541,5 +9542,47 @@ void tst_QGraphicsItem::modality_keyEvents() QCOMPARE(rect1Spy.counts[QEvent::KeyRelease], 0); } +void tst_QGraphicsItem::itemIsInFront() +{ + QGraphicsScene scene; + QGraphicsRectItem *rect1 = new QGraphicsRectItem; + rect1->setData(0, "rect1"); + scene.addItem(rect1); + + QGraphicsRectItem *rect1child1 = new QGraphicsRectItem(rect1); + rect1child1->setZValue(1); + rect1child1->setData(0, "rect1child1"); + + QGraphicsRectItem *rect1child2 = new QGraphicsRectItem(rect1); + rect1child2->setParentItem(rect1); + rect1child2->setData(0, "rect1child2"); + + QGraphicsRectItem *rect1child1_1 = new QGraphicsRectItem(rect1child1); + rect1child1_1->setData(0, "rect1child1_1"); + + QGraphicsRectItem *rect1child1_2 = new QGraphicsRectItem(rect1child1); + rect1child1_2->setFlag(QGraphicsItem::ItemStacksBehindParent); + rect1child1_2->setData(0, "rect1child1_2"); + + QGraphicsRectItem *rect2 = new QGraphicsRectItem; + rect2->setData(0, "rect2"); + scene.addItem(rect2); + + QGraphicsRectItem *rect2child1 = new QGraphicsRectItem(rect2); + rect2child1->setData(0, "rect2child1"); + + QCOMPARE(qt_closestItemFirst(rect1, rect1), false); + QCOMPARE(qt_closestItemFirst(rect1, rect2), false); + QCOMPARE(qt_closestItemFirst(rect1child1, rect2child1), false); + QCOMPARE(qt_closestItemFirst(rect1child1, rect1child2), true); + QCOMPARE(qt_closestItemFirst(rect1child1_1, rect1child2), true); + QCOMPARE(qt_closestItemFirst(rect1child1_1, rect1child1), true); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1child2), true); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1child1), false); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect1), true); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2), false); + QCOMPARE(qt_closestItemFirst(rect1child1_2, rect2child1), false); +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From ed2ff6553ec481bd489df096d5ec1cdb545ebb33 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Tue, 20 Oct 2009 16:12:55 +0200 Subject: Optimization in qt_closestItemFirst private function No need to traverse the tree again to access the topLevelItem in case there is no common ancestor. Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem_p.h | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 38145ac..8621b11 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -662,19 +662,18 @@ inline bool qt_closestItemFirst(const QGraphicsItem *item1, const QGraphicsItem } // item1Ancestor is now at the same level as item2Ancestor, but not the same. - const QGraphicsItem *a1 = t1; - const QGraphicsItem *a2 = t2; - while (a1) { - const QGraphicsItem *p1 = a1; - const QGraphicsItem *p2 = a2; - a1 = a1->parentItem(); - a2 = a2->parentItem(); - if (a1 && a1 == a2) - return qt_closestLeaf(p1, p2); + const QGraphicsItem *p1 = t1; + const QGraphicsItem *p2 = t2; + while (t1 && t1 != t2) { + p1 = t1; + p2 = t2; + t1 = t1->d_ptr->parent; + t2 = t2->d_ptr->parent; } - // No common ancestor? Then just compare the items' toplevels directly. - return qt_closestLeaf(t1->topLevelItem(), t2->topLevelItem()); + // in case we have a common ancestor, we compare the immediate children in the ancestor's path. + // otherwise we compare the respective items' topLevelItems directly. + return qt_closestLeaf(p1, p2); } /*! -- cgit v0.12 From 84cfe9af5e333872ac67368a6b14c377ceeda8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Trond=20Kjern=C3=A5sen?= Date: Tue, 20 Oct 2009 17:51:15 +0200 Subject: Fixed an assert when running the composition demo on Mac. We can't create a QGLWidget in the QGLEngineSelector, since it may be called before a QApplication object has been constructed. Reviewed-by: Kim --- src/opengl/qgl.cpp | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/opengl/qgl.cpp b/src/opengl/qgl.cpp index 97e3dad..6720ae7 100644 --- a/src/opengl/qgl.cpp +++ b/src/opengl/qgl.cpp @@ -151,22 +151,6 @@ class QGLEngineSelector public: QGLEngineSelector() : engineType(QPaintEngine::MaxUser) { -#ifdef Q_WS_MAC - // The ATI X1600 driver for Mac OS X does not support return - // values from functions in GLSL. Since working around this in - // the GL2 engine would require a big, ugly rewrite, we're - // falling back to the GL 1 engine.. - QGLWidget *tmp = 0; - if (!QGLContext::currentContext()) { - tmp = new QGLWidget(); - tmp->makeCurrent(); - } - if (strstr((char *) glGetString(GL_RENDERER), "X1600")) - setPreferredPaintEngine(QPaintEngine::OpenGL); - if (tmp) - delete tmp; -#endif - } void setPreferredPaintEngine(QPaintEngine::Type type) { @@ -175,6 +159,25 @@ public: } QPaintEngine::Type preferredPaintEngine() { +#ifdef Q_WS_MAC + // The ATI X1600 driver for Mac OS X does not support return + // values from functions in GLSL. Since working around this in + // the GL2 engine would require a big, ugly rewrite, we're + // falling back to the GL 1 engine.. + static bool mac_x1600_check_done = false; + if (!mac_x1600_check_done) { + QGLWidget *tmp = 0; + if (!QGLContext::currentContext()) { + tmp = new QGLWidget(); + tmp->makeCurrent(); + } + if (strstr((char *) glGetString(GL_RENDERER), "X1600")) + engineType = QPaintEngine::OpenGL; + if (tmp) + delete tmp; + mac_x1600_check_done = true; + } +#endif if (engineType == QPaintEngine::MaxUser) { // No user-set engine - use the defaults #if defined(QT_OPENGL_ES_2) -- cgit v0.12 From 9b6753eac7439caa2dd8915ed3616cef6d1f6cd0 Mon Sep 17 00:00:00 2001 From: Iain Date: Wed, 21 Oct 2009 01:26:15 +0300 Subject: Update EABI DEF files for Symbian OS Reviewed-by: TrustMe --- src/s60installs/eabi/QtGuiu.def | 45 ++++++++++++++++++++++++++++------ src/s60installs/eabi/QtMultimediau.def | 5 ++-- src/s60installs/eabi/QtNetworku.def | 4 +++ src/s60installs/eabi/QtScriptu.def | 1 + src/s60installs/eabi/phononu.def | 10 ++++++++ 5 files changed, 55 insertions(+), 10 deletions(-) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 7c3542e..19afd9a 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -2288,7 +2288,7 @@ EXPORTS _ZN13QGestureEvent11setAcceptedEP8QGestureb @ 2287 NONAME _ZN13QGestureEvent6acceptEP8QGesture @ 2288 NONAME _ZN13QGestureEvent6ignoreEP8QGesture @ 2289 NONAME - _ZN13QGestureEvent7gestureEN2Qt11GestureTypeE @ 2290 NONAME + _ZN13QGestureEvent7gestureEN2Qt11GestureTypeE @ 2290 NONAME ABSENT _ZN13QGestureEventC1ERK5QListIP8QGestureE @ 2291 NONAME _ZN13QGestureEventC2ERK5QListIP8QGestureE @ 2292 NONAME _ZN13QGraphicsItem10addToIndexEv @ 2293 NONAME @@ -2651,8 +2651,8 @@ EXPORTS _ZN13QSwipeGesture13setSwipeAngleEf @ 2650 NONAME _ZN13QSwipeGesture16staticMetaObjectE @ 2651 NONAME DATA 16 _ZN13QSwipeGesture19getStaticMetaObjectEv @ 2652 NONAME - _ZN13QSwipeGesture20setVerticalDirectionENS_14SwipeDirectionE @ 2653 NONAME - _ZN13QSwipeGesture22setHorizontalDirectionENS_14SwipeDirectionE @ 2654 NONAME + _ZN13QSwipeGesture20setVerticalDirectionENS_14SwipeDirectionE @ 2653 NONAME ABSENT + _ZN13QSwipeGesture22setHorizontalDirectionENS_14SwipeDirectionE @ 2654 NONAME ABSENT _ZN13QSwipeGestureC1EP7QObject @ 2655 NONAME _ZN13QSwipeGestureC2EP7QObject @ 2656 NONAME _ZN13QTextDocument10adjustSizeEv @ 2657 NONAME @@ -3124,7 +3124,7 @@ EXPORTS _ZN14QWidgetPrivate20setLayoutItemMarginsEiiii @ 3123 NONAME _ZN14QWidgetPrivate20setWindowIcon_helperEv @ 3124 NONAME _ZN14QWidgetPrivate20setWindowOpacity_sysEf @ 3125 NONAME - _ZN14QWidgetPrivate21activateSymbianWindowEv @ 3126 NONAME + _ZN14QWidgetPrivate21activateSymbianWindowEv @ 3126 NONAME ABSENT _ZN14QWidgetPrivate21setMaximumSize_helperERiS0_ @ 3127 NONAME _ZN14QWidgetPrivate21setMinimumSize_helperERiS0_ @ 3128 NONAME _ZN14QWidgetPrivate21setWindowIconText_sysERK7QString @ 3129 NONAME @@ -6369,12 +6369,12 @@ EXPORTS _ZN8QGesture15setTargetObjectEP7QObject @ 6368 NONAME _ZN8QGesture16staticMetaObjectE @ 6369 NONAME DATA 16 _ZN8QGesture19getStaticMetaObjectEv @ 6370 NONAME - _ZN8QGestureC1EN2Qt11GestureTypeEP7QObject @ 6371 NONAME + _ZN8QGestureC1EN2Qt11GestureTypeEP7QObject @ 6371 NONAME ABSENT _ZN8QGestureC1EP7QObject @ 6372 NONAME - _ZN8QGestureC1ER15QGesturePrivateN2Qt11GestureTypeEP7QObject @ 6373 NONAME - _ZN8QGestureC2EN2Qt11GestureTypeEP7QObject @ 6374 NONAME + _ZN8QGestureC1ER15QGesturePrivateN2Qt11GestureTypeEP7QObject @ 6373 NONAME ABSENT + _ZN8QGestureC2EN2Qt11GestureTypeEP7QObject @ 6374 NONAME ABSENT _ZN8QGestureC2EP7QObject @ 6375 NONAME - _ZN8QGestureC2ER15QGesturePrivateN2Qt11GestureTypeEP7QObject @ 6376 NONAME + _ZN8QGestureC2ER15QGesturePrivateN2Qt11GestureTypeEP7QObject @ 6376 NONAME ABSENT _ZN8QGestureD0Ev @ 6377 NONAME _ZN8QGestureD1Ev @ 6378 NONAME _ZN8QGestureD2Ev @ 6379 NONAME @@ -11557,4 +11557,33 @@ EXPORTS qt_pixmap_cleanup_hook @ 11556 NONAME DATA 4 qt_pixmap_cleanup_hook_64 @ 11557 NONAME DATA 4 qt_tab_all_widgets @ 11558 NONAME DATA 1 + _Z22qt_paint_device_metricPK12QPaintDeviceNS_17PaintDeviceMetricE @ 11559 NONAME + _ZN14QWidgetPrivate17_q_delayedDestroyEP11CCoeControl @ 11560 NONAME + _ZN14QWidgetPrivate21activateSymbianWindowEP11CCoeControl @ 11561 NONAME + _ZN18QGuiPlatformPlugin11qt_metacallEN11QMetaObject4CallEiPPv @ 11562 NONAME + _ZN18QGuiPlatformPlugin11qt_metacastEPKc @ 11563 NONAME + _ZN18QGuiPlatformPlugin12platformHintENS_12PlatformHintE @ 11564 NONAME + _ZN18QGuiPlatformPlugin14fileSystemIconERK9QFileInfo @ 11565 NONAME + _ZN18QGuiPlatformPlugin16staticMetaObjectE @ 11566 NONAME DATA 16 + _ZN18QGuiPlatformPlugin19getStaticMetaObjectEv @ 11567 NONAME + _ZN18QGuiPlatformPlugin19systemIconThemeNameEv @ 11568 NONAME + _ZN18QGuiPlatformPlugin20iconThemeSearchPathsEv @ 11569 NONAME + _ZN18QGuiPlatformPlugin7paletteEv @ 11570 NONAME + _ZN18QGuiPlatformPlugin9styleNameEv @ 11571 NONAME + _ZN18QGuiPlatformPluginC1EP7QObject @ 11572 NONAME + _ZN18QGuiPlatformPluginC2EP7QObject @ 11573 NONAME + _ZN18QGuiPlatformPluginD0Ev @ 11574 NONAME + _ZN18QGuiPlatformPluginD1Ev @ 11575 NONAME + _ZN18QGuiPlatformPluginD2Ev @ 11576 NONAME + _ZN8QGestureC1ER15QGesturePrivateP7QObject @ 11577 NONAME + _ZN8QGestureC2ER15QGesturePrivateP7QObject @ 11578 NONAME + _ZNK11QPixmapData26createCompatiblePixmapDataEv @ 11579 NONAME + _ZNK13QGestureEvent7gestureEN2Qt11GestureTypeE @ 11580 NONAME + _ZNK17QRasterPixmapData26createCompatiblePixmapDataEv @ 11581 NONAME + _ZNK18QGuiPlatformPlugin10metaObjectEv @ 11582 NONAME + _ZTI18QGuiPlatformPlugin @ 11583 NONAME + _ZTI27QGuiPlatformPluginInterface @ 11584 NONAME + _ZTV18QGuiPlatformPlugin @ 11585 NONAME + _ZThn8_N18QGuiPlatformPluginD0Ev @ 11586 NONAME + _ZThn8_N18QGuiPlatformPluginD1Ev @ 11587 NONAME diff --git a/src/s60installs/eabi/QtMultimediau.def b/src/s60installs/eabi/QtMultimediau.def index 787ad3a..c946056 100644 --- a/src/s60installs/eabi/QtMultimediau.def +++ b/src/s60installs/eabi/QtMultimediau.def @@ -115,8 +115,8 @@ EXPORTS _ZN19QAbstractAudioInput6notifyEv @ 114 NONAME _ZN19QVideoSurfaceFormat11setPropertyEPKcRK8QVariant @ 115 NONAME _ZN19QVideoSurfaceFormat11setViewportERK5QRect @ 116 NONAME - _ZN19QVideoSurfaceFormat12setFrameRateERK5QPairIiiE @ 117 NONAME - _ZN19QVideoSurfaceFormat12setFrameRateEii @ 118 NONAME + _ZN19QVideoSurfaceFormat12setFrameRateERK5QPairIiiE @ 117 NONAME ABSENT + _ZN19QVideoSurfaceFormat12setFrameRateEii @ 118 NONAME ABSENT _ZN19QVideoSurfaceFormat12setFrameSizeERK5QSizeNS_12ViewportModeE @ 119 NONAME _ZN19QVideoSurfaceFormat12setFrameSizeEiiNS_12ViewportModeE @ 120 NONAME _ZN19QVideoSurfaceFormat16setYuvColorSpaceENS_13YuvColorSpaceE @ 121 NONAME @@ -275,4 +275,5 @@ EXPORTS _ZThn8_N18QAudioEnginePluginD0Ev @ 274 NONAME _ZThn8_N18QAudioEnginePluginD1Ev @ 275 NONAME _Zls6QDebugRK19QVideoSurfaceFormat @ 276 NONAME + _ZN19QVideoSurfaceFormat12setFrameRateEf @ 277 NONAME diff --git a/src/s60installs/eabi/QtNetworku.def b/src/s60installs/eabi/QtNetworku.def index f216f85..c37c4a0 100644 --- a/src/s60installs/eabi/QtNetworku.def +++ b/src/s60installs/eabi/QtNetworku.def @@ -989,4 +989,8 @@ EXPORTS _ZlsR11QDataStreamRK21QNetworkCacheMetaData @ 988 NONAME _ZrsR11QDataStreamR12QHostAddress @ 989 NONAME _ZrsR11QDataStreamR21QNetworkCacheMetaData @ 990 NONAME + _ZN10QSslSocket12socketOptionEN15QAbstractSocket12SocketOptionE @ 991 NONAME + _ZN10QSslSocket15setSocketOptionEN15QAbstractSocket12SocketOptionERK8QVariant @ 992 NONAME + _ZN15QNetworkRequest20setOriginatingObjectEP7QObject @ 993 NONAME + _ZNK15QNetworkRequest17originatingObjectEv @ 994 NONAME diff --git a/src/s60installs/eabi/QtScriptu.def b/src/s60installs/eabi/QtScriptu.def index d0a3e3e..1592664 100644 --- a/src/s60installs/eabi/QtScriptu.def +++ b/src/s60installs/eabi/QtScriptu.def @@ -341,4 +341,5 @@ EXPORTS _ZThn8_N22QScriptExtensionPluginD1Ev @ 340 NONAME _ZlsR11QDataStreamRK18QScriptContextInfo @ 341 NONAME _ZrsR11QDataStreamR18QScriptContextInfo @ 342 NONAME + _Z5qHashRK13QScriptString @ 343 NONAME diff --git a/src/s60installs/eabi/phononu.def b/src/s60installs/eabi/phononu.def index 651a0b8..af1e3cc 100644 --- a/src/s60installs/eabi/phononu.def +++ b/src/s60installs/eabi/phononu.def @@ -534,4 +534,14 @@ EXPORTS _ZThn8_N6Phonon19AbstractAudioOutputD1Ev @ 533 NONAME _ZThn8_N6Phonon6EffectD0Ev @ 534 NONAME _ZThn8_N6Phonon6EffectD1Ev @ 535 NONAME + _ZTIN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE0EEE @ 536 NONAME + _ZTIN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE1EEE @ 537 NONAME + _ZTIN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE2EEE @ 538 NONAME + _ZTIN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE3EEE @ 539 NONAME + _ZTIN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE4EEE @ 540 NONAME + _ZTVN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE0EEE @ 541 NONAME + _ZTVN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE1EEE @ 542 NONAME + _ZTVN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE2EEE @ 543 NONAME + _ZTVN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE3EEE @ 544 NONAME + _ZTVN6Phonon22ObjectDescriptionModelILNS_21ObjectDescriptionTypeE4EEE @ 545 NONAME -- cgit v0.12 From 619d049371ac8a180de3d91140bf252f44c25dad Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 21 Oct 2009 10:15:19 +0200 Subject: Improve performance when starting a lot of animations We avoid stopping/starting the timer over and over again Patch suggested by Aaron. Reviewed-by: Aaron Kennedy --- src/corelib/animation/qabstractanimation.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 0d5f278..2f776d3 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -272,7 +272,8 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopL Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer); QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true; animationsToStart << animation; - startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); + if (!startStopAnimationTimer.isActive()) + startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); } } @@ -290,7 +291,7 @@ void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) if (idx <= currentAnimationIdx) --currentAnimationIdx; - if (animations.isEmpty()) + if (animations.isEmpty() && !startStopAnimationTimer.isActive()) startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this); } else { animationsToStart.removeOne(animation); -- cgit v0.12 From a072ddb5072d837ff6d2ff1f09800e8e3917f034 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 21 Oct 2009 10:49:42 +0200 Subject: Fixes to the way animations are registered to the timer It could happen that an animation would be unregistered when it shouldn't. Reviewed-by: Leo Cunha --- src/corelib/animation/qabstractanimation.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 2f776d3..f83c2a1 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -279,11 +279,11 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopL void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation) { + unregisterRunningAnimation(animation); + if (!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer) return; - unregisterRunningAnimation(animation); - int idx = animations.indexOf(animation); if (idx != -1) { animations.removeAt(idx); @@ -384,25 +384,20 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) QUnifiedTimer::instance()->ensureTimerUpdate(q); if (!guard) return; + //here we're sure that we were in running state before and that the + //animation is currently registered QUnifiedTimer::instance()->unregisterAnimation(q); break; case QAbstractAnimation::Running: { bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped; + QUnifiedTimer::instance()->registerAnimation(q, isTopLevel); // this ensures that the value is updated now that the animation is running if (oldState == QAbstractAnimation::Stopped) { if (isTopLevel) // currentTime needs to be updated if pauseTimer is active QUnifiedTimer::instance()->ensureTimerUpdate(q); - if (!guard) - return; - } - - // test needed in case we stop in the setCurrentTime inside ensureTimerUpdate (zero duration) - if (state == QAbstractAnimation::Running) { - // register timer if our parent is not running - QUnifiedTimer::instance()->registerAnimation(q, isTopLevel); } } break; @@ -415,7 +410,8 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) if (deleteWhenStopped) q->deleteLater(); - QUnifiedTimer::instance()->unregisterAnimation(q); + if (oldState == QAbstractAnimation::Running) + QUnifiedTimer::instance()->unregisterAnimation(q); if (dura == -1 || loopCount < 0 || (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount)) @@ -462,7 +458,8 @@ QAbstractAnimation::~QAbstractAnimation() QAbstractAnimation::State oldState = d->state; d->state = Stopped; emit stateChanged(oldState, d->state); - QUnifiedTimer::instance()->unregisterAnimation(this); + if (oldState == QAbstractAnimation::Running) + QUnifiedTimer::instance()->unregisterAnimation(this); } } -- cgit v0.12 From 7b09b0eda2f3e5bc34150669157287ccb85c8d72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Tue, 20 Oct 2009 13:17:58 +0200 Subject: Group the spacing functions together, and add a sizePolicy property. Improve the documentation for size policy. --- src/gui/graphicsview/qgraphicsanchorlayout.cpp | 22 ++++++++++++++++------ src/gui/graphicsview/qgraphicsanchorlayout.h | 3 ++- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.cpp b/src/gui/graphicsview/qgraphicsanchorlayout.cpp index c39e8a6..c7d2bb7 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.cpp +++ b/src/gui/graphicsview/qgraphicsanchorlayout.cpp @@ -118,16 +118,26 @@ QGraphicsAnchor::~QGraphicsAnchor() } /*! - Sets the size policy of the anchor to \a policy. + \property QGraphicsAnchor::sizePolicy + \brief the size policy for the QGraphicsAnchor. + + By setting the size policy on an anchor you can configure how the item can resize itself + from its preferred spacing. For instance, if the anchor has the size policy + QSizePolicy::Minimum, the spacing is the minimum size of the anchor. However, its size + can grow up to the anchors maximum size. If the default size policy is QSizePolicy::Fixed, + the anchor can neither grow or shrink, which means that the only size the anchor can have + is the spacing. QSizePolicy::Fixed is the default size policy. + QGraphicsAnchor always has a minimum spacing of 0 and a very large maximum spacing. + + \sa QGraphicsAnchor::spacing */ + void QGraphicsAnchor::setSizePolicy(QSizePolicy::Policy policy) { Q_D(QGraphicsAnchor); d->setSizePolicy(policy); } -/*! - Returns the size policy of the anchor. The default size policy is QSizePolicy::Fixed -*/ + QSizePolicy::Policy QGraphicsAnchor::sizePolicy() const { Q_D(const QGraphicsAnchor); @@ -136,12 +146,12 @@ QSizePolicy::Policy QGraphicsAnchor::sizePolicy() const /*! \property QGraphicsAnchor::spacing - \brief the space between items in the QGraphicsAnchorLayout. + \brief the preferred space between items in the QGraphicsAnchorLayout. Depending on the anchor type, the default spacing is either 0 or a value returned from the style. - \sa QGraphicsAnchorLayout::anchor() + \sa QGraphicsAnchorLayout::addAnchor() */ void QGraphicsAnchor::setSpacing(qreal spacing) { diff --git a/src/gui/graphicsview/qgraphicsanchorlayout.h b/src/gui/graphicsview/qgraphicsanchorlayout.h index f09ac43..01c3a86 100644 --- a/src/gui/graphicsview/qgraphicsanchorlayout.h +++ b/src/gui/graphicsview/qgraphicsanchorlayout.h @@ -62,12 +62,13 @@ class Q_GUI_EXPORT QGraphicsAnchor : public QObject { Q_OBJECT Q_PROPERTY(qreal spacing READ spacing WRITE setSpacing RESET unsetSpacing) + Q_PROPERTY(QSizePolicy::Policy sizePolicy READ sizePolicy WRITE setSizePolicy) public: void setSpacing(qreal spacing); void unsetSpacing(); + qreal spacing() const; void setSizePolicy(QSizePolicy::Policy policy); QSizePolicy::Policy sizePolicy() const; - qreal spacing() const; ~QGraphicsAnchor(); private: QGraphicsAnchor(QGraphicsAnchorLayout *parent); -- cgit v0.12 From 140d5af0f8635397c48f160bb8a33861b332c171 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Wed, 21 Oct 2009 11:04:32 +0200 Subject: Clips color interpolation to range [0, 255] This avoid warnings when using easing curves that progress outside the range [0.0, 1.0]. Patch proposed by warwick. Reviewed-by: Warwick Allison --- src/gui/animation/qguivariantanimation.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/animation/qguivariantanimation.cpp b/src/gui/animation/qguivariantanimation.cpp index 0ae79b6..1e9c166 100644 --- a/src/gui/animation/qguivariantanimation.cpp +++ b/src/gui/animation/qguivariantanimation.cpp @@ -54,10 +54,10 @@ QT_BEGIN_NAMESPACE template<> Q_INLINE_TEMPLATE QColor _q_interpolate(const QColor &f,const QColor &t, qreal progress) { - return QColor(_q_interpolate(f.red(), t.red(), progress), - _q_interpolate(f.green(), t.green(), progress), - _q_interpolate(f.blue(), t.blue(), progress), - _q_interpolate(f.alpha(), t.alpha(), progress)); + return QColor(qBound(0,_q_interpolate(f.red(), t.red(), progress),255), + qBound(0,_q_interpolate(f.green(), t.green(), progress),255), + qBound(0,_q_interpolate(f.blue(), t.blue(), progress),255), + qBound(0,_q_interpolate(f.alpha(), t.alpha(), progress),255)); } template<> Q_INLINE_TEMPLATE QQuaternion _q_interpolate(const QQuaternion &f,const QQuaternion &t, qreal progress) -- cgit v0.12 From 3be273fc751624fab078878904ad3cb483cd141f Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Wed, 21 Oct 2009 13:31:07 +0200 Subject: Properly detect font smoothing setting on Mac OS X in raster engine MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We would assume font smoothing on the mac was always turned on, giving poor text rendering in the cases where it was not. This implementation mirrors querying the cleartype setting on Windows, checking the setting on application initialization and rendering into an 8 bit cache if it is turned off. Task-number: QTBUG-4881 Reviewed-by: Morten Johan Sørvig --- src/gui/kernel/qapplication_mac.mm | 11 +++++++++++ src/gui/painting/qpaintengine_raster.cpp | 6 +++++- src/gui/painting/qtextureglyphcache.cpp | 4 ++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qapplication_mac.mm b/src/gui/kernel/qapplication_mac.mm index f9c8aa3..771cddc 100644 --- a/src/gui/kernel/qapplication_mac.mm +++ b/src/gui/kernel/qapplication_mac.mm @@ -203,6 +203,8 @@ static EventHandlerRef tablet_proximity_handler = 0; static EventHandlerUPP tablet_proximity_UPP = 0; bool QApplicationPrivate::native_modal_dialog_active; +Q_GUI_EXPORT bool qt_applefontsmoothing_enabled; + /***************************************************************************** External functions *****************************************************************************/ @@ -222,6 +224,12 @@ extern bool qt_sendSpontaneousEvent(QObject *obj, QEvent *event); // qapplicatio void onApplicationWindowChangedActivation( QWidget*widget, bool activated ); void onApplicationChangedActivation( bool activated ); +static void qt_mac_read_fontsmoothing_settings() +{ + NSInteger appleFontSmoothing = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleFontSmoothing"]; + qt_applefontsmoothing_enabled = (appleFontSmoothing > 0); +} + Q_GUI_EXPORT bool qt_mac_execute_apple_script(const char *script, long script_len, AEDesc *ret) { OSStatus err; AEDesc scriptTextDesc; @@ -1203,6 +1211,9 @@ void qt_init(QApplicationPrivate *priv, int) } if (QApplication::desktopSettingsAware()) QApplicationPrivate::qt_mac_apply_settings(); + + qt_mac_read_fontsmoothing_settings(); + // Cocoa application delegate #ifdef QT_MAC_USE_COCOA NSApplication *cocoaApp = [NSApplication sharedApplication]; diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index fab2d8d..fd0e810 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -132,6 +132,10 @@ static const qreal aliasedCoordinateDelta = 0.5 - 0.015625; extern bool qt_cleartype_enabled; #endif +#ifdef Q_WS_MAC +extern bool qt_applefontsmoothing_enabled; +#endif + /******************************************************************************** * Span functions @@ -508,7 +512,7 @@ bool QRasterPaintEngine::begin(QPaintDevice *device) #if defined(Q_WS_WIN) else if (qt_cleartype_enabled) #elif defined (Q_WS_MAC) - else if (true) + else if (qt_applefontsmoothing_enabled) #else else if (false) #endif diff --git a/src/gui/painting/qtextureglyphcache.cpp b/src/gui/painting/qtextureglyphcache.cpp index 25b6aba..a192e87 100644 --- a/src/gui/painting/qtextureglyphcache.cpp +++ b/src/gui/painting/qtextureglyphcache.cpp @@ -229,8 +229,8 @@ void QImageTextureGlyphCache::createTextureData(int width, int height) int QImageTextureGlyphCache::glyphMargin() const { -#ifdef Q_WS_MAC - return 2; +#if defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA) + return 0; #else return m_type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; #endif -- cgit v0.12 From cdb98c137db4d051e4b41c9fa4626c4c369cc0b1 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Wed, 21 Oct 2009 13:24:06 +0200 Subject: Improved QFontInfo::pointSize() slightly on X11. In non-GUI applications on X11, QFont and QFontInfo return different point size because for QFontInfo, the point size is converted to pixel size and back, but with different dpis. This commit improves the situation for the case where font config is used, but the bug still needs to be fixed properly by using the same dpi for all point<->pixel size conversions. Reviewed-by: Trond --- src/gui/text/qfontdatabase_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qfontdatabase_x11.cpp b/src/gui/text/qfontdatabase_x11.cpp index 382c4fe..27ff003 100644 --- a/src/gui/text/qfontdatabase_x11.cpp +++ b/src/gui/text/qfontdatabase_x11.cpp @@ -752,7 +752,7 @@ QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &request) if (X11->display) dpi = QX11Info::appDpiY(); else - dpi = 96; // #### + dpi = qt_defaultDpiY(); } double size; -- cgit v0.12 From 0bf8f2cbc596280b86d53e19b2bde316c2cafe3f Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Wed, 21 Oct 2009 14:26:33 +0200 Subject: Added doc warning about ARGB32 image drawing and fixed format docs --- src/gui/image/qimage.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 21ab40c..571ef9d 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -546,11 +546,7 @@ bool QImageData::checkForAlphaPixels() const Each pixel stored in a QImage is represented by an integer. The size of the integer varies depending on the format. QImage supports several image formats described by the \l Format - enum. The monochrome (1-bit), 8-bit and 32-bit images are - available in all versions of Qt. In addition Qt for Embedded Linux - also supports 2-bit, 4-bit, and 16-bit images. For more information - about the Qt Extended specific formats, see the documentation of the \l - Format enum. + enum. Monochrome images are stored using 1-bit indexes into a color table with at most two colors. There are two different types of @@ -707,9 +703,20 @@ bool QImageData::checkForAlphaPixels() const packed with the most significant bit (MSB) first. \value Format_MonoLSB The image is stored using 1-bit per pixel. Bytes are packed with the less significant bit (LSB) first. - \value Format_Indexed8 The image is stored using 8-bit indexes into a colormap. + + \value Format_Indexed8 The image is stored using 8-bit indexes + into a colormap. \warning Drawing into a + QImage with Indexed8 format is not + supported. + \value Format_RGB32 The image is stored using a 32-bit RGB format (0xffRRGGBB). - \value Format_ARGB32 The image is stored using a 32-bit ARGB format (0xAARRGGBB). + + \value Format_ARGB32 The image is stored using a 32-bit ARGB + format (0xAARRGGBB). \warning Do not + render into ARGB32 images using + QPainter. Format_ARGB32_Premultiplied is + significantly faster. + \value Format_ARGB32_Premultiplied The image is stored using a premultiplied 32-bit ARGB format (0xAARRGGBB), i.e. the red, green, and blue channels are multiplied @@ -718,7 +725,9 @@ bool QImageData::checkForAlphaPixels() const undefined.) Certain operations (such as image composition using alpha blending) are faster using premultiplied ARGB32 than with plain ARGB32. + \value Format_RGB16 The image is stored using a 16-bit RGB format (5-6-5). + \value Format_ARGB8565_Premultiplied The image is stored using a premultiplied 24-bit ARGB format (8-5-6-5). \value Format_RGB666 The image is stored using a 24-bit RGB format (6-6-6). -- cgit v0.12 From 522fc01a18b9eae80b733befb98a948f0fbbba06 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Wed, 21 Oct 2009 13:52:07 +0200 Subject: Make Symbian emulator behave the same as device for mouse & touchscreen Emulator HAL reports that it supports mouse but not touch. Since Qt is changing behaviour based on these values, the emulator works differently from the device. To workaround, the emulator HAL values are ignored and following used: 5.0: mouse 0, touch 1 3.x: mouse 0, touch 0 The mouse can still be used to interact with the emulator, as pointer events are still delivered. Task-number: QTBUG-4803 Task-number: QTBUG-4616 Reviewed-by: Sami Merila --- src/gui/kernel/qapplication_s60.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index d6fdd02..689429e 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1092,6 +1092,13 @@ void qt_init(QApplicationPrivate * /* priv */, int) err = HAL::Get(HALData::EPen, touch); if (err != KErrNone || touchIsUnsupportedOnSystem) touch = 0; +#ifdef __WINS__ + if(QSysInfo::symbianVersion() <= QSysInfo::SV_9_4) { + //for symbian SDK emulator, force values to match typical devices. + mouse = 0; + touch = touchIsUnsupportedOnSystem ? 0 : 1; + } +#endif if (mouse || machineUID == KMachineUidSamsungI8510) { S60->hasTouchscreen = false; S60->virtualMouseRequired = false; -- cgit v0.12 From 95e438189a36c71d632099b3873557103697bc3b Mon Sep 17 00:00:00 2001 From: Marius Bugge Monsen Date: Wed, 21 Oct 2009 14:46:52 +0200 Subject: Make QMenu::activateCausedStack() exception safe. Use an internal class to reset the activationRecursionGuard when the scope is closed. Reviewed-by: Leo Cunha --- src/gui/widgets/qmenu.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 324bc90..ea25901 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -975,10 +975,19 @@ bool QMenuPrivate::mouseEventTaken(QMouseEvent *e) return false; } +class ExceptionGuard +{ +public: + inline ExceptionGuard(bool *w = 0) : watched(w) { Q_ASSERT(!(*watched)); *watched = true; } + inline ~ExceptionGuard() { *watched = false; } + inline operator bool() { return *watched; } +private: + bool *watched; +}; + void QMenuPrivate::activateCausedStack(const QList > &causedStack, QAction *action, QAction::ActionEvent action_e, bool self) { - Q_ASSERT(!activationRecursionGuard); - activationRecursionGuard = true; + ExceptionGuard guard(&activationRecursionGuard); #ifdef QT3_SUPPORT const int actionId = q_func()->findIdForAction(action); #endif @@ -1023,7 +1032,6 @@ void QMenuPrivate::activateCausedStack(const QList > &causedSt #endif } } - activationRecursionGuard = false; } void QMenuPrivate::activateAction(QAction *action, QAction::ActionEvent action_e, bool self) -- cgit v0.12 From 8e9b7dc23c7fde1d9970cd83b3283260b881f5e9 Mon Sep 17 00:00:00 2001 From: ck Date: Wed, 21 Oct 2009 15:33:15 +0200 Subject: Assistant: More useful error messages for help collections. --- tools/assistant/lib/qhelpcollectionhandler.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tools/assistant/lib/qhelpcollectionhandler.cpp b/tools/assistant/lib/qhelpcollectionhandler.cpp index f59b227..4aa7ab6 100644 --- a/tools/assistant/lib/qhelpcollectionhandler.cpp +++ b/tools/assistant/lib/qhelpcollectionhandler.cpp @@ -76,7 +76,8 @@ bool QHelpCollectionHandler::isDBOpened() { if (m_dbOpened) return true; - emit error(tr("The collection file is not set up yet!")); + emit error(tr("The collection file '%1' is not set up yet!"). + arg(m_collectionFile)); return false; } @@ -134,7 +135,8 @@ bool QHelpCollectionHandler::copyCollectionFile(const QString &fileName) QFileInfo fi(fileName); if (fi.exists()) { - emit error(tr("The specified collection file already exists!")); + emit error(tr("The collection file '%1' already exists!"). + arg(fileName)); return false; } @@ -281,7 +283,7 @@ bool QHelpCollectionHandler::removeCustomFilter(const QString &filterName) filterNameId = m_query.value(0).toInt(); if (filterNameId < 0) { - emit error(tr("Unknown filter!")); + emit error(tr("Unknown filter '%1'!").arg(filterName)); return false; } @@ -386,7 +388,7 @@ bool QHelpCollectionHandler::registerDocumentation(const QString &fileName) QString ns = reader.namespaceName(); if (ns.isEmpty()) { - emit error(tr("Invalid documentation file!")); + emit error(tr("Invalid documentation file '%1'!").arg(fileName)); return false; } @@ -553,7 +555,7 @@ int QHelpCollectionHandler::registerNamespace(const QString &nspace, const QStri if (m_query.exec()) namespaceId = m_query.lastInsertId().toInt(); if (namespaceId < 1) { - emit error(tr("Cannot register namespace!")); + emit error(tr("Cannot register namespace '%1'!").arg(nspace)); return -1; } return namespaceId; @@ -577,7 +579,7 @@ void QHelpCollectionHandler::optimizeDatabase(const QString &fileName) db.setDatabaseName(fileName); if (!db.open()) { QSqlDatabase::removeDatabase(QLatin1String("optimize")); - emit error(tr("Cannot open database to optimize!")); + emit error(tr("Cannot open database '%1' to optimize!").arg(fileName)); return; } -- cgit v0.12 From e7e687f737c19eda884448b6991836a102f0f3f4 Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 21 Oct 2009 14:14:26 +0100 Subject: Fixed logical error in winIdChanged auto test. The test (see 02fbfdbd) previously asserted that changing the parent of a native widget caused a WinIdChange event on Symbian, but not on other platforms. The test now asserts that: 1. Changing the parent of a native widget causes a WinIdChange event on all platforms. 2. Changing the grandparent of a native widget causes a WinIdChange event only on Symbian. Reviewed-by: Paul Olav Tvete --- tests/auto/qwidget/tst_qwidget.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index a03f112..050d1c5 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -4391,12 +4391,27 @@ void tst_QWidget::winIdChangeEvent() { // Changing parent of a native widget + // Should cause winId of child to change, on all platforms QWidget parent1, parent2; WinIdChangeWidget child(&parent1); const WId winIdBefore = child.winId(); QCOMPARE(child.m_winIdChangeEventCount, 1); child.setParent(&parent2); const WId winIdAfter = child.internalWinId(); + QVERIFY(winIdBefore != winIdAfter); + QCOMPARE(child.m_winIdChangeEventCount, 2); + } + + { + // Changing grandparent of a native widget + // Should cause winId of grandchild to change only on Symbian + QWidget grandparent1, grandparent2; + QWidget parent(&grandparent1); + WinIdChangeWidget child(&parent); + const WId winIdBefore = child.winId(); + QCOMPARE(child.m_winIdChangeEventCount, 1); + parent.setParent(&grandparent2); + const WId winIdAfter = child.internalWinId(); #ifdef Q_OS_SYMBIAN QVERIFY(winIdBefore != winIdAfter); QCOMPARE(child.m_winIdChangeEventCount, 2); -- cgit v0.12 From 27abb4acf6fec8d9c2f18242ce539ebbc905eefc Mon Sep 17 00:00:00 2001 From: Marius Bugge Monsen Date: Wed, 21 Oct 2009 16:11:45 +0200 Subject: The QMenuPrivate::activationRecursionGuard has to be a boolean. Reviewed-by: Trust Me --- src/gui/widgets/qmenu_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qmenu_p.h b/src/gui/widgets/qmenu_p.h index 6a8e4b0..9348f7b 100644 --- a/src/gui/widgets/qmenu_p.h +++ b/src/gui/widgets/qmenu_p.h @@ -197,7 +197,7 @@ public: mutable uint ncols : 4; //4 bits is probably plenty uint collapsibleSeparators : 1; - uint activationRecursionGuard : 1; + bool activationRecursionGuard; //selection static QPointer mouseDown; -- cgit v0.12 From bc2de3fbcc3f19c80938bdea17f01aa7da9f055e Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Wed, 21 Oct 2009 16:53:03 +0200 Subject: Listen on hasVideoChanged() instead of only checking hasVideo(). This means that when the backend's knowledge about the content's video capability changes outside the LoadingState, it still work. This apparently matters for the Helix backend. Patch supplied by Adookkattil Saleem (Nokia-D/Dallas). Reviewed-by: Gareth Stockwell Reviewed-by: Frans Englich --- demos/qmediaplayer/mediaplayer.cpp | 8 ++++++-- demos/qmediaplayer/mediaplayer.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/demos/qmediaplayer/mediaplayer.cpp b/demos/qmediaplayer/mediaplayer.cpp index e1ceb0e..624bab7 100644 --- a/demos/qmediaplayer/mediaplayer.cpp +++ b/demos/qmediaplayer/mediaplayer.cpp @@ -321,6 +321,7 @@ MediaPlayer::MediaPlayer(const QString &filePath, connect(&m_MediaObject, SIGNAL(finished()), this, SLOT(finished())); connect(&m_MediaObject, SIGNAL(stateChanged(Phonon::State, Phonon::State)), this, SLOT(stateChanged(Phonon::State, Phonon::State))); connect(&m_MediaObject, SIGNAL(bufferStatus(int)), this, SLOT(bufferStatus(int))); + connect(&m_MediaObject, SIGNAL(hasVideoChanged(bool)), this, SLOT(hasVideoChanged(bool))); rewindButton->setEnabled(false); playButton->setEnabled(false); @@ -339,8 +340,6 @@ void MediaPlayer::stateChanged(Phonon::State newstate, Phonon::State oldstate) Q_UNUSED(oldstate); if (oldstate == Phonon::LoadingState) { - m_videoWindow.setVisible(m_MediaObject.hasVideo()); - info->setVisible(!m_MediaObject.hasVideo()); QRect videoHintRect = QRect(QPoint(0, 0), m_videoWindow.sizeHint()); QRect newVideoRect = QApplication::desktop()->screenGeometry().intersected(videoHintRect); if (!m_hasSmallScreen) { @@ -846,3 +845,8 @@ void MediaPlayer::aspectChanged(QAction *act) m_videoWidget->setAspectRatio(Phonon::VideoWidget::AspectRatioAuto); } +void MediaPlayer::hasVideoChanged(bool bHasVideo) +{ + info->setVisible(!bHasVideo); + m_videoWindow.setVisible(bHasVideo); +} diff --git a/demos/qmediaplayer/mediaplayer.h b/demos/qmediaplayer/mediaplayer.h index 40ffa40..83f14e8 100644 --- a/demos/qmediaplayer/mediaplayer.h +++ b/demos/qmediaplayer/mediaplayer.h @@ -93,6 +93,7 @@ public slots: void playPause(); void scaleChanged(QAction *); void aspectChanged(QAction *); + void hasVideoChanged(bool); private slots: void setAspect(int); -- cgit v0.12 From 9c136d34c1d15d077ab5103a84dfb2449b796d1f Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 21 Oct 2009 17:31:18 +0200 Subject: Fixed crash in tst_qabstractitemview. Reviewed-by: trust-me --- src/gui/itemviews/qlistview.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index b6e0ab7..f58f458 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1939,7 +1939,11 @@ int QListModeViewBase::verticalScrollToValue(int index, QListView::ScrollHint hi bool above, bool below, const QRect &area, const QRect &rect) const { if (verticalScrollMode() == QAbstractItemView::ScrollPerItem) { - int value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()), flowPositions.count() - 1); + int value; + if (scrollValueMap.isEmpty()) + value = 0; + else + value = qBound(0, scrollValueMap.at(verticalScrollBar()->value()), flowPositions.count() - 1); if (above) hint = QListView::PositionAtTop; else if (below) @@ -2000,7 +2004,11 @@ int QListModeViewBase::horizontalScrollToValue(int index, QListView::ScrollHint if (horizontalScrollMode() != QAbstractItemView::ScrollPerItem) return QCommonListViewBase::horizontalScrollToValue(index, hint, leftOf, rightOf, area, rect); - int value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1); + int value; + if (scrollValueMap.isEmpty()) + value = 0; + else + value = qBound(0, scrollValueMap.at(horizontalScrollBar()->value()), flowPositions.count() - 1); if (leftOf) hint = QListView::PositionAtTop; else if (rightOf) @@ -2312,7 +2320,7 @@ int QListModeViewBase::perItemScrollingPageSteps(int length, int bounds, bool wr QVector positions; if (wrap) positions = segmentPositions; - else { + else if (!flowPositions.isEmpty()) { positions.reserve(scrollValueMap.size()); foreach (int itemShown, scrollValueMap) positions.append(flowPositions.at(itemShown)); -- cgit v0.12 From d043b59fedc41c774cc68eb49d9900dc6d36f3e5 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 21 Oct 2009 18:27:40 +0200 Subject: windowsmobilelify embedded demos Reviewed-by: aportale --- demos/embedded/digiflip/digiflip.cpp | 8 ++++---- demos/embedded/flickable/main.cpp | 2 +- demos/embedded/lightmaps/lightmaps.cpp | 4 ++-- demos/embedded/raycasting/raycasting.cpp | 6 ++++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/demos/embedded/digiflip/digiflip.cpp b/demos/embedded/digiflip/digiflip.cpp index 2edb752..9d6265d 100644 --- a/demos/embedded/digiflip/digiflip.cpp +++ b/demos/embedded/digiflip/digiflip.cpp @@ -117,7 +117,7 @@ protected: QPixmap drawDigits(int n, const QRect &rect) { int scaleFactor = 2; -#if defined(Q_OS_SYMBIAN) +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) if (rect.height() > 240) scaleFactor = 1; #endif @@ -192,7 +192,7 @@ protected: void paintFlip() { QPainter p(this); -#if !defined(Q_OS_SYMBIAN) +#if !defined(Q_OS_SYMBIAN) && !defined(Q_OS_WINCE_WM) p.setRenderHint(QPainter::SmoothPixmapTransform, true); p.setRenderHint(QPainter::Antialiasing, true); #endif @@ -319,7 +319,7 @@ public: connect(slideAction, SIGNAL(triggered()), SLOT(chooseSlide())); connect(flipAction, SIGNAL(triggered()), SLOT(chooseFlip())); connect(rotateAction, SIGNAL(triggered()), SLOT(chooseRotate())); -#if defined(Q_OS_SYMBIAN) +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) menuBar()->addAction(slideAction); menuBar()->addAction(flipAction); menuBar()->addAction(rotateAction); @@ -414,7 +414,7 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); DigiFlip time; -#if defined(Q_OS_SYMBIAN) +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) time.showMaximized(); #else time.resize(320, 240); diff --git a/demos/embedded/flickable/main.cpp b/demos/embedded/flickable/main.cpp index 403085a..eb2c3c0 100644 --- a/demos/embedded/flickable/main.cpp +++ b/demos/embedded/flickable/main.cpp @@ -222,7 +222,7 @@ int main(int argc, char *argv[]) ColorList list; list.setWindowTitle("Kinetic Scrolling"); -#ifdef Q_OS_SYMBIAN +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) list.showMaximized(); #else list.resize(320, 320); diff --git a/demos/embedded/lightmaps/lightmaps.cpp b/demos/embedded/lightmaps/lightmaps.cpp index 52297d2..ea34ae6 100644 --- a/demos/embedded/lightmaps/lightmaps.cpp +++ b/demos/embedded/lightmaps/lightmaps.cpp @@ -510,7 +510,7 @@ public: connect(nightModeAction, SIGNAL(triggered()), map, SLOT(toggleNightMode())); connect(osmAction, SIGNAL(triggered()), SLOT(aboutOsm())); -#if defined(Q_OS_SYMBIAN) +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) menuBar()->addAction(osloAction); menuBar()->addAction(berlinAction); menuBar()->addAction(jakartaAction); @@ -568,7 +568,7 @@ int main(int argc, char **argv) MapZoom w; w.setWindowTitle("OpenStreetMap"); -#if defined(Q_OS_SYMBIAN) +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) w.showMaximized(); #else w.resize(600, 450); diff --git a/demos/embedded/raycasting/raycasting.cpp b/demos/embedded/raycasting/raycasting.cpp index c3b21b6..cb08b51 100644 --- a/demos/embedded/raycasting/raycasting.cpp +++ b/demos/embedded/raycasting/raycasting.cpp @@ -251,7 +251,9 @@ public: protected: void resizeEvent(QResizeEvent*) { -#if defined(Q_OS_SYMBIAN) +#if defined(Q_OS_WINCE_WM) + touchDevice = true; +#elif defined(Q_OS_SYMBIAN) // FIXME: use HAL if (width() > 480 || height() > 480) touchDevice = true; @@ -378,7 +380,7 @@ int main(int argc, char **argv) Raycasting w; w.setWindowTitle("Raycasting"); -#if defined(Q_OS_SYMBIAN) +#if defined(Q_OS_SYMBIAN) || defined(Q_OS_WINCE_WM) w.showMaximized(); #else w.resize(640, 480); -- cgit v0.12 From fad27a3b6f018a0bc3cb261c81aaefc540589585 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 21 Oct 2009 21:57:41 +0200 Subject: Rename the .cpp for QNetworkReply benchmark tests --- tests/benchmarks/qnetworkreply/main.cpp | 74 ---------------------- tests/benchmarks/qnetworkreply/qnetworkreply.pro | 2 +- .../benchmarks/qnetworkreply/tst_qnetworkreply.cpp | 74 ++++++++++++++++++++++ 3 files changed, 75 insertions(+), 75 deletions(-) delete mode 100644 tests/benchmarks/qnetworkreply/main.cpp create mode 100644 tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp diff --git a/tests/benchmarks/qnetworkreply/main.cpp b/tests/benchmarks/qnetworkreply/main.cpp deleted file mode 100644 index 666e4f1..0000000 --- a/tests/benchmarks/qnetworkreply/main.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -// This file contains benchmarks for QNetworkReply functions. - -#include -#include -#include -#include -#include -#include -#include "../../auto/network-settings.h" - -class tst_qnetworkreply : public QObject -{ - Q_OBJECT -private slots: - void httpLatency(); - -}; - -void tst_qnetworkreply::httpLatency() -{ - QNetworkAccessManager manager; - QBENCHMARK{ - QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/")); - QNetworkReply* reply = manager.get(request); - connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); - QTestEventLoop::instance().enterLoop(5); - QVERIFY(!QTestEventLoop::instance().timeout()); - delete reply; - } -} - -QTEST_MAIN(tst_qnetworkreply) - -#include "main.moc" diff --git a/tests/benchmarks/qnetworkreply/qnetworkreply.pro b/tests/benchmarks/qnetworkreply/qnetworkreply.pro index 060acf5..1e67d81 100644 --- a/tests/benchmarks/qnetworkreply/qnetworkreply.pro +++ b/tests/benchmarks/qnetworkreply/qnetworkreply.pro @@ -10,4 +10,4 @@ QT += network CONFIG += release # Input -SOURCES += main.cpp +SOURCES += tst_qnetworkreply.cpp diff --git a/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp new file mode 100644 index 0000000..666e4f1 --- /dev/null +++ b/tests/benchmarks/qnetworkreply/tst_qnetworkreply.cpp @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +// This file contains benchmarks for QNetworkReply functions. + +#include +#include +#include +#include +#include +#include +#include "../../auto/network-settings.h" + +class tst_qnetworkreply : public QObject +{ + Q_OBJECT +private slots: + void httpLatency(); + +}; + +void tst_qnetworkreply::httpLatency() +{ + QNetworkAccessManager manager; + QBENCHMARK{ + QNetworkRequest request(QUrl("http://" + QtNetworkSettings::serverName() + "/qtest/")); + QNetworkReply* reply = manager.get(request); + connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection); + QTestEventLoop::instance().enterLoop(5); + QVERIFY(!QTestEventLoop::instance().timeout()); + delete reply; + } +} + +QTEST_MAIN(tst_qnetworkreply) + +#include "main.moc" -- cgit v0.12 From 493ce4c0aa1c7dc73206917b1a6874e77b7385d9 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 22 Oct 2009 10:48:46 +1000 Subject: Fixed clock() function return values in audio class's. clock() function should return microseconds, fixed example, alsa backend and win32 backend. Reviewed-by:Justin McPherson --- examples/multimedia/audioinput/audioinput.cpp | 2 +- examples/multimedia/audiooutput/audiooutput.cpp | 2 +- src/multimedia/audio/qaudioinput_alsa_p.cpp | 2 +- src/multimedia/audio/qaudioinput_win32_p.cpp | 2 +- src/multimedia/audio/qaudiooutput_alsa_p.cpp | 2 +- src/multimedia/audio/qaudiooutput_win32_p.cpp | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/multimedia/audioinput/audioinput.cpp b/examples/multimedia/audioinput/audioinput.cpp index 05723ae..3d537a2 100644 --- a/examples/multimedia/audioinput/audioinput.cpp +++ b/examples/multimedia/audioinput/audioinput.cpp @@ -216,7 +216,7 @@ InputTest::~InputTest() {} void InputTest::status() { - qWarning()<<"bytesReady = "<bytesReady()<<" bytes, clock = "<clock()<<"ms, totalTime = "<totalTime()/1000<<"ms"; + qWarning()<<"bytesReady = "<bytesReady()<<" bytes, clock = "<clock()/1000<<"ms, totalTime = "<totalTime()/1000<<"ms"; } void InputTest::readMore() diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp index 9e532cd..c92bbaf 100644 --- a/examples/multimedia/audiooutput/audiooutput.cpp +++ b/examples/multimedia/audiooutput/audiooutput.cpp @@ -200,7 +200,7 @@ void AudioTest::deviceChanged(int idx) void AudioTest::status() { - qWarning()<<"byteFree = "<bytesFree()<<" bytes, clock = "<clock()<<"ms, totalTime = "<totalTime()/1000<<"ms"; + qWarning()<<"byteFree = "<bytesFree()<<" bytes, clock = "<clock()/1000<<"ms, totalTime = "<totalTime()/1000<<"ms"; } void AudioTest::writeMore() diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index 6786657..9eb8cfb 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -630,7 +630,7 @@ qint64 QAudioInputPrivate::clock() const l = -l; l %= 1000000; } - return ((t1.tv_sec * 1000)+l/1000); + return ((t1.tv_sec * 1000000)+l); } else return 0; #else diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index b6b1efe..a059e76 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -544,7 +544,7 @@ qint64 QAudioInputPrivate::clock() const if (deviceState == QAudio::StopState) return 0; - return timeStampOpened.elapsed(); + return timeStampOpened.elapsed()*1000; } void QAudioInputPrivate::reset() diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index efa7b27..689da89 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -682,7 +682,7 @@ qint64 QAudioOutputPrivate::clock() const l = -l; l %= 1000000; } - return ((t1.tv_sec * 1000)+l/1000); + return ((t1.tv_sec * 1000000)+l); } else return 0; #else diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index 2c4a1c2..1810ed2 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -496,7 +496,7 @@ qint64 QAudioOutputPrivate::clock() const if (deviceState == QAudio::StopState) return 0; - return timeStampOpened.elapsed(); + return timeStampOpened.elapsed()*1000; } QAudio::Error QAudioOutputPrivate::error() const -- cgit v0.12 From 100afe8da00fdb1661b22e049960ed00a1d3c765 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Thu, 22 Oct 2009 15:12:40 +1000 Subject: Fix a bug in QGraphicsRotation related to 2D projections The projection to 2D needs to be done when the rotation is applied, not after all transformations have been applied. Reviewed-by: trustme --- src/gui/graphicsview/qgraphicsitem_p.h | 2 +- src/gui/graphicsview/qgraphicstransform.cpp | 4 +++- tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 6550362..8696324 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -539,7 +539,7 @@ struct QGraphicsItemPrivate::TransformData QMatrix4x4 m; for (int i = 0; i < graphicsTransforms.size(); ++i) graphicsTransforms.at(i)->applyTo(&m); - x *= m.toTransform(); + x *= m.toTransform(0); } x.translate(xOrigin, yOrigin); x.rotate(rotation); diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index ec1a2f5..49d8999 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -547,7 +547,9 @@ void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const return; matrix->translate(d->origin); - matrix->rotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z()); + QMatrix4x4 m; + m.rotate(d->angle, d->axis.x(), d->axis.y(), d->axis.z()); + *matrix *= m.toTransform(); matrix->translate(-d->origin); } diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index b407fef..eb5c099 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -88,7 +88,7 @@ static QTransform transform2D(const QGraphicsTransform& t) { QMatrix4x4 m; t.applyTo(&m); - return m.toTransform(); + return m.toTransform(0); } void tst_QGraphicsTransform::scale() -- cgit v0.12 From f07a027b342e09fbb9d1678d3855cddfc27d3925 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 22 Oct 2009 08:41:41 +0200 Subject: Documentation: Correct dangling reference to Qt Designer documentation. Task-number: QTBUG-4605 --- doc/src/qt4-intro.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index cecff0e..4943984 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -834,7 +834,7 @@ these settings when you edit forms. More information about these improvements can be found in the - \l{What's New in Qt Designer 4.6} overview. + \l{What's New in Qt Designer 4.5} overview. \section1 Qt Linguist Improvements -- cgit v0.12 From 38f7a788242fcc5ed7e75291bffd2b1b16d76f76 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Thu, 22 Oct 2009 10:20:03 +0200 Subject: QDom autotests: make test fail instead of time out introduce a QFAIL for now until problem is fixed Reviewed-by: Carlos Duclos --- tests/auto/qdom/tst_qdom.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index 6637202..0d58554e 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -322,6 +322,7 @@ void tst_QDom::toString_01_data() */ void tst_QDom::toString_01() { + QFAIL("make test fail instead of timing out, will be fixed later (QT-2357)"); QFETCH(QString, fileName); QFile f(fileName); -- cgit v0.12 From 5f8978a02bde7f84dc48b63d3722b925730790f0 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Oct 2009 10:34:44 +0200 Subject: move default QAbstractButton font setup on Win mobile to QApplication The original approach of modifying the font for QAbstractButtons in QWindowsMobileStyle::polish broke the autotest tst_qstylesheetstyle::fontPropagation. Reviewed-by: thartman --- src/gui/kernel/qapplication_win.cpp | 2 ++ src/gui/styles/qwindowsmobilestyle.cpp | 25 +------------------------ 2 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/gui/kernel/qapplication_win.cpp b/src/gui/kernel/qapplication_win.cpp index 1babb69..5a4f4e6 100644 --- a/src/gui/kernel/qapplication_win.cpp +++ b/src/gui/kernel/qapplication_win.cpp @@ -624,6 +624,8 @@ static void qt_set_windows_font_resources() if (qt_wince_is_mobile()) { smallerFont.setPointSize(systemFont.pointSize()-1); QApplication::setFont(smallerFont, "QTabBar"); + smallerFont.setBold(true); + QApplication::setFont(smallerFont, "QAbstractButton"); } #endif// Q_OS_WINCE } diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index 32e39b2..f04a4b2 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -3130,34 +3130,11 @@ void QWindowsMobileStyle::polish(QWidget *widget) { else #endif //QT_NO_TOOLBAR -#ifndef QT_NO_PROPERTIES - if (QAbstractButton *pushButton = qobject_cast(widget)) { - QVariant oldFont = widget->property("_q_styleWindowsMobileFont"); - if (!oldFont.isValid()) { - QFont f = pushButton->font(); - widget->setProperty("_q_styleWindowsMobileFont", f); - f.setBold(true); - int p = f.pointSize(); - if (p > 2) - f.setPointSize(p-1); - pushButton->setFont(f); - } - } -#endif - QWindowsStyle::polish(widget); + QWindowsStyle::polish(widget); } void QWindowsMobileStyle::unpolish(QWidget *widget) { -#ifndef QT_NO_PROPERTIES - if (QAbstractButton *pushButton = qobject_cast(widget)) { - QVariant oldFont = widget->property("_q_styleWindowsMobileFont"); - if (oldFont.isValid()) { - widget->setFont(qVariantValue(oldFont)); - widget->setProperty("_q_styleWindowsMobileFont", QVariant()); - } - } -#endif QWindowsStyle::unpolish(widget); } -- cgit v0.12 From e546f7b1bfe98436c26fb6aa11a88053ae4eb185 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 21 Oct 2009 14:41:32 +0200 Subject: actually guess the target language from the file name --help says it does, but it didn't really. --- tools/linguist/lupdate/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index 6b554e0..bdaec4f 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -160,6 +160,8 @@ static void updateTsFiles(const Translator &fetchedTor, const QStringList &tsFil tor.setCodecName(codecForTr); if (!targetLanguage.isEmpty()) tor.setLanguageCode(targetLanguage); + else + tor.setLanguageCode(Translator::guessLanguageCodeFromFileName(fileName)); if (!sourceLanguage.isEmpty()) tor.setSourceLanguageCode(sourceLanguage); } -- cgit v0.12 From babfff66074573bb34a0abd561052c1cc4df5ef0 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 21 Oct 2009 14:42:43 +0200 Subject: id-based: use source strings instead of empty translations only for unfinished messages --- tests/auto/linguist/lrelease/testdata/idbased.ts | 1 + tools/linguist/shared/qm.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/auto/linguist/lrelease/testdata/idbased.ts b/tests/auto/linguist/lrelease/testdata/idbased.ts index 61497de..cd47158 100644 --- a/tests/auto/linguist/lrelease/testdata/idbased.ts +++ b/tests/auto/linguist/lrelease/testdata/idbased.ts @@ -9,6 +9,7 @@ This has no translation. + Foo bar. diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index fefe91c..998d0ac 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -440,9 +440,10 @@ void Releaser::insert(const TranslatorMessage &message, bool forceComment) void Releaser::insertIdBased(const TranslatorMessage &message) { QStringList tlns = message.translations(); - for (int i = 0; i < tlns.size(); ++i) - if (tlns.at(i).isEmpty()) - tlns[i] = message.sourceText(); + if (message.type() == TranslatorMessage::Unfinished) + for (int i = 0; i < tlns.size(); ++i) + if (tlns.at(i).isEmpty()) + tlns[i] = message.sourceText(); ByteTranslatorMessage bmsg("", originalBytes(message.id(), false), "", tlns); m_messages.insert(bmsg, 0); } -- cgit v0.12 From f3d76ae452d1c430bf294a0750318327a866332c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 21 Oct 2009 14:44:42 +0200 Subject: id-based: do not drop unfinished untranslated messages otherwise the fallback to use the source string is rather pointless --- tools/linguist/shared/qm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/linguist/shared/qm.cpp b/tools/linguist/shared/qm.cpp index 998d0ac..317a07e 100644 --- a/tools/linguist/shared/qm.cpp +++ b/tools/linguist/shared/qm.cpp @@ -714,7 +714,7 @@ static bool saveQM(const Translator &translator, QIODevice &dev, ConversionData continue; } if (typ == TranslatorMessage::Unfinished) { - if (msg.translation().isEmpty()) { + if (!cd.m_idBased && msg.translation().isEmpty()) { ++untranslated; continue; } else { -- cgit v0.12 From 40b0291252ac07ebac4ba34221728651c887c9b3 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 22 Oct 2009 10:31:38 +0200 Subject: consider message id when comparing messages --- tests/auto/linguist/lrelease/testdata/idbased.ts | 6 ++++++ tools/linguist/shared/translatormessage.cpp | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/auto/linguist/lrelease/testdata/idbased.ts b/tests/auto/linguist/lrelease/testdata/idbased.ts index cd47158..c7555c8 100644 --- a/tests/auto/linguist/lrelease/testdata/idbased.ts +++ b/tests/auto/linguist/lrelease/testdata/idbased.ts @@ -18,5 +18,11 @@ Drop me! + + + + + + diff --git a/tools/linguist/shared/translatormessage.cpp b/tools/linguist/shared/translatormessage.cpp index 417f6b1..db6f333 100644 --- a/tools/linguist/shared/translatormessage.cpp +++ b/tools/linguist/shared/translatormessage.cpp @@ -151,6 +151,7 @@ bool TranslatorMessage::operator==(const TranslatorMessage& m) const return (m_context == m.m_context) && m_sourcetext == m.m_sourcetext && m_extra[msgIdPlural] == m.m_extra[msgIdPlural] + && m_id == m.m_id && (m_sourcetext.isEmpty() || m_comment == m.m_comment); } @@ -161,7 +162,9 @@ bool TranslatorMessage::operator<(const TranslatorMessage& m) const return m_context < m.m_context; if (m_sourcetext != m.m_sourcetext) return m_sourcetext < m.m_sourcetext; - return m_comment < m.m_comment; + if (m_comment != m.m_comment) + return m_comment < m.m_comment; + return m_id < m.m_id; } int qHash(const TranslatorMessage &msg) @@ -170,7 +173,8 @@ int qHash(const TranslatorMessage &msg) qHash(msg.context()) ^ qHash(msg.sourceText()) ^ qHash(msg.extra(QLatin1String("po-msgid_plural"))) ^ - qHash(msg.comment()); + qHash(msg.comment()) ^ + qHash(msg.id()); } bool TranslatorMessage::hasExtra(const QString &key) const -- cgit v0.12 From dfec518d7636306bb8c96652d4e72b0883c123df Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 21 Oct 2009 16:50:53 +0200 Subject: qfontengine_win.cpp: special Windows CE code removed Reviewed-by: thartman --- src/gui/text/qfontengine_win.cpp | 91 +++++++--------------------------------- 1 file changed, 16 insertions(+), 75 deletions(-) diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp index cc555a3..d781c70 100644 --- a/src/gui/text/qfontengine_win.cpp +++ b/src/gui/text/qfontengine_win.cpp @@ -125,6 +125,7 @@ HDC shared_dc() } #endif +#ifndef Q_WS_WINCE typedef BOOL (WINAPI *PtrGetCharWidthI)(HDC, UINT, UINT, LPWORD, LPINT); static PtrGetCharWidthI ptrGetCharWidthI = 0; static bool resolvedGetCharWidthI = false; @@ -136,6 +137,7 @@ static void resolveGetCharWidthI() resolvedGetCharWidthI = true; ptrGetCharWidthI = (PtrGetCharWidthI)QLibrary::resolve(QLatin1String("gdi32"), "GetCharWidthI"); } +#endif // !defined(Q_WS_WINCE) // defined in qtextengine_win.cpp typedef void *SCRIPT_CACHE; @@ -340,8 +342,10 @@ QFontEngineWin::QFontEngineWin(const QString &name, HFONT _hfont, bool stockFont designAdvances = 0; designAdvancesSize = 0; +#ifndef Q_WS_WINCE if (!resolvedGetCharWidthI) resolveGetCharWidthI(); +#endif } QFontEngineWin::~QFontEngineWin() @@ -381,80 +385,18 @@ bool QFontEngineWin::stringToCMap(const QChar *str, int len, QGlyphLayout *glyph if (flags & QTextEngine::GlyphIndicesOnly) return true; -#if defined(Q_WS_WINCE) - HDC hdc = shared_dc(); - if (flags & QTextEngine::DesignMetrics) { - HGDIOBJ oldFont = 0; - int glyph_pos = 0; - for(register int i = 0; i < len; i++) { - bool surrogate = (str[i].unicode() >= 0xd800 && str[i].unicode() < 0xdc00 && i < len-1 - && str[i+1].unicode() >= 0xdc00 && str[i+1].unicode() < 0xe000); - unsigned int glyph = glyphs->glyphs[glyph_pos]; - if(int(glyph) >= designAdvancesSize) { - int newSize = (glyph + 256) >> 8 << 8; - designAdvances = q_check_ptr((QFixed *)realloc(designAdvances, newSize*sizeof(QFixed))); - for(int i = designAdvancesSize; i < newSize; ++i) - designAdvances[i] = -1000000; - designAdvancesSize = newSize; - } - if(designAdvances[glyph] < -999999) { - if(!oldFont) - oldFont = selectDesignFont(); - SIZE size = {0, 0}; - GetTextExtentPoint32(hdc, (wchar_t *)(str+i), surrogate ? 2 : 1, &size); - designAdvances[glyph] = QFixed((int)size.cx)/designToDevice; - } - glyphs->advances_x[glyph_pos] = designAdvances[glyph]; - glyphs->advances_y[glyph_pos] = 0; - if (surrogate) - ++i; - ++glyph_pos; - } - if(oldFont) - DeleteObject(SelectObject(hdc, oldFont)); - } else { - int glyph_pos = 0; - HGDIOBJ oldFont = 0; - - for(register int i = 0; i < len; i++) { - bool surrogate = (str[i].unicode() >= 0xd800 && str[i].unicode() < 0xdc00 && i < len-1 - && str[i+1].unicode() >= 0xdc00 && str[i+1].unicode() < 0xe000); - unsigned int glyph = glyphs->glyphs[glyph_pos]; - - glyphs->advances_y[glyph_pos] = 0; - - if (glyph >= widthCacheSize) { - int newSize = (glyph + 256) >> 8 << 8; - widthCache = q_check_ptr((unsigned char *)realloc(widthCache, - newSize*sizeof(QFixed))); - memset(widthCache + widthCacheSize, 0, newSize - widthCacheSize); - widthCacheSize = newSize; - } - glyphs->advances_x[glyph_pos] = widthCache[glyph]; - // font-width cache failed - if (glyphs->advances_x[glyph_pos] == 0) { - SIZE size = {0, 0}; - if (!oldFont) - oldFont = SelectObject(hdc, hfont); - GetTextExtentPoint32(hdc, (wchar_t *)str + i, surrogate ? 2 : 1, &size); - glyphs->advances_x[glyph_pos] = size.cx; - // if glyph's within cache range, store it for later - if (size.cx > 0 && size.cx < 0x100) - widthCache[glyph] = size.cx; - } - - if (surrogate) - ++i; - ++glyph_pos; - } + recalcAdvances(glyphs, flags); + return true; +} - if (oldFont) - SelectObject(hdc, oldFont); - } +inline void calculateTTFGlyphWidth(HDC hdc, UINT glyph, int &width) +{ +#if defined(Q_WS_WINCE) + GetCharWidth32(hdc, glyph, glyph, &width); #else - recalcAdvances(glyphs, flags); + if (ptrGetCharWidthI) + ptrGetCharWidthI(hdc, glyph, 1, 0, &width); #endif - return true; } void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const @@ -477,8 +419,7 @@ void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla oldFont = selectDesignFont(); int width = 0; - if (ptrGetCharWidthI) - ptrGetCharWidthI(hdc, glyph, 1, 0, &width); + calculateTTFGlyphWidth(hdc, glyph, width); designAdvances[glyph] = QFixed(width) / designToDevice; } glyphs->advances_x[i] = designAdvances[glyph]; @@ -517,8 +458,8 @@ void QFontEngineWin::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFla SIZE size = {0, 0}; GetTextExtentPoint32(hdc, (wchar_t *)ch, chrLen, &size); width = size.cx; - } else if (ptrGetCharWidthI) { - ptrGetCharWidthI(hdc, glyph, 1, 0, &width); + } else { + calculateTTFGlyphWidth(hdc, glyph, width); } glyphs->advances_x[i] = width; // if glyph's within cache range, store it for later -- cgit v0.12 From d4a136dc3f1176665c19eec24fa43f40e5180a89 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Oct 2009 10:52:27 +0200 Subject: qfiledialog2 added to tests/auto/auto.pro Reviewed-by: alexis --- tests/auto/auto.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 8e3ce81..0f7a7f1 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -127,6 +127,7 @@ SUBDIRS += \ qexplicitlyshareddatapointer \ qfile \ qfiledialog \ + qfiledialog2 \ qfileinfo \ qfilesystemwatcher \ qfilesystemmodel \ -- cgit v0.12 From 03b19d156948e561c45724524467cc26bb7c4055 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 22 Oct 2009 10:55:04 +0200 Subject: Added license headers to new files --- .../gl2paintengineex/qtriangulatingstroker.cpp | 41 ++++++++++++++++++++++ .../gl2paintengineex/qtriangulatingstroker_p.h | 41 ++++++++++++++++++++++ 2 files changed, 82 insertions(+) diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp index 250dab6..a3c8266 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker.cpp @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #include "qtriangulatingstroker_p.h" #include diff --git a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h index a28fc45..b7354db 100644 --- a/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h +++ b/src/opengl/gl2paintengineex/qtriangulatingstroker_p.h @@ -1,3 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtOpenGL module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + #ifndef QTRIANGULATINGSTROKER_P_H #define QTRIANGULATINGSTROKER_P_H -- cgit v0.12 From a7f377e8a20ee35d8bda55b2b13c9607f9ddfb3a Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Thu, 22 Oct 2009 10:55:26 +0200 Subject: updated documentation for QPixmap::fromImage() --- src/gui/image/qpixmap.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index f94552d..a3b7516 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -470,9 +470,11 @@ QPixmap::operator QVariant() const conversion fails. If the pixmap has 1-bit depth, the returned image will also be 1 - bit deep. If the pixmap has 2- to 8-bit depth, the returned image - has 8-bit depth. If the pixmap has greater than 8-bit depth, the - returned image has 32-bit depth. + bit deep. Images with more bits will be returned in a format + closely represents the underlying system. Usually this will be + QImage::Format_ARGB32_Premultiplied for pixmaps with an alpha and + QImage::Format_RGB32 or QImage::Format_RGB16 for pixmaps without + alpha. Note that for the moment, alpha masks on monochrome images are ignored. @@ -1704,8 +1706,8 @@ QPixmap QPixmap::transformed(const QMatrix &matrix, Qt::TransformationMode mode) In addition, on Symbian, the QPixmap class supports conversion to and from CFbsBitmap: the toSymbianCFbsBitmap() function creates - CFbsBitmap equivalent to the QPixmap, based on given mode and returns - a CFbsBitmap object. The fromSymbianCFbsBitmap() function returns a + CFbsBitmap equivalent to the QPixmap, based on given mode and returns + a CFbsBitmap object. The fromSymbianCFbsBitmap() function returns a QPixmap that is equivalent to the given bitmap and given mode. \section1 Pixmap Transformations -- cgit v0.12 From adc8f1b1e7a91c3807b074a43c18d2b0e31c9a9d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 22 Oct 2009 11:00:25 +0200 Subject: QWindowsMobileStyle::drawPrimitive(PE_Frame) background color fixed The background color of PE_Frame was palette().light() and has been changed to use palette().background() now. This fixes the autotest tst_QStyleSheetStyle::task188195_baseBackground for Windows mobile. Reviewed-by: thartman --- src/gui/styles/qwindowsmobilestyle.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qwindowsmobilestyle.cpp b/src/gui/styles/qwindowsmobilestyle.cpp index f04a4b2..886301b 100644 --- a/src/gui/styles/qwindowsmobilestyle.cpp +++ b/src/gui/styles/qwindowsmobilestyle.cpp @@ -1460,10 +1460,8 @@ void QWindowsMobileStyle::drawPrimitive(PrimitiveElement element, const QStyleOp painter->drawLines(a); break; } case PE_Frame: - if (d->doubleControls) - qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),2,&option->palette.light()); - else - qDrawPlainRect(painter, option->rect, option->palette.shadow().color(),1,&option->palette.light()); + qDrawPlainRect(painter, option->rect, option->palette.shadow().color(), + d->doubleControls ? 2 : 1, &option->palette.background()); break; case PE_FrameLineEdit: case PE_FrameMenu: -- cgit v0.12 From ed1892665111f900e4d831a41b4ec79666931f0d Mon Sep 17 00:00:00 2001 From: aavit Date: Thu, 15 Oct 2009 14:48:31 +0200 Subject: Upgrade libpng to version 1.2.40 This commit contains a clean copy of the libpng source distribution. The Qt patches will follow in a separate commit. --- src/3rdparty/libpng/ANNOUNCE | 54 +- src/3rdparty/libpng/CHANGES | 338 ++- src/3rdparty/libpng/INSTALL | 16 +- src/3rdparty/libpng/KNOWNBUG | 2 +- src/3rdparty/libpng/LICENSE | 8 +- src/3rdparty/libpng/README | 25 +- src/3rdparty/libpng/TODO | 1 + src/3rdparty/libpng/Y2KINFO | 4 +- src/3rdparty/libpng/configure | 4 +- src/3rdparty/libpng/example.c | 297 +- src/3rdparty/libpng/libpng-1.2.29.txt | 2906 ------------------ src/3rdparty/libpng/libpng-1.2.40.txt | 3112 ++++++++++++++++++++ src/3rdparty/libpng/libpng.3 | 803 ++++- src/3rdparty/libpng/libpngpf.3 | 720 ++++- src/3rdparty/libpng/png.5 | 2 +- src/3rdparty/libpng/png.c | 572 ++-- src/3rdparty/libpng/png.h | 419 ++- src/3rdparty/libpng/pngconf.h | 160 +- src/3rdparty/libpng/pngerror.c | 107 +- src/3rdparty/libpng/pngget.c | 214 +- src/3rdparty/libpng/pngmem.c | 126 +- src/3rdparty/libpng/pngpread.c | 339 ++- src/3rdparty/libpng/pngread.c | 372 ++- src/3rdparty/libpng/pngrio.c | 68 +- src/3rdparty/libpng/pngrtran.c | 629 ++-- src/3rdparty/libpng/pngrutil.c | 837 +++--- src/3rdparty/libpng/pngset.c | 803 ++--- src/3rdparty/libpng/pngtest.c | 609 ++-- src/3rdparty/libpng/pngtrans.c | 111 +- src/3rdparty/libpng/pngwio.c | 129 +- src/3rdparty/libpng/pngwrite.c | 391 +-- src/3rdparty/libpng/pngwtran.c | 39 +- src/3rdparty/libpng/pngwutil.c | 937 +++--- src/3rdparty/libpng/scripts/CMakeLists.txt | 137 +- src/3rdparty/libpng/scripts/descrip.mms | 6 +- src/3rdparty/libpng/scripts/libpng-config-head.in | 7 +- src/3rdparty/libpng/scripts/libpng-config.in | 7 +- src/3rdparty/libpng/scripts/libpng.icc | 7 +- src/3rdparty/libpng/scripts/libpng.pc-configure.in | 7 +- src/3rdparty/libpng/scripts/libpng.pc.in | 2 +- src/3rdparty/libpng/scripts/makefile.32sunu | 7 +- src/3rdparty/libpng/scripts/makefile.64sunu | 7 +- src/3rdparty/libpng/scripts/makefile.acorn | 3 +- src/3rdparty/libpng/scripts/makefile.aix | 29 +- src/3rdparty/libpng/scripts/makefile.amiga | 5 +- src/3rdparty/libpng/scripts/makefile.atari | 8 +- src/3rdparty/libpng/scripts/makefile.bc32 | 39 +- src/3rdparty/libpng/scripts/makefile.beos | 12 +- src/3rdparty/libpng/scripts/makefile.bor | 42 +- src/3rdparty/libpng/scripts/makefile.cygwin | 17 +- src/3rdparty/libpng/scripts/makefile.darwin | 17 +- src/3rdparty/libpng/scripts/makefile.dec | 9 +- src/3rdparty/libpng/scripts/makefile.dj2 | 9 +- src/3rdparty/libpng/scripts/makefile.elf | 12 +- src/3rdparty/libpng/scripts/makefile.freebsd | 7 +- src/3rdparty/libpng/scripts/makefile.gcc | 32 +- src/3rdparty/libpng/scripts/makefile.gcmmx | 19 +- src/3rdparty/libpng/scripts/makefile.hp64 | 12 +- src/3rdparty/libpng/scripts/makefile.hpgcc | 11 +- src/3rdparty/libpng/scripts/makefile.hpux | 10 +- src/3rdparty/libpng/scripts/makefile.ibmc | 24 +- src/3rdparty/libpng/scripts/makefile.intel | 14 +- src/3rdparty/libpng/scripts/makefile.knr | 12 +- src/3rdparty/libpng/scripts/makefile.linux | 14 +- src/3rdparty/libpng/scripts/makefile.mingw | 20 +- src/3rdparty/libpng/scripts/makefile.mips | 8 +- src/3rdparty/libpng/scripts/makefile.msc | 13 +- src/3rdparty/libpng/scripts/makefile.ne12bsd | 12 +- src/3rdparty/libpng/scripts/makefile.netbsd | 12 +- src/3rdparty/libpng/scripts/makefile.nommx | 45 +- src/3rdparty/libpng/scripts/makefile.openbsd | 13 +- src/3rdparty/libpng/scripts/makefile.os2 | 7 +- src/3rdparty/libpng/scripts/makefile.sco | 7 +- src/3rdparty/libpng/scripts/makefile.sggcc | 15 +- src/3rdparty/libpng/scripts/makefile.sgi | 9 +- src/3rdparty/libpng/scripts/makefile.so9 | 11 +- src/3rdparty/libpng/scripts/makefile.solaris | 12 +- src/3rdparty/libpng/scripts/makefile.solaris-x86 | 11 +- src/3rdparty/libpng/scripts/makefile.std | 7 +- src/3rdparty/libpng/scripts/makefile.sunos | 7 +- src/3rdparty/libpng/scripts/makefile.vcawin32 | 17 +- src/3rdparty/libpng/scripts/makefile.vcwin32 | 13 +- src/3rdparty/libpng/scripts/makefile.watcom | 5 +- src/3rdparty/libpng/scripts/makevms.com | 4 +- src/3rdparty/libpng/scripts/pngos2.def | 2 +- src/3rdparty/libpng/scripts/pngw32.def | 3 +- src/3rdparty/libpng/scripts/smakefile.ppc | 5 +- 87 files changed, 9379 insertions(+), 6577 deletions(-) delete mode 100644 src/3rdparty/libpng/libpng-1.2.29.txt create mode 100644 src/3rdparty/libpng/libpng-1.2.40.txt diff --git a/src/3rdparty/libpng/ANNOUNCE b/src/3rdparty/libpng/ANNOUNCE index 5580fb8..b73bbb5 100644 --- a/src/3rdparty/libpng/ANNOUNCE +++ b/src/3rdparty/libpng/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.2.29 - May 8, 2008 +Libpng 1.2.40 - September 10, 2009 This is a public release of libpng, intended for use in production codes. @@ -8,53 +8,49 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - libpng-1.2.29.tar.gz - libpng-1.2.29.tar.lzma - (Get the lzma codec from ). - libpng-1.2.29.tar.bz2 + libpng-1.2.40.tar.xz (LZMA-compressed, recommended) + libpng-1.2.40.tar.gz + libpng-1.2.40.tar.bz2 Source files with LF line endings (for Unix/Linux) without the "configure" script - libpng-1.2.29-no-config.tar.gz - libpng-1.2.29-no-config.tar.lzma - libpng-1.2.29-no-config.tar.bz2 + libpng-1.2.40-no-config.tar.xz (LZMA-compressed, recommended) + libpng-1.2.40-no-config.tar.gz + libpng-1.2.40-no-config.tar.bz2 Source files with CRLF line endings (for Windows), without the "configure" script - lpng1229.zip - lpng1229.7z - lpng1229.tar.bz2 + lpng1240.zip + lpng1240.7z + lpng1240.tar.bz2 Project files - libpng-1.2.29-project-netware.zip - libpng-1.2.29-project-wince.zip + libpng-1.2.40-project-netware.zip + libpng-1.2.40-project-wince.zip Other information: - libpng-1.2.29-README.txt - libpng-1.2.29-KNOWNBUGS.txt - libpng-1.2.29-LICENSE.txt - libpng-1.2.29-Y2K-compliance.txt - libpng-1.2.29-[previous version]-diff.txt + libpng-1.2.40-README.txt + libpng-1.2.40-KNOWNBUGS.txt + libpng-1.2.40-LICENSE.txt + libpng-1.2.40-Y2K-compliance.txt + libpng-1.2.40-[previous version]-diff.txt -Changes since the last public release (1.2.28): +Changes since the last public release (1.2.39): -version 1.2.29 [May 8, 2008] +version 1.2.40 [September 10, 2009] - Removed some stray *.diff and *.orig files - Reverted Makefile.in, aclocal.m4, and configure to the libpng-1.2.26 - versions. - Added --force to autogen libtoolize options and --force-missing to - automake options. - Changed $(ECHO) to echo in Makefile.am and Makefile.in - Updated all configure files to autoconf-2.62 - #ifdef out pnggcrd.c code if using MSC_VER + Removed an extra png_debug() recently added to png_write_find_filter(). + Fixed incorrect #ifdef in pngset.c regarding unknown chunk support. + Various bugfixes and improvements to CMakeLists.txt (Philip Lowman) Send comments/corrections/commendations to png-mng-implement at lists.sf.net -(subscription required; visit + +Send comments/corrections/commendations to png-mng-implement at lists.sf.net +(subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement to subscribe) or to glennrp at users.sourceforge.net diff --git a/src/3rdparty/libpng/CHANGES b/src/3rdparty/libpng/CHANGES index 590987c..9bb8ac8 100644 --- a/src/3rdparty/libpng/CHANGES +++ b/src/3rdparty/libpng/CHANGES @@ -1,4 +1,4 @@ - +/* CHANGES - changes for libpng version 0.2 @@ -539,7 +539,8 @@ version 1.0.5d [November 29, 1999] Eliminated pngtypes.h; use macros instead to declare PNG_CHNK arrays. Renamed "PNG_GLOBAL_ARRAYS" to "PNG_USE_GLOBAL_ARRAYS" and made available to applications a macro "PNG_USE_LOCAL_ARRAYS". - #ifdef out all the new declarations when PNG_USE_GLOBAL_ARRAYS is defined. + Remove all the new declarations with #ifdef/#endif when + PNG_USE_GLOBAL_ARRAYS is defined. Added PNG_EXPORT_VAR macro to accommodate making DLL's. version 1.0.5e [November 30, 1999] Added iCCP, iTXt, and sPLT support; added "lang" member to the png_text @@ -1179,7 +1180,7 @@ version 1.2.4beta3 [June 28, 2002] Plugged memory leak of row_buf in pngtest.c when there is a png_error(). Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data. Added "test-installed" target to makefile.32sunu, makefile.64sunu, - makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, + makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9. version 1.2.4rc1 and 1.0.14rc1 [July 2, 2002] Added "test-installed" target to makefile.cygwin and makefile.sco. @@ -1300,7 +1301,7 @@ version 1.2.6beta4 [July 28, 2004] Added PNG_NO_SEQUENTIAL_READ_SUPPORTED macro to conditionally remove sequential read support. Added some "#if PNG_WRITE_SUPPORTED" blocks. - #ifdef'ed out some redundancy in png_malloc_default(). + Removed some redundancy with #ifdef/#endif in png_malloc_default(). Use png_malloc instead of png_zalloc to allocate the pallete. version 1.0.16rc1 and 1.2.6rc1 [August 4, 2004] Fixed buffer overflow vulnerability in png_handle_tRNS() @@ -1370,7 +1371,8 @@ version 1.2.8beta1 [November 1, 2004] Fixed bug, introduced in libpng-1.2.7, that overruns a buffer during strip alpha operation in png_do_strip_filler(). Added PNG_1_2_X definition in pngconf.h - #ifdef out png_info_init in png.c and png_read_init in pngread.c (as of 1.3.0) + Comment out with #ifdef/#endif png_info_init in png.c and png_read_init + in pngread.c (as of 1.3.0) version 1.2.8beta2 [November 2, 2004] Reduce color_type to a nonalpha type after strip alpha operation in png_do_strip_filler(). @@ -1387,7 +1389,7 @@ version 1.2.8beta5 [November 20, 2004] Use png_ptr->flags instead of png_ptr->transformations to pass PNG_STRIP_ALPHA info to png_do_strip_filler(), to preserve ABI compatibility. - Revised handling of SPECIALBUILD, PRIVATEBUILD, + Revised handling of SPECIALBUILD, PRIVATEBUILD, PNG_LIBPNG_BUILD_SPECIAL_STRING and PNG_LIBPNG_BUILD_PRIVATE_STRING. version 1.2.8rc1 [November 24, 2004] Moved handling of BUILD macros from pngconf.h to png.h @@ -1685,14 +1687,14 @@ version 1.2.16beta1 [January 6, 2007] version 1.2.16beta2 [January 16, 2007] Revised scripts/CMakeLists.txt - + version 1.0.24, 1.2.16 [January 31, 2007] No changes. - + version 1.2.17beta1 [March 6, 2007] Revised scripts/CMakeLists.txt to install both shared and static libraries. Deleted a redundant line from pngset.c. - + version 1.2.17beta2 [April 26, 2007] Relocated misplaced test for png_ptr == NULL in pngpread.c Change "==" to "&" for testing PNG_RGB_TO_GRAY_ERR & PNG_RGB_TO_GRAY_WARN @@ -1713,7 +1715,7 @@ version 1.2.17rc2 [May 8, 2007] Added png_ptr->unknown_chunk to hold working unknown chunk data, so it can be free'ed in case of error. Revised unknown chunk handling in pngrutil.c and pngpread.c to use this structure. - + version 1.2.17rc3 [May 8, 2007] Revised symbol-handling in configure script. @@ -1756,9 +1758,9 @@ version 1.2.19beta6 [May 22, 2007] Added a special "_MSC_VER" case that defines png_snprintf to _snprintf version 1.2.19beta7 [May 22, 2007] - Squelched png_squelch_warnings() in pnggccrd.c and added an - #ifdef PNG_MMX_CODE_SUPPORTED block around the declarations that caused - the warnings that png_squelch_warnings was squelching. + Squelched png_squelch_warnings() in pnggccrd.c and added + an #ifdef PNG_MMX_CODE_SUPPORTED/#endif block around the declarations + that caused the warnings that png_squelch_warnings was squelching. version 1.2.19beta8 [May 22, 2007] Removed __MMX__ from test in pngconf.h. @@ -2107,7 +2109,7 @@ version 1.2.27beta01 [April 12, 2008] Fixed bug (introduced in libpng-1.0.5h) with handling zero-length unknown chunks. Added more information about png_set_keep_unknown_chunks() to the - documetation. + documentation. Reject tRNS chunk with out-of-range samples instead of masking off the invalid high bits as done in since libpng-1.2.19beta5. @@ -2127,7 +2129,7 @@ version 1.2.27beta04 [April 18, 2008] Rebuilt Makefile.in, aclocal.m4, and configure with autoconf-2.62 version 1.2.27beta05 [April 19, 2008] - Added MAINTEINERCLEANFILES variable to Makefile.am + Added MAINTAINERCLEANFILES variable to Makefile.am version 1.2.27beta06 [April 21, 2008] Avoid changing color_type from GRAY to RGB by @@ -2156,7 +2158,7 @@ version 1.2.29beta03 [May 2, 2008] automake options. Changed $(ECHO) to echo in Makefile.am and Makefile.in Updated all configure files to autoconf-2.62 - #ifdef out pnggcrd.c code if using MSC_VER + Comment out pnggcrd.c code with #ifdef/#endif if using MSC_VER version 1.2.29rc01 [May 4, 2008] No changes. @@ -2164,6 +2166,309 @@ version 1.2.29rc01 [May 4, 2008] version 1.0.35 and 1.2.29 [May 8, 2008] No changes. +version 1.0.37 [May 9, 2008] + Updated Makefile.in and configure (omitted version 1.0.36). + +version 1.2.30beta01 [May 29, 2008] + Updated libpng.pc-configure.in and libpng-config.in per debian bug reports. + +version 1.2.30beta02 [June 25, 2008] + Restored png_flush(png_ptr) at the end of png_write_end(), that was + removed from libpng-1.0.9beta03. + +version 1.2.30beta03 [July 6, 2008] + Merged some cosmetic whitespace changes from libpng-1.4.0beta19. + Inline call of png_get_uint_32() in png_get_uint_31(), as in 1.4.0beta19. + Added demo of decoding vpAg and sTER chunks to pngtest.c, from 1.4.0beta19. + Changed PNGMAJ from 0 to 12 in makefile.darwin, which does not like 0. + Added new private function png_read_chunk_header() from 1.4.0beta19. + Merge reading of chunk length and chunk type into a single 8-byte read. + Merge writing of chunk length and chunk type into a single 8-byte write. + +version 1.2.30beta04 [July 10, 2008] + Merged more cosmetic whitespace changes from libpng-1.4.0beta19. + +version 1.0.38rc01, 1.2.30rc01 [July 18, 2008] + No changes. + +version 1.0.38rc02, 1.2.30rc02 [July 21, 2008] + Moved local array "chunkdata" from pngrutil.c to the png_struct, so + it will be freed by png_read_destroy() in case of a read error (Kurt + Christensen). + +version 1.0.38rc03, 1.2.30rc03 [July 21, 2008] + Changed "purpose" and "buffer" to png_ptr->chunkdata to avoid memory leaking. + +version 1.0.38rc04, 1.2.30rc04 [July 22, 2008] + Changed "chunkdata = NULL" to "png_ptr->chunkdata = NULL" several places in + png_decompress_chunk(). + +version 1.0.38rc05, 1.2.30rc05 [July 25, 2008] + Changed all remaining "chunkdata" to "png_ptr->chunkdata" in + png_decompress_chunk() and remove chunkdata from parameter list. + Put a call to png_check_chunk_name() in png_read_chunk_header(). + Revised png_check_chunk_name() to reject a name with a lowercase 3rd byte. + Removed two calls to png_check_chunk_name() occuring later in the process. + +version 1.0.38rc06, 1.2.30rc06 [July 29, 2008] + Added a call to png_check_chunk_name() in pngpread.c + Reverted png_check_chunk_name() to accept a name with a lowercase 3rd byte. + +version 1.0.38r07, 1.2.30r07 [August 2, 2008] + Changed "-Wall" to "-W -Wall" in the CFLAGS in all makefiles (Cosmin Truta) + Declared png_ptr "volatile" in pngread.c and pngwrite.c to avoid warnings. + Added code in pngset.c to quiet compiler warnings. + Updated contrib/visupng/cexcept.h to version 2.0.1 + Relocated a misplaced "#endif /* PNG_NO_WRITE_FILTER */" in pngwutil.c + +version 1.0.38r08, 1.2.30r08 [August 2, 2008] + Enclose "volatile" declarations in #ifdef PNG_SETJMP_SUPPORTED (Cosmin). + +version 1.0.38, 1.2.30 [August 14, 2008] + No changes. + +version 1.2.31rc01 [August 19, 2008] + Removed extra crc check at the end of png_handle_cHRM(). Bug introduced + in libpng-1.2.30beta03 (Heiko Nitzsche). + +version 1.2.31rc02 [August 19, 2008] + Added PNG_WRITE_FLUSH_SUPPORTED block around new png_flush() call. + +version 1.2.31rc03 [August 19, 2008] + Added PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED block, off by default, around + new png_flush(). + +version 1.0.39, 1.2.31 [August 21, 2008] + No changes. + +version 1.2.32beta01 [September 6, 2008] + Shortened tIME_string to 29 bytes in pngtest.c (bug introduced in + libpng-1.2.22). + Fixed off-by-one error introduced in png_push_read_zTXt() function in + libpng-1.2.30beta04/pngpread.c (Harald van Dijk) + These bugs have been given the vulnerability id CVE-2008-3964. + +version 1.0.40, 1.2.32 [September 18, 2008] + No changes. + +version 1.2.33beta01 [October 6, 2008] + Revised makefile.darwin to fix shared library numbering. + Change png_set_gray_1_2_4_to_8() to png_set_expand_gray_1_2_4_to_8() + in example.c (debian bug report) + +version 1.2.33rc01 [October 15, 2008] + No changes. + +version 1.0.41rc01, version 1.2.33rc02 [October 23, 2008] + Changed remaining "key" to "png_ptr->chunkdata" in png_handle_tEXt() + to avoid memory leak after memory failure while reading tEXt chunk.` + +version 1.2.33 [October 31, 2008] + No changes. + +version 1.2.34beta01 [November 27, 2008] + Revised png_warning() to write its message on standard output by default + when warning_fn is NULL. This was the behavior prior to libpng-1.2.9beta9. + Fixed string vs pointer-to-string error in png_check_keyword(). + Added png_check_cHRM_fixed() in png.c and moved checking from pngget.c, + pngrutil.c, and pngwrite.c, and eliminated floating point cHRM checking. + Added check for zero-area RGB cHRM triangle in png_check_cHRM_fixed(). + In png_check_cHRM_fixed(), ensure white_y is > 0, and removed redundant + check for all-zero coordinates that is detected by the triangle check. + Revised png_warning() to write its message on standard output by default + when warning_fn is NULL. + +version 1.2.34beta02 [November 28, 2008] + Corrected off-by-one error in bKGD validity check in png_write_bKGD() + and in png_handle_bKGD(). + +version 1.2.34beta03 [December 1, 2008] + Revised bKGD validity check to use >= x instead of > x + 1 + Merged with png_debug from libpng-1.4.0 to remove newlines. + +version 1.2.34beta04 [December 2, 2008] + More merging with png_debug from libpng-1.4.0 to remove newlines. + +version 1.2.34beta05 [December 5, 2008] + Removed redundant check for key==NULL before calling png_check_keyword() + to ensure that new_key gets initialized and removed extra warning + (Arvan Pritchard). + +version 1.2.34beta06 [December 9, 2008] + In png_write_png(), respect the placement of the filler bytes in an earlier + call to png_set_filler() (Jim Barry). + +version 1.2.34beta07 [December 9, 2008] + Undid previous change and added PNG_TRANSFORM_STRIP_FILLER_BEFORE and + PNG_TRANSFORM_STRIP_FILLER_AFTER conditionals and deprecated + PNG_TRANSFORM_STRIP_FILLER (Jim Barry). + +version 1.0.42rc01, 1.2.34rc01 [December 11, 2008] + No changes. + +version 1.0.42, 1.2.34 [December 18, 2008] + No changes. + +version 1.2.35beta01 [February 4, 2009] + Zero out some arrays of pointers after png_malloc(). (Tavis Ormandy) + +version 1.2.35beta02 [February 4, 2009] + Zero out more arrays of pointers after png_malloc(). + +version 1.2.35beta03 [February 5, 2009] + Use png_memset() instead of a loop to intialize pointers. We realize + this will not work on platforms where the NULL pointer is not all zeroes. + +version 1.2.35rc01 [February 11, 2009] + No changes. + +version 1.2.35rc02 [February 12, 2009] + Fix typo in new png_memset call in pngset.c (png_color should be png_charp) + +version 1.0.43 and 1.2.35 [February 14, 2009] + No changes. + +version 1.2.36beta01 [February 28, 2009] + Revised comments in png_set_read_fn() and png_set_write_fn(). + Revised order of #ifdef's and indentation in png_debug definitions of png.h + bug introduced in libpng-1.2.34. + +version 1.2.36beta02 [March 21, 2009] + Use png_memset() after png_malloc() of big_row_buf when reading an + interlaced file, to avoid a possible UMR. + Undid recent revision of PNG_NO_STDIO version of png_write_flush(). Users + having trouble with fflush() can build with PNG_NO_WRITE_FLUSH defined. + Revised libpng*.txt documentation about use of png_write_flush(). + Removed fflush() from pngtest.c. + Added "#define PNG_NO_WRITE_FLUSH" to contrib/pngminim/encoder/pngusr.h + +version 1.2.36beta03 [March 27, 2009] + Relocated misplaced PNG_1_0_X define in png.h that caused the prototype + for png_set_strip_error_numbers() to be omitted from PNG_NO_ASSEMBLER_CODE + builds. This bug was introduced in libpng-1.2.15beta4. + Added a section on differences between 1.0.x and 1.2.x to libpng.3/libpng.txt + +version 1.2.36beta04 [April 5, 2009] + Fixed potential memory leak of "new_name" in png_write_iCCP() (Ralph Giles) + +version 1.2.36beta05 [April 24, 2009] + Added "ifndef PNG_SKIP_SETJMP_CHECK" block in pngconf.h to allow + application code writers to bypass the check for multiple inclusion + of setjmp.h when they know that it is safe to ignore the situation. + Made some cosmetic changes to whitespace in pngtest output. + Renamed "user_chunk_data" to "my_user_chunk_data" in pngtest.c to suppress + "shadowed declaration" warning from gcc-4.3.3. + Renamed "gamma" to "png_gamma" in pngset.c to avoid "shadowed declaration" + warning about a global "gamma" variable in math.h on some platforms. + +version 1.2.36rc01 [April 30, 2009] + No changes. + +version 1.0.44 and 1.2.36 [May 7, 2009] + No changes. + +version 1.2.37beta01 [May 14, 2009] + Fixed inconsistency in pngrutil.c, introduced in libpng-1.2.36. The + memset() was using "png_ptr->rowbytes" instead of "row_bytes", which + the corresponding png_malloc() uses (Joe Drew). + Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri) + Updated some of the makefiles in the scripts directory (merged with + those in libpng-1.4.0beta57). + +version 1.2.37beta02 [May 19, 2009] + Fixed typo in libpng documentation (FILTER_AVE should be FILTER_AVG) + Relocated misplaced #endif in pngwrite.c, sCAL chunk handler. + Conditionally compile png_read_finish_row() which is not used by + progressive readers. + Added contrib/pngminim/preader to demonstrate building minimal progressive + decoder, based on contrib/gregbook with embedded libpng and zlib. + +version 1.2.37beta03 [May 20, 2009] + In contrib/pngminim/*, renamed "makefile.std" to "makefile", since there + is only one makefile in those directories, and revised the README files + accordingly. + Reformated sources in libpng style (3-space indentation, comment format) + +version 1.2.37rc01 [May 27, 2009] + No changes. + +versions 1.2.37 and 1.0.45 [June 4, 2009] + Reformatted several remaining "else statement;" and "if () statement;" into + two lines. + Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h + and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h + Added sections about the git repository and our coding style to the + documentation (merged from libpng-1.4.0beta62) + Added a section to the libpng documentation about using png_get_io_ptr() + in configure scripts to detect the presence of libpng. + +version 1.2.38beta01 [June 17, 2009] + Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR() + multiple times and to specify the sample order in the tRNS chunk, + because the ISO PNG specification has a typo in the tRNS table. + Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to + PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism + available for ignoring known chunks even when not saving unknown chunks. + Adopted preference for consistent use of "#ifdef" and "#ifndef" versus + "#if defined()" and "if !defined()" where possible. + Added PNG_NO_HANDLE_AS_UNKNOWN in the PNG_LEGACY_SUPPORTED block of + pngconf.h, and moved the various unknown chunk macro definitions + outside of the PNG_READ|WRITE_ANCILLARY_CHUNK_SUPPORTED blocks. + +version 1.0.46 [June 18, 2009] + Removed some editing cruft from scripts/libpng.pc.in and some makefiles. + +version 1.2.38rc01 [June 24, 2009] + No changes. + +version 1.2.38rc02 [June 29, 2009] + Added a reference to the libpng license in each source file. + +version 1.2.38rc03 [July 11, 2009] + Revised references to the libpng license in pngconf.h and contrib/visupng + source files. + Rebuilt configure scripts with autoconf-2.63. + +version 1.0.47 and 1.2.38 [July 16, 2009] + No changes. + +version 1.2.39beta01 [July 25, 2009] + Added a prototype for png_64bit_product() in png.c + +version 1.2.39beta02 [July 27, 2009] + Avoid a possible NULL dereference in debug build, in png_set_text_2(). + (bug introduced in libpng-0.95, discovered by Evan Rouault) + +version 1.2.39beta03 [July 29, 2009] + Relocated new png_64_bit_product() prototype into png.h + Expanded the information about prototypes in the libpng style section of + the documentation. + Rebuilt configure scripts with autoconf-2.64. + +version 1.2.39beta04 [August 1, 2009] + Replaced *.tar.lzma with *.txz in distribution. Get the xz codec + from . + +version 1.2.39beta05 [August 1, 2009] + Reject attempt to write iCCP chunk with negative embedded profile length + (JD Chen) + +version 1.2.39c01 [August 6, 2009] + No changes. + +version 1.2.39 and 1.0.48 [August 13, 2009] + No changes. + +version 1.2.40beta01 [August 20, 2009] + Removed an extra png_debug() recently added to png_write_find_filter(). + Fixed incorrect #ifdef in pngset.c regarding unknown chunk support. + +version 1.2.40rc01 [September 2, 2009] + Various bugfixes and improvements to CMakeLists.txt (Philip Lowman) + +version 1.2.40 and 1.0.49 [September 10, 2009] + No changes. + Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement @@ -2171,3 +2476,4 @@ to subscribe) or to glennrp at users.sourceforge.net Glenn R-P +*/ diff --git a/src/3rdparty/libpng/INSTALL b/src/3rdparty/libpng/INSTALL index 6060e31..2986ae3 100644 --- a/src/3rdparty/libpng/INSTALL +++ b/src/3rdparty/libpng/INSTALL @@ -1,5 +1,5 @@ -Installing libpng version 1.2.29 - May 8, 2008 +Installing libpng version 1.2.40 - September 10, 2009 On Unix/Linux and similar systems, you can simply type @@ -44,7 +44,7 @@ to have access to the zlib.h and zconf.h include files that correspond to the version of zlib that's installed. You can rename the directories that you downloaded (they -might be called "libpng-1.2.29" or "lpng109" and "zlib-1.2.1" +might be called "libpng-1.2.40" or "lpng109" and "zlib-1.2.1" or "zlib121") so that you have directories called "zlib" and "libpng". Your directory structure should look like this: @@ -101,9 +101,9 @@ include CMakeLists.txt => "cmake" script makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.elf => Linux/ELF makefile symbol versioning, - gcc, creates libpng12.so.0.1.2.29) + gcc, creates libpng12.so.0.1.2.40) makefile.linux => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.29) + (gcc, creates libpng12.so.0.1.2.40) makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.knr => Archaic UNIX Makefile that converts files with ansi2knr (Requires ansi2knr.c from @@ -125,14 +125,14 @@ include makefile.openbsd => OpenBSD makefile makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) makefile.sggcc => Silicon Graphics (gcc, - creates libpng12.so.0.1.2.29) + creates libpng12.so.0.1.2.40) makefile.sunos => Sun makefile makefile.solaris => Solaris 2.X makefile (gcc, - creates libpng12.so.0.1.2.29) + creates libpng12.so.0.1.2.40) makefile.solaris-x86 => Solaris/intelMMX 2.X makefile (gcc, - creates libpng12.so.0.1.2.29) + creates libpng12.so.0.1.2.40) makefile.so9 => Solaris 9 makefile (gcc, - creates libpng12.so.0.1.2.29) + creates libpng12.so.0.1.2.40) makefile.32sunu => Sun Ultra 32-bit makefile makefile.64sunu => Sun Ultra 64-bit makefile makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc diff --git a/src/3rdparty/libpng/KNOWNBUG b/src/3rdparty/libpng/KNOWNBUG index 7688a9c..5e0c96f 100644 --- a/src/3rdparty/libpng/KNOWNBUG +++ b/src/3rdparty/libpng/KNOWNBUG @@ -1,5 +1,5 @@ -Known bugs in libpng version 1.2.29 +Known bugs in libpng version 1.2.40 1. February 23, 2006: The custom makefiles don't build libpng with -lz. diff --git a/src/3rdparty/libpng/LICENSE b/src/3rdparty/libpng/LICENSE index 072d9ef..93dd04a 100644 --- a/src/3rdparty/libpng/LICENSE +++ b/src/3rdparty/libpng/LICENSE @@ -8,8 +8,10 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: If you modify libpng you may insert additional notices immediately following this sentence. -libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are -Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and are +This code is released under the libpng license. + +libpng versions 1.2.6, August 15, 2004, through 1.2.40, September 10, 2009, are +Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors @@ -106,4 +108,4 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -May 8, 2008 +September 10, 2009 diff --git a/src/3rdparty/libpng/README b/src/3rdparty/libpng/README index fd2dbb1..171b65a 100644 --- a/src/3rdparty/libpng/README +++ b/src/3rdparty/libpng/README @@ -1,4 +1,4 @@ -README for libpng version 1.2.29 - May 8, 2008 (shared library 12.0) +README for libpng version 1.2.40 - September 10, 2009 (shared library 12.0) See the note about version numbers near the top of png.h See INSTALL for instructions on how to install libpng. @@ -6,7 +6,10 @@ See INSTALL for instructions on how to install libpng. Libpng comes in several distribution formats. Get libpng-*.tar.gz, libpng-*.tar.lzma, or libpng-*.tar.bz2 if you want UNIX-style line endings in the text files, or lpng*.7z or lpng*.zip if you want DOS-style -line endings. +line endings. You can get UNIX-style line endings from the *.zip file +by using "unzip -a" but there seems to be no simple way to recover +UNIX-style line endings from the *.7z file. The *.tar.lzma file is +recommended for *NIX users instead. Version 0.89 was the first official release of libpng. Don't let the fact that it's the first release fool you. The libpng library has been in @@ -55,7 +58,7 @@ to set different actions based on whether the CRC error occurred in a critical or an ancillary chunk. The changes made to the library, and bugs fixed are based on discussions -on the PNG-implement mailing list +on the png-mng-implement mailing list and not on material submitted privately to Guy, Andreas, or Glenn. They will forward any good suggestions to the list. @@ -111,14 +114,14 @@ to subscribe) or to glennrp at users.sourceforge.net You can't reach Guy, the original libpng author, at the addresses given in previous versions of this document. He and Andreas will read mail -addressed to the png-implement list, however. +addressed to the png-mng-implement list, however. Please do not send general questions about PNG. Send them to the (png-mng-misc at lists.sourceforge.net, subscription required, visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement to subscribe) On the other hand, please do not send libpng questions to that address, send them to me -or to the png-implement list. I'll +or to the png-mng-implement list. I'll get them in the end anyway. If you have a question about something in the PNG specification that is related to using libpng, send it to me. Send me any questions that start with "I was using libpng, @@ -191,11 +194,11 @@ Files in this distribution: descrip.mms => VMS makefile for MMS or MMK makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.elf => Linux/ELF makefile symbol versioning, - gcc, creates libpng12.so.0.1.2.29) + gcc, creates libpng12.so.0.1.2.40) makefile.linux => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.29) + (gcc, creates libpng12.so.0.1.2.40) makefile.gcmmx => Linux/ELF makefile - (gcc, creates libpng12.so.0.1.2.29, + (gcc, creates libpng12.so.0.1.2.40, uses assembler code tuned for Intel MMX platform) makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.knr => Archaic UNIX Makefile that converts files with @@ -217,12 +220,12 @@ Files in this distribution: makefile.openbsd => OpenBSD makefile makefile.sgi => Silicon Graphics IRIX (cc, creates static lib) makefile.sggcc => Silicon Graphics - (gcc, creates libpng12.so.0.1.2.29) + (gcc, creates libpng12.so.0.1.2.40) makefile.sunos => Sun makefile makefile.solaris => Solaris 2.X makefile - (gcc, creates libpng12.so.0.1.2.29) + (gcc, creates libpng12.so.0.1.2.40) makefile.so9 => Solaris 9 makefile - (gcc, creates libpng12.so.0.1.2.29) + (gcc, creates libpng12.so.0.1.2.40) makefile.32sunu => Sun Ultra 32-bit makefile makefile.64sunu => Sun Ultra 64-bit makefile makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc diff --git a/src/3rdparty/libpng/TODO b/src/3rdparty/libpng/TODO index a5f6395..face765 100644 --- a/src/3rdparty/libpng/TODO +++ b/src/3rdparty/libpng/TODO @@ -22,3 +22,4 @@ Build gamma tables using fixed point (and do away with floating point entirely). Use greater precision when changing to linear gamma for compositing against background and doing rgb-to-gray transformation. Investigate pre-incremented loop counters and other loop constructions. +Add interpolated method of handling interlacing. diff --git a/src/3rdparty/libpng/Y2KINFO b/src/3rdparty/libpng/Y2KINFO index 43348df..e31bb7f 100644 --- a/src/3rdparty/libpng/Y2KINFO +++ b/src/3rdparty/libpng/Y2KINFO @@ -1,13 +1,13 @@ Y2K compliance in libpng: ========================= - May 8, 2008 + September 10, 2009 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and - upward through 1.2.29 are Y2K compliant. It is my belief that earlier + upward through 1.2.40 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has three year fields. One is a 2-byte unsigned integer diff --git a/src/3rdparty/libpng/configure b/src/3rdparty/libpng/configure index 56b2452..4871efc 100755 --- a/src/3rdparty/libpng/configure +++ b/src/3rdparty/libpng/configure @@ -1,13 +1,13 @@ #!/bin/sh echo " There is no \"configure\" script in this distribution of - libpng-1.2.29. + libpng-1.2.40. Instead, please copy the appropriate makefile for your system from the \"scripts\" directory. Read the INSTALL file for more details. Update, July 2004: you can get a \"configure\" based distribution from the libpng distribution sites. Download the file - libpng-1.2.29.tar.gz, libpng-1.2.29.tar.lzma, or libpng-1.2.29.tar.bz2 + libpng-1.2.40.tar.gz, libpng-1.2.40.tar.lzma, or libpng-1.2.40.tar.bz2 " diff --git a/src/3rdparty/libpng/example.c b/src/3rdparty/libpng/example.c index 0815873..dcf38de 100644 --- a/src/3rdparty/libpng/example.c +++ b/src/3rdparty/libpng/example.c @@ -2,9 +2,9 @@ #if 0 /* in case someone actually tries to compile this */ /* example.c - an example of using libpng - * Last changed in libpng 1.2.1 December 7, 2001. + * Last changed in libpng 1.2.37 [June 4, 2009] * This file has been placed in the public domain by the authors. - * Maintained 1998-2007 Glenn Randers-Pehrson + * Maintained 1998-2009 Glenn Randers-Pehrson * Maintained 1996, 1997 Andreas Dilger) * Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) */ @@ -91,14 +91,15 @@ void read_png(char *file_name) /* We need to open the file */ if ((fp = fopen(file_name, "rb")) == NULL) return (ERROR); + #else no_open_file /* prototype 2 */ -void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ +void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ { png_structp png_ptr; png_infop info_ptr; png_uint_32 width, height; int bit_depth, color_type, interlace_type; -#endif no_open_file /* only use one prototype! */ +#endif no_open_file /* Only use one prototype! */ /* Create and initialize the png_struct with the desired error handler * functions. If you want to use the default stderr and longjump method, @@ -164,6 +165,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ * pixels) into the info structure with this call: */ png_read_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); + #else /* OK, you're doing it the hard way, with the lower-level functions */ @@ -175,13 +177,13 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, int_p_NULL, int_p_NULL); -/* Set up the data transformations you want. Note that these are all - * optional. Only call them if you want/need them. Many of the - * transformations only work on specific types of images, and many - * are mutually exclusive. - */ + /* Set up the data transformations you want. Note that these are all + * optional. Only call them if you want/need them. Many of the + * transformations only work on specific types of images, and many + * are mutually exclusive. + */ - /* tell libpng to strip 16 bit/color files down to 8 bits/color */ + /* Tell libpng to strip 16 bit/color files down to 8 bits/color */ png_set_strip_16(png_ptr); /* Strip alpha bytes from the input data without combining with the @@ -204,7 +206,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ /* Expand grayscale images to the full 8 bits from 1, 2, or 4 bits/pixel */ if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) - png_set_gray_1_2_4_to_8(png_ptr); + png_set_expand_gray_1_2_4_to_8(png_ptr); /* Expand paletted or RGB images with transparency to full alpha channels * so the data will be available as RGBA quartets. @@ -228,10 +230,11 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ png_set_background(png_ptr, &my_background, PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - /* Some suggestions as to how to get a screen gamma value */ - - /* Note that screen gamma is the display_exponent, which includes - * the CRT_exponent and any correction for viewing conditions */ + /* Some suggestions as to how to get a screen gamma value + * + * Note that screen gamma is the display_exponent, which includes + * the CRT_exponent and any correction for viewing conditions + */ if (/* We have a user-defined screen gamma value */) { screen_gamma = user-defined screen_gamma; @@ -244,7 +247,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ /* If we don't have another value */ else { - screen_gamma = 2.2; /* A good guess for a PC monitors in a dimly + screen_gamma = 2.2; /* A good guess for a PC monitor in a dimly lit room */ screen_gamma = 1.7 or 1.0; /* A good guess for Mac systems */ } @@ -277,7 +280,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ png_colorp palette; /* This reduces the image to the application supplied palette */ - if (/* we have our own palette */) + if (/* We have our own palette */) { /* An array of colors to which the image should be dithered */ png_color std_color_cube[MAX_SCREEN_COLORS]; @@ -297,7 +300,7 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ } } - /* invert monochrome files to have 0 as white and 1 as black */ + /* Invert monochrome files to have 0 as white and 1 as black */ png_set_invert_mono(png_ptr); /* If you want to shift the pixel values from the range [0,255] or @@ -306,20 +309,20 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ */ if (png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT)) { - png_color_8p sig_bit; + png_color_8p sig_bit_p; - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - png_set_shift(png_ptr, sig_bit); + png_get_sBIT(png_ptr, info_ptr, &sig_bit_p); + png_set_shift(png_ptr, sig_bit_p); } - /* flip the RGB pixels to BGR (or RGBA to BGRA) */ + /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ if (color_type & PNG_COLOR_MASK_COLOR) png_set_bgr(png_ptr); - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ + /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ png_set_swap_alpha(png_ptr); - /* swap bytes of 16 bit files to least significant byte first */ + /* Swap bytes of 16 bit files to least significant byte first */ png_set_swap(png_ptr); /* Add filler (or alpha) byte (before/after each RGB triplet) */ @@ -342,11 +345,13 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ /* The easiest way to read the image: */ png_bytep row_pointers[height]; + /* Clear the pointer array */ + for (row = 0; row < height; row++) + row_pointers[row] = NULL; + for (row = 0; row < height; row++) - { row_pointers[row] = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - } /* Now it's time to read the image. One of these methods is REQUIRED */ #ifdef entire /* Read the entire image in one go */ @@ -372,32 +377,31 @@ void read_png(FILE *fp, unsigned int sig_read) /* file is already open */ #else no_sparkle /* Read the image using the "rectangle" effect */ png_read_rows(png_ptr, png_bytepp_NULL, &row_pointers[y], number_of_rows); -#endif no_sparkle /* use only one of these two methods */ +#endif no_sparkle /* Use only one of these two methods */ } - /* if you want to display the image after every pass, do - so here */ -#endif no_single /* use only one of these two methods */ + /* If you want to display the image after every pass, do so here */ +#endif no_single /* Use only one of these two methods */ } -#endif no_entire /* use only one of these two methods */ +#endif no_entire /* Use only one of these two methods */ - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ + /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); #endif hilevel /* At this point you have read the entire image */ - /* clean up after the read, and free any memory allocated - REQUIRED */ + /* Clean up after the read, and free any memory allocated - REQUIRED */ png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL); - /* close the file */ + /* Close the file */ fclose(fp); - /* that's it */ + /* That's it */ return (OK); } -/* progressively read a file */ +/* Progressively read a file */ int initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr) @@ -462,7 +466,7 @@ process_data(png_structp *png_ptr, png_infop *info_ptr, /* This one's new also. Simply give it chunks of data as * they arrive from the data stream (in order, of course). - * On Segmented machines, don't give it any more than 64K. + * On segmented machines, don't give it any more than 64K. * The library seems to run fine with sizes of 4K, although * you can give it much less if necessary (I assume you can * give it chunks of 1 byte, but I haven't tried with less @@ -476,36 +480,37 @@ process_data(png_structp *png_ptr, png_infop *info_ptr, info_callback(png_structp png_ptr, png_infop info) { -/* do any setup here, including setting any of the transformations - * mentioned in the Reading PNG files section. For now, you _must_ - * call either png_start_read_image() or png_read_update_info() - * after all the transformations are set (even if you don't set - * any). You may start getting rows before png_process_data() - * returns, so this is your last chance to prepare for that. - */ + /* Do any setup here, including setting any of the transformations + * mentioned in the Reading PNG files section. For now, you _must_ + * call either png_start_read_image() or png_read_update_info() + * after all the transformations are set (even if you don't set + * any). You may start getting rows before png_process_data() + * returns, so this is your last chance to prepare for that. + */ } row_callback(png_structp png_ptr, png_bytep new_row, png_uint_32 row_num, int pass) { -/* - * This function is called for every row in the image. If the - * image is interlaced, and you turned on the interlace handler, - * this function will be called for every row in every pass. - * - * In this function you will receive a pointer to new row data from - * libpng called new_row that is to replace a corresponding row (of - * the same data format) in a buffer allocated by your application. - * - * The new row data pointer new_row may be NULL, indicating there is - * no new data to be replaced (in cases of interlace loading). - * - * If new_row is not NULL then you need to call - * png_progressive_combine_row() to replace the corresponding row as - * shown below: - */ + /* + * This function is called for every row in the image. If the + * image is interlaced, and you turned on the interlace handler, + * this function will be called for every row in every pass. + * + * In this function you will receive a pointer to new row data from + * libpng called new_row that is to replace a corresponding row (of + * the same data format) in a buffer allocated by your application. + * + * The new row data pointer "new_row" may be NULL, indicating there is + * no new data to be replaced (in cases of interlace loading). + * + * If new_row is not NULL then you need to call + * png_progressive_combine_row() to replace the corresponding row as + * shown below: + */ + /* Check if row_num is in bounds. */ - if((row_num >= 0) && (row_num < height)) + if ((row_num >= 0) && (row_num < height)) { /* Get pointer to corresponding row in our * PNG read buffer. @@ -515,47 +520,47 @@ row_callback(png_structp png_ptr, png_bytep new_row, /* If both rows are allocated then copy the new row * data to the corresponding row data. */ - if((old_row != NULL) && (new_row != NULL)) + if ((old_row != NULL) && (new_row != NULL)) png_progressive_combine_row(png_ptr, old_row, new_row); } -/* - * The rows and passes are called in order, so you don't really - * need the row_num and pass, but I'm supplying them because it - * may make your life easier. - * - * For the non-NULL rows of interlaced images, you must call - * png_progressive_combine_row() passing in the new row and the - * old row, as demonstrated above. You can call this function for - * NULL rows (it will just return) and for non-interlaced images - * (it just does the png_memcpy for you) if it will make the code - * easier. Thus, you can just do this for all cases: - */ + /* + * The rows and passes are called in order, so you don't really + * need the row_num and pass, but I'm supplying them because it + * may make your life easier. + * + * For the non-NULL rows of interlaced images, you must call + * png_progressive_combine_row() passing in the new row and the + * old row, as demonstrated above. You can call this function for + * NULL rows (it will just return) and for non-interlaced images + * (it just does the png_memcpy for you) if it will make the code + * easier. Thus, you can just do this for all cases: + */ png_progressive_combine_row(png_ptr, old_row, new_row); -/* where old_row is what was displayed for previous rows. Note - * that the first pass (pass == 0 really) will completely cover - * the old row, so the rows do not have to be initialized. After - * the first pass (and only for interlaced images), you will have - * to pass the current row as new_row, and the function will combine - * the old row and the new row. - */ + /* where old_row is what was displayed for previous rows. Note + * that the first pass (pass == 0 really) will completely cover + * the old row, so the rows do not have to be initialized. After + * the first pass (and only for interlaced images), you will have + * to pass the current row as new_row, and the function will combine + * the old row and the new row. + */ } end_callback(png_structp png_ptr, png_infop info) { -/* this function is called when the whole image has been read, - * including any chunks after the image (up to and including - * the IEND). You will usually have the same info chunk as you - * had in the header, although some data may have been added - * to the comments and time fields. - * - * Most people won't do much here, perhaps setting a flag that - * marks the image as finished. - */ + /* This function is called when the whole image has been read, + * including any chunks after the image (up to and including + * the IEND). You will usually have the same info chunk as you + * had in the header, although some data may have been added + * to the comments and time fields. + * + * Most people won't do much here, perhaps setting a flag that + * marks the image as finished. + */ } -/* write a png file */ +/* Write a png file */ void write_png(char *file_name /* , ... other image information ... */) { FILE *fp; @@ -563,7 +568,7 @@ void write_png(char *file_name /* , ... other image information ... */) png_infop info_ptr; png_colorp palette; - /* open the file */ + /* Open the file */ fp = fopen(file_name, "wb"); if (fp == NULL) return (ERROR); @@ -597,30 +602,34 @@ void write_png(char *file_name /* , ... other image information ... */) */ if (setjmp(png_jmpbuf(png_ptr))) { - /* If we get here, we had a problem reading the file */ + /* If we get here, we had a problem writing the file */ fclose(fp); png_destroy_write_struct(&png_ptr, &info_ptr); return (ERROR); } /* One of the following I/O initialization functions is REQUIRED */ + #ifdef streams /* I/O initialization method 1 */ - /* set up the output control if you are using standard C streams */ + /* Set up the output control if you are using standard C streams */ png_init_io(png_ptr, fp); + #else no_streams /* I/O initialization method 2 */ - /* If you are using replacement read functions, instead of calling - * png_init_io() here you would call */ + /* If you are using replacement write functions, instead of calling + * png_init_io() here you would call + */ png_set_write_fn(png_ptr, (void *)user_io_ptr, user_write_fn, user_IO_flush_function); /* where user_io_ptr is a structure you want available to the callbacks */ -#endif no_streams /* only use one initialization method */ +#endif no_streams /* Only use one initialization method */ #ifdef hilevel /* This is the easy way. Use it if you already have all the - * image info living info in the structure. You could "|" many + * image info living in the structure. You could "|" many * PNG_TRANSFORM flags into the png_transforms integer here. */ png_write_png(png_ptr, info_ptr, png_transforms, png_voidp_NULL); + #else /* This is the hard way */ @@ -635,25 +644,27 @@ void write_png(char *file_name /* , ... other image information ... */) png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, PNG_COLOR_TYPE_???, PNG_INTERLACE_????, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE); - /* set the palette if there is one. REQUIRED for indexed-color images */ + /* Set the palette if there is one. REQUIRED for indexed-color images */ palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH - * png_sizeof (png_color)); - /* ... set palette colors ... */ + * png_sizeof(png_color)); + /* ... Set palette colors ... */ png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH); /* You must not free palette here, because png_set_PLTE only makes a link to - the palette that you malloced. Wait until you are about to destroy - the png structure. */ + * the palette that you malloced. Wait until you are about to destroy + * the png structure. + */ - /* optional significant bit chunk */ - /* if we are dealing with a grayscale image then */ + /* Optional significant bit (sBIT) chunk */ + png_color_8 sig_bit; + /* If we are dealing with a grayscale image then */ sig_bit.gray = true_bit_depth; - /* otherwise, if we are dealing with a color image then */ + /* Otherwise, if we are dealing with a color image then */ sig_bit.red = true_red_bit_depth; sig_bit.green = true_green_bit_depth; sig_bit.blue = true_blue_bit_depth; - /* if the image has an alpha channel then */ + /* If the image has an alpha channel then */ sig_bit.alpha = true_alpha_bit_depth; - png_set_sBIT(png_ptr, info_ptr, sig_bit); + png_set_sBIT(png_ptr, info_ptr, &sig_bit); /* Optional gamma chunk is strongly suggested if you have any guess @@ -678,9 +689,12 @@ void write_png(char *file_name /* , ... other image information ... */) #endif png_set_text(png_ptr, info_ptr, text_ptr, 3); - /* other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs, */ - /* note that if sRGB is present the gAMA and cHRM chunks must be ignored - * on read and must be written in accordance with the sRGB profile */ + /* Other optional chunks like cHRM, bKGD, tRNS, tIME, oFFs, pHYs */ + + /* Note that if sRGB is present the gAMA and cHRM chunks must be ignored + * on read and, if your application chooses to write them, they must + * be written in accordance with the sRGB profile + */ /* Write the file header information. REQUIRED */ png_write_info(png_ptr, info_ptr); @@ -692,7 +706,7 @@ void write_png(char *file_name /* , ... other image information ... */) * write_my_chunk(); * png_write_info(png_ptr, info_ptr); * - * However, given the level of known- and unknown-chunk support in 1.1.0 + * However, given the level of known- and unknown-chunk support in 1.2.0 * and up, this should no longer be necessary. */ @@ -702,11 +716,11 @@ void write_png(char *file_name /* , ... other image information ... */) * at the end. */ - /* set up the transformations you want. Note that these are + /* Set up the transformations you want. Note that these are * all optional. Only call them if you want them. */ - /* invert monochrome pixels */ + /* Invert monochrome pixels */ png_set_invert_mono(png_ptr); /* Shift the pixels up to a legal bit depth and fill in @@ -714,10 +728,10 @@ void write_png(char *file_name /* , ... other image information ... */) */ png_set_shift(png_ptr, &sig_bit); - /* pack pixels into bytes */ + /* Pack pixels into bytes */ png_set_packing(png_ptr); - /* swap location of alpha bytes from ARGB to RGBA */ + /* Swap location of alpha bytes from ARGB to RGBA */ png_set_swap_alpha(png_ptr); /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into @@ -725,16 +739,16 @@ void write_png(char *file_name /* , ... other image information ... */) */ png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - /* flip BGR pixels to RGB */ + /* Flip BGR pixels to RGB */ png_set_bgr(png_ptr); - /* swap bytes of 16-bit files to most significant byte first */ + /* Swap bytes of 16-bit files to most significant byte first */ png_set_swap(png_ptr); - /* swap bits of 1, 2, 4 bit packed pixel formats */ + /* Swap bits of 1, 2, 4 bit packed pixel formats */ png_set_packswap(png_ptr); - /* turn on interlace handling if you are not using png_write_image() */ + /* Turn on interlace handling if you are not using png_write_image() */ if (interlacing) number_passes = png_set_interlace_handling(png_ptr); else @@ -755,12 +769,14 @@ void write_png(char *file_name /* , ... other image information ... */) row_pointers[k] = image + k*width*bytes_per_pixel; /* One of the following output methods is REQUIRED */ -#ifdef entire /* write out the entire image data in one call */ + +#ifdef entire /* Write out the entire image data in one call */ png_write_image(png_ptr, row_pointers); - /* the other way to write the image - deal with interlacing */ + /* The other way to write the image - deal with interlacing */ + +#else no_entire /* Write out the image data by one or more scanlines */ -#else no_entire /* write out the image data by one or more scanlines */ /* The number of passes is either 1 for non-interlaced images, * or 7 for interlaced images. */ @@ -771,14 +787,12 @@ void write_png(char *file_name /* , ... other image information ... */) /* If you are only writing one row at a time, this works */ for (y = 0; y < height; y++) - { png_write_rows(png_ptr, &row_pointers[y], 1); - } } -#endif no_entire /* use only one output method */ +#endif no_entire /* Use only one output method */ /* You can write optional chunks like tEXt, zTXt, and tIME at the end - * as well. Shouldn't be necessary in 1.1.0 and up as all the public + * as well. Shouldn't be necessary in 1.2.0 and up as all the public * chunks are supported and you can use png_set_unknown_chunks() to * register unknown chunks into the info structure to be written out. */ @@ -788,26 +802,33 @@ void write_png(char *file_name /* , ... other image information ... */) #endif hilevel /* If you png_malloced a palette, free it here (don't free info_ptr->palette, - as recommended in versions 1.0.5m and earlier of this example; if - libpng mallocs info_ptr->palette, libpng will free it). If you - allocated it with malloc() instead of png_malloc(), use free() instead - of png_free(). */ + * as recommended in versions 1.0.5m and earlier of this example; if + * libpng mallocs info_ptr->palette, libpng will free it). If you + * allocated it with malloc() instead of png_malloc(), use free() instead + * of png_free(). + */ png_free(png_ptr, palette); - palette=NULL; + palette = NULL; /* Similarly, if you png_malloced any data that you passed in with - png_set_something(), such as a hist or trans array, free it here, - when you can be sure that libpng is through with it. */ + * png_set_something(), such as a hist or trans array, free it here, + * when you can be sure that libpng is through with it. + */ png_free(png_ptr, trans); - trans=NULL; + trans = NULL; + /* Whenever you use png_free() it is a good idea to set the pointer to + * NULL in case your application inadvertently tries to png_free() it + * again. When png_free() sees a NULL it returns without action, thus + * avoiding the double-free security problem. + */ - /* clean up after the write, and free any memory allocated */ + /* Clean up after the write, and free any memory allocated */ png_destroy_write_struct(&png_ptr, &info_ptr); - /* close the file */ + /* Close the file */ fclose(fp); - /* that's it */ + /* That's it */ return (OK); } diff --git a/src/3rdparty/libpng/libpng-1.2.29.txt b/src/3rdparty/libpng/libpng-1.2.29.txt deleted file mode 100644 index 91b9806..0000000 --- a/src/3rdparty/libpng/libpng-1.2.29.txt +++ /dev/null @@ -1,2906 +0,0 @@ -libpng.txt - A description on how to use and modify libpng - - libpng version 1.2.29 - May 8, 2008 - Updated and distributed by Glenn Randers-Pehrson - - Copyright (c) 1998-2008 Glenn Randers-Pehrson - For conditions of distribution and use, see copyright - notice in png.h. - - Based on: - - libpng versions 0.97, January 1998, through 1.2.29 - May 8, 2008 - Updated and distributed by Glenn Randers-Pehrson - Copyright (c) 1998-2008 Glenn Randers-Pehrson - - libpng 1.0 beta 6 version 0.96 May 28, 1997 - Updated and distributed by Andreas Dilger - Copyright (c) 1996, 1997 Andreas Dilger - - libpng 1.0 beta 2 - version 0.88 January 26, 1996 - For conditions of distribution and use, see copyright - notice in png.h. Copyright (c) 1995, 1996 Guy Eric - Schalnat, Group 42, Inc. - - Updated/rewritten per request in the libpng FAQ - Copyright (c) 1995, 1996 Frank J. T. Wojcik - December 18, 1995 & January 20, 1996 - -I. Introduction - -This file describes how to use and modify the PNG reference library -(known as libpng) for your own use. There are five sections to this -file: introduction, structures, reading, writing, and modification and -configuration notes for various special platforms. In addition to this -file, example.c is a good starting point for using the library, as -it is heavily commented and should include everything most people -will need. We assume that libpng is already installed; see the -INSTALL file for instructions on how to install libpng. - -For examples of libpng usage, see the files "example.c", "pngtest.c", -and the files in the "contrib" directory, all of which are included in the -libpng distribution. - -Libpng was written as a companion to the PNG specification, as a way -of reducing the amount of time and effort it takes to support the PNG -file format in application programs. - -The PNG specification (second edition), November 2003, is available as -a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at -. It is technically equivalent -to the PNG specification (second edition) but has some additional material. - -The PNG-1.0 specification is available -as RFC 2083 and as a -W3C Recommendation . - -Some additional chunks are described in the special-purpose public chunks -documents at . - -Other information -about PNG, and the latest version of libpng, can be found at the PNG home -page, . - -Most users will not have to modify the library significantly; advanced -users may want to modify it more. All attempts were made to make it as -complete as possible, while keeping the code easy to understand. -Currently, this library only supports C. Support for other languages -is being considered. - -Libpng has been designed to handle multiple sessions at one time, -to be easily modifiable, to be portable to the vast majority of -machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy -to use. The ultimate goal of libpng is to promote the acceptance of -the PNG file format in whatever way possible. While there is still -work to be done (see the TODO file), libpng should cover the -majority of the needs of its users. - -Libpng uses zlib for its compression and decompression of PNG files. -Further information about zlib, and the latest version of zlib, can -be found at the zlib home page, . -The zlib compression utility is a general purpose utility that is -useful for more than PNG files, and can be used without libpng. -See the documentation delivered with zlib for more details. -You can usually find the source files for the zlib utility wherever you -find the libpng source files. - -Libpng is thread safe, provided the threads are using different -instances of the structures. Each thread should have its own -png_struct and png_info instances, and thus its own image. -Libpng does not protect itself against two threads using the -same instance of a structure. - -II. Structures - -There are two main structures that are important to libpng, png_struct -and png_info. The first, png_struct, is an internal structure that -will not, for the most part, be used by a user except as the first -variable passed to every libpng function call. - -The png_info structure is designed to provide information about the -PNG file. At one time, the fields of png_info were intended to be -directly accessible to the user. However, this tended to cause problems -with applications using dynamically loaded libraries, and as a result -a set of interface functions for png_info (the png_get_*() and png_set_*() -functions) was developed. The fields of png_info are still available for -older applications, but it is suggested that applications use the new -interfaces if at all possible. - -Applications that do make direct access to the members of png_struct (except -for png_ptr->jmpbuf) must be recompiled whenever the library is updated, -and applications that make direct access to the members of png_info must -be recompiled if they were compiled or loaded with libpng version 1.0.6, -in which the members were in a different order. In version 1.0.7, the -members of the png_info structure reverted to the old order, as they were -in versions 0.97c through 1.0.5. Starting with version 2.0.0, both -structures are going to be hidden, and the contents of the structures will -only be accessible through the png_get/png_set functions. - -The png.h header file is an invaluable reference for programming with libpng. -And while I'm on the topic, make sure you include the libpng header file: - -#include - -III. Reading - -We'll now walk you through the possible functions to call when reading -in a PNG file sequentially, briefly explaining the syntax and purpose -of each one. See example.c and png.h for more detail. While -progressive reading is covered in the next section, you will still -need some of the functions discussed in this section to read a PNG -file. - -Setup - -You will want to do the I/O initialization(*) before you get into libpng, -so if it doesn't work, you don't have much to undo. Of course, you -will also want to insure that you are, in fact, dealing with a PNG -file. Libpng provides a simple check to see if a file is a PNG file. -To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 if the bytes match the corresponding -bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes -you pass in, the greater the accuracy of the prediction. - -If you are intending to keep the file pointer open for use in libpng, -you must ensure you don't read more than 8 bytes from the beginning -of the file, and you also have to make a call to png_set_sig_bytes_read() -with the number of bytes you read from the beginning. Libpng will -then only check the bytes (if any) that your program didn't read. - -(*): If you are not using the standard I/O functions, you will need -to replace them with custom functions. See the discussion under -Customizing libpng. - - - FILE *fp = fopen(file_name, "rb"); - if (!fp) - { - return (ERROR); - } - fread(header, 1, number, fp); - is_png = !png_sig_cmp(header, 0, number); - if (!is_png) - { - return (NOT_PNG); - } - - -Next, png_struct and png_info need to be allocated and initialized. In -order to ensure that the size of these structures is correct even with a -dynamically linked libpng, there are functions to initialize and -allocate the structures. We also pass the library version, optional -pointers to error handling functions, and a pointer to a data struct for -use by the error functions, if necessary (the pointer and functions can -be NULL if the default error handlers are to be used). See the section -on Changes to Libpng below regarding the old initialization functions. -The structure allocation functions quietly return NULL if they fail to -create the structure, so your application should check for that. - - png_structp png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, - (png_infopp)NULL, (png_infopp)NULL); - return (ERROR); - } - - png_infop end_info = png_create_info_struct(png_ptr); - if (!end_info) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_read_struct_2() instead of png_create_read_struct(): - - png_structp png_ptr = png_create_read_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -The error handling routines passed to png_create_read_struct() -and the memory alloc/free routines passed to png_create_struct_2() -are only necessary if you are not using the libpng supplied error -handling and memory alloc/free functions. - -When libpng encounters an error, it expects to longjmp back -to your routine. Therefore, you will need to call setjmp and pass -your png_jmpbuf(png_ptr). If you read the file from different -routines, you will need to update the jmpbuf field every time you enter -a new routine that will call a png_*() function. - -See your documentation of setjmp/longjmp for your compiler for more -information on setjmp/longjmp. See the discussion on libpng error -handling in the Customizing Libpng section below for more information -on the libpng error handling. If an error occurs, and libpng longjmp's -back to your setjmp, you will want to call png_destroy_read_struct() to -free any memory. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - fclose(fp); - return (ERROR); - } - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the input code. The default for libpng is to -use the C function fread(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. If you wish to handle reading data in another -way, you need not call the png_init_io() function, but you must then -implement the libpng I/O methods discussed in the Customizing Libpng -section below. - - png_init_io(png_ptr, fp); - -If you had previously opened the file and read any of the signature from -the beginning in order to see if this was a PNG file, you need to let -libpng know that there are some bytes missing from the start of the file. - - png_set_sig_bytes(png_ptr, number); - -Setting up callback code - -You can set up a callback function to handle any unknown chunks in the -input stream. You must supply the function - - read_chunk_callback(png_ptr ptr, - png_unknown_chunkp chunk); - { - /* The unknown chunk structure contains your - chunk data, along with similar data for any other - unknown chunks: */ - - png_byte name[5]; - png_byte *data; - png_size_t size; - - /* Note that libpng has already taken care of - the CRC handling */ - - /* put your code here. Search for your chunk in the - unknown chunk structure, process it, and return one - of the following: */ - - return (-n); /* chunk had an error */ - return (0); /* did not recognize */ - return (n); /* success */ - } - -(You can give your function another name that you like instead of -"read_chunk_callback") - -To inform libpng about your function, use - - png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, - read_chunk_callback); - -This names not only the callback function, but also a user pointer that -you can retrieve with - - png_get_user_chunk_ptr(png_ptr); - -If you call the png_set_read_user_chunk_fn() function, then all unknown -chunks will be saved when read, in case your callback function will need -one or more of them. This behavior can be changed with the -png_set_keep_unknown_chunks() function, described below. - -At this point, you can set up a callback function that will be -called after each row has been read, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void read_row_callback(png_ptr ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "read_row_callback") - -To inform libpng about your function, use - - png_set_read_status_fn(png_ptr, read_row_callback); - -Width and height limits - -The PNG specification allows the width and height of an image to be as -large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. -Since very few applications really need to process such large images, -we have imposed an arbitrary 1-million limit on rows and columns. -Larger images will be rejected immediately with a png_error() call. If -you wish to override this limit, you can use - - png_set_user_limits(png_ptr, width_max, height_max); - -to set your own limits, or use width_max = height_max = 0x7fffffffL -to allow all valid dimensions (libpng may reject some very large images -anyway because of potential buffer overflow conditions). - -You should put this statement after you create the PNG structure and -before calling png_read_info(), png_read_png(), or png_process_data(). -If you need to retrieve the limits that are being applied, use - - width_max = png_get_user_width_max(png_ptr); - height_max = png_get_user_height_max(png_ptr); - -Unknown-chunk handling - -Now you get to set the way the library processes unknown chunks in the -input PNG stream. Both known and unknown chunks will be read. Normal -behavior is that known chunks will be parsed into information in -various info_ptr members while unknown chunks will be discarded. To change -this, you can call: - - png_set_keep_unknown_chunks(png_ptr, keep, - chunk_list, num_chunks); - keep - 0: default unknown chunk handling - 1: ignore; do not keep - 2: keep only if safe-to-copy - 3: keep even if unsafe-to-copy - You can use these definitions: - PNG_HANDLE_CHUNK_AS_DEFAULT 0 - PNG_HANDLE_CHUNK_NEVER 1 - PNG_HANDLE_CHUNK_IF_SAFE 2 - PNG_HANDLE_CHUNK_ALWAYS 3 - chunk_list - list of chunks affected (a byte string, - five bytes per chunk, NULL or '\0' if - num_chunks is 0) - num_chunks - number of chunks affected; if 0, all - unknown chunks are affected. If nonzero, - only the chunks in the list are affected - -Unknown chunks declared in this way will be saved as raw data onto a -list of png_unknown_chunk structures. If a chunk that is normally -known to libpng is named in the list, it will be handled as unknown, -according to the "keep" directive. If a chunk is named in successive -instances of png_set_keep_unknown_chunks(), the final instance will -take precedence. The IHDR and IEND chunks should not be named in -chunk_list; if they are, libpng will process them normally anyway. - -Here is an example of the usage of png_set_keep_unknown_chunks(), -where the private "vpAg" chunk will later be processed by a user chunk -callback function: - - png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'}; - - #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - png_byte unused_chunks[]= - { - 104, 73, 83, 84, (png_byte) '\0', /* hIST */ - 105, 84, 88, 116, (png_byte) '\0', /* iTXt */ - 112, 67, 65, 76, (png_byte) '\0', /* pCAL */ - 115, 67, 65, 76, (png_byte) '\0', /* sCAL */ - 115, 80, 76, 84, (png_byte) '\0', /* sPLT */ - 116, 73, 77, 69, (png_byte) '\0', /* tIME */ - }; - #endif - - ... - - #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* ignore all unknown chunks: */ - png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); - /* except for vpAg: */ - png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); - /* also ignore unused known chunks: */ - png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, - (int)sizeof(unused_chunks)/5); - #endif - - -The high-level read interface - -At this point there are two ways to proceed; through the high-level -read interface, or through a sequence of low-level read operations. -You can use the high-level interface if (a) you are willing to read -the entire image into memory, and (b) the input transformations -you want to do are limited to the following set: - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to - 8 bits - PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel - PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit - samples to bytes - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_EXPAND Perform set_expand() - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - -(This excludes setting a background color, doing gamma transformation, -dithering, and setting filler.) If this is the case, simply do this: - - png_read_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of -some set of transformation flags. This call is equivalent to png_read_info(), -followed the set of transformations indicated by the transform mask, -then png_read_image(), and finally png_read_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future input transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_read_png(). - -After you have called png_read_png(), you can retrieve the image data -with - - row_pointers = png_get_rows(png_ptr, info_ptr); - -where row_pointers is an array of pointers to the pixel data for each row: - - png_bytep row_pointers[height]; - -If you know your image size and pixel size ahead of time, you can allocate -row_pointers prior to calling png_read_png() with - - if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) - png_error (png_ptr, - "Image is too tall to process in memory"); - if (width > PNG_UINT_32_MAX/pixel_size) - png_error (png_ptr, - "Image is too wide to process in memory"); - row_pointers = png_malloc(png_ptr, - height*png_sizeof(png_bytep)); - for (int i=0; i) and -png_get_(png_ptr, info_ptr, ...) functions return non-zero if the -data has been read, or zero if it is missing. The parameters to the -png_get_ are set directly if they are simple data types, or a pointer -into the info_ptr is returned for any complex types. - - png_get_PLTE(png_ptr, info_ptr, &palette, - &num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_get_gAMA(png_ptr, info_ptr, &gamma); - gamma - the gamma the file is written - at (PNG_INFO_gAMA) - - png_get_sRGB(png_ptr, info_ptr, &srgb_intent); - srgb_intent - the rendering intent (PNG_INFO_sRGB) - The presence of the sRGB chunk - means that the pixel data is in the - sRGB color space. This chunk also - implies specific values of gAMA and - cHRM. - - png_get_iCCP(png_ptr, info_ptr, &name, - &compression_type, &profile, &proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_get_sBIT(png_ptr, info_ptr, &sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, - red, green, and blue channels, - whichever are appropriate for the - given color type (png_color_16) - - png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, - &trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_get_hIST(png_ptr, info_ptr, &hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_get_tIME(png_ptr, info_ptr, &mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_get_bKGD(png_ptr, info_ptr, &background); - background - background color (PNG_VALID_bKGD) - valid 16-bit red, green and blue - values, regardless of color_type - - num_comments = png_get_text(png_ptr, info_ptr, - &text_ptr, &num_text); - num_comments - number of comments - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (empty - string for unknown). - text_ptr[i].lang_key - keyword in UTF-8 - (empty string for unknown). - num_text - number of comments (same as - num_comments; you can put NULL here - to avoid the duplication) - Note while png_set_text() will accept text, language, - and translated keywords that can be NULL pointers, the - structure returned by png_get_text will always contain - regular zero-terminated C strings. They might be - empty strings but they will never be NULL pointers. - - num_spalettes = png_get_sPLT(png_ptr, info_ptr, - &palette_ptr); - palette_ptr - array of palette structures holding - contents of one or more sPLT chunks - read. - num_spalettes - number of sPLT chunks read. - - png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, - &unit_type); - offset_x - positive offset from the left edge - of the screen - offset_y - positive offset from the top edge - of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, - &unit_type); - res_x - pixels/unit physical resolution in - x direction - res_y - pixels/unit physical resolution in - x direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_get_sCAL(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, - &height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - num_unknown_chunks = png_get_unknown_chunks(png_ptr, - info_ptr, &unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position of chunk in file - - The value of "i" corresponds to the order in which the - chunks were read from the PNG file or inserted with the - png_set_unknown_chunks() function. - -The data from the pHYs chunk can be retrieved in several convenient -forms: - - res_x = png_get_x_pixels_per_meter(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_meter(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_meter(png_ptr, - info_ptr) - res_x = png_get_x_pixels_per_inch(png_ptr, - info_ptr) - res_y = png_get_y_pixels_per_inch(png_ptr, - info_ptr) - res_x_and_y = png_get_pixels_per_inch(png_ptr, - info_ptr) - aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, - info_ptr) - - (Each of these returns 0 [signifying "unknown"] if - the data is not present or if res_x is 0; - res_x_and_y is 0 if res_x != res_y) - -The data from the oFFs chunk can be retrieved in several convenient -forms: - - x_offset = png_get_x_offset_microns(png_ptr, info_ptr); - y_offset = png_get_y_offset_microns(png_ptr, info_ptr); - x_offset = png_get_x_offset_inches(png_ptr, info_ptr); - y_offset = png_get_y_offset_inches(png_ptr, info_ptr); - - (Each of these returns 0 [signifying "unknown" if both - x and y are 0] if the data is not present or if the - chunk is present but the unit is the pixel) - -For more information, see the png_info definition in png.h and the -PNG specification for chunk contents. Be careful with trusting -rowbytes, as some of the transformations could increase the space -needed to hold a row (expand, filler, gray_to_rgb, etc.). -See png_read_update_info(), below. - -A quick word about text_ptr and num_text. PNG stores comments in -keyword/text pairs, one pair per chunk, with no limit on the number -of text chunks, and a 2^31 byte limit on their size. While there are -suggested keywords, there is no requirement to restrict the use to these -strings. It is strongly suggested that keywords and text be sensible -to humans (that's the point), so don't use abbreviations. Non-printing -symbols are not allowed. See the PNG specification for more details. -There is also no requirement to have text after the keyword. - -Keywords should be limited to 79 Latin-1 characters without leading or -trailing spaces, but non-consecutive spaces are allowed within the -keyword. It is possible to have the same keyword any number of times. -The text_ptr is an array of png_text structures, each holding a -pointer to a language string, a pointer to a keyword and a pointer to -a text string. The text string, language code, and translated -keyword may be empty or NULL pointers. The keyword/text -pairs are put into the array in the order that they are received. -However, some or all of the text chunks may be after the image, so, to -make sure you have read all the text chunks, don't mess with these -until after you read the stuff after the image. This will be -mentioned again below in the discussion that goes with png_read_end(). - -Input transformations - -After you've read the header information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -The colors used for the background and transparency values should be -supplied in the same format/depth as the current image data. They -are stored in the same format/depth as the image data in a bKGD or tRNS -chunk, so this is what libpng expects for this data. The colors are -transformed to keep in sync with the image data when an application -calls the png_read_update_info() routine (see below). - -Data will be decoded into the supplied row buffers packed into bytes -unless the library has been told to transform it into another format. -For example, 4 bit/pixel paletted or grayscale data will be returned -2 pixels/byte with the leftmost pixel in the high-order bits of the -byte, unless png_set_packing() is called. 8-bit RGB data will be stored -in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() -is called to insert filler bytes, either before or after each RGB triplet. -16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant -byte of the color value first, unless png_set_strip_16() is called to -transform it to regular RGB RGB triplets, or png_set_filler() or -png_set_add alpha() is called to insert filler bytes, either before or -after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can -be modified with -png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). - -The following code transforms grayscale images of less than 8 to 8 bits, -changes paletted images to RGB, and adds a full alpha channel if there is -transparency information in a tRNS chunk. This is most useful on -grayscale images with bit depths of 2 or 4 or if there is a multiple-image -viewing application that wishes to treat all images in the same way. - - if (color_type == PNG_COLOR_TYPE_PALETTE) - png_set_palette_to_rgb(png_ptr); - - if (color_type == PNG_COLOR_TYPE_GRAY && - bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); - - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); - -These three functions are actually aliases for png_set_expand(), added -in libpng version 1.0.4, with the function names expanded to improve code -readability. In some future version they may actually do different -things. - -As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was -added. It expands the sample depth without changing tRNS to alpha. -At the same time, png_set_gray_1_2_4_to_8() was deprecated, and it -will be removed from a future version. - - -PNG can have files with 16 bits per channel. If you only can handle -8 bits per channel, this will strip the pixels down to 8 bit. - - if (bit_depth == 16) - png_set_strip_16(png_ptr); - -If, for some reason, you don't need the alpha channel on an image, -and you want to remove it rather than combining it with the background -(but the image author certainly had in mind that you *would* combine -it with the background, so that's what you should probably do): - - if (color_type & PNG_COLOR_MASK_ALPHA) - png_set_strip_alpha(png_ptr); - -In PNG files, the alpha channel in an image -is the level of opacity. If you need the alpha channel in an image to -be the level of transparency instead of opacity, you can invert the -alpha channel (or the tRNS chunk data) after it's read, so that 0 is -fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit -images) is fully transparent, with - - png_set_invert_alpha(png_ptr); - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit -files. This code expands to 1 pixel per byte without changing the -values of the pixels: - - if (bit_depth < 8) - png_set_packing(png_ptr); - -PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels -stored in a PNG image have been "scaled" or "shifted" up to the next -higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to -8 bits/sample in the range [0, 255]). However, it is also possible to -convert the PNG pixel data back to the original bit depth of the image. -This call reduces the pixels back down to the original bit depth: - - png_color_8p sig_bit; - - if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) - png_set_shift(png_ptr, sig_bit); - -PNG files store 3-color pixels in red, green, blue order. This code -changes the storage of the pixels to blue, green, red: - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_bgr(png_ptr); - -PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them -into 4 or 8 bytes for windowing systems that need them in this format: - - if (color_type == PNG_COLOR_TYPE_RGB) - png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); - -where "filler" is the 8 or 16-bit number to fill with, and the location is -either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether -you want the filler before the RGB or after. This transformation -does not affect images that already have full alpha channels. To add an -opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which -will generate RGBA pixels. - -Note that png_set_filler() does not change the color type. If you want -to do that, you can add a true alpha channel with - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_GRAY) - png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); - -where "filler" contains the alpha value to assign to each pixel. -This function was added in libpng-1.2.7. - -If you are reading an image with an alpha channel, and you need the -data as ARGB instead of the normal PNG format RGBA: - - if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_swap_alpha(png_ptr); - -For some uses, you may want a grayscale image to be represented as -RGB. This code will do that conversion: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_gray_to_rgb(png_ptr); - -Conversely, you can convert an RGB or RGBA image to grayscale or grayscale -with alpha. - - if (color_type == PNG_COLOR_TYPE_RGB || - color_type == PNG_COLOR_TYPE_RGB_ALPHA) - png_set_rgb_to_gray_fixed(png_ptr, error_action, - int red_weight, int green_weight); - - error_action = 1: silently do the conversion - error_action = 2: issue a warning if the original - image has any pixel where - red != green or red != blue - error_action = 3: issue an error and abort the - conversion if the original - image has any pixel where - red != green or red != blue - - red_weight: weight of red component times 100000 - green_weight: weight of green component times 100000 - If either weight is negative, default - weights (21268, 71514) are used. - -If you have set error_action = 1 or 2, you can -later check whether the image really was gray, after processing -the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. -It will return a png_byte that is zero if the image was gray or -1 if there were any non-gray pixels. bKGD and sBIT data -will be silently converted to grayscale, using the green channel -data, regardless of the error_action setting. - -With red_weight+green_weight<=100000, -the normalized graylevel is computed: - - int rw = red_weight * 65536; - int gw = green_weight * 65536; - int bw = 65536 - (rw + gw); - gray = (rw*red + gw*green + bw*blue)/65536; - -The default values approximate those recommended in the Charles -Poynton's Color FAQ, -Copyright (c) 1998-01-04 Charles Poynton - - Y = 0.212671 * R + 0.715160 * G + 0.072169 * B - -Libpng approximates this with - - Y = 0.21268 * R + 0.7151 * G + 0.07217 * B - -which can be expressed with integers as - - Y = (6969 * R + 23434 * G + 2365 * B)/32768 - -The calculation is done in a linear colorspace, if the image gamma -is known. - -If you have a grayscale and you are using png_set_expand_depth(), -png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to -a higher bit-depth, you must either supply the background color as a gray -value at the original file bit-depth (need_expand = 1) or else supply the -background color as an RGB triplet at the final, expanded bit depth -(need_expand = 0). Similarly, if you are reading a paletted image, you -must either supply the background color as a palette index (need_expand = 1) -or as an RGB triplet that may or may not be in the palette (need_expand = 0). - - png_color_16 my_background; - png_color_16p image_background; - - if (png_get_bKGD(png_ptr, info_ptr, &image_background)) - png_set_background(png_ptr, image_background, - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); - else - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); - -The png_set_background() function tells libpng to composite images -with alpha or simple transparency against the supplied background -color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), -you may use this color, or supply another color more suitable for -the current display (e.g., the background color from a web page). You -need to tell libpng whether the color is in the gamma space of the -display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file -(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one -that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't -know why anyone would use this, but it's here). - -To properly display PNG images on any kind of system, the application needs -to know what the display gamma is. Ideally, the user will know this, and -the application will allow them to set it. One method of allowing the user -to set the display gamma separately for each system is to check for a -SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be -correctly set. - -Note that display_gamma is the overall gamma correction required to produce -pleasing results, which depends on the lighting conditions in the surrounding -environment. In a dim or brightly lit room, no compensation other than -the physical gamma exponent of the monitor is needed, while in a dark room -a slightly smaller exponent is better. - - double gamma, screen_gamma; - - if (/* We have a user-defined screen - gamma value */) - { - screen_gamma = user_defined_screen_gamma; - } - /* One way that applications can share the same - screen gamma value */ - else if ((gamma_str = getenv("SCREEN_GAMMA")) - != NULL) - { - screen_gamma = (double)atof(gamma_str); - } - /* If we don't have another value */ - else - { - screen_gamma = 2.2; /* A good guess for a - PC monitor in a bright office or a dim room */ - screen_gamma = 2.0; /* A good guess for a - PC monitor in a dark room */ - screen_gamma = 1.7 or 1.0; /* A good - guess for Mac systems */ - } - -The png_set_gamma() function handles gamma transformations of the data. -Pass both the file gamma and the current screen_gamma. If the file does -not have a gamma value, you can pass one anyway if you have an idea what -it is (usually 0.45455 is a good guess for GIF images on PCs). Note -that file gammas are inverted from screen gammas. See the discussions -on gamma in the PNG specification for an excellent description of what -gamma is, and why all applications should support it. It is strongly -recommended that PNG viewers support gamma correction. - - if (png_get_gAMA(png_ptr, info_ptr, &gamma)) - png_set_gamma(png_ptr, screen_gamma, gamma); - else - png_set_gamma(png_ptr, screen_gamma, 0.45455); - -If you need to reduce an RGB file to a paletted file, or if a paletted -file has more entries then will fit on your screen, png_set_dither() -will do that. Note that this is a simple match dither that merely -finds the closest color available. This should work fairly well with -optimized palettes, and fairly badly with linear color cubes. If you -pass a palette that is larger then maximum_colors, the file will -reduce the number of colors in the palette so it will fit into -maximum_colors. If there is a histogram, it will use it to make -more intelligent choices when reducing the palette. If there is no -histogram, it may not do as good a job. - - if (color_type & PNG_COLOR_MASK_COLOR) - { - if (png_get_valid(png_ptr, info_ptr, - PNG_INFO_PLTE)) - { - png_uint_16p histogram = NULL; - - png_get_hIST(png_ptr, info_ptr, - &histogram); - png_set_dither(png_ptr, palette, num_palette, - max_screen_colors, histogram, 1); - } - else - { - png_color std_color_cube[MAX_SCREEN_COLORS] = - { ... colors ... }; - - png_set_dither(png_ptr, std_color_cube, - MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, - NULL,0); - } - } - -PNG files describe monochrome as black being zero and white being one. -The following code will reverse this (make black be one and white be -zero): - - if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) - png_set_invert_mono(png_ptr); - -This function can also be used to invert grayscale and gray-alpha images: - - if (color_type == PNG_COLOR_TYPE_GRAY || - color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - png_set_invert_mono(png_ptr); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code changes the storage to the -other way (little-endian, i.e. least significant bits first, the -way PCs store them): - - if (bit_depth == 16) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_read_user_transform_fn(png_ptr, - read_transform_fn); - -You must supply the function - - void read_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -after all of the other transformations have been processed. - -You can also set up a pointer to a user structure for use by your -callback function, and you can inform libpng that your transform -function will change the number of channels or bit depth with the -function - - png_set_user_transform_info(png_ptr, user_ptr, - user_depth, user_channels); - -The user's application, not libpng, is responsible for allocating and -freeing any memory required for the user structure. - -You can retrieve the pointer via the function -png_get_user_transform_ptr(). For example: - - voidp read_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -The last thing to handle is interlacing; this is covered in detail below, -but you must call the function here if you want libpng to handle expansion -of the interlaced image. - - number_of_passes = png_set_interlace_handling(png_ptr); - -After setting the transformations, libpng can update your png_info -structure to reflect any transformations you've requested with this -call. This is most useful to update the info structure's rowbytes -field so you can use it to allocate your image memory. This function -will also update your palette with the correct screen_gamma and -background if these have been given with the calls above. - - png_read_update_info(png_ptr, info_ptr); - -After you call png_read_update_info(), you can allocate any -memory you need to hold the image. The row data is simply -raw byte data for all forms of images. As the actual allocation -varies among applications, no example will be given. If you -are allocating one large chunk, you will need to build an -array of pointers to each row, as it will be needed for some -of the functions below. - -Reading image data - -After you've allocated memory, you can read the image data. -The simplest way to do this is in one function call. If you are -allocating enough memory to hold the whole image, you can just -call png_read_image() and libpng will read in all the image data -and put it in the memory area supplied. You will need to pass in -an array of pointers to each row. - -This function automatically handles interlacing, so you don't need -to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_read_rows(). - - png_read_image(png_ptr, row_pointers); - -where row_pointers is: - - png_bytep row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to read in the whole image at once, you can -use png_read_rows() instead. If there is no interlacing (check -interlace_type == PNG_INTERLACE_NONE), this is simple: - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -where row_pointers is the same as in the png_read_image() call. - -If you are doing this just one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - png_read_row(png_ptr, row_pointer, NULL); - -If the file is interlaced (interlace_type != 0 in the IHDR chunk), things -get somewhat harder. The only current (PNG Specification version 1.2) -interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) -is a somewhat complicated 2D interlace scheme, known as Adam7, that -breaks down an image into seven smaller images of varying size, based -on an 8x8 grid. - -libpng can fill out those images or it can give them to you "as is". -If you want them filled out, there are two ways to do that. The one -mentioned in the PNG specification is to expand each pixel to cover -those pixels that have not been read yet (the "rectangle" method). -This results in a blocky image for the first pass, which gradually -smooths out as more pixels are read. The other method is the "sparkle" -method, where pixels are drawn only in their final locations, with the -rest of the image remaining whatever colors they were initialized to -before the start of the read. The first method usually looks better, -but tends to be slower, as there are more pixels to put in the rows. - -If you don't want libpng to handle the interlacing details, just call -png_read_rows() seven times to read in all seven images. Each of the -images is a valid image by itself, or they can all be combined on an -8x8 grid to form a single image (although if you intend to combine them -you would be far better off using the libpng interlace handling). - -The first pass will return an image 1/8 as wide as the entire image -(every 8th column starting in column 0) and 1/8 as high as the original -(every 8th row starting in row 0), the second will be 1/8 as wide -(starting in column 4) and 1/8 as high (also starting in row 0). The -third pass will be 1/4 as wide (every 4th pixel starting in column 0) and -1/8 as high (every 8th row starting in row 4), and the fourth pass will -be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, -and every 4th row starting in row 0). The fifth pass will return an -image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), -while the sixth pass will be 1/2 as wide and 1/2 as high as the original -(starting in column 1 and row 0). The seventh and final pass will be as -wide as the original, and 1/2 as high, containing all of the odd -numbered scanlines. Phew! - -If you want libpng to expand the images, call this before calling -png_start_read_image() or png_read_update_info(): - - if (interlace_type == PNG_INTERLACE_ADAM7) - number_of_passes - = png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. -This function can be called even if the file is not interlaced, -where it will return one pass. - -If you are not going to display the image after each pass, but are -going to wait until the entire image is read in, use the sparkle -effect. This effect is faster and the end result of either method -is exactly the same. If you are planning on displaying the image -after each pass, the "rectangle" effect is generally considered the -better looking one. - -If you only want the "sparkle" effect, just call png_read_rows() as -normal, with the third parameter NULL. Make sure you make pass over -the image number_of_passes times, and you don't change the data in the -rows between calls. You can change the locations of the data, just -not the data. Each pass only writes the pixels appropriate for that -pass, and assumes the data from previous passes is still valid. - - png_read_rows(png_ptr, row_pointers, NULL, - number_of_rows); - -If you only want the first effect (the rectangles), do the same as -before except pass the row buffer in the third parameter, and leave -the second parameter NULL. - - png_read_rows(png_ptr, NULL, row_pointers, - number_of_rows); - -Finishing a sequential read - -After you are finished reading the image through the -low-level interface, you can finish reading the file. If you are -interested in comments or time, which may be stored either before or -after the image data, you should pass the separate png_info struct if -you want to keep the comments from before and after the image -separate. If you are not interested, you can pass NULL. - - png_read_end(png_ptr, end_info); - -When you are done, you can free all memory allocated by libpng like this: - - png_destroy_read_struct(&png_ptr, &info_ptr, - &end_info); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -This function only affects data that has already been allocated. -You can call this function after reading the PNG data but before calling -any png_set_*() functions, to control whether the user or the png_set_*() -function is responsible for freeing any existing data that might be present, -and again after the png_set_*() functions to control whether the user -or png_destroy_*() is supposed to free the data. When the user assumes -responsibility for libpng-allocated data, the application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated your row_pointers in a single block, as suggested above in -the description of the high level read interface, you must not transfer -responsibility for freeing it to the png_set_rows or png_read_destroy function, -because they would also try to free the individual row_pointers[i]. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. - -The png_free_data() function will turn off the "valid" flag for anything -it frees. If you need to turn the flag off for a chunk that was freed by your -application instead of by libpng, you can use - - png_set_invalid(png_ptr, info_ptr, mask); - mask - identifies the chunks to be made invalid, - containing the bitwise OR of one or - more of - PNG_INFO_gAMA, PNG_INFO_sBIT, - PNG_INFO_cHRM, PNG_INFO_PLTE, - PNG_INFO_tRNS, PNG_INFO_bKGD, - PNG_INFO_hIST, PNG_INFO_pHYs, - PNG_INFO_oFFs, PNG_INFO_tIME, - PNG_INFO_pCAL, PNG_INFO_sRGB, - PNG_INFO_iCCP, PNG_INFO_sPLT, - PNG_INFO_sCAL, PNG_INFO_IDAT - -For a more compact example of reading a PNG image, see the file example.c. - -Reading PNG files progressively - -The progressive reader is slightly different then the non-progressive -reader. Instead of calling png_read_info(), png_read_rows(), and -png_read_end(), you make one call to png_process_data(), which calls -callbacks when it has the info, a row, or the end of the image. You -set up these callbacks with png_set_progressive_read_fn(). You don't -have to worry about the input/output functions of libpng, as you are -giving the library the data directly in png_process_data(). I will -assume that you have read the section on reading PNG files above, -so I will only highlight the differences (although I will show -all of the code). - -png_structp png_ptr; -png_infop info_ptr; - - /* An example code fragment of how you would - initialize the progressive reader in your - application. */ - int - initialize_png_reader() - { - png_ptr = png_create_read_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_read_struct(&png_ptr, (png_infopp)NULL, - (png_infopp)NULL); - return (ERROR); - } - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new. You can provide functions - to be called when the header info is valid, - when each row is completed, and when the image - is finished. If you aren't using all functions, - you can specify NULL parameters. Even when all - three functions are NULL, you need to call - png_set_progressive_read_fn(). You can use - any struct as the user_ptr (cast to a void pointer - for the function call), and retrieve the pointer - from inside the callbacks using the function - - png_get_progressive_ptr(png_ptr); - - which will return a void pointer, which you have - to cast appropriately. - */ - png_set_progressive_read_fn(png_ptr, (void *)user_ptr, - info_callback, row_callback, end_callback); - - return 0; - } - - /* A code fragment that you call as you receive blocks - of data */ - int - process_data(png_bytep buffer, png_uint_32 length) - { - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_read_struct(&png_ptr, &info_ptr, - (png_infopp)NULL); - return (ERROR); - } - - /* This one's new also. Simply give it a chunk - of data from the file stream (in order, of - course). On machines with segmented memory - models machines, don't give it any more than - 64K. The library seems to run fine with sizes - of 4K. Although you can give it much less if - necessary (I assume you can give it chunks of - 1 byte, I haven't tried less then 256 bytes - yet). When this function returns, you may - want to display any rows that were generated - in the row callback if you don't already do - so there. - */ - png_process_data(png_ptr, info_ptr, buffer, length); - return 0; - } - - /* This function is called (as set by - png_set_progressive_read_fn() above) when enough data - has been supplied so all of the header has been - read. - */ - void - info_callback(png_structp png_ptr, png_infop info) - { - /* Do any setup here, including setting any of - the transformations mentioned in the Reading - PNG files section. For now, you _must_ call - either png_start_read_image() or - png_read_update_info() after all the - transformations are set (even if you don't set - any). You may start getting rows before - png_process_data() returns, so this is your - last chance to prepare for that. - */ - } - - /* This function is called when each row of image - data is complete */ - void - row_callback(png_structp png_ptr, png_bytep new_row, - png_uint_32 row_num, int pass) - { - /* If the image is interlaced, and you turned - on the interlace handler, this function will - be called for every row in every pass. Some - of these rows will not be changed from the - previous pass. When the row is not changed, - the new_row variable will be NULL. The rows - and passes are called in order, so you don't - really need the row_num and pass, but I'm - supplying them because it may make your life - easier. - - For the non-NULL rows of interlaced images, - you must call png_progressive_combine_row() - passing in the row and the old row. You can - call this function for NULL rows (it will just - return) and for non-interlaced images (it just - does the memcpy for you) if it will make the - code easier. Thus, you can just do this for - all cases: - */ - - png_progressive_combine_row(png_ptr, old_row, - new_row); - - /* where old_row is what was displayed for - previously for the row. Note that the first - pass (pass == 0, really) will completely cover - the old row, so the rows do not have to be - initialized. After the first pass (and only - for interlaced images), you will have to pass - the current row, and the function will combine - the old row and the new row. - */ - } - - void - end_callback(png_structp png_ptr, png_infop info) - { - /* This function is called after the whole image - has been read, including any chunks after the - image (up to and including the IEND). You - will usually have the same info chunk as you - had in the header, although some data may have - been added to the comments and time fields. - - Most people won't do much here, perhaps setting - a flag that marks the image as finished. - */ - } - - - -IV. Writing - -Much of this is very similar to reading. However, everything of -importance is repeated here, so you won't have to constantly look -back up in the reading section to understand writing. - -Setup - -You will want to do the I/O initialization before you get into libpng, -so if it doesn't work, you don't have anything to undo. If you are not -using the standard I/O functions, you will need to replace them with -custom writing functions. See the discussion under Customizing libpng. - - FILE *fp = fopen(file_name, "wb"); - if (!fp) - { - return (ERROR); - } - -Next, png_struct and png_info need to be allocated and initialized. -As these can be both relatively large, you may not want to store these -on the stack, unless you have stack space to spare. Of course, you -will want to check if they return NULL. If you are also reading, -you won't want to name your read structure and your write structure -both "png_ptr"; you can call them anything you like, such as -"read_ptr" and "write_ptr". Look at pngtest.c, for example. - - png_structp png_ptr = png_create_write_struct - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn); - if (!png_ptr) - return (ERROR); - - png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { - png_destroy_write_struct(&png_ptr, - (png_infopp)NULL); - return (ERROR); - } - -If you want to use your own memory allocation routines, -define PNG_USER_MEM_SUPPORTED and use -png_create_write_struct_2() instead of png_create_write_struct(): - - png_structp png_ptr = png_create_write_struct_2 - (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, - user_error_fn, user_warning_fn, (png_voidp) - user_mem_ptr, user_malloc_fn, user_free_fn); - -After you have these structures, you will need to set up the -error handling. When libpng encounters an error, it expects to -longjmp() back to your routine. Therefore, you will need to call -setjmp() and pass the png_jmpbuf(png_ptr). If you -write the file from different routines, you will need to update -the png_jmpbuf(png_ptr) every time you enter a new routine that will -call a png_*() function. See your documentation of setjmp/longjmp -for your compiler for more information on setjmp/longjmp. See -the discussion on libpng error handling in the Customizing Libpng -section below for more information on the libpng error handling. - - if (setjmp(png_jmpbuf(png_ptr))) - { - png_destroy_write_struct(&png_ptr, &info_ptr); - fclose(fp); - return (ERROR); - } - ... - return; - -If you would rather avoid the complexity of setjmp/longjmp issues, -you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case -errors will result in a call to PNG_ABORT() which defaults to abort(). - -Now you need to set up the output code. The default for libpng is to -use the C function fwrite(). If you use this, you will need to pass a -valid FILE * in the function png_init_io(). Be sure that the file is -opened in binary mode. Again, if you wish to handle writing data in -another way, see the discussion on libpng I/O handling in the Customizing -Libpng section below. - - png_init_io(png_ptr, fp); - -If you are embedding your PNG into a datastream such as MNG, and don't -want libpng to write the 8-byte signature, or if you have already -written the signature in your application, use - - png_set_sig_bytes(png_ptr, 8); - -to inform libpng that it should not write a signature. - -Write callbacks - -At this point, you can set up a callback function that will be -called after each row has been written, which you can use to control -a progress meter or the like. It's demonstrated in pngtest.c. -You must supply a function - - void write_row_callback(png_ptr, png_uint_32 row, - int pass); - { - /* put your code here */ - } - -(You can give it another name that you like instead of "write_row_callback") - -To inform libpng about your function, use - - png_set_write_status_fn(png_ptr, write_row_callback); - -You now have the option of modifying how the compression library will -run. The following functions are mainly for testing, but may be useful -in some cases, like if you need to write PNG files extremely fast and -are willing to give up some compression, or if you want to get the -maximum possible compression at the expense of slower writing. If you -have no special needs in this area, let the library do what it wants by -not calling this function at all, as it has been tuned to deliver a good -speed/compression ratio. The second parameter to png_set_filter() is -the filter method, for which the only valid values are 0 (as of the -July 1999 PNG specification, version 1.2) or 64 (if you are writing -a PNG datastream that is to be embedded in a MNG datastream). The third -parameter is a flag that indicates which filter type(s) are to be tested -for each scanline. See the PNG specification for details on the specific filter -types. - - - /* turn on or off filtering, and/or choose - specific filters. You can use either a single - PNG_FILTER_VALUE_NAME or the bitwise OR of one - or more PNG_FILTER_NAME masks. */ - png_set_filter(png_ptr, 0, - PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | - PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | - PNG_FILTER_UP | PNG_FILTER_VALUE_UP | - PNG_FILTER_AVE | PNG_FILTER_VALUE_AVE | - PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| - PNG_ALL_FILTERS); - -If an application -wants to start and stop using particular filters during compression, -it should start out with all of the filters (to ensure that the previous -row of pixels will be stored in case it's needed later), and then add -and remove them after the start of compression. - -If you are writing a PNG datastream that is to be embedded in a MNG -datastream, the second parameter can be either 0 or 64. - -The png_set_compression_*() functions interface to the zlib compression -library, and should mostly be ignored unless you really know what you are -doing. The only generally useful call is png_set_compression_level() -which changes how much time zlib spends on trying to compress the image -data. See the Compression Library (zlib.h and algorithm.txt, distributed -with zlib) for details on the compression levels. - - /* set the zlib compression level */ - png_set_compression_level(png_ptr, - Z_BEST_COMPRESSION); - - /* set other zlib parameters */ - png_set_compression_mem_level(png_ptr, 8); - png_set_compression_strategy(png_ptr, - Z_DEFAULT_STRATEGY); - png_set_compression_window_bits(png_ptr, 15); - png_set_compression_method(png_ptr, 8); - png_set_compression_buffer_size(png_ptr, 8192) - -extern PNG_EXPORT(void,png_set_zbuf_size) - -Setting the contents of info for output - -You now need to fill in the png_info structure with all the data you -wish to write before the actual image. Note that the only thing you -are allowed to write after the image is the text chunks and the time -chunk (as of PNG Specification 1.2, anyway). See png_write_end() and -the latest PNG specification for more information on that. If you -wish to write them before the image, fill them in now, and flag that -data as being valid. If you want to wait until after the data, don't -fill them until png_write_end(). For all the fields in png_info and -their data types, see png.h. For explanations of what the fields -contain, see the PNG specification. - -Some of the more important parts of the png_info are: - - png_set_IHDR(png_ptr, info_ptr, width, height, - bit_depth, color_type, interlace_type, - compression_type, filter_method) - width - holds the width of the image - in pixels (up to 2^31). - height - holds the height of the image - in pixels (up to 2^31). - bit_depth - holds the bit depth of one of the - image channels. - (valid values are 1, 2, 4, 8, 16 - and depend also on the - color_type. See also significant - bits (sBIT) below). - color_type - describes which color/alpha - channels are present. - PNG_COLOR_TYPE_GRAY - (bit depths 1, 2, 4, 8, 16) - PNG_COLOR_TYPE_GRAY_ALPHA - (bit depths 8, 16) - PNG_COLOR_TYPE_PALETTE - (bit depths 1, 2, 4, 8) - PNG_COLOR_TYPE_RGB - (bit_depths 8, 16) - PNG_COLOR_TYPE_RGB_ALPHA - (bit_depths 8, 16) - - PNG_COLOR_MASK_PALETTE - PNG_COLOR_MASK_COLOR - PNG_COLOR_MASK_ALPHA - - interlace_type - PNG_INTERLACE_NONE or - PNG_INTERLACE_ADAM7 - compression_type - (must be - PNG_COMPRESSION_TYPE_DEFAULT) - filter_method - (must be PNG_FILTER_TYPE_DEFAULT - or, if you are writing a PNG to - be embedded in a MNG datastream, - can also be - PNG_INTRAPIXEL_DIFFERENCING) - -If you call png_set_IHDR(), the call must appear before any of the -other png_set_*() functions, which might require access to some of -the IHDR settings. The remaining png_set_*() functions can be called -in any order. - - png_set_PLTE(png_ptr, info_ptr, palette, - num_palette); - palette - the palette for the file - (array of png_color) - num_palette - number of entries in the palette - - png_set_gAMA(png_ptr, info_ptr, gamma); - gamma - the gamma the image was created - at (PNG_INFO_gAMA) - - png_set_sRGB(png_ptr, info_ptr, srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of - the sRGB chunk means that the pixel - data is in the sRGB color space. - This chunk also implies specific - values of gAMA and cHRM. Rendering - intent is the CSS-1 property that - has been defined by the International - Color Consortium - (http://www.color.org). - It can be one of - PNG_sRGB_INTENT_SATURATION, - PNG_sRGB_INTENT_PERCEPTUAL, - PNG_sRGB_INTENT_ABSOLUTE, or - PNG_sRGB_INTENT_RELATIVE. - - - png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, - srgb_intent); - srgb_intent - the rendering intent - (PNG_INFO_sRGB) The presence of the - sRGB chunk means that the pixel - data is in the sRGB color space. - This function also causes gAMA and - cHRM chunks with the specific values - that are consistent with sRGB to be - written. - - png_set_iCCP(png_ptr, info_ptr, name, compression_type, - profile, proflen); - name - The profile name. - compression - The compression type; always - PNG_COMPRESSION_TYPE_BASE for PNG 1.0. - You may give NULL to this argument to - ignore it. - profile - International Color Consortium color - profile data. May contain NULs. - proflen - length of profile data in bytes. - - png_set_sBIT(png_ptr, info_ptr, sig_bit); - sig_bit - the number of significant bits for - (PNG_INFO_sBIT) each of the gray, red, - green, and blue channels, whichever are - appropriate for the given color type - (png_color_16) - - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, - trans_values); - trans - array of transparent entries for - palette (PNG_INFO_tRNS) - trans_values - graylevel or color sample values of - the single transparent color for - non-paletted images (PNG_INFO_tRNS) - num_trans - number of transparent entries - (PNG_INFO_tRNS) - - png_set_hIST(png_ptr, info_ptr, hist); - (PNG_INFO_hIST) - hist - histogram of palette (array of - png_uint_16) - - png_set_tIME(png_ptr, info_ptr, mod_time); - mod_time - time image was last modified - (PNG_VALID_tIME) - - png_set_bKGD(png_ptr, info_ptr, background); - background - background color (PNG_VALID_bKGD) - - png_set_text(png_ptr, info_ptr, text_ptr, num_text); - text_ptr - array of png_text holding image - comments - text_ptr[i].compression - type of compression used - on "text" PNG_TEXT_COMPRESSION_NONE - PNG_TEXT_COMPRESSION_zTXt - PNG_ITXT_COMPRESSION_NONE - PNG_ITXT_COMPRESSION_zTXt - text_ptr[i].key - keyword for comment. Must contain - 1-79 characters. - text_ptr[i].text - text comments for current - keyword. Can be NULL or empty. - text_ptr[i].text_length - length of text string, - after decompression, 0 for iTXt - text_ptr[i].itxt_length - length of itxt string, - after decompression, 0 for tEXt/zTXt - text_ptr[i].lang - language of comment (NULL or - empty for unknown). - text_ptr[i].translated_keyword - keyword in UTF-8 (NULL - or empty for unknown). - num_text - number of comments - - png_set_sPLT(png_ptr, info_ptr, &palette_ptr, - num_spalettes); - palette_ptr - array of png_sPLT_struct structures - to be added to the list of palettes - in the info structure. - num_spalettes - number of palette structures to be - added. - - png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, - unit_type); - offset_x - positive offset from the left - edge of the screen - offset_y - positive offset from the top - edge of the screen - unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER - - png_set_pHYs(png_ptr, info_ptr, res_x, res_y, - unit_type); - res_x - pixels/unit physical resolution - in x direction - res_y - pixels/unit physical resolution - in y direction - unit_type - PNG_RESOLUTION_UNKNOWN, - PNG_RESOLUTION_METER - - png_set_sCAL(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are doubles) - - png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) - unit - physical scale units (an integer) - width - width of a pixel in physical scale units - height - height of a pixel in physical scale units - (width and height are strings like "2.54") - - png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, - num_unknowns) - unknowns - array of png_unknown_chunk - structures holding unknown chunks - unknowns[i].name - name of unknown chunk - unknowns[i].data - data of unknown chunk - unknowns[i].size - size of unknown chunk's data - unknowns[i].location - position to write chunk in file - 0: do not write chunk - PNG_HAVE_IHDR: before PLTE - PNG_HAVE_PLTE: before IDAT - PNG_AFTER_IDAT: after IDAT - -The "location" member is set automatically according to -what part of the output file has already been written. -You can change its value after calling png_set_unknown_chunks() -as demonstrated in pngtest.c. Within each of the "locations", -the chunks are sequenced according to their position in the -structure (that is, the value of "i", which is the order in which -the chunk was either read from the input file or defined with -png_set_unknown_chunks). - -A quick word about text and num_text. text is an array of png_text -structures. num_text is the number of valid structures in the array. -Each png_text structure holds a language code, a keyword, a text value, -and a compression type. - -The compression types have the same valid numbers as the compression -types of the image data. Currently, the only valid number is zero. -However, you can store text either compressed or uncompressed, unlike -images, which always have to be compressed. So if you don't want the -text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. -Because tEXt and zTXt chunks don't have a language field, if you -specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt -any language code or translated keyword will not be written out. - -Until text gets around 1000 bytes, it is not worth compressing it. -After the text has been written out to the file, the compression type -is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, -so that it isn't written out again at the end (in case you are calling -png_write_end() with the same struct. - -The keywords that are given in the PNG Specification are: - - Title Short (one line) title or - caption for image - Author Name of image's creator - Description Description of image (possibly long) - Copyright Copyright notice - Creation Time Time of original image creation - (usually RFC 1123 format, see below) - Software Software used to create the image - Disclaimer Legal disclaimer - Warning Warning of nature of content - Source Device used to create the image - Comment Miscellaneous comment; conversion - from other image format - -The keyword-text pairs work like this. Keywords should be short -simple descriptions of what the comment is about. Some typical -keywords are found in the PNG specification, as is some recommendations -on keywords. You can repeat keywords in a file. You can even write -some text before the image and some after. For example, you may want -to put a description of the image before the image, but leave the -disclaimer until after, so viewers working over modem connections -don't have to wait for the disclaimer to go over the modem before -they start seeing the image. Finally, keywords should be full -words, not abbreviations. Keywords and text are in the ISO 8859-1 -(Latin-1) character set (a superset of regular ASCII) and can not -contain NUL characters, and should not contain control or other -unprintable characters. To make the comments widely readable, stick -with basic ASCII, and avoid machine specific character set extensions -like the IBM-PC character set. The keyword must be present, but -you can leave off the text string on non-compressed pairs. -Compressed pairs must have a text string, as only the text string -is compressed anyway, so the compression would be meaningless. - -PNG supports modification time via the png_time structure. Two -conversion routines are provided, png_convert_from_time_t() for -time_t and png_convert_from_struct_tm() for struct tm. The -time_t routine uses gmtime(). You don't have to use either of -these, but if you wish to fill in the png_time structure directly, -you should provide the time in universal time (GMT) if possible -instead of your local time. Note that the year number is the full -year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and -that months start with 1. - -If you want to store the time of the original image creation, you should -use a plain tEXt chunk with the "Creation Time" keyword. This is -necessary because the "creation time" of a PNG image is somewhat vague, -depending on whether you mean the PNG file, the time the image was -created in a non-PNG format, a still photo from which the image was -scanned, or possibly the subject matter itself. In order to facilitate -machine-readable dates, it is recommended that the "Creation Time" -tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), -although this isn't a requirement. Unlike the tIME chunk, the -"Creation Time" tEXt chunk is not expected to be automatically changed -by the software. To facilitate the use of RFC 1123 dates, a function -png_convert_to_rfc1123(png_timep) is provided to convert from PNG -time to an RFC 1123 format string. - -Writing unknown chunks - -You can use the png_set_unknown_chunks function to queue up chunks -for writing. You give it a chunk name, raw data, and a size; that's -all there is to it. The chunks will be written by the next following -png_write_info_before_PLTE, png_write_info, or png_write_end function. -Any chunks previously read into the info structure's unknown-chunk -list will also be written out in a sequence that satisfies the PNG -specification's ordering rules. - -The high-level write interface - -At this point there are two ways to proceed; through the high-level -write interface, or through a sequence of low-level write operations. -You can use the high-level interface if your image data is present -in the info structure. All defined output -transformations are permitted, enabled by the following masks. - - PNG_TRANSFORM_IDENTITY No transformation - PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples - PNG_TRANSFORM_PACKSWAP Change order of packed - pixels to LSB first - PNG_TRANSFORM_INVERT_MONO Invert monochrome images - PNG_TRANSFORM_SHIFT Normalize pixels to the - sBIT depth - PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA - to BGRA - PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA - to AG - PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity - to transparency - PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples - PNG_TRANSFORM_STRIP_FILLER Strip out filler bytes. - -If you have valid image data in the info structure (you can use -png_set_rows() to put image data in the info structure), simply do this: - - png_write_png(png_ptr, info_ptr, png_transforms, NULL) - -where png_transforms is an integer containing the bitwise OR of some set of -transformation flags. This call is equivalent to png_write_info(), -followed the set of transformations indicated by the transform mask, -then png_write_image(), and finally png_write_end(). - -(The final parameter of this call is not yet used. Someday it might point -to transformation parameters required by some future output transform.) - -You must use png_transforms and not call any png_set_transform() functions -when you use png_write_png(). - -The low-level write interface - -If you are going the low-level route instead, you are now ready to -write all the file information up to the actual image data. You do -this with a call to png_write_info(). - - png_write_info(png_ptr, info_ptr); - -Note that there is one transformation you may need to do before -png_write_info(). In PNG files, the alpha channel in an image is the -level of opacity. If your data is supplied as a level of -transparency, you can invert the alpha channel before you write it, so -that 0 is fully transparent and 255 (in 8-bit or paletted images) or -65535 (in 16-bit images) is fully opaque, with - - png_set_invert_alpha(png_ptr); - -This must appear before png_write_info() instead of later with the -other transformations because in the case of paletted images the tRNS -chunk data has to be inverted before the tRNS chunk is written. If -your image is not a paletted image, the tRNS data (which in such cases -represents a single color to be rendered as transparent) won't need to -be changed, and you can safely do this transformation after your -png_write_info() call. - -If you need to write a private chunk that you want to appear before -the PLTE chunk when PLTE is present, you can write the PNG info in -two steps, and insert code to write your own chunk between them: - - png_write_info_before_PLTE(png_ptr, info_ptr); - png_set_unknown_chunks(png_ptr, info_ptr, ...); - png_write_info(png_ptr, info_ptr); - -After you've written the file information, you can set up the library -to handle any special transformations of the image data. The various -ways to transform the data will be described in the order that they -should occur. This is important, as some of these change the color -type and/or bit depth of the data, and some others only work on -certain color types and bit depths. Even though each transformation -checks to see if it has data that it can do something with, you should -make sure to only enable a transformation if it will be valid for the -data. For example, don't swap red and blue on grayscale data. - -PNG files store RGB pixels packed into 3 or 6 bytes. This code tells -the library to strip input data that has 4 or 8 bytes per pixel down -to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 -bytes per pixel). - - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); - -where the 0 is unused, and the location is either PNG_FILLER_BEFORE or -PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel -is stored XRGB or RGBX. - -PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as -they can, resulting in, for example, 8 pixels per byte for 1 bit files. -If the data is supplied at 1 pixel per byte, use this code, which will -correctly pack the pixels into a single byte: - - png_set_packing(png_ptr); - -PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your -data is of another bit depth, you can write an sBIT chunk into the -file so that decoders can recover the original data if desired. - - /* Set the true bit depth of the image data */ - if (color_type & PNG_COLOR_MASK_COLOR) - { - sig_bit.red = true_bit_depth; - sig_bit.green = true_bit_depth; - sig_bit.blue = true_bit_depth; - } - else - { - sig_bit.gray = true_bit_depth; - } - if (color_type & PNG_COLOR_MASK_ALPHA) - { - sig_bit.alpha = true_bit_depth; - } - - png_set_sBIT(png_ptr, info_ptr, &sig_bit); - -If the data is stored in the row buffer in a bit depth other than -one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), -this will scale the values to appear to be the correct bit depth as -is required by PNG. - - png_set_shift(png_ptr, &sig_bit); - -PNG files store 16 bit pixels in network byte order (big-endian, -ie. most significant bits first). This code would be used if they are -supplied the other way (little-endian, i.e. least significant bits -first, the way PCs store them): - - if (bit_depth > 8) - png_set_swap(png_ptr); - -If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you -need to change the order the pixels are packed into bytes, you can use: - - if (bit_depth < 8) - png_set_packswap(png_ptr); - -PNG files store 3 color pixels in red, green, blue order. This code -would be used if they are supplied as blue, green, red: - - png_set_bgr(png_ptr); - -PNG files describe monochrome as black being zero and white being -one. This code would be used if the pixels are supplied with this reversed -(black being one and white being zero): - - png_set_invert_mono(png_ptr); - -Finally, you can write your own transformation function if none of -the existing ones meets your needs. This is done by setting a callback -with - - png_set_write_user_transform_fn(png_ptr, - write_transform_fn); - -You must supply the function - - void write_transform_fn(png_ptr ptr, row_info_ptr - row_info, png_bytep data) - -See pngtest.c for a working example. Your function will be called -before any of the other transformations are processed. - -You can also set up a pointer to a user structure for use by your -callback function. - - png_set_user_transform_info(png_ptr, user_ptr, 0, 0); - -The user_channels and user_depth parameters of this function are ignored -when writing; you can set them to zero as shown. - -You can retrieve the pointer via the function png_get_user_transform_ptr(). -For example: - - voidp write_user_transform_ptr = - png_get_user_transform_ptr(png_ptr); - -It is possible to have libpng flush any pending output, either manually, -or automatically after a certain number of lines have been written. To -flush the output stream a single time call: - - png_write_flush(png_ptr); - -and to have libpng flush the output stream periodically after a certain -number of scanlines have been written, call: - - png_set_flush(png_ptr, nrows); - -Note that the distance between rows is from the last time png_write_flush() -was called, or the first row of the image if it has never been called. -So if you write 50 lines, and then png_set_flush 25, it will flush the -output on the next scanline, and every 25 lines thereafter, unless -png_write_flush() is called before 25 more lines have been written. -If nrows is too small (less than about 10 lines for a 640 pixel wide -RGB image) the image compression may decrease noticeably (although this -may be acceptable for real-time applications). Infrequent flushing will -only degrade the compression performance by a few percent over images -that do not use flushing. - -Writing the image data - -That's it for the transformations. Now you can write the image data. -The simplest way to do this is in one function call. If you have the -whole image in memory, you can just call png_write_image() and libpng -will write the image. You will need to pass in an array of pointers to -each row. This function automatically handles interlacing, so you don't -need to call png_set_interlace_handling() or call this function multiple -times, or any of that other stuff necessary with png_write_rows(). - - png_write_image(png_ptr, row_pointers); - -where row_pointers is: - - png_byte *row_pointers[height]; - -You can point to void or char or whatever you use for pixels. - -If you don't want to write the whole image at once, you can -use png_write_rows() instead. If the file is not interlaced, -this is simple: - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -row_pointers is the same as in the png_write_image() call. - -If you are just writing one row at a time, you can do this with -a single row_pointer instead of an array of row_pointers: - - png_bytep row_pointer = row; - - png_write_row(png_ptr, row_pointer); - -When the file is interlaced, things can get a good deal more -complicated. The only currently (as of the PNG Specification -version 1.2, dated July 1999) defined interlacing scheme for PNG files -is the "Adam7" interlace scheme, that breaks down an -image into seven smaller images of varying size. libpng will build -these images for you, or you can do them yourself. If you want to -build them yourself, see the PNG specification for details of which -pixels to write when. - -If you don't want libpng to handle the interlacing details, just -use png_set_interlace_handling() and call png_write_rows() the -correct number of times to write all seven sub-images. - -If you want libpng to build the sub-images, call this before you start -writing any rows: - - number_of_passes = - png_set_interlace_handling(png_ptr); - -This will return the number of passes needed. Currently, this -is seven, but may change if another interlace type is added. - -Then write the complete image number_of_passes times. - - png_write_rows(png_ptr, row_pointers, - number_of_rows); - -As some of these rows are not used, and thus return immediately, -you may want to read about interlacing in the PNG specification, -and only update the rows that are actually used. - -Finishing a sequential write - -After you are finished writing the image, you should finish writing -the file. If you are interested in writing comments or time, you should -pass an appropriately filled png_info pointer. If you are not interested, -you can pass NULL. - - png_write_end(png_ptr, info_ptr); - -When you are done, you can free all memory used by libpng like this: - - png_destroy_write_struct(&png_ptr, &info_ptr); - -It is also possible to individually free the info_ptr members that -point to libpng-allocated storage with the following function: - - png_free_data(png_ptr, info_ptr, mask, seq) - mask - identifies data to be freed, a mask - containing the bitwise OR of one or - more of - PNG_FREE_PLTE, PNG_FREE_TRNS, - PNG_FREE_HIST, PNG_FREE_ICCP, - PNG_FREE_PCAL, PNG_FREE_ROWS, - PNG_FREE_SCAL, PNG_FREE_SPLT, - PNG_FREE_TEXT, PNG_FREE_UNKN, - or simply PNG_FREE_ALL - seq - sequence number of item to be freed - (-1 for all items) - -This function may be safely called when the relevant storage has -already been freed, or has not yet been allocated, or was allocated -by the user and not by libpng, and will in those -cases do nothing. The "seq" parameter is ignored if only one item -of the selected data type, such as PLTE, is allowed. If "seq" is not --1, and multiple items are allowed for the data type identified in -the mask, such as text or sPLT, only the n'th item in the structure -is freed, where n is "seq". - -If you allocated data such as a palette that you passed -in to libpng with png_set_*, you must not free it until just before the call to -png_destroy_write_struct(). - -The default behavior is only to free data that was allocated internally -by libpng. This can be changed, so that libpng will not free the data, -or so that it will free data that was allocated by the user with png_malloc() -or png_zalloc() and passed in via a png_set_*() function, with - - png_data_freer(png_ptr, info_ptr, freer, mask) - mask - which data elements are affected - same choices as in png_free_data() - freer - one of - PNG_DESTROY_WILL_FREE_DATA - PNG_SET_WILL_FREE_DATA - PNG_USER_WILL_FREE_DATA - -For example, to transfer responsibility for some data from a read structure -to a write structure, you could use - - png_data_freer(read_ptr, read_info_ptr, - PNG_USER_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - png_data_freer(write_ptr, write_info_ptr, - PNG_DESTROY_WILL_FREE_DATA, - PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) - -thereby briefly reassigning responsibility for freeing to the user but -immediately afterwards reassigning it once more to the write_destroy -function. Having done this, it would then be safe to destroy the read -structure and continue to use the PLTE, tRNS, and hIST data in the write -structure. - -This function only affects data that has already been allocated. -You can call this function before calling after the png_set_*() functions -to control whether the user or png_destroy_*() is supposed to free the data. -When the user assumes responsibility for libpng-allocated data, the -application must use -png_free() to free it, and when the user transfers responsibility to libpng -for data that the user has allocated, the user must have used png_malloc() -or png_zalloc() to allocate it. - -If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword -separately, do not transfer responsibility for freeing text_ptr to libpng, -because when libpng fills a png_text structure it combines these members with -the key member, and png_free_data() will free only text_ptr.key. Similarly, -if you transfer responsibility for free'ing text_ptr from libpng to your -application, your application must not separately free those members. -For a more compact example of writing a PNG image, see the file example.c. - -V. Modifying/Customizing libpng: - -There are two issues here. The first is changing how libpng does -standard things like memory allocation, input/output, and error handling. -The second deals with more complicated things like adding new chunks, -adding new transformations, and generally changing how libpng works. -Both of those are compile-time issues; that is, they are generally -determined at the time the code is written, and there is rarely a need -to provide the user with a means of changing them. - -Memory allocation, input/output, and error handling - -All of the memory allocation, input/output, and error handling in libpng -goes through callbacks that are user-settable. The default routines are -in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change -these functions, call the appropriate png_set_*_fn() function. - -Memory allocation is done through the functions png_malloc() -and png_free(). These currently just call the standard C functions. If -your pointers can't access more then 64K at a time, you will want to set -MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling -memory allocation on a platform will change between applications, these -functions must be modified in the library at compile time. If you prefer -to use a different method of allocating and freeing data, you can use -png_create_read_struct_2() or png_create_write_struct_2() to register -your own functions as described above. -These functions also provide a void pointer that can be retrieved via - - mem_ptr=png_get_mem_ptr(png_ptr); - -Your replacement memory functions must have prototypes as follows: - - png_voidp malloc_fn(png_structp png_ptr, - png_size_t size); - void free_fn(png_structp png_ptr, png_voidp ptr); - -Your malloc_fn() must return NULL in case of failure. The png_malloc() -function will normally call png_error() if it receives a NULL from the -system memory allocator or from your replacement malloc_fn(). - -Your free_fn() will never be called with a NULL ptr, since libpng's -png_free() checks for NULL before calling free_fn(). - -Input/Output in libpng is done through png_read() and png_write(), -which currently just call fread() and fwrite(). The FILE * is stored in -png_struct and is initialized via png_init_io(). If you wish to change -the method of I/O, the library supplies callbacks that you can set -through the function png_set_read_fn() and png_set_write_fn() at run -time, instead of calling the png_init_io() function. These functions -also provide a void pointer that can be retrieved via the function -png_get_io_ptr(). For example: - - png_set_read_fn(png_structp read_ptr, - voidp read_io_ptr, png_rw_ptr read_data_fn) - - png_set_write_fn(png_structp write_ptr, - voidp write_io_ptr, png_rw_ptr write_data_fn, - png_flush_ptr output_flush_fn); - - voidp read_io_ptr = png_get_io_ptr(read_ptr); - voidp write_io_ptr = png_get_io_ptr(write_ptr); - -The replacement I/O functions must have prototypes as follows: - - void user_read_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_write_data(png_structp png_ptr, - png_bytep data, png_size_t length); - void user_flush_data(png_structp png_ptr); - -Supplying NULL for the read, write, or flush functions sets them back -to using the default C stream functions. It is an error to read from -a write stream, and vice versa. - -Error handling in libpng is done through png_error() and png_warning(). -Errors handled through png_error() are fatal, meaning that png_error() -should never return to its caller. Currently, this is handled via -setjmp() and longjmp() (unless you have compiled libpng with -PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), -but you could change this to do things like exit() if you should wish. - -On non-fatal errors, png_warning() is called -to print a warning message, and then control returns to the calling code. -By default png_error() and png_warning() print a message on stderr via -fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined -(because you don't want the messages) or PNG_NO_STDIO defined (because -fprintf() isn't available). If you wish to change the behavior of the error -functions, you will need to set up your own message callbacks. These -functions are normally supplied at the time that the png_struct is created. -It is also possible to redirect errors and warnings to your own replacement -functions after png_create_*_struct() has been called by calling: - - png_set_error_fn(png_structp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warning_fn); - - png_voidp error_ptr = png_get_error_ptr(png_ptr); - -If NULL is supplied for either error_fn or warning_fn, then the libpng -default function will be used, calling fprintf() and/or longjmp() if a -problem is encountered. The replacement error functions should have -parameters as follows: - - void user_error_fn(png_structp png_ptr, - png_const_charp error_msg); - void user_warning_fn(png_structp png_ptr, - png_const_charp warning_msg); - -The motivation behind using setjmp() and longjmp() is the C++ throw and -catch exception handling methods. This makes the code much easier to write, -as there is no need to check every return code of every function call. -However, there are some uncertainties about the status of local variables -after a longjmp, so the user may want to be careful about doing anything after -setjmp returns non-zero besides returning itself. Consult your compiler -documentation for more details. For an alternative approach, you may wish -to use the "cexcept" facility (see http://cexcept.sourceforge.net). - -Custom chunks - -If you need to read or write custom chunks, you may need to get deeper -into the libpng code. The library now has mechanisms for storing -and writing chunks of unknown type; you can even declare callbacks -for custom chunks. However, this may not be good enough if the -library code itself needs to know about interactions between your -chunk and existing `intrinsic' chunks. - -If you need to write a new intrinsic chunk, first read the PNG -specification. Acquire a first level of -understanding of how it works. Pay particular attention to the -sections that describe chunk names, and look at how other chunks were -designed, so you can do things similarly. Second, check out the -sections of libpng that read and write chunks. Try to find a chunk -that is similar to yours and use it as a template. More details can -be found in the comments inside the code. It is best to handle unknown -chunks in a generic method, via callback functions, instead of by -modifying libpng functions. - -If you wish to write your own transformation for the data, look through -the part of the code that does the transformations, and check out some of -the simpler ones to get an idea of how they work. Try to find a similar -transformation to the one you want to add and copy off of it. More details -can be found in the comments inside the code itself. - -Configuring for 16 bit platforms - -You will want to look into zconf.h to tell zlib (and thus libpng) that -it cannot allocate more then 64K at a time. Even if you can, the memory -won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. - -Configuring for DOS - -For DOS users who only have access to the lower 640K, you will -have to limit zlib's memory usage via a png_set_compression_mem_level() -call. See zlib.h or zconf.h in the zlib library for more information. - -Configuring for Medium Model - -Libpng's support for medium model has been tested on most of the popular -compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets -defined, and FAR gets defined to far in pngconf.h, and you should be -all set. Everything in the library (except for zlib's structure) is -expecting far data. You must use the typedefs with the p or pp on -the end for pointers (or at least look at them and be careful). Make -note that the rows of data are defined as png_bytepp, which is an -unsigned char far * far *. - -Configuring for gui/windowing platforms: - -You will need to write new error and warning functions that use the GUI -interface, as described previously, and set them to be the error and -warning functions at the time that png_create_*_struct() is called, -in order to have them available during the structure initialization. -They can be changed later via png_set_error_fn(). On some compilers, -you may also have to change the memory allocators (png_malloc, etc.). - -Configuring for compiler xxx: - -All includes for libpng are in pngconf.h. If you need to add/change/delete -an include, this is the place to do it. The includes that are not -needed outside libpng are protected by the PNG_INTERNAL definition, -which is only defined for those routines inside libpng itself. The -files in libpng proper only include png.h, which includes pngconf.h. - -Configuring zlib: - -There are special functions to configure the compression. Perhaps the -most useful one changes the compression level, which currently uses -input compression values in the range 0 - 9. The library normally -uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests -have shown that for a large majority of images, compression values in -the range 3-6 compress nearly as well as higher levels, and do so much -faster. For online applications it may be desirable to have maximum speed -(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also -specify no compression (Z_NO_COMPRESSION = 0), but this would create -files larger than just storing the raw bitmap. You can specify the -compression level by calling: - - png_set_compression_level(png_ptr, level); - -Another useful one is to reduce the memory level used by the library. -The memory level defaults to 8, but it can be lowered if you are -short on memory (running DOS, for example, where you only have 640K). -Note that the memory level does have an effect on compression; among -other things, lower levels will result in sections of incompressible -data being emitted in smaller stored blocks, with a correspondingly -larger relative overhead of up to 15% in the worst case. - - png_set_compression_mem_level(png_ptr, level); - -The other functions are for configuring zlib. They are not recommended -for normal use and may result in writing an invalid PNG file. See -zlib.h for more information on what these mean. - - png_set_compression_strategy(png_ptr, - strategy); - png_set_compression_window_bits(png_ptr, - window_bits); - png_set_compression_method(png_ptr, method); - png_set_compression_buffer_size(png_ptr, size); - -Controlling row filtering - -If you want to control whether libpng uses filtering or not, which -filters are used, and how it goes about picking row filters, you -can call one of these functions. The selection and configuration -of row filters can have a significant impact on the size and -encoding speed and a somewhat lesser impact on the decoding speed -of an image. Filtering is enabled by default for RGB and grayscale -images (with and without alpha), but not for paletted images nor -for any images with bit depths less than 8 bits/pixel. - -The 'method' parameter sets the main filtering method, which is -currently only '0' in the PNG 1.2 specification. The 'filters' -parameter sets which filter(s), if any, should be used for each -scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS -to turn filtering on and off, respectively. - -Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, -PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise -ORed together with '|' to specify one or more filters to use. -These filters are described in more detail in the PNG specification. -If you intend to change the filter type during the course of writing -the image, you should start with flags set for all of the filters -you intend to use so that libpng can initialize its internal -structures appropriately for all of the filter types. (Note that this -means the first row must always be adaptively filtered, because libpng -currently does not allocate the filter buffers until png_write_row() -is called for the first time.) - - filters = PNG_FILTER_NONE | PNG_FILTER_SUB - PNG_FILTER_UP | PNG_FILTER_AVE | - PNG_FILTER_PAETH | PNG_ALL_FILTERS; - - png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, - filters); - The second parameter can also be - PNG_INTRAPIXEL_DIFFERENCING if you are - writing a PNG to be embedded in a MNG - datastream. This parameter must be the - same as the value of filter_method used - in png_set_IHDR(). - -It is also possible to influence how libpng chooses from among the -available filters. This is done in one or both of two ways - by -telling it how important it is to keep the same filter for successive -rows, and by telling it the relative computational costs of the filters. - - double weights[3] = {1.5, 1.3, 1.1}, - costs[PNG_FILTER_VALUE_LAST] = - {1.0, 1.3, 1.3, 1.5, 1.7}; - - png_set_filter_heuristics(png_ptr, - PNG_FILTER_HEURISTIC_WEIGHTED, 3, - weights, costs); - -The weights are multiplying factors that indicate to libpng that the -row filter should be the same for successive rows unless another row filter -is that many times better than the previous filter. In the above example, -if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a -"sum of absolute differences" 1.5 x 1.3 times higher than other filters -and still be chosen, while the NONE filter could have a sum 1.1 times -higher than other filters and still be chosen. Unspecified weights are -taken to be 1.0, and the specified weights should probably be declining -like those above in order to emphasize recent filters over older filters. - -The filter costs specify for each filter type a relative decoding cost -to be considered when selecting row filters. This means that filters -with higher costs are less likely to be chosen over filters with lower -costs, unless their "sum of absolute differences" is that much smaller. -The costs do not necessarily reflect the exact computational speeds of -the various filters, since this would unduly influence the final image -size. - -Note that the numbers above were invented purely for this example and -are given only to help explain the function usage. Little testing has -been done to find optimum values for either the costs or the weights. - -Removing unwanted object code - -There are a bunch of #define's in pngconf.h that control what parts of -libpng are compiled. All the defines end in _SUPPORTED. If you are -never going to use a capability, you can change the #define to #undef -before recompiling libpng and save yourself code and data space, or -you can turn off individual capabilities with defines that begin with -PNG_NO_. - -You can also turn all of the transforms and ancillary chunk capabilities -off en masse with compiler directives that define -PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, -or all four, -along with directives to turn on any of the capabilities that you do -want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable -the extra transformations but still leave the library fully capable of reading -and writing PNG files with all known public chunks -Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive -produces a library that is incapable of reading or writing ancillary chunks. -If you are not using the progressive reading capability, you can -turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse -this with the INTERLACING capability, which you'll still have). - -All the reading and writing specific code are in separate files, so the -linker should only grab the files it needs. However, if you want to -make sure, or if you are building a stand alone library, all the -reading files start with pngr and all the writing files start with -pngw. The files that don't match either (like png.c, pngtrans.c, etc.) -are used for both reading and writing, and always need to be included. -The progressive reader is in pngpread.c - -If you are creating or distributing a dynamically linked library (a .so -or DLL file), you should not remove or disable any parts of the library, -as this will cause applications linked with different versions of the -library to fail if they call functions not available in your library. -The size of the library itself should not be an issue, because only -those sections that are actually used will be loaded into memory. - -Requesting debug printout - -The macro definition PNG_DEBUG can be used to request debugging -printout. Set it to an integer value in the range 0 to 3. Higher -numbers result in increasing amounts of debugging information. The -information is printed to the "stderr" file, unless another file -name is specified in the PNG_DEBUG_FILE macro definition. - -When PNG_DEBUG > 0, the following functions (macros) become available: - - png_debug(level, message) - png_debug1(level, message, p1) - png_debug2(level, message, p1, p2) - -in which "level" is compared to PNG_DEBUG to decide whether to print -the message, "message" is the formatted string to be printed, -and p1 and p2 are parameters that are to be embedded in the string -according to printf-style formatting directives. For example, - - png_debug1(2, "foo=%d\n", foo); - -is expanded to - - if(PNG_DEBUG > 2) - fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); - -When PNG_DEBUG is defined but is zero, the macros aren't defined, but you -can still use PNG_DEBUG to control your own debugging: - - #ifdef PNG_DEBUG - fprintf(stderr, ... - #endif - -When PNG_DEBUG = 1, the macros are defined, but only png_debug statements -having level = 0 will be printed. There aren't any such statements in -this version of libpng, but if you insert some they will be printed. - -VII. MNG support - -The MNG specification (available at http://www.libpng.org/pub/mng) allows -certain extensions to PNG for PNG images that are embedded in MNG datastreams. -Libpng can support some of these extensions. To enable them, use the -png_permit_mng_features() function: - - feature_set = png_permit_mng_features(png_ptr, mask) - mask is a png_uint_32 containing the bitwise OR of the - features you want to enable. These include - PNG_FLAG_MNG_EMPTY_PLTE - PNG_FLAG_MNG_FILTER_64 - PNG_ALL_MNG_FEATURES - feature_set is a png_uint_32 that is the bitwise AND of - your mask with the set of MNG features that is - supported by the version of libpng that you are using. - -It is an error to use this function when reading or writing a standalone -PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped -in a MNG datastream. As a minimum, it must have the MNG 8-byte signature -and the MHDR and MEND chunks. Libpng does not provide support for these -or any other MNG chunks; your application must provide its own support for -them. You may wish to consider using libmng (available at -http://www.libmng.com) instead. - -VIII. Changes to Libpng from version 0.88 - -It should be noted that versions of libpng later than 0.96 are not -distributed by the original libpng author, Guy Schalnat, nor by -Andreas Dilger, who had taken over from Guy during 1996 and 1997, and -distributed versions 0.89 through 0.96, but rather by another member -of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are -still alive and well, but they have moved on to other things. - -The old libpng functions png_read_init(), png_write_init(), -png_info_init(), png_read_destroy(), and png_write_destroy() have been -moved to PNG_INTERNAL in version 0.95 to discourage their use. These -functions will be removed from libpng version 2.0.0. - -The preferred method of creating and initializing the libpng structures is -via the png_create_read_struct(), png_create_write_struct(), and -png_create_info_struct() because they isolate the size of the structures -from the application, allow version error checking, and also allow the -use of custom error handling routines during the initialization, which -the old functions do not. The functions png_read_destroy() and -png_write_destroy() do not actually free the memory that libpng -allocated for these structs, but just reset the data structures, so they -can be used instead of png_destroy_read_struct() and -png_destroy_write_struct() if you feel there is too much system overhead -allocating and freeing the png_struct for each image read. - -Setting the error callbacks via png_set_message_fn() before -png_read_init() as was suggested in libpng-0.88 is no longer supported -because this caused applications that do not use custom error functions -to fail if the png_ptr was not initialized to zero. It is still possible -to set the error callbacks AFTER png_read_init(), or to change them with -png_set_error_fn(), which is essentially the same function, but with a new -name to force compilation errors with applications that try to use the old -method. - -Starting with version 1.0.7, you can find out which version of the library -you are using at run-time: - - png_uint_32 libpng_vn = png_access_version_number(); - -The number libpng_vn is constructed from the major version, minor -version with leading zero, and release number with leading zero, -(e.g., libpng_vn for version 1.0.7 is 10007). - -You can also check which version of png.h you used when compiling your -application: - - png_uint_32 application_vn = PNG_LIBPNG_VER; - -IX. Y2K Compliance in libpng - -May 8, 2008 - -Since the PNG Development group is an ad-hoc body, we can't make -an official declaration. - -This is your unofficial assurance that libpng from version 0.71 and -upward through 1.2.29 are Y2K compliant. It is my belief that earlier -versions were also Y2K compliant. - -Libpng only has three year fields. One is a 2-byte unsigned integer that -will hold years up to 65535. The other two hold the date in text -format, and will hold years up to 9999. - -The integer is - "png_uint_16 year" in png_time_struct. - -The strings are - "png_charp time_buffer" in png_struct and - "near_time_buffer", which is a local character string in png.c. - -There are seven time-related functions: - - png_convert_to_rfc_1123() in png.c - (formerly png_convert_to_rfc_1152() in error) - png_convert_from_struct_tm() in pngwrite.c, called - in pngwrite.c - png_convert_from_time_t() in pngwrite.c - png_get_tIME() in pngget.c - png_handle_tIME() in pngrutil.c, called in pngread.c - png_set_tIME() in pngset.c - png_write_tIME() in pngwutil.c, called in pngwrite.c - -All appear to handle dates properly in a Y2K environment. The -png_convert_from_time_t() function calls gmtime() to convert from system -clock time, which returns (year - 1900), which we properly convert to -the full 4-digit year. There is a possibility that applications using -libpng are not passing 4-digit years into the png_convert_to_rfc_1123() -function, or that they are incorrectly passing only a 2-digit year -instead of "year - 1900" into the png_convert_from_struct_tm() function, -but this is not under our control. The libpng documentation has always -stated that it works with 4-digit years, and the APIs have been -documented as such. - -The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned -integer to hold the year, and can hold years as large as 65535. - -zlib, upon which libpng depends, is also Y2K compliant. It contains -no date-related code. - - - Glenn Randers-Pehrson - libpng maintainer - PNG Development Group diff --git a/src/3rdparty/libpng/libpng-1.2.40.txt b/src/3rdparty/libpng/libpng-1.2.40.txt new file mode 100644 index 0000000..019c886 --- /dev/null +++ b/src/3rdparty/libpng/libpng-1.2.40.txt @@ -0,0 +1,3112 @@ +libpng.txt - A description on how to use and modify libpng + + libpng version 1.2.40 - September 10, 2009 + Updated and distributed by Glenn Randers-Pehrson + + Copyright (c) 1998-2009 Glenn Randers-Pehrson + + This document is released under the libpng license. + For conditions of distribution and use, see the disclaimer + and license in png.h + + Based on: + + libpng versions 0.97, January 1998, through 1.2.40 - September 10, 2009 + Updated and distributed by Glenn Randers-Pehrson + Copyright (c) 1998-2009 Glenn Randers-Pehrson + + libpng 1.0 beta 6 version 0.96 May 28, 1997 + Updated and distributed by Andreas Dilger + Copyright (c) 1996, 1997 Andreas Dilger + + libpng 1.0 beta 2 - version 0.88 January 26, 1996 + For conditions of distribution and use, see copyright + notice in png.h. Copyright (c) 1995, 1996 Guy Eric + Schalnat, Group 42, Inc. + + Updated/rewritten per request in the libpng FAQ + Copyright (c) 1995, 1996 Frank J. T. Wojcik + December 18, 1995 & January 20, 1996 + +I. Introduction + +This file describes how to use and modify the PNG reference library +(known as libpng) for your own use. There are five sections to this +file: introduction, structures, reading, writing, and modification and +configuration notes for various special platforms. In addition to this +file, example.c is a good starting point for using the library, as +it is heavily commented and should include everything most people +will need. We assume that libpng is already installed; see the +INSTALL file for instructions on how to install libpng. + +For examples of libpng usage, see the files "example.c", "pngtest.c", +and the files in the "contrib" directory, all of which are included in the +libpng distribution. + +Libpng was written as a companion to the PNG specification, as a way +of reducing the amount of time and effort it takes to support the PNG +file format in application programs. + +The PNG specification (second edition), November 2003, is available as +a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2003 (E)) at +. It is technically equivalent +to the PNG specification (second edition) but has some additional material. + +The PNG-1.0 specification is available +as RFC 2083 and as a +W3C Recommendation . + +Some additional chunks are described in the special-purpose public chunks +documents at . + +Other information +about PNG, and the latest version of libpng, can be found at the PNG home +page, . + +Most users will not have to modify the library significantly; advanced +users may want to modify it more. All attempts were made to make it as +complete as possible, while keeping the code easy to understand. +Currently, this library only supports C. Support for other languages +is being considered. + +Libpng has been designed to handle multiple sessions at one time, +to be easily modifiable, to be portable to the vast majority of +machines (ANSI, K&R, 16-, 32-, and 64-bit) available, and to be easy +to use. The ultimate goal of libpng is to promote the acceptance of +the PNG file format in whatever way possible. While there is still +work to be done (see the TODO file), libpng should cover the +majority of the needs of its users. + +Libpng uses zlib for its compression and decompression of PNG files. +Further information about zlib, and the latest version of zlib, can +be found at the zlib home page, . +The zlib compression utility is a general purpose utility that is +useful for more than PNG files, and can be used without libpng. +See the documentation delivered with zlib for more details. +You can usually find the source files for the zlib utility wherever you +find the libpng source files. + +Libpng is thread safe, provided the threads are using different +instances of the structures. Each thread should have its own +png_struct and png_info instances, and thus its own image. +Libpng does not protect itself against two threads using the +same instance of a structure. + +II. Structures + +There are two main structures that are important to libpng, png_struct +and png_info. The first, png_struct, is an internal structure that +will not, for the most part, be used by a user except as the first +variable passed to every libpng function call. + +The png_info structure is designed to provide information about the +PNG file. At one time, the fields of png_info were intended to be +directly accessible to the user. However, this tended to cause problems +with applications using dynamically loaded libraries, and as a result +a set of interface functions for png_info (the png_get_*() and png_set_*() +functions) was developed. The fields of png_info are still available for +older applications, but it is suggested that applications use the new +interfaces if at all possible. + +Applications that do make direct access to the members of png_struct (except +for png_ptr->jmpbuf) must be recompiled whenever the library is updated, +and applications that make direct access to the members of png_info must +be recompiled if they were compiled or loaded with libpng version 1.0.6, +in which the members were in a different order. In version 1.0.7, the +members of the png_info structure reverted to the old order, as they were +in versions 0.97c through 1.0.5. Starting with version 2.0.0, both +structures are going to be hidden, and the contents of the structures will +only be accessible through the png_get/png_set functions. + +The png.h header file is an invaluable reference for programming with libpng. +And while I'm on the topic, make sure you include the libpng header file: + +#include + +III. Reading + +We'll now walk you through the possible functions to call when reading +in a PNG file sequentially, briefly explaining the syntax and purpose +of each one. See example.c and png.h for more detail. While +progressive reading is covered in the next section, you will still +need some of the functions discussed in this section to read a PNG +file. + +Setup + +You will want to do the I/O initialization(*) before you get into libpng, +so if it doesn't work, you don't have much to undo. Of course, you +will also want to insure that you are, in fact, dealing with a PNG +file. Libpng provides a simple check to see if a file is a PNG file. +To use it, pass in the first 1 to 8 bytes of the file to the function +png_sig_cmp(), and it will return 0 (false) if the bytes match the +corresponding bytes of the PNG signature, or nonzero (true) otherwise. +Of course, the more bytes you pass in, the greater the accuracy of the +prediction. + +If you are intending to keep the file pointer open for use in libpng, +you must ensure you don't read more than 8 bytes from the beginning +of the file, and you also have to make a call to png_set_sig_bytes_read() +with the number of bytes you read from the beginning. Libpng will +then only check the bytes (if any) that your program didn't read. + +(*): If you are not using the standard I/O functions, you will need +to replace them with custom functions. See the discussion under +Customizing libpng. + + + FILE *fp = fopen(file_name, "rb"); + if (!fp) + { + return (ERROR); + } + fread(header, 1, number, fp); + is_png = !png_sig_cmp(header, 0, number); + if (!is_png) + { + return (NOT_PNG); + } + + +Next, png_struct and png_info need to be allocated and initialized. In +order to ensure that the size of these structures is correct even with a +dynamically linked libpng, there are functions to initialize and +allocate the structures. We also pass the library version, optional +pointers to error handling functions, and a pointer to a data struct for +use by the error functions, if necessary (the pointer and functions can +be NULL if the default error handlers are to be used). See the section +on Changes to Libpng below regarding the old initialization functions. +The structure allocation functions quietly return NULL if they fail to +create the structure, so your application should check for that. + + png_structp png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + if (!png_ptr) + return (ERROR); + + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, + (png_infopp)NULL, (png_infopp)NULL); + return (ERROR); + } + + png_infop end_info = png_create_info_struct(png_ptr); + if (!end_info) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + +If you want to use your own memory allocation routines, +define PNG_USER_MEM_SUPPORTED and use +png_create_read_struct_2() instead of png_create_read_struct(): + + png_structp png_ptr = png_create_read_struct_2 + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn, (png_voidp) + user_mem_ptr, user_malloc_fn, user_free_fn); + +The error handling routines passed to png_create_read_struct() +and the memory alloc/free routines passed to png_create_struct_2() +are only necessary if you are not using the libpng supplied error +handling and memory alloc/free functions. + +When libpng encounters an error, it expects to longjmp back +to your routine. Therefore, you will need to call setjmp and pass +your png_jmpbuf(png_ptr). If you read the file from different +routines, you will need to update the jmpbuf field every time you enter +a new routine that will call a png_*() function. + +See your documentation of setjmp/longjmp for your compiler for more +information on setjmp/longjmp. See the discussion on libpng error +handling in the Customizing Libpng section below for more information +on the libpng error handling. If an error occurs, and libpng longjmp's +back to your setjmp, you will want to call png_destroy_read_struct() to +free any memory. + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + &end_info); + fclose(fp); + return (ERROR); + } + +If you would rather avoid the complexity of setjmp/longjmp issues, +you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case +errors will result in a call to PNG_ABORT() which defaults to abort(). + +Now you need to set up the input code. The default for libpng is to +use the C function fread(). If you use this, you will need to pass a +valid FILE * in the function png_init_io(). Be sure that the file is +opened in binary mode. If you wish to handle reading data in another +way, you need not call the png_init_io() function, but you must then +implement the libpng I/O methods discussed in the Customizing Libpng +section below. + + png_init_io(png_ptr, fp); + +If you had previously opened the file and read any of the signature from +the beginning in order to see if this was a PNG file, you need to let +libpng know that there are some bytes missing from the start of the file. + + png_set_sig_bytes(png_ptr, number); + +Setting up callback code + +You can set up a callback function to handle any unknown chunks in the +input stream. You must supply the function + + read_chunk_callback(png_ptr ptr, + png_unknown_chunkp chunk); + { + /* The unknown chunk structure contains your + chunk data, along with similar data for any other + unknown chunks: */ + + png_byte name[5]; + png_byte *data; + png_size_t size; + + /* Note that libpng has already taken care of + the CRC handling */ + + /* put your code here. Search for your chunk in the + unknown chunk structure, process it, and return one + of the following: */ + + return (-n); /* chunk had an error */ + return (0); /* did not recognize */ + return (n); /* success */ + } + +(You can give your function another name that you like instead of +"read_chunk_callback") + +To inform libpng about your function, use + + png_set_read_user_chunk_fn(png_ptr, user_chunk_ptr, + read_chunk_callback); + +This names not only the callback function, but also a user pointer that +you can retrieve with + + png_get_user_chunk_ptr(png_ptr); + +If you call the png_set_read_user_chunk_fn() function, then all unknown +chunks will be saved when read, in case your callback function will need +one or more of them. This behavior can be changed with the +png_set_keep_unknown_chunks() function, described below. + +At this point, you can set up a callback function that will be +called after each row has been read, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void read_row_callback(png_ptr ptr, png_uint_32 row, + int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "read_row_callback") + +To inform libpng about your function, use + + png_set_read_status_fn(png_ptr, read_row_callback); + +Unknown-chunk handling + +Now you get to set the way the library processes unknown chunks in the +input PNG stream. Both known and unknown chunks will be read. Normal +behavior is that known chunks will be parsed into information in +various info_ptr members while unknown chunks will be discarded. This +behavior can be wasteful if your application will never use some known +chunk types. To change this, you can call: + + png_set_keep_unknown_chunks(png_ptr, keep, + chunk_list, num_chunks); + keep - 0: default unknown chunk handling + 1: ignore; do not keep + 2: keep only if safe-to-copy + 3: keep even if unsafe-to-copy + You can use these definitions: + PNG_HANDLE_CHUNK_AS_DEFAULT 0 + PNG_HANDLE_CHUNK_NEVER 1 + PNG_HANDLE_CHUNK_IF_SAFE 2 + PNG_HANDLE_CHUNK_ALWAYS 3 + chunk_list - list of chunks affected (a byte string, + five bytes per chunk, NULL or '\0' if + num_chunks is 0) + num_chunks - number of chunks affected; if 0, all + unknown chunks are affected. If nonzero, + only the chunks in the list are affected + +Unknown chunks declared in this way will be saved as raw data onto a +list of png_unknown_chunk structures. If a chunk that is normally +known to libpng is named in the list, it will be handled as unknown, +according to the "keep" directive. If a chunk is named in successive +instances of png_set_keep_unknown_chunks(), the final instance will +take precedence. The IHDR and IEND chunks should not be named in +chunk_list; if they are, libpng will process them normally anyway. + +Here is an example of the usage of png_set_keep_unknown_chunks(), +where the private "vpAg" chunk will later be processed by a user chunk +callback function: + + png_byte vpAg[5]={118, 112, 65, 103, (png_byte) '\0'}; + + #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + png_byte unused_chunks[]= + { + 104, 73, 83, 84, (png_byte) '\0', /* hIST */ + 105, 84, 88, 116, (png_byte) '\0', /* iTXt */ + 112, 67, 65, 76, (png_byte) '\0', /* pCAL */ + 115, 67, 65, 76, (png_byte) '\0', /* sCAL */ + 115, 80, 76, 84, (png_byte) '\0', /* sPLT */ + 116, 73, 77, 69, (png_byte) '\0', /* tIME */ + }; + #endif + + ... + + #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + /* ignore all unknown chunks: */ + png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0); + /* except for vpAg: */ + png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1); + /* also ignore unused known chunks: */ + png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks, + (int)sizeof(unused_chunks)/5); + #endif + +User limits + +The PNG specification allows the width and height of an image to be as +large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. +Since very few applications really need to process such large images, +we have imposed an arbitrary 1-million limit on rows and columns. +Larger images will be rejected immediately with a png_error() call. If +you wish to override this limit, you can use + + png_set_user_limits(png_ptr, width_max, height_max); + +to set your own limits, or use width_max = height_max = 0x7fffffffL +to allow all valid dimensions (libpng may reject some very large images +anyway because of potential buffer overflow conditions). + +You should put this statement after you create the PNG structure and +before calling png_read_info(), png_read_png(), or png_process_data(). +If you need to retrieve the limits that are being applied, use + + width_max = png_get_user_width_max(png_ptr); + height_max = png_get_user_height_max(png_ptr); + +The high-level read interface + +At this point there are two ways to proceed; through the high-level +read interface, or through a sequence of low-level read operations. +You can use the high-level interface if (a) you are willing to read +the entire image into memory, and (b) the input transformations +you want to do are limited to the following set: + + PNG_TRANSFORM_IDENTITY No transformation + PNG_TRANSFORM_STRIP_16 Strip 16-bit samples to + 8 bits + PNG_TRANSFORM_STRIP_ALPHA Discard the alpha channel + PNG_TRANSFORM_PACKING Expand 1, 2 and 4-bit + samples to bytes + PNG_TRANSFORM_PACKSWAP Change order of packed + pixels to LSB first + PNG_TRANSFORM_EXPAND Perform set_expand() + PNG_TRANSFORM_INVERT_MONO Invert monochrome images + PNG_TRANSFORM_SHIFT Normalize pixels to the + sBIT depth + PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA + to BGRA + PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA + to AG + PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity + to transparency + PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples + +(This excludes setting a background color, doing gamma transformation, +dithering, and setting filler.) If this is the case, simply do this: + + png_read_png(png_ptr, info_ptr, png_transforms, NULL) + +where png_transforms is an integer containing the bitwise OR of +some set of transformation flags. This call is equivalent to png_read_info(), +followed the set of transformations indicated by the transform mask, +then png_read_image(), and finally png_read_end(). + +(The final parameter of this call is not yet used. Someday it might point +to transformation parameters required by some future input transform.) + +You must use png_transforms and not call any png_set_transform() functions +when you use png_read_png(). + +After you have called png_read_png(), you can retrieve the image data +with + + row_pointers = png_get_rows(png_ptr, info_ptr); + +where row_pointers is an array of pointers to the pixel data for each row: + + png_bytep row_pointers[height]; + +If you know your image size and pixel size ahead of time, you can allocate +row_pointers prior to calling png_read_png() with + + if (height > PNG_UINT_32_MAX/png_sizeof(png_byte)) + png_error (png_ptr, + "Image is too tall to process in memory"); + if (width > PNG_UINT_32_MAX/pixel_size) + png_error (png_ptr, + "Image is too wide to process in memory"); + row_pointers = png_malloc(png_ptr, + height*png_sizeof(png_bytep)); + for (int i=0; i) and +png_get_(png_ptr, info_ptr, ...) functions return non-zero if the +data has been read, or zero if it is missing. The parameters to the +png_get_ are set directly if they are simple data types, or a pointer +into the info_ptr is returned for any complex types. + + png_get_PLTE(png_ptr, info_ptr, &palette, + &num_palette); + palette - the palette for the file + (array of png_color) + num_palette - number of entries in the palette + + png_get_gAMA(png_ptr, info_ptr, &gamma); + gamma - the gamma the file is written + at (PNG_INFO_gAMA) + + png_get_sRGB(png_ptr, info_ptr, &srgb_intent); + srgb_intent - the rendering intent (PNG_INFO_sRGB) + The presence of the sRGB chunk + means that the pixel data is in the + sRGB color space. This chunk also + implies specific values of gAMA and + cHRM. + + png_get_iCCP(png_ptr, info_ptr, &name, + &compression_type, &profile, &proflen); + name - The profile name. + compression - The compression type; always + PNG_COMPRESSION_TYPE_BASE for PNG 1.0. + You may give NULL to this argument to + ignore it. + profile - International Color Consortium color + profile data. May contain NULs. + proflen - length of profile data in bytes. + + png_get_sBIT(png_ptr, info_ptr, &sig_bit); + sig_bit - the number of significant bits for + (PNG_INFO_sBIT) each of the gray, + red, green, and blue channels, + whichever are appropriate for the + given color type (png_color_16) + + png_get_tRNS(png_ptr, info_ptr, &trans, &num_trans, + &trans_values); + trans - array of transparent entries for + palette (PNG_INFO_tRNS) + trans_values - graylevel or color sample values of + the single transparent color for + non-paletted images (PNG_INFO_tRNS) + num_trans - number of transparent entries + (PNG_INFO_tRNS) + + png_get_hIST(png_ptr, info_ptr, &hist); + (PNG_INFO_hIST) + hist - histogram of palette (array of + png_uint_16) + + png_get_tIME(png_ptr, info_ptr, &mod_time); + mod_time - time image was last modified + (PNG_VALID_tIME) + + png_get_bKGD(png_ptr, info_ptr, &background); + background - background color (PNG_VALID_bKGD) + valid 16-bit red, green and blue + values, regardless of color_type + + num_comments = png_get_text(png_ptr, info_ptr, + &text_ptr, &num_text); + num_comments - number of comments + text_ptr - array of png_text holding image + comments + text_ptr[i].compression - type of compression used + on "text" PNG_TEXT_COMPRESSION_NONE + PNG_TEXT_COMPRESSION_zTXt + PNG_ITXT_COMPRESSION_NONE + PNG_ITXT_COMPRESSION_zTXt + text_ptr[i].key - keyword for comment. Must contain + 1-79 characters. + text_ptr[i].text - text comments for current + keyword. Can be empty. + text_ptr[i].text_length - length of text string, + after decompression, 0 for iTXt + text_ptr[i].itxt_length - length of itxt string, + after decompression, 0 for tEXt/zTXt + text_ptr[i].lang - language of comment (empty + string for unknown). + text_ptr[i].lang_key - keyword in UTF-8 + (empty string for unknown). + num_text - number of comments (same as + num_comments; you can put NULL here + to avoid the duplication) + Note while png_set_text() will accept text, language, + and translated keywords that can be NULL pointers, the + structure returned by png_get_text will always contain + regular zero-terminated C strings. They might be + empty strings but they will never be NULL pointers. + + num_spalettes = png_get_sPLT(png_ptr, info_ptr, + &palette_ptr); + palette_ptr - array of palette structures holding + contents of one or more sPLT chunks + read. + num_spalettes - number of sPLT chunks read. + + png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, + &unit_type); + offset_x - positive offset from the left edge + of the screen + offset_y - positive offset from the top edge + of the screen + unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER + + png_get_pHYs(png_ptr, info_ptr, &res_x, &res_y, + &unit_type); + res_x - pixels/unit physical resolution in + x direction + res_y - pixels/unit physical resolution in + x direction + unit_type - PNG_RESOLUTION_UNKNOWN, + PNG_RESOLUTION_METER + + png_get_sCAL(png_ptr, info_ptr, &unit, &width, + &height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are doubles) + + png_get_sCAL_s(png_ptr, info_ptr, &unit, &width, + &height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are strings like "2.54") + + num_unknown_chunks = png_get_unknown_chunks(png_ptr, + info_ptr, &unknowns) + unknowns - array of png_unknown_chunk + structures holding unknown chunks + unknowns[i].name - name of unknown chunk + unknowns[i].data - data of unknown chunk + unknowns[i].size - size of unknown chunk's data + unknowns[i].location - position of chunk in file + + The value of "i" corresponds to the order in which the + chunks were read from the PNG file or inserted with the + png_set_unknown_chunks() function. + +The data from the pHYs chunk can be retrieved in several convenient +forms: + + res_x = png_get_x_pixels_per_meter(png_ptr, + info_ptr) + res_y = png_get_y_pixels_per_meter(png_ptr, + info_ptr) + res_x_and_y = png_get_pixels_per_meter(png_ptr, + info_ptr) + res_x = png_get_x_pixels_per_inch(png_ptr, + info_ptr) + res_y = png_get_y_pixels_per_inch(png_ptr, + info_ptr) + res_x_and_y = png_get_pixels_per_inch(png_ptr, + info_ptr) + aspect_ratio = png_get_pixel_aspect_ratio(png_ptr, + info_ptr) + + (Each of these returns 0 [signifying "unknown"] if + the data is not present or if res_x is 0; + res_x_and_y is 0 if res_x != res_y) + +The data from the oFFs chunk can be retrieved in several convenient +forms: + + x_offset = png_get_x_offset_microns(png_ptr, info_ptr); + y_offset = png_get_y_offset_microns(png_ptr, info_ptr); + x_offset = png_get_x_offset_inches(png_ptr, info_ptr); + y_offset = png_get_y_offset_inches(png_ptr, info_ptr); + + (Each of these returns 0 [signifying "unknown" if both + x and y are 0] if the data is not present or if the + chunk is present but the unit is the pixel) + +For more information, see the png_info definition in png.h and the +PNG specification for chunk contents. Be careful with trusting +rowbytes, as some of the transformations could increase the space +needed to hold a row (expand, filler, gray_to_rgb, etc.). +See png_read_update_info(), below. + +A quick word about text_ptr and num_text. PNG stores comments in +keyword/text pairs, one pair per chunk, with no limit on the number +of text chunks, and a 2^31 byte limit on their size. While there are +suggested keywords, there is no requirement to restrict the use to these +strings. It is strongly suggested that keywords and text be sensible +to humans (that's the point), so don't use abbreviations. Non-printing +symbols are not allowed. See the PNG specification for more details. +There is also no requirement to have text after the keyword. + +Keywords should be limited to 79 Latin-1 characters without leading or +trailing spaces, but non-consecutive spaces are allowed within the +keyword. It is possible to have the same keyword any number of times. +The text_ptr is an array of png_text structures, each holding a +pointer to a language string, a pointer to a keyword and a pointer to +a text string. The text string, language code, and translated +keyword may be empty or NULL pointers. The keyword/text +pairs are put into the array in the order that they are received. +However, some or all of the text chunks may be after the image, so, to +make sure you have read all the text chunks, don't mess with these +until after you read the stuff after the image. This will be +mentioned again below in the discussion that goes with png_read_end(). + +Input transformations + +After you've read the header information, you can set up the library +to handle any special transformations of the image data. The various +ways to transform the data will be described in the order that they +should occur. This is important, as some of these change the color +type and/or bit depth of the data, and some others only work on +certain color types and bit depths. Even though each transformation +checks to see if it has data that it can do something with, you should +make sure to only enable a transformation if it will be valid for the +data. For example, don't swap red and blue on grayscale data. + +The colors used for the background and transparency values should be +supplied in the same format/depth as the current image data. They +are stored in the same format/depth as the image data in a bKGD or tRNS +chunk, so this is what libpng expects for this data. The colors are +transformed to keep in sync with the image data when an application +calls the png_read_update_info() routine (see below). + +Data will be decoded into the supplied row buffers packed into bytes +unless the library has been told to transform it into another format. +For example, 4 bit/pixel paletted or grayscale data will be returned +2 pixels/byte with the leftmost pixel in the high-order bits of the +byte, unless png_set_packing() is called. 8-bit RGB data will be stored +in RGB RGB RGB format unless png_set_filler() or png_set_add_alpha() +is called to insert filler bytes, either before or after each RGB triplet. +16-bit RGB data will be returned RRGGBB RRGGBB, with the most significant +byte of the color value first, unless png_set_strip_16() is called to +transform it to regular RGB RGB triplets, or png_set_filler() or +png_set_add alpha() is called to insert filler bytes, either before or +after each RRGGBB triplet. Similarly, 8-bit or 16-bit grayscale data can +be modified with +png_set_filler(), png_set_add_alpha(), or png_set_strip_16(). + +The following code transforms grayscale images of less than 8 to 8 bits, +changes paletted images to RGB, and adds a full alpha channel if there is +transparency information in a tRNS chunk. This is most useful on +grayscale images with bit depths of 2 or 4 or if there is a multiple-image +viewing application that wishes to treat all images in the same way. + + if (color_type == PNG_COLOR_TYPE_PALETTE) + png_set_palette_to_rgb(png_ptr); + + if (color_type == PNG_COLOR_TYPE_GRAY && + bit_depth < 8) png_set_expand_gray_1_2_4_to_8(png_ptr); + + if (png_get_valid(png_ptr, info_ptr, + PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png_ptr); + +These three functions are actually aliases for png_set_expand(), added +in libpng version 1.0.4, with the function names expanded to improve code +readability. In some future version they may actually do different +things. + +As of libpng version 1.2.9, png_set_expand_gray_1_2_4_to_8() was +added. It expands the sample depth without changing tRNS to alpha. + +PNG can have files with 16 bits per channel. If you only can handle +8 bits per channel, this will strip the pixels down to 8 bit. + + if (bit_depth == 16) + png_set_strip_16(png_ptr); + +If, for some reason, you don't need the alpha channel on an image, +and you want to remove it rather than combining it with the background +(but the image author certainly had in mind that you *would* combine +it with the background, so that's what you should probably do): + + if (color_type & PNG_COLOR_MASK_ALPHA) + png_set_strip_alpha(png_ptr); + +In PNG files, the alpha channel in an image +is the level of opacity. If you need the alpha channel in an image to +be the level of transparency instead of opacity, you can invert the +alpha channel (or the tRNS chunk data) after it's read, so that 0 is +fully opaque and 255 (in 8-bit or paletted images) or 65535 (in 16-bit +images) is fully transparent, with + + png_set_invert_alpha(png_ptr); + +PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as +they can, resulting in, for example, 8 pixels per byte for 1 bit +files. This code expands to 1 pixel per byte without changing the +values of the pixels: + + if (bit_depth < 8) + png_set_packing(png_ptr); + +PNG files have possible bit depths of 1, 2, 4, 8, and 16. All pixels +stored in a PNG image have been "scaled" or "shifted" up to the next +higher possible bit depth (e.g. from 5 bits/sample in the range [0,31] to +8 bits/sample in the range [0, 255]). However, it is also possible to +convert the PNG pixel data back to the original bit depth of the image. +This call reduces the pixels back down to the original bit depth: + + png_color_8p sig_bit; + + if (png_get_sBIT(png_ptr, info_ptr, &sig_bit)) + png_set_shift(png_ptr, sig_bit); + +PNG files store 3-color pixels in red, green, blue order. This code +changes the storage of the pixels to blue, green, red: + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_bgr(png_ptr); + +PNG files store RGB pixels packed into 3 or 6 bytes. This code expands them +into 4 or 8 bytes for windowing systems that need them in this format: + + if (color_type == PNG_COLOR_TYPE_RGB) + png_set_filler(png_ptr, filler, PNG_FILLER_BEFORE); + +where "filler" is the 8 or 16-bit number to fill with, and the location is +either PNG_FILLER_BEFORE or PNG_FILLER_AFTER, depending upon whether +you want the filler before the RGB or after. This transformation +does not affect images that already have full alpha channels. To add an +opaque alpha channel, use filler=0xff or 0xffff and PNG_FILLER_AFTER which +will generate RGBA pixels. + +Note that png_set_filler() does not change the color type. If you want +to do that, you can add a true alpha channel with + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_GRAY) + png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER); + +where "filler" contains the alpha value to assign to each pixel. +This function was added in libpng-1.2.7. + +If you are reading an image with an alpha channel, and you need the +data as ARGB instead of the normal PNG format RGBA: + + if (color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_swap_alpha(png_ptr); + +For some uses, you may want a grayscale image to be represented as +RGB. This code will do that conversion: + + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_gray_to_rgb(png_ptr); + +Conversely, you can convert an RGB or RGBA image to grayscale or grayscale +with alpha. + + if (color_type == PNG_COLOR_TYPE_RGB || + color_type == PNG_COLOR_TYPE_RGB_ALPHA) + png_set_rgb_to_gray_fixed(png_ptr, error_action, + int red_weight, int green_weight); + + error_action = 1: silently do the conversion + error_action = 2: issue a warning if the original + image has any pixel where + red != green or red != blue + error_action = 3: issue an error and abort the + conversion if the original + image has any pixel where + red != green or red != blue + + red_weight: weight of red component times 100000 + green_weight: weight of green component times 100000 + If either weight is negative, default + weights (21268, 71514) are used. + +If you have set error_action = 1 or 2, you can +later check whether the image really was gray, after processing +the image rows, with the png_get_rgb_to_gray_status(png_ptr) function. +It will return a png_byte that is zero if the image was gray or +1 if there were any non-gray pixels. bKGD and sBIT data +will be silently converted to grayscale, using the green channel +data, regardless of the error_action setting. + +With red_weight+green_weight<=100000, +the normalized graylevel is computed: + + int rw = red_weight * 65536; + int gw = green_weight * 65536; + int bw = 65536 - (rw + gw); + gray = (rw*red + gw*green + bw*blue)/65536; + +The default values approximate those recommended in the Charles +Poynton's Color FAQ, +Copyright (c) 1998-01-04 Charles Poynton + + Y = 0.212671 * R + 0.715160 * G + 0.072169 * B + +Libpng approximates this with + + Y = 0.21268 * R + 0.7151 * G + 0.07217 * B + +which can be expressed with integers as + + Y = (6969 * R + 23434 * G + 2365 * B)/32768 + +The calculation is done in a linear colorspace, if the image gamma +is known. + +If you have a grayscale and you are using png_set_expand_depth(), +png_set_expand(), or png_set_gray_to_rgb to change to truecolor or to +a higher bit-depth, you must either supply the background color as a gray +value at the original file bit-depth (need_expand = 1) or else supply the +background color as an RGB triplet at the final, expanded bit depth +(need_expand = 0). Similarly, if you are reading a paletted image, you +must either supply the background color as a palette index (need_expand = 1) +or as an RGB triplet that may or may not be in the palette (need_expand = 0). + + png_color_16 my_background; + png_color_16p image_background; + + if (png_get_bKGD(png_ptr, info_ptr, &image_background)) + png_set_background(png_ptr, image_background, + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + else + png_set_background(png_ptr, &my_background, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + +The png_set_background() function tells libpng to composite images +with alpha or simple transparency against the supplied background +color. If the PNG file contains a bKGD chunk (PNG_INFO_bKGD valid), +you may use this color, or supply another color more suitable for +the current display (e.g., the background color from a web page). You +need to tell libpng whether the color is in the gamma space of the +display (PNG_BACKGROUND_GAMMA_SCREEN for colors you supply), the file +(PNG_BACKGROUND_GAMMA_FILE for colors from the bKGD chunk), or one +that is neither of these gammas (PNG_BACKGROUND_GAMMA_UNIQUE - I don't +know why anyone would use this, but it's here). + +To properly display PNG images on any kind of system, the application needs +to know what the display gamma is. Ideally, the user will know this, and +the application will allow them to set it. One method of allowing the user +to set the display gamma separately for each system is to check for a +SCREEN_GAMMA or DISPLAY_GAMMA environment variable, which will hopefully be +correctly set. + +Note that display_gamma is the overall gamma correction required to produce +pleasing results, which depends on the lighting conditions in the surrounding +environment. In a dim or brightly lit room, no compensation other than +the physical gamma exponent of the monitor is needed, while in a dark room +a slightly smaller exponent is better. + + double gamma, screen_gamma; + + if (/* We have a user-defined screen + gamma value */) + { + screen_gamma = user_defined_screen_gamma; + } + /* One way that applications can share the same + screen gamma value */ + else if ((gamma_str = getenv("SCREEN_GAMMA")) + != NULL) + { + screen_gamma = (double)atof(gamma_str); + } + /* If we don't have another value */ + else + { + screen_gamma = 2.2; /* A good guess for a + PC monitor in a bright office or a dim room */ + screen_gamma = 2.0; /* A good guess for a + PC monitor in a dark room */ + screen_gamma = 1.7 or 1.0; /* A good + guess for Mac systems */ + } + +The png_set_gamma() function handles gamma transformations of the data. +Pass both the file gamma and the current screen_gamma. If the file does +not have a gamma value, you can pass one anyway if you have an idea what +it is (usually 0.45455 is a good guess for GIF images on PCs). Note +that file gammas are inverted from screen gammas. See the discussions +on gamma in the PNG specification for an excellent description of what +gamma is, and why all applications should support it. It is strongly +recommended that PNG viewers support gamma correction. + + if (png_get_gAMA(png_ptr, info_ptr, &gamma)) + png_set_gamma(png_ptr, screen_gamma, gamma); + else + png_set_gamma(png_ptr, screen_gamma, 0.45455); + +If you need to reduce an RGB file to a paletted file, or if a paletted +file has more entries then will fit on your screen, png_set_dither() +will do that. Note that this is a simple match dither that merely +finds the closest color available. This should work fairly well with +optimized palettes, and fairly badly with linear color cubes. If you +pass a palette that is larger then maximum_colors, the file will +reduce the number of colors in the palette so it will fit into +maximum_colors. If there is a histogram, it will use it to make +more intelligent choices when reducing the palette. If there is no +histogram, it may not do as good a job. + + if (color_type & PNG_COLOR_MASK_COLOR) + { + if (png_get_valid(png_ptr, info_ptr, + PNG_INFO_PLTE)) + { + png_uint_16p histogram = NULL; + + png_get_hIST(png_ptr, info_ptr, + &histogram); + png_set_dither(png_ptr, palette, num_palette, + max_screen_colors, histogram, 1); + } + else + { + png_color std_color_cube[MAX_SCREEN_COLORS] = + { ... colors ... }; + + png_set_dither(png_ptr, std_color_cube, + MAX_SCREEN_COLORS, MAX_SCREEN_COLORS, + NULL,0); + } + } + +PNG files describe monochrome as black being zero and white being one. +The following code will reverse this (make black be one and white be +zero): + + if (bit_depth == 1 && color_type == PNG_COLOR_TYPE_GRAY) + png_set_invert_mono(png_ptr); + +This function can also be used to invert grayscale and gray-alpha images: + + if (color_type == PNG_COLOR_TYPE_GRAY || + color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + png_set_invert_mono(png_ptr); + +PNG files store 16 bit pixels in network byte order (big-endian, +ie. most significant bits first). This code changes the storage to the +other way (little-endian, i.e. least significant bits first, the +way PCs store them): + + if (bit_depth == 16) + png_set_swap(png_ptr); + +If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you +need to change the order the pixels are packed into bytes, you can use: + + if (bit_depth < 8) + png_set_packswap(png_ptr); + +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_read_user_transform_fn(png_ptr, + read_transform_fn); + +You must supply the function + + void read_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +after all of the other transformations have been processed. + +You can also set up a pointer to a user structure for use by your +callback function, and you can inform libpng that your transform +function will change the number of channels or bit depth with the +function + + png_set_user_transform_info(png_ptr, user_ptr, + user_depth, user_channels); + +The user's application, not libpng, is responsible for allocating and +freeing any memory required for the user structure. + +You can retrieve the pointer via the function +png_get_user_transform_ptr(). For example: + + voidp read_user_transform_ptr = + png_get_user_transform_ptr(png_ptr); + +The last thing to handle is interlacing; this is covered in detail below, +but you must call the function here if you want libpng to handle expansion +of the interlaced image. + + number_of_passes = png_set_interlace_handling(png_ptr); + +After setting the transformations, libpng can update your png_info +structure to reflect any transformations you've requested with this +call. This is most useful to update the info structure's rowbytes +field so you can use it to allocate your image memory. This function +will also update your palette with the correct screen_gamma and +background if these have been given with the calls above. + + png_read_update_info(png_ptr, info_ptr); + +After you call png_read_update_info(), you can allocate any +memory you need to hold the image. The row data is simply +raw byte data for all forms of images. As the actual allocation +varies among applications, no example will be given. If you +are allocating one large chunk, you will need to build an +array of pointers to each row, as it will be needed for some +of the functions below. + +Reading image data + +After you've allocated memory, you can read the image data. +The simplest way to do this is in one function call. If you are +allocating enough memory to hold the whole image, you can just +call png_read_image() and libpng will read in all the image data +and put it in the memory area supplied. You will need to pass in +an array of pointers to each row. + +This function automatically handles interlacing, so you don't need +to call png_set_interlace_handling() or call this function multiple +times, or any of that other stuff necessary with png_read_rows(). + + png_read_image(png_ptr, row_pointers); + +where row_pointers is: + + png_bytep row_pointers[height]; + +You can point to void or char or whatever you use for pixels. + +If you don't want to read in the whole image at once, you can +use png_read_rows() instead. If there is no interlacing (check +interlace_type == PNG_INTERLACE_NONE), this is simple: + + png_read_rows(png_ptr, row_pointers, NULL, + number_of_rows); + +where row_pointers is the same as in the png_read_image() call. + +If you are doing this just one row at a time, you can do this with +a single row_pointer instead of an array of row_pointers: + + png_bytep row_pointer = row; + png_read_row(png_ptr, row_pointer, NULL); + +If the file is interlaced (interlace_type != 0 in the IHDR chunk), things +get somewhat harder. The only current (PNG Specification version 1.2) +interlacing type for PNG is (interlace_type == PNG_INTERLACE_ADAM7) +is a somewhat complicated 2D interlace scheme, known as Adam7, that +breaks down an image into seven smaller images of varying size, based +on an 8x8 grid. + +libpng can fill out those images or it can give them to you "as is". +If you want them filled out, there are two ways to do that. The one +mentioned in the PNG specification is to expand each pixel to cover +those pixels that have not been read yet (the "rectangle" method). +This results in a blocky image for the first pass, which gradually +smooths out as more pixels are read. The other method is the "sparkle" +method, where pixels are drawn only in their final locations, with the +rest of the image remaining whatever colors they were initialized to +before the start of the read. The first method usually looks better, +but tends to be slower, as there are more pixels to put in the rows. + +If you don't want libpng to handle the interlacing details, just call +png_read_rows() seven times to read in all seven images. Each of the +images is a valid image by itself, or they can all be combined on an +8x8 grid to form a single image (although if you intend to combine them +you would be far better off using the libpng interlace handling). + +The first pass will return an image 1/8 as wide as the entire image +(every 8th column starting in column 0) and 1/8 as high as the original +(every 8th row starting in row 0), the second will be 1/8 as wide +(starting in column 4) and 1/8 as high (also starting in row 0). The +third pass will be 1/4 as wide (every 4th pixel starting in column 0) and +1/8 as high (every 8th row starting in row 4), and the fourth pass will +be 1/4 as wide and 1/4 as high (every 4th column starting in column 2, +and every 4th row starting in row 0). The fifth pass will return an +image 1/2 as wide, and 1/4 as high (starting at column 0 and row 2), +while the sixth pass will be 1/2 as wide and 1/2 as high as the original +(starting in column 1 and row 0). The seventh and final pass will be as +wide as the original, and 1/2 as high, containing all of the odd +numbered scanlines. Phew! + +If you want libpng to expand the images, call this before calling +png_start_read_image() or png_read_update_info(): + + if (interlace_type == PNG_INTERLACE_ADAM7) + number_of_passes + = png_set_interlace_handling(png_ptr); + +This will return the number of passes needed. Currently, this +is seven, but may change if another interlace type is added. +This function can be called even if the file is not interlaced, +where it will return one pass. + +If you are not going to display the image after each pass, but are +going to wait until the entire image is read in, use the sparkle +effect. This effect is faster and the end result of either method +is exactly the same. If you are planning on displaying the image +after each pass, the "rectangle" effect is generally considered the +better looking one. + +If you only want the "sparkle" effect, just call png_read_rows() as +normal, with the third parameter NULL. Make sure you make pass over +the image number_of_passes times, and you don't change the data in the +rows between calls. You can change the locations of the data, just +not the data. Each pass only writes the pixels appropriate for that +pass, and assumes the data from previous passes is still valid. + + png_read_rows(png_ptr, row_pointers, NULL, + number_of_rows); + +If you only want the first effect (the rectangles), do the same as +before except pass the row buffer in the third parameter, and leave +the second parameter NULL. + + png_read_rows(png_ptr, NULL, row_pointers, + number_of_rows); + +Finishing a sequential read + +After you are finished reading the image through the +low-level interface, you can finish reading the file. If you are +interested in comments or time, which may be stored either before or +after the image data, you should pass the separate png_info struct if +you want to keep the comments from before and after the image +separate. If you are not interested, you can pass NULL. + + png_read_end(png_ptr, end_info); + +When you are done, you can free all memory allocated by libpng like this: + + png_destroy_read_struct(&png_ptr, &info_ptr, + &end_info); + +It is also possible to individually free the info_ptr members that +point to libpng-allocated storage with the following function: + + png_free_data(png_ptr, info_ptr, mask, seq) + mask - identifies data to be freed, a mask + containing the bitwise OR of one or + more of + PNG_FREE_PLTE, PNG_FREE_TRNS, + PNG_FREE_HIST, PNG_FREE_ICCP, + PNG_FREE_PCAL, PNG_FREE_ROWS, + PNG_FREE_SCAL, PNG_FREE_SPLT, + PNG_FREE_TEXT, PNG_FREE_UNKN, + or simply PNG_FREE_ALL + seq - sequence number of item to be freed + (-1 for all items) + +This function may be safely called when the relevant storage has +already been freed, or has not yet been allocated, or was allocated +by the user and not by libpng, and will in those +cases do nothing. The "seq" parameter is ignored if only one item +of the selected data type, such as PLTE, is allowed. If "seq" is not +-1, and multiple items are allowed for the data type identified in +the mask, such as text or sPLT, only the n'th item in the structure +is freed, where n is "seq". + +The default behavior is only to free data that was allocated internally +by libpng. This can be changed, so that libpng will not free the data, +or so that it will free data that was allocated by the user with png_malloc() +or png_zalloc() and passed in via a png_set_*() function, with + + png_data_freer(png_ptr, info_ptr, freer, mask) + mask - which data elements are affected + same choices as in png_free_data() + freer - one of + PNG_DESTROY_WILL_FREE_DATA + PNG_SET_WILL_FREE_DATA + PNG_USER_WILL_FREE_DATA + +This function only affects data that has already been allocated. +You can call this function after reading the PNG data but before calling +any png_set_*() functions, to control whether the user or the png_set_*() +function is responsible for freeing any existing data that might be present, +and again after the png_set_*() functions to control whether the user +or png_destroy_*() is supposed to free the data. When the user assumes +responsibility for libpng-allocated data, the application must use +png_free() to free it, and when the user transfers responsibility to libpng +for data that the user has allocated, the user must have used png_malloc() +or png_zalloc() to allocate it. + +If you allocated your row_pointers in a single block, as suggested above in +the description of the high level read interface, you must not transfer +responsibility for freeing it to the png_set_rows or png_read_destroy function, +because they would also try to free the individual row_pointers[i]. + +If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword +separately, do not transfer responsibility for freeing text_ptr to libpng, +because when libpng fills a png_text structure it combines these members with +the key member, and png_free_data() will free only text_ptr.key. Similarly, +if you transfer responsibility for free'ing text_ptr from libpng to your +application, your application must not separately free those members. + +The png_free_data() function will turn off the "valid" flag for anything +it frees. If you need to turn the flag off for a chunk that was freed by your +application instead of by libpng, you can use + + png_set_invalid(png_ptr, info_ptr, mask); + mask - identifies the chunks to be made invalid, + containing the bitwise OR of one or + more of + PNG_INFO_gAMA, PNG_INFO_sBIT, + PNG_INFO_cHRM, PNG_INFO_PLTE, + PNG_INFO_tRNS, PNG_INFO_bKGD, + PNG_INFO_hIST, PNG_INFO_pHYs, + PNG_INFO_oFFs, PNG_INFO_tIME, + PNG_INFO_pCAL, PNG_INFO_sRGB, + PNG_INFO_iCCP, PNG_INFO_sPLT, + PNG_INFO_sCAL, PNG_INFO_IDAT + +For a more compact example of reading a PNG image, see the file example.c. + +Reading PNG files progressively + +The progressive reader is slightly different then the non-progressive +reader. Instead of calling png_read_info(), png_read_rows(), and +png_read_end(), you make one call to png_process_data(), which calls +callbacks when it has the info, a row, or the end of the image. You +set up these callbacks with png_set_progressive_read_fn(). You don't +have to worry about the input/output functions of libpng, as you are +giving the library the data directly in png_process_data(). I will +assume that you have read the section on reading PNG files above, +so I will only highlight the differences (although I will show +all of the code). + +png_structp png_ptr; +png_infop info_ptr; + + /* An example code fragment of how you would + initialize the progressive reader in your + application. */ + int + initialize_png_reader() + { + png_ptr = png_create_read_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + if (!png_ptr) + return (ERROR); + info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_read_struct(&png_ptr, (png_infopp)NULL, + (png_infopp)NULL); + return (ERROR); + } + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + + /* This one's new. You can provide functions + to be called when the header info is valid, + when each row is completed, and when the image + is finished. If you aren't using all functions, + you can specify NULL parameters. Even when all + three functions are NULL, you need to call + png_set_progressive_read_fn(). You can use + any struct as the user_ptr (cast to a void pointer + for the function call), and retrieve the pointer + from inside the callbacks using the function + + png_get_progressive_ptr(png_ptr); + + which will return a void pointer, which you have + to cast appropriately. + */ + png_set_progressive_read_fn(png_ptr, (void *)user_ptr, + info_callback, row_callback, end_callback); + + return 0; + } + + /* A code fragment that you call as you receive blocks + of data */ + int + process_data(png_bytep buffer, png_uint_32 length) + { + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_read_struct(&png_ptr, &info_ptr, + (png_infopp)NULL); + return (ERROR); + } + + /* This one's new also. Simply give it a chunk + of data from the file stream (in order, of + course). On machines with segmented memory + models machines, don't give it any more than + 64K. The library seems to run fine with sizes + of 4K. Although you can give it much less if + necessary (I assume you can give it chunks of + 1 byte, I haven't tried less then 256 bytes + yet). When this function returns, you may + want to display any rows that were generated + in the row callback if you don't already do + so there. + */ + png_process_data(png_ptr, info_ptr, buffer, length); + return 0; + } + + /* This function is called (as set by + png_set_progressive_read_fn() above) when enough data + has been supplied so all of the header has been + read. + */ + void + info_callback(png_structp png_ptr, png_infop info) + { + /* Do any setup here, including setting any of + the transformations mentioned in the Reading + PNG files section. For now, you _must_ call + either png_start_read_image() or + png_read_update_info() after all the + transformations are set (even if you don't set + any). You may start getting rows before + png_process_data() returns, so this is your + last chance to prepare for that. + */ + } + + /* This function is called when each row of image + data is complete */ + void + row_callback(png_structp png_ptr, png_bytep new_row, + png_uint_32 row_num, int pass) + { + /* If the image is interlaced, and you turned + on the interlace handler, this function will + be called for every row in every pass. Some + of these rows will not be changed from the + previous pass. When the row is not changed, + the new_row variable will be NULL. The rows + and passes are called in order, so you don't + really need the row_num and pass, but I'm + supplying them because it may make your life + easier. + + For the non-NULL rows of interlaced images, + you must call png_progressive_combine_row() + passing in the row and the old row. You can + call this function for NULL rows (it will just + return) and for non-interlaced images (it just + does the memcpy for you) if it will make the + code easier. Thus, you can just do this for + all cases: + */ + + png_progressive_combine_row(png_ptr, old_row, + new_row); + + /* where old_row is what was displayed for + previously for the row. Note that the first + pass (pass == 0, really) will completely cover + the old row, so the rows do not have to be + initialized. After the first pass (and only + for interlaced images), you will have to pass + the current row, and the function will combine + the old row and the new row. + */ + } + + void + end_callback(png_structp png_ptr, png_infop info) + { + /* This function is called after the whole image + has been read, including any chunks after the + image (up to and including the IEND). You + will usually have the same info chunk as you + had in the header, although some data may have + been added to the comments and time fields. + + Most people won't do much here, perhaps setting + a flag that marks the image as finished. + */ + } + + + +IV. Writing + +Much of this is very similar to reading. However, everything of +importance is repeated here, so you won't have to constantly look +back up in the reading section to understand writing. + +Setup + +You will want to do the I/O initialization before you get into libpng, +so if it doesn't work, you don't have anything to undo. If you are not +using the standard I/O functions, you will need to replace them with +custom writing functions. See the discussion under Customizing libpng. + + FILE *fp = fopen(file_name, "wb"); + if (!fp) + { + return (ERROR); + } + +Next, png_struct and png_info need to be allocated and initialized. +As these can be both relatively large, you may not want to store these +on the stack, unless you have stack space to spare. Of course, you +will want to check if they return NULL. If you are also reading, +you won't want to name your read structure and your write structure +both "png_ptr"; you can call them anything you like, such as +"read_ptr" and "write_ptr". Look at pngtest.c, for example. + + png_structp png_ptr = png_create_write_struct + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn); + if (!png_ptr) + return (ERROR); + + png_infop info_ptr = png_create_info_struct(png_ptr); + if (!info_ptr) + { + png_destroy_write_struct(&png_ptr, + (png_infopp)NULL); + return (ERROR); + } + +If you want to use your own memory allocation routines, +define PNG_USER_MEM_SUPPORTED and use +png_create_write_struct_2() instead of png_create_write_struct(): + + png_structp png_ptr = png_create_write_struct_2 + (PNG_LIBPNG_VER_STRING, (png_voidp)user_error_ptr, + user_error_fn, user_warning_fn, (png_voidp) + user_mem_ptr, user_malloc_fn, user_free_fn); + +After you have these structures, you will need to set up the +error handling. When libpng encounters an error, it expects to +longjmp() back to your routine. Therefore, you will need to call +setjmp() and pass the png_jmpbuf(png_ptr). If you +write the file from different routines, you will need to update +the png_jmpbuf(png_ptr) every time you enter a new routine that will +call a png_*() function. See your documentation of setjmp/longjmp +for your compiler for more information on setjmp/longjmp. See +the discussion on libpng error handling in the Customizing Libpng +section below for more information on the libpng error handling. + + if (setjmp(png_jmpbuf(png_ptr))) + { + png_destroy_write_struct(&png_ptr, &info_ptr); + fclose(fp); + return (ERROR); + } + ... + return; + +If you would rather avoid the complexity of setjmp/longjmp issues, +you can compile libpng with PNG_SETJMP_NOT_SUPPORTED, in which case +errors will result in a call to PNG_ABORT() which defaults to abort(). + +Now you need to set up the output code. The default for libpng is to +use the C function fwrite(). If you use this, you will need to pass a +valid FILE * in the function png_init_io(). Be sure that the file is +opened in binary mode. Again, if you wish to handle writing data in +another way, see the discussion on libpng I/O handling in the Customizing +Libpng section below. + + png_init_io(png_ptr, fp); + +If you are embedding your PNG into a datastream such as MNG, and don't +want libpng to write the 8-byte signature, or if you have already +written the signature in your application, use + + png_set_sig_bytes(png_ptr, 8); + +to inform libpng that it should not write a signature. + +Write callbacks + +At this point, you can set up a callback function that will be +called after each row has been written, which you can use to control +a progress meter or the like. It's demonstrated in pngtest.c. +You must supply a function + + void write_row_callback(png_ptr, png_uint_32 row, + int pass); + { + /* put your code here */ + } + +(You can give it another name that you like instead of "write_row_callback") + +To inform libpng about your function, use + + png_set_write_status_fn(png_ptr, write_row_callback); + +You now have the option of modifying how the compression library will +run. The following functions are mainly for testing, but may be useful +in some cases, like if you need to write PNG files extremely fast and +are willing to give up some compression, or if you want to get the +maximum possible compression at the expense of slower writing. If you +have no special needs in this area, let the library do what it wants by +not calling this function at all, as it has been tuned to deliver a good +speed/compression ratio. The second parameter to png_set_filter() is +the filter method, for which the only valid values are 0 (as of the +July 1999 PNG specification, version 1.2) or 64 (if you are writing +a PNG datastream that is to be embedded in a MNG datastream). The third +parameter is a flag that indicates which filter type(s) are to be tested +for each scanline. See the PNG specification for details on the specific filter +types. + + + /* turn on or off filtering, and/or choose + specific filters. You can use either a single + PNG_FILTER_VALUE_NAME or the bitwise OR of one + or more PNG_FILTER_NAME masks. */ + png_set_filter(png_ptr, 0, + PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE | + PNG_FILTER_SUB | PNG_FILTER_VALUE_SUB | + PNG_FILTER_UP | PNG_FILTER_VALUE_UP | + PNG_FILTER_AVG | PNG_FILTER_VALUE_AVG | + PNG_FILTER_PAETH | PNG_FILTER_VALUE_PAETH| + PNG_ALL_FILTERS); + +If an application +wants to start and stop using particular filters during compression, +it should start out with all of the filters (to ensure that the previous +row of pixels will be stored in case it's needed later), and then add +and remove them after the start of compression. + +If you are writing a PNG datastream that is to be embedded in a MNG +datastream, the second parameter can be either 0 or 64. + +The png_set_compression_*() functions interface to the zlib compression +library, and should mostly be ignored unless you really know what you are +doing. The only generally useful call is png_set_compression_level() +which changes how much time zlib spends on trying to compress the image +data. See the Compression Library (zlib.h and algorithm.txt, distributed +with zlib) for details on the compression levels. + + /* set the zlib compression level */ + png_set_compression_level(png_ptr, + Z_BEST_COMPRESSION); + + /* set other zlib parameters */ + png_set_compression_mem_level(png_ptr, 8); + png_set_compression_strategy(png_ptr, + Z_DEFAULT_STRATEGY); + png_set_compression_window_bits(png_ptr, 15); + png_set_compression_method(png_ptr, 8); + png_set_compression_buffer_size(png_ptr, 8192) + +extern PNG_EXPORT(void,png_set_zbuf_size) + +Setting the contents of info for output + +You now need to fill in the png_info structure with all the data you +wish to write before the actual image. Note that the only thing you +are allowed to write after the image is the text chunks and the time +chunk (as of PNG Specification 1.2, anyway). See png_write_end() and +the latest PNG specification for more information on that. If you +wish to write them before the image, fill them in now, and flag that +data as being valid. If you want to wait until after the data, don't +fill them until png_write_end(). For all the fields in png_info and +their data types, see png.h. For explanations of what the fields +contain, see the PNG specification. + +Some of the more important parts of the png_info are: + + png_set_IHDR(png_ptr, info_ptr, width, height, + bit_depth, color_type, interlace_type, + compression_type, filter_method) + width - holds the width of the image + in pixels (up to 2^31). + height - holds the height of the image + in pixels (up to 2^31). + bit_depth - holds the bit depth of one of the + image channels. + (valid values are 1, 2, 4, 8, 16 + and depend also on the + color_type. See also significant + bits (sBIT) below). + color_type - describes which color/alpha + channels are present. + PNG_COLOR_TYPE_GRAY + (bit depths 1, 2, 4, 8, 16) + PNG_COLOR_TYPE_GRAY_ALPHA + (bit depths 8, 16) + PNG_COLOR_TYPE_PALETTE + (bit depths 1, 2, 4, 8) + PNG_COLOR_TYPE_RGB + (bit_depths 8, 16) + PNG_COLOR_TYPE_RGB_ALPHA + (bit_depths 8, 16) + + PNG_COLOR_MASK_PALETTE + PNG_COLOR_MASK_COLOR + PNG_COLOR_MASK_ALPHA + + interlace_type - PNG_INTERLACE_NONE or + PNG_INTERLACE_ADAM7 + compression_type - (must be + PNG_COMPRESSION_TYPE_DEFAULT) + filter_method - (must be PNG_FILTER_TYPE_DEFAULT + or, if you are writing a PNG to + be embedded in a MNG datastream, + can also be + PNG_INTRAPIXEL_DIFFERENCING) + +If you call png_set_IHDR(), the call must appear before any of the +other png_set_*() functions, because they might require access to some of +the IHDR settings. The remaining png_set_*() functions can be called +in any order. + +If you wish, you can reset the compression_type, interlace_type, or +filter_method later by calling png_set_IHDR() again; if you do this, the +width, height, bit_depth, and color_type must be the same in each call. + + png_set_PLTE(png_ptr, info_ptr, palette, + num_palette); + palette - the palette for the file + (array of png_color) + num_palette - number of entries in the palette + + png_set_gAMA(png_ptr, info_ptr, gamma); + gamma - the gamma the image was created + at (PNG_INFO_gAMA) + + png_set_sRGB(png_ptr, info_ptr, srgb_intent); + srgb_intent - the rendering intent + (PNG_INFO_sRGB) The presence of + the sRGB chunk means that the pixel + data is in the sRGB color space. + This chunk also implies specific + values of gAMA and cHRM. Rendering + intent is the CSS-1 property that + has been defined by the International + Color Consortium + (http://www.color.org). + It can be one of + PNG_sRGB_INTENT_SATURATION, + PNG_sRGB_INTENT_PERCEPTUAL, + PNG_sRGB_INTENT_ABSOLUTE, or + PNG_sRGB_INTENT_RELATIVE. + + + png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, + srgb_intent); + srgb_intent - the rendering intent + (PNG_INFO_sRGB) The presence of the + sRGB chunk means that the pixel + data is in the sRGB color space. + This function also causes gAMA and + cHRM chunks with the specific values + that are consistent with sRGB to be + written. + + png_set_iCCP(png_ptr, info_ptr, name, compression_type, + profile, proflen); + name - The profile name. + compression - The compression type; always + PNG_COMPRESSION_TYPE_BASE for PNG 1.0. + You may give NULL to this argument to + ignore it. + profile - International Color Consortium color + profile data. May contain NULs. + proflen - length of profile data in bytes. + + png_set_sBIT(png_ptr, info_ptr, sig_bit); + sig_bit - the number of significant bits for + (PNG_INFO_sBIT) each of the gray, red, + green, and blue channels, whichever are + appropriate for the given color type + (png_color_16) + + png_set_tRNS(png_ptr, info_ptr, trans, num_trans, + trans_values); + trans - array of transparent entries for + palette (PNG_INFO_tRNS) + trans_values - graylevel or color sample values + (in order red, green, blue) of the + single transparent color for + non-paletted images (PNG_INFO_tRNS) + num_trans - number of transparent entries + (PNG_INFO_tRNS) + + png_set_hIST(png_ptr, info_ptr, hist); + (PNG_INFO_hIST) + hist - histogram of palette (array of + png_uint_16) + + png_set_tIME(png_ptr, info_ptr, mod_time); + mod_time - time image was last modified + (PNG_VALID_tIME) + + png_set_bKGD(png_ptr, info_ptr, background); + background - background color (PNG_VALID_bKGD) + + png_set_text(png_ptr, info_ptr, text_ptr, num_text); + text_ptr - array of png_text holding image + comments + text_ptr[i].compression - type of compression used + on "text" PNG_TEXT_COMPRESSION_NONE + PNG_TEXT_COMPRESSION_zTXt + PNG_ITXT_COMPRESSION_NONE + PNG_ITXT_COMPRESSION_zTXt + text_ptr[i].key - keyword for comment. Must contain + 1-79 characters. + text_ptr[i].text - text comments for current + keyword. Can be NULL or empty. + text_ptr[i].text_length - length of text string, + after decompression, 0 for iTXt + text_ptr[i].itxt_length - length of itxt string, + after decompression, 0 for tEXt/zTXt + text_ptr[i].lang - language of comment (NULL or + empty for unknown). + text_ptr[i].translated_keyword - keyword in UTF-8 (NULL + or empty for unknown). + num_text - number of comments + + png_set_sPLT(png_ptr, info_ptr, &palette_ptr, + num_spalettes); + palette_ptr - array of png_sPLT_struct structures + to be added to the list of palettes + in the info structure. + num_spalettes - number of palette structures to be + added. + + png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, + unit_type); + offset_x - positive offset from the left + edge of the screen + offset_y - positive offset from the top + edge of the screen + unit_type - PNG_OFFSET_PIXEL, PNG_OFFSET_MICROMETER + + png_set_pHYs(png_ptr, info_ptr, res_x, res_y, + unit_type); + res_x - pixels/unit physical resolution + in x direction + res_y - pixels/unit physical resolution + in y direction + unit_type - PNG_RESOLUTION_UNKNOWN, + PNG_RESOLUTION_METER + + png_set_sCAL(png_ptr, info_ptr, unit, width, height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are doubles) + + png_set_sCAL_s(png_ptr, info_ptr, unit, width, height) + unit - physical scale units (an integer) + width - width of a pixel in physical scale units + height - height of a pixel in physical scale units + (width and height are strings like "2.54") + + png_set_unknown_chunks(png_ptr, info_ptr, &unknowns, + num_unknowns) + unknowns - array of png_unknown_chunk + structures holding unknown chunks + unknowns[i].name - name of unknown chunk + unknowns[i].data - data of unknown chunk + unknowns[i].size - size of unknown chunk's data + unknowns[i].location - position to write chunk in file + 0: do not write chunk + PNG_HAVE_IHDR: before PLTE + PNG_HAVE_PLTE: before IDAT + PNG_AFTER_IDAT: after IDAT + +The "location" member is set automatically according to +what part of the output file has already been written. +You can change its value after calling png_set_unknown_chunks() +as demonstrated in pngtest.c. Within each of the "locations", +the chunks are sequenced according to their position in the +structure (that is, the value of "i", which is the order in which +the chunk was either read from the input file or defined with +png_set_unknown_chunks). + +A quick word about text and num_text. text is an array of png_text +structures. num_text is the number of valid structures in the array. +Each png_text structure holds a language code, a keyword, a text value, +and a compression type. + +The compression types have the same valid numbers as the compression +types of the image data. Currently, the only valid number is zero. +However, you can store text either compressed or uncompressed, unlike +images, which always have to be compressed. So if you don't want the +text compressed, set the compression type to PNG_TEXT_COMPRESSION_NONE. +Because tEXt and zTXt chunks don't have a language field, if you +specify PNG_TEXT_COMPRESSION_NONE or PNG_TEXT_COMPRESSION_zTXt +any language code or translated keyword will not be written out. + +Until text gets around 1000 bytes, it is not worth compressing it. +After the text has been written out to the file, the compression type +is set to PNG_TEXT_COMPRESSION_NONE_WR or PNG_TEXT_COMPRESSION_zTXt_WR, +so that it isn't written out again at the end (in case you are calling +png_write_end() with the same struct. + +The keywords that are given in the PNG Specification are: + + Title Short (one line) title or + caption for image + Author Name of image's creator + Description Description of image (possibly long) + Copyright Copyright notice + Creation Time Time of original image creation + (usually RFC 1123 format, see below) + Software Software used to create the image + Disclaimer Legal disclaimer + Warning Warning of nature of content + Source Device used to create the image + Comment Miscellaneous comment; conversion + from other image format + +The keyword-text pairs work like this. Keywords should be short +simple descriptions of what the comment is about. Some typical +keywords are found in the PNG specification, as is some recommendations +on keywords. You can repeat keywords in a file. You can even write +some text before the image and some after. For example, you may want +to put a description of the image before the image, but leave the +disclaimer until after, so viewers working over modem connections +don't have to wait for the disclaimer to go over the modem before +they start seeing the image. Finally, keywords should be full +words, not abbreviations. Keywords and text are in the ISO 8859-1 +(Latin-1) character set (a superset of regular ASCII) and can not +contain NUL characters, and should not contain control or other +unprintable characters. To make the comments widely readable, stick +with basic ASCII, and avoid machine specific character set extensions +like the IBM-PC character set. The keyword must be present, but +you can leave off the text string on non-compressed pairs. +Compressed pairs must have a text string, as only the text string +is compressed anyway, so the compression would be meaningless. + +PNG supports modification time via the png_time structure. Two +conversion routines are provided, png_convert_from_time_t() for +time_t and png_convert_from_struct_tm() for struct tm. The +time_t routine uses gmtime(). You don't have to use either of +these, but if you wish to fill in the png_time structure directly, +you should provide the time in universal time (GMT) if possible +instead of your local time. Note that the year number is the full +year (e.g. 1998, rather than 98 - PNG is year 2000 compliant!), and +that months start with 1. + +If you want to store the time of the original image creation, you should +use a plain tEXt chunk with the "Creation Time" keyword. This is +necessary because the "creation time" of a PNG image is somewhat vague, +depending on whether you mean the PNG file, the time the image was +created in a non-PNG format, a still photo from which the image was +scanned, or possibly the subject matter itself. In order to facilitate +machine-readable dates, it is recommended that the "Creation Time" +tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"), +although this isn't a requirement. Unlike the tIME chunk, the +"Creation Time" tEXt chunk is not expected to be automatically changed +by the software. To facilitate the use of RFC 1123 dates, a function +png_convert_to_rfc1123(png_timep) is provided to convert from PNG +time to an RFC 1123 format string. + +Writing unknown chunks + +You can use the png_set_unknown_chunks function to queue up chunks +for writing. You give it a chunk name, raw data, and a size; that's +all there is to it. The chunks will be written by the next following +png_write_info_before_PLTE, png_write_info, or png_write_end function. +Any chunks previously read into the info structure's unknown-chunk +list will also be written out in a sequence that satisfies the PNG +specification's ordering rules. + +The high-level write interface + +At this point there are two ways to proceed; through the high-level +write interface, or through a sequence of low-level write operations. +You can use the high-level interface if your image data is present +in the info structure. All defined output +transformations are permitted, enabled by the following masks. + + PNG_TRANSFORM_IDENTITY No transformation + PNG_TRANSFORM_PACKING Pack 1, 2 and 4-bit samples + PNG_TRANSFORM_PACKSWAP Change order of packed + pixels to LSB first + PNG_TRANSFORM_INVERT_MONO Invert monochrome images + PNG_TRANSFORM_SHIFT Normalize pixels to the + sBIT depth + PNG_TRANSFORM_BGR Flip RGB to BGR, RGBA + to BGRA + PNG_TRANSFORM_SWAP_ALPHA Flip RGBA to ARGB or GA + to AG + PNG_TRANSFORM_INVERT_ALPHA Change alpha from opacity + to transparency + PNG_TRANSFORM_SWAP_ENDIAN Byte-swap 16-bit samples + PNG_TRANSFORM_STRIP_FILLER Strip out filler + bytes (deprecated). + PNG_TRANSFORM_STRIP_FILLER_BEFORE Strip out leading + filler bytes + PNG_TRANSFORM_STRIP_FILLER_AFTER Strip out trailing + filler bytes + +If you have valid image data in the info structure (you can use +png_set_rows() to put image data in the info structure), simply do this: + + png_write_png(png_ptr, info_ptr, png_transforms, NULL) + +where png_transforms is an integer containing the bitwise OR of some set of +transformation flags. This call is equivalent to png_write_info(), +followed the set of transformations indicated by the transform mask, +then png_write_image(), and finally png_write_end(). + +(The final parameter of this call is not yet used. Someday it might point +to transformation parameters required by some future output transform.) + +You must use png_transforms and not call any png_set_transform() functions +when you use png_write_png(). + +The low-level write interface + +If you are going the low-level route instead, you are now ready to +write all the file information up to the actual image data. You do +this with a call to png_write_info(). + + png_write_info(png_ptr, info_ptr); + +Note that there is one transformation you may need to do before +png_write_info(). In PNG files, the alpha channel in an image is the +level of opacity. If your data is supplied as a level of +transparency, you can invert the alpha channel before you write it, so +that 0 is fully transparent and 255 (in 8-bit or paletted images) or +65535 (in 16-bit images) is fully opaque, with + + png_set_invert_alpha(png_ptr); + +This must appear before png_write_info() instead of later with the +other transformations because in the case of paletted images the tRNS +chunk data has to be inverted before the tRNS chunk is written. If +your image is not a paletted image, the tRNS data (which in such cases +represents a single color to be rendered as transparent) won't need to +be changed, and you can safely do this transformation after your +png_write_info() call. + +If you need to write a private chunk that you want to appear before +the PLTE chunk when PLTE is present, you can write the PNG info in +two steps, and insert code to write your own chunk between them: + + png_write_info_before_PLTE(png_ptr, info_ptr); + png_set_unknown_chunks(png_ptr, info_ptr, ...); + png_write_info(png_ptr, info_ptr); + +After you've written the file information, you can set up the library +to handle any special transformations of the image data. The various +ways to transform the data will be described in the order that they +should occur. This is important, as some of these change the color +type and/or bit depth of the data, and some others only work on +certain color types and bit depths. Even though each transformation +checks to see if it has data that it can do something with, you should +make sure to only enable a transformation if it will be valid for the +data. For example, don't swap red and blue on grayscale data. + +PNG files store RGB pixels packed into 3 or 6 bytes. This code tells +the library to strip input data that has 4 or 8 bytes per pixel down +to 3 or 6 bytes (or strip 2 or 4-byte grayscale+filler data to 1 or 2 +bytes per pixel). + + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); + +where the 0 is unused, and the location is either PNG_FILLER_BEFORE or +PNG_FILLER_AFTER, depending upon whether the filler byte in the pixel +is stored XRGB or RGBX. + +PNG files pack pixels of bit depths 1, 2, and 4 into bytes as small as +they can, resulting in, for example, 8 pixels per byte for 1 bit files. +If the data is supplied at 1 pixel per byte, use this code, which will +correctly pack the pixels into a single byte: + + png_set_packing(png_ptr); + +PNG files reduce possible bit depths to 1, 2, 4, 8, and 16. If your +data is of another bit depth, you can write an sBIT chunk into the +file so that decoders can recover the original data if desired. + + /* Set the true bit depth of the image data */ + if (color_type & PNG_COLOR_MASK_COLOR) + { + sig_bit.red = true_bit_depth; + sig_bit.green = true_bit_depth; + sig_bit.blue = true_bit_depth; + } + else + { + sig_bit.gray = true_bit_depth; + } + if (color_type & PNG_COLOR_MASK_ALPHA) + { + sig_bit.alpha = true_bit_depth; + } + + png_set_sBIT(png_ptr, info_ptr, &sig_bit); + +If the data is stored in the row buffer in a bit depth other than +one supported by PNG (e.g. 3 bit data in the range 0-7 for a 4-bit PNG), +this will scale the values to appear to be the correct bit depth as +is required by PNG. + + png_set_shift(png_ptr, &sig_bit); + +PNG files store 16 bit pixels in network byte order (big-endian, +ie. most significant bits first). This code would be used if they are +supplied the other way (little-endian, i.e. least significant bits +first, the way PCs store them): + + if (bit_depth > 8) + png_set_swap(png_ptr); + +If you are using packed-pixel images (1, 2, or 4 bits/pixel), and you +need to change the order the pixels are packed into bytes, you can use: + + if (bit_depth < 8) + png_set_packswap(png_ptr); + +PNG files store 3 color pixels in red, green, blue order. This code +would be used if they are supplied as blue, green, red: + + png_set_bgr(png_ptr); + +PNG files describe monochrome as black being zero and white being +one. This code would be used if the pixels are supplied with this reversed +(black being one and white being zero): + + png_set_invert_mono(png_ptr); + +Finally, you can write your own transformation function if none of +the existing ones meets your needs. This is done by setting a callback +with + + png_set_write_user_transform_fn(png_ptr, + write_transform_fn); + +You must supply the function + + void write_transform_fn(png_ptr ptr, row_info_ptr + row_info, png_bytep data) + +See pngtest.c for a working example. Your function will be called +before any of the other transformations are processed. + +You can also set up a pointer to a user structure for use by your +callback function. + + png_set_user_transform_info(png_ptr, user_ptr, 0, 0); + +The user_channels and user_depth parameters of this function are ignored +when writing; you can set them to zero as shown. + +You can retrieve the pointer via the function png_get_user_transform_ptr(). +For example: + + voidp write_user_transform_ptr = + png_get_user_transform_ptr(png_ptr); + +It is possible to have libpng flush any pending output, either manually, +or automatically after a certain number of lines have been written. To +flush the output stream a single time call: + + png_write_flush(png_ptr); + +and to have libpng flush the output stream periodically after a certain +number of scanlines have been written, call: + + png_set_flush(png_ptr, nrows); + +Note that the distance between rows is from the last time png_write_flush() +was called, or the first row of the image if it has never been called. +So if you write 50 lines, and then png_set_flush 25, it will flush the +output on the next scanline, and every 25 lines thereafter, unless +png_write_flush() is called before 25 more lines have been written. +If nrows is too small (less than about 10 lines for a 640 pixel wide +RGB image) the image compression may decrease noticeably (although this +may be acceptable for real-time applications). Infrequent flushing will +only degrade the compression performance by a few percent over images +that do not use flushing. + +Writing the image data + +That's it for the transformations. Now you can write the image data. +The simplest way to do this is in one function call. If you have the +whole image in memory, you can just call png_write_image() and libpng +will write the image. You will need to pass in an array of pointers to +each row. This function automatically handles interlacing, so you don't +need to call png_set_interlace_handling() or call this function multiple +times, or any of that other stuff necessary with png_write_rows(). + + png_write_image(png_ptr, row_pointers); + +where row_pointers is: + + png_byte *row_pointers[height]; + +You can point to void or char or whatever you use for pixels. + +If you don't want to write the whole image at once, you can +use png_write_rows() instead. If the file is not interlaced, +this is simple: + + png_write_rows(png_ptr, row_pointers, + number_of_rows); + +row_pointers is the same as in the png_write_image() call. + +If you are just writing one row at a time, you can do this with +a single row_pointer instead of an array of row_pointers: + + png_bytep row_pointer = row; + + png_write_row(png_ptr, row_pointer); + +When the file is interlaced, things can get a good deal more +complicated. The only currently (as of the PNG Specification +version 1.2, dated July 1999) defined interlacing scheme for PNG files +is the "Adam7" interlace scheme, that breaks down an +image into seven smaller images of varying size. libpng will build +these images for you, or you can do them yourself. If you want to +build them yourself, see the PNG specification for details of which +pixels to write when. + +If you don't want libpng to handle the interlacing details, just +use png_set_interlace_handling() and call png_write_rows() the +correct number of times to write all seven sub-images. + +If you want libpng to build the sub-images, call this before you start +writing any rows: + + number_of_passes = + png_set_interlace_handling(png_ptr); + +This will return the number of passes needed. Currently, this +is seven, but may change if another interlace type is added. + +Then write the complete image number_of_passes times. + + png_write_rows(png_ptr, row_pointers, + number_of_rows); + +As some of these rows are not used, and thus return immediately, +you may want to read about interlacing in the PNG specification, +and only update the rows that are actually used. + +Finishing a sequential write + +After you are finished writing the image, you should finish writing +the file. If you are interested in writing comments or time, you should +pass an appropriately filled png_info pointer. If you are not interested, +you can pass NULL. + + png_write_end(png_ptr, info_ptr); + +When you are done, you can free all memory used by libpng like this: + + png_destroy_write_struct(&png_ptr, &info_ptr); + +It is also possible to individually free the info_ptr members that +point to libpng-allocated storage with the following function: + + png_free_data(png_ptr, info_ptr, mask, seq) + mask - identifies data to be freed, a mask + containing the bitwise OR of one or + more of + PNG_FREE_PLTE, PNG_FREE_TRNS, + PNG_FREE_HIST, PNG_FREE_ICCP, + PNG_FREE_PCAL, PNG_FREE_ROWS, + PNG_FREE_SCAL, PNG_FREE_SPLT, + PNG_FREE_TEXT, PNG_FREE_UNKN, + or simply PNG_FREE_ALL + seq - sequence number of item to be freed + (-1 for all items) + +This function may be safely called when the relevant storage has +already been freed, or has not yet been allocated, or was allocated +by the user and not by libpng, and will in those +cases do nothing. The "seq" parameter is ignored if only one item +of the selected data type, such as PLTE, is allowed. If "seq" is not +-1, and multiple items are allowed for the data type identified in +the mask, such as text or sPLT, only the n'th item in the structure +is freed, where n is "seq". + +If you allocated data such as a palette that you passed +in to libpng with png_set_*, you must not free it until just before the call to +png_destroy_write_struct(). + +The default behavior is only to free data that was allocated internally +by libpng. This can be changed, so that libpng will not free the data, +or so that it will free data that was allocated by the user with png_malloc() +or png_zalloc() and passed in via a png_set_*() function, with + + png_data_freer(png_ptr, info_ptr, freer, mask) + mask - which data elements are affected + same choices as in png_free_data() + freer - one of + PNG_DESTROY_WILL_FREE_DATA + PNG_SET_WILL_FREE_DATA + PNG_USER_WILL_FREE_DATA + +For example, to transfer responsibility for some data from a read structure +to a write structure, you could use + + png_data_freer(read_ptr, read_info_ptr, + PNG_USER_WILL_FREE_DATA, + PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) + png_data_freer(write_ptr, write_info_ptr, + PNG_DESTROY_WILL_FREE_DATA, + PNG_FREE_PLTE|PNG_FREE_tRNS|PNG_FREE_hIST) + +thereby briefly reassigning responsibility for freeing to the user but +immediately afterwards reassigning it once more to the write_destroy +function. Having done this, it would then be safe to destroy the read +structure and continue to use the PLTE, tRNS, and hIST data in the write +structure. + +This function only affects data that has already been allocated. +You can call this function before calling after the png_set_*() functions +to control whether the user or png_destroy_*() is supposed to free the data. +When the user assumes responsibility for libpng-allocated data, the +application must use +png_free() to free it, and when the user transfers responsibility to libpng +for data that the user has allocated, the user must have used png_malloc() +or png_zalloc() to allocate it. + +If you allocated text_ptr.text, text_ptr.lang, and text_ptr.translated_keyword +separately, do not transfer responsibility for freeing text_ptr to libpng, +because when libpng fills a png_text structure it combines these members with +the key member, and png_free_data() will free only text_ptr.key. Similarly, +if you transfer responsibility for free'ing text_ptr from libpng to your +application, your application must not separately free those members. +For a more compact example of writing a PNG image, see the file example.c. + +V. Modifying/Customizing libpng: + +There are two issues here. The first is changing how libpng does +standard things like memory allocation, input/output, and error handling. +The second deals with more complicated things like adding new chunks, +adding new transformations, and generally changing how libpng works. +Both of those are compile-time issues; that is, they are generally +determined at the time the code is written, and there is rarely a need +to provide the user with a means of changing them. + +Memory allocation, input/output, and error handling + +All of the memory allocation, input/output, and error handling in libpng +goes through callbacks that are user-settable. The default routines are +in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively. To change +these functions, call the appropriate png_set_*_fn() function. + +Memory allocation is done through the functions png_malloc() +and png_free(). These currently just call the standard C functions. If +your pointers can't access more then 64K at a time, you will want to set +MAXSEG_64K in zlib.h. Since it is unlikely that the method of handling +memory allocation on a platform will change between applications, these +functions must be modified in the library at compile time. If you prefer +to use a different method of allocating and freeing data, you can use +png_create_read_struct_2() or png_create_write_struct_2() to register +your own functions as described above. +These functions also provide a void pointer that can be retrieved via + + mem_ptr=png_get_mem_ptr(png_ptr); + +Your replacement memory functions must have prototypes as follows: + + png_voidp malloc_fn(png_structp png_ptr, + png_size_t size); + void free_fn(png_structp png_ptr, png_voidp ptr); + +Your malloc_fn() must return NULL in case of failure. The png_malloc() +function will normally call png_error() if it receives a NULL from the +system memory allocator or from your replacement malloc_fn(). + +Your free_fn() will never be called with a NULL ptr, since libpng's +png_free() checks for NULL before calling free_fn(). + +Input/Output in libpng is done through png_read() and png_write(), +which currently just call fread() and fwrite(). The FILE * is stored in +png_struct and is initialized via png_init_io(). If you wish to change +the method of I/O, the library supplies callbacks that you can set +through the function png_set_read_fn() and png_set_write_fn() at run +time, instead of calling the png_init_io() function. These functions +also provide a void pointer that can be retrieved via the function +png_get_io_ptr(). For example: + + png_set_read_fn(png_structp read_ptr, + voidp read_io_ptr, png_rw_ptr read_data_fn) + + png_set_write_fn(png_structp write_ptr, + voidp write_io_ptr, png_rw_ptr write_data_fn, + png_flush_ptr output_flush_fn); + + voidp read_io_ptr = png_get_io_ptr(read_ptr); + voidp write_io_ptr = png_get_io_ptr(write_ptr); + +The replacement I/O functions must have prototypes as follows: + + void user_read_data(png_structp png_ptr, + png_bytep data, png_size_t length); + void user_write_data(png_structp png_ptr, + png_bytep data, png_size_t length); + void user_flush_data(png_structp png_ptr); + +The user_read_data() function is responsible for detecting and +handling end-of-data errors. + +Supplying NULL for the read, write, or flush functions sets them back +to using the default C stream functions, which expect the io_ptr to +point to a standard *FILE structure. It is probably a mistake +to use NULL for one of write_data_fn and output_flush_fn but not both +of them, unless you have built libpng with PNG_NO_WRITE_FLUSH defined. +It is an error to read from a write stream, and vice versa. + +Error handling in libpng is done through png_error() and png_warning(). +Errors handled through png_error() are fatal, meaning that png_error() +should never return to its caller. Currently, this is handled via +setjmp() and longjmp() (unless you have compiled libpng with +PNG_SETJMP_NOT_SUPPORTED, in which case it is handled via PNG_ABORT()), +but you could change this to do things like exit() if you should wish. + +On non-fatal errors, png_warning() is called +to print a warning message, and then control returns to the calling code. +By default png_error() and png_warning() print a message on stderr via +fprintf() unless the library is compiled with PNG_NO_CONSOLE_IO defined +(because you don't want the messages) or PNG_NO_STDIO defined (because +fprintf() isn't available). If you wish to change the behavior of the error +functions, you will need to set up your own message callbacks. These +functions are normally supplied at the time that the png_struct is created. +It is also possible to redirect errors and warnings to your own replacement +functions after png_create_*_struct() has been called by calling: + + png_set_error_fn(png_structp png_ptr, + png_voidp error_ptr, png_error_ptr error_fn, + png_error_ptr warning_fn); + + png_voidp error_ptr = png_get_error_ptr(png_ptr); + +If NULL is supplied for either error_fn or warning_fn, then the libpng +default function will be used, calling fprintf() and/or longjmp() if a +problem is encountered. The replacement error functions should have +parameters as follows: + + void user_error_fn(png_structp png_ptr, + png_const_charp error_msg); + void user_warning_fn(png_structp png_ptr, + png_const_charp warning_msg); + +The motivation behind using setjmp() and longjmp() is the C++ throw and +catch exception handling methods. This makes the code much easier to write, +as there is no need to check every return code of every function call. +However, there are some uncertainties about the status of local variables +after a longjmp, so the user may want to be careful about doing anything after +setjmp returns non-zero besides returning itself. Consult your compiler +documentation for more details. For an alternative approach, you may wish +to use the "cexcept" facility (see http://cexcept.sourceforge.net). + +Custom chunks + +If you need to read or write custom chunks, you may need to get deeper +into the libpng code. The library now has mechanisms for storing +and writing chunks of unknown type; you can even declare callbacks +for custom chunks. However, this may not be good enough if the +library code itself needs to know about interactions between your +chunk and existing `intrinsic' chunks. + +If you need to write a new intrinsic chunk, first read the PNG +specification. Acquire a first level of +understanding of how it works. Pay particular attention to the +sections that describe chunk names, and look at how other chunks were +designed, so you can do things similarly. Second, check out the +sections of libpng that read and write chunks. Try to find a chunk +that is similar to yours and use it as a template. More details can +be found in the comments inside the code. It is best to handle unknown +chunks in a generic method, via callback functions, instead of by +modifying libpng functions. + +If you wish to write your own transformation for the data, look through +the part of the code that does the transformations, and check out some of +the simpler ones to get an idea of how they work. Try to find a similar +transformation to the one you want to add and copy off of it. More details +can be found in the comments inside the code itself. + +Configuring for 16 bit platforms + +You will want to look into zconf.h to tell zlib (and thus libpng) that +it cannot allocate more then 64K at a time. Even if you can, the memory +won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K. + +Configuring for DOS + +For DOS users who only have access to the lower 640K, you will +have to limit zlib's memory usage via a png_set_compression_mem_level() +call. See zlib.h or zconf.h in the zlib library for more information. + +Configuring for Medium Model + +Libpng's support for medium model has been tested on most of the popular +compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets +defined, and FAR gets defined to far in pngconf.h, and you should be +all set. Everything in the library (except for zlib's structure) is +expecting far data. You must use the typedefs with the p or pp on +the end for pointers (or at least look at them and be careful). Make +note that the rows of data are defined as png_bytepp, which is an +unsigned char far * far *. + +Configuring for gui/windowing platforms: + +You will need to write new error and warning functions that use the GUI +interface, as described previously, and set them to be the error and +warning functions at the time that png_create_*_struct() is called, +in order to have them available during the structure initialization. +They can be changed later via png_set_error_fn(). On some compilers, +you may also have to change the memory allocators (png_malloc, etc.). + +Configuring for compiler xxx: + +All includes for libpng are in pngconf.h. If you need to add, change +or delete an include, this is the place to do it. +The includes that are not needed outside libpng are protected by the +PNG_INTERNAL definition, which is only defined for those routines inside +libpng itself. The files in libpng proper only include png.h, which +includes pngconf.h. + +Configuring zlib: + +There are special functions to configure the compression. Perhaps the +most useful one changes the compression level, which currently uses +input compression values in the range 0 - 9. The library normally +uses the default compression level (Z_DEFAULT_COMPRESSION = 6). Tests +have shown that for a large majority of images, compression values in +the range 3-6 compress nearly as well as higher levels, and do so much +faster. For online applications it may be desirable to have maximum speed +(Z_BEST_SPEED = 1). With versions of zlib after v0.99, you can also +specify no compression (Z_NO_COMPRESSION = 0), but this would create +files larger than just storing the raw bitmap. You can specify the +compression level by calling: + + png_set_compression_level(png_ptr, level); + +Another useful one is to reduce the memory level used by the library. +The memory level defaults to 8, but it can be lowered if you are +short on memory (running DOS, for example, where you only have 640K). +Note that the memory level does have an effect on compression; among +other things, lower levels will result in sections of incompressible +data being emitted in smaller stored blocks, with a correspondingly +larger relative overhead of up to 15% in the worst case. + + png_set_compression_mem_level(png_ptr, level); + +The other functions are for configuring zlib. They are not recommended +for normal use and may result in writing an invalid PNG file. See +zlib.h for more information on what these mean. + + png_set_compression_strategy(png_ptr, + strategy); + png_set_compression_window_bits(png_ptr, + window_bits); + png_set_compression_method(png_ptr, method); + png_set_compression_buffer_size(png_ptr, size); + +Controlling row filtering + +If you want to control whether libpng uses filtering or not, which +filters are used, and how it goes about picking row filters, you +can call one of these functions. The selection and configuration +of row filters can have a significant impact on the size and +encoding speed and a somewhat lesser impact on the decoding speed +of an image. Filtering is enabled by default for RGB and grayscale +images (with and without alpha), but not for paletted images nor +for any images with bit depths less than 8 bits/pixel. + +The 'method' parameter sets the main filtering method, which is +currently only '0' in the PNG 1.2 specification. The 'filters' +parameter sets which filter(s), if any, should be used for each +scanline. Possible values are PNG_ALL_FILTERS and PNG_NO_FILTERS +to turn filtering on and off, respectively. + +Individual filter types are PNG_FILTER_NONE, PNG_FILTER_SUB, +PNG_FILTER_UP, PNG_FILTER_AVG, PNG_FILTER_PAETH, which can be bitwise +ORed together with '|' to specify one or more filters to use. +These filters are described in more detail in the PNG specification. +If you intend to change the filter type during the course of writing +the image, you should start with flags set for all of the filters +you intend to use so that libpng can initialize its internal +structures appropriately for all of the filter types. (Note that this +means the first row must always be adaptively filtered, because libpng +currently does not allocate the filter buffers until png_write_row() +is called for the first time.) + + filters = PNG_FILTER_NONE | PNG_FILTER_SUB + PNG_FILTER_UP | PNG_FILTER_AVG | + PNG_FILTER_PAETH | PNG_ALL_FILTERS; + + png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, + filters); + The second parameter can also be + PNG_INTRAPIXEL_DIFFERENCING if you are + writing a PNG to be embedded in a MNG + datastream. This parameter must be the + same as the value of filter_method used + in png_set_IHDR(). + +It is also possible to influence how libpng chooses from among the +available filters. This is done in one or both of two ways - by +telling it how important it is to keep the same filter for successive +rows, and by telling it the relative computational costs of the filters. + + double weights[3] = {1.5, 1.3, 1.1}, + costs[PNG_FILTER_VALUE_LAST] = + {1.0, 1.3, 1.3, 1.5, 1.7}; + + png_set_filter_heuristics(png_ptr, + PNG_FILTER_HEURISTIC_WEIGHTED, 3, + weights, costs); + +The weights are multiplying factors that indicate to libpng that the +row filter should be the same for successive rows unless another row filter +is that many times better than the previous filter. In the above example, +if the previous 3 filters were SUB, SUB, NONE, the SUB filter could have a +"sum of absolute differences" 1.5 x 1.3 times higher than other filters +and still be chosen, while the NONE filter could have a sum 1.1 times +higher than other filters and still be chosen. Unspecified weights are +taken to be 1.0, and the specified weights should probably be declining +like those above in order to emphasize recent filters over older filters. + +The filter costs specify for each filter type a relative decoding cost +to be considered when selecting row filters. This means that filters +with higher costs are less likely to be chosen over filters with lower +costs, unless their "sum of absolute differences" is that much smaller. +The costs do not necessarily reflect the exact computational speeds of +the various filters, since this would unduly influence the final image +size. + +Note that the numbers above were invented purely for this example and +are given only to help explain the function usage. Little testing has +been done to find optimum values for either the costs or the weights. + +Removing unwanted object code + +There are a bunch of #define's in pngconf.h that control what parts of +libpng are compiled. All the defines end in _SUPPORTED. If you are +never going to use a capability, you can change the #define to #undef +before recompiling libpng and save yourself code and data space, or +you can turn off individual capabilities with defines that begin with +PNG_NO_. + +You can also turn all of the transforms and ancillary chunk capabilities +off en masse with compiler directives that define +PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS, +or all four, +along with directives to turn on any of the capabilities that you do +want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable +the extra transformations but still leave the library fully capable of reading +and writing PNG files with all known public chunks +Use of the PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive +produces a library that is incapable of reading or writing ancillary chunks. +If you are not using the progressive reading capability, you can +turn that off with PNG_NO_PROGRESSIVE_READ (don't confuse +this with the INTERLACING capability, which you'll still have). + +All the reading and writing specific code are in separate files, so the +linker should only grab the files it needs. However, if you want to +make sure, or if you are building a stand alone library, all the +reading files start with pngr and all the writing files start with +pngw. The files that don't match either (like png.c, pngtrans.c, etc.) +are used for both reading and writing, and always need to be included. +The progressive reader is in pngpread.c + +If you are creating or distributing a dynamically linked library (a .so +or DLL file), you should not remove or disable any parts of the library, +as this will cause applications linked with different versions of the +library to fail if they call functions not available in your library. +The size of the library itself should not be an issue, because only +those sections that are actually used will be loaded into memory. + +Requesting debug printout + +The macro definition PNG_DEBUG can be used to request debugging +printout. Set it to an integer value in the range 0 to 3. Higher +numbers result in increasing amounts of debugging information. The +information is printed to the "stderr" file, unless another file +name is specified in the PNG_DEBUG_FILE macro definition. + +When PNG_DEBUG > 0, the following functions (macros) become available: + + png_debug(level, message) + png_debug1(level, message, p1) + png_debug2(level, message, p1, p2) + +in which "level" is compared to PNG_DEBUG to decide whether to print +the message, "message" is the formatted string to be printed, +and p1 and p2 are parameters that are to be embedded in the string +according to printf-style formatting directives. For example, + + png_debug1(2, "foo=%d\n", foo); + +is expanded to + + if(PNG_DEBUG > 2) + fprintf(PNG_DEBUG_FILE, "foo=%d\n", foo); + +When PNG_DEBUG is defined but is zero, the macros aren't defined, but you +can still use PNG_DEBUG to control your own debugging: + + #ifdef PNG_DEBUG + fprintf(stderr, ... + #endif + +When PNG_DEBUG = 1, the macros are defined, but only png_debug statements +having level = 0 will be printed. There aren't any such statements in +this version of libpng, but if you insert some they will be printed. + +VI. MNG support + +The MNG specification (available at http://www.libpng.org/pub/mng) allows +certain extensions to PNG for PNG images that are embedded in MNG datastreams. +Libpng can support some of these extensions. To enable them, use the +png_permit_mng_features() function: + + feature_set = png_permit_mng_features(png_ptr, mask) + mask is a png_uint_32 containing the bitwise OR of the + features you want to enable. These include + PNG_FLAG_MNG_EMPTY_PLTE + PNG_FLAG_MNG_FILTER_64 + PNG_ALL_MNG_FEATURES + feature_set is a png_uint_32 that is the bitwise AND of + your mask with the set of MNG features that is + supported by the version of libpng that you are using. + +It is an error to use this function when reading or writing a standalone +PNG file with the PNG 8-byte signature. The PNG datastream must be wrapped +in a MNG datastream. As a minimum, it must have the MNG 8-byte signature +and the MHDR and MEND chunks. Libpng does not provide support for these +or any other MNG chunks; your application must provide its own support for +them. You may wish to consider using libmng (available at +http://www.libmng.com) instead. + +VII. Changes to Libpng from version 0.88 + +It should be noted that versions of libpng later than 0.96 are not +distributed by the original libpng author, Guy Schalnat, nor by +Andreas Dilger, who had taken over from Guy during 1996 and 1997, and +distributed versions 0.89 through 0.96, but rather by another member +of the original PNG Group, Glenn Randers-Pehrson. Guy and Andreas are +still alive and well, but they have moved on to other things. + +The old libpng functions png_read_init(), png_write_init(), +png_info_init(), png_read_destroy(), and png_write_destroy() have been +moved to PNG_INTERNAL in version 0.95 to discourage their use. These +functions will be removed from libpng version 2.0.0. + +The preferred method of creating and initializing the libpng structures is +via the png_create_read_struct(), png_create_write_struct(), and +png_create_info_struct() because they isolate the size of the structures +from the application, allow version error checking, and also allow the +use of custom error handling routines during the initialization, which +the old functions do not. The functions png_read_destroy() and +png_write_destroy() do not actually free the memory that libpng +allocated for these structs, but just reset the data structures, so they +can be used instead of png_destroy_read_struct() and +png_destroy_write_struct() if you feel there is too much system overhead +allocating and freeing the png_struct for each image read. + +Setting the error callbacks via png_set_message_fn() before +png_read_init() as was suggested in libpng-0.88 is no longer supported +because this caused applications that do not use custom error functions +to fail if the png_ptr was not initialized to zero. It is still possible +to set the error callbacks AFTER png_read_init(), or to change them with +png_set_error_fn(), which is essentially the same function, but with a new +name to force compilation errors with applications that try to use the old +method. + +Starting with version 1.0.7, you can find out which version of the library +you are using at run-time: + + png_uint_32 libpng_vn = png_access_version_number(); + +The number libpng_vn is constructed from the major version, minor +version with leading zero, and release number with leading zero, +(e.g., libpng_vn for version 1.0.7 is 10007). + +You can also check which version of png.h you used when compiling your +application: + + png_uint_32 application_vn = PNG_LIBPNG_VER; + +VIII. Changes to Libpng from version 1.0.x to 1.2.x + +Support for user memory management was enabled by default. To +accomplish this, the functions png_create_read_struct_2(), +png_create_write_struct_2(), png_set_mem_fn(), png_get_mem_ptr(), +png_malloc_default(), and png_free_default() were added. + +Support for certain MNG features was enabled. + +Support for numbered error messages was added. However, we never got +around to actually numbering the error messages. The function +png_set_strip_error_numbers() was added (Note: the prototype for this +function was inadvertently removed from png.h in PNG_NO_ASSEMBLER_CODE +builds of libpng-1.2.15. It was restored in libpng-1.2.36). + +The png_malloc_warn() function was added at libpng-1.2.3. This issues +a png_warning and returns NULL instead of aborting when it fails to +acquire the requested memory allocation. + +Support for setting user limits on image width and height was enabled +by default. The functions png_set_user_limits(), png_get_user_width_max(), +and png_get_user_height_max() were added at libpng-1.2.6. + +The png_set_add_alpha() function was added at libpng-1.2.7. + +The function png_set_expand_gray_1_2_4_to_8() was added at libpng-1.2.9. +Unlike png_set_gray_1_2_4_to_8(), the new function does not expand the +tRNS chunk to alpha. The png_set_gray_1_2_4_to_8() function is +deprecated. + +A number of macro definitions in support of runtime selection of +assembler code features (especially Intel MMX code support) were +added at libpng-1.2.0: + + PNG_ASM_FLAG_MMX_SUPPORT_COMPILED + PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU + PNG_ASM_FLAG_MMX_READ_COMBINE_ROW + PNG_ASM_FLAG_MMX_READ_INTERLACE + PNG_ASM_FLAG_MMX_READ_FILTER_SUB + PNG_ASM_FLAG_MMX_READ_FILTER_UP + PNG_ASM_FLAG_MMX_READ_FILTER_AVG + PNG_ASM_FLAG_MMX_READ_FILTER_PAETH + PNG_ASM_FLAGS_INITIALIZED + PNG_MMX_READ_FLAGS + PNG_MMX_FLAGS + PNG_MMX_WRITE_FLAGS + PNG_MMX_FLAGS + +We added the following functions in support of runtime +selection of assembler code features: + + png_get_mmx_flagmask() + png_set_mmx_thresholds() + png_get_asm_flags() + png_get_mmx_bitdepth_threshold() + png_get_mmx_rowbytes_threshold() + png_set_asm_flags() + +We replaced all of these functions with simple stubs in libpng-1.2.20, +when the Intel assembler code was removed due to a licensing issue. + +IX. (Omitted) + +X. Detecting libpng + +The png_get_io_ptr() function has been present since libpng-0.88, has never +changed, and is unaffected by conditional compilation macros. It is the +best choice for use in configure scripts for detecting the presence of any +libpng version since 0.88. In an autoconf "configure.in" you could use + + AC_CHECK_LIB(png, png_get_io_ptr, ... + +XI. Source code repository + +Since about February 2009, version 1.2.34, libpng has been under "git" source +control. The git repository was built from old libpng-x.y.z.tar.gz files +going back to version 0.70. You can access the git repository (read only) +at + + git://libpng.git.sourceforge.net/gitroot/libpng + +or you can browse it via "gitweb" at + + http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng + +Patches can be sent to glennrp at users.sourceforge.net or to +png-mng-implement at lists.sourceforge.net or you can upload them to +the libpng bug tracker at + + http://libpng.sourceforge.net + +XII. Coding style + +Our coding style is similar to the "Allman" style, with curly +braces on separate lines: + + if (condition) + { + action; + } + + else if (another condition) + { + another action; + } + +The braces can be omitted from simple one-line actions: + + if (condition) + return (0); + +We use 3-space indentation, except for continued statements which +are usually indented the same as the first line of the statement +plus four more spaces. + +Comments appear with the leading "/*" at the same indentation as +the statement that follows the comment: + + /* Single-line comment */ + statement; + + /* Multiple-line + * comment + */ + statement; + +Very short comments can be placed at the end of the statement +to which they pertain: + + statement; /* comment */ + +We don't use C++ style ("//") comments. We have, however, +used them in the past in some now-abandoned MMX assembler +code. + +Functions and their curly braces are not indented, and +exported functions are marked with PNGAPI: + + /* This is a public function that is visible to + * application programers. It does thus-and-so. + */ + void PNGAPI + png_exported_function(png_ptr, png_info, foo) + { + body; + } + +The prototypes for all exported functions appear in png.h, +above the comment that says + + /* Maintainer: Put new public prototypes here ... */ + +We mark all non-exported functions with "/* PRIVATE */"": + + void /* PRIVATE */ + png_non_exported_function(png_ptr, png_info, foo) + { + body; + } + +The prototypes for non-exported functions (except for those in +pngtest) appear in +the PNG_INTERNAL section of png.h +above the comment that says + + /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ + +The names of all exported functions and variables begin +with "png_", and all publicly visible C preprocessor +macros begin with "PNG_". + +We put a space after each comma and after each semicolon +in "for" statments, and we put spaces before and after each +C binary operator and after "for" or "while". We don't +put a space between a typecast and the expression being +cast, nor do we put one between a function name and the +left parenthesis that follows it: + + for (i = 2; i > 0; --i) + x[i] = a(x) + (int)b; + +We prefer #ifdef and #ifndef to #if defined() and if !defined() +when there is only one macro being tested. + +Other rules can be inferred by inspecting the libpng +source. + +XIII. Y2K Compliance in libpng + +September 10, 2009 + +Since the PNG Development group is an ad-hoc body, we can't make +an official declaration. + +This is your unofficial assurance that libpng from version 0.71 and +upward through 1.2.40 are Y2K compliant. It is my belief that earlier +versions were also Y2K compliant. + +Libpng only has three year fields. One is a 2-byte unsigned integer that +will hold years up to 65535. The other two hold the date in text +format, and will hold years up to 9999. + +The integer is + "png_uint_16 year" in png_time_struct. + +The strings are + "png_charp time_buffer" in png_struct and + "near_time_buffer", which is a local character string in png.c. + +There are seven time-related functions: + + png_convert_to_rfc_1123() in png.c + (formerly png_convert_to_rfc_1152() in error) + png_convert_from_struct_tm() in pngwrite.c, called + in pngwrite.c + png_convert_from_time_t() in pngwrite.c + png_get_tIME() in pngget.c + png_handle_tIME() in pngrutil.c, called in pngread.c + png_set_tIME() in pngset.c + png_write_tIME() in pngwutil.c, called in pngwrite.c + +All appear to handle dates properly in a Y2K environment. The +png_convert_from_time_t() function calls gmtime() to convert from system +clock time, which returns (year - 1900), which we properly convert to +the full 4-digit year. There is a possibility that applications using +libpng are not passing 4-digit years into the png_convert_to_rfc_1123() +function, or that they are incorrectly passing only a 2-digit year +instead of "year - 1900" into the png_convert_from_struct_tm() function, +but this is not under our control. The libpng documentation has always +stated that it works with 4-digit years, and the APIs have been +documented as such. + +The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned +integer to hold the year, and can hold years as large as 65535. + +zlib, upon which libpng depends, is also Y2K compliant. It contains +no date-related code. + + + Glenn Randers-Pehrson + libpng maintainer + PNG Development Group diff --git a/src/3rdparty/libpng/libpng.3 b/src/3rdparty/libpng/libpng.3 index ef7fc5b..65b3686 100644 --- a/src/3rdparty/libpng/libpng.3 +++ b/src/3rdparty/libpng/libpng.3 @@ -1,404 +1,815 @@ -.TH LIBPNG 3 "May 8, 2008" +.TH LIBPNG 3 "September 10, 2009" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.2.29 +libpng \- Portable Network Graphics (PNG) Reference Library 1.2.40 .SH SYNOPSIS -\fB -#include \fP +\fI\fB + +\fB#include \fP + +\fI\fB \fBpng_uint_32 png_access_version_number \fI(void\fP\fB);\fP +\fI\fB + \fBint png_check_sig (png_bytep \fP\fIsig\fP\fB, int \fInum\fP\fB);\fP +\fI\fB + \fBvoid png_chunk_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP +\fI\fB + \fBvoid png_chunk_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP +\fI\fB + \fBvoid png_convert_from_struct_tm (png_timep \fP\fIptime\fP\fB, struct tm FAR * \fIttime\fP\fB);\fP +\fI\fB + \fBvoid png_convert_from_time_t (png_timep \fP\fIptime\fP\fB, time_t \fIttime\fP\fB);\fP +\fI\fB + \fBpng_charp png_convert_to_rfc1123 (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fIptime\fP\fB);\fP +\fI\fB + \fBpng_infop png_create_info_struct (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_structp png_create_read_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP +\fI\fB + \fBpng_structp png_create_read_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP +\fI\fB + \fBpng_structp png_create_write_struct (png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarn_fn\fP\fB);\fP +\fI\fB + \fBpng_structp png_create_write_struct_2(png_const_charp \fP\fIuser_png_ver\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fP\fIwarn_fn\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP +\fI\fB + \fBint png_debug(int \fP\fIlevel\fP\fB, png_const_charp \fImessage\fP\fB);\fP +\fI\fB + \fBint png_debug1(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fIp1\fP\fB);\fP +\fI\fB + \fBint png_debug2(int \fP\fIlevel\fP\fB, png_const_charp \fP\fImessage\fP\fB, \fP\fIp1\fP\fB, \fIp2\fP\fB);\fP +\fI\fB + \fBvoid png_destroy_info_struct (png_structp \fP\fIpng_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_destroy_read_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fP\fIinfo_ptr_ptr\fP\fB, png_infopp \fIend_info_ptr_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_destroy_write_struct (png_structpp \fP\fIpng_ptr_ptr\fP\fB, png_infopp \fIinfo_ptr_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_error (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fIerror\fP\fB);\fP +\fI\fB + \fBvoid png_free (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP +\fI\fB + \fBvoid png_free_chunk_list (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_free_default(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fIptr\fP\fB);\fP +\fI\fB + \fBvoid png_free_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fInum\fP\fB);\fP +\fI\fB + \fBpng_byte png_get_bit_depth (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fI*background\fP\fB);\fP +\fI\fB + \fBpng_byte png_get_channels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fI*white_x\fP\fB, double \fP\fI*white_y\fP\fB, double \fP\fI*red_x\fP\fB, double \fP\fI*red_y\fP\fB, double \fP\fI*green_x\fP\fB, double \fP\fI*green_y\fP\fB, double \fP\fI*blue_x\fP\fB, double \fI*blue_y\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*white_x\fP\fB, png_uint_32 \fP\fI*white_y\fP\fB, png_uint_32 \fP\fI*red_x\fP\fB, png_uint_32 \fP\fI*red_y\fP\fB, png_uint_32 \fP\fI*green_x\fP\fB, png_uint_32 \fP\fI*green_y\fP\fB, png_uint_32 \fP\fI*blue_x\fP\fB, png_uint_32 \fI*blue_y\fP\fB);\fP +\fI\fB + \fBpng_byte png_get_color_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_byte png_get_compression_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_byte png_get_copyright (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_voidp png_get_error_ptr (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_byte png_get_filter_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fI*file_gamma\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fI*int_file_gamma\fP\fB);\fP +\fI\fB + \fBpng_byte png_get_header_ver (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_byte png_get_header_version (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fI*hist\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charpp \fP\fIname\fP\fB, int \fP\fI*compression_type\fP\fB, png_charpp \fP\fIprofile\fP\fB, png_uint_32 \fI*proflen\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*width\fP\fB, png_uint_32 \fP\fI*height\fP\fB, int \fP\fI*bit_depth\fP\fB, int \fP\fI*color_type\fP\fB, int \fP\fI*interlace_type\fP\fB, int \fP\fI*compression_type\fP\fB, int \fI*filter_type\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_image_height (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_image_width (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP -\fB#if !defined(PNG_1_0_X) png_int_32 png_get_int_32 (png_bytep buf); \fI#endif +\fI\fB + +\fB#if \fI!defined(PNG_1_0_X) + +\fBpng_int_32 png_get_int_32 (png_bytep \fIbuf\fP\fB);\fP + +\fI\fB#endif + +\fI\fB \fBpng_byte png_get_interlace_type (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_voidp png_get_io_ptr (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_byte png_get_libpng_ver (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_voidp png_get_mem_ptr(png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*offset_x\fP\fB, png_uint_32 \fP\fI*offset_y\fP\fB, int \fI*unit_type\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fI*purpose\fP\fB, png_int_32 \fP\fI*X0\fP\fB, png_int_32 \fP\fI*X1\fP\fB, int \fP\fI*type\fP\fB, int \fP\fI*nparams\fP\fB, png_charp \fP\fI*units\fP\fB, png_charpp \fI*params\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fI*res_x\fP\fB, png_uint_32 \fP\fI*res_y\fP\fB, int \fI*unit_type\fP\fB);\fP +\fI\fB + \fBfloat png_get_pixel_aspect_ratio (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_voidp png_get_progressive_ptr (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fI*palette\fP\fB, int \fI*num_palette\fP\fB);\fP -\fBpng_byte png_get_rgb_to_gray_status (png_structp png_ptr) png_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + +\fBpng_byte png_get_rgb_to_gray_status (png_structp \fIpng_ptr) + +\fBpng_uint_32 png_get_rowbytes (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fI\fB \fBpng_bytepp png_get_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fI*sig_bit\fP\fB);\fP +\fI\fB + \fBpng_bytep png_get_signature (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fI*splt_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fI*intent\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fI*text_ptr\fP\fB, int \fI*num_text\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fI*mod_time\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fI*trans\fP\fB, int \fP\fI*num_trans\fP\fB, png_color_16p \fI*trans_values\fP\fB);\fP -\fB#if !defined(PNG_1_0_X) png_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP +\fI\fB + +\fB#if \fI!defined(PNG_1_0_X) + +\fBpng_uint_16 png_get_uint_16 (png_bytep \fIbuf\fP\fB);\fP + +\fI\fB \fBpng_uint_32 png_get_uint_31 (png_bytep \fIbuf\fP\fB);\fP -\fBpng_uint_32 png_get_uint_32 (png_bytep buf); \fI#endif +\fI\fB + +\fBpng_uint_32 png_get_uint_32 (png_bytep \fIbuf\fP\fB);\fP + +\fI\fB#endif + +\fI\fB \fBpng_uint_32 png_get_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkpp \fIunknowns\fP\fB);\fP +\fI\fB + \fBpng_voidp png_get_user_chunk_ptr (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_user_height_max( png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_voidp png_get_user_transform_ptr (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_user_width_max (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_valid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIflag\fP\fB);\fP +\fI\fB + \fBpng_int_32 png_get_x_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_int_32 png_get_x_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_x_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_int_32 png_get_y_offset_microns (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_int_32 png_get_y_offset_pixels (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_y_pixels_per_meter (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_get_compression_buffer_size (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBint png_handle_as_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP +\fI\fB + \fBvoid png_init_io (png_structp \fP\fIpng_ptr\fP\fB, FILE \fI*fp\fP\fB);\fP +\fI\fB + \fBDEPRECATED: void png_info_init (png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBDEPRECATED: void png_info_init_2 (png_infopp \fP\fIptr_ptr\fP\fB, png_size_t \fIpng_info_struct_size\fP\fB);\fP +\fI\fB + \fBpng_voidp png_malloc (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP +\fI\fB + \fBpng_voidp png_malloc_default(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP +\fI\fB + \fBvoidp png_memcpy (png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_size_t \fIsize\fP\fB);\fP +\fI\fB + \fBpng_voidp png_memcpy_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, png_voidp \fP\fIs2\fP\fB, png_uint_32 \fIsize\fP\fB);\fP +\fI\fB + \fBvoidp png_memset (png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_size_t \fIsize\fP\fB);\fP +\fI\fB + \fBpng_voidp png_memset_check (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIs1\fP\fB, int \fP\fIvalue\fP\fB, png_uint_32 \fIsize\fP\fB);\fP +\fI\fB + \fBDEPRECATED: void png_permit_empty_plte (png_structp \fP\fIpng_ptr\fP\fB, int \fIempty_plte_permitted\fP\fB);\fP +\fI\fB + \fBvoid png_process_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_size\fP\fB);\fP +\fI\fB + \fBvoid png_progressive_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIold_row\fP\fB, png_bytep \fInew_row\fP\fB);\fP +\fI\fB + \fBvoid png_read_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_infop \fIend_info_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_read_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP +\fI\fB + \fBDEPRECATED: void png_read_init (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBDEPRECATED: void png_read_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP +\fI\fB + \fBvoid png_read_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_read_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP +\fI\fB + \fBvoid png_read_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fIdisplay_row\fP\fB);\fP +\fI\fB + \fBvoid png_read_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_bytepp \fP\fIdisplay_row\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP +\fI\fB + \fBvoid png_read_update_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP -\fB#if !defined(PNG_1_0_X) png_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP +\fI\fB + +\fB#if \fI!defined(PNG_1_0_X) + +\fBpng_save_int_32 (png_bytep \fP\fIbuf\fP\fB, png_int_32 \fIi\fP\fB);\fP + +\fI\fB \fBvoid png_save_uint_16 (png_bytep \fP\fIbuf\fP\fB, unsigned int \fIi\fP\fB);\fP +\fI\fB + \fBvoid png_save_uint_32 (png_bytep \fP\fIbuf\fP\fB, png_uint_32 \fIi\fP\fB);\fP -\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int flags); \fI#endif +\fI\fB + +\fBvoid png_set_add_alpha (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP + +\fI\fB#endif + +\fI\fB \fBvoid png_set_background (png_structp \fP\fIpng_ptr\fP\fB, png_color_16p \fP\fIbackground_color\fP\fB, int \fP\fIbackground_gamma_code\fP\fB, int \fP\fIneed_expand\fP\fB, double \fIbackground_gamma\fP\fB);\fP +\fI\fB + \fBvoid png_set_bgr (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP +\fI\fB + \fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP +\fI\fB + \fBvoid png_set_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP +\fI\fB + \fBvoid png_set_compression_level (png_structp \fP\fIpng_ptr\fP\fB, int \fIlevel\fP\fB);\fP +\fI\fB + \fBvoid png_set_compression_mem_level (png_structp \fP\fIpng_ptr\fP\fB, int \fImem_level\fP\fB);\fP +\fI\fB + \fBvoid png_set_compression_method (png_structp \fP\fIpng_ptr\fP\fB, int \fImethod\fP\fB);\fP +\fI\fB + \fBvoid png_set_compression_strategy (png_structp \fP\fIpng_ptr\fP\fB, int \fIstrategy\fP\fB);\fP +\fI\fB + \fBvoid png_set_compression_window_bits (png_structp \fP\fIpng_ptr\fP\fB, int \fIwindow_bits\fP\fB);\fP +\fI\fB + \fBvoid png_set_crc_action (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcrit_action\fP\fB, int \fIancil_action\fP\fB);\fP +\fI\fB + \fBvoid png_set_dither (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fP\fInum_palette\fP\fB, int \fP\fImaximum_colors\fP\fB, png_uint_16p \fP\fIhistogram\fP\fB, int \fIfull_dither\fP\fB);\fP +\fI\fB + \fBvoid png_set_error_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIerror_ptr\fP\fB, png_error_ptr \fP\fIerror_fn\fP\fB, png_error_ptr \fIwarning_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_expand (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_expand_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_filler (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, int \fIflags\fP\fB);\fP +\fI\fB + \fBvoid png_set_filter (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fImethod\fP\fB, int \fIfilters\fP\fB);\fP +\fI\fB + \fBvoid png_set_filter_heuristics (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIheuristic_method\fP\fB, int \fP\fInum_weights\fP\fB, png_doublep \fP\fIfilter_weights\fP\fB, png_doublep \fIfilter_costs\fP\fB);\fP +\fI\fB + \fBvoid png_set_flush (png_structp \fP\fIpng_ptr\fP\fB, int \fInrows\fP\fB);\fP +\fI\fB + \fBvoid png_set_gamma (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIscreen_gamma\fP\fB, double \fIdefault_file_gamma\fP\fB);\fP +\fI\fB + \fBvoid png_set_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP +\fI\fB + \fBvoid png_set_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIfile_gamma\fP\fB);\fP +\fI\fB + \fBvoid png_set_gray_1_2_4_to_8(png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_gray_to_rgb (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_16p \fIhist\fP\fB);\fP +\fI\fB + \fBvoid png_set_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, png_uint_32 \fIproflen\fP\fB);\fP +\fI\fB + \fBint png_set_interlace_handling (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_invalid (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fImask\fP\fB);\fP +\fI\fB + \fBvoid png_set_invert_alpha (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_invert_mono (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIinterlace_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fIfilter_type\fP\fB);\fP +\fI\fB + \fBvoid png_set_keep_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIkeep\fP\fB, png_bytep \fP\fIchunk_list\fP\fB, int \fInum_chunks\fP\fB);\fP +\fI\fB + \fBvoid png_set_mem_fn(png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fImem_ptr\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_free_ptr \fIfree_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIoffset_x\fP\fB, png_uint_32 \fP\fIoffset_y\fP\fB, int \fIunit_type\fP\fB);\fP +\fI\fB + \fBvoid png_set_packing (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_packswap (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_palette_to_rgb(png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP +\fI\fB + \fBvoid png_set_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fP\fIres_x\fP\fB, png_uint_32 \fP\fIres_y\fP\fB, int \fIunit_type\fP\fB);\fP +\fI\fB + \fBvoid png_set_progressive_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIprogressive_ptr\fP\fB, png_progressive_info_ptr \fP\fIinfo_fn\fP\fB, png_progressive_row_ptr \fP\fIrow_fn\fP\fB, png_progressive_end_ptr \fIend_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP +\fI\fB + \fBvoid png_set_read_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fIread_data_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_read_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_read_status_ptr \fIread_row_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_read_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIread_user_transform_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_rgb_to_gray (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIerror_action\fP\fB, double \fP\fIred\fP\fB, double \fIgreen\fP\fB);\fP +\fI\fB + \fBvoid png_set_rgb_to_gray_fixed (png_structp \fP\fIpng_ptr\fP\fB, int error_action png_fixed_point \fP\fIred\fP\fB, png_fixed_point \fIgreen\fP\fB);\fP +\fI\fB + \fBvoid png_set_rows (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytepp \fIrow_pointers\fP\fB);\fP +\fI\fB + \fBvoid png_set_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_8p \fIsig_bit\fP\fB);\fP +\fI\fB + \fBvoid png_set_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP +\fI\fB + \fBvoid png_set_shift (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fItrue_bits\fP\fB);\fP +\fI\fB + \fBvoid png_set_sig_bytes (png_structp \fP\fIpng_ptr\fP\fB, int \fInum_bytes\fP\fB);\fP +\fI\fB + \fBvoid png_set_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_spalette_p \fP\fIsplt_ptr\fP\fB, int \fInum_spalettes\fP\fB);\fP +\fI\fB + \fBvoid png_set_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP +\fI\fB + \fBvoid png_set_sRGB_gAMA_and_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fIintent\fP\fB);\fP +\fI\fB + \fBvoid png_set_strip_16 (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_strip_alpha (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_swap (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_swap_alpha (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_set_text (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP +\fI\fB + \fBvoid png_set_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP +\fI\fB + \fBvoid png_set_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fP\fInum_trans\fP\fB, png_color_16p \fItrans_values\fP\fB);\fP +\fI\fB + \fBvoid png_set_tRNS_to_alpha(png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBpng_uint_32 png_set_unknown_chunks (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_unknown_chunkp \fP\fIunknowns\fP\fB, int \fP\fInum\fP\fB, int \fIlocation\fP\fB);\fP +\fI\fB + \fBvoid png_set_unknown_chunk_location(png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fIchunk\fP\fB, int \fIlocation\fP\fB);\fP +\fI\fB + \fBvoid png_set_read_user_chunk_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_chunk_ptr\fP\fB, png_user_chunk_ptr \fIread_user_chunk_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_user_limits (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIuser_width_max\fP\fB, png_uint_32 \fIuser_height_max\fP\fB);\fP +\fI\fB + \fBvoid png_set_user_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIuser_transform_ptr\fP\fB, int \fP\fIuser_transform_depth\fP\fB, int \fIuser_transform_channels\fP\fB);\fP +\fI\fB + \fBvoid png_set_write_fn (png_structp \fP\fIpng_ptr\fP\fB, png_voidp \fP\fIio_ptr\fP\fB, png_rw_ptr \fP\fIwrite_data_fn\fP\fB, png_flush_ptr \fIoutput_flush_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_write_status_fn (png_structp \fP\fIpng_ptr\fP\fB, png_write_status_ptr \fIwrite_row_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_write_user_transform_fn (png_structp \fP\fIpng_ptr\fP\fB, png_user_transform_ptr \fIwrite_user_transform_fn\fP\fB);\fP +\fI\fB + \fBvoid png_set_compression_buffer_size(png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIsize\fP\fB);\fP +\fI\fB + \fBint png_sig_cmp (png_bytep \fP\fIsig\fP\fB, png_size_t \fP\fIstart\fP\fB, png_size_t \fInum_to_check\fP\fB);\fP +\fI\fB + \fBvoid png_start_read_image (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_warning (png_structp \fP\fIpng_ptr\fP\fB, png_const_charp \fImessage\fP\fB);\fP +\fI\fB + \fBvoid png_write_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP +\fI\fB + \fBvoid png_write_chunk_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP +\fI\fB + \fBvoid png_write_chunk_end (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_write_chunk_start (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIchunk_name\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB + \fBvoid png_write_destroy (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_write_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_write_flush (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_write_image (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fIimage\fP\fB);\fP +\fI\fB + \fBDEPRECATED: void png_write_init (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + \fBDEPRECATED: void png_write_init_2 (png_structpp \fP\fIptr_ptr\fP\fB, png_const_charp \fP\fIuser_png_ver\fP\fB, png_size_t \fP\fIpng_struct_size\fP\fB, png_size_t \fIpng_info_size\fP\fB);\fP +\fI\fB + \fBvoid png_write_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_write_info_before_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB + \fBvoid png_write_png (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, int \fP\fItransforms\fP\fB, png_voidp \fIparams\fP\fB);\fP +\fI\fB + \fBvoid png_write_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fI\fB + \fBvoid png_write_rows (png_structp \fP\fIpng_ptr\fP\fB, png_bytepp \fP\fIrow\fP\fB, png_uint_32 \fInum_rows\fP\fB);\fP +\fI\fB + \fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP +\fI\fB + \fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP +\fI\fB + .SH DESCRIPTION The .I libpng @@ -410,18 +821,20 @@ Following is a copy of the libpng.txt file that accompanies libpng. .SH LIBPNG.TXT libpng.txt - A description on how to use and modify libpng - libpng version 1.2.29 - May 8, 2008 + libpng version 1.2.40 - September 10, 2009 Updated and distributed by Glenn Randers-Pehrson - Copyright (c) 1998-2008 Glenn Randers-Pehrson - For conditions of distribution and use, see copyright - notice in png.h. + Copyright (c) 1998-2009 Glenn Randers-Pehrson + + This document is released under the libpng license. + For conditions of distribution and use, see the disclaimer + and license in png.h Based on: - libpng versions 0.97, January 1998, through 1.2.29 - May 8, 2008 + libpng versions 0.97, January 1998, through 1.2.40 - September 10, 2009 Updated and distributed by Glenn Randers-Pehrson - Copyright (c) 1998-2008 Glenn Randers-Pehrson + Copyright (c) 1998-2009 Glenn Randers-Pehrson libpng 1.0 beta 6 version 0.96 May 28, 1997 Updated and distributed by Andreas Dilger @@ -551,9 +964,10 @@ so if it doesn't work, you don't have much to undo. Of course, you will also want to insure that you are, in fact, dealing with a PNG file. Libpng provides a simple check to see if a file is a PNG file. To use it, pass in the first 1 to 8 bytes of the file to the function -png_sig_cmp(), and it will return 0 if the bytes match the corresponding -bytes of the PNG signature, or nonzero otherwise. Of course, the more bytes -you pass in, the greater the accuracy of the prediction. +png_sig_cmp(), and it will return 0 (false) if the bytes match the +corresponding bytes of the PNG signature, or nonzero (true) otherwise. +Of course, the more bytes you pass in, the greater the accuracy of the +prediction. If you are intending to keep the file pointer open for use in libpng, you must ensure you don't read more than 8 bytes from the beginning @@ -730,35 +1144,14 @@ To inform libpng about your function, use png_set_read_status_fn(png_ptr, read_row_callback); -.SS Width and height limits - -The PNG specification allows the width and height of an image to be as -large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. -Since very few applications really need to process such large images, -we have imposed an arbitrary 1-million limit on rows and columns. -Larger images will be rejected immediately with a png_error() call. If -you wish to override this limit, you can use - - png_set_user_limits(png_ptr, width_max, height_max); - -to set your own limits, or use width_max = height_max = 0x7fffffffL -to allow all valid dimensions (libpng may reject some very large images -anyway because of potential buffer overflow conditions). - -You should put this statement after you create the PNG structure and -before calling png_read_info(), png_read_png(), or png_process_data(). -If you need to retrieve the limits that are being applied, use - - width_max = png_get_user_width_max(png_ptr); - height_max = png_get_user_height_max(png_ptr); - .SS Unknown-chunk handling Now you get to set the way the library processes unknown chunks in the input PNG stream. Both known and unknown chunks will be read. Normal behavior is that known chunks will be parsed into information in -various info_ptr members while unknown chunks will be discarded. To change -this, you can call: +various info_ptr members while unknown chunks will be discarded. This +behavior can be wasteful if your application will never use some known +chunk types. To change this, you can call: png_set_keep_unknown_chunks(png_ptr, keep, chunk_list, num_chunks); @@ -816,6 +1209,27 @@ callback function: (int)sizeof(unused_chunks)/5); #endif +.SS User limits + +The PNG specification allows the width and height of an image to be as +large as 2^31-1 (0x7fffffff), or about 2.147 billion rows and columns. +Since very few applications really need to process such large images, +we have imposed an arbitrary 1-million limit on rows and columns. +Larger images will be rejected immediately with a png_error() call. If +you wish to override this limit, you can use + + png_set_user_limits(png_ptr, width_max, height_max); + +to set your own limits, or use width_max = height_max = 0x7fffffffL +to allow all valid dimensions (libpng may reject some very large images +anyway because of potential buffer overflow conditions). + +You should put this statement after you create the PNG structure and +before calling png_read_info(), png_read_png(), or png_process_data(). +If you need to retrieve the limits that are being applied, use + + width_max = png_get_user_width_max(png_ptr); + height_max = png_get_user_height_max(png_ptr); .SS The high-level read interface @@ -882,6 +1296,8 @@ row_pointers prior to calling png_read_png() with row_pointers = png_malloc(png_ptr, height*png_sizeof(png_bytep)); for (int i=0; i 0; --i) + x[i] = a(x) + (int)b; + +We prefer #ifdef and #ifndef to #if defined() and if !defined() +when there is only one macro being tested. + +Other rules can be inferred by inspecting the libpng +source. + +.SH XIII. Y2K Compliance in libpng + +September 10, 2009 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. This is your unofficial assurance that libpng from version 0.71 and -upward through 1.2.29 are Y2K compliant. It is my belief that earlier +upward through 1.2.40 are Y2K compliant. It is my belief that earlier versions were also Y2K compliant. Libpng only has three year fields. One is a 2-byte unsigned integer that @@ -3499,6 +4116,56 @@ the first widely used release: 1.2.29rc01 13 10229 12.so.0.29[.0] 1.0.35 10 10035 10.so.0.35[.0] 1.2.29 13 10229 12.so.0.29[.0] + 1.0.37 10 10037 10.so.0.37[.0] + 1.2.30beta01-04 13 10230 12.so.0.30[.0] + 1.0.38rc01-08 10 10038 10.so.0.38[.0] + 1.2.30rc01-08 13 10230 12.so.0.30[.0] + 1.0.38 10 10038 10.so.0.38[.0] + 1.2.30 13 10230 12.so.0.30[.0] + 1.0.39rc01-03 10 10039 10.so.0.39[.0] + 1.2.31rc01-03 13 10231 12.so.0.31[.0] + 1.0.39 10 10039 10.so.0.39[.0] + 1.2.31 13 10231 12.so.0.31[.0] + 1.2.32beta01-02 13 10232 12.so.0.32[.0] + 1.0.40rc01 10 10040 10.so.0.40[.0] + 1.2.32rc01 13 10232 12.so.0.32[.0] + 1.0.40 10 10040 10.so.0.40[.0] + 1.2.32 13 10232 12.so.0.32[.0] + 1.2.33beta01-02 13 10233 12.so.0.33[.0] + 1.2.33rc01-02 13 10233 12.so.0.33[.0] + 1.0.41rc01 10 10041 10.so.0.41[.0] + 1.2.33 13 10233 12.so.0.33[.0] + 1.0.41 10 10041 10.so.0.41[.0] + 1.2.34beta01-07 13 10234 12.so.0.34[.0] + 1.0.42rc01 10 10042 10.so.0.42[.0] + 1.2.34rc01 13 10234 12.so.0.34[.0] + 1.0.42 10 10042 10.so.0.42[.0] + 1.2.34 13 10234 12.so.0.34[.0] + 1.2.35beta01-03 13 10235 12.so.0.35[.0] + 1.0.43rc01-02 10 10043 10.so.0.43[.0] + 1.2.35rc01-02 13 10235 12.so.0.35[.0] + 1.0.43 10 10043 10.so.0.43[.0] + 1.2.35 13 10235 12.so.0.35[.0] + 1.2.36beta01-05 13 10236 12.so.0.36[.0] + 1.2.36rc01 13 10236 12.so.0.36[.0] + 1.0.44 10 10044 10.so.0.44[.0] + 1.2.36 13 10236 12.so.0.36[.0] + 1.2.37beta01-03 13 10237 12.so.0.37[.0] + 1.2.37rc01 13 10237 12.so.0.37[.0] + 1.2.37 13 10237 12.so.0.37[.0] + 1.2.45 10 10045 12.so.0.45[.0] + 1.0.46 10 10046 10.so.0.46[.0] + 1.2.38beta01 13 10238 12.so.0.38[.0] + 1.2.38rc01-03 13 10238 12.so.0.38[.0] + 1.0.47 10 10047 10.so.0.47[.0] + 1.2.38 13 10238 12.so.0.38[.0] + 1.2.39beta01-05 13 10239 12.so.0.39[.0] + 1.2.39rc01 13 10239 12.so.0.39[.0] + 1.0.48 10 10048 10.so.0.48[.0] + 1.2.39 13 10239 12.so.0.39[.0] + 1.2.40rc01 13 10240 12.so.0.40[.0] + 1.0.49 10 10049 10.so.0.49[.0] + 1.2.40 13 10240 12.so.0.40[.0] Henceforth the source version will match the shared-library minor and patch numbers; the shared-library major version number will be @@ -3554,7 +4221,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.2.29 - May 8, 2008: +Libpng version 1.2.40 - September 10, 2009: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). @@ -3575,7 +4242,9 @@ included in the libpng distribution, the latter shall prevail.) If you modify libpng you may insert additional notices immediately following this sentence. -libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are +This code is released under the libpng license. + +libpng versions 1.2.6, August 15, 2004, through 1.2.40, September 10, 2009, are Copyright (c) 2004,2006-2008 Glenn Randers-Pehrson, and are distributed according to the same disclaimer and license as libpng-1.2.5 with the following individual added to the list of Contributing Authors @@ -3674,7 +4343,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -May 8, 2008 +September 10, 2009 .\" end of man page diff --git a/src/3rdparty/libpng/libpngpf.3 b/src/3rdparty/libpng/libpngpf.3 index 423964f..a1e030d 100644 --- a/src/3rdparty/libpng/libpngpf.3 +++ b/src/3rdparty/libpng/libpngpf.3 @@ -1,266 +1,782 @@ -.TH LIBPNGPF 3 "May 8, 2008" +.TH LIBPNGPF 3 "September 10, 2009" .SH NAME -libpng \- Portable Network Graphics (PNG) Reference Library 1.2.29 +libpng \- Portable Network Graphics (PNG) Reference Library 1.2.40 (private functions) .SH SYNOPSIS \fB#include \fP +\fI\fB + +\fI\fB + \fBvoid png_build_gamma_table (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_build_grayscale_palette (int \fP\fIbit_depth\fP\fB, png_colorp \fIpalette\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_calculate_crc (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIptr\fP\fB, png_size_t \fIlength\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_check_chunk_name (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIchunk_name\fP\fB);\fP +\fI\fB + +\fI\fB + \fBpng_size_t png_check_keyword (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charpp \fInew_key\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_combine_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fImask\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_correct_palette (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, int \fInum_palette\fP\fB);\fP +\fI\fB + +\fI\fB + \fBint png_crc_error (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + +\fI\fB + \fBint png_crc_finish (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIskip\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_crc_read (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuf\fP\fB, png_size_t \fIlength\fP\fB);\fP +\fI\fB + +\fI\fB + \fBpng_voidp png_create_struct (int \fItype\fP\fB);\fP +\fI\fB + +\fI\fB + \fBpng_voidp png_create_struct_2 (int \fP\fItype\fP\fB, png_malloc_ptr \fP\fImalloc_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP -\fBpng_charp png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP +\fI\fB + +\fI\fB + +\fBvoid png_decompress_chunk (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcomp_type\fP\fB, png_charp \fP\fIchunkdata\fP\fB, png_size_t \fP\fIchunklength\fP\fB, png_size_t \fP\fIprefix_length\fP\fB, png_size_t \fI*data_length\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fP\fIfree_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_background (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fP\fItrans_values\fP\fB, png_color_16p \fP\fIbackground\fP\fB, png_color_16p \fP\fIbackground_1\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_bytep \fP\fIgamma_from_1\fP\fB, png_bytep \fP\fIgamma_to_1\fP\fB, png_uint_16pp \fP\fIgamma_16\fP\fB, png_uint_16pp \fP\fIgamma_16_from_1\fP\fB, png_uint_16pp \fP\fIgamma_16_to_1\fP\fB, int \fIgamma_shift\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_expand (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fItrans_value\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_expand_palette (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fInum_trans\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_gamma (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_uint_16pp \fP\fIgamma_16_table\fP\fB, int \fIgamma_shift\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_pack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIbit_depth\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_read_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, png_uint_32 \fIflags\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_read_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fP\fIpass\fP\fB, png_uint_32 \fItransformations\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_shift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIbit_depth\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_strip_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIflags\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_unshift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIsig_bits\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_IEND (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_init_mmx_flags (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_process_IDAT_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_fill_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP + +\fI\fB + +\fI\fB + +\fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP + +\fI\fB + +\fI\fB -\fBvoid png_destroy_struct (png_voidp \fIstruct_ptr\fP\fB);\fP +\fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP -\fBvoid png_destroy_struct_2 (png_voidp \fP\fIstruct_ptr\fP\fB, png_free_ptr \fP\fIfree_fn\fP\fB, png_voidp \fImem_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_do_background (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fP\fItrans_values\fP\fB, png_color_16p \fP\fIbackground\fP\fB, png_color_16p \fP\fIbackground_1\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_bytep \fP\fIgamma_from_1\fP\fB, png_bytep \fP\fIgamma_to_1\fP\fB, png_uint_16pp \fP\fIgamma_16\fP\fB, png_uint_16pp \fP\fIgamma_16_from_1\fP\fB, png_uint_16pp \fP\fIgamma_16_to_1\fP\fB, int \fIgamma_shift\fP\fB);\fP +\fI\fB -\fBvoid png_do_bgr (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP -\fBvoid png_do_chop (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fI\fB -\fBvoid png_do_dither (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIpalette_lookup\fP\fB, png_bytep \fIdither_lookup\fP\fB);\fP +\fI\fB -\fBvoid png_do_expand (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_16p \fItrans_value\fP\fB);\fP +\fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP -\fBvoid png_do_expand_palette (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_bytep \fP\fItrans\fP\fB, int \fInum_trans\fP\fB);\fP +\fI\fB -\fBvoid png_do_gamma (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIgamma_table\fP\fB, png_uint_16pp \fP\fIgamma_16_table\fP\fB, int \fIgamma_shift\fP\fB);\fP +\fI\fB -\fBvoid png_do_gray_to_rgb (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP -\fBvoid png_do_invert (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fI\fB -\fBvoid png_do_pack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIbit_depth\fP\fB);\fP +\fI\fB -\fBvoid png_do_packswap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP -\fBvoid png_do_read_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fP\fIfiller\fP\fB, png_uint_32 \fIflags\fP\fB);\fP +\fI\fB -\fBvoid png_do_read_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fP\fIpass\fP\fB, png_uint_32 \fItransformations\fP\fB);\fP +\fI\fB -\fBvoid png_do_read_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP -\fBvoid png_do_read_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fI\fB -\fBvoid png_do_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBint png_do_rgb_to_gray (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fBvoid png_push_restore_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP -\fBvoid png_do_shift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIbit_depth\fP\fB);\fP +\fI\fB -\fBvoid png_do_strip_filler (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_uint_32 \fIflags\fP\fB);\fP +\fI\fB -\fBvoid png_do_swap (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP -\fBvoid png_do_unpack (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fI\fB -\fBvoid png_do_unshift (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_color_8p \fIsig_bits\fP\fB);\fP +\fI\fB -\fBvoid png_do_write_interlace (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, int \fIpass\fP\fB);\fP +\fBpng_uint_32 png_read_chunk_header (png_structp \fIpng_ptr\fP\fB);\fP -\fBvoid png_do_write_invert_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fI\fB -\fBvoid png_do_write_swap_alpha (png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fI\fB -\fBvoid png_do_write_transformations (png_structp \fIpng_ptr\fP\fB);\fP +\fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP -\fBvoid *png_far_to_near (png_structp png_ptr,png_voidp \fP\fIptr\fP\fB, int \fIcheck\fP\fB);\fP +\fI\fB -\fBvoid png_flush (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_handle_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fBvoid png_read_filter_row (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIprev_row\fP\fB, int \fIfilter\fP\fB);\fP -\fBvoid png_handle_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_gAMA (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP -\fBvoid png_handle_IEND (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP -\fBvoid png_handle_iTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP -\fBvoid png_handle_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP -\fBvoid png_handle_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_sRGB (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP -\fBvoid png_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fBint png_set_text_2 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP -\fBvoid png_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_info_destroy (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP -\fBvoid png_init_mmx_flags (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_init_read_transformations (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_process_IDAT_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP +\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP -\fBvoid png_process_some_data (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_push_check_crc (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_push_crc_finish (png_structp \fIpng_ptr\fP\fB);\fP +\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP -\fBvoid png_push_crc_skip (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_push_fill_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_push_handle_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP -\fBvoid png_push_handle_unknown (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_push_handle_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_uint_32 \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_push_have_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP -\fBvoid png_push_have_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_push_have_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIrow\fP\fB);\fP +\fI\fB -\fBvoid png_push_process_row (png_structp \fIpng_ptr\fP\fB);\fP +\fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP -\fBvoid png_push_read_chunk (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_push_read_end (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_push_read_IDAT (png_structp \fIpng_ptr\fP\fB);\fP +\fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP -\fBvoid png_push_read_sig (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_push_read_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_push_read_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP -\fBvoid png_push_restore_buffer (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIbuffer\fP\fB, png_size_t \fIbuffer_length\fP\fB);\fP +\fI\fB -\fBvoid png_push_save_buffer (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_read_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP +\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP -\fBvoid png_read_filter_row (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fP\fIrow_info\fP\fB, png_bytep \fP\fIrow\fP\fB, png_bytep \fP\fIprev_row\fP\fB, int \fIfilter\fP\fB);\fP +\fI\fB -\fBvoid png_read_finish_row (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_read_push_finish_row (png_structp \fIpng_ptr\fP\fB);\fP +\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP -\fBvoid png_read_start_row (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_read_transform_info (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fIinfo_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_reset_crc (png_structp \fIpng_ptr\fP\fB);\fP +\fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP -\fBint png_set_text_2 (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_textp \fP\fItext_ptr\fP\fB, int \fInum_text\fP\fB);\fP +\fI\fB -\fBvoid png_write_cHRM (png_structp \fP\fIpng_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP +\fI\fB -\fBvoid png_write_cHRM_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwhite_x\fP\fB, png_uint_32 \fP\fIwhite_y\fP\fB, png_uint_32 \fP\fIred_x\fP\fB, png_uint_32 \fP\fIred_y\fP\fB, png_uint_32 \fP\fIgreen_x\fP\fB, png_uint_32 \fP\fIgreen_y\fP\fB, png_uint_32 \fP\fIblue_x\fP\fB, png_uint_32 \fIblue_y\fP\fB);\fP +\fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP -\fBvoid png_write_data (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP +\fI\fB -\fBvoid png_write_filtered_row (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fIfiltered_row\fP\fB);\fP +\fI\fB -\fBvoid png_write_find_filter (png_structp \fP\fIpng_ptr\fP\fB, png_row_infop \fIrow_info\fP\fB);\fP +\fBvoid png_write_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fP\fIfilter_type\fP\fB, int \fIinterlace_type\fP\fB);\fP -\fBvoid png_write_finish_row (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_write_gAMA (png_structp \fP\fIpng_ptr\fP\fB, double \fIfile_gamma\fP\fB);\fP +\fI\fB -\fBvoid png_write_gAMA_fixed (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fIint_file_gamma\fP\fB);\fP +\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext\fP\fB);\fP -\fBvoid png_write_hIST (png_structp \fP\fIpng_ptr\fP\fB, png_uint_16p \fP\fIhist\fP\fB, int \fInum_hist\fP\fB);\fP +\fI\fB -\fBvoid png_write_iCCP (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIname\fP\fB, int \fP\fIcompression_type\fP\fB, png_charp \fP\fIprofile\fP\fB, int \fIproflen\fP\fB);\fP +\fI\fB -\fBvoid png_write_IDAT (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fIdata\fP\fB, png_size_t \fIlength\fP\fB);\fP +\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP -\fBvoid png_write_IEND (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB -\fBvoid png_write_IHDR (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIwidth\fP\fB, png_uint_32 \fP\fIheight\fP\fB, int \fP\fIbit_depth\fP\fB, int \fP\fIcolor_type\fP\fB, int \fP\fIcompression_type\fP\fB, int \fP\fIfilter_type\fP\fB, int \fIinterlace_type\fP\fB);\fP +\fI\fB -\fBvoid png_write_iTXt (png_structp \fP\fIpng_ptr\fP\fB, int \fP\fIcompression\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fIlang\fP\fB, png_charp \fP\fItranslated_key\fP\fB, png_charp \fItext\fP\fB);\fP +\fBvoid png_write_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP -\fBvoid png_write_oFFs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_offset\fP\fB, png_uint_32 \fP\fIy_offset\fP\fB, int \fIunit_type\fP\fB);\fP +\fI\fB -\fBvoid png_write_pCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIpurpose\fP\fB, png_int_32 \fP\fIX0\fP\fB, png_int_32 \fP\fIX1\fP\fB, int \fP\fItype\fP\fB, int \fP\fInparams\fP\fB, png_charp \fP\fIunits\fP\fB, png_charpp \fIparams\fP\fB);\fP +\fI\fB \fBvoid png_write_pHYs (png_structp \fP\fIpng_ptr\fP\fB, png_uint_32 \fP\fIx_pixels_per_unit\fP\fB, png_uint_32 \fP\fIy_pixels_per_unit\fP\fB, int \fIunit_type\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_PLTE (png_structp \fP\fIpng_ptr\fP\fB, png_colorp \fP\fIpalette\fP\fB, png_uint_32 \fInum_pal\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_sBIT (png_structp \fP\fIpng_ptr\fP\fB, png_color_8p \fP\fIsbit\fP\fB, int \fIcolor_type\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_sCAL (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, double \fP\fIwidth\fP\fB, double \fIheight\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_sCAL_s (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIunit\fP\fB, png_charp \fP\fIwidth\fP\fB, png_charp \fIheight\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_sig (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_sRGB (png_structp \fP\fIpng_ptr\fP\fB, int \fIintent\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_sPLT (png_structp \fP\fIpng_ptr\fP\fB, png_spalette_p \fIpalette\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_start_row (png_structp \fIpng_ptr\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_tEXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fItext_len\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_tIME (png_structp \fP\fIpng_ptr\fP\fB, png_timep \fImod_time\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_tRNS (png_structp \fP\fIpng_ptr\fP\fB, png_bytep \fP\fItrans\fP\fB, png_color_16p \fP\fIvalues\fP\fB, int \fP\fInumber\fP\fB, int \fIcolor_type\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_write_zTXt (png_structp \fP\fIpng_ptr\fP\fB, png_charp \fP\fIkey\fP\fB, png_charp \fP\fItext\fP\fB, png_size_t \fP\fItext_len\fP\fB, int \fIcompression\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoidpf png_zalloc (voidpf \fP\fIpng_ptr\fP\fB, uInt \fP\fIitems\fP\fB, uInt \fIsize\fP\fB);\fP +\fI\fB + +\fI\fB + \fBvoid png_zfree (voidpf \fP\fIpng_ptr\fP\fB, voidpf \fIptr\fP\fB);\fP \fI\fB +\fI\fB + .SH DESCRIPTION The functions listed above are used privately by libpng and are not recommended for use by applications. They are diff --git a/src/3rdparty/libpng/png.5 b/src/3rdparty/libpng/png.5 index 832a6f4..30923ba 100644 --- a/src/3rdparty/libpng/png.5 +++ b/src/3rdparty/libpng/png.5 @@ -1,4 +1,4 @@ -.TH PNG 5 "May 8, 2008" +.TH PNG 5 "September 10, 2009" .SH NAME png \- Portable Network Graphics (PNG) format .SH DESCRIPTION diff --git a/src/3rdparty/libpng/png.c b/src/3rdparty/libpng/png.c index 63ae86e..be1bd3a 100644 --- a/src/3rdparty/libpng/png.c +++ b/src/3rdparty/libpng/png.c @@ -1,11 +1,14 @@ /* png.c - location for general purpose libpng functions * - * Last changed in libpng 1.2.21 October 4, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.2.39 [August 13, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ #define PNG_INTERNAL @@ -13,7 +16,7 @@ #include "png.h" /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_29 Your_png_h_is_not_version_1_2_29; +typedef version_1_2_40 Your_png_h_is_not_version_1_2_40; /* Version information for C files. This had better match the version * string defined in png.h. */ @@ -53,18 +56,18 @@ PNG_tRNS; PNG_zTXt; #ifdef PNG_READ_SUPPORTED -/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ +/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ -/* start of interlace block */ +/* Start of interlace block */ PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; -/* offset to next interlace block */ +/* Offset to next interlace block */ PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; -/* start of interlace block in the y direction */ +/* Start of interlace block in the y direction */ PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; -/* offset to next interlace block in the y direction */ +/* Offset to next interlace block in the y direction */ PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need @@ -92,8 +95,9 @@ PNG_CONST int FARDATA png_pass_dsp_mask[] void PNGAPI png_set_sig_bytes(png_structp png_ptr, int num_bytes) { - if(png_ptr == NULL) return; - png_debug(1, "in png_set_sig_bytes\n"); + if (png_ptr == NULL) + return; + png_debug(1, "in png_set_sig_bytes"); if (num_bytes > 8) png_error(png_ptr, "Too many bytes for PNG signature."); @@ -144,7 +148,7 @@ png_check_sig(png_bytep sig, int num) #ifdef PNG_1_0_X voidpf PNGAPI #else -voidpf /* private */ +voidpf /* PRIVATE */ #endif png_zalloc(voidpf png_ptr, uInt items, uInt size) { @@ -153,7 +157,8 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size) png_uint_32 save_flags=p->flags; png_uint_32 num_bytes; - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); if (items > PNG_UINT_32_MAX/size) { png_warning (p, "Potential overflow in png_zalloc()"); @@ -183,11 +188,11 @@ png_zalloc(voidpf png_ptr, uInt items, uInt size) return ((voidpf)ptr); } -/* function to free memory for zlib */ +/* Function to free memory for zlib */ #ifdef PNG_1_0_X void PNGAPI #else -void /* private */ +void /* PRIVATE */ #endif png_zfree(voidpf png_ptr, voidpf ptr) { @@ -240,8 +245,9 @@ png_create_info_struct(png_structp png_ptr) { png_infop info_ptr; - png_debug(1, "in png_create_info_struct\n"); - if(png_ptr == NULL) return (NULL); + png_debug(1, "in png_create_info_struct"); + if (png_ptr == NULL) + return (NULL); #ifdef PNG_USER_MEM_SUPPORTED info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO, png_ptr->malloc_fn, png_ptr->mem_ptr); @@ -263,9 +269,10 @@ void PNGAPI png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr) { png_infop info_ptr = NULL; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; - png_debug(1, "in png_destroy_info_struct\n"); + png_debug(1, "in png_destroy_info_struct"); if (info_ptr_ptr != NULL) info_ptr = *info_ptr_ptr; @@ -302,19 +309,20 @@ png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size) { png_infop info_ptr = *ptr_ptr; - if(info_ptr == NULL) return; + if (info_ptr == NULL) + return; - png_debug(1, "in png_info_init_3\n"); + png_debug(1, "in png_info_init_3"); - if(png_sizeof(png_info) > png_info_struct_size) - { - png_destroy_struct(info_ptr); - info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); - *ptr_ptr = info_ptr; - } + if (png_sizeof(png_info) > png_info_struct_size) + { + png_destroy_struct(info_ptr); + info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO); + *ptr_ptr = info_ptr; + } - /* set everything to 0 */ - png_memset(info_ptr, 0, png_sizeof (png_info)); + /* Set everything to 0 */ + png_memset(info_ptr, 0, png_sizeof(png_info)); } #ifdef PNG_FREE_ME_SUPPORTED @@ -322,12 +330,12 @@ void PNGAPI png_data_freer(png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask) { - png_debug(1, "in png_data_freer\n"); + png_debug(1, "in png_data_freer"); if (png_ptr == NULL || info_ptr == NULL) return; - if(freer == PNG_DESTROY_WILL_FREE_DATA) + if (freer == PNG_DESTROY_WILL_FREE_DATA) info_ptr->free_me |= mask; - else if(freer == PNG_USER_WILL_FREE_DATA) + else if (freer == PNG_USER_WILL_FREE_DATA) info_ptr->free_me &= ~mask; else png_warning(png_ptr, @@ -339,249 +347,250 @@ void PNGAPI png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask, int num) { - png_debug(1, "in png_free_data\n"); + png_debug(1, "in png_free_data"); if (png_ptr == NULL || info_ptr == NULL) return; #if defined(PNG_TEXT_SUPPORTED) -/* free text item num or (if num == -1) all text items */ + /* Free text item num or (if num == -1) all text items */ #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) + if ((mask & PNG_FREE_TEXT) & info_ptr->free_me) #else -if (mask & PNG_FREE_TEXT) + if (mask & PNG_FREE_TEXT) #endif -{ - if (num != -1) - { - if (info_ptr->text && info_ptr->text[num].key) - { - png_free(png_ptr, info_ptr->text[num].key); - info_ptr->text[num].key = NULL; - } - } - else { - int i; - for (i = 0; i < info_ptr->num_text; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); - png_free(png_ptr, info_ptr->text); - info_ptr->text = NULL; - info_ptr->num_text=0; + if (num != -1) + { + if (info_ptr->text && info_ptr->text[num].key) + { + png_free(png_ptr, info_ptr->text[num].key); + info_ptr->text[num].key = NULL; + } + } + else + { + int i; + for (i = 0; i < info_ptr->num_text; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i); + png_free(png_ptr, info_ptr->text); + info_ptr->text = NULL; + info_ptr->num_text=0; + } } -} #endif #if defined(PNG_tRNS_SUPPORTED) -/* free any tRNS entry */ + /* Free any tRNS entry */ #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) + if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) #else -if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) + if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS)) #endif -{ - png_free(png_ptr, info_ptr->trans); - info_ptr->valid &= ~PNG_INFO_tRNS; + { + png_free(png_ptr, info_ptr->trans); + info_ptr->trans = NULL; + info_ptr->valid &= ~PNG_INFO_tRNS; #ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; + png_ptr->flags &= ~PNG_FLAG_FREE_TRNS; #endif - info_ptr->trans = NULL; -} + } #endif #if defined(PNG_sCAL_SUPPORTED) -/* free any sCAL entry */ + /* Free any sCAL entry */ #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) + if ((mask & PNG_FREE_SCAL) & info_ptr->free_me) #else -if (mask & PNG_FREE_SCAL) + if (mask & PNG_FREE_SCAL) #endif -{ + { #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, info_ptr->scal_s_width); - png_free(png_ptr, info_ptr->scal_s_height); - info_ptr->scal_s_width = NULL; - info_ptr->scal_s_height = NULL; + png_free(png_ptr, info_ptr->scal_s_width); + png_free(png_ptr, info_ptr->scal_s_height); + info_ptr->scal_s_width = NULL; + info_ptr->scal_s_height = NULL; #endif - info_ptr->valid &= ~PNG_INFO_sCAL; -} + info_ptr->valid &= ~PNG_INFO_sCAL; + } #endif #if defined(PNG_pCAL_SUPPORTED) -/* free any pCAL entry */ + /* Free any pCAL entry */ #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) + if ((mask & PNG_FREE_PCAL) & info_ptr->free_me) #else -if (mask & PNG_FREE_PCAL) + if (mask & PNG_FREE_PCAL) #endif -{ - png_free(png_ptr, info_ptr->pcal_purpose); - png_free(png_ptr, info_ptr->pcal_units); - info_ptr->pcal_purpose = NULL; - info_ptr->pcal_units = NULL; - if (info_ptr->pcal_params != NULL) - { - int i; - for (i = 0; i < (int)info_ptr->pcal_nparams; i++) - { - png_free(png_ptr, info_ptr->pcal_params[i]); - info_ptr->pcal_params[i]=NULL; - } - png_free(png_ptr, info_ptr->pcal_params); - info_ptr->pcal_params = NULL; - } - info_ptr->valid &= ~PNG_INFO_pCAL; -} + { + png_free(png_ptr, info_ptr->pcal_purpose); + png_free(png_ptr, info_ptr->pcal_units); + info_ptr->pcal_purpose = NULL; + info_ptr->pcal_units = NULL; + if (info_ptr->pcal_params != NULL) + { + int i; + for (i = 0; i < (int)info_ptr->pcal_nparams; i++) + { + png_free(png_ptr, info_ptr->pcal_params[i]); + info_ptr->pcal_params[i]=NULL; + } + png_free(png_ptr, info_ptr->pcal_params); + info_ptr->pcal_params = NULL; + } + info_ptr->valid &= ~PNG_INFO_pCAL; + } #endif #if defined(PNG_iCCP_SUPPORTED) -/* free any iCCP entry */ + /* Free any iCCP entry */ #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) + if ((mask & PNG_FREE_ICCP) & info_ptr->free_me) #else -if (mask & PNG_FREE_ICCP) + if (mask & PNG_FREE_ICCP) #endif -{ - png_free(png_ptr, info_ptr->iccp_name); - png_free(png_ptr, info_ptr->iccp_profile); - info_ptr->iccp_name = NULL; - info_ptr->iccp_profile = NULL; - info_ptr->valid &= ~PNG_INFO_iCCP; -} + { + png_free(png_ptr, info_ptr->iccp_name); + png_free(png_ptr, info_ptr->iccp_profile); + info_ptr->iccp_name = NULL; + info_ptr->iccp_profile = NULL; + info_ptr->valid &= ~PNG_INFO_iCCP; + } #endif #if defined(PNG_sPLT_SUPPORTED) -/* free a given sPLT entry, or (if num == -1) all sPLT entries */ + /* Free a given sPLT entry, or (if num == -1) all sPLT entries */ #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) + if ((mask & PNG_FREE_SPLT) & info_ptr->free_me) #else -if (mask & PNG_FREE_SPLT) + if (mask & PNG_FREE_SPLT) #endif -{ - if (num != -1) { - if(info_ptr->splt_palettes) + if (num != -1) { - png_free(png_ptr, info_ptr->splt_palettes[num].name); - png_free(png_ptr, info_ptr->splt_palettes[num].entries); - info_ptr->splt_palettes[num].name = NULL; - info_ptr->splt_palettes[num].entries = NULL; + if (info_ptr->splt_palettes) + { + png_free(png_ptr, info_ptr->splt_palettes[num].name); + png_free(png_ptr, info_ptr->splt_palettes[num].entries); + info_ptr->splt_palettes[num].name = NULL; + info_ptr->splt_palettes[num].entries = NULL; + } + } + else + { + if (info_ptr->splt_palettes_num) + { + int i; + for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); + + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes = NULL; + info_ptr->splt_palettes_num = 0; + } + info_ptr->valid &= ~PNG_INFO_sPLT; } } - else - { - if(info_ptr->splt_palettes_num) - { - int i; - for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i); - - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes = NULL; - info_ptr->splt_palettes_num = 0; - } - info_ptr->valid &= ~PNG_INFO_sPLT; - } -} #endif #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - if(png_ptr->unknown_chunk.data) - { - png_free(png_ptr, png_ptr->unknown_chunk.data); - png_ptr->unknown_chunk.data = NULL; - } + if (png_ptr->unknown_chunk.data) + { + png_free(png_ptr, png_ptr->unknown_chunk.data); + png_ptr->unknown_chunk.data = NULL; + } + #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) + if ((mask & PNG_FREE_UNKN) & info_ptr->free_me) #else -if (mask & PNG_FREE_UNKN) + if (mask & PNG_FREE_UNKN) #endif -{ - if (num != -1) { - if(info_ptr->unknown_chunks) - { - png_free(png_ptr, info_ptr->unknown_chunks[num].data); - info_ptr->unknown_chunks[num].data = NULL; - } - } - else - { - int i; + if (num != -1) + { + if (info_ptr->unknown_chunks) + { + png_free(png_ptr, info_ptr->unknown_chunks[num].data); + info_ptr->unknown_chunks[num].data = NULL; + } + } + else + { + int i; - if(info_ptr->unknown_chunks_num) - { - for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) - png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); + if (info_ptr->unknown_chunks_num) + { + for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++) + png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i); - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks = NULL; - info_ptr->unknown_chunks_num = 0; - } + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks = NULL; + info_ptr->unknown_chunks_num = 0; + } + } } -} #endif #if defined(PNG_hIST_SUPPORTED) -/* free any hIST entry */ + /* Free any hIST entry */ #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_HIST) & info_ptr->free_me) + if ((mask & PNG_FREE_HIST) & info_ptr->free_me) #else -if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) + if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST)) #endif -{ - png_free(png_ptr, info_ptr->hist); - info_ptr->hist = NULL; - info_ptr->valid &= ~PNG_INFO_hIST; + { + png_free(png_ptr, info_ptr->hist); + info_ptr->hist = NULL; + info_ptr->valid &= ~PNG_INFO_hIST; #ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_HIST; + png_ptr->flags &= ~PNG_FLAG_FREE_HIST; #endif -} + } #endif -/* free any PLTE entry that was internally allocated */ + /* Free any PLTE entry that was internally allocated */ #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) + if ((mask & PNG_FREE_PLTE) & info_ptr->free_me) #else -if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) + if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE)) #endif -{ - png_zfree(png_ptr, info_ptr->palette); - info_ptr->palette = NULL; - info_ptr->valid &= ~PNG_INFO_PLTE; + { + png_zfree(png_ptr, info_ptr->palette); + info_ptr->palette = NULL; + info_ptr->valid &= ~PNG_INFO_PLTE; #ifndef PNG_FREE_ME_SUPPORTED - png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; + png_ptr->flags &= ~PNG_FLAG_FREE_PLTE; #endif - info_ptr->num_palette = 0; -} + info_ptr->num_palette = 0; + } #if defined(PNG_INFO_IMAGE_SUPPORTED) -/* free any image bits attached to the info structure */ + /* Free any image bits attached to the info structure */ #ifdef PNG_FREE_ME_SUPPORTED -if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) + if ((mask & PNG_FREE_ROWS) & info_ptr->free_me) #else -if (mask & PNG_FREE_ROWS) + if (mask & PNG_FREE_ROWS) #endif -{ - if(info_ptr->row_pointers) - { - int row; - for (row = 0; row < (int)info_ptr->height; row++) - { - png_free(png_ptr, info_ptr->row_pointers[row]); - info_ptr->row_pointers[row]=NULL; - } - png_free(png_ptr, info_ptr->row_pointers); - info_ptr->row_pointers=NULL; - } - info_ptr->valid &= ~PNG_INFO_IDAT; -} + { + if (info_ptr->row_pointers) + { + int row; + for (row = 0; row < (int)info_ptr->height; row++) + { + png_free(png_ptr, info_ptr->row_pointers[row]); + info_ptr->row_pointers[row]=NULL; + } + png_free(png_ptr, info_ptr->row_pointers); + info_ptr->row_pointers=NULL; + } + info_ptr->valid &= ~PNG_INFO_IDAT; + } #endif #ifdef PNG_FREE_ME_SUPPORTED - if(num == -1) - info_ptr->free_me &= ~mask; + if (num == -1) + info_ptr->free_me &= ~mask; else - info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); + info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL); #endif } @@ -592,16 +601,16 @@ if (mask & PNG_FREE_ROWS) void /* PRIVATE */ png_info_destroy(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_info_destroy\n"); + png_debug(1, "in png_info_destroy"); png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1); -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) if (png_ptr->num_chunk_list) { - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + png_ptr->num_chunk_list = 0; } #endif @@ -616,7 +625,8 @@ png_info_destroy(png_structp png_ptr, png_infop info_ptr) png_voidp PNGAPI png_get_io_ptr(png_structp png_ptr) { - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); return (png_ptr->io_ptr); } @@ -631,8 +641,9 @@ png_get_io_ptr(png_structp png_ptr) void PNGAPI png_init_io(png_structp png_ptr, png_FILE_p fp) { - png_debug(1, "in png_init_io\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_init_io"); + if (png_ptr == NULL) + return; png_ptr->io_ptr = (png_voidp)fp; } #endif @@ -648,7 +659,8 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); if (png_ptr->time_buffer == NULL) { png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29* @@ -669,7 +681,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) #ifdef USE_FAR_KEYWORD { char near_time_buf[29]; - png_snprintf6(near_time_buf,29,"%d %s %d %02d:%02d:%02d +0000", + png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000", ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); @@ -677,7 +689,7 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) 29*png_sizeof(char)); } #else - png_snprintf6(png_ptr->time_buffer,29,"%d %s %d %02d:%02d:%02d +0000", + png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000", ptime->day % 32, short_months[(ptime->month - 1) % 12], ptime->year, ptime->hour % 24, ptime->minute % 60, ptime->second % 61); @@ -692,9 +704,9 @@ png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime) png_charp PNGAPI png_get_copyright(png_structp png_ptr) { - png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ - return ((png_charp) "\n libpng version 1.2.29 - May 8, 2008\n\ - Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\ + png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */ + return ((png_charp) "\n libpng version 1.2.40 - September 10, 2009\n\ + Copyright (c) 1998-2009 Glenn Randers-Pehrson\n\ Copyright (c) 1996-1997 Andreas Dilger\n\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n"); } @@ -711,7 +723,7 @@ png_charp PNGAPI png_get_libpng_ver(png_structp png_ptr) { /* Version of *.c files used when building libpng */ - png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ + png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */ return ((png_charp) PNG_LIBPNG_VER_STRING); } @@ -719,7 +731,7 @@ png_charp PNGAPI png_get_header_ver(png_structp png_ptr) { /* Version of *.h files used when building libpng */ - png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ + png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */ return ((png_charp) PNG_LIBPNG_VER_STRING); } @@ -727,7 +739,7 @@ png_charp PNGAPI png_get_header_version(png_structp png_ptr) { /* Returns longer string containing both version and date */ - png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */ + png_ptr = png_ptr; /* Silence compiler warning about unused png_ptr */ return ((png_charp) PNG_HEADER_VERSION_STRING #ifndef PNG_READ_SUPPORTED " (NO READ SUPPORT)" @@ -740,15 +752,15 @@ png_get_header_version(png_structp png_ptr) int PNGAPI png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) { - /* check chunk_name and return "keep" value if it's on the list, else 0 */ + /* Check chunk_name and return "keep" value if it's on the list, else 0 */ int i; png_bytep p; - if(png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0) + if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0) return 0; - p=png_ptr->chunk_list+png_ptr->num_chunk_list*5-5; - for (i = png_ptr->num_chunk_list; i; i--, p-=5) + p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5; + for (i = png_ptr->num_chunk_list; i; i--, p -= 5) if (!png_memcmp(chunk_name, p, 4)) - return ((int)*(p+4)); + return ((int)*(p + 4)); return 0; } #endif @@ -757,7 +769,8 @@ png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name) int PNGAPI png_reset_zstream(png_structp png_ptr) { - if (png_ptr == NULL) return Z_STREAM_ERROR; + if (png_ptr == NULL) + return Z_STREAM_ERROR; return (inflateReset(&png_ptr->zstream)); } #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ @@ -773,11 +786,11 @@ png_access_version_number(void) #if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED) #if !defined(PNG_1_0_X) -/* this function was added to libpng 1.2.0 */ +/* This function was added to libpng 1.2.0 */ int PNGAPI png_mmx_support(void) { - /* obsolete, to be removed from libpng-1.4.0 */ + /* Obsolete, to be removed from libpng-1.4.0 */ return -1; } #endif /* PNG_1_0_X */ @@ -790,9 +803,124 @@ png_mmx_support(void) png_size_t PNGAPI png_convert_size(size_t size) { - if (size > (png_size_t)-1) - PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ - return ((png_size_t)size); + if (size > (png_size_t)-1) + PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */ + return ((png_size_t)size); } #endif /* PNG_SIZE_T */ + +/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ +#if defined(PNG_cHRM_SUPPORTED) +#if !defined(PNG_NO_CHECK_cHRM) + +/* + * Multiply two 32-bit numbers, V1 and V2, using 32-bit + * arithmetic, to produce a 64 bit result in the HI/LO words. + * + * A B + * x C D + * ------ + * AD || BD + * AC || CB || 0 + * + * where A and B are the high and low 16-bit words of V1, + * C and D are the 16-bit words of V2, AD is the product of + * A and D, and X || Y is (X << 16) + Y. +*/ + +void /* PRIVATE */ +png_64bit_product (long v1, long v2, unsigned long *hi_product, + unsigned long *lo_product) +{ + int a, b, c, d; + long lo, hi, x, y; + + a = (v1 >> 16) & 0xffff; + b = v1 & 0xffff; + c = (v2 >> 16) & 0xffff; + d = v2 & 0xffff; + + lo = b * d; /* BD */ + x = a * d + c * b; /* AD + CB */ + y = ((lo >> 16) & 0xffff) + x; + + lo = (lo & 0xffff) | ((y & 0xffff) << 16); + hi = (y >> 16) & 0xffff; + + hi += a * c; /* AC */ + + *hi_product = (unsigned long)hi; + *lo_product = (unsigned long)lo; +} + +int /* PRIVATE */ +png_check_cHRM_fixed(png_structp png_ptr, + png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x, + png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, + png_fixed_point blue_x, png_fixed_point blue_y) +{ + int ret = 1; + unsigned long xy_hi,xy_lo,yx_hi,yx_lo; + + png_debug(1, "in function png_check_cHRM_fixed"); + if (png_ptr == NULL) + return 0; + + if (white_x < 0 || white_y <= 0 || + red_x < 0 || red_y < 0 || + green_x < 0 || green_y < 0 || + blue_x < 0 || blue_y < 0) + { + png_warning(png_ptr, + "Ignoring attempt to set negative chromaticity value"); + ret = 0; + } + if (white_x > (png_fixed_point) PNG_UINT_31_MAX || + white_y > (png_fixed_point) PNG_UINT_31_MAX || + red_x > (png_fixed_point) PNG_UINT_31_MAX || + red_y > (png_fixed_point) PNG_UINT_31_MAX || + green_x > (png_fixed_point) PNG_UINT_31_MAX || + green_y > (png_fixed_point) PNG_UINT_31_MAX || + blue_x > (png_fixed_point) PNG_UINT_31_MAX || + blue_y > (png_fixed_point) PNG_UINT_31_MAX ) + { + png_warning(png_ptr, + "Ignoring attempt to set chromaticity value exceeding 21474.83"); + ret = 0; + } + if (white_x > 100000L - white_y) + { + png_warning(png_ptr, "Invalid cHRM white point"); + ret = 0; + } + if (red_x > 100000L - red_y) + { + png_warning(png_ptr, "Invalid cHRM red point"); + ret = 0; + } + if (green_x > 100000L - green_y) + { + png_warning(png_ptr, "Invalid cHRM green point"); + ret = 0; + } + if (blue_x > 100000L - blue_y) + { + png_warning(png_ptr, "Invalid cHRM blue point"); + ret = 0; + } + + png_64bit_product(green_x - red_x, blue_y - red_y, &xy_hi, &xy_lo); + png_64bit_product(green_y - red_y, blue_x - red_x, &yx_hi, &yx_lo); + + if (xy_hi == yx_hi && xy_lo == yx_lo) + { + png_warning(png_ptr, + "Ignoring attempt to set cHRM RGB triangle with zero area"); + ret = 0; + } + + return ret; +} +#endif /* NO_PNG_CHECK_cHRM */ +#endif /* PNG_cHRM_SUPPORTED */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ diff --git a/src/3rdparty/libpng/png.h b/src/3rdparty/libpng/png.h index 2e194b7..d95339d 100644 --- a/src/3rdparty/libpng/png.h +++ b/src/3rdparty/libpng/png.h @@ -1,14 +1,16 @@ /* png.h - header file for PNG reference library * - * libpng version 1.2.29 - May 8, 2008 - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * libpng version 1.2.40 - September 10, 2009 + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license (See LICENSE, below) + * * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.2.29 - May 8, 2008: Glenn + * libpng versions 0.97, January 1998, through 1.2.40 - September 10, 2009: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -192,6 +194,57 @@ * 1.2.29rc01 13 10229 12.so.0.29[.0] * 1.0.35 10 10035 10.so.0.35[.0] * 1.2.29 13 10229 12.so.0.29[.0] + * 1.0.37 10 10037 10.so.0.37[.0] + * 1.2.30beta01-04 13 10230 12.so.0.30[.0] + * 1.0.38rc01-08 10 10038 10.so.0.38[.0] + * 1.2.30rc01-08 13 10230 12.so.0.30[.0] + * 1.0.38 10 10038 10.so.0.38[.0] + * 1.2.30 13 10230 12.so.0.30[.0] + * 1.0.39rc01-03 10 10039 10.so.0.39[.0] + * 1.2.31rc01-03 13 10231 12.so.0.31[.0] + * 1.0.39 10 10039 10.so.0.39[.0] + * 1.2.31 13 10231 12.so.0.31[.0] + * 1.2.32beta01-02 13 10232 12.so.0.32[.0] + * 1.0.40rc01 10 10040 10.so.0.40[.0] + * 1.2.32rc01 13 10232 12.so.0.32[.0] + * 1.0.40 10 10040 10.so.0.40[.0] + * 1.2.32 13 10232 12.so.0.32[.0] + * 1.2.33beta01-02 13 10233 12.so.0.33[.0] + * 1.2.33rc01-02 13 10233 12.so.0.33[.0] + * 1.0.41rc01 10 10041 10.so.0.41[.0] + * 1.2.33 13 10233 12.so.0.33[.0] + * 1.0.41 10 10041 10.so.0.41[.0] + * 1.2.34beta01-07 13 10234 12.so.0.34[.0] + * 1.0.42rc01 10 10042 10.so.0.42[.0] + * 1.2.34rc01 13 10234 12.so.0.34[.0] + * 1.0.42 10 10042 10.so.0.42[.0] + * 1.2.34 13 10234 12.so.0.34[.0] + * 1.2.35beta01-03 13 10235 12.so.0.35[.0] + * 1.0.43rc01-02 10 10043 10.so.0.43[.0] + * 1.2.35rc01-02 13 10235 12.so.0.35[.0] + * 1.0.43 10 10043 10.so.0.43[.0] + * 1.2.35 13 10235 12.so.0.35[.0] + * 1.2.36beta01-05 13 10236 12.so.0.36[.0] + * 1.2.36rc01 13 10236 12.so.0.36[.0] + * 1.0.44 10 10044 10.so.0.44[.0] + * 1.2.36 13 10236 12.so.0.36[.0] + * 1.2.37beta01-03 13 10237 12.so.0.37[.0] + * 1.2.37rc01 13 10237 12.so.0.37[.0] + * 1.2.37 13 10237 12.so.0.37[.0] + * 1.2.45 10 10045 12.so.0.45[.0] + * 1.0.46 10 10046 10.so.0.46[.0] + * 1.2.38beta01 13 10238 12.so.0.38[.0] + * 1.2.38rc01-03 13 10238 12.so.0.38[.0] + * 1.0.47 10 10047 10.so.0.47[.0] + * 1.2.38 13 10238 12.so.0.38[.0] + * 1.2.39beta01-05 13 10239 12.so.0.39[.0] + * 1.2.39rc01 13 10239 12.so.0.39[.0] + * 1.0.48 10 10048 10.so.0.48[.0] + * 1.2.39 13 10239 12.so.0.39[.0] + * 1.2.40beta01 13 10240 12.so.0.40[.0] + * 1.2.40rc01 13 10240 12.so.0.40[.0] + * 1.0.49 10 10049 10.so.0.49[.0] + * 1.2.40 13 10240 12.so.0.40[.0] * * Henceforth the source version will match the shared-library major * and minor numbers; the shared-library major version number will be @@ -221,8 +274,10 @@ * If you modify libpng you may insert additional notices immediately following * this sentence. * - * libpng versions 1.2.6, August 15, 2004, through 1.2.29, May 8, 2008, are - * Copyright (c) 2004, 2006-2008 Glenn Randers-Pehrson, and are + * This code is released under the libpng license. + * + * libpng versions 1.2.6, August 15, 2004, through 1.2.40, September 10, 2009, are + * Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are * distributed according to the same disclaimer and license as libpng-1.2.5 * with the following individual added to the list of Contributing Authors: * @@ -333,13 +388,13 @@ * Y2K compliance in libpng: * ========================= * - * May 8, 2008 + * September 10, 2009 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. * * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.2.29 are Y2K compliant. It is my belief that earlier + * upward through 1.2.40 are Y2K compliant. It is my belief that earlier * versions were also Y2K compliant. * * Libpng only has three year fields. One is a 2-byte unsigned integer @@ -395,9 +450,9 @@ */ /* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.2.29" +#define PNG_LIBPNG_VER_STRING "1.2.40" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.2.29 - May 8, 2008\n" + " libpng version 1.2.40 - September 10, 2009\n" #define PNG_LIBPNG_VER_SONUM 0 #define PNG_LIBPNG_VER_DLLNUM 13 @@ -405,9 +460,10 @@ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ #define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MINOR 2 -#define PNG_LIBPNG_VER_RELEASE 29 +#define PNG_LIBPNG_VER_RELEASE 40 /* This should match the numeric part of the final component of - * PNG_LIBPNG_VER_STRING, omitting any leading zero: */ + * PNG_LIBPNG_VER_STRING, omitting any leading zero: + */ #define PNG_LIBPNG_VER_BUILD 0 @@ -417,7 +473,7 @@ #define PNG_LIBPNG_BUILD_RC 3 #define PNG_LIBPNG_BUILD_STABLE 4 #define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 - + /* Release-Specific Flags */ #define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with PNG_LIBPNG_BUILD_STABLE only */ @@ -432,15 +488,16 @@ * We must not include leading zeros. * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only * version 1.0.0 was mis-numbered 100 instead of 10000). From - * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */ -#define PNG_LIBPNG_VER 10229 /* 1.2.29 */ + * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release + */ +#define PNG_LIBPNG_VER 10240 /* 1.2.40 */ #ifndef PNG_VERSION_INFO_ONLY -/* include the compression library's header */ +/* Include the compression library's header */ #include "zlib.h" #endif -/* include all user configurable info, including optional assembler routines */ +/* Include all user configurable info, including optional assembler routines */ #include "pngconf.h" /* @@ -448,12 +505,12 @@ /* Ref MSDN: Private as priority over Special * VS_FF_PRIVATEBUILD File *was not* built using standard release * procedures. If this value is given, the StringFileInfo block must - * contain a PrivateBuild string. + * contain a PrivateBuild string. * * VS_FF_SPECIALBUILD File *was* built by the original company using * standard release procedures but is a variation of the standard * file of the same version number. If this value is given, the - * StringFileInfo block must contain a SpecialBuild string. + * StringFileInfo block must contain a SpecialBuild string. */ #if defined(PNG_USER_PRIVATEBUILD) @@ -515,14 +572,14 @@ extern "C" { #define png_write_status_ptr_NULL NULL #endif -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +/* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */ #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) /* Version information for C files, stored in png.c. This had better match * the version above. */ #ifdef PNG_USE_GLOBAL_ARRAYS PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18]; - /* need room for 99.99.99beta99z */ + /* Need room for 99.99.99beta99z */ #else #define png_libpng_ver png_get_header_ver(NULL) #endif @@ -641,7 +698,8 @@ typedef png_text FAR * FAR * png_textpp; #endif /* Supported compression types for text in PNG files (tEXt, and zTXt). - * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ + * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. + */ #define PNG_TEXT_COMPRESSION_NONE_WR -3 #define PNG_TEXT_COMPRESSION_zTXt_WR -2 #define PNG_TEXT_COMPRESSION_NONE -1 @@ -668,7 +726,8 @@ typedef struct png_time_struct typedef png_time FAR * png_timep; typedef png_time FAR * FAR * png_timepp; -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ + defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) /* png_unknown_chunk is a structure to hold queued chunks for which there is * no specific support. The idea is that we can use this to queue * up private chunks for output even though the library doesn't actually @@ -730,7 +789,7 @@ typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; */ typedef struct png_info_struct { - /* the following are necessary for every PNG file */ + /* The following are necessary for every PNG file */ png_uint_32 width; /* width of image in pixels (from IHDR) */ png_uint_32 height; /* height of image in pixels (from IHDR) */ png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */ @@ -903,8 +962,9 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) png_uint_32 free_me; /* flags items libpng is responsible for freeing */ #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunks that the library doesn't recognize. */ +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ + defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) + /* Storage for unknown chunks that the library doesn't recognize. */ png_unknown_chunkp unknown_chunks; png_size_t unknown_chunks_num; #endif @@ -919,7 +979,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) #endif #if defined(PNG_sPLT_SUPPORTED) - /* data on sPLT chunks (there may be more than one). */ + /* Data on sPLT chunks (there may be more than one). */ png_sPLT_tp splt_palettes; png_uint_32 splt_palettes_num; #endif @@ -1134,7 +1194,10 @@ typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp)); #define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ #define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ #define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only */ +#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only, deprecated */ +/* Added to libpng-1.2.34 */ +#define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800 /* write only */ +#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ /* Flags for MNG supported features */ #define PNG_FLAG_MNG_EMPTY_PLTE 0x01 @@ -1204,7 +1267,7 @@ struct png_struct_def png_uint_32 row_number; /* current row in interlace pass */ png_bytep prev_row; /* buffer to save previous (unfiltered) row */ png_bytep row_buf; /* buffer to save current (unfiltered) row */ -#ifndef PNG_NO_WRITE_FILTERING +#ifndef PNG_NO_WRITE_FILTER png_bytep sub_row; /* buffer to save "sub" row when filtering */ png_bytep up_row; /* buffer to save "up" row when filtering */ png_bytep avg_row; /* buffer to save "avg" row when filtering */ @@ -1251,7 +1314,7 @@ struct png_struct_def #endif /* PNG_bKGD_SUPPORTED */ #if defined(PNG_WRITE_FLUSH_SUPPORTED) - png_flush_ptr output_flush_fn;/* Function for flushing output */ + png_flush_ptr output_flush_fn; /* Function for flushing output */ png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */ png_uint_32 flush_rows; /* number of rows written since last flush */ #endif @@ -1349,7 +1412,7 @@ struct png_struct_def /* New members added in libpng-1.0.6 */ #ifdef PNG_FREE_ME_SUPPORTED - png_uint_32 free_me; /* flags items libpng is responsible for freeing */ + png_uint_32 free_me; /* flags items libpng is responsible for freeing */ #endif #if defined(PNG_USER_CHUNKS_SUPPORTED) @@ -1357,7 +1420,7 @@ struct png_struct_def png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */ #endif -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED int num_chunk_list; png_bytep chunk_list; #endif @@ -1375,7 +1438,7 @@ struct png_struct_def #if defined(PNG_MNG_FEATURES_SUPPORTED) || \ defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \ defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED) -/* changed from png_byte to png_uint_32 at version 1.2.0 */ +/* Changed from png_byte to png_uint_32 at version 1.2.0 */ #ifdef PNG_1_0_X png_byte mng_features_permitted; #else @@ -1411,21 +1474,21 @@ struct png_struct_def /* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */ #ifdef PNG_USER_MEM_SUPPORTED - png_voidp mem_ptr; /* user supplied struct for mem functions */ - png_malloc_ptr malloc_fn; /* function for allocating memory */ - png_free_ptr free_fn; /* function for freeing memory */ + png_voidp mem_ptr; /* user supplied struct for mem functions */ + png_malloc_ptr malloc_fn; /* function for allocating memory */ + png_free_ptr free_fn; /* function for freeing memory */ #endif /* New member added in libpng-1.0.13 and 1.2.0 */ - png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ + png_bytep big_row_buf; /* buffer to save current (unfiltered) row */ #if defined(PNG_READ_DITHER_SUPPORTED) /* The following three members were added at version 1.0.14 and 1.2.4 */ - png_bytep dither_sort; /* working sort array */ - png_bytep index_to_palette; /* where the original index currently is */ - /* in the palette */ - png_bytep palette_to_index; /* which original index points to this */ - /* palette color */ + png_bytep dither_sort; /* working sort array */ + png_bytep index_to_palette; /* where the original index currently is */ + /* in the palette */ + png_bytep palette_to_index; /* which original index points to this */ + /* palette color */ #endif /* New members added in libpng-1.0.16 and 1.2.6 */ @@ -1438,19 +1501,23 @@ struct png_struct_def /* New member added in libpng-1.0.25 and 1.2.17 */ #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) - /* storage for unknown chunk that the library doesn't recognize. */ + /* Storage for unknown chunk that the library doesn't recognize. */ png_unknown_chunk unknown_chunk; #endif /* New members added in libpng-1.2.26 */ png_uint_32 old_big_row_buf_size, old_prev_row_size; + +/* New member added in libpng-1.2.30 */ + png_charp chunkdata; /* buffer for reading chunk data */ + }; /* This triggers a compiler error in png.c, if png.c and png.h * do not agree upon the version number. */ -typedef png_structp version_1_2_29; +typedef png_structp version_1_2_40; typedef png_struct FAR * FAR * png_structpp; @@ -1554,7 +1621,7 @@ extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr, png_infop info_ptr)); #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the information before the actual image data. */ +/* Read the information before the actual image data. */ extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr, png_infop info_ptr)); #endif @@ -1567,11 +1634,11 @@ extern PNG_EXPORT(png_charp,png_convert_to_rfc1123) #if !defined(_WIN32_WCE) /* "time.h" functions are not supported on WindowsCE */ #if defined(PNG_WRITE_tIME_SUPPORTED) -/* convert from a struct tm to png_time */ +/* Convert from a struct tm to png_time */ extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime, struct tm FAR * ttime)); -/* convert from time_t to png_time. Uses gmtime() */ +/* Convert from time_t to png_time. Uses gmtime() */ extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime, time_t ttime)); #endif /* PNG_WRITE_tIME_SUPPORTED */ @@ -1691,7 +1758,7 @@ extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr, #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip the second byte of information from a 16-bit depth file. */ +/* Strip the second byte of information from a 16-bit depth file. */ extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr)); #endif @@ -1727,74 +1794,74 @@ extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows)); extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr)); #endif -/* optional update palette with requested transformations */ +/* Optional update palette with requested transformations */ extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ +/* Optional call to update the users info structure */ extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr, png_infop info_ptr)); #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read one or more rows of image data. */ +/* Read one or more rows of image data. */ extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr, png_bytepp row, png_bytepp display_row, png_uint_32 num_rows)); #endif #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read a row of data. */ +/* Read a row of data. */ extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr, png_bytep row, png_bytep display_row)); #endif #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the whole image into memory at once. */ +/* Read the whole image into memory at once. */ extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr, png_bytepp image)); #endif -/* write a row of image data */ +/* Write a row of image data */ extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr, png_bytep row)); -/* write a few rows of image data */ +/* Write a few rows of image data */ extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr, png_bytepp row, png_uint_32 num_rows)); -/* write the image data */ +/* Write the image data */ extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr, png_bytepp image)); -/* writes the end of the PNG file. */ +/* Writes the end of the PNG file. */ extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr, png_infop info_ptr)); #ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED -/* read the end of the PNG file. */ +/* Read the end of the PNG file. */ extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr, png_infop info_ptr)); #endif -/* free any memory associated with the png_info_struct */ +/* Free any memory associated with the png_info_struct */ extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr, png_infopp info_ptr_ptr)); -/* free any memory associated with the png_struct and the png_info_structs */ +/* Free any memory associated with the png_struct and the png_info_structs */ extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); -/* free all memory used by the read (old method - NOT DLL EXPORTED) */ +/* Free all memory used by the read (old method - NOT DLL EXPORTED) */ extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)); -/* free any memory associated with the png_struct and the png_info_structs */ +/* Free any memory associated with the png_struct and the png_info_structs */ extern PNG_EXPORT(void,png_destroy_write_struct) PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr)); -/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ +/* Free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */ extern void png_write_destroy PNGARG((png_structp png_ptr)); -/* set the libpng method of handling chunk CRC errors */ +/* Set the libpng method of handling chunk CRC errors */ extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, int crit_action, int ancil_action)); @@ -1822,7 +1889,7 @@ extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr, * header file (zlib.h) for an explination of the compression functions. */ -/* set the filtering method(s) used by libpng. Currently, the only valid +/* Set the filtering method(s) used by libpng. Currently, the only valid * value for "method" is 0. */ extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method, @@ -1950,6 +2017,11 @@ extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr)); * If buffered output is not used, then output_flush_fn can be set to NULL. * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time * output_flush_fn will be ignored (and thus can be NULL). + * It is probably a mistake to use NULL for output_flush_fn if + * write_data_fn is not also NULL unless you have built libpng with + * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's + * default flush function, which uses the standard *FILE structure, will + * be used. */ extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); @@ -2014,15 +2086,15 @@ extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); -/* returns the user pointer associated with the push read functions */ +/* Returns the user pointer associated with the push read functions */ extern PNG_EXPORT(png_voidp,png_get_progressive_ptr) PNGARG((png_structp png_ptr)); -/* function to be called when data becomes available */ +/* Function to be called when data becomes available */ extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr, png_infop info_ptr, png_bytep buffer, png_size_t buffer_size)); -/* function that combines rows. Not very much different than the +/* Function that combines rows. Not very much different than the * png_combine_row() call. Is this even used????? */ extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr, @@ -2040,7 +2112,7 @@ extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr, png_uint_32 size)); #endif -/* frees a pointer allocated by png_malloc() */ +/* Frees a pointer allocated by png_malloc() */ extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr)); #if defined(PNG_1_0_X) @@ -2057,11 +2129,12 @@ extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 free_me, int num)); #ifdef PNG_FREE_ME_SUPPORTED /* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application */ + * by libpng or by the application + */ extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask)); #endif -/* assignments for png_data_freer */ +/* Assignments for png_data_freer */ #define PNG_DESTROY_WILL_FREE_DATA 1 #define PNG_SET_WILL_FREE_DATA 1 #define PNG_USER_WILL_FREE_DATA 2 @@ -2145,11 +2218,13 @@ png_infop info_ptr)); #if defined(PNG_INFO_IMAGE_SUPPORTED) /* Returns row_pointers, which is an array of pointers to scanlines that was -returned from png_read_png(). */ + * returned from png_read_png(). + */ extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr, png_infop info_ptr)); /* Set row_pointers, which is an array of pointers to scanlines for use -by png_write_png(). */ + * by png_write_png(). + */ extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)); #endif @@ -2450,8 +2525,8 @@ extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, #endif #endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */ -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) -/* provide a list of chunks and how they are to be handled, if the built-in +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +/* Provide a list of chunks and how they are to be handled, if the built-in handling or default unknown chunk handling is not desired. Any chunks not listed will be handled in the default manner. The IHDR and IEND chunks must not be listed. @@ -2462,6 +2537,10 @@ extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr, */ extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp png_ptr, int keep, png_bytep chunk_list, int num_chunks)); +PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep + chunk_name)); +#endif +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr, png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)); extern PNG_EXPORT(void, png_set_unknown_chunk_location) @@ -2469,14 +2548,11 @@ extern PNG_EXPORT(void, png_set_unknown_chunk_location) extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp png_ptr, png_infop info_ptr, png_unknown_chunkpp entries)); #endif -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep - chunk_name)); -#endif /* Png_free_data() will turn off the "valid" flag for anything it frees. - If you need to turn it off for a chunk that your application has freed, - you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */ + * If you need to turn it off for a chunk that your application has freed, + * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); + */ extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr, png_infop info_ptr, int mask)); @@ -2502,34 +2578,90 @@ extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr, #if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) #include #if (PNG_DEBUG > 1) -#define png_debug(l,m) _RPT0(_CRT_WARN,m) -#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m,p1) -#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m,p1,p2) +#ifndef _DEBUG +# define _DEBUG +#endif +#ifndef png_debug +#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) +#endif +#ifndef png_debug1 +#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) +#endif +#ifndef png_debug2 +#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) +#endif #endif #else /* PNG_DEBUG_FILE || !_MSC_VER */ #ifndef PNG_DEBUG_FILE #define PNG_DEBUG_FILE stderr #endif /* PNG_DEBUG_FILE */ + #if (PNG_DEBUG > 1) -#define png_debug(l,m) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ -} -#define png_debug1(l,m,p1) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ -} -#define png_debug2(l,m,p1,p2) \ -{ \ - int num_tabs=l; \ - fprintf(PNG_DEBUG_FILE,"%s"m,(num_tabs==1 ? "\t" : \ - (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ -} +/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on non-ISO + * compilers. + */ +# ifdef __STDC__ +# ifndef png_debug +# define png_debug(l,m) \ + { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ + } +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ + } +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + { \ + int num_tabs=l; \ + fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ + } +# endif +# else /* __STDC __ */ +# ifndef png_debug +# define png_debug(l,m) \ + { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format); \ + } +# endif +# ifndef png_debug1 +# define png_debug1(l,m,p1) \ + { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1); \ + } +# endif +# ifndef png_debug2 +# define png_debug2(l,m,p1,p2) \ + { \ + int num_tabs=l; \ + char format[256]; \ + snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ + (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ + m,PNG_STRING_NEWLINE); \ + fprintf(PNG_DEBUG_FILE,format,p1,p2); \ + } +# endif +# endif /* __STDC __ */ #endif /* (PNG_DEBUG > 1) */ + #endif /* _MSC_VER */ #endif /* (PNG_DEBUG > 0) */ #endif /* PNG_DEBUG */ @@ -2624,17 +2756,17 @@ extern PNG_EXPORT(void,png_set_mmx_thresholds) #if !defined(PNG_1_0_X) /* png.c, pnggccrd.c, or pngvcrd.c */ extern PNG_EXPORT(int,png_mmx_support) PNGARG((void)); +#endif /* PNG_1_0_X */ #endif /* PNG_ASSEMBLER_CODE_SUPPORTED */ /* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. */ + * messages before passing them to the error or warning handler. + */ #ifdef PNG_ERROR_NUMBERS_SUPPORTED extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp png_ptr, png_uint_32 strip_mode)); #endif -#endif /* PNG_1_0_X */ - /* Added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp @@ -2645,7 +2777,10 @@ extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp png_ptr)); #endif -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */ + +/* Maintainer: Put new public prototypes here ^, in libpng.3, and in + * project defs + */ #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED /* With these routines we avoid an integer divide, which will be slower on @@ -2674,7 +2809,7 @@ extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp (png_uint_32)(alpha)) + (png_uint_32)32768L); \ (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } -#else /* standard method using integer division */ +#else /* Standard method using integer division */ # define png_composite(composite, fg, alpha, bg) \ (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ @@ -2757,7 +2892,7 @@ extern PNG_EXPORT(void,png_save_uint_16) #define PNG_HAVE_PNG_SIGNATURE 0x1000 #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ -/* flags for the transformations the PNG library does on the image data */ +/* Flags for the transformations the PNG library does on the image data */ #define PNG_BGR 0x0001 #define PNG_INTERLACE 0x0002 #define PNG_PACK 0x0004 @@ -2791,7 +2926,7 @@ extern PNG_EXPORT(void,png_save_uint_16) /* 0x20000000L unused */ /* 0x40000000L unused */ -/* flags for png_create_struct */ +/* Flags for png_create_struct */ #define PNG_STRUCT_PNG 0x0001 #define PNG_STRUCT_INFO 0x0002 @@ -2801,7 +2936,7 @@ extern PNG_EXPORT(void,png_save_uint_16) #define PNG_COST_SHIFT 3 #define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT)) -/* flags for the png_ptr->flags rather than declaring a byte for each one */ +/* Flags for the png_ptr->flags rather than declaring a byte for each one */ #define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001 #define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002 #define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004 @@ -2843,7 +2978,7 @@ extern PNG_EXPORT(void,png_save_uint_16) #define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \ PNG_FLAG_CRC_CRITICAL_MASK) -/* save typing and make code easier to understand */ +/* Save typing and make code easier to understand */ #define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \ abs((int)((c1).green) - (int)((c2).green)) + \ @@ -2856,15 +2991,16 @@ extern PNG_EXPORT(void,png_save_uint_16) (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) ) /* PNG_OUT_OF_RANGE returns true if value is outside the range - ideal-delta..ideal+delta. Each argument is evaluated twice. - "ideal" and "delta" should be constants, normally simple - integers, "value" a variable. Added to libpng-1.2.6 JB */ + * ideal-delta..ideal+delta. Each argument is evaluated twice. + * "ideal" and "delta" should be constants, normally simple + * integers, "value" a variable. Added to libpng-1.2.6 JB + */ #define PNG_OUT_OF_RANGE(value, ideal, delta) \ ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) ) -/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */ +/* Variables declared in png.c - only it needs to define PNG_NO_EXTERN */ #if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN) -/* place to hold the signature string for a PNG file. */ +/* Place to hold the signature string for a PNG file. */ #ifdef PNG_USE_GLOBAL_ARRAYS PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8]; #else @@ -2983,7 +3119,8 @@ PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr)); #endif /* Next four functions are used internally as callbacks. PNGAPI is required - * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */ + * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. + */ PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr, png_bytep data, png_size_t length)); @@ -3026,8 +3163,8 @@ PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf, /* Decompress data in a chunk that uses compression */ #if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \ defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) -PNG_EXTERN png_charp png_decompress_chunk PNGARG((png_structp png_ptr, - int comp_type, png_charp chunkdata, png_size_t chunklength, +PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr, + int comp_type, png_size_t chunklength, png_size_t prefix_length, png_size_t *data_length)); #endif @@ -3048,10 +3185,10 @@ PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr, PNG_EXTERN void png_flush PNGARG((png_structp png_ptr)); #endif -/* simple function to write the signature */ +/* Simple function to write the signature */ PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr)); -/* write various chunks */ +/* Write various chunks */ /* Write the IHDR chunk, and update the png_struct with the necessary * information. @@ -3203,12 +3340,12 @@ PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr)); PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr)); #endif -/* combine a row of data, dealing with alpha, etc. if requested */ +/* Combine a row of data, dealing with alpha, etc. if requested */ PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row, int mask)); #if defined(PNG_READ_INTERLACING_SUPPORTED) -/* expand an interlaced row */ +/* Expand an interlaced row */ /* OLD pre-1.0.9 interface: PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info, png_bytep row, int pass, png_uint_32 transformations)); @@ -3219,12 +3356,12 @@ PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr)); /* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */ #if defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* grab pixels out of a row for an interlaced pass */ +/* Grab pixels out of a row for an interlaced pass */ PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info, png_bytep row, int pass)); #endif -/* unfilter a row */ +/* Unfilter a row */ PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr, png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter)); @@ -3235,16 +3372,16 @@ PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr, /* Write out the filtered row. */ PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr, png_bytep filtered_row)); -/* finish a row while reading, dealing with interlacing passes, etc. */ +/* Finish a row while reading, dealing with interlacing passes, etc. */ PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr)); -/* initialize the row buffers, etc. */ +/* Initialize the row buffers, etc. */ PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr)); -/* optional call to update the users info structure */ +/* Optional call to update the users info structure */ PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr, png_infop info_ptr)); -/* these are the functions that do the transformations */ +/* These are the functions that do the transformations */ #if defined(PNG_READ_FILLER_SUPPORTED) PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info, png_bytep row, png_uint_32 filler, png_uint_32 flags)); @@ -3366,7 +3503,7 @@ PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info, * then calls the appropriate callback for the chunk if it is valid. */ -/* decode the IHDR chunk */ +/* Decode the IHDR chunk */ PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr, png_uint_32 length)); PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr, @@ -3465,7 +3602,7 @@ PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr, PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr, png_bytep chunk_name)); -/* handle the transformations for reading and writing */ +/* Handle the transformations for reading and writing */ PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr)); PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr)); @@ -3556,6 +3693,26 @@ png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif /* PNG_pHYs_SUPPORTED */ #endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */ +/* Read the chunk header (length + type name) */ +PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr)); + +/* Added at libpng version 1.2.34 */ +#if defined(PNG_cHRM_SUPPORTED) +PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr, + png_fixed_point int_white_x, png_fixed_point int_white_y, + png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point + int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x, + png_fixed_point int_blue_y)); +#endif + +#if defined(PNG_cHRM_SUPPORTED) +#if !defined(PNG_NO_CHECK_cHRM) +/* Added at libpng version 1.2.34 */ +PNG_EXTERN void png_64bit_product (long v1, long v2, unsigned long *hi_product, + unsigned long *lo_product); +#endif +#endif + /* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */ #endif /* PNG_INTERNAL */ @@ -3565,5 +3722,5 @@ png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); #endif #endif /* PNG_VERSION_INFO_ONLY */ -/* do not put anything past this line */ +/* Do not put anything past this line */ #endif /* PNG_H */ diff --git a/src/3rdparty/libpng/pngconf.h b/src/3rdparty/libpng/pngconf.h index 066be02..5530bde 100644 --- a/src/3rdparty/libpng/pngconf.h +++ b/src/3rdparty/libpng/pngconf.h @@ -1,11 +1,14 @@ /* pngconf.h - machine configurable file for libpng * - * libpng version 1.2.29 - May 8, 2008 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * libpng version 1.2.40 - September 10, 2009 + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ /* Any machine specific code is near the front of this file, so if you @@ -19,7 +22,7 @@ #define PNG_1_2_X -/* +/* * PNG_USER_CONFIG has to be defined on the compiler command line. This * includes the resource compiler for Windows DLL configurations. */ @@ -39,7 +42,7 @@ /* * Added at libpng-1.2.8 - * + * * If you create a private DLL you need to define in "pngusr.h" the followings: * #define PNG_USER_PRIVATEBUILD @@ -50,8 +53,8 @@ * number and must match your private DLL name> * e.g. // private DLL "libpng13gx.dll" * #define PNG_USER_DLLFNAME_POSTFIX "gx" - * - * The following macros are also at your disposal if you want to complete the + * + * The following macros are also at your disposal if you want to complete the * DLL VERSIONINFO structure. * - PNG_USER_VERSIONINFO_COMMENTS * - PNG_USER_VERSIONINFO_COMPANYNAME @@ -147,9 +150,9 @@ * 'Cygwin' defines/defaults: * PNG_BUILD_DLL -- (ignored) building the dll * (no define) -- (ignored) building an application, linking to the dll - * PNG_STATIC -- (ignored) building the static lib, or building an + * PNG_STATIC -- (ignored) building the static lib, or building an * application that links to the static lib. - * ALL_STATIC -- (ignored) building various static libs, or building an + * ALL_STATIC -- (ignored) building various static libs, or building an * application that links to the static libs. * Thus, * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and @@ -162,12 +165,12 @@ * PNG_BUILD_DLL * PNG_STATIC * (nothing) == PNG_USE_DLL - * + * * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent - * of auto-import in binutils, we no longer need to worry about + * of auto-import in binutils, we no longer need to worry about * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore, * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes - * to __declspec() stuff. However, we DO need to worry about + * to __declspec() stuff. However, we DO need to worry about * PNG_BUILD_DLL and PNG_STATIC because those change some defaults * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed. */ @@ -211,8 +214,8 @@ # if !defined(PNG_DLL) # define PNG_DLL # endif -# endif -# endif +# endif +# endif # endif #endif @@ -233,12 +236,11 @@ # include /* Console I/O functions are not supported on WindowsCE */ # define PNG_NO_CONSOLE_IO + /* abort() may not be supported on some/all Windows CE platforms */ +# define PNG_ABORT() exit(-1) # ifdef PNG_DEBUG # undef PNG_DEBUG # endif -# ifndef PNG_ABORT -# define PNG_ABORT() exit(3) -# endif #endif #ifdef PNG_BUILD_DLL @@ -315,21 +317,29 @@ #ifdef PNG_SETJMP_SUPPORTED /* This is an attempt to force a single setjmp behaviour on Linux. If * the X config stuff didn't define _BSD_SOURCE we wouldn't need this. + * + * You can bypass this test if you know that your application uses exactly + * the same setjmp.h that was included when libpng was built. Only define + * PNG_SKIP_SETJMP_CHECK while building your application, prior to the + * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK + * while building a separate libpng library for general use. */ -# ifdef __linux__ -# ifdef _BSD_SOURCE -# define PNG_SAVE_BSD_SOURCE -# undef _BSD_SOURCE -# endif -# ifdef _SETJMP_H - /* If you encounter a compiler error here, see the explanation - * near the end of INSTALL. - */ - __pngconf.h__ already includes setjmp.h; - __dont__ include it again.; -# endif -# endif /* __linux__ */ +# ifndef PNG_SKIP_SETJMP_CHECK +# ifdef __linux__ +# ifdef _BSD_SOURCE +# define PNG_SAVE_BSD_SOURCE +# undef _BSD_SOURCE +# endif +# ifdef _SETJMP_H + /* If you encounter a compiler error here, see the explanation + * near the end of INSTALL. + */ + __pngconf.h__ in libpng already includes setjmp.h; + __dont__ include it again.; +# endif +# endif /* __linux__ */ +# endif /* PNG_SKIP_SETJMP_CHECK */ /* include setjmp.h for error handling */ # include @@ -344,7 +354,7 @@ # endif /* __linux__ */ #endif /* PNG_SETJMP_SUPPORTED */ -#if defined(BSD) && !defined(VXWORKS) +#ifdef BSD # include #else # include @@ -480,7 +490,7 @@ * iTXt support was added. iTXt support was turned off by default through * libpng-1.2.x, to support old apps that malloc the png_text structure * instead of calling png_set_text() and letting libpng malloc it. It - * was turned on by default in libpng-1.3.0. + * will be turned on by default in libpng-1.4.0. */ #if defined(PNG_1_0_X) || defined (PNG_1_2_X) @@ -514,6 +524,7 @@ # define PNG_NO_FREE_ME # define PNG_NO_READ_UNKNOWN_CHUNKS # define PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_NO_HANDLE_AS_UNKNOWN # define PNG_NO_READ_USER_CHUNKS # define PNG_NO_READ_iCCP # define PNG_NO_WRITE_iCCP @@ -543,7 +554,7 @@ # define PNG_FREE_ME_SUPPORTED #endif -#if defined(PNG_READ_SUPPORTED) +#ifdef PNG_READ_SUPPORTED #if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \ !defined(PNG_NO_READ_TRANSFORMS) @@ -631,7 +642,7 @@ #endif /* PNG_READ_SUPPORTED */ -#if defined(PNG_WRITE_SUPPORTED) +#ifdef PNG_WRITE_SUPPORTED # if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \ !defined(PNG_NO_WRITE_TRANSFORMS) @@ -734,7 +745,7 @@ # define PNG_EASY_ACCESS_SUPPORTED #endif -/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 +/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0 * and removed from version 1.2.20. The following will be removed * from libpng-1.4.0 */ @@ -801,6 +812,11 @@ # define PNG_USER_HEIGHT_MAX 1000000L #endif +/* Added at libpng-1.2.34 and 1.4.0 */ +#ifndef PNG_STRING_NEWLINE +#define PNG_STRING_NEWLINE "\n" +#endif + /* These are currently experimental features, define them if you want */ /* very little testing */ @@ -928,14 +944,22 @@ # define PNG_READ_zTXt_SUPPORTED # define PNG_zTXt_SUPPORTED #endif +#ifndef PNG_NO_READ_OPT_PLTE +# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ +#endif /* optional PLTE chunk in RGB and RGBA images */ +#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ + defined(PNG_READ_zTXt_SUPPORTED) +# define PNG_READ_TEXT_SUPPORTED +# define PNG_TEXT_SUPPORTED +#endif + +#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ + #ifndef PNG_NO_READ_UNKNOWN_CHUNKS # define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED # ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED # define PNG_UNKNOWN_CHUNKS_SUPPORTED # endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif #endif #if !defined(PNG_NO_READ_USER_CHUNKS) && \ defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) @@ -948,17 +972,14 @@ # undef PNG_NO_HANDLE_AS_UNKNOWN # endif #endif -#ifndef PNG_NO_READ_OPT_PLTE -# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */ -#endif /* optional PLTE chunk in RGB and RGBA images */ -#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \ - defined(PNG_READ_zTXt_SUPPORTED) -# define PNG_READ_TEXT_SUPPORTED -# define PNG_TEXT_SUPPORTED -#endif -#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */ +#ifndef PNG_NO_HANDLE_AS_UNKNOWN +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +#endif +#ifdef PNG_WRITE_SUPPORTED #ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED #ifdef PNG_NO_WRITE_TEXT @@ -1070,17 +1091,6 @@ # define PNG_zTXt_SUPPORTED # endif #endif -#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS -# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_UNKNOWN_CHUNKS_SUPPORTED -# endif -# ifndef PNG_NO_HANDLE_AS_UNKNOWN -# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -# endif -# endif -#endif #if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \ defined(PNG_WRITE_zTXt_SUPPORTED) # define PNG_WRITE_TEXT_SUPPORTED @@ -1091,6 +1101,20 @@ #endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */ +#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS +# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED +# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED +# define PNG_UNKNOWN_CHUNKS_SUPPORTED +# endif +#endif + +#ifndef PNG_NO_HANDLE_AS_UNKNOWN +# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED +# endif +#endif +#endif /* PNG_WRITE_SUPPORTED */ + /* Turn this off to disable png_read_png() and * png_write_png() and leave the row_pointers member * out of the info structure. @@ -1126,10 +1150,10 @@ typedef unsigned char png_byte; change (I'm not sure if you will or not, so I thought I'd be safe) */ #ifdef PNG_SIZE_T typedef PNG_SIZE_T png_size_t; -# define png_sizeof(x) png_convert_size(sizeof (x)) +# define png_sizeof(x) png_convert_size(sizeof(x)) #else typedef size_t png_size_t; -# define png_sizeof(x) sizeof (x) +# define png_sizeof(x) sizeof(x) #endif /* The following is needed for medium model support. It cannot be in the @@ -1236,7 +1260,7 @@ typedef char FAR * FAR * FAR * png_charppp; #if defined(PNG_1_0_X) || defined(PNG_1_2_X) /* SPC - Is this stuff deprecated? */ -/* It'll be removed as of libpng-1.3.0 - GR-P */ +/* It'll be removed as of libpng-1.4.0 - GR-P */ /* libpng typedefs for types in zlib. If zlib changes * or another compression library is used, then change these. * Eliminates need to change all the source files. @@ -1309,7 +1333,7 @@ typedef z_stream FAR * png_zstreamp; # define PNGAPI __cdecl # undef PNG_IMPEXP # define PNG_IMPEXP -#endif +#endif /* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall", * you may get warnings regarding the linkage of png_zalloc and png_zfree. @@ -1333,9 +1357,7 @@ typedef z_stream FAR * png_zstreamp; defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) # ifndef PNGAPI -# if (defined(__GNUC__) && defined(__arm__)) || defined (__ARMCC__) -# define PNGAPI -# elif defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) || defined(__WINSCW__) +# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) # define PNGAPI __cdecl # else # define PNGAPI _cdecl @@ -1385,14 +1407,6 @@ typedef z_stream FAR * png_zstreamp; # if 0 /* ... other platforms, with other meanings */ # endif # endif - -# if !defined(PNG_IMPEXP) -# include -# if defined(QT_VISIBILITY_AVAILABLE) -# define PNG_IMPEXP __attribute__((visibility("default"))) -# endif -# endif - #endif #ifndef PNGAPI diff --git a/src/3rdparty/libpng/pngerror.c b/src/3rdparty/libpng/pngerror.c index b364fc0..d68416b 100644 --- a/src/3rdparty/libpng/pngerror.c +++ b/src/3rdparty/libpng/pngerror.c @@ -1,12 +1,15 @@ /* pngerror.c - stub functions for i/o and memory allocation * - * Last changed in libpng 1.2.22 [October 13, 2007] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.2.37 [June 4, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file provides a location for all error handling. Users who * need special error handling are expected to write replacement functions * and use png_set_error_fn() to use those functions. See the instructions @@ -15,8 +18,8 @@ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + static void /* PRIVATE */ png_default_error PNGARG((png_structp png_ptr, png_const_charp error_message)); @@ -44,28 +47,29 @@ png_error(png_structp png_ptr, png_const_charp error_message) { if (*error_message == '#') { + /* Strip "#nnnn " from beginning of error message. */ int offset; - for (offset=1; offset<15; offset++) - if (*(error_message+offset) == ' ') + for (offset = 1; offset<15; offset++) + if (error_message[offset] == ' ') break; if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT) { int i; - for (i=0; iflags&PNG_FLAG_STRIP_ERROR_TEXT) { - msg[0]='0'; - msg[1]='\0'; - error_message=msg; + msg[0] = '0'; + msg[1] = '\0'; + error_message = msg; } } } @@ -110,16 +114,16 @@ png_warning(png_structp png_ptr, png_const_charp warning_message) { if (*warning_message == '#') { - for (offset=1; offset<15; offset++) - if (*(warning_message+offset) == ' ') + for (offset = 1; offset < 15; offset++) + if (warning_message[offset] == ' ') break; } } - if (png_ptr != NULL && png_ptr->warning_fn != NULL) - (*(png_ptr->warning_fn))(png_ptr, warning_message+offset); } + if (png_ptr != NULL && png_ptr->warning_fn != NULL) + (*(png_ptr->warning_fn))(png_ptr, warning_message + offset); else - png_default_warning(png_ptr, warning_message+offset); + png_default_warning(png_ptr, warning_message + offset); } #endif /* PNG_NO_WARNINGS */ @@ -167,8 +171,8 @@ png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp { buffer[iout++] = ':'; buffer[iout++] = ' '; - png_memcpy(buffer+iout, error_message, PNG_MAX_ERROR_TEXT); - buffer[iout+PNG_MAX_ERROR_TEXT-1] = '\0'; + png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT); + buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0'; } } @@ -216,26 +220,35 @@ png_default_error(png_structp png_ptr, png_const_charp error_message) #ifdef PNG_ERROR_NUMBERS_SUPPORTED if (*error_message == '#') { + /* Strip "#nnnn " from beginning of error message. */ int offset; char error_number[16]; - for (offset=0; offset<15; offset++) + for (offset = 0; offset<15; offset++) { - error_number[offset] = *(error_message+offset+1); - if (*(error_message+offset) == ' ') + error_number[offset] = error_message[offset + 1]; + if (error_message[offset] == ' ') break; } - if((offset > 1) && (offset < 15)) + if ((offset > 1) && (offset < 15)) { - error_number[offset-1]='\0'; - fprintf(stderr, "libpng error no. %s: %s\n", error_number, - error_message+offset); + error_number[offset - 1] = '\0'; + fprintf(stderr, "libpng error no. %s: %s", + error_number, error_message + offset + 1); + fprintf(stderr, PNG_STRING_NEWLINE); } else - fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset); + { + fprintf(stderr, "libpng error: %s, offset=%d", + error_message, offset); + fprintf(stderr, PNG_STRING_NEWLINE); + } } else #endif - fprintf(stderr, "libpng error: %s\n", error_message); + { + fprintf(stderr, "libpng error: %s", error_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } #endif #ifdef PNG_SETJMP_SUPPORTED @@ -255,7 +268,7 @@ png_default_error(png_structp png_ptr, png_const_charp error_message) PNG_ABORT(); #endif #ifdef PNG_NO_CONSOLE_IO - error_message = error_message; /* make compiler happy */ + error_message = error_message; /* Make compiler happy */ #endif } @@ -274,28 +287,36 @@ png_default_warning(png_structp png_ptr, png_const_charp warning_message) { int offset; char warning_number[16]; - for (offset=0; offset<15; offset++) + for (offset = 0; offset < 15; offset++) { - warning_number[offset]=*(warning_message+offset+1); - if (*(warning_message+offset) == ' ') + warning_number[offset] = warning_message[offset + 1]; + if (warning_message[offset] == ' ') break; } - if((offset > 1) && (offset < 15)) + if ((offset > 1) && (offset < 15)) { - warning_number[offset-1]='\0'; - fprintf(stderr, "libpng warning no. %s: %s\n", warning_number, - warning_message+offset); + warning_number[offset + 1] = '\0'; + fprintf(stderr, "libpng warning no. %s: %s", + warning_number, warning_message + offset); + fprintf(stderr, PNG_STRING_NEWLINE); } else - fprintf(stderr, "libpng warning: %s\n", warning_message); + { + fprintf(stderr, "libpng warning: %s", + warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } } else # endif - fprintf(stderr, "libpng warning: %s\n", warning_message); + { + fprintf(stderr, "libpng warning: %s", warning_message); + fprintf(stderr, PNG_STRING_NEWLINE); + } #else - warning_message = warning_message; /* make compiler happy */ + warning_message = warning_message; /* Make compiler happy */ #endif - png_ptr = png_ptr; /* make compiler happy */ + png_ptr = png_ptr; /* Make compiler happy */ } #endif /* PNG_NO_WARNINGS */ @@ -333,7 +354,7 @@ png_get_error_ptr(png_structp png_ptr) void PNGAPI png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode) { - if(png_ptr != NULL) + if (png_ptr != NULL) { png_ptr->flags &= ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode); diff --git a/src/3rdparty/libpng/pngget.c b/src/3rdparty/libpng/pngget.c index a0e90bb..38e4f9e 100644 --- a/src/3rdparty/libpng/pngget.c +++ b/src/3rdparty/libpng/pngget.c @@ -1,16 +1,19 @@ /* pngget.c - retrieval of values from info struct * - * Last changed in libpng 1.2.15 January 5, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.2.37 [June 4, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * */ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) png_uint_32 PNGAPI @@ -18,6 +21,7 @@ png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->valid & flag); + else return(0); } @@ -27,6 +31,7 @@ png_get_rowbytes(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->rowbytes); + else return(0); } @@ -37,20 +42,20 @@ png_get_rows(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) return(info_ptr->row_pointers); + else return(0); } #endif #ifdef PNG_EASY_ACCESS_SUPPORTED -/* easy access to info, added in libpng-0.99 */ +/* Easy access to info, added in libpng-0.99 */ png_uint_32 PNGAPI png_get_image_width(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->width; - } + return (0); } @@ -58,9 +63,8 @@ png_uint_32 PNGAPI png_get_image_height(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->height; - } + return (0); } @@ -68,9 +72,8 @@ png_byte PNGAPI png_get_bit_depth(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->bit_depth; - } + return (0); } @@ -78,9 +81,8 @@ png_byte PNGAPI png_get_color_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->color_type; - } + return (0); } @@ -88,9 +90,8 @@ png_byte PNGAPI png_get_filter_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->filter_type; - } + return (0); } @@ -98,9 +99,8 @@ png_byte PNGAPI png_get_interlace_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->interlace_type; - } + return (0); } @@ -108,9 +108,8 @@ png_byte PNGAPI png_get_compression_type(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) - { return info_ptr->compression_type; - } + return (0); } @@ -121,10 +120,13 @@ png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function\n", "png_get_x_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter"); + + if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) return (0); - else return (info_ptr->x_pixels_per_unit); + + else + return (info_ptr->x_pixels_per_unit); } #else return (0); @@ -139,10 +141,13 @@ png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER) + png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter"); + + if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER) return (0); - else return (info_ptr->y_pixels_per_unit); + + else + return (info_ptr->y_pixels_per_unit); } #else return (0); @@ -157,11 +162,14 @@ png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr) #if defined(PNG_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function\n", "png_get_pixels_per_meter"); - if(info_ptr->phys_unit_type != PNG_RESOLUTION_METER || + png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter"); + + if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER || info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit) return (0); - else return (info_ptr->x_pixels_per_unit); + + else + return (info_ptr->x_pixels_per_unit); } #else return (0); @@ -175,9 +183,10 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_pHYs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_pHYs) { - png_debug1(1, "in %s retrieval function\n", "png_get_aspect_ratio"); + png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); if (info_ptr->x_pixels_per_unit == 0) return ((float)0.0); else @@ -185,7 +194,7 @@ png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr) /(float)info_ptr->x_pixels_per_unit)); } #else - return (0.0); + return (0.0); #endif return ((float)0.0); } @@ -196,15 +205,19 @@ png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) #if defined(PNG_oFFs_SUPPORTED) + if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); + + if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) return (0); - else return (info_ptr->x_offset); + + else + return (info_ptr->x_offset); } #else - return (0); + return (0); #endif return (0); } @@ -213,13 +226,17 @@ png_int_32 PNGAPI png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) + png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); + + if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER) return (0); - else return (info_ptr->y_offset); + + else + return (info_ptr->y_offset); } #else return (0); @@ -231,13 +248,17 @@ png_int_32 PNGAPI png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function\n", "png_get_x_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns"); + + if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); - else return (info_ptr->x_offset); + + else + return (info_ptr->x_offset); } #else return (0); @@ -249,13 +270,17 @@ png_int_32 PNGAPI png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr) { if (png_ptr != NULL && info_ptr != NULL) + #if defined(PNG_oFFs_SUPPORTED) if (info_ptr->valid & PNG_INFO_oFFs) { - png_debug1(1, "in %s retrieval function\n", "png_get_y_offset_microns"); - if(info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) + png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns"); + + if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL) return (0); - else return (info_ptr->y_offset); + + else + return (info_ptr->y_offset); } #else return (0); @@ -308,7 +333,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function\n", "pHYs"); + png_debug1(1, "in %s retrieval function", "pHYs"); if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; @@ -323,7 +348,7 @@ png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr, { *unit_type = (int)info_ptr->phys_unit_type; retval |= PNG_INFO_pHYs; - if(*unit_type == 1) + if (*unit_type == 1) { if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50); if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50); @@ -365,7 +390,7 @@ png_get_bKGD(png_structp png_ptr, png_infop info_ptr, if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) && background != NULL) { - png_debug1(1, "in %s retrieval function\n", "bKGD"); + png_debug1(1, "in %s retrieval function", "bKGD"); *background = &(info_ptr->background); return (PNG_INFO_bKGD); } @@ -382,7 +407,7 @@ png_get_cHRM(png_structp png_ptr, png_infop info_ptr, { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { - png_debug1(1, "in %s retrieval function\n", "cHRM"); + png_debug1(1, "in %s retrieval function", "cHRM"); if (white_x != NULL) *white_x = (double)info_ptr->x_white; if (white_y != NULL) @@ -413,7 +438,7 @@ png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)) { - png_debug1(1, "in %s retrieval function\n", "cHRM"); + png_debug1(1, "in %s retrieval function", "cHRM"); if (white_x != NULL) *white_x = info_ptr->int_x_white; if (white_y != NULL) @@ -445,7 +470,7 @@ png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) && file_gamma != NULL) { - png_debug1(1, "in %s retrieval function\n", "gAMA"); + png_debug1(1, "in %s retrieval function", "gAMA"); *file_gamma = (double)info_ptr->gamma; return (PNG_INFO_gAMA); } @@ -460,7 +485,7 @@ png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA) && int_file_gamma != NULL) { - png_debug1(1, "in %s retrieval function\n", "gAMA"); + png_debug1(1, "in %s retrieval function", "gAMA"); *int_file_gamma = info_ptr->int_gamma; return (PNG_INFO_gAMA); } @@ -476,7 +501,7 @@ png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB) && file_srgb_intent != NULL) { - png_debug1(1, "in %s retrieval function\n", "sRGB"); + png_debug1(1, "in %s retrieval function", "sRGB"); *file_srgb_intent = (int)info_ptr->srgb_intent; return (PNG_INFO_sRGB); } @@ -493,11 +518,12 @@ png_get_iCCP(png_structp png_ptr, png_infop info_ptr, if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP) && name != NULL && profile != NULL && proflen != NULL) { - png_debug1(1, "in %s retrieval function\n", "iCCP"); + png_debug1(1, "in %s retrieval function", "iCCP"); *name = info_ptr->iccp_name; *profile = info_ptr->iccp_profile; - /* compression_type is a dummy so the API won't have to change - if we introduce multiple compression types later. */ + /* Compression_type is a dummy so the API won't have to change + * if we introduce multiple compression types later. + */ *proflen = (int)info_ptr->iccp_proflen; *compression_type = (int)info_ptr->iccp_compression; return (PNG_INFO_iCCP); @@ -527,7 +553,7 @@ png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) && hist != NULL) { - png_debug1(1, "in %s retrieval function\n", "hIST"); + png_debug1(1, "in %s retrieval function", "hIST"); *hist = info_ptr->hist; return (PNG_INFO_hIST); } @@ -545,27 +571,34 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr, if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL && bit_depth != NULL && color_type != NULL) { - png_debug1(1, "in %s retrieval function\n", "IHDR"); + png_debug1(1, "in %s retrieval function", "IHDR"); *width = info_ptr->width; *height = info_ptr->height; *bit_depth = info_ptr->bit_depth; if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16) - png_error(png_ptr, "Invalid bit depth"); + png_error(png_ptr, "Invalid bit depth"); + *color_type = info_ptr->color_type; + if (info_ptr->color_type > 6) - png_error(png_ptr, "Invalid color type"); + png_error(png_ptr, "Invalid color type"); + if (compression_type != NULL) *compression_type = info_ptr->compression_type; + if (filter_type != NULL) *filter_type = info_ptr->filter_type; + if (interlace_type != NULL) *interlace_type = info_ptr->interlace_type; - /* check for potential overflow of rowbytes */ + /* Check for potential overflow of rowbytes */ if (*width == 0 || *width > PNG_UINT_31_MAX) png_error(png_ptr, "Invalid image width"); + if (*height == 0 || *height > PNG_UINT_31_MAX) png_error(png_ptr, "Invalid image height"); + if (info_ptr->width > (PNG_UINT_32_MAX >> 3) /* 8-byte RGBA pixels */ - 64 /* bigrowbuf hack */ @@ -576,6 +609,7 @@ png_get_IHDR(png_structp png_ptr, png_infop info_ptr, png_warning(png_ptr, "Width too large for libpng to process image data."); } + return (1); } return (0); @@ -589,7 +623,7 @@ png_get_oFFs(png_structp png_ptr, png_infop info_ptr, if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) && offset_x != NULL && offset_y != NULL && unit_type != NULL) { - png_debug1(1, "in %s retrieval function\n", "oFFs"); + png_debug1(1, "in %s retrieval function", "oFFs"); *offset_x = info_ptr->x_offset; *offset_y = info_ptr->y_offset; *unit_type = (int)info_ptr->offset_unit_type; @@ -606,10 +640,10 @@ png_get_pCAL(png_structp png_ptr, png_infop info_ptr, png_charp *units, png_charpp *params) { if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) - && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && - nparams != NULL && units != NULL && params != NULL) + && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL && + nparams != NULL && units != NULL && params != NULL) { - png_debug1(1, "in %s retrieval function\n", "pCAL"); + png_debug1(1, "in %s retrieval function", "pCAL"); *purpose = info_ptr->pcal_purpose; *X0 = info_ptr->pcal_X0; *X1 = info_ptr->pcal_X1; @@ -630,7 +664,7 @@ png_get_sCAL(png_structp png_ptr, png_infop info_ptr, int *unit, double *width, double *height) { if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) + (info_ptr->valid & PNG_INFO_sCAL)) { *unit = info_ptr->scal_unit; *width = info_ptr->scal_pixel_width; @@ -646,7 +680,7 @@ png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr, int *unit, png_charpp width, png_charpp height) { if (png_ptr != NULL && info_ptr != NULL && - (info_ptr->valid & PNG_INFO_sCAL)) + (info_ptr->valid & PNG_INFO_sCAL)) { *unit = info_ptr->scal_unit; *width = info_ptr->scal_s_width; @@ -669,17 +703,20 @@ png_get_pHYs(png_structp png_ptr, png_infop info_ptr, if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) { - png_debug1(1, "in %s retrieval function\n", "pHYs"); + png_debug1(1, "in %s retrieval function", "pHYs"); + if (res_x != NULL) { *res_x = info_ptr->x_pixels_per_unit; retval |= PNG_INFO_pHYs; } + if (res_y != NULL) { *res_y = info_ptr->y_pixels_per_unit; retval |= PNG_INFO_pHYs; } + if (unit_type != NULL) { *unit_type = (int)info_ptr->phys_unit_type; @@ -697,10 +734,10 @@ png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette, if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE) && palette != NULL) { - png_debug1(1, "in %s retrieval function\n", "PLTE"); + png_debug1(1, "in %s retrieval function", "PLTE"); *palette = info_ptr->palette; *num_palette = info_ptr->num_palette; - png_debug1(3, "num_palette = %d\n", *num_palette); + png_debug1(3, "num_palette = %d", *num_palette); return (PNG_INFO_PLTE); } return (0); @@ -713,7 +750,7 @@ png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) && sig_bit != NULL) { - png_debug1(1, "in %s retrieval function\n", "sBIT"); + png_debug1(1, "in %s retrieval function", "sBIT"); *sig_bit = &(info_ptr->sig_bit); return (PNG_INFO_sBIT); } @@ -728,13 +765,16 @@ png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr, { if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0) { - png_debug1(1, "in %s retrieval function\n", + png_debug1(1, "in %s retrieval function", (png_ptr->chunk_name[0] == '\0' ? "text" : (png_const_charp)png_ptr->chunk_name)); + if (text_ptr != NULL) *text_ptr = info_ptr->text; + if (num_text != NULL) *num_text = info_ptr->num_text; + return ((png_uint_32)info_ptr->num_text); } if (num_text != NULL) @@ -750,7 +790,7 @@ png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time) if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) && mod_time != NULL) { - png_debug1(1, "in %s retrieval function\n", "tIME"); + png_debug1(1, "in %s retrieval function", "tIME"); *mod_time = &(info_ptr->mod_time); return (PNG_INFO_tIME); } @@ -766,7 +806,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 retval = 0; if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS)) { - png_debug1(1, "in %s retrieval function\n", "tRNS"); + png_debug1(1, "in %s retrieval function", "tRNS"); if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) { if (trans != NULL) @@ -774,6 +814,7 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr, *trans = info_ptr->trans; retval |= PNG_INFO_tRNS; } + if (trans_values != NULL) *trans_values = &(info_ptr->trans_values); } @@ -784,10 +825,11 @@ png_get_tRNS(png_structp png_ptr, png_infop info_ptr, *trans_values = &(info_ptr->trans_values); retval |= PNG_INFO_tRNS; } - if(trans != NULL) + + if (trans != NULL) *trans = NULL; } - if(num_trans != NULL) + if (num_trans != NULL) { *num_trans = info_ptr->num_trans; retval |= PNG_INFO_tRNS; @@ -837,54 +879,54 @@ png_get_compression_buffer_size(png_structp png_ptr) #ifdef PNG_ASSEMBLER_CODE_SUPPORTED #ifndef PNG_1_0_X -/* this function was added to libpng 1.2.0 and should exist by default */ +/* This function was added to libpng 1.2.0 and should exist by default */ png_uint_32 PNGAPI png_get_asm_flags (png_structp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ + /* Obsolete, to be removed from libpng-1.4.0 */ return (png_ptr? 0L: 0L); } -/* this function was added to libpng 1.2.0 and should exist by default */ +/* This function was added to libpng 1.2.0 and should exist by default */ png_uint_32 PNGAPI png_get_asm_flagmask (int flag_select) { - /* obsolete, to be removed from libpng-1.4.0 */ + /* Obsolete, to be removed from libpng-1.4.0 */ flag_select=flag_select; return 0L; } /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */ -/* this function was added to libpng 1.2.0 */ +/* This function was added to libpng 1.2.0 */ png_uint_32 PNGAPI png_get_mmx_flagmask (int flag_select, int *compilerID) { - /* obsolete, to be removed from libpng-1.4.0 */ + /* Obsolete, to be removed from libpng-1.4.0 */ flag_select=flag_select; *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */ return 0L; } -/* this function was added to libpng 1.2.0 */ +/* This function was added to libpng 1.2.0 */ png_byte PNGAPI png_get_mmx_bitdepth_threshold (png_structp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ + /* Obsolete, to be removed from libpng-1.4.0 */ return (png_ptr? 0: 0); } -/* this function was added to libpng 1.2.0 */ +/* This function was added to libpng 1.2.0 */ png_uint_32 PNGAPI png_get_mmx_rowbytes_threshold (png_structp png_ptr) { - /* obsolete, to be removed from libpng-1.4.0 */ + /* Obsolete, to be removed from libpng-1.4.0 */ return (png_ptr? 0L: 0L); } #endif /* ?PNG_1_0_X */ #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* these functions were added to libpng 1.2.6 */ +/* These functions were added to libpng 1.2.6 */ png_uint_32 PNGAPI png_get_user_width_max (png_structp png_ptr) { @@ -896,6 +938,6 @@ png_get_user_height_max (png_structp png_ptr) return (png_ptr? png_ptr->user_height_max : 0); } #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ - + #endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */ diff --git a/src/3rdparty/libpng/pngmem.c b/src/3rdparty/libpng/pngmem.c index 13cc60c..e190cc3 100644 --- a/src/3rdparty/libpng/pngmem.c +++ b/src/3rdparty/libpng/pngmem.c @@ -1,12 +1,15 @@ /* pngmem.c - stub functions for memory allocation * - * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Last changed in libpng 1.2.37 [June 4, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file provides a location for all memory allocation. Users who * need special memory handling are expected to supply replacement * functions for png_malloc() and png_free(), and to use @@ -16,12 +19,11 @@ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) /* Borland DOS special memory handler */ #if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__) -/* if you change this, be sure to change the one in png.h also */ +/* If you change this, be sure to change the one in png.h also */ /* Allocate memory for a png_struct. The malloc and memset can be replaced by a single call to calloc() if this is thought to improve performance. */ @@ -41,14 +43,14 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) png_voidp struct_ptr; if (type == PNG_STRUCT_INFO) - size = png_sizeof(png_info); + size = png_sizeof(png_info); else if (type == PNG_STRUCT_PNG) - size = png_sizeof(png_struct); + size = png_sizeof(png_struct); else - return (png_get_copyright(NULL)); + return (png_get_copyright(NULL)); #ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) + if (malloc_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; @@ -57,7 +59,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) } else #endif /* PNG_USER_MEM_SUPPORTED */ - struct_ptr = (png_voidp)farmalloc(size); + struct_ptr = (png_voidp)farmalloc(size); if (struct_ptr != NULL) png_memset(struct_ptr, 0, size); return (struct_ptr); @@ -80,7 +82,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, if (struct_ptr != NULL) { #ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) + if (free_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; @@ -122,10 +124,10 @@ png_malloc(png_structp png_ptr, png_uint_32 size) return (NULL); #ifdef PNG_USER_MEM_SUPPORTED - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); + if (png_ptr->malloc_fn != NULL) + ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); else - ret = (png_malloc_default(png_ptr, size)); + ret = (png_malloc_default(png_ptr, size)); if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Out of memory!"); return (ret); @@ -150,12 +152,12 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) #endif if (size != (size_t)size) - ret = NULL; + ret = NULL; else if (size == (png_uint_32)65536L) { if (png_ptr->offset_table == NULL) { - /* try to see if we need to do any of this fancy stuff */ + /* Try to see if we need to do any of this fancy stuff */ ret = farmalloc(size); if (ret == NULL || ((png_size_t)ret & 0xffff)) { @@ -171,7 +173,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) ret = NULL; } - if(png_ptr->zlib_window_bits > 14) + if (png_ptr->zlib_window_bits > 14) num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14)); else num_blocks = 1; @@ -210,7 +212,7 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) png_ptr->offset_table = table; png_ptr->offset_table_ptr = farmalloc(num_blocks * - png_sizeof (png_bytep)); + png_sizeof(png_bytep)); if (png_ptr->offset_table_ptr == NULL) { @@ -270,9 +272,10 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) return (ret); } -/* free a pointer allocated by png_malloc(). In the default - configuration, png_ptr is not used, but is passed in case it - is needed. If ptr is NULL, return without taking any action. */ +/* Free a pointer allocated by png_malloc(). In the default + * configuration, png_ptr is not used, but is passed in case it + * is needed. If ptr is NULL, return without taking any action. + */ void PNGAPI png_free(png_structp png_ptr, png_voidp ptr) { @@ -285,7 +288,8 @@ png_free(png_structp png_ptr, png_voidp ptr) (*(png_ptr->free_fn))(png_ptr, ptr); return; } - else png_free_default(png_ptr, ptr); + else + png_free_default(png_ptr, ptr); } void PNGAPI @@ -293,7 +297,8 @@ png_free_default(png_structp png_ptr, png_voidp ptr) { #endif /* PNG_USER_MEM_SUPPORTED */ - if(png_ptr == NULL || ptr == NULL) return; + if (png_ptr == NULL || ptr == NULL) + return; if (png_ptr->offset_table != NULL) { @@ -353,7 +358,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) return (NULL); #ifdef PNG_USER_MEM_SUPPORTED - if(malloc_fn != NULL) + if (malloc_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; @@ -369,7 +374,7 @@ png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr) struct_ptr = (png_voidp)farmalloc(size); #else # if defined(_MSC_VER) && defined(MAXSEG_64K) - struct_ptr = (png_voidp)halloc(size,1); + struct_ptr = (png_voidp)halloc(size, 1); # else struct_ptr = (png_voidp)malloc(size); # endif @@ -398,7 +403,7 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, if (struct_ptr != NULL) { #ifdef PNG_USER_MEM_SUPPORTED - if(free_fn != NULL) + if (free_fn != NULL) { png_struct dummy_struct; png_structp png_ptr = &dummy_struct; @@ -420,10 +425,12 @@ png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn, } /* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. */ + * 64K. However, zlib may allocate more then 64K if you don't tell + * it not to. See zconf.h and png.h for more information. zlib does + * need to allocate exactly 64K, so whatever you call here must + * have the ability to do that. + */ + png_voidp PNGAPI png_malloc(png_structp png_ptr, png_uint_32 size) @@ -434,10 +441,10 @@ png_malloc(png_structp png_ptr, png_uint_32 size) if (png_ptr == NULL || size == 0) return (NULL); - if(png_ptr->malloc_fn != NULL) - ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); + if (png_ptr->malloc_fn != NULL) + ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size)); else - ret = (png_malloc_default(png_ptr, size)); + ret = (png_malloc_default(png_ptr, size)); if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0) png_error(png_ptr, "Out of Memory!"); return (ret); @@ -464,23 +471,23 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) } #endif - /* Check for overflow */ + /* Check for overflow */ #if defined(__TURBOC__) && !defined(__FLAT__) - if (size != (unsigned long)size) - ret = NULL; - else - ret = farmalloc(size); + if (size != (unsigned long)size) + ret = NULL; + else + ret = farmalloc(size); #else # if defined(_MSC_VER) && defined(MAXSEG_64K) - if (size != (unsigned long)size) - ret = NULL; - else - ret = halloc(size, 1); + if (size != (unsigned long)size) + ret = NULL; + else + ret = halloc(size, 1); # else - if (size != (size_t)size) - ret = NULL; - else - ret = malloc((size_t)size); + if (size != (size_t)size) + ret = NULL; + else + ret = malloc((size_t)size); # endif #endif @@ -493,7 +500,8 @@ png_malloc_default(png_structp png_ptr, png_uint_32 size) } /* Free a pointer allocated by png_malloc(). If ptr is NULL, return - without taking any action. */ + * without taking any action. + */ void PNGAPI png_free(png_structp png_ptr, png_voidp ptr) { @@ -506,7 +514,8 @@ png_free(png_structp png_ptr, png_voidp ptr) (*(png_ptr->free_fn))(png_ptr, ptr); return; } - else png_free_default(png_ptr, ptr); + else + png_free_default(png_ptr, ptr); } void PNGAPI png_free_default(png_structp png_ptr, png_voidp ptr) @@ -542,9 +551,10 @@ png_malloc_warn(png_structp png_ptr, png_uint_32 size) { png_voidp ptr; png_uint_32 save_flags; - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); - save_flags=png_ptr->flags; + save_flags = png_ptr->flags; png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK; ptr = (png_voidp)png_malloc((png_structp)png_ptr, size); png_ptr->flags=save_flags; @@ -560,7 +570,7 @@ png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2, size = (png_size_t)length; if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memcpy_check."); + png_error(png_ptr, "Overflow in png_memcpy_check."); return(png_memcpy (s1, s2, size)); } @@ -573,7 +583,7 @@ png_memset_check (png_structp png_ptr, png_voidp s1, int value, size = (png_size_t)length; if ((png_uint_32)size != length) - png_error(png_ptr,"Overflow in png_memset_check."); + png_error(png_ptr, "Overflow in png_memset_check."); return (png_memset (s1, value, size)); @@ -587,10 +597,11 @@ void PNGAPI png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { - if(png_ptr != NULL) { - png_ptr->mem_ptr = mem_ptr; - png_ptr->malloc_fn = malloc_fn; - png_ptr->free_fn = free_fn; + if (png_ptr != NULL) + { + png_ptr->mem_ptr = mem_ptr; + png_ptr->malloc_fn = malloc_fn; + png_ptr->free_fn = free_fn; } } @@ -601,7 +612,8 @@ png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr png_voidp PNGAPI png_get_mem_ptr(png_structp png_ptr) { - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); return ((png_voidp)png_ptr->mem_ptr); } #endif /* PNG_USER_MEM_SUPPORTED */ diff --git a/src/3rdparty/libpng/pngpread.c b/src/3rdparty/libpng/pngpread.c index aa7151c..7adb7b8 100644 --- a/src/3rdparty/libpng/pngpread.c +++ b/src/3rdparty/libpng/pngpread.c @@ -1,19 +1,21 @@ /* pngpread.c - read a png file in push mode * - * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Last changed in libpng 1.2.38 [July 16, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ #define PNG_INTERNAL #include "png.h" - #ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* push model modes */ +/* Push model modes */ #define PNG_READ_SIG_MODE 0 #define PNG_READ_CHUNK_MODE 1 #define PNG_READ_IDAT_MODE 2 @@ -28,7 +30,9 @@ void PNGAPI png_process_data(png_structp png_ptr, png_infop info_ptr, png_bytep buffer, png_size_t buffer_size) { - if(png_ptr == NULL || info_ptr == NULL) return; + if (png_ptr == NULL || info_ptr == NULL) + return; + png_push_restore_buffer(png_ptr, buffer, buffer_size); while (png_ptr->buffer_size) @@ -43,7 +47,9 @@ png_process_data(png_structp png_ptr, png_infop info_ptr, void /* PRIVATE */ png_process_some_data(png_structp png_ptr, png_infop info_ptr) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + switch (png_ptr->process_mode) { case PNG_READ_SIG_MODE: @@ -51,22 +57,26 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr) png_push_read_sig(png_ptr, info_ptr); break; } + case PNG_READ_CHUNK_MODE: { png_push_read_chunk(png_ptr, info_ptr); break; } + case PNG_READ_IDAT_MODE: { png_push_read_IDAT(png_ptr); break; } + #if defined(PNG_READ_tEXt_SUPPORTED) case PNG_READ_tEXt_MODE: { png_push_read_tEXt(png_ptr, info_ptr); break; } + #endif #if defined(PNG_READ_zTXt_SUPPORTED) case PNG_READ_zTXt_MODE: @@ -74,6 +84,7 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr) png_push_read_zTXt(png_ptr, info_ptr); break; } + #endif #if defined(PNG_READ_iTXt_SUPPORTED) case PNG_READ_iTXt_MODE: @@ -81,12 +92,14 @@ png_process_some_data(png_structp png_ptr, png_infop info_ptr) png_push_read_iTXt(png_ptr, info_ptr); break; } + #endif case PNG_SKIP_MODE: { png_push_crc_finish(png_ptr); break; } + default: { png_ptr->buffer_size = 0; @@ -114,7 +127,7 @@ png_push_read_sig(png_structp png_ptr, png_infop info_ptr) png_push_fill_buffer(png_ptr, &(info_ptr->signature[num_checked]), num_to_check); - png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes+num_to_check); + png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check); if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check)) { @@ -210,27 +223,31 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) } png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); + png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_check_chunk_name(png_ptr, png_ptr->chunk_name); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; } if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) + if (png_ptr->mode & PNG_AFTER_IDAT) png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) { + if (png_ptr->push_length != 13) + png_error(png_ptr, "Invalid IHDR length"); + if (png_ptr->push_length + 4 > png_ptr->buffer_size) { - if (png_ptr->push_length != 13) - png_error(png_ptr, "Invalid IHDR length"); png_push_save_buffer(png_ptr); return; } + png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length); } + else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) { if (png_ptr->push_length + 4 > png_ptr->buffer_size) @@ -238,11 +255,13 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length); png_ptr->process_mode = PNG_READ_DONE_MODE; png_push_have_end(png_ptr, info_ptr); } + #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) { @@ -251,20 +270,26 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) png_ptr->mode |= PNG_HAVE_IDAT; + png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length); + if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before IDAT"); + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && !(png_ptr->mode & PNG_HAVE_PLTE)) png_error(png_ptr, "Missing PLTE before IDAT"); } } + #endif else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) { @@ -275,23 +300,26 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) } png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length); } + else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) { /* If we reach an IDAT chunk, this means we have read all of the * header chunks, and we can start reading the image (or if this * is called after the image has been read - we have an error). */ - if (!(png_ptr->mode & PNG_HAVE_IHDR)) - png_error(png_ptr, "Missing IHDR before IDAT"); - else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) - png_error(png_ptr, "Missing PLTE before IDAT"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) + png_error(png_ptr, "Missing IHDR before IDAT"); + + else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && + !(png_ptr->mode & PNG_HAVE_PLTE)) + png_error(png_ptr, "Missing PLTE before IDAT"); if (png_ptr->mode & PNG_HAVE_IDAT) { if (!(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) - if (png_ptr->push_length == 0) - return; + if (png_ptr->push_length == 0) + return; if (png_ptr->mode & PNG_AFTER_IDAT) png_error(png_ptr, "Too many IDAT's found"); @@ -305,6 +333,7 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_ptr->zstream.next_out = png_ptr->row_buf; return; } + #if defined(PNG_READ_gAMA_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) { @@ -313,8 +342,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_sBIT_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) @@ -324,8 +355,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_cHRM_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) @@ -335,8 +368,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_sRGB_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) @@ -346,8 +381,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_iCCP_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) @@ -357,8 +394,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_sPLT_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) @@ -368,8 +407,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_tRNS_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) @@ -379,8 +420,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_bKGD_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) @@ -390,8 +433,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_hIST_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) @@ -401,8 +446,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_pHYs_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) @@ -412,8 +459,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_oFFs_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) @@ -423,9 +472,11 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length); } #endif + #if defined(PNG_READ_pCAL_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) { @@ -434,8 +485,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_sCAL_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) @@ -445,8 +498,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_tIME_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) @@ -456,8 +511,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_tEXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) @@ -467,8 +524,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_zTXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) @@ -478,8 +537,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length); } + #endif #if defined(PNG_READ_iTXt_SUPPORTED) else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) @@ -489,8 +550,10 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) png_push_save_buffer(png_ptr); return; } + png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); } + #endif else { @@ -565,7 +628,9 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) { png_bytep ptr; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + ptr = buffer; if (png_ptr->save_buffer_size) { @@ -589,6 +654,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) if (length < png_ptr->current_buffer_size) save_size = length; + else save_size = png_ptr->current_buffer_size; @@ -606,7 +672,7 @@ png_push_save_buffer(png_structp png_ptr) { if (png_ptr->save_buffer_ptr != png_ptr->save_buffer) { - png_size_t i,istop; + png_size_t i, istop; png_bytep sp; png_bytep dp; @@ -629,6 +695,7 @@ png_push_save_buffer(png_structp png_ptr) { png_error(png_ptr, "Potential overflow of save_buffer"); } + new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256; old_buffer = png_ptr->save_buffer; png_ptr->save_buffer = (png_bytep)png_malloc(png_ptr, @@ -675,7 +742,7 @@ png_push_read_IDAT(png_structp png_ptr) } png_push_fill_buffer(png_ptr, chunk_length, 4); - png_ptr->push_length = png_get_uint_31(png_ptr,chunk_length); + png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length); png_reset_crc(png_ptr); png_crc_read(png_ptr, png_ptr->chunk_name, 4); png_ptr->mode |= PNG_HAVE_CHUNK_HEADER; @@ -697,16 +764,19 @@ png_push_read_IDAT(png_structp png_ptr) if (png_ptr->idat_size < (png_uint_32)png_ptr->save_buffer_size) { save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) + + /* Check for overflow */ + if ((png_uint_32)save_size != png_ptr->idat_size) png_error(png_ptr, "save_size overflowed in pngpread"); } else save_size = png_ptr->save_buffer_size; png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size); + if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED)) png_process_IDAT_data(png_ptr, png_ptr->save_buffer_ptr, save_size); + png_ptr->idat_size -= save_size; png_ptr->buffer_size -= save_size; png_ptr->save_buffer_size -= save_size; @@ -719,8 +789,9 @@ png_push_read_IDAT(png_structp png_ptr) if (png_ptr->idat_size < (png_uint_32)png_ptr->current_buffer_size) { save_size = (png_size_t)png_ptr->idat_size; - /* check for overflow */ - if((png_uint_32)save_size != png_ptr->idat_size) + + /* Check for overflow */ + if ((png_uint_32)save_size != png_ptr->idat_size) png_error(png_ptr, "save_size overflowed in pngpread"); } else @@ -760,7 +831,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, png_ptr->zstream.next_in = buffer; png_ptr->zstream.avail_in = (uInt)buffer_length; - for(;;) + for (;;) { ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH); if (ret != Z_OK) @@ -769,6 +840,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, { if (png_ptr->zstream.avail_in) png_error(png_ptr, "Extra compressed data"); + if (!(png_ptr->zstream.avail_out)) { png_push_process_row(png_ptr); @@ -780,6 +852,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, } else if (ret == Z_BUF_ERROR) break; + else png_error(png_ptr, "Decompression Error"); } @@ -801,6 +874,7 @@ png_process_IDAT_data(png_structp png_ptr, png_bytep buffer, png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes; png_ptr->zstream.next_out = png_ptr->row_buf; } + else break; } @@ -829,7 +903,7 @@ png_push_process_row(png_structp png_ptr) png_do_read_transformations(png_ptr); #if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ + /* Blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) @@ -847,9 +921,10 @@ png_push_process_row(png_structp png_ptr) for (i = 0; i < 8 && png_ptr->pass == 0; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); - png_read_push_finish_row(png_ptr); /* updates png_ptr->pass */ + png_read_push_finish_row(png_ptr); /* Updates png_ptr->pass */ } - if (png_ptr->pass == 2) /* pass 1 might be empty */ + + if (png_ptr->pass == 2) /* Pass 1 might be empty */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { @@ -857,6 +932,7 @@ png_push_process_row(png_structp png_ptr) png_read_push_finish_row(png_ptr); } } + if (png_ptr->pass == 4 && png_ptr->height <= 4) { for (i = 0; i < 2 && png_ptr->pass == 4; i++) @@ -865,13 +941,16 @@ png_push_process_row(png_structp png_ptr) png_read_push_finish_row(png_ptr); } } + if (png_ptr->pass == 6 && png_ptr->height <= 4) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } + break; } + case 1: { int i; @@ -880,7 +959,8 @@ png_push_process_row(png_structp png_ptr) png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 2) /* skip top 4 generated rows */ + + if (png_ptr->pass == 2) /* Skip top 4 generated rows */ { for (i = 0; i < 4 && png_ptr->pass == 2; i++) { @@ -888,22 +968,27 @@ png_push_process_row(png_structp png_ptr) png_read_push_finish_row(png_ptr); } } + break; } + case 2: { int i; + for (i = 0; i < 4 && png_ptr->pass == 2; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } + for (i = 0; i < 4 && png_ptr->pass == 2; i++) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 4) /* pass 3 might be empty */ + + if (png_ptr->pass == 4) /* Pass 3 might be empty */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { @@ -911,17 +996,21 @@ png_push_process_row(png_structp png_ptr) png_read_push_finish_row(png_ptr); } } + break; } + case 3: { int i; + for (i = 0; i < 4 && png_ptr->pass == 3; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 4) /* skip top two generated rows */ + + if (png_ptr->pass == 4) /* Skip top two generated rows */ { for (i = 0; i < 2 && png_ptr->pass == 4; i++) { @@ -929,49 +1018,61 @@ png_push_process_row(png_structp png_ptr) png_read_push_finish_row(png_ptr); } } + break; } + case 4: { int i; + for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } + for (i = 0; i < 2 && png_ptr->pass == 4; i++) { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 6) /* pass 5 might be empty */ + + if (png_ptr->pass == 6) /* Pass 5 might be empty */ { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } + break; } + case 5: { int i; + for (i = 0; i < 2 && png_ptr->pass == 5; i++) { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); } - if (png_ptr->pass == 6) /* skip top generated row */ + + if (png_ptr->pass == 6) /* Skip top generated row */ { png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } + break; } case 6: { png_push_have_row(png_ptr, png_ptr->row_buf + 1); png_read_push_finish_row(png_ptr); + if (png_ptr->pass != 6) break; + png_push_have_row(png_ptr, png_bytep_NULL); png_read_push_finish_row(png_ptr); } @@ -989,18 +1090,18 @@ void /* PRIVATE */ png_read_push_finish_row(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ + /* Start of interlace block in the y direction */ PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ + /* Offset to next interlace block in the y direction */ PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2}; /* Height of interlace block. This is not currently used - if you need @@ -1013,6 +1114,7 @@ png_read_push_finish_row(png_structp png_ptr) if (png_ptr->row_number < png_ptr->num_rows) return; +#if defined(PNG_READ_INTERLACING_SUPPORTED) if (png_ptr->interlaced) { png_ptr->row_number = 0; @@ -1020,40 +1122,37 @@ png_read_push_finish_row(png_structp png_ptr) png_ptr->rowbytes + 1); do { - int pass; - pass = png_ptr->pass; - pass++; - if ((pass == 1 && png_ptr->width < 5) || - (pass == 3 && png_ptr->width < 3) || - (pass == 5 && png_ptr->width < 2)) - pass++; - - if (pass > 7) - pass--; - png_ptr->pass = (png_byte) pass; - if (pass < 7) - { - png_ptr->iwidth = (png_ptr->width + - png_pass_inc[pass] - 1 - - png_pass_start[pass]) / - png_pass_inc[pass]; - - png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, - png_ptr->iwidth) + 1; - - if (png_ptr->transformations & PNG_INTERLACE) - break; - - png_ptr->num_rows = (png_ptr->height + - png_pass_yinc[pass] - 1 - - png_pass_ystart[pass]) / - png_pass_yinc[pass]; - } - else - break; + png_ptr->pass++; + if ((png_ptr->pass == 1 && png_ptr->width < 5) || + (png_ptr->pass == 3 && png_ptr->width < 3) || + (png_ptr->pass == 5 && png_ptr->width < 2)) + png_ptr->pass++; + + if (png_ptr->pass > 7) + png_ptr->pass--; + + if (png_ptr->pass >= 7) + break; + + png_ptr->iwidth = (png_ptr->width + + png_pass_inc[png_ptr->pass] - 1 - + png_pass_start[png_ptr->pass]) / + png_pass_inc[png_ptr->pass]; + + png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, + png_ptr->iwidth) + 1; + + if (png_ptr->transformations & PNG_INTERLACE) + break; + + png_ptr->num_rows = (png_ptr->height + + png_pass_yinc[png_ptr->pass] - 1 - + png_pass_ystart[png_ptr->pass]) / + png_pass_yinc[png_ptr->pass]; } while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0); } +#endif /* PNG_READ_INTERLACING_SUPPORTED */ } #if defined(PNG_READ_tEXt_SUPPORTED) @@ -1064,7 +1163,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place tEXt"); - info_ptr = info_ptr; /* to quiet some compiler warnings */ + info_ptr = info_ptr; /* To quiet some compiler warnings */ } #ifdef PNG_MAX_MALLOC_64K @@ -1079,7 +1178,7 @@ png_push_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 #endif png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); + (png_uint_32)(length + 1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; png_ptr->current_text_size = (png_size_t)length; @@ -1096,8 +1195,10 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) if (png_ptr->buffer_size < png_ptr->current_text_left) text_size = png_ptr->buffer_size; + else text_size = png_ptr->current_text_left; + png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); png_ptr->current_text_left -= text_size; png_ptr->current_text_ptr += text_size; @@ -1125,7 +1226,7 @@ png_push_read_tEXt(png_structp png_ptr, png_infop info_ptr) key = png_ptr->current_text; for (text = key; *text; text++) - /* empty loop */ ; + /* Empty loop */ ; if (text < key + png_ptr->current_text_size) text++; @@ -1160,7 +1261,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place zTXt"); - info_ptr = info_ptr; /* to quiet some compiler warnings */ + info_ptr = info_ptr; /* To quiet some compiler warnings */ } #ifdef PNG_MAX_MALLOC_64K @@ -1177,7 +1278,7 @@ png_push_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 #endif png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); + (png_uint_32)(length + 1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; png_ptr->current_text_size = (png_size_t)length; @@ -1194,8 +1295,10 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) if (png_ptr->buffer_size < (png_uint_32)png_ptr->current_text_left) text_size = png_ptr->buffer_size; + else text_size = png_ptr->current_text_left; + png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); png_ptr->current_text_left -= text_size; png_ptr->current_text_ptr += text_size; @@ -1219,7 +1322,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) key = png_ptr->current_text; for (text = key; *text; text++) - /* empty loop */ ; + /* Empty loop */ ; /* zTXt can't have zero text */ if (text >= key + png_ptr->current_text_size) @@ -1231,7 +1334,7 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) text++; - if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */ + if (*text != PNG_TEXT_COMPRESSION_zTXt) /* Check compression byte */ { png_ptr->current_text = NULL; png_free(png_ptr, key); @@ -1268,13 +1371,17 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) if (text == NULL) { text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + key_size + 1)); + (png_uint_32)(png_ptr->zbuf_size + - png_ptr->zstream.avail_out + key_size + 1)); + png_memcpy(text + key_size, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); + png_memcpy(text, key, key_size); + text_size = key_size + png_ptr->zbuf_size - png_ptr->zstream.avail_out; + *(text + text_size) = '\0'; } else @@ -1283,12 +1390,15 @@ png_push_read_zTXt(png_structp png_ptr, png_infop info_ptr) tmp = text; text = (png_charp)png_malloc(png_ptr, text_size + - (png_uint_32)(png_ptr->zbuf_size - png_ptr->zstream.avail_out - + 1)); + (png_uint_32)(png_ptr->zbuf_size + - png_ptr->zstream.avail_out + 1)); + png_memcpy(text, tmp, text_size); png_free(png_ptr, tmp); + png_memcpy(text + text_size, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); + text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out; *(text + text_size) = '\0'; } @@ -1352,7 +1462,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 if (!(png_ptr->mode & PNG_HAVE_IHDR) || (png_ptr->mode & PNG_HAVE_IEND)) { png_error(png_ptr, "Out of place iTXt"); - info_ptr = info_ptr; /* to quiet some compiler warnings */ + info_ptr = info_ptr; /* To quiet some compiler warnings */ } #ifdef PNG_MAX_MALLOC_64K @@ -1367,7 +1477,7 @@ png_push_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 #endif png_ptr->current_text = (png_charp)png_malloc(png_ptr, - (png_uint_32)(length+1)); + (png_uint_32)(length + 1)); png_ptr->current_text[length] = '\0'; png_ptr->current_text_ptr = png_ptr->current_text; png_ptr->current_text_size = (png_size_t)length; @@ -1385,8 +1495,10 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) if (png_ptr->buffer_size < png_ptr->current_text_left) text_size = png_ptr->buffer_size; + else text_size = png_ptr->current_text_left; + png_crc_read(png_ptr, (png_bytep)png_ptr->current_text_ptr, text_size); png_ptr->current_text_left -= text_size; png_ptr->current_text_ptr += text_size; @@ -1417,23 +1529,25 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) key = png_ptr->current_text; for (lang = key; *lang; lang++) - /* empty loop */ ; + /* Empty loop */ ; if (lang < key + png_ptr->current_text_size - 3) lang++; comp_flag = *lang++; - lang++; /* skip comp_type, always zero */ + lang++; /* Skip comp_type, always zero */ for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ + /* Empty loop */ ; + + lang_key++; /* Skip NUL separator */ text=lang_key; + if (lang_key < key + png_ptr->current_text_size - 1) { for (; *text; text++) - /* empty loop */ ; + /* Empty loop */ ; } if (text < key + png_ptr->current_text_size) @@ -1441,6 +1555,7 @@ png_push_read_iTXt(png_structp png_ptr, png_infop info_ptr) text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)png_sizeof(png_text)); + text_ptr->compression = comp_flag + 2; text_ptr->key = key; text_ptr->lang = lang; @@ -1468,22 +1583,21 @@ void /* PRIVATE */ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_uint_32 skip=0; - png_check_chunk_name(png_ptr, png_ptr->chunk_name); + png_uint_32 skip = 0; if (!(png_ptr->chunk_name[0] & 0x20)) { #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != - PNG_HANDLE_CHUNK_ALWAYS + if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + PNG_HANDLE_CHUNK_ALWAYS #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - && png_ptr->read_user_chunk_fn == NULL + && png_ptr->read_user_chunk_fn == NULL #endif - ) + ) #endif - png_chunk_error(png_ptr, "unknown critical chunk"); + png_chunk_error(png_ptr, "unknown critical chunk"); - info_ptr = info_ptr; /* to quiet some compiler warnings */ + info_ptr = info_ptr; /* To quiet some compiler warnings */ } #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) @@ -1500,41 +1614,50 @@ png_push_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 png_memcpy((png_charp)png_ptr->unknown_chunk.name, (png_charp)png_ptr->chunk_name, png_sizeof(png_ptr->unknown_chunk.name)); - png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1]='\0'; + png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name) - 1] + = '\0'; png_ptr->unknown_chunk.size = (png_size_t)length; + if (length == 0) png_ptr->unknown_chunk.data = NULL; + else { - png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length); + png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, + (png_uint_32)length); png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); } + #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) + if (png_ptr->read_user_chunk_fn != NULL) { - /* callback to user unknown chunk handler */ + /* Callback to user unknown chunk handler */ int ret; ret = (*(png_ptr->read_user_chunk_fn)) (png_ptr, &png_ptr->unknown_chunk); + if (ret < 0) png_chunk_error(png_ptr, "error in user chunk"); + if (ret == 0) { if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != + if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS) png_chunk_error(png_ptr, "unknown critical chunk"); png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); } } + else #endif png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); png_free(png_ptr, png_ptr->unknown_chunk.data); png_ptr->unknown_chunk.data = NULL; } + else #endif skip=length; @@ -1571,7 +1694,9 @@ png_progressive_combine_row (png_structp png_ptr, PNG_CONST int FARDATA png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; #endif - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); } @@ -1581,7 +1706,9 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + png_ptr->info_fn = info_fn; png_ptr->row_fn = row_fn; png_ptr->end_fn = end_fn; @@ -1592,7 +1719,9 @@ png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, png_voidp PNGAPI png_get_progressive_ptr(png_structp png_ptr) { - if(png_ptr == NULL) return (NULL); + if (png_ptr == NULL) + return (NULL); + return png_ptr->io_ptr; } #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ diff --git a/src/3rdparty/libpng/pngread.c b/src/3rdparty/libpng/pngread.c index bd8bcd9..a4cbb3e 100644 --- a/src/3rdparty/libpng/pngread.c +++ b/src/3rdparty/libpng/pngread.c @@ -1,19 +1,21 @@ /* pngread.c - read a PNG file * - * Last changed in libpng 1.2.25 [February 18, 2008] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Last changed in libpng 1.2.37 [June 4, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file contains routines that an application calls directly to * read a PNG file or stream. */ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) /* Create a PNG structure for reading, and allocate any memory needed. */ @@ -35,6 +37,9 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, { #endif /* PNG_USER_MEM_SUPPORTED */ +#ifdef PNG_SETJMP_SUPPORTED + volatile +#endif png_structp png_ptr; #ifdef PNG_SETJMP_SUPPORTED @@ -45,7 +50,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, int i; - png_debug(1, "in png_create_read_struct\n"); + png_debug(1, "in png_create_read_struct"); #ifdef PNG_USER_MEM_SUPPORTED png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); @@ -55,7 +60,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, if (png_ptr == NULL) return (NULL); - /* added at libpng-1.2.6 */ + /* Added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED png_ptr->user_width_max=PNG_USER_WIDTH_MAX; png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; @@ -69,7 +74,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, #endif { png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; + png_ptr->zbuf = NULL; #ifdef PNG_USER_MEM_SUPPORTED png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, (png_voidp)mem_ptr); @@ -79,7 +84,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, return (NULL); } #ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); + png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); #endif #endif @@ -89,18 +94,18 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - if(user_png_ver) + if (user_png_ver) { - i=0; + i = 0; do { - if(user_png_ver[i] != png_libpng_ver[i]) + if (user_png_ver[i] != png_libpng_ver[i]) png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; } while (png_libpng_ver[i++]); } else png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; - + if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH) { @@ -128,14 +133,14 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_warning(png_ptr, msg); #endif #ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; + png_ptr->flags = 0; #endif png_error(png_ptr, "Incompatible libpng version in application and library"); } } - /* initialize zbuf - compression buffer */ + /* Initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); @@ -164,7 +169,7 @@ png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); + png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); #else if (setjmp(png_ptr->jmpbuf)) PNG_ABORT(); @@ -190,13 +195,14 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_info_size) { /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || + if (png_sizeof(png_struct) > png_struct_size || png_sizeof(png_info) > png_info_size) { char msg[80]; - png_ptr->warning_fn=NULL; + png_ptr->warning_fn = NULL; if (user_png_ver) { png_snprintf(msg, 80, @@ -210,20 +216,20 @@ png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver, png_warning(png_ptr, msg); } #endif - if(png_sizeof(png_struct) > png_struct_size) + if (png_sizeof(png_struct) > png_struct_size) { - png_ptr->error_fn=NULL; + png_ptr->error_fn = NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; + png_ptr->flags = 0; #endif png_error(png_ptr, "The png struct allocated by the application for reading is too small."); } - if(png_sizeof(png_info) > png_info_size) + if (png_sizeof(png_info) > png_info_size) { - png_ptr->error_fn=NULL; + png_ptr->error_fn = NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED - png_ptr->flags=0; + png_ptr->flags = 0; #endif png_error(png_ptr, "The info struct allocated by application for reading is too small."); @@ -240,20 +246,21 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, jmp_buf tmp_jmp; /* to save current jump buffer */ #endif - int i=0; + int i = 0; png_structp png_ptr=*ptr_ptr; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; do { - if(user_png_ver[i] != png_libpng_ver[i]) + if (user_png_ver[i] != png_libpng_ver[i]) { #ifdef PNG_LEGACY_SUPPORTED png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; #else - png_ptr->warning_fn=NULL; + png_ptr->warning_fn = NULL; png_warning(png_ptr, "Application uses deprecated png_read_init() and should be recompiled."); break; @@ -261,35 +268,35 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, } } while (png_libpng_ver[i++]); - png_debug(1, "in png_read_init_3\n"); + png_debug(1, "in png_read_init_3"); #ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); + /* Save jump buffer and error functions */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); #endif - if(png_sizeof(png_struct) > png_struct_size) - { - png_destroy_struct(png_ptr); - *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); - png_ptr = *ptr_ptr; - } + if (png_sizeof(png_struct) > png_struct_size) + { + png_destroy_struct(png_ptr); + *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG); + png_ptr = *ptr_ptr; + } - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); + /* Reset all variables to 0 */ + png_memset(png_ptr, 0, png_sizeof(png_struct)); #ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); + /* Restore jump buffer */ + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); #endif - /* added at libpng-1.2.6 */ + /* Added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED png_ptr->user_width_max=PNG_USER_WIDTH_MAX; png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; #endif - /* initialize zbuf - compression buffer */ + /* Initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); @@ -324,8 +331,9 @@ png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, void PNGAPI png_read_info(png_structp png_ptr, png_infop info_ptr) { - if(png_ptr == NULL || info_ptr == NULL) return; - png_debug(1, "in png_read_info\n"); + if (png_ptr == NULL || info_ptr == NULL) + return; + png_debug(1, "in png_read_info"); /* If we haven't checked all of the PNG signature bytes, do so now. */ if (png_ptr->sig_bytes < 8) { @@ -347,7 +355,7 @@ png_read_info(png_structp png_ptr, png_infop info_ptr) png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; } - for(;;) + for (;;) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IHDR; @@ -406,38 +414,29 @@ png_read_info(png_structp png_ptr, png_infop info_ptr) PNG_CONST PNG_zTXt; #endif #endif /* PNG_USE_LOCAL_ARRAYS */ - png_byte chunk_length[4]; - png_uint_32 length; - - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug2(0, "Reading %s chunk, length=%lu.\n", png_ptr->chunk_name, - length); + png_uint_32 length = png_read_chunk_header(png_ptr); + PNG_CONST png_bytep chunk_name = png_ptr->chunk_name; /* This should be a binary subdivision search or a hash for * matching the chunk name rather than a linear search. */ - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) - if(png_ptr->mode & PNG_AFTER_IDAT) + if (!png_memcmp(chunk_name, png_IDAT, 4)) + if (png_ptr->mode & PNG_AFTER_IDAT) png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + if (!png_memcmp(chunk_name, png_IHDR, 4)) png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + else if (!png_memcmp(chunk_name, png_IEND, 4)) png_handle_IEND(png_ptr, info_ptr, length); #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + else if (png_handle_as_unknown(png_ptr, chunk_name)) { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + if (!png_memcmp(chunk_name, png_IDAT, 4)) png_ptr->mode |= PNG_HAVE_IDAT; png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + if (!png_memcmp(chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + else if (!png_memcmp(chunk_name, png_IDAT, 4)) { if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before IDAT"); @@ -448,9 +447,9 @@ png_read_info(png_structp png_ptr, png_infop info_ptr) } } #endif - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + else if (!png_memcmp(chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + else if (!png_memcmp(chunk_name, png_IDAT, 4)) { if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before IDAT"); @@ -463,71 +462,71 @@ png_read_info(png_structp png_ptr, png_infop info_ptr) break; } #if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + else if (!png_memcmp(chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + else if (!png_memcmp(chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + else if (!png_memcmp(chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + else if (!png_memcmp(chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + else if (!png_memcmp(chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + else if (!png_memcmp(chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + else if (!png_memcmp(chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + else if (!png_memcmp(chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + else if (!png_memcmp(chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + else if (!png_memcmp(chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + else if (!png_memcmp(chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + else if (!png_memcmp(chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + else if (!png_memcmp(chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + else if (!png_memcmp(chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + else if (!png_memcmp(chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + else if (!png_memcmp(chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + else if (!png_memcmp(chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif else @@ -536,12 +535,13 @@ png_read_info(png_structp png_ptr, png_infop info_ptr) } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -/* optional call to update the users info_ptr structure */ +/* Optional call to update the users info_ptr structure */ void PNGAPI png_read_update_info(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_read_update_info\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_read_update_info"); + if (png_ptr == NULL) + return; if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); else @@ -559,8 +559,9 @@ png_read_update_info(png_structp png_ptr, png_infop info_ptr) void PNGAPI png_start_read_image(png_structp png_ptr) { - png_debug(1, "in png_start_read_image\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_start_read_image"); + if (png_ptr == NULL) + return; if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); } @@ -573,18 +574,19 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IDAT; PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, - 0xff}; + 0xff}; PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff}; #endif int ret; - if(png_ptr == NULL) return; - png_debug2(1, "in png_read_row (row %lu, pass %d)\n", + if (png_ptr == NULL) + return; + png_debug2(1, "in png_read_row (row %lu, pass %d)", png_ptr->row_number, png_ptr->pass); if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) png_read_start_row(png_ptr); if (png_ptr->row_number == 0 && png_ptr->pass == 0) { - /* check for transforms that have been set but were defined out */ + /* Check for transforms that have been set but were defined out */ #if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) if (png_ptr->transformations & PNG_INVERT_MONO) png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined."); @@ -616,7 +618,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) } #if defined(PNG_READ_INTERLACING_SUPPORTED) - /* if interlaced and we do not need a new row, combine row and return */ + /* If interlaced and we do not need a new row, combine row and return */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { switch (png_ptr->pass) @@ -703,15 +705,9 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) { while (!png_ptr->idat_size) { - png_byte chunk_length[4]; - png_crc_finish(png_ptr, 0); - png_read_data(png_ptr, chunk_length, 4); - png_ptr->idat_size = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); + png_ptr->idat_size = png_read_chunk_header(png_ptr); if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) png_error(png_ptr, "Not enough image data"); } @@ -747,7 +743,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->row_info.width); - if(png_ptr->row_buf[0]) + if (png_ptr->row_buf[0]) png_read_filter_row(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->prev_row + 1, (int)(png_ptr->row_buf[0])); @@ -756,7 +752,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) png_ptr->rowbytes + 1); #if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) { /* Intrapixel differencing */ @@ -769,15 +765,15 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row) png_do_read_transformations(png_ptr); #if defined(PNG_READ_INTERLACING_SUPPORTED) - /* blow up interlaced rows to full size */ + /* Blow up interlaced rows to full size */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { if (png_ptr->pass < 6) -/* old interface (pre-1.0.9): - png_do_read_interlace(&(png_ptr->row_info), - png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); - */ + /* Old interface (pre-1.0.9): + * png_do_read_interlace(&(png_ptr->row_info), + * png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations); + */ png_do_read_interlace(png_ptr); if (dsp_row != NULL) @@ -835,8 +831,9 @@ png_read_rows(png_structp png_ptr, png_bytepp row, png_bytepp rp; png_bytepp dp; - png_debug(1, "in png_read_rows\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_read_rows"); + if (png_ptr == NULL) + return; rp = row; dp = display_row; if (rp != NULL && dp != NULL) @@ -847,14 +844,14 @@ png_read_rows(png_structp png_ptr, png_bytepp row, png_read_row(png_ptr, rptr, dptr); } - else if(rp != NULL) + else if (rp != NULL) for (i = 0; i < num_rows; i++) { png_bytep rptr = *rp; png_read_row(png_ptr, rptr, png_bytep_NULL); rp++; } - else if(dp != NULL) + else if (dp != NULL) for (i = 0; i < num_rows; i++) { png_bytep dptr = *dp; @@ -880,12 +877,13 @@ png_read_rows(png_structp png_ptr, png_bytepp row, void PNGAPI png_read_image(png_structp png_ptr, png_bytepp image) { - png_uint_32 i,image_height; + png_uint_32 i, image_height; int pass, j; png_bytepp rp; - png_debug(1, "in png_read_image\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_read_image"); + if (png_ptr == NULL) + return; #ifdef PNG_READ_INTERLACING_SUPPORTED pass = png_set_interlace_handling(png_ptr); @@ -920,11 +918,9 @@ png_read_image(png_structp png_ptr, png_bytepp image) void PNGAPI png_read_end(png_structp png_ptr, png_infop info_ptr) { - png_byte chunk_length[4]; - png_uint_32 length; - - png_debug(1, "in png_read_end\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_read_end"); + if (png_ptr == NULL) + return; png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */ do @@ -986,33 +982,27 @@ png_read_end(png_structp png_ptr, png_infop info_ptr) PNG_CONST PNG_zTXt; #endif #endif /* PNG_USE_LOCAL_ARRAYS */ + png_uint_32 length = png_read_chunk_header(png_ptr); + PNG_CONST png_bytep chunk_name = png_ptr->chunk_name; - png_read_data(png_ptr, chunk_length, 4); - length = png_get_uint_31(png_ptr,chunk_length); - - png_reset_crc(png_ptr); - png_crc_read(png_ptr, png_ptr->chunk_name, 4); - - png_debug1(0, "Reading %s chunk.\n", png_ptr->chunk_name); - - if (!png_memcmp(png_ptr->chunk_name, png_IHDR, 4)) + if (!png_memcmp(chunk_name, png_IHDR, 4)) png_handle_IHDR(png_ptr, info_ptr, length); - else if (!png_memcmp(png_ptr->chunk_name, png_IEND, 4)) + else if (!png_memcmp(chunk_name, png_IEND, 4)) png_handle_IEND(png_ptr, info_ptr, length); #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED - else if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name)) + else if (png_handle_as_unknown(png_ptr, chunk_name)) { - if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + if (!png_memcmp(chunk_name, png_IDAT, 4)) { if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT)) png_error(png_ptr, "Too many IDAT's found"); } png_handle_unknown(png_ptr, info_ptr, length); - if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + if (!png_memcmp(chunk_name, png_PLTE, 4)) png_ptr->mode |= PNG_HAVE_PLTE; } #endif - else if (!png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) + else if (!png_memcmp(chunk_name, png_IDAT, 4)) { /* Zero length IDATs are legal after the last IDAT has been * read, but not after other chunks have been read. @@ -1021,74 +1011,74 @@ png_read_end(png_structp png_ptr, png_infop info_ptr) png_error(png_ptr, "Too many IDAT's found"); png_crc_finish(png_ptr, length); } - else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4)) + else if (!png_memcmp(chunk_name, png_PLTE, 4)) png_handle_PLTE(png_ptr, info_ptr, length); #if defined(PNG_READ_bKGD_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_bKGD, 4)) + else if (!png_memcmp(chunk_name, png_bKGD, 4)) png_handle_bKGD(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_cHRM_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_cHRM, 4)) + else if (!png_memcmp(chunk_name, png_cHRM, 4)) png_handle_cHRM(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_gAMA_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_gAMA, 4)) + else if (!png_memcmp(chunk_name, png_gAMA, 4)) png_handle_gAMA(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_hIST_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_hIST, 4)) + else if (!png_memcmp(chunk_name, png_hIST, 4)) png_handle_hIST(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_oFFs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_oFFs, 4)) + else if (!png_memcmp(chunk_name, png_oFFs, 4)) png_handle_oFFs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pCAL, 4)) + else if (!png_memcmp(chunk_name, png_pCAL, 4)) png_handle_pCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sCAL_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sCAL, 4)) + else if (!png_memcmp(chunk_name, png_sCAL, 4)) png_handle_sCAL(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_pHYs_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_pHYs, 4)) + else if (!png_memcmp(chunk_name, png_pHYs, 4)) png_handle_pHYs(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sBIT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sBIT, 4)) + else if (!png_memcmp(chunk_name, png_sBIT, 4)) png_handle_sBIT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sRGB_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sRGB, 4)) + else if (!png_memcmp(chunk_name, png_sRGB, 4)) png_handle_sRGB(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iCCP_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iCCP, 4)) + else if (!png_memcmp(chunk_name, png_iCCP, 4)) png_handle_iCCP(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_sPLT_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_sPLT, 4)) + else if (!png_memcmp(chunk_name, png_sPLT, 4)) png_handle_sPLT(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tEXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4)) + else if (!png_memcmp(chunk_name, png_tEXt, 4)) png_handle_tEXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tIME_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tIME, 4)) + else if (!png_memcmp(chunk_name, png_tIME, 4)) png_handle_tIME(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_tRNS_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_tRNS, 4)) + else if (!png_memcmp(chunk_name, png_tRNS, 4)) png_handle_tRNS(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_zTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4)) + else if (!png_memcmp(chunk_name, png_zTXt, 4)) png_handle_zTXt(png_ptr, info_ptr, length); #endif #if defined(PNG_READ_iTXt_SUPPORTED) - else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4)) + else if (!png_memcmp(chunk_name, png_iTXt, 4)) png_handle_iTXt(png_ptr, info_ptr, length); #endif else @@ -1097,7 +1087,7 @@ png_read_end(png_structp png_ptr, png_infop info_ptr) } #endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ -/* free all memory used by the read */ +/* Free all memory used by the read */ void PNGAPI png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr) @@ -1109,11 +1099,9 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, png_voidp mem_ptr = NULL; #endif - png_debug(1, "in png_destroy_read_struct\n"); + png_debug(1, "in png_destroy_read_struct"); if (png_ptr_ptr != NULL) - { png_ptr = *png_ptr_ptr; - } if (png_ptr == NULL) return; @@ -1159,16 +1147,19 @@ png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr, *end_info_ptr_ptr = NULL; } + if (png_ptr != NULL) + { #ifdef PNG_USER_MEM_SUPPORTED - png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, - (png_voidp)mem_ptr); + png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn, + (png_voidp)mem_ptr); #else - png_destroy_struct((png_voidp)png_ptr); + png_destroy_struct((png_voidp)png_ptr); #endif - *png_ptr_ptr = NULL; + *png_ptr_ptr = NULL; + } } -/* free all memory used by the read (old method) */ +/* Free all memory used by the read (old method) */ void /* PRIVATE */ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr) { @@ -1182,7 +1173,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr png_free_ptr free_fn; #endif - png_debug(1, "in png_read_destroy\n"); + png_debug(1, "in png_read_destroy"); if (info_ptr != NULL) png_info_destroy(png_ptr, info_ptr); @@ -1192,6 +1183,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->big_row_buf); png_free(png_ptr, png_ptr->prev_row); + png_free(png_ptr, png_ptr->chunkdata); #if defined(PNG_READ_DITHER_SUPPORTED) png_free(png_ptr, png_ptr->palette_lookup); png_free(png_ptr, png_ptr->dither_index); @@ -1288,7 +1280,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr * being used again. */ #ifdef PNG_SETJMP_SUPPORTED - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); #endif error_fn = png_ptr->error_fn; @@ -1298,7 +1290,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr free_fn = png_ptr->free_fn; #endif - png_memset(png_ptr, 0, png_sizeof (png_struct)); + png_memset(png_ptr, 0, png_sizeof(png_struct)); png_ptr->error_fn = error_fn; png_ptr->warning_fn = warning_fn; @@ -1308,7 +1300,7 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr #endif #ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); #endif } @@ -1316,7 +1308,8 @@ png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr void PNGAPI png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->read_row_fn = read_row_fn; } @@ -1330,9 +1323,10 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, { int row; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; #if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency + /* Invert the alpha channel from opacity to transparency */ if (transforms & PNG_TRANSFORM_INVERT_ALPHA) png_set_invert_alpha(png_ptr); @@ -1343,15 +1337,15 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, */ png_read_info(png_ptr, info_ptr); if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep)) - png_error(png_ptr,"Image is too high to process with png_read_png()"); + png_error(png_ptr, "Image is too high to process with png_read_png()"); /* -------------- image transformations start here ------------------- */ #if defined(PNG_READ_16_TO_8_SUPPORTED) - /* tell libpng to strip 16 bit/color files down to 8 bits per color + /* Tell libpng to strip 16 bit/color files down to 8 bits per color. */ if (transforms & PNG_TRANSFORM_STRIP_16) - png_set_strip_16(png_ptr); + png_set_strip_16(png_ptr); #endif #if defined(PNG_READ_STRIP_ALPHA_SUPPORTED) @@ -1359,7 +1353,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, * the background (not recommended). */ if (transforms & PNG_TRANSFORM_STRIP_ALPHA) - png_set_strip_alpha(png_ptr); + png_set_strip_alpha(png_ptr); #endif #if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED) @@ -1367,7 +1361,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, * byte into separate bytes (useful for paletted and grayscale images). */ if (transforms & PNG_TRANSFORM_PACKING) - png_set_packing(png_ptr); + png_set_packing(png_ptr); #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED) @@ -1375,7 +1369,7 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, * (not useful if you are using png_set_packing). */ if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); + png_set_packswap(png_ptr); #endif #if defined(PNG_READ_EXPAND_SUPPORTED) @@ -1385,9 +1379,9 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, * channels so the data will be available as RGBA quartets. */ if (transforms & PNG_TRANSFORM_EXPAND) - if ((png_ptr->bit_depth < 8) || - (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || - (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) + if ((png_ptr->bit_depth < 8) || + (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) || + (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))) png_set_expand(png_ptr); #endif @@ -1395,10 +1389,10 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, */ #if defined(PNG_READ_INVERT_SUPPORTED) - /* invert monochrome files to have 0 as white and 1 as black + /* Invert monochrome files to have 0 as white and 1 as black */ if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); + png_set_invert_mono(png_ptr); #endif #if defined(PNG_READ_SHIFT_SUPPORTED) @@ -1417,24 +1411,24 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, #endif #if defined(PNG_READ_BGR_SUPPORTED) - /* flip the RGB pixels to BGR (or RGBA to BGRA) + /* Flip the RGB pixels to BGR (or RGBA to BGRA) */ if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); + png_set_bgr(png_ptr); #endif #if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) - /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) + /* Swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR) */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) png_set_swap_alpha(png_ptr); #endif #if defined(PNG_READ_SWAP_SUPPORTED) - /* swap bytes of 16 bit files to least significant byte first + /* Swap bytes of 16 bit files to least significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); + png_set_swap(png_ptr); #endif /* We don't handle adding filler bytes */ @@ -1450,27 +1444,27 @@ png_read_png(png_structp png_ptr, png_infop info_ptr, #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); #endif - if(info_ptr->row_pointers == NULL) + if (info_ptr->row_pointers == NULL) { info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr, info_ptr->height * png_sizeof(png_bytep)); + png_memset(info_ptr->row_pointers, 0, info_ptr->height + * png_sizeof(png_bytep)); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_ROWS; #endif for (row = 0; row < (int)info_ptr->height; row++) - { info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr)); - } } png_read_image(png_ptr, info_ptr->row_pointers); info_ptr->valid |= PNG_INFO_IDAT; - /* read rest of file, and get additional chunks in info_ptr - REQUIRED */ + /* Read rest of file, and get additional chunks in info_ptr - REQUIRED */ png_read_end(png_ptr, info_ptr); - transforms = transforms; /* quiet compiler warnings */ + transforms = transforms; /* Quiet compiler warnings */ params = params; } diff --git a/src/3rdparty/libpng/pngrio.c b/src/3rdparty/libpng/pngrio.c index 7d2522f..2267bca 100644 --- a/src/3rdparty/libpng/pngrio.c +++ b/src/3rdparty/libpng/pngrio.c @@ -1,12 +1,15 @@ /* pngrio.c - functions for data input * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * Last changed in libpng 1.2.37 [June 4, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file provides a location for all input. Users who need * special handling are expected to write a function that has the same * arguments as this and performs a similar function, but that possibly @@ -17,18 +20,18 @@ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) /* Read the data from whatever input you are using. The default routine - reads from a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered reads. This should never be asked - to read more then 64K on a 16 bit machine. */ + * reads from a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered reads. This should never be asked + * to read more then 64K on a 16 bit machine. + */ void /* PRIVATE */ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { - png_debug1(4,"reading %d bytes\n", (int)length); + png_debug1(4, "reading %d bytes", (int)length); if (png_ptr->read_data_fn != NULL) (*(png_ptr->read_data_fn))(png_ptr, data, length); else @@ -37,16 +40,18 @@ png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) #if !defined(PNG_NO_STDIO) /* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ + * not reading from a standard C stream, you should create a replacement + * read_data function and use it at run time with png_set_read_fn(), rather + * than changing the library. + */ #ifndef USE_FAR_KEYWORD void PNGAPI png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_size_t check; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; /* fread() returns 0 on error, so it is OK to store this in a png_size_t * instead of an int, which is what fread() actually returns. */ @@ -62,7 +67,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_error(png_ptr, "Read Error"); } #else -/* this is the model-independent version. Since the standard I/O library +/* This is the model-independent version. Since the standard I/O library can't handle far buffers in the medium and small models, we have to copy the data. */ @@ -77,7 +82,8 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) png_byte *n_data; png_FILE_p io_ptr; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; /* Check if data really is near. If so, use usual code. */ n_data = (png_byte *)CVT_PTR_NOCHECK(data); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); @@ -106,7 +112,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) err = fread(buf, (png_size_t)1, read, io_ptr); #endif png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) + if (err != read) break; else check += err; @@ -122,23 +128,27 @@ png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) #endif /* This function allows the application to supply a new input function - for libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png input data structure - io_ptr - pointer to user supplied structure containing info about - the input functions. May be NULL. - read_data_fn - pointer to a new input function that takes as its - arguments a pointer to a png_struct, a pointer to - a location where input data can be stored, and a 32-bit - unsigned int that is the number of bytes to be read. - To exit and output any fatal error messages the new write - function should call png_error(png_ptr, "Error msg"). */ + * for libpng if standard C streams aren't being used. + * + * This function takes as its arguments: + * png_ptr - pointer to a png input data structure + * io_ptr - pointer to user supplied structure containing info about + * the input functions. May be NULL. + * read_data_fn - pointer to a new input function that takes as its + * arguments a pointer to a png_struct, a pointer to + * a location where input data can be stored, and a 32-bit + * unsigned int that is the number of bytes to be read. + * To exit and output any fatal error messages the new write + * function should call png_error(png_ptr, "Error msg"). + * May be NULL, in which case libpng's default function will + * be used. + */ void PNGAPI png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr read_data_fn) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_ptr->io_ptr = io_ptr; #if !defined(PNG_NO_STDIO) diff --git a/src/3rdparty/libpng/pngrtran.c b/src/3rdparty/libpng/pngrtran.c index 873b22c..d7e6b4a 100644 --- a/src/3rdparty/libpng/pngrtran.c +++ b/src/3rdparty/libpng/pngrtran.c @@ -1,12 +1,15 @@ /* pngrtran.c - transforms the data in a row for PNG readers * - * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Last changed in libpng 1.2.38 [July 16, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file contains functions optionally called by an application * in order to tell libpng how to handle data when reading a PNG. * Transformations that are used in both reading and writing are @@ -15,32 +18,37 @@ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) /* Set the action on getting a CRC error for an ancillary or critical chunk. */ void PNGAPI png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) { - png_debug(1, "in png_set_crc_action\n"); + png_debug(1, "in png_set_crc_action"); /* Tell libpng how we react to CRC errors in critical chunks */ - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; switch (crit_action) { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ + case PNG_CRC_NO_CHANGE: /* Leave setting as is */ break; - case PNG_CRC_WARN_USE: /* warn/use data */ + + case PNG_CRC_WARN_USE: /* Warn/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE; break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ + + case PNG_CRC_QUIET_USE: /* Quiet/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE | PNG_FLAG_CRC_CRITICAL_IGNORE; break; - case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */ - png_warning(png_ptr, "Can't discard critical data on CRC error."); - case PNG_CRC_ERROR_QUIT: /* error/quit */ + + case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */ + png_warning(png_ptr, + "Can't discard critical data on CRC error."); + case PNG_CRC_ERROR_QUIT: /* Error/quit */ + case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; @@ -49,22 +57,27 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) switch (ancil_action) { - case PNG_CRC_NO_CHANGE: /* leave setting as is */ + case PNG_CRC_NO_CHANGE: /* Leave setting as is */ break; - case PNG_CRC_WARN_USE: /* warn/use data */ + + case PNG_CRC_WARN_USE: /* Warn/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE; break; - case PNG_CRC_QUIET_USE: /* quiet/use data */ + + case PNG_CRC_QUIET_USE: /* Quiet/use data */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN; break; - case PNG_CRC_ERROR_QUIT: /* error/quit */ + + case PNG_CRC_ERROR_QUIT: /* Error/quit */ png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN; break; - case PNG_CRC_WARN_DISCARD: /* warn/discard data */ + + case PNG_CRC_WARN_DISCARD: /* Warn/discard data */ + case PNG_CRC_DEFAULT: default: png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK; @@ -74,14 +87,15 @@ png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action) #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ defined(PNG_FLOATING_POINT_SUPPORTED) -/* handle alpha and tRNS via a background color */ +/* Handle alpha and tRNS via a background color */ void PNGAPI png_set_background(png_structp png_ptr, png_color_16p background_color, int background_gamma_code, int need_expand, double background_gamma) { - png_debug(1, "in png_set_background\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_background"); + if (png_ptr == NULL) + return; if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN) { png_warning(png_ptr, "Application must supply a known background gamma"); @@ -98,12 +112,13 @@ png_set_background(png_structp png_ptr, #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) -/* strip 16 bit depth files to 8 bit depth */ +/* Strip 16 bit depth files to 8 bit depth */ void PNGAPI png_set_strip_16(png_structp png_ptr) { - png_debug(1, "in png_set_strip_16\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_strip_16"); + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_16_TO_8; } #endif @@ -112,8 +127,9 @@ png_set_strip_16(png_structp png_ptr) void PNGAPI png_set_strip_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_strip_alpha\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_strip_alpha"); + if (png_ptr == NULL) + return; png_ptr->flags |= PNG_FLAG_STRIP_ALPHA; } #endif @@ -142,8 +158,9 @@ png_set_dither(png_structp png_ptr, png_colorp palette, int num_palette, int maximum_colors, png_uint_16p histogram, int full_dither) { - png_debug(1, "in png_set_dither\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_dither"); + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_DITHER; if (!full_dither) @@ -151,7 +168,7 @@ png_set_dither(png_structp png_ptr, png_colorp palette, int i; png_ptr->dither_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); + (png_uint_32)(num_palette * png_sizeof(png_byte))); for (i = 0; i < num_palette; i++) png_ptr->dither_index[i] = (png_byte)i; } @@ -161,27 +178,29 @@ png_set_dither(png_structp png_ptr, png_colorp palette, if (histogram != NULL) { /* This is easy enough, just throw out the least used colors. - Perhaps not the best solution, but good enough. */ + * Perhaps not the best solution, but good enough. + */ int i; - /* initialize an array to sort colors */ + /* Initialize an array to sort colors */ png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); + (png_uint_32)(num_palette * png_sizeof(png_byte))); - /* initialize the dither_sort array */ + /* Initialize the dither_sort array */ for (i = 0; i < num_palette; i++) png_ptr->dither_sort[i] = (png_byte)i; /* Find the least used palette entries by starting a - bubble sort, and running it until we have sorted - out enough colors. Note that we don't care about - sorting all the colors, just finding which are - least used. */ + * bubble sort, and running it until we have sorted + * out enough colors. Note that we don't care about + * sorting all the colors, just finding which are + * least used. + */ for (i = num_palette - 1; i >= maximum_colors; i--) { - int done; /* to stop early if the list is pre-sorted */ + int done; /* To stop early if the list is pre-sorted */ int j; done = 1; @@ -202,13 +221,14 @@ png_set_dither(png_structp png_ptr, png_colorp palette, break; } - /* swap the palette around, and set up a table, if necessary */ + /* Swap the palette around, and set up a table, if necessary */ if (full_dither) { int j = num_palette; - /* put all the useful colors within the max, but don't - move the others */ + /* Put all the useful colors within the max, but don't + * move the others. + */ for (i = 0; i < maximum_colors; i++) { if ((int)png_ptr->dither_sort[i] >= maximum_colors) @@ -224,11 +244,12 @@ png_set_dither(png_structp png_ptr, png_colorp palette, { int j = num_palette; - /* move all the used colors inside the max limit, and - develop a translation table */ + /* Move all the used colors inside the max limit, and + * develop a translation table. + */ for (i = 0; i < maximum_colors; i++) { - /* only move the colors we need to */ + /* Only move the colors we need to */ if ((int)png_ptr->dither_sort[i] >= maximum_colors) { png_color tmp_color; @@ -240,20 +261,20 @@ png_set_dither(png_structp png_ptr, png_colorp palette, tmp_color = palette[j]; palette[j] = palette[i]; palette[i] = tmp_color; - /* indicate where the color went */ + /* Indicate where the color went */ png_ptr->dither_index[j] = (png_byte)i; png_ptr->dither_index[i] = (png_byte)j; } } - /* find closest color for those colors we are not using */ + /* Find closest color for those colors we are not using */ for (i = 0; i < num_palette; i++) { if ((int)png_ptr->dither_index[i] >= maximum_colors) { int min_d, k, min_k, d_index; - /* find the closest color to one we threw out */ + /* Find the closest color to one we threw out */ d_index = png_ptr->dither_index[i]; min_d = PNG_COLOR_DIST(palette[d_index], palette[0]); for (k = 1, min_k = 0; k < maximum_colors; k++) @@ -268,39 +289,39 @@ png_set_dither(png_structp png_ptr, png_colorp palette, min_k = k; } } - /* point to closest color */ + /* Point to closest color */ png_ptr->dither_index[i] = (png_byte)min_k; } } } png_free(png_ptr, png_ptr->dither_sort); - png_ptr->dither_sort=NULL; + png_ptr->dither_sort = NULL; } else { /* This is much harder to do simply (and quickly). Perhaps - we need to go through a median cut routine, but those - don't always behave themselves with only a few colors - as input. So we will just find the closest two colors, - and throw out one of them (chosen somewhat randomly). - [We don't understand this at all, so if someone wants to - work on improving it, be our guest - AED, GRP] - */ + * we need to go through a median cut routine, but those + * don't always behave themselves with only a few colors + * as input. So we will just find the closest two colors, + * and throw out one of them (chosen somewhat randomly). + * [We don't understand this at all, so if someone wants to + * work on improving it, be our guest - AED, GRP] + */ int i; int max_d; int num_new_palette; png_dsortp t; png_dsortpp hash; - t=NULL; + t = NULL; - /* initialize palette index arrays */ + /* Initialize palette index arrays */ png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); + (png_uint_32)(num_palette * png_sizeof(png_byte))); png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr, - (png_uint_32)(num_palette * png_sizeof (png_byte))); + (png_uint_32)(num_palette * png_sizeof(png_byte))); - /* initialize the sort array */ + /* Initialize the sort array */ for (i = 0; i < num_palette; i++) { png_ptr->index_to_palette[i] = (png_byte)i; @@ -308,21 +329,19 @@ png_set_dither(png_structp png_ptr, png_colorp palette, } hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 * - png_sizeof (png_dsortp))); - for (i = 0; i < 769; i++) - hash[i] = NULL; -/* png_memset(hash, 0, 769 * png_sizeof (png_dsortp)); */ + png_sizeof(png_dsortp))); + png_memset(hash, 0, 769 * png_sizeof(png_dsortp)); num_new_palette = num_palette; - /* initial wild guess at how far apart the farthest pixel - pair we will be eliminating will be. Larger - numbers mean more areas will be allocated, Smaller - numbers run the risk of not saving enough data, and - having to do this all over again. - - I have not done extensive checking on this number. - */ + /* Initial wild guess at how far apart the farthest pixel + * pair we will be eliminating will be. Larger + * numbers mean more areas will be allocated, Smaller + * numbers run the risk of not saving enough data, and + * having to do this all over again. + * + * I have not done extensive checking on this number. + */ max_d = 96; while (num_new_palette > maximum_colors) @@ -436,8 +455,8 @@ png_set_dither(png_structp png_ptr, png_colorp palette, png_free(png_ptr, hash); png_free(png_ptr, png_ptr->palette_to_index); png_free(png_ptr, png_ptr->index_to_palette); - png_ptr->palette_to_index=NULL; - png_ptr->index_to_palette=NULL; + png_ptr->palette_to_index = NULL; + png_ptr->index_to_palette = NULL; } num_palette = maximum_colors; } @@ -457,12 +476,10 @@ png_set_dither(png_structp png_ptr, png_colorp palette, int num_green = (1 << PNG_DITHER_GREEN_BITS); int num_blue = (1 << PNG_DITHER_BLUE_BITS); png_size_t num_entries = ((png_size_t)1 << total_bits); - png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr, - (png_uint_32)(num_entries * png_sizeof (png_byte))); - + (png_uint_32)(num_entries * png_sizeof(png_byte))); png_memset(png_ptr->palette_lookup, 0, num_entries * - png_sizeof (png_byte)); + png_sizeof(png_byte)); distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries * png_sizeof(png_byte))); @@ -526,8 +543,9 @@ png_set_dither(png_structp png_ptr, png_colorp palette, void PNGAPI png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) { - png_debug(1, "in png_set_gamma\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_gamma"); + if (png_ptr == NULL) + return; if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) || (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) || (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)) @@ -545,8 +563,9 @@ png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma) void PNGAPI png_set_expand(png_structp png_ptr) { - png_debug(1, "in png_set_expand\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_expand"); + if (png_ptr == NULL) + return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } @@ -572,8 +591,9 @@ png_set_expand(png_structp png_ptr) void PNGAPI png_set_palette_to_rgb(png_structp png_ptr) { - png_debug(1, "in png_set_palette_to_rgb\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_palette_to_rgb"); + if (png_ptr == NULL) + return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } @@ -583,8 +603,9 @@ png_set_palette_to_rgb(png_structp png_ptr) void PNGAPI png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) { - png_debug(1, "in png_set_expand_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_expand_gray_1_2_4_to_8"); + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_EXPAND; png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } @@ -596,8 +617,9 @@ png_set_expand_gray_1_2_4_to_8(png_structp png_ptr) void PNGAPI png_set_gray_1_2_4_to_8(png_structp png_ptr) { - png_debug(1, "in png_set_gray_1_2_4_to_8\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_gray_1_2_4_to_8"); + if (png_ptr == NULL) + return; png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); } #endif @@ -607,7 +629,7 @@ png_set_gray_1_2_4_to_8(png_structp png_ptr) void PNGAPI png_set_tRNS_to_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_tRNS_to_alpha\n"); + png_debug(1, "in png_set_tRNS_to_alpha"); png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS); png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } @@ -617,7 +639,7 @@ png_set_tRNS_to_alpha(png_structp png_ptr) void PNGAPI png_set_gray_to_rgb(png_structp png_ptr) { - png_debug(1, "in png_set_gray_to_rgb\n"); + png_debug(1, "in png_set_gray_to_rgb"); png_ptr->transformations |= PNG_GRAY_TO_RGB; png_ptr->flags &= ~PNG_FLAG_ROW_INIT; } @@ -633,10 +655,11 @@ void PNGAPI png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red, double green) { - int red_fixed = (int)((float)red*100000.0 + 0.5); - int green_fixed = (int)((float)green*100000.0 + 0.5); - if(png_ptr == NULL) return; - png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); + int red_fixed = (int)((float)red*100000.0 + 0.5); + int green_fixed = (int)((float)green*100000.0 + 0.5); + if (png_ptr == NULL) + return; + png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed); } #endif @@ -644,14 +667,17 @@ void PNGAPI png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, png_fixed_point red, png_fixed_point green) { - png_debug(1, "in png_set_rgb_to_gray\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_rgb_to_gray"); + if (png_ptr == NULL) + return; switch(error_action) { case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY; break; + case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN; break; + case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR; } if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) @@ -659,21 +685,22 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, png_ptr->transformations |= PNG_EXPAND; #else { - png_warning(png_ptr, "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); + png_warning(png_ptr, + "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED."); png_ptr->transformations &= ~PNG_RGB_TO_GRAY; } #endif { png_uint_16 red_int, green_int; - if(red < 0 || green < 0) + if (red < 0 || green < 0) { red_int = 6968; /* .212671 * 32768 + .5 */ green_int = 23434; /* .715160 * 32768 + .5 */ } - else if(red + green < 100000L) + else if (red + green < 100000L) { - red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); - green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); + red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L); + green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L); } else { @@ -683,26 +710,28 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action, } png_ptr->rgb_to_gray_red_coeff = red_int; png_ptr->rgb_to_gray_green_coeff = green_int; - png_ptr->rgb_to_gray_blue_coeff = (png_uint_16)(32768-red_int-green_int); + png_ptr->rgb_to_gray_blue_coeff = + (png_uint_16)(32768 - red_int - green_int); } } #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) + defined(PNG_LEGACY_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) void PNGAPI png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr read_user_transform_fn) { - png_debug(1, "in png_set_read_user_transform_fn\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_read_user_transform_fn"); + if (png_ptr == NULL) + return; #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) png_ptr->transformations |= PNG_USER_TRANSFORM; png_ptr->read_user_transform_fn = read_user_transform_fn; #endif #ifdef PNG_LEGACY_SUPPORTED - if(read_user_transform_fn) + if (read_user_transform_fn) png_warning(png_ptr, "This version of libpng does not support user transforms"); #endif @@ -715,9 +744,9 @@ png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr void /* PRIVATE */ png_init_read_transformations(png_structp png_ptr) { - png_debug(1, "in png_init_read_transformations\n"); + png_debug(1, "in png_init_read_transformations"); #if defined(PNG_USELESS_TESTS_SUPPORTED) - if(png_ptr != NULL) + if (png_ptr != NULL) #endif { #if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \ @@ -729,8 +758,9 @@ png_init_read_transformations(png_structp png_ptr) #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) /* Detect gray background and attempt to enable optimization - * for gray --> RGB case */ - /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or + * for gray --> RGB case + * + * Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or * RGB_ALPHA (in which case need_expand is superfluous anyway), the * background color might actually be gray yet not be flagged as such. * This is not a problem for the current code, which uses @@ -757,7 +787,7 @@ png_init_read_transformations(png_structp png_ptr) { if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */ { - /* expand background and tRNS chunks */ + /* Expand background and tRNS chunks */ switch (png_ptr->bit_depth) { case 1: @@ -771,6 +801,7 @@ png_init_read_transformations(png_structp png_ptr) = png_ptr->trans_values.blue = png_ptr->trans_values.gray; } break; + case 2: png_ptr->background.gray *= (png_uint_16)0x55; png_ptr->background.red = png_ptr->background.green @@ -782,6 +813,7 @@ png_init_read_transformations(png_structp png_ptr) = png_ptr->trans_values.blue = png_ptr->trans_values.gray; } break; + case 4: png_ptr->background.gray *= (png_uint_16)0x11; png_ptr->background.red = png_ptr->background.green @@ -793,7 +825,9 @@ png_init_read_transformations(png_structp png_ptr) = png_ptr->trans_values.blue = png_ptr->trans_values.gray; } break; + case 8: + case 16: png_ptr->background.red = png_ptr->background.green = png_ptr->background.blue = png_ptr->background.gray; @@ -816,9 +850,10 @@ png_init_read_transformations(png_structp png_ptr) if (!(png_ptr->transformations & PNG_EXPAND_tRNS)) #endif { - /* invert the alpha channel (in tRNS) unless the pixels are - going to be expanded, in which case leave it for later */ - int i,istop; + /* Invert the alpha channel (in tRNS) unless the pixels are + * going to be expanded, in which case leave it for later + */ + int i, istop; istop=(int)png_ptr->num_trans; for (i=0; itrans[i] = (png_byte)(255 - png_ptr->trans[i]); @@ -839,12 +874,12 @@ png_init_read_transformations(png_structp png_ptr) && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0) < PNG_GAMMA_THRESHOLD)) { - int i,k; + int i, k; k=0; for (i=0; inum_trans; i++) { if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff) - k=1; /* partial transparency is present */ + k=1; /* Partial transparency is present */ } if (k == 0) png_ptr->transformations &= ~PNG_GAMMA; @@ -859,8 +894,7 @@ png_init_read_transformations(png_structp png_ptr) { if (color_type == PNG_COLOR_TYPE_PALETTE) { - /* could skip if no transparency and - */ + /* Could skip if no transparency */ png_color back, back_1; png_colorp palette = png_ptr->palette; int num_palette = png_ptr->num_palette; @@ -885,10 +919,12 @@ png_init_read_transformations(png_structp png_ptr) g = (png_ptr->screen_gamma); gs = 1.0; break; + case PNG_BACKGROUND_GAMMA_FILE: g = 1.0 / (png_ptr->gamma); gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); break; + case PNG_BACKGROUND_GAMMA_UNIQUE: g = 1.0 / (png_ptr->background_gamma); gs = 1.0 / (png_ptr->background_gamma * @@ -977,10 +1013,12 @@ png_init_read_transformations(png_structp png_ptr) g = (png_ptr->screen_gamma); gs = 1.0; break; + case PNG_BACKGROUND_GAMMA_FILE: g = 1.0 / (png_ptr->gamma); gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); break; + case PNG_BACKGROUND_GAMMA_UNIQUE: g = 1.0 / (png_ptr->background_gamma); gs = 1.0 / (png_ptr->background_gamma * @@ -1022,7 +1060,7 @@ png_init_read_transformations(png_structp png_ptr) } } else - /* transformation does not include PNG_BACKGROUND */ + /* Transformation does not include PNG_BACKGROUND */ #endif /* PNG_READ_BACKGROUND_SUPPORTED */ if (color_type == PNG_COLOR_TYPE_PALETTE) { @@ -1110,7 +1148,7 @@ png_init_read_transformations(png_structp png_ptr) } #if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \ && !defined(PNG_READ_BACKGROUND_SUPPORTED) - if(png_ptr) + if (png_ptr) return; #endif } @@ -1122,7 +1160,7 @@ png_init_read_transformations(png_structp png_ptr) void /* PRIVATE */ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_read_transform_info\n"); + png_debug(1, "in png_read_transform_info"); #if defined(PNG_READ_EXPAND_SUPPORTED) if (png_ptr->transformations & PNG_EXPAND) { @@ -1142,10 +1180,6 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) { if (png_ptr->transformations & PNG_EXPAND_tRNS) info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; -#if 0 /* Removed from libpng-1.2.27 */ - else - info_ptr->color_type |= PNG_COLOR_MASK_COLOR; -#endif } if (info_ptr->bit_depth < 8) info_ptr->bit_depth = 8; @@ -1194,8 +1228,8 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) if (png_ptr->transformations & PNG_DITHER) { if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) || - (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && - png_ptr->palette_lookup && info_ptr->bit_depth == 8) + (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) && + png_ptr->palette_lookup && info_ptr->bit_depth == 8) { info_ptr->color_type = PNG_COLOR_TYPE_PALETTE; } @@ -1229,7 +1263,7 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) (info_ptr->color_type == PNG_COLOR_TYPE_GRAY))) { info_ptr->channels++; - /* if adding a true alpha channel not just filler */ + /* If adding a true alpha channel not just filler */ #if !defined(PNG_1_0_X) if (png_ptr->transformations & PNG_ADD_ALPHA) info_ptr->color_type |= PNG_COLOR_MASK_ALPHA; @@ -1239,11 +1273,11 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr) #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \ defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) + if (png_ptr->transformations & PNG_USER_TRANSFORM) { - if(info_ptr->bit_depth < png_ptr->user_transform_depth) + if (info_ptr->bit_depth < png_ptr->user_transform_depth) info_ptr->bit_depth = png_ptr->user_transform_depth; - if(info_ptr->channels < png_ptr->user_transform_channels) + if (info_ptr->channels < png_ptr->user_transform_channels) info_ptr->channels = png_ptr->user_transform_channels; } #endif @@ -1251,10 +1285,10 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED) info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,info_ptr->width); + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width); #if !defined(PNG_READ_EXPAND_SUPPORTED) - if(png_ptr) + if (png_ptr) return; #endif } @@ -1266,14 +1300,14 @@ defined(PNG_READ_USER_TRANSFORM_SUPPORTED) void /* PRIVATE */ png_do_read_transformations(png_structp png_ptr) { - png_debug(1, "in png_do_read_transformations\n"); + png_debug(1, "in png_do_read_transformations"); if (png_ptr->row_buf == NULL) { #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) char msg[50]; png_snprintf2(msg, 50, - "NULL row buffer for row %ld, pass %d", png_ptr->row_number, + "NULL row buffer for row %ld, pass %d", (long)png_ptr->row_number, png_ptr->pass); png_error(png_ptr, msg); #else @@ -1284,7 +1318,8 @@ png_do_read_transformations(png_structp png_ptr) if (!(png_ptr->flags & PNG_FLAG_ROW_INIT)) /* Application has failed to call either png_read_start_image() * or png_read_update_info() after setting transforms that expand - * pixels. This check added to libpng-1.2.19 */ + * pixels. This check added to libpng-1.2.19 + */ #if (PNG_WARN_UNINITIALIZED_ROW==1) png_error(png_ptr, "Uninitialized row"); #else @@ -1324,52 +1359,54 @@ png_do_read_transformations(png_structp png_ptr) { int rgb_error = png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1); - if(rgb_error) + if (rgb_error) { png_ptr->rgb_to_gray_status=1; - if((png_ptr->transformations & PNG_RGB_TO_GRAY) == + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == PNG_RGB_TO_GRAY_WARN) png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel"); - if((png_ptr->transformations & PNG_RGB_TO_GRAY) == + if ((png_ptr->transformations & PNG_RGB_TO_GRAY) == PNG_RGB_TO_GRAY_ERR) png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel"); } } #endif -/* -From Andreas Dilger e-mail to png-implement, 26 March 1998: - - In most cases, the "simple transparency" should be done prior to doing - gray-to-RGB, or you will have to test 3x as many bytes to check if a - pixel is transparent. You would also need to make sure that the - transparency information is upgraded to RGB. - - To summarize, the current flow is: - - Gray + simple transparency -> compare 1 or 2 gray bytes and composite - with background "in place" if transparent, - convert to RGB if necessary - - Gray + alpha -> composite with gray background and remove alpha bytes, - convert to RGB if necessary - - To support RGB backgrounds for gray images we need: - - Gray + simple transparency -> convert to RGB + simple transparency, compare - 3 or 6 bytes and composite with background - "in place" if transparent (3x compare/pixel - compared to doing composite with gray bkgrnd) - - Gray + alpha -> convert to RGB + alpha, composite with background and - remove alpha bytes (3x float operations/pixel - compared with composite on gray background) - - Greg's change will do this. The reason it wasn't done before is for - performance, as this increases the per-pixel operations. If we would check - in advance if the background was gray or RGB, and position the gray-to-RGB - transform appropriately, then it would save a lot of work/time. +/* From Andreas Dilger e-mail to png-implement, 26 March 1998: + * + * In most cases, the "simple transparency" should be done prior to doing + * gray-to-RGB, or you will have to test 3x as many bytes to check if a + * pixel is transparent. You would also need to make sure that the + * transparency information is upgraded to RGB. + * + * To summarize, the current flow is: + * - Gray + simple transparency -> compare 1 or 2 gray bytes and composite + * with background "in place" if transparent, + * convert to RGB if necessary + * - Gray + alpha -> composite with gray background and remove alpha bytes, + * convert to RGB if necessary + * + * To support RGB backgrounds for gray images we need: + * - Gray + simple transparency -> convert to RGB + simple transparency, + * compare 3 or 6 bytes and composite with + * background "in place" if transparent + * (3x compare/pixel compared to doing + * composite with gray bkgrnd) + * - Gray + alpha -> convert to RGB + alpha, composite with background and + * remove alpha bytes (3x float + * operations/pixel compared with composite + * on gray background) + * + * Greg's change will do this. The reason it wasn't done before is for + * performance, as this increases the per-pixel operations. If we would check + * in advance if the background was gray or RGB, and position the gray-to-RGB + * transform appropriately, then it would save a lot of work/time. */ #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if background is non-gray; else do later - * for performance reasons */ + /* If gray -> RGB, do so now only if background is non-gray; else do later + * for performance reasons + */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); @@ -1394,14 +1431,14 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998: #if defined(PNG_READ_GAMMA_SUPPORTED) if ((png_ptr->transformations & PNG_GAMMA) && #if defined(PNG_READ_BACKGROUND_SUPPORTED) - !((png_ptr->transformations & PNG_BACKGROUND) && - ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && + !((png_ptr->transformations & PNG_BACKGROUND) && + ((png_ptr->num_trans != 0) || + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && #endif - (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) + (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)) png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1, - png_ptr->gamma_table, png_ptr->gamma_16_table, - png_ptr->gamma_shift); + png_ptr->gamma_table, png_ptr->gamma_16_table, + png_ptr->gamma_shift); #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) @@ -1414,7 +1451,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998: { png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->palette_lookup, png_ptr->dither_index); - if(png_ptr->row_info.rowbytes == (png_uint_32)0) + if (png_ptr->row_info.rowbytes == (png_uint_32)0) png_error(png_ptr, "png_do_dither returned rowbytes=0"); } #endif @@ -1446,7 +1483,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998: #endif #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) - /* if gray -> RGB, do so now only if we did not do so above */ + /* If gray -> RGB, do so now only if we did not do so above */ if ((png_ptr->transformations & PNG_GRAY_TO_RGB) && (png_ptr->mode & PNG_BACKGROUND_IS_GRAY)) png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1); @@ -1476,21 +1513,21 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998: #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) if (png_ptr->transformations & PNG_USER_TRANSFORM) { - if(png_ptr->read_user_transform_fn != NULL) - (*(png_ptr->read_user_transform_fn)) /* user read transform function */ - (png_ptr, /* png_ptr */ - &(png_ptr->row_info), /* row_info: */ - /* png_uint_32 width; width of row */ - /* png_uint_32 rowbytes; number of bytes in row */ - /* png_byte color_type; color type of pixels */ - /* png_byte bit_depth; bit depth of samples */ - /* png_byte channels; number of channels (1-4) */ - /* png_byte pixel_depth; bits per pixel (depth*channels) */ - png_ptr->row_buf + 1); /* start of pixel data for row */ + if (png_ptr->read_user_transform_fn != NULL) + (*(png_ptr->read_user_transform_fn)) /* User read transform function */ + (png_ptr, /* png_ptr */ + &(png_ptr->row_info), /* row_info: */ + /* png_uint_32 width; width of row */ + /* png_uint_32 rowbytes; number of bytes in row */ + /* png_byte color_type; color type of pixels */ + /* png_byte bit_depth; bit depth of samples */ + /* png_byte channels; number of channels (1-4) */ + /* png_byte pixel_depth; bits per pixel (depth*channels) */ + png_ptr->row_buf + 1); /* start of pixel data for row */ #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->user_transform_depth) + if (png_ptr->user_transform_depth) png_ptr->row_info.bit_depth = png_ptr->user_transform_depth; - if(png_ptr->user_transform_channels) + if (png_ptr->user_transform_channels) png_ptr->row_info.channels = png_ptr->user_transform_channels; #endif png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth * @@ -1512,7 +1549,7 @@ From Andreas Dilger e-mail to png-implement, 26 March 1998: void /* PRIVATE */ png_do_unpack(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_unpack\n"); + png_debug(1, "in png_do_unpack"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && row_info->bit_depth < 8) #else @@ -1544,6 +1581,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } break; } + case 2: { @@ -1565,6 +1603,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) } break; } + case 4: { png_bytep sp = row + (png_size_t)((row_width - 1) >> 1); @@ -1602,7 +1641,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row) void /* PRIVATE */ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) { - png_debug(1, "in png_do_unshift\n"); + png_debug(1, "in png_do_unshift"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && sig_bits != NULL && @@ -1656,6 +1695,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) } break; } + case 4: { png_bytep bp = row; @@ -1671,6 +1711,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) } break; } + case 8: { png_bytep bp = row; @@ -1683,6 +1724,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) } break; } + case 16: { png_bytep bp = row; @@ -1704,11 +1746,11 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits) #endif #if defined(PNG_READ_16_TO_8_SUPPORTED) -/* chop rows of bit depth 16 down to 8 */ +/* Chop rows of bit depth 16 down to 8 */ void /* PRIVATE */ png_do_chop(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_chop\n"); + png_debug(1, "in png_do_chop"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && row_info->bit_depth == 16) #else @@ -1728,14 +1770,17 @@ png_do_chop(png_row_infop row_info, png_bytep row) * * What the ideal calculation should be: * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) * 255 + 127) / (png_uint_32)65535L; + * (png_uint_32)(*(sp + 1))) * 255 + 127) + * / (png_uint_32)65535L; * * GRR: no, I think this is what it really should be: * *dp = (((((png_uint_32)(*sp) << 8) | - * (png_uint_32)(*(sp + 1))) + 128L) / (png_uint_32)257L; + * (png_uint_32)(*(sp + 1))) + 128L) + * / (png_uint_32)257L; * * GRR: here's the exact calculation with shifts: - * temp = (((png_uint_32)(*sp) << 8) | (png_uint_32)(*(sp + 1))) + 128L; + * temp = (((png_uint_32)(*sp) << 8) | + * (png_uint_32)(*(sp + 1))) + 128L; * *dp = (temp - (temp >> 8)) >> 8; * * Approximate calculation with shift/add instead of multiply/divide: @@ -1762,7 +1807,7 @@ png_do_chop(png_row_infop row_info, png_bytep row) void /* PRIVATE */ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_swap_alpha\n"); + png_debug(1, "in png_do_read_swap_alpha"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif @@ -1854,7 +1899,7 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) void /* PRIVATE */ png_do_read_invert_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_invert_alpha\n"); + png_debug(1, "in png_do_read_invert_alpha"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif @@ -1960,14 +2005,14 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, png_byte hi_filler = (png_byte)((filler>>8) & 0xff); png_byte lo_filler = (png_byte)(filler & 0xff); - png_debug(1, "in png_do_read_filler\n"); + png_debug(1, "in png_do_read_filler"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && #endif row_info->color_type == PNG_COLOR_TYPE_GRAY) { - if(row_info->bit_depth == 8) + if (row_info->bit_depth == 8) { /* This changes the data from G to GX */ if (flags & PNG_FLAG_FILLER_AFTER) @@ -1999,7 +2044,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->rowbytes = row_width * 2; } } - else if(row_info->bit_depth == 16) + else if (row_info->bit_depth == 16) { /* This changes the data from GG to GGXX */ if (flags & PNG_FLAG_FILLER_AFTER) @@ -2039,7 +2084,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, } /* COLOR_TYPE == GRAY */ else if (row_info->color_type == PNG_COLOR_TYPE_RGB) { - if(row_info->bit_depth == 8) + if (row_info->bit_depth == 8) { /* This changes the data from RGB to RGBX */ if (flags & PNG_FLAG_FILLER_AFTER) @@ -2075,7 +2120,7 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, row_info->rowbytes = row_width * 4; } } - else if(row_info->bit_depth == 16) + else if (row_info->bit_depth == 16) { /* This changes the data from RRGGBB to RRGGBBXX */ if (flags & PNG_FLAG_FILLER_AFTER) @@ -2125,14 +2170,14 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, #endif #if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED) -/* expand grayscale files to RGB, with or without alpha */ +/* Expand grayscale files to RGB, with or without alpha */ void /* PRIVATE */ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) { png_uint_32 i; png_uint_32 row_width = row_info->width; - png_debug(1, "in png_do_gray_to_rgb\n"); + png_debug(1, "in png_do_gray_to_rgb"); if (row_info->bit_depth >= 8 && #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -2202,16 +2247,18 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) row_info->color_type |= PNG_COLOR_MASK_COLOR; row_info->pixel_depth = (png_byte)(row_info->channels * row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } } #endif #if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) -/* reduce RGB files to grayscale, with or without alpha +/* Reduce RGB files to grayscale, with or without alpha * using the equation given in Poynton's ColorFAQ at - * - * Copyright (c) 1998-01-04 Charles Poynton poynton at inforamp.net + * (THIS LINK IS DEAD June 2008) + * New link: + * + * Charles Poynton poynton at poynton.com * * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B * @@ -2236,7 +2283,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) png_uint_32 row_width = row_info->width; int rgb_error = 0; - png_debug(1, "in png_do_rgb_to_gray\n"); + png_debug(1, "in png_do_rgb_to_gray"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -2262,14 +2309,14 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) png_byte red = png_ptr->gamma_to_1[*(sp++)]; png_byte green = png_ptr->gamma_to_1[*(sp++)]; png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) + if (red != green || red != blue) { rgb_error |= 1; *(dp++) = png_ptr->gamma_from_1[ - (rc*red+gc*green+bc*blue)>>15]; + (rc*red + gc*green + bc*blue)>>15]; } else - *(dp++) = *(sp-1); + *(dp++) = *(sp - 1); } } else @@ -2282,13 +2329,13 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) png_byte red = *(sp++); png_byte green = *(sp++); png_byte blue = *(sp++); - if(red != green || red != blue) + if (red != green || red != blue) { rgb_error |= 1; - *(dp++) = (png_byte)((rc*red+gc*green+bc*blue)>>15); + *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); } else - *(dp++) = *(sp-1); + *(dp++) = *(sp - 1); } } } @@ -2309,7 +2356,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - if(red == green && red == blue) + if (red == green && red == blue) w = red; else { @@ -2343,7 +2390,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - if(red != green || red != blue) + if (red != green || red != blue) rgb_error |= 1; gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); *(dp++) = (png_byte)((gray16>>8) & 0xff); @@ -2366,7 +2413,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) png_byte red = png_ptr->gamma_to_1[*(sp++)]; png_byte green = png_ptr->gamma_to_1[*(sp++)]; png_byte blue = png_ptr->gamma_to_1[*(sp++)]; - if(red != green || red != blue) + if (red != green || red != blue) rgb_error |= 1; *(dp++) = png_ptr->gamma_from_1 [(rc*red + gc*green + bc*blue)>>15]; @@ -2383,7 +2430,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) png_byte red = *(sp++); png_byte green = *(sp++); png_byte blue = *(sp++); - if(red != green || red != blue) + if (red != green || red != blue) rgb_error |= 1; *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15); *(dp++) = *(sp++); /* alpha */ @@ -2406,7 +2453,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2; - if(red == green && red == blue) + if (red == green && red == blue) w = red; else { @@ -2440,7 +2487,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2; - if(red != green || red != blue) + if (red != green || red != blue) rgb_error |= 1; gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15); *(dp++) = (png_byte)((gray16>>8) & 0xff); @@ -2455,7 +2502,7 @@ png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row) row_info->color_type &= ~PNG_COLOR_MASK_COLOR; row_info->pixel_depth = (png_byte)(row_info->channels * row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } return rgb_error; } @@ -2474,7 +2521,7 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette) int i; int v; - png_debug(1, "in png_do_build_grayscale_palette\n"); + png_debug(1, "in png_do_build_grayscale_palette"); if (palette == NULL) return; @@ -2484,18 +2531,22 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette) num_palette = 2; color_inc = 0xff; break; + case 2: num_palette = 4; color_inc = 0x55; break; + case 4: num_palette = 16; color_inc = 0x11; break; + case 8: num_palette = 256; color_inc = 1; break; + default: num_palette = 0; color_inc = 0; @@ -2516,7 +2567,7 @@ void /* PRIVATE */ png_correct_palette(png_structp png_ptr, png_colorp palette, int num_palette) { - png_debug(1, "in png_correct_palette\n"); + png_debug(1, "in png_correct_palette"); #if defined(PNG_READ_BACKGROUND_SUPPORTED) && \ defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED) if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND)) @@ -2673,7 +2724,7 @@ png_correct_palette(png_structp png_ptr, png_colorp palette, } } } - else /* assume grayscale palette (what else could it be?) */ + else /* Assume grayscale palette (what else could it be?) */ { int i; @@ -2713,7 +2764,7 @@ png_do_background(png_row_infop row_info, png_bytep row, png_uint_32 row_width=row_info->width; int shift; - png_debug(1, "in png_do_background\n"); + png_debug(1, "in png_do_background"); if (background != NULL && #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -2749,6 +2800,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } break; } + case 2: { #if defined(PNG_READ_GAMMA_SUPPORTED) @@ -2805,6 +2857,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } break; } + case 4: { #if defined(PNG_READ_GAMMA_SUPPORTED) @@ -2861,6 +2914,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } break; } + case 8: { #if defined(PNG_READ_GAMMA_SUPPORTED) @@ -2893,6 +2947,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } break; } + case 16: { #if defined(PNG_READ_GAMMA_SUPPORTED) @@ -2906,7 +2961,7 @@ png_do_background(png_row_infop row_info, png_bytep row, v = (png_uint_16)(((*sp) << 8) + *(sp + 1)); if (v == trans_values->gray) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *sp = (png_byte)((background->gray >> 8) & 0xff); *(sp + 1) = (png_byte)(background->gray & 0xff); } @@ -2939,6 +2994,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } break; } + case PNG_COLOR_TYPE_RGB: { if (row_info->bit_depth == 8) @@ -2996,7 +3052,7 @@ png_do_background(png_row_infop row_info, png_bytep row, if (r == trans_values->red && g == trans_values->green && b == trans_values->blue) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *sp = (png_byte)((background->red >> 8) & 0xff); *(sp + 1) = (png_byte)(background->red & 0xff); *(sp + 2) = (png_byte)((background->green >> 8) & 0xff); @@ -3043,6 +3099,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } break; } + case PNG_COLOR_TYPE_GRAY_ALPHA: { if (row_info->bit_depth == 8) @@ -3063,7 +3120,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } else if (a == 0) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *dp = (png_byte)background->gray; } else @@ -3130,7 +3187,7 @@ png_do_background(png_row_infop row_info, png_bytep row, else #endif { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *dp = (png_byte)((background->gray >> 8) & 0xff); *(dp + 1) = (png_byte)(background->gray & 0xff); } @@ -3185,6 +3242,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } break; } + case PNG_COLOR_TYPE_RGB_ALPHA: { if (row_info->bit_depth == 8) @@ -3207,7 +3265,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } else if (a == 0) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *dp = (png_byte)background->red; *(dp + 1) = (png_byte)background->green; *(dp + 2) = (png_byte)background->blue; @@ -3288,7 +3346,7 @@ png_do_background(png_row_infop row_info, png_bytep row, } else if (a == 0) { - /* background is already in screen gamma */ + /* Background is already in screen gamma */ *dp = (png_byte)((background->red >> 8) & 0xff); *(dp + 1) = (png_byte)(background->red & 0xff); *(dp + 2) = (png_byte)((background->green >> 8) & 0xff); @@ -3373,7 +3431,7 @@ png_do_background(png_row_infop row_info, png_bytep row, row_info->channels--; row_info->pixel_depth = (png_byte)(row_info->channels * row_info->bit_depth); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } } } @@ -3395,7 +3453,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row, png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_gamma\n"); + png_debug(1, "in png_do_gamma"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -3443,6 +3501,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row, } break; } + case PNG_COLOR_TYPE_RGB_ALPHA: { if (row_info->bit_depth == 8) @@ -3480,6 +3539,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row, } break; } + case PNG_COLOR_TYPE_GRAY_ALPHA: { if (row_info->bit_depth == 8) @@ -3504,6 +3564,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row, } break; } + case PNG_COLOR_TYPE_GRAY: { if (row_info->bit_depth == 2) @@ -3524,6 +3585,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row, sp++; } } + if (row_info->bit_depth == 4) { sp = row; @@ -3537,6 +3599,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row, sp++; } } + else if (row_info->bit_depth == 8) { sp = row; @@ -3546,6 +3609,7 @@ png_do_gamma(png_row_infop row_info, png_bytep row, sp++; } } + else if (row_info->bit_depth == 16) { sp = row; @@ -3577,7 +3641,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_expand_palette\n"); + png_debug(1, "in png_do_expand_palette"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -3611,6 +3675,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, } break; } + case 2: { sp = row + (png_size_t)((row_width - 1) >> 2); @@ -3632,6 +3697,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, } break; } + case 4: { sp = row + (png_size_t)((row_width - 1) >> 1); @@ -3696,6 +3762,7 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, *dp-- = palette[*sp].red; sp--; } + row_info->bit_depth = 8; row_info->pixel_depth = 24; row_info->rowbytes = row_width * 3; @@ -3720,7 +3787,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_expand\n"); + png_debug(1, "in png_do_expand"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif @@ -3757,6 +3824,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, } break; } + case 2: { gray = (png_uint_16)((gray&0x03)*0x55); @@ -3780,6 +3848,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, } break; } + case 4: { gray = (png_uint_16)((gray&0x0f)*0x11); @@ -3803,6 +3872,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, break; } } + row_info->bit_depth = 8; row_info->pixel_depth = 8; row_info->rowbytes = row_width; @@ -3824,6 +3894,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, *dp-- = *sp--; } } + else if (row_info->bit_depth == 16) { png_byte gray_high = (gray >> 8) & 0xff; @@ -3832,7 +3903,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, dp = row + (row_info->rowbytes << 1) - 1; for (i = 0; i < row_width; i++) { - if (*(sp-1) == gray_high && *(sp) == gray_low) + if (*(sp - 1) == gray_high && *(sp) == gray_low) { *dp-- = 0; *dp-- = 0; @@ -3846,6 +3917,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, *dp-- = *sp--; } } + row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA; row_info->channels = 2; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1); @@ -3911,7 +3983,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA; row_info->channels = 4; row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2); - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } } } @@ -3926,7 +3998,7 @@ png_do_dither(png_row_infop row_info, png_bytep row, png_uint_32 i; png_uint_32 row_width=row_info->width; - png_debug(1, "in png_do_dither\n"); + png_debug(1, "in png_do_dither"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif @@ -3943,13 +4015,13 @@ png_do_dither(png_row_infop row_info, png_bytep row, g = *sp++; b = *sp++; - /* this looks real messy, but the compiler will reduce - it down to a reasonable formula. For example, with - 5 bits per color, we get: - p = (((r >> 3) & 0x1f) << 10) | - (((g >> 3) & 0x1f) << 5) | - ((b >> 3) & 0x1f); - */ + /* This looks real messy, but the compiler will reduce + * it down to a reasonable formula. For example, with + * 5 bits per color, we get: + * p = (((r >> 3) & 0x1f) << 10) | + * (((g >> 3) & 0x1f) << 5) | + * ((b >> 3) & 0x1f); + */ p = (((r >> (8 - PNG_DITHER_RED_BITS)) & ((1 << PNG_DITHER_RED_BITS) - 1)) << (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) | @@ -3964,7 +4036,7 @@ png_do_dither(png_row_infop row_info, png_bytep row, row_info->color_type = PNG_COLOR_TYPE_PALETTE; row_info->channels = 1; row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && palette_lookup != NULL && row_info->bit_depth == 8) @@ -3993,7 +4065,7 @@ png_do_dither(png_row_infop row_info, png_bytep row, row_info->color_type = PNG_COLOR_TYPE_PALETTE; row_info->channels = 1; row_info->pixel_depth = row_info->bit_depth; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,row_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width); } else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE && dither_lookup && row_info->bit_depth == 8) @@ -4021,7 +4093,7 @@ static PNG_CONST int png_gamma_shift[] = void /* PRIVATE */ png_build_gamma_table(png_structp png_ptr) { - png_debug(1, "in png_build_gamma_table\n"); + png_debug(1, "in png_build_gamma_table"); if (png_ptr->bit_depth <= 8) { @@ -4030,6 +4102,7 @@ png_build_gamma_table(png_structp png_ptr) if (png_ptr->screen_gamma > .000001) g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma); + else g = 1.0; @@ -4062,10 +4135,11 @@ png_build_gamma_table(png_structp png_ptr) png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr, (png_uint_32)256); - if(png_ptr->screen_gamma > 0.000001) + if (png_ptr->screen_gamma > 0.000001) g = 1.0 / png_ptr->screen_gamma; + else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ + g = png_ptr->gamma; /* Probably doing rgb_to_gray */ for (i = 0; i < 256; i++) { @@ -4086,8 +4160,10 @@ png_build_gamma_table(png_structp png_ptr) if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) { sig_bit = (int)png_ptr->sig_bit.red; + if ((int)png_ptr->sig_bit.green > sig_bit) sig_bit = png_ptr->sig_bit.green; + if ((int)png_ptr->sig_bit.blue > sig_bit) sig_bit = png_ptr->sig_bit.blue; } @@ -4098,6 +4174,7 @@ png_build_gamma_table(png_structp png_ptr) if (sig_bit > 0) shift = 16 - sig_bit; + else shift = 0; @@ -4109,6 +4186,7 @@ png_build_gamma_table(png_structp png_ptr) if (shift > 8) shift = 8; + if (shift < 0) shift = 0; @@ -4122,7 +4200,8 @@ png_build_gamma_table(png_structp png_ptr) g = 1.0; png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); + (png_uint_32)(num * png_sizeof(png_uint_16p))); + png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p)); if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND)) { @@ -4132,7 +4211,7 @@ png_build_gamma_table(png_structp png_ptr) for (i = 0; i < num; i++) { png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); + (png_uint_32)(256 * png_sizeof(png_uint_16))); } g = 1.0 / g; @@ -4162,9 +4241,10 @@ png_build_gamma_table(png_structp png_ptr) for (i = 0; i < num; i++) { png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); + (png_uint_32)(256 * png_sizeof(png_uint_16))); ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) { png_ptr->gamma_16_table[i][j] = @@ -4182,12 +4262,13 @@ png_build_gamma_table(png_structp png_ptr) g = 1.0 / (png_ptr->gamma); png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p ))); + (png_uint_32)(num * png_sizeof(png_uint_16p ))); + png_memset(png_ptr->gamma_16_to_1, 0, num * png_sizeof(png_uint_16p)); for (i = 0; i < num; i++) { png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); + (png_uint_32)(256 * png_sizeof(png_uint_16))); ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); @@ -4199,21 +4280,25 @@ png_build_gamma_table(png_structp png_ptr) } } - if(png_ptr->screen_gamma > 0.000001) + if (png_ptr->screen_gamma > 0.000001) g = 1.0 / png_ptr->screen_gamma; + else - g = png_ptr->gamma; /* probably doing rgb_to_gray */ + g = png_ptr->gamma; /* Probably doing rgb_to_gray */ png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr, - (png_uint_32)(num * png_sizeof (png_uint_16p))); + (png_uint_32)(num * png_sizeof(png_uint_16p))); + png_memset(png_ptr->gamma_16_from_1, 0, + num * png_sizeof(png_uint_16p)); for (i = 0; i < num; i++) { png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr, - (png_uint_32)(256 * png_sizeof (png_uint_16))); + (png_uint_32)(256 * png_sizeof(png_uint_16))); ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4); + for (j = 0; j < 256; j++) { png_ptr->gamma_16_from_1[i][j] = @@ -4230,11 +4315,11 @@ png_build_gamma_table(png_structp png_ptr) #endif #if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ +/* Undoes intrapixel differencing */ void /* PRIVATE */ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_read_intrapixel\n"); + png_debug(1, "in png_do_read_intrapixel"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -4250,8 +4335,10 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 3; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 4; + else return; @@ -4268,18 +4355,20 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) if (row_info->color_type == PNG_COLOR_TYPE_RGB) bytes_per_pixel = 6; + else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA) bytes_per_pixel = 8; + else return; for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel) { - png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); - png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); - png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0+s1+65536L) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2+s1+65536L) & 0xffffL); + png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1); + png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3); + png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5); + png_uint_32 red = (png_uint_32)((s0 + s1 + 65536L) & 0xffffL); + png_uint_32 blue = (png_uint_32)((s2 + s1 + 65536L) & 0xffffL); *(rp ) = (png_byte)((red >> 8) & 0xff); *(rp+1) = (png_byte)(red & 0xff); *(rp+4) = (png_byte)((blue >> 8) & 0xff); diff --git a/src/3rdparty/libpng/pngrutil.c b/src/3rdparty/libpng/pngrutil.c index 531cb05..f656dfb 100644 --- a/src/3rdparty/libpng/pngrutil.c +++ b/src/3rdparty/libpng/pngrutil.c @@ -1,19 +1,21 @@ /* pngrutil.c - utilities to read a PNG file * - * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Last changed in libpng 1.2.38 [July 16, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file contains routines that are only called from within * libpng itself during the course of reading an image. */ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) #if defined(_WIN32_WCE) && (_WIN32_WCE<0x500) @@ -22,7 +24,7 @@ #ifdef PNG_FLOATING_POINT_SUPPORTED # if defined(WIN32_WCE_OLD) -/* strtod() function is not supported on WindowsCE */ +/* The strtod() function is not supported on WindowsCE */ __inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr) { double result = 0; @@ -30,7 +32,7 @@ __inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **end wchar_t *str, *end; len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0); - str = (wchar_t *)png_malloc(png_ptr, len * sizeof(wchar_t)); + str = (wchar_t *)png_malloc(png_ptr, len * png_sizeof(wchar_t)); if ( NULL != str ) { MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len); @@ -49,7 +51,15 @@ __inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **end png_uint_32 PNGAPI png_get_uint_31(png_structp png_ptr, png_bytep buf) { +#ifdef PNG_READ_BIG_ENDIAN_SUPPORTED png_uint_32 i = png_get_uint_32(buf); +#else + /* Avoid an extra function call by inlining the result. */ + png_uint_32 i = ((png_uint_32)(*buf) << 24) + + ((png_uint_32)(*(buf + 1)) << 16) + + ((png_uint_32)(*(buf + 2)) << 8) + + (png_uint_32)(*(buf + 3)); +#endif if (i > PNG_UINT_31_MAX) png_error(png_ptr, "PNG unsigned integer out of range."); return (i); @@ -69,7 +79,8 @@ png_get_uint_32(png_bytep buf) /* Grab a signed 32-bit integer from a buffer in big-endian format. The * data is stored in the PNG file in two's complement format, and it is - * assumed that the machine format for signed integers is the same. */ + * assumed that the machine format for signed integers is the same. + */ png_int_32 PNGAPI png_get_int_32(png_bytep buf) { @@ -92,19 +103,50 @@ png_get_uint_16(png_bytep buf) } #endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */ +/* Read the chunk header (length + type name). + * Put the type name into png_ptr->chunk_name, and return the length. + */ +png_uint_32 /* PRIVATE */ +png_read_chunk_header(png_structp png_ptr) +{ + png_byte buf[8]; + png_uint_32 length; + + /* Read the length and the chunk name */ + png_read_data(png_ptr, buf, 8); + length = png_get_uint_31(png_ptr, buf); + + /* Put the chunk name into png_ptr->chunk_name */ + png_memcpy(png_ptr->chunk_name, buf + 4, 4); + + png_debug2(0, "Reading %s chunk, length = %lu", + png_ptr->chunk_name, length); + + /* Reset the crc and run it over the chunk name */ + png_reset_crc(png_ptr); + png_calculate_crc(png_ptr, png_ptr->chunk_name, 4); + + /* Check to see if chunk name is valid */ + png_check_chunk_name(png_ptr, png_ptr->chunk_name); + + return length; +} + /* Read data, and (optionally) run it through the CRC. */ void /* PRIVATE */ png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_read_data(png_ptr, buf, length); png_calculate_crc(png_ptr, buf, length); } /* Optionally skip data and then check the CRC. Depending on whether we - are reading a ancillary or critical chunk, and how the program has set - things up, we may calculate the CRC on the data and print a message. - Returns '1' if there was a CRC error, '0' otherwise. */ + * are reading a ancillary or critical chunk, and how the program has set + * things up, we may calculate the CRC on the data and print a message. + * Returns '1' if there was a CRC error, '0' otherwise. + */ int /* PRIVATE */ png_crc_finish(png_structp png_ptr, png_uint_32 skip) { @@ -123,7 +165,7 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip) if (png_crc_error(png_ptr)) { if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */ - !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || + !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) || (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */ (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))) { @@ -140,7 +182,8 @@ png_crc_finish(png_structp png_ptr, png_uint_32 skip) } /* Compare the CRC stored in the PNG file with that calculated by libpng from - the data it has read thus far. */ + * the data it has read thus far. + */ int /* PRIVATE */ png_crc_error(png_structp png_ptr) { @@ -180,9 +223,9 @@ png_crc_error(png_structp png_ptr) * holding the original prefix part and an uncompressed version of the * trailing part (the malloc area passed in is freed). */ -png_charp /* PRIVATE */ +void /* PRIVATE */ png_decompress_chunk(png_structp png_ptr, int comp_type, - png_charp chunkdata, png_size_t chunklength, + png_size_t chunklength, png_size_t prefix_size, png_size_t *newlength) { static PNG_CONST char msg[] = "Error decoding compressed text"; @@ -192,7 +235,7 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, if (comp_type == PNG_COMPRESSION_TYPE_BASE) { int ret = Z_OK; - png_ptr->zstream.next_in = (png_bytep)(chunkdata + prefix_size); + png_ptr->zstream.next_in = (png_bytep)(png_ptr->chunkdata + prefix_size); png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size); png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; @@ -218,18 +261,20 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, text = (png_charp)png_malloc_warn(png_ptr, text_size); if (text == NULL) { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk"); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_error(png_ptr, "Not enough memory to decompress chunk"); } - png_memcpy(text, chunkdata, prefix_size); + png_memcpy(text, png_ptr->chunkdata, prefix_size); } text[text_size - 1] = 0x00; /* Copy what we can of the error message into the text chunk */ - text_size = (png_size_t)(chunklength - (text - chunkdata) - 1); - text_size = png_sizeof(msg) > text_size ? text_size : - png_sizeof(msg); + text_size = (png_size_t)(chunklength - + (text - png_ptr->chunkdata) - 1); + if (text_size > png_sizeof(msg)) + text_size = png_sizeof(msg); png_memcpy(text + prefix_size, msg, text_size); break; } @@ -241,13 +286,15 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, png_ptr->zbuf_size - png_ptr->zstream.avail_out; text = (png_charp)png_malloc_warn(png_ptr, text_size + 1); if (text == NULL) - { - png_free(png_ptr,chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk."); - } + { + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_error(png_ptr, + "Not enough memory to decompress chunk."); + } png_memcpy(text + prefix_size, png_ptr->zbuf, text_size - prefix_size); - png_memcpy(text, chunkdata, prefix_size); + png_memcpy(text, png_ptr->chunkdata, prefix_size); *(text + text_size) = 0x00; } else @@ -261,8 +308,10 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, if (text == NULL) { png_free(png_ptr, tmp); - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory to decompress chunk.."); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_error(png_ptr, + "Not enough memory to decompress chunk.."); } png_memcpy(text, tmp, text_size); png_free(png_ptr, tmp); @@ -289,29 +338,33 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, png_snprintf(umsg, 52, "Buffer error in compressed datastream in %s chunk", png_ptr->chunk_name); + else if (ret == Z_DATA_ERROR) png_snprintf(umsg, 52, "Data error in compressed datastream in %s chunk", png_ptr->chunk_name); + else png_snprintf(umsg, 52, "Incomplete compressed datastream in %s chunk", png_ptr->chunk_name); + png_warning(png_ptr, umsg); #else png_warning(png_ptr, "Incomplete compressed datastream in chunk other than IDAT"); #endif - text_size=prefix_size; + text_size = prefix_size; if (text == NULL) { text = (png_charp)png_malloc_warn(png_ptr, text_size+1); if (text == NULL) { - png_free(png_ptr, chunkdata); - png_error(png_ptr,"Not enough memory for text."); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + png_error(png_ptr, "Not enough memory for text."); } - png_memcpy(text, chunkdata, prefix_size); + png_memcpy(text, png_ptr->chunkdata, prefix_size); } *(text + text_size) = 0x00; } @@ -319,8 +372,8 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, inflateReset(&png_ptr->zstream); png_ptr->zstream.avail_in = 0; - png_free(png_ptr, chunkdata); - chunkdata = text; + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = text; *newlength=text_size; } else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */ @@ -328,22 +381,19 @@ png_decompress_chunk(png_structp png_ptr, int comp_type, #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) char umsg[50]; - png_snprintf(umsg, 50, - "Unknown zTXt compression type %d", comp_type); + png_snprintf(umsg, 50, "Unknown zTXt compression type %d", comp_type); png_warning(png_ptr, umsg); #else png_warning(png_ptr, "Unknown zTXt compression type"); #endif - *(chunkdata + prefix_size) = 0x00; - *newlength=prefix_size; + *(png_ptr->chunkdata + prefix_size) = 0x00; + *newlength = prefix_size; } - - return chunkdata; } #endif -/* read and check the IDHR chunk */ +/* Read and check the IDHR chunk */ void /* PRIVATE */ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -352,12 +402,12 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) int bit_depth, color_type, compression_type, filter_type; int interlace_type; - png_debug(1, "in png_handle_IHDR\n"); + png_debug(1, "in png_handle_IHDR"); if (png_ptr->mode & PNG_HAVE_IHDR) png_error(png_ptr, "Out of place IHDR"); - /* check the length */ + /* Check the length */ if (length != 13) png_error(png_ptr, "Invalid IHDR chunk"); @@ -374,7 +424,7 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) filter_type = buf[11]; interlace_type = buf[12]; - /* set internal variables */ + /* Set internal variables */ png_ptr->width = width; png_ptr->height = height; png_ptr->bit_depth = (png_byte)bit_depth; @@ -385,36 +435,39 @@ png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #endif png_ptr->compression_type = (png_byte)compression_type; - /* find number of channels */ + /* Find number of channels */ switch (png_ptr->color_type) { case PNG_COLOR_TYPE_GRAY: case PNG_COLOR_TYPE_PALETTE: png_ptr->channels = 1; break; + case PNG_COLOR_TYPE_RGB: png_ptr->channels = 3; break; + case PNG_COLOR_TYPE_GRAY_ALPHA: png_ptr->channels = 2; break; + case PNG_COLOR_TYPE_RGB_ALPHA: png_ptr->channels = 4; break; } - /* set up other useful info */ + /* Set up other useful info */ png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth * png_ptr->channels); - png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->width); - png_debug1(3,"bit_depth = %d\n", png_ptr->bit_depth); - png_debug1(3,"channels = %d\n", png_ptr->channels); - png_debug1(3,"rowbytes = %lu\n", png_ptr->rowbytes); + png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width); + png_debug1(3, "bit_depth = %d", png_ptr->bit_depth); + png_debug1(3, "channels = %d", png_ptr->channels); + png_debug1(3, "rowbytes = %lu", png_ptr->rowbytes); png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth, color_type, interlace_type, compression_type, filter_type); } -/* read and check the palette */ +/* Read and check the palette */ void /* PRIVATE */ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { @@ -424,16 +477,18 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_colorp pal_ptr; #endif - png_debug(1, "in png_handle_PLTE\n"); + png_debug(1, "in png_handle_PLTE"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before PLTE"); + else if (png_ptr->mode & PNG_HAVE_IDAT) { png_warning(png_ptr, "Invalid PLTE after IDAT"); png_crc_finish(png_ptr, length); return; } + else if (png_ptr->mode & PNG_HAVE_PLTE) png_error(png_ptr, "Duplicate PLTE chunk"); @@ -462,6 +517,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_crc_finish(png_ptr, length); return; } + else { png_error(png_ptr, "Invalid palette chunk"); @@ -486,7 +542,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_byte buf[3]; png_crc_read(png_ptr, buf, 3); - /* don't depend upon png_color being any order */ + /* Don't depend upon png_color being any order */ palette[i].red = buf[0]; palette[i].green = buf[1]; palette[i].blue = buf[2]; @@ -494,9 +550,10 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #endif /* If we actually NEED the PLTE chunk (ie for a paletted image), we do - whatever the normal CRC configuration tells us. However, if we - have an RGB image, the PLTE can be considered ancillary, so - we will act as though it is. */ + * whatever the normal CRC configuration tells us. However, if we + * have an RGB image, the PLTE can be considered ancillary, so + * we will act as though it is. + */ #if !defined(PNG_READ_OPT_PLTE_SUPPORTED) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) #endif @@ -556,7 +613,7 @@ png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) void /* PRIVATE */ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_debug(1, "in png_handle_IEND\n"); + png_debug(1, "in png_handle_IEND"); if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT)) { @@ -571,7 +628,7 @@ png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } png_crc_finish(png_ptr, length); - info_ptr =info_ptr; /* quiet compiler warnings about unused info_ptr */ + info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */ } #if defined(PNG_READ_gAMA_SUPPORTED) @@ -584,7 +641,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #endif png_byte buf[4]; - png_debug(1, "in png_handle_gAMA\n"); + png_debug(1, "in png_handle_gAMA"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before gAMA"); @@ -621,7 +678,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) return; igamma = (png_fixed_point)png_get_uint_32(buf); - /* check for zero gamma */ + /* Check for zero gamma */ if (igamma == 0) { png_warning(png_ptr, @@ -636,7 +693,7 @@ png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_warning(png_ptr, "Ignoring incorrect gAMA value when sRGB is also present"); #ifndef PNG_NO_CONSOLE_IO - fprintf(stderr, "gamma = (%d/100000)\n", (int)igamma); + fprintf(stderr, "gamma = (%d/100000)", (int)igamma); #endif return; } @@ -662,7 +719,7 @@ png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_size_t truelen; png_byte buf[4]; - png_debug(1, "in png_handle_sBIT\n"); + png_debug(1, "in png_handle_sBIT"); buf[0] = buf[1] = buf[2] = buf[3] = 0; @@ -725,7 +782,7 @@ png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) void /* PRIVATE */ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_byte buf[4]; + png_byte buf[32]; #ifdef PNG_FLOATING_POINT_SUPPORTED float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; #endif @@ -734,7 +791,7 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_uint_32 uint_x, uint_y; - png_debug(1, "in png_handle_cHRM\n"); + png_debug(1, "in png_handle_cHRM"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before cHRM"); @@ -766,64 +823,27 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) return; } - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x > 80000L || uint_y > 80000L || - uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM white point"); - png_crc_finish(png_ptr, 24); + png_crc_read(png_ptr, buf, 32); + if (png_crc_finish(png_ptr, 0)) return; - } - int_x_white = (png_fixed_point)uint_x; - int_y_white = (png_fixed_point)uint_y; - png_crc_read(png_ptr, buf, 4); uint_x = png_get_uint_32(buf); + uint_y = png_get_uint_32(buf + 4); + int_x_white = (png_fixed_point)uint_x; + int_y_white = (png_fixed_point)uint_y; - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM red point"); - png_crc_finish(png_ptr, 16); - return; - } + uint_x = png_get_uint_32(buf + 8); + uint_y = png_get_uint_32(buf + 12); int_x_red = (png_fixed_point)uint_x; int_y_red = (png_fixed_point)uint_y; - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM green point"); - png_crc_finish(png_ptr, 8); - return; - } + uint_x = png_get_uint_32(buf + 16); + uint_y = png_get_uint_32(buf + 20); int_x_green = (png_fixed_point)uint_x; int_y_green = (png_fixed_point)uint_y; - png_crc_read(png_ptr, buf, 4); - uint_x = png_get_uint_32(buf); - - png_crc_read(png_ptr, buf, 4); - uint_y = png_get_uint_32(buf); - - if (uint_x + uint_y > 100000L) - { - png_warning(png_ptr, "Invalid cHRM blue point"); - png_crc_finish(png_ptr, 0); - return; - } + uint_x = png_get_uint_32(buf + 24); + uint_y = png_get_uint_32(buf + 28); int_x_blue = (png_fixed_point)uint_x; int_y_blue = (png_fixed_point)uint_y; @@ -854,19 +874,18 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) "Ignoring incorrect cHRM value when sRGB is also present"); #ifndef PNG_NO_CONSOLE_IO #ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"wx=%f, wy=%f, rx=%f, ry=%f\n", + fprintf(stderr, "wx=%f, wy=%f, rx=%f, ry=%f\n", white_x, white_y, red_x, red_y); - fprintf(stderr,"gx=%f, gy=%f, bx=%f, by=%f\n", + fprintf(stderr, "gx=%f, gy=%f, bx=%f, by=%f\n", green_x, green_y, blue_x, blue_y); #else - fprintf(stderr,"wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", + fprintf(stderr, "wx=%ld, wy=%ld, rx=%ld, ry=%ld\n", int_x_white, int_y_white, int_x_red, int_y_red); - fprintf(stderr,"gx=%ld, gy=%ld, bx=%ld, by=%ld\n", + fprintf(stderr, "gx=%ld, gy=%ld, bx=%ld, by=%ld\n", int_x_green, int_y_green, int_x_blue, int_y_blue); #endif #endif /* PNG_NO_CONSOLE_IO */ } - png_crc_finish(png_ptr, 0); return; } #endif /* PNG_READ_sRGB_SUPPORTED */ @@ -880,8 +899,6 @@ png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) int_x_white, int_y_white, int_x_red, int_y_red, int_x_green, int_y_green, int_x_blue, int_y_blue); #endif - if (png_crc_finish(png_ptr, 0)) - return; } #endif @@ -892,7 +909,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) int intent; png_byte buf[1]; - png_debug(1, "in png_handle_sRGB\n"); + png_debug(1, "in png_handle_sRGB"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sRGB"); @@ -925,7 +942,7 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) return; intent = buf[0]; - /* check for bad intent */ + /* Check for bad intent */ if (intent >= PNG_sRGB_INTENT_LAST) { png_warning(png_ptr, "Unknown sRGB intent"); @@ -949,10 +966,11 @@ png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) "Ignoring incorrect gAMA value when sRGB is also present"); #ifndef PNG_NO_CONSOLE_IO # ifdef PNG_FIXED_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=(%d/100000)\n",(int)png_ptr->int_gamma); + fprintf(stderr, "incorrect gamma=(%d/100000)\n", + (int)png_ptr->int_gamma); # else # ifdef PNG_FLOATING_POINT_SUPPORTED - fprintf(stderr,"incorrect gamma=%f\n",png_ptr->gamma); + fprintf(stderr, "incorrect gamma=%f\n", png_ptr->gamma); # endif # endif #endif @@ -987,7 +1005,6 @@ void /* PRIVATE */ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { - png_charp chunkdata; png_byte compression_type; png_bytep pC; png_charp profile; @@ -995,7 +1012,7 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_uint_32 profile_size, profile_length; png_size_t slength, prefix_length, data_length; - png_debug(1, "in png_handle_iCCP\n"); + png_debug(1, "in png_handle_iCCP"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before iCCP"); @@ -1025,74 +1042,81 @@ png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif - chunkdata = (png_charp)png_malloc(png_ptr, length + 1); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1); slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, skip)) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - chunkdata[slength] = 0x00; + png_ptr->chunkdata[slength] = 0x00; - for (profile = chunkdata; *profile; profile++) - /* empty loop to find end of name */ ; + for (profile = png_ptr->chunkdata; *profile; profile++) + /* Empty loop to find end of name */ ; ++profile; - /* there should be at least one zero (the compression type byte) - following the separator, and we should be on it */ - if ( profile >= chunkdata + slength - 1) + /* There should be at least one zero (the compression type byte) + * following the separator, and we should be on it + */ + if ( profile >= png_ptr->chunkdata + slength - 1) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "Malformed iCCP chunk"); return; } - /* compression_type should always be zero */ + /* Compression_type should always be zero */ compression_type = *profile++; if (compression_type) { png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk"); - compression_type=0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 + compression_type = 0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8 wrote nonzero) */ } - prefix_length = profile - chunkdata; - chunkdata = png_decompress_chunk(png_ptr, compression_type, chunkdata, - slength, prefix_length, &data_length); + prefix_length = profile - png_ptr->chunkdata; + png_decompress_chunk(png_ptr, compression_type, + slength, prefix_length, &data_length); profile_length = data_length - prefix_length; if ( prefix_length > data_length || profile_length < 4) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "Profile size field missing from iCCP chunk"); return; } /* Check the profile_size recorded in the first 32 bits of the ICC profile */ - pC = (png_bytep)(chunkdata+prefix_length); - profile_size = ((*(pC ))<<24) | - ((*(pC+1))<<16) | - ((*(pC+2))<< 8) | - ((*(pC+3)) ); + pC = (png_bytep)(png_ptr->chunkdata + prefix_length); + profile_size = ((*(pC ))<<24) | + ((*(pC + 1))<<16) | + ((*(pC + 2))<< 8) | + ((*(pC + 3)) ); - if(profile_size < profile_length) + if (profile_size < profile_length) profile_length = profile_size; - if(profile_size > profile_length) + if (profile_size > profile_length) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "Ignoring truncated iCCP profile."); return; } - png_set_iCCP(png_ptr, info_ptr, chunkdata, compression_type, - chunkdata + prefix_length, profile_length); - png_free(png_ptr, chunkdata); + png_set_iCCP(png_ptr, info_ptr, png_ptr->chunkdata, + compression_type, png_ptr->chunkdata + prefix_length, profile_length); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; } #endif /* PNG_READ_iCCP_SUPPORTED */ @@ -1101,7 +1125,6 @@ void /* PRIVATE */ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) /* Note: this does not properly handle chunks that are > 64K under DOS */ { - png_bytep chunkdata; png_bytep entry_start; png_sPLT_t new_palette; #ifdef PNG_NO_POINTER_INDEXING @@ -1111,7 +1134,8 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_uint_32 skip = 0; png_size_t slength; - png_debug(1, "in png_handle_sPLT\n"); + png_debug(1, "in png_handle_sPLT"); + if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sPLT"); @@ -1131,45 +1155,49 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif - chunkdata = (png_bytep)png_malloc(png_ptr, length + 1); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1); slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, skip)) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - chunkdata[slength] = 0x00; + png_ptr->chunkdata[slength] = 0x00; - for (entry_start = chunkdata; *entry_start; entry_start++) - /* empty loop to find end of name */ ; + for (entry_start = (png_bytep)png_ptr->chunkdata; *entry_start; entry_start++) + /* Empty loop to find end of name */ ; ++entry_start; - /* a sample depth should follow the separator, and we should be on it */ - if (entry_start > chunkdata + slength - 2) + /* A sample depth should follow the separator, and we should be on it */ + if (entry_start > (png_bytep)png_ptr->chunkdata + slength - 2) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "malformed sPLT chunk"); return; } new_palette.depth = *entry_start++; entry_size = (new_palette.depth == 8 ? 6 : 10); - data_length = (slength - (entry_start - chunkdata)); + data_length = (slength - (entry_start - (png_bytep)png_ptr->chunkdata)); - /* integrity-check the data length */ + /* Integrity-check the data length */ if (data_length % entry_size) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "sPLT chunk has bad length"); return; } new_palette.nentries = (png_int_32) ( data_length / entry_size); - if ((png_uint_32) new_palette.nentries > (png_uint_32) (PNG_SIZE_MAX / - png_sizeof(png_sPLT_entry))) + if ((png_uint_32) new_palette.nentries > + (png_uint_32) (PNG_SIZE_MAX / png_sizeof(png_sPLT_entry))) { png_warning(png_ptr, "sPLT chunk too long"); return; @@ -1226,12 +1254,13 @@ png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif - /* discard all chunk data except the name and stash that */ - new_palette.name = (png_charp)chunkdata; + /* Discard all chunk data except the name and stash that */ + new_palette.name = png_ptr->chunkdata; png_set_sPLT(png_ptr, info_ptr, &new_palette, 1); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_free(png_ptr, new_palette.entries); } #endif /* PNG_READ_sPLT_SUPPORTED */ @@ -1242,7 +1271,7 @@ png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_byte readbuf[PNG_MAX_PALETTE_LENGTH]; - png_debug(1, "in png_handle_tRNS\n"); + png_debug(1, "in png_handle_tRNS"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before tRNS"); @@ -1338,7 +1367,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_size_t truelen; png_byte buf[6]; - png_debug(1, "in png_handle_bKGD\n"); + png_debug(1, "in png_handle_bKGD"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before bKGD"); @@ -1389,7 +1418,7 @@ png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_ptr->background.index = buf[0]; if (info_ptr && info_ptr->num_palette) { - if(buf[0] > info_ptr->num_palette) + if (buf[0] >= info_ptr->num_palette) { png_warning(png_ptr, "Incorrect bKGD chunk index value"); return; @@ -1427,7 +1456,7 @@ png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) unsigned int num, i; png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH]; - png_debug(1, "in png_handle_hIST\n"); + png_debug(1, "in png_handle_hIST"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before hIST"); @@ -1482,7 +1511,7 @@ png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_uint_32 res_x, res_y; int unit_type; - png_debug(1, "in png_handle_pHYs\n"); + png_debug(1, "in png_handle_pHYs"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before pHYs"); @@ -1525,7 +1554,7 @@ png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_int_32 offset_x, offset_y; int unit_type; - png_debug(1, "in png_handle_oFFs\n"); + png_debug(1, "in png_handle_oFFs"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before oFFs"); @@ -1561,11 +1590,10 @@ png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #endif #if defined(PNG_READ_pCAL_SUPPORTED) -/* read the pCAL chunk (described in the PNG Extensions document) */ +/* Read the pCAL chunk (described in the PNG Extensions document) */ void /* PRIVATE */ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_charp purpose; png_int_32 X0, X1; png_byte type, nparams; png_charp buf, units, endptr; @@ -1573,7 +1601,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_size_t slength; int i; - png_debug(1, "in png_handle_pCAL\n"); + png_debug(1, "in png_handle_pCAL"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before pCAL"); @@ -1590,48 +1618,51 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) return; } - png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n", + png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)", length + 1); - purpose = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (purpose == NULL) + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) { png_warning(png_ptr, "No memory for pCAL purpose."); return; } slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)purpose, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - purpose[slength] = 0x00; /* null terminate the last string */ + png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */ - png_debug(3, "Finding end of pCAL purpose string\n"); - for (buf = purpose; *buf; buf++) - /* empty loop */ ; + png_debug(3, "Finding end of pCAL purpose string"); + for (buf = png_ptr->chunkdata; *buf; buf++) + /* Empty loop */ ; - endptr = purpose + slength; + endptr = png_ptr->chunkdata + slength; /* We need to have at least 12 bytes after the purpose string in order to get the parameter information. */ if (endptr <= buf + 12) { png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - png_debug(3, "Reading pCAL X0, X1, type, nparams, and units\n"); + png_debug(3, "Reading pCAL X0, X1, type, nparams, and units"); X0 = png_get_int_32((png_bytep)buf+1); X1 = png_get_int_32((png_bytep)buf+5); type = buf[9]; nparams = buf[10]; units = buf + 11; - png_debug(3, "Checking pCAL equation type and number of parameters\n"); + png_debug(3, "Checking pCAL equation type and number of parameters"); /* Check that we have the right number of parameters for known equation types. */ if ((type == PNG_EQUATION_LINEAR && nparams != 2) || @@ -1640,7 +1671,8 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) (type == PNG_EQUATION_HYPERBOLIC && nparams != 4)) { png_warning(png_ptr, "Invalid pCAL parameters for equation type"); - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } else if (type >= PNG_EQUATION_LAST) @@ -1651,12 +1683,13 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) for (buf = units; *buf; buf++) /* Empty loop to move past the units string. */ ; - png_debug(3, "Allocating pCAL parameters array\n"); - params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_charp))) ; + png_debug(3, "Allocating pCAL parameters array"); + params = (png_charpp)png_malloc_warn(png_ptr, + (png_uint_32)(nparams * png_sizeof(png_charp))) ; if (params == NULL) { - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_warning(png_ptr, "No memory for pCAL params."); return; } @@ -1666,7 +1699,7 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { buf++; /* Skip the null string terminator from previous parameter. */ - png_debug1(3, "Reading pCAL parameter %d\n", i); + png_debug1(3, "Reading pCAL parameter %d", i); for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++) /* Empty loop to move past each parameter string */ ; @@ -1674,26 +1707,28 @@ png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if (buf > endptr) { png_warning(png_ptr, "Invalid pCAL data"); - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_free(png_ptr, params); return; } } - png_set_pCAL(png_ptr, info_ptr, purpose, X0, X1, type, nparams, + png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams, units, params); - png_free(png_ptr, purpose); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_free(png_ptr, params); } #endif #if defined(PNG_READ_sCAL_SUPPORTED) -/* read the sCAL chunk */ +/* Read the sCAL chunk */ void /* PRIVATE */ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { - png_charp buffer, ep; + png_charp ep; #ifdef PNG_FLOATING_POINT_SUPPORTED double width, height; png_charp vp; @@ -1704,7 +1739,7 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #endif png_size_t slength; - png_debug(1, "in png_handle_sCAL\n"); + png_debug(1, "in png_handle_sCAL"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before sCAL"); @@ -1721,88 +1756,91 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) return; } - png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n", + png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)", length + 1); - buffer = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (buffer == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk"); - return; - } + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk"); + return; + } slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)buffer, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { - png_free(png_ptr, buffer); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - buffer[slength] = 0x00; /* null terminate the last string */ + png_ptr->chunkdata[slength] = 0x00; /* Null terminate the last string */ - ep = buffer + 1; /* skip unit byte */ + ep = png_ptr->chunkdata + 1; /* Skip unit byte */ #ifdef PNG_FLOATING_POINT_SUPPORTED width = png_strtod(png_ptr, ep, &vp); if (*vp) { - png_warning(png_ptr, "malformed width string in sCAL chunk"); - return; + png_warning(png_ptr, "malformed width string in sCAL chunk"); + return; } #else #ifdef PNG_FIXED_POINT_SUPPORTED swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); if (swidth == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); - return; - } + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk width"); + return; + } png_memcpy(swidth, ep, (png_size_t)png_strlen(ep)); #endif #endif - for (ep = buffer; *ep; ep++) - /* empty loop */ ; + for (ep = png_ptr->chunkdata; *ep; ep++) + /* Empty loop */ ; ep++; - if (buffer + slength < ep) + if (png_ptr->chunkdata + slength < ep) { - png_warning(png_ptr, "Truncated sCAL chunk"); + png_warning(png_ptr, "Truncated sCAL chunk"); #if defined(PNG_FIXED_POINT_SUPPORTED) && \ !defined(PNG_FLOATING_POINT_SUPPORTED) - png_free(png_ptr, swidth); + png_free(png_ptr, swidth); #endif - png_free(png_ptr, buffer); - return; + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; + return; } #ifdef PNG_FLOATING_POINT_SUPPORTED height = png_strtod(png_ptr, ep, &vp); if (*vp) { - png_warning(png_ptr, "malformed height string in sCAL chunk"); - return; + png_warning(png_ptr, "malformed height string in sCAL chunk"); + return; } #else #ifdef PNG_FIXED_POINT_SUPPORTED sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1); if (sheight == NULL) - { - png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); - return; - } + { + png_warning(png_ptr, "Out of memory while processing sCAL chunk height"); + return; + } png_memcpy(sheight, ep, (png_size_t)png_strlen(ep)); #endif #endif - if (buffer + slength < ep + if (png_ptr->chunkdata + slength < ep #ifdef PNG_FLOATING_POINT_SUPPORTED || width <= 0. || height <= 0. #endif ) { png_warning(png_ptr, "Invalid sCAL data"); - png_free(png_ptr, buffer); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) png_free(png_ptr, swidth); png_free(png_ptr, sheight); @@ -1812,14 +1850,15 @@ png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #ifdef PNG_FLOATING_POINT_SUPPORTED - png_set_sCAL(png_ptr, info_ptr, buffer[0], width, height); + png_set_sCAL(png_ptr, info_ptr, png_ptr->chunkdata[0], width, height); #else #ifdef PNG_FIXED_POINT_SUPPORTED - png_set_sCAL_s(png_ptr, info_ptr, buffer[0], swidth, sheight); + png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0], swidth, sheight); #endif #endif - png_free(png_ptr, buffer); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; #if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED) png_free(png_ptr, swidth); png_free(png_ptr, sheight); @@ -1834,7 +1873,7 @@ png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_byte buf[7]; png_time mod_time; - png_debug(1, "in png_handle_tIME\n"); + png_debug(1, "in png_handle_tIME"); if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Out of place tIME chunk"); @@ -1882,7 +1921,8 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_size_t slength; int ret; - png_debug(1, "in png_handle_tEXt\n"); + png_debug(1, "in png_handle_tEXt"); + if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before tEXt"); @@ -1899,25 +1939,30 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif - key = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (key == NULL) + png_free(png_ptr, png_ptr->chunkdata); + + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) { png_warning(png_ptr, "No memory to process text chunk."); return; } slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)key, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, skip)) { - png_free(png_ptr, key); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } + key = png_ptr->chunkdata; + key[slength] = 0x00; for (text = key; *text; text++) - /* empty loop to find end of key */ ; + /* Empty loop to find end of key */ ; if (text != key + slength) text++; @@ -1927,7 +1972,8 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if (text_ptr == NULL) { png_warning(png_ptr, "Not enough memory to process text chunk."); - png_free(png_ptr, key); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } text_ptr->compression = PNG_TEXT_COMPRESSION_NONE; @@ -1940,9 +1986,10 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) text_ptr->text = text; text_ptr->text_length = png_strlen(text); - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); - png_free(png_ptr, key); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; png_free(png_ptr, text_ptr); if (ret) png_warning(png_ptr, "Insufficient memory to process text chunk."); @@ -1950,18 +1997,19 @@ png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) #endif #if defined(PNG_READ_zTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ +/* Note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_textp text_ptr; - png_charp chunkdata; png_charp text; int comp_type; int ret; png_size_t slength, prefix_len, data_len; - png_debug(1, "in png_handle_zTXt\n"); + png_debug(1, "in png_handle_zTXt"); + + if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before zTXt"); @@ -1973,36 +2021,39 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) there is no hard and fast rule to tell us where to stop. */ if (length > (png_uint_32)65535L) { - png_warning(png_ptr,"zTXt chunk too large to fit in memory"); + png_warning(png_ptr, "zTXt chunk too large to fit in memory"); png_crc_finish(png_ptr, length); return; } #endif - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) { - png_warning(png_ptr,"Out of memory processing zTXt chunk."); + png_warning(png_ptr, "Out of memory processing zTXt chunk."); return; } slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - chunkdata[slength] = 0x00; + png_ptr->chunkdata[slength] = 0x00; - for (text = chunkdata; *text; text++) - /* empty loop */ ; + for (text = png_ptr->chunkdata; *text; text++) + /* Empty loop */ ; /* zTXt must have some text after the chunkdataword */ - if (text >= chunkdata + slength - 2) + if (text >= png_ptr->chunkdata + slength - 2) { png_warning(png_ptr, "Truncated zTXt chunk"); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } else @@ -2013,54 +2064,56 @@ png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_warning(png_ptr, "Unknown compression type in zTXt chunk"); comp_type = PNG_TEXT_COMPRESSION_zTXt; } - text++; /* skip the compression_method byte */ + text++; /* Skip the compression_method byte */ } - prefix_len = text - chunkdata; + prefix_len = text - png_ptr->chunkdata; - chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata, - (png_size_t)length, prefix_len, &data_len); + png_decompress_chunk(png_ptr, comp_type, + (png_size_t)length, prefix_len, &data_len); text_ptr = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)png_sizeof(png_text)); + (png_uint_32)png_sizeof(png_text)); if (text_ptr == NULL) { - png_warning(png_ptr,"Not enough memory to process zTXt chunk."); - png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Not enough memory to process zTXt chunk."); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } text_ptr->compression = comp_type; - text_ptr->key = chunkdata; + text_ptr->key = png_ptr->chunkdata; #ifdef PNG_iTXt_SUPPORTED text_ptr->lang = NULL; text_ptr->lang_key = NULL; text_ptr->itxt_length = 0; #endif - text_ptr->text = chunkdata + prefix_len; + text_ptr->text = png_ptr->chunkdata + prefix_len; text_ptr->text_length = data_len; - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; if (ret) png_error(png_ptr, "Insufficient memory to store zTXt chunk."); } #endif #if defined(PNG_READ_iTXt_SUPPORTED) -/* note: this does not correctly handle chunks that are > 64K under DOS */ +/* Note: this does not correctly handle chunks that are > 64K under DOS */ void /* PRIVATE */ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_textp text_ptr; - png_charp chunkdata; png_charp key, lang, text, lang_key; int comp_flag; int comp_type = 0; int ret; png_size_t slength, prefix_len, data_len; - png_debug(1, "in png_handle_iTXt\n"); + png_debug(1, "in png_handle_iTXt"); + if (!(png_ptr->mode & PNG_HAVE_IHDR)) png_error(png_ptr, "Missing IHDR before iTXt"); @@ -2073,40 +2126,44 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) there is no hard and fast rule to tell us where to stop. */ if (length > (png_uint_32)65535L) { - png_warning(png_ptr,"iTXt chunk too large to fit in memory"); + png_warning(png_ptr, "iTXt chunk too large to fit in memory"); png_crc_finish(png_ptr, length); return; } #endif - chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); - if (chunkdata == NULL) + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1); + if (png_ptr->chunkdata == NULL) { png_warning(png_ptr, "No memory to process iTXt chunk."); return; } slength = (png_size_t)length; - png_crc_read(png_ptr, (png_bytep)chunkdata, slength); + png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength); if (png_crc_finish(png_ptr, 0)) { - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - chunkdata[slength] = 0x00; + png_ptr->chunkdata[slength] = 0x00; - for (lang = chunkdata; *lang; lang++) - /* empty loop */ ; - lang++; /* skip NUL separator */ + for (lang = png_ptr->chunkdata; *lang; lang++) + /* Empty loop */ ; + lang++; /* Skip NUL separator */ /* iTXt must have a language tag (possibly empty), two compression bytes, - translated keyword (possibly empty), and possibly some text after the - keyword */ + * translated keyword (possibly empty), and possibly some text after the + * keyword + */ - if (lang >= chunkdata + slength - 3) + if (lang >= png_ptr->chunkdata + slength - 3) { png_warning(png_ptr, "Truncated iTXt chunk"); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } else @@ -2116,54 +2173,58 @@ png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } for (lang_key = lang; *lang_key; lang_key++) - /* empty loop */ ; - lang_key++; /* skip NUL separator */ + /* Empty loop */ ; + lang_key++; /* Skip NUL separator */ - if (lang_key >= chunkdata + slength) + if (lang_key >= png_ptr->chunkdata + slength) { png_warning(png_ptr, "Truncated iTXt chunk"); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } for (text = lang_key; *text; text++) - /* empty loop */ ; - text++; /* skip NUL separator */ - if (text >= chunkdata + slength) + /* Empty loop */ ; + text++; /* Skip NUL separator */ + if (text >= png_ptr->chunkdata + slength) { png_warning(png_ptr, "Malformed iTXt chunk"); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } - prefix_len = text - chunkdata; + prefix_len = text - png_ptr->chunkdata; - key=chunkdata; + key=png_ptr->chunkdata; if (comp_flag) - chunkdata = png_decompress_chunk(png_ptr, comp_type, chunkdata, - (size_t)length, prefix_len, &data_len); + png_decompress_chunk(png_ptr, comp_type, + (size_t)length, prefix_len, &data_len); else - data_len=png_strlen(chunkdata + prefix_len); + data_len = png_strlen(png_ptr->chunkdata + prefix_len); text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)png_sizeof(png_text)); if (text_ptr == NULL) { - png_warning(png_ptr,"Not enough memory to process iTXt chunk."); - png_free(png_ptr, chunkdata); + png_warning(png_ptr, "Not enough memory to process iTXt chunk."); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; return; } text_ptr->compression = (int)comp_flag + 1; - text_ptr->lang_key = chunkdata+(lang_key-key); - text_ptr->lang = chunkdata+(lang-key); + text_ptr->lang_key = png_ptr->chunkdata + (lang_key - key); + text_ptr->lang = png_ptr->chunkdata + (lang - key); text_ptr->itxt_length = data_len; text_ptr->text_length = 0; - text_ptr->key = chunkdata; - text_ptr->text = chunkdata + prefix_len; + text_ptr->key = png_ptr->chunkdata; + text_ptr->text = png_ptr->chunkdata + prefix_len; - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1); + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1); png_free(png_ptr, text_ptr); - png_free(png_ptr, chunkdata); + png_free(png_ptr, png_ptr->chunkdata); + png_ptr->chunkdata = NULL; if (ret) png_error(png_ptr, "Insufficient memory to store iTXt chunk."); } @@ -2179,23 +2240,22 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) { png_uint_32 skip = 0; - png_debug(1, "in png_handle_unknown\n"); + png_debug(1, "in png_handle_unknown"); + if (png_ptr->mode & PNG_HAVE_IDAT) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_CONST PNG_IDAT; #endif - if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */ + if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* Not an IDAT */ png_ptr->mode |= PNG_AFTER_IDAT; } - png_check_chunk_name(png_ptr, png_ptr->chunk_name); - if (!(png_ptr->chunk_name[0] & 0x20)) { -#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != +#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) + if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) && png_ptr->read_user_chunk_fn == NULL @@ -2206,8 +2266,11 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) - if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) || - (png_ptr->read_user_chunk_fn != NULL)) + if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) +#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) + || (png_ptr->read_user_chunk_fn != NULL) +#endif + ) { #ifdef PNG_MAX_MALLOC_64K if (length > (png_uint_32)65535L) @@ -2218,7 +2281,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) } #endif png_memcpy((png_charp)png_ptr->unknown_chunk.name, - (png_charp)png_ptr->chunk_name, + (png_charp)png_ptr->chunk_name, png_sizeof(png_ptr->unknown_chunk.name)); png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1] = '\0'; png_ptr->unknown_chunk.size = (png_size_t)length; @@ -2230,9 +2293,9 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length); } #if defined(PNG_READ_USER_CHUNKS_SUPPORTED) - if(png_ptr->read_user_chunk_fn != NULL) + if (png_ptr->read_user_chunk_fn != NULL) { - /* callback to user unknown chunk handler */ + /* Callback to user unknown chunk handler */ int ret; ret = (*(png_ptr->read_user_chunk_fn)) (png_ptr, &png_ptr->unknown_chunk); @@ -2241,8 +2304,10 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) if (ret == 0) { if (!(png_ptr->chunk_name[0] & 0x20)) - if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != +#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) + if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) != PNG_HANDLE_CHUNK_ALWAYS) +#endif png_chunk_error(png_ptr, "unknown critical chunk"); png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1); @@ -2261,7 +2326,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) png_crc_finish(png_ptr, skip); #if !defined(PNG_READ_USER_CHUNKS_SUPPORTED) - info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */ + info_ptr = info_ptr; /* Quiet compiler warnings about unused info_ptr */ #endif } @@ -2276,7 +2341,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length) void /* PRIVATE */ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) { - png_debug(1, "in png_check_chunk_name\n"); + png_debug(1, "in png_check_chunk_name"); if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) || isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3])) { @@ -2298,7 +2363,7 @@ png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name) void /* PRIVATE */ png_combine_row(png_structp png_ptr, png_bytep row, int mask) { - png_debug(1,"in png_combine_row\n"); + png_debug(1, "in png_combine_row"); if (mask == 0xff) { png_memcpy(row, png_ptr->row_buf + 1, @@ -2509,12 +2574,12 @@ png_do_read_interlace(png_structp png_ptr) int pass = png_ptr->pass; png_uint_32 transformations = png_ptr->transformations; #ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* offset to next interlace block */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Offset to next interlace block */ PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; #endif - png_debug(1,"in png_do_read_interlace\n"); + png_debug(1, "in png_do_read_interlace"); if (row != NULL && row_info != NULL) { png_uint_32 final_width; @@ -2715,10 +2780,10 @@ png_do_read_interlace(png_structp png_ptr) } } row_info->width = final_width; - row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,final_width); + row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width); } #if !defined(PNG_READ_PACKSWAP_SUPPORTED) - transformations = transformations; /* silence compiler warning */ + transformations = transformations; /* Silence compiler warning */ #endif } #endif /* PNG_READ_INTERLACING_SUPPORTED */ @@ -2727,8 +2792,8 @@ void /* PRIVATE */ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter) { - png_debug(1, "in png_read_filter_row\n"); - png_debug2(2,"row = %lu, filter = %d\n", png_ptr->row_number, filter); + png_debug(1, "in png_read_filter_row"); + png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter); switch (filter) { case PNG_FILTER_VALUE_NONE: @@ -2802,7 +2867,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, rp++; } - for (i = 0; i < istop; i++) /* use leftover rp,pp */ + for (i = 0; i < istop; i++) /* Use leftover rp,pp */ { int a, b, c, pa, pb, pc, p; @@ -2832,7 +2897,7 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, p = c; */ - p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c; + p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c; *rp = (png_byte)(((int)(*rp) + p) & 0xff); rp++; @@ -2841,33 +2906,34 @@ png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row, } default: png_warning(png_ptr, "Ignoring bad adaptive filter type"); - *row=0; + *row = 0; break; } } +#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED void /* PRIVATE */ png_read_finish_row(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_READ_INTERLACING_SUPPORTED - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ + /* Start of interlace block in the y direction */ PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ + /* Offset to next interlace block in the y direction */ PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif /* PNG_READ_INTERLACING_SUPPORTED */ #endif - png_debug(1, "in png_read_finish_row\n"); + png_debug(1, "in png_read_finish_row"); png_ptr->row_number++; if (png_ptr->row_number < png_ptr->num_rows) return; @@ -2919,7 +2985,7 @@ png_read_finish_row(png_structp png_ptr) png_ptr->zstream.next_out = (Byte *)&extra; png_ptr->zstream.avail_out = (uInt)1; - for(;;) + for (;;) { if (!(png_ptr->zstream.avail_in)) { @@ -2977,32 +3043,33 @@ png_read_finish_row(png_structp png_ptr) png_ptr->mode |= PNG_AFTER_IDAT; } +#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */ void /* PRIVATE */ png_read_start_row(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS #ifdef PNG_READ_INTERLACING_SUPPORTED - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ + /* Start of interlace block in the y direction */ PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ + /* Offset to next interlace block in the y direction */ PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif #endif int max_pixel_depth; - png_uint_32 row_bytes; + png_size_t row_bytes; - png_debug(1, "in png_read_start_row\n"); + png_debug(1, "in png_read_start_row"); png_ptr->zstream.avail_in = 0; png_init_read_transformations(png_ptr); #ifdef PNG_READ_INTERLACING_SUPPORTED @@ -3019,11 +3086,8 @@ png_read_start_row(png_structp png_ptr) png_pass_start[png_ptr->pass]) / png_pass_inc[png_ptr->pass]; - row_bytes = PNG_ROWBYTES(png_ptr->pixel_depth,png_ptr->iwidth) + 1; - - png_ptr->irowbytes = (png_size_t)row_bytes; - if((png_uint_32)png_ptr->irowbytes != row_bytes) - png_error(png_ptr, "Rowbytes overflow in png_read_start_row"); + png_ptr->irowbytes = + PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1; } else #endif /* PNG_READ_INTERLACING_SUPPORTED */ @@ -3125,58 +3189,63 @@ png_read_start_row(png_structp png_ptr) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if(png_ptr->transformations & PNG_USER_TRANSFORM) + if (png_ptr->transformations & PNG_USER_TRANSFORM) { - int user_pixel_depth=png_ptr->user_transform_depth* + int user_pixel_depth = png_ptr->user_transform_depth* png_ptr->user_transform_channels; - if(user_pixel_depth > max_pixel_depth) + if (user_pixel_depth > max_pixel_depth) max_pixel_depth=user_pixel_depth; } #endif - /* align the width on the next larger 8 pixels. Mainly used - for interlacing */ + /* Align the width on the next larger 8 pixels. Mainly used + * for interlacing + */ row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7)); - /* calculate the maximum bytes needed, adding a byte and a pixel - for safety's sake */ - row_bytes = PNG_ROWBYTES(max_pixel_depth,row_bytes) + + /* Calculate the maximum bytes needed, adding a byte and a pixel + * for safety's sake + */ + row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) + 1 + ((max_pixel_depth + 7) >> 3); #ifdef PNG_MAX_MALLOC_64K if (row_bytes > (png_uint_32)65536L) png_error(png_ptr, "This image requires a row greater than 64KB"); #endif - if(row_bytes + 64 > png_ptr->old_big_row_buf_size) + if (row_bytes + 64 > png_ptr->old_big_row_buf_size) { - png_free(png_ptr,png_ptr->big_row_buf); - png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes+64); - png_ptr->row_buf = png_ptr->big_row_buf+32; - png_ptr->old_big_row_buf_size = row_bytes+64; + png_free(png_ptr, png_ptr->big_row_buf); + png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 64); + if (png_ptr->interlaced) + png_memset(png_ptr->big_row_buf, 0, row_bytes + 64); + png_ptr->row_buf = png_ptr->big_row_buf + 32; + png_ptr->old_big_row_buf_size = row_bytes + 64; } #ifdef PNG_MAX_MALLOC_64K - if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L) + if ((png_uint_32)row_bytes + 1 > (png_uint_32)65536L) png_error(png_ptr, "This image requires a row greater than 64KB"); #endif - if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1)) + if ((png_uint_32)row_bytes > (png_uint_32)(PNG_SIZE_MAX - 1)) png_error(png_ptr, "Row has too many bytes to allocate in memory."); - if(png_ptr->rowbytes+1 > png_ptr->old_prev_row_size) + if (row_bytes + 1 > png_ptr->old_prev_row_size) { - png_free(png_ptr,png_ptr->prev_row); - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( - png_ptr->rowbytes + 1)); - png_ptr->old_prev_row_size = png_ptr->rowbytes+1; + png_free(png_ptr, png_ptr->prev_row); + png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)( + row_bytes + 1)); + png_memset_check(png_ptr, png_ptr->prev_row, 0, row_bytes + 1); + png_ptr->old_prev_row_size = row_bytes + 1; } - png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1); + png_ptr->rowbytes = row_bytes; - png_debug1(3, "width = %lu,\n", png_ptr->width); - png_debug1(3, "height = %lu,\n", png_ptr->height); - png_debug1(3, "iwidth = %lu,\n", png_ptr->iwidth); - png_debug1(3, "num_rows = %lu\n", png_ptr->num_rows); - png_debug1(3, "rowbytes = %lu,\n", png_ptr->rowbytes); - png_debug1(3, "irowbytes = %lu,\n", png_ptr->irowbytes); + png_debug1(3, "width = %lu,", png_ptr->width); + png_debug1(3, "height = %lu,", png_ptr->height); + png_debug1(3, "iwidth = %lu,", png_ptr->iwidth); + png_debug1(3, "num_rows = %lu,", png_ptr->num_rows); + png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes); + png_debug1(3, "irowbytes = %lu", png_ptr->irowbytes); png_ptr->flags |= PNG_FLAG_ROW_INIT; } diff --git a/src/3rdparty/libpng/pngset.c b/src/3rdparty/libpng/pngset.c index 8b25ca5..9e1b885 100644 --- a/src/3rdparty/libpng/pngset.c +++ b/src/3rdparty/libpng/pngset.c @@ -1,12 +1,15 @@ /* pngset.c - storage of image information into info struct * - * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Last changed in libpng 1.2.40 [September 10, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * The functions here are used during reads to store data from the file * into the info struct, and during writes to store application data * into the info struct for writing into the file. This abstracts the @@ -15,14 +18,14 @@ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if defined(PNG_bKGD_SUPPORTED) void PNGAPI png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background) { - png_debug1(1, "in %s storage function\n", "bKGD"); + png_debug1(1, "in %s storage function", "bKGD"); + if (png_ptr == NULL || info_ptr == NULL) return; @@ -38,34 +41,10 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr, double white_x, double white_y, double red_x, double red_y, double green_x, double green_y, double blue_x, double blue_y) { - png_debug1(1, "in %s storage function\n", "cHRM"); + png_debug1(1, "in %s storage function", "cHRM"); + if (png_ptr == NULL || info_ptr == NULL) return; - if (!(white_x || white_y || red_x || red_y || green_x || green_y || - blue_x || blue_y)) - { - png_warning(png_ptr, - "Ignoring attempt to set all-zero chromaticity values"); - return; - } - if (white_x < 0.0 || white_y < 0.0 || - red_x < 0.0 || red_y < 0.0 || - green_x < 0.0 || green_y < 0.0 || - blue_x < 0.0 || blue_y < 0.0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > 21474.83 || white_y > 21474.83 || - red_x > 21474.83 || red_y > 21474.83 || - green_x > 21474.83 || green_y > 21474.83 || - blue_x > 21474.83 || blue_y > 21474.83) - { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; - } info_ptr->x_white = (float)white_x; info_ptr->y_white = (float)white_y; @@ -87,7 +66,8 @@ png_set_cHRM(png_structp png_ptr, png_infop info_ptr, #endif info_ptr->valid |= PNG_INFO_cHRM; } -#endif +#endif /* PNG_FLOATING_POINT_SUPPORTED */ + #ifdef PNG_FIXED_POINT_SUPPORTED void PNGAPI png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, @@ -95,69 +75,49 @@ png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y, png_fixed_point blue_x, png_fixed_point blue_y) { - png_debug1(1, "in %s storage function\n", "cHRM"); + png_debug1(1, "in %s storage function", "cHRM fixed"); + if (png_ptr == NULL || info_ptr == NULL) return; - if (!(white_x || white_y || red_x || red_y || green_x || green_y || - blue_x || blue_y)) - { - png_warning(png_ptr, - "Ignoring attempt to set all-zero chromaticity values"); - return; - } - if (white_x < 0 || white_y < 0 || - red_x < 0 || red_y < 0 || - green_x < 0 || green_y < 0 || - blue_x < 0 || blue_y < 0) - { - png_warning(png_ptr, - "Ignoring attempt to set negative chromaticity value"); - return; - } - if (white_x > (png_fixed_point) PNG_UINT_31_MAX || - white_y > (png_fixed_point) PNG_UINT_31_MAX || - red_x > (png_fixed_point) PNG_UINT_31_MAX || - red_y > (png_fixed_point) PNG_UINT_31_MAX || - green_x > (png_fixed_point) PNG_UINT_31_MAX || - green_y > (png_fixed_point) PNG_UINT_31_MAX || - blue_x > (png_fixed_point) PNG_UINT_31_MAX || - blue_y > (png_fixed_point) PNG_UINT_31_MAX ) +#if !defined(PNG_NO_CHECK_cHRM) + if (png_check_cHRM_fixed(png_ptr, + white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y)) +#endif { - png_warning(png_ptr, - "Ignoring attempt to set chromaticity value exceeding 21474.83"); - return; + info_ptr->int_x_white = white_x; + info_ptr->int_y_white = white_y; + info_ptr->int_x_red = red_x; + info_ptr->int_y_red = red_y; + info_ptr->int_x_green = green_x; + info_ptr->int_y_green = green_y; + info_ptr->int_x_blue = blue_x; + info_ptr->int_y_blue = blue_y; +#ifdef PNG_FLOATING_POINT_SUPPORTED + info_ptr->x_white = (float)(white_x/100000.); + info_ptr->y_white = (float)(white_y/100000.); + info_ptr->x_red = (float)( red_x/100000.); + info_ptr->y_red = (float)( red_y/100000.); + info_ptr->x_green = (float)(green_x/100000.); + info_ptr->y_green = (float)(green_y/100000.); + info_ptr->x_blue = (float)( blue_x/100000.); + info_ptr->y_blue = (float)( blue_y/100000.); +#endif + info_ptr->valid |= PNG_INFO_cHRM; } - info_ptr->int_x_white = white_x; - info_ptr->int_y_white = white_y; - info_ptr->int_x_red = red_x; - info_ptr->int_y_red = red_y; - info_ptr->int_x_green = green_x; - info_ptr->int_y_green = green_y; - info_ptr->int_x_blue = blue_x; - info_ptr->int_y_blue = blue_y; -#ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->x_white = (float)(white_x/100000.); - info_ptr->y_white = (float)(white_y/100000.); - info_ptr->x_red = (float)( red_x/100000.); - info_ptr->y_red = (float)( red_y/100000.); - info_ptr->x_green = (float)(green_x/100000.); - info_ptr->y_green = (float)(green_y/100000.); - info_ptr->x_blue = (float)( blue_x/100000.); - info_ptr->y_blue = (float)( blue_y/100000.); -#endif - info_ptr->valid |= PNG_INFO_cHRM; } -#endif -#endif +#endif /* PNG_FIXED_POINT_SUPPORTED */ +#endif /* PNG_cHRM_SUPPORTED */ #if defined(PNG_gAMA_SUPPORTED) #ifdef PNG_FLOATING_POINT_SUPPORTED void PNGAPI png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) { - double gamma; - png_debug1(1, "in %s storage function\n", "gAMA"); + double png_gamma; + + png_debug1(1, "in %s storage function", "gAMA"); + if (png_ptr == NULL || info_ptr == NULL) return; @@ -165,16 +125,16 @@ png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma) if (file_gamma > 21474.83) { png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=21474.83; + png_gamma=21474.83; } else - gamma=file_gamma; - info_ptr->gamma = (float)gamma; + png_gamma = file_gamma; + info_ptr->gamma = (float)png_gamma; #ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = (int)(gamma*100000.+.5); + info_ptr->int_gamma = (int)(png_gamma*100000.+.5); #endif info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0.0) + if (png_gamma == 0.0) png_warning(png_ptr, "Setting gamma=0"); } #endif @@ -182,35 +142,36 @@ void PNGAPI png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point int_gamma) { - png_fixed_point gamma; + png_fixed_point png_gamma; + + png_debug1(1, "in %s storage function", "gAMA"); - png_debug1(1, "in %s storage function\n", "gAMA"); if (png_ptr == NULL || info_ptr == NULL) return; - if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX) + if (int_gamma > (png_fixed_point)PNG_UINT_31_MAX) { - png_warning(png_ptr, "Limiting gamma to 21474.83"); - gamma=PNG_UINT_31_MAX; + png_warning(png_ptr, "Limiting gamma to 21474.83"); + png_gamma=PNG_UINT_31_MAX; } else { - if (int_gamma < 0) - { - png_warning(png_ptr, "Setting negative gamma to zero"); - gamma=0; - } - else - gamma=int_gamma; + if (int_gamma < 0) + { + png_warning(png_ptr, "Setting negative gamma to zero"); + png_gamma = 0; + } + else + png_gamma = int_gamma; } #ifdef PNG_FLOATING_POINT_SUPPORTED - info_ptr->gamma = (float)(gamma/100000.); + info_ptr->gamma = (float)(png_gamma/100000.); #endif #ifdef PNG_FIXED_POINT_SUPPORTED - info_ptr->int_gamma = gamma; + info_ptr->int_gamma = png_gamma; #endif info_ptr->valid |= PNG_INFO_gAMA; - if(gamma == 0) + if (png_gamma == 0) png_warning(png_ptr, "Setting gamma=0"); } #endif @@ -221,32 +182,35 @@ png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist) { int i; - png_debug1(1, "in %s storage function\n", "hIST"); + png_debug1(1, "in %s storage function", "hIST"); + if (png_ptr == NULL || info_ptr == NULL) return; + if (info_ptr->num_palette == 0 || info_ptr->num_palette > PNG_MAX_PALETTE_LENGTH) { - png_warning(png_ptr, - "Invalid palette size, hIST allocation skipped."); - return; + png_warning(png_ptr, + "Invalid palette size, hIST allocation skipped."); + return; } #ifdef PNG_FREE_ME_SUPPORTED png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0); #endif - /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version - 1.2.1 */ + /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in + * version 1.2.1 + */ png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr, - (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof (png_uint_16))); + (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16))); if (png_ptr->hist == NULL) - { - png_warning(png_ptr, "Insufficient memory for hIST chunk data."); - return; - } + { + png_warning(png_ptr, "Insufficient memory for hIST chunk data."); + return; + } for (i = 0; i < info_ptr->num_palette; i++) - png_ptr->hist[i] = hist[i]; + png_ptr->hist[i] = hist[i]; info_ptr->hist = png_ptr->hist; info_ptr->valid |= PNG_INFO_hIST; @@ -264,11 +228,12 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr, int color_type, int interlace_type, int compression_type, int filter_type) { - png_debug1(1, "in %s storage function\n", "IHDR"); + png_debug1(1, "in %s storage function", "IHDR"); + if (png_ptr == NULL || info_ptr == NULL) return; - /* check for width and height valid values */ + /* Check for width and height valid values */ if (width == 0 || height == 0) png_error(png_ptr, "Image width or height is zero in IHDR"); #ifdef PNG_SET_USER_LIMITS_SUPPORTED @@ -288,13 +253,13 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr, - 8) /* extra max_pixel_depth pad */ png_warning(png_ptr, "Width is too large for libpng to process pixels"); - /* check other values */ + /* Check other values */ if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 && - bit_depth != 8 && bit_depth != 16) + bit_depth != 8 && bit_depth != 16) png_error(png_ptr, "Invalid bit depth in IHDR"); if (color_type < 0 || color_type == 1 || - color_type == 5 || color_type > 6) + color_type == 5 || color_type > 6) png_error(png_ptr, "Invalid color type in IHDR"); if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) || @@ -319,21 +284,21 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr, * 4. The filter_method is 64 and * 5. The color_type is RGB or RGBA */ - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); - if(filter_type != PNG_FILTER_TYPE_BASE) + if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted) + png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); + if (filter_type != PNG_FILTER_TYPE_BASE) { - if(!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && - (color_type == PNG_COLOR_TYPE_RGB || + if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + (filter_type == PNG_INTRAPIXEL_DIFFERENCING) && + ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && + (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA))) png_error(png_ptr, "Unknown filter method in IHDR"); - if(png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) + if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) png_warning(png_ptr, "Invalid filter method in IHDR"); } #else - if(filter_type != PNG_FILTER_TYPE_BASE) + if (filter_type != PNG_FILTER_TYPE_BASE) png_error(png_ptr, "Unknown filter method in IHDR"); #endif @@ -354,7 +319,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr, info_ptr->channels++; info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth); - /* check for potential overflow */ + /* Check for potential overflow */ if (width > (PNG_UINT_32_MAX >> 3) /* 8-byte RGBA pixels */ - 64 /* bigrowbuf hack */ @@ -363,7 +328,7 @@ png_set_IHDR(png_structp png_ptr, png_infop info_ptr, - 8) /* extra max_pixel_depth pad */ info_ptr->rowbytes = (png_size_t)0; else - info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth,width); + info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width); } #if defined(PNG_oFFs_SUPPORTED) @@ -371,7 +336,8 @@ void PNGAPI png_set_oFFs(png_structp png_ptr, png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y, int unit_type) { - png_debug1(1, "in %s storage function\n", "oFFs"); + png_debug1(1, "in %s storage function", "oFFs"); + if (png_ptr == NULL || info_ptr == NULL) return; @@ -391,56 +357,60 @@ png_set_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length; int i; - png_debug1(1, "in %s storage function\n", "pCAL"); + png_debug1(1, "in %s storage function", "pCAL"); + if (png_ptr == NULL || info_ptr == NULL) return; length = png_strlen(purpose) + 1; - png_debug1(3, "allocating purpose for info (%lu bytes)\n", length); + png_debug1(3, "allocating purpose for info (%lu bytes)", + (unsigned long)length); info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_purpose == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL purpose."); - return; - } + { + png_warning(png_ptr, "Insufficient memory for pCAL purpose."); + return; + } png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length); - png_debug(3, "storing X0, X1, type, and nparams in info\n"); + png_debug(3, "storing X0, X1, type, and nparams in info"); info_ptr->pcal_X0 = X0; info_ptr->pcal_X1 = X1; info_ptr->pcal_type = (png_byte)type; info_ptr->pcal_nparams = (png_byte)nparams; length = png_strlen(units) + 1; - png_debug1(3, "allocating units for info (%lu bytes)\n", length); + png_debug1(3, "allocating units for info (%lu bytes)", + (unsigned long)length); info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_units == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL units."); - return; - } + { + png_warning(png_ptr, "Insufficient memory for pCAL units."); + return; + } png_memcpy(info_ptr->pcal_units, units, (png_size_t)length); info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)((nparams + 1) * png_sizeof(png_charp))); if (info_ptr->pcal_params == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL params."); - return; - } + { + png_warning(png_ptr, "Insufficient memory for pCAL params."); + return; + } - info_ptr->pcal_params[nparams] = NULL; + png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp)); for (i = 0; i < nparams; i++) { length = png_strlen(params[i]) + 1; - png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length); + png_debug2(3, "allocating parameter %d for info (%lu bytes)", i, + (unsigned long)length); info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->pcal_params[i] == NULL) - { - png_warning(png_ptr, "Insufficient memory for pCAL parameter."); - return; - } + { + png_warning(png_ptr, "Insufficient memory for pCAL parameter."); + return; + } png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length); } @@ -457,7 +427,8 @@ void PNGAPI png_set_sCAL(png_structp png_ptr, png_infop info_ptr, int unit, double width, double height) { - png_debug1(1, "in %s storage function\n", "sCAL"); + png_debug1(1, "in %s storage function", "sCAL"); + if (png_ptr == NULL || info_ptr == NULL) return; @@ -475,14 +446,16 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, { png_uint_32 length; - png_debug1(1, "in %s storage function\n", "sCAL"); + png_debug1(1, "in %s storage function", "sCAL"); + if (png_ptr == NULL || info_ptr == NULL) return; info_ptr->scal_unit = (png_byte)unit; length = png_strlen(swidth) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); + png_debug1(3, "allocating unit for info (%u bytes)", + (unsigned int)length); info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_width == NULL) { @@ -493,11 +466,13 @@ png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr, png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length); length = png_strlen(sheight) + 1; - png_debug1(3, "allocating unit for info (%d bytes)\n", length); + png_debug1(3, "allocating unit for info (%u bytes)", + (unsigned int)length); info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length); if (info_ptr->scal_s_height == NULL) { png_free (png_ptr, info_ptr->scal_s_width); + info_ptr->scal_s_width = NULL; png_warning(png_ptr, "Memory allocation failed while processing sCAL."); return; @@ -517,7 +492,8 @@ void PNGAPI png_set_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type) { - png_debug1(1, "in %s storage function\n", "pHYs"); + png_debug1(1, "in %s storage function", "pHYs"); + if (png_ptr == NULL || info_ptr == NULL) return; @@ -533,20 +509,21 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp palette, int num_palette) { - png_debug1(1, "in %s storage function\n", "PLTE"); + png_debug1(1, "in %s storage function", "PLTE"); + if (png_ptr == NULL || info_ptr == NULL) return; if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH) - { - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) png_error(png_ptr, "Invalid palette length"); - else - { + else + { png_warning(png_ptr, "Invalid palette length"); return; - } - } + } + } /* * It may not actually be necessary to set png_ptr->palette here; @@ -558,13 +535,14 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr, #endif /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead - of num_palette entries, - in case of an invalid PNG file that has too-large sample values. */ + * of num_palette entries, in case of an invalid PNG file that has + * too-large sample values. + */ png_ptr->palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)); - png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof (png_color)); + png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color)); info_ptr->palette = png_ptr->palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; @@ -582,11 +560,12 @@ void PNGAPI png_set_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p sig_bit) { - png_debug1(1, "in %s storage function\n", "sBIT"); + png_debug1(1, "in %s storage function", "sBIT"); + if (png_ptr == NULL || info_ptr == NULL) return; - png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof (png_color_8)); + png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8)); info_ptr->valid |= PNG_INFO_sBIT; } #endif @@ -595,7 +574,8 @@ png_set_sBIT(png_structp png_ptr, png_infop info_ptr, void PNGAPI png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent) { - png_debug1(1, "in %s storage function\n", "sRGB"); + png_debug1(1, "in %s storage function", "sRGB"); + if (png_ptr == NULL || info_ptr == NULL) return; @@ -619,12 +599,11 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, #ifdef PNG_FLOATING_POINT_SUPPORTED float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y; #endif -#ifdef PNG_FIXED_POINT_SUPPORTED png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y; #endif -#endif - png_debug1(1, "in %s storage function\n", "sRGB_gAMA_and_cHRM"); + png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM"); + if (png_ptr == NULL || info_ptr == NULL) return; @@ -642,7 +621,6 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, #endif #if defined(PNG_cHRM_SUPPORTED) -#ifdef PNG_FIXED_POINT_SUPPORTED int_white_x = 31270L; int_white_y = 32900L; int_red_x = 64000L; @@ -652,10 +630,6 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, int_blue_x = 15000L; int_blue_y = 6000L; - png_set_cHRM_fixed(png_ptr, info_ptr, - int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, int_green_y, - int_blue_x, int_blue_y); -#endif #ifdef PNG_FLOATING_POINT_SUPPORTED white_x = (float).3127; white_y = (float).3290; @@ -665,13 +639,27 @@ png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr, green_y = (float).60; blue_x = (float).15; blue_y = (float).06; +#endif - png_set_cHRM(png_ptr, info_ptr, - white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); +#if !defined(PNG_NO_CHECK_cHRM) + if (png_check_cHRM_fixed(png_ptr, + int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, + int_green_y, int_blue_x, int_blue_y)) #endif + { +#ifdef PNG_FIXED_POINT_SUPPORTED + png_set_cHRM_fixed(png_ptr, info_ptr, + int_white_x, int_white_y, int_red_x, int_red_y, int_green_x, + int_green_y, int_blue_x, int_blue_y); #endif -} +#ifdef PNG_FLOATING_POINT_SUPPORTED + png_set_cHRM(png_ptr, info_ptr, + white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y); #endif + } +#endif /* cHRM */ +} +#endif /* sRGB */ #if defined(PNG_iCCP_SUPPORTED) @@ -684,7 +672,8 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr, png_charp new_iccp_profile; png_uint_32 length; - png_debug1(1, "in %s storage function\n", "iCCP"); + png_debug1(1, "in %s storage function", "iCCP"); + if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL) return; @@ -700,7 +689,8 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr, if (new_iccp_profile == NULL) { png_free (png_ptr, new_iccp_name); - png_warning(png_ptr, "Insufficient memory to process iCCP profile."); + png_warning(png_ptr, + "Insufficient memory to process iCCP profile."); return; } png_memcpy(new_iccp_profile, profile, (png_size_t)proflen); @@ -723,21 +713,22 @@ png_set_iCCP(png_structp png_ptr, png_infop info_ptr, #if defined(PNG_TEXT_SUPPORTED) void PNGAPI png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) + int num_text) { int ret; - ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); + ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text); if (ret) - png_error(png_ptr, "Insufficient memory to store text"); + png_error(png_ptr, "Insufficient memory to store text"); } int /* PRIVATE */ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, - int num_text) + int num_text) { int i; - png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ? + png_debug1(1, "in %s storage function", ((png_ptr == NULL || + png_ptr->chunk_name[0] == '\0') ? "text" : (png_const_charp)png_ptr->chunk_name)); if (png_ptr == NULL || info_ptr == NULL || num_text == 0) @@ -757,12 +748,12 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, info_ptr->max_text = info_ptr->num_text + num_text + 8; old_text = info_ptr->text; info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); + (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); if (info_ptr->text == NULL) - { - png_free(png_ptr, old_text); - return(1); - } + { + png_free(png_ptr, old_text); + return(1); + } png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max * png_sizeof(png_text))); png_free(png_ptr, old_text); @@ -772,20 +763,20 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, info_ptr->max_text = num_text + 8; info_ptr->num_text = 0; info_ptr->text = (png_textp)png_malloc_warn(png_ptr, - (png_uint_32)(info_ptr->max_text * png_sizeof (png_text))); + (png_uint_32)(info_ptr->max_text * png_sizeof(png_text))); if (info_ptr->text == NULL) - return(1); + return(1); #ifdef PNG_FREE_ME_SUPPORTED info_ptr->free_me |= PNG_FREE_TEXT; #endif } - png_debug1(3, "allocated %d entries for info_ptr->text\n", + png_debug1(3, "allocated %d entries for info_ptr->text", info_ptr->max_text); } for (i = 0; i < num_text; i++) { - png_size_t text_length,key_len; - png_size_t lang_len,lang_key_len; + png_size_t text_length, key_len; + png_size_t lang_len, lang_key_len; png_textp textp = &(info_ptr->text[info_ptr->num_text]); if (text_ptr[i].key == NULL) @@ -793,28 +784,28 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, key_len = png_strlen(text_ptr[i].key); - if(text_ptr[i].compression <= 0) + if (text_ptr[i].compression <= 0) { - lang_len = 0; - lang_key_len = 0; + lang_len = 0; + lang_key_len = 0; } else #ifdef PNG_iTXt_SUPPORTED { - /* set iTXt data */ - if (text_ptr[i].lang != NULL) - lang_len = png_strlen(text_ptr[i].lang); - else - lang_len = 0; - if (text_ptr[i].lang_key != NULL) - lang_key_len = png_strlen(text_ptr[i].lang_key); - else - lang_key_len = 0; + /* Set iTXt data */ + if (text_ptr[i].lang != NULL) + lang_len = png_strlen(text_ptr[i].lang); + else + lang_len = 0; + if (text_ptr[i].lang_key != NULL) + lang_key_len = png_strlen(text_ptr[i].lang_key); + else + lang_key_len = 0; } #else { - png_warning(png_ptr, "iTXt chunk not supported."); - continue; + png_warning(png_ptr, "iTXt chunk not supported."); + continue; } #endif @@ -822,7 +813,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, { text_length = 0; #ifdef PNG_iTXt_SUPPORTED - if(text_ptr[i].compression > 0) + if (text_ptr[i].compression > 0) textp->compression = PNG_ITXT_COMPRESSION_NONE; else #endif @@ -835,26 +826,27 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, } textp->key = (png_charp)png_malloc_warn(png_ptr, - (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4)); + (png_uint_32) + (key_len + text_length + lang_len + lang_key_len + 4)); if (textp->key == NULL) - return(1); - png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n", - (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4), - (int)textp->key); - - png_memcpy(textp->key, text_ptr[i].key, - (png_size_t)(key_len)); - *(textp->key+key_len) = '\0'; + return(1); + png_debug2(2, "Allocated %lu bytes at %x in png_set_text", + (png_uint_32) + (key_len + lang_len + lang_key_len + text_length + 4), + (int)textp->key); + + png_memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len)); + *(textp->key + key_len) = '\0'; #ifdef PNG_iTXt_SUPPORTED if (text_ptr[i].compression > 0) { - textp->lang=textp->key + key_len + 1; + textp->lang = textp->key + key_len + 1; png_memcpy(textp->lang, text_ptr[i].lang, lang_len); - *(textp->lang+lang_len) = '\0'; - textp->lang_key=textp->lang + lang_len + 1; + *(textp->lang + lang_len) = '\0'; + textp->lang_key = textp->lang + lang_len + 1; png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len); - *(textp->lang_key+lang_key_len) = '\0'; - textp->text=textp->lang_key + lang_key_len + 1; + *(textp->lang_key + lang_key_len) = '\0'; + textp->text = textp->lang_key + lang_key_len + 1; } else #endif @@ -863,15 +855,15 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, textp->lang=NULL; textp->lang_key=NULL; #endif - textp->text=textp->key + key_len + 1; + textp->text = textp->key + key_len + 1; } - if(text_length) + if (text_length) png_memcpy(textp->text, text_ptr[i].text, (png_size_t)(text_length)); - *(textp->text+text_length) = '\0'; + *(textp->text + text_length) = '\0'; #ifdef PNG_iTXt_SUPPORTED - if(textp->compression > 0) + if (textp->compression > 0) { textp->text_length = 0; textp->itxt_length = text_length; @@ -885,7 +877,7 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, #endif } info_ptr->num_text++; - png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text); + png_debug1(3, "transferred text chunk %d", info_ptr->num_text); } return(0); } @@ -895,12 +887,13 @@ png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr, void PNGAPI png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time) { - png_debug1(1, "in %s storage function\n", "tIME"); + png_debug1(1, "in %s storage function", "tIME"); + if (png_ptr == NULL || info_ptr == NULL || (png_ptr->mode & PNG_WROTE_tIME)) return; - png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof (png_time)); + png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time)); info_ptr->valid |= PNG_INFO_tIME; } #endif @@ -910,12 +903,11 @@ void PNGAPI png_set_tRNS(png_structp png_ptr, png_infop info_ptr, png_bytep trans, int num_trans, png_color_16p trans_values) { - png_debug1(1, "in %s storage function\n", "tRNS"); + png_debug1(1, "in %s storage function", "tRNS"); + if (png_ptr == NULL || info_ptr == NULL) return; - png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); - if (trans != NULL) { /* @@ -924,11 +916,15 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr, * function used to do the allocation. */ +#ifdef PNG_FREE_ME_SUPPORTED + png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0); +#endif + /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */ png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr, (png_uint_32)PNG_MAX_PALETTE_LENGTH); if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) - png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); + png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans); } if (trans_values != NULL) @@ -940,12 +936,12 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr, ((int)trans_values->red > sample_max || (int)trans_values->green > sample_max || (int)trans_values->blue > sample_max))) - png_warning(png_ptr, - "tRNS chunk has out-of-range samples for bit_depth"); + png_warning(png_ptr, + "tRNS chunk has out-of-range samples for bit_depth"); png_memcpy(&(info_ptr->trans_values), trans_values, png_sizeof(png_color_16)); if (num_trans == 0) - num_trans = 1; + num_trans = 1; } info_ptr->num_trans = (png_uint_16)num_trans; @@ -965,132 +961,141 @@ png_set_tRNS(png_structp png_ptr, png_infop info_ptr, void PNGAPI png_set_sPLT(png_structp png_ptr, png_infop info_ptr, png_sPLT_tp entries, int nentries) +/* + * entries - array of png_sPLT_t structures + * to be added to the list of palettes + * in the info structure. + * nentries - number of palette structures to be + * added. + */ { - png_sPLT_tp np; - int i; + png_sPLT_tp np; + int i; - if (png_ptr == NULL || info_ptr == NULL) - return; + if (png_ptr == NULL || info_ptr == NULL) + return; - np = (png_sPLT_tp)png_malloc_warn(png_ptr, - (info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)); - if (np == NULL) - { + np = (png_sPLT_tp)png_malloc_warn(png_ptr, + (info_ptr->splt_palettes_num + nentries) * + (png_uint_32)png_sizeof(png_sPLT_t)); + if (np == NULL) + { png_warning(png_ptr, "No memory for sPLT palettes."); - return; - } + return; + } - png_memcpy(np, info_ptr->splt_palettes, - info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); - png_free(png_ptr, info_ptr->splt_palettes); - info_ptr->splt_palettes=NULL; + png_memcpy(np, info_ptr->splt_palettes, + info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t)); + png_free(png_ptr, info_ptr->splt_palettes); + info_ptr->splt_palettes=NULL; - for (i = 0; i < nentries; i++) - { - png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; - png_sPLT_tp from = entries + i; - png_uint_32 length; + for (i = 0; i < nentries; i++) + { + png_sPLT_tp to = np + info_ptr->splt_palettes_num + i; + png_sPLT_tp from = entries + i; + png_uint_32 length; - length = png_strlen(from->name) + 1; + length = png_strlen(from->name) + 1; to->name = (png_charp)png_malloc_warn(png_ptr, length); - if (to->name == NULL) - { - png_warning(png_ptr, - "Out of memory while processing sPLT chunk"); - continue; - } - png_memcpy(to->name, from->name, length); - to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, - from->nentries * png_sizeof(png_sPLT_entry)); - if (to->entries == NULL) - { - png_warning(png_ptr, - "Out of memory while processing sPLT chunk"); - png_free(png_ptr,to->name); - to->name = NULL; - continue; - } - png_memcpy(to->entries, from->entries, - from->nentries * png_sizeof(png_sPLT_entry)); - to->nentries = from->nentries; - to->depth = from->depth; - } - - info_ptr->splt_palettes = np; - info_ptr->splt_palettes_num += nentries; - info_ptr->valid |= PNG_INFO_sPLT; + if (to->name == NULL) + { + png_warning(png_ptr, + "Out of memory while processing sPLT chunk"); + continue; + } + png_memcpy(to->name, from->name, length); + to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr, + (png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry))); + if (to->entries == NULL) + { + png_warning(png_ptr, + "Out of memory while processing sPLT chunk"); + png_free(png_ptr, to->name); + to->name = NULL; + continue; + } + png_memcpy(to->entries, from->entries, + from->nentries * png_sizeof(png_sPLT_entry)); + to->nentries = from->nentries; + to->depth = from->depth; + } + + info_ptr->splt_palettes = np; + info_ptr->splt_palettes_num += nentries; + info_ptr->valid |= PNG_INFO_sPLT; #ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_SPLT; + info_ptr->free_me |= PNG_FREE_SPLT; #endif } #endif /* PNG_sPLT_SUPPORTED */ -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) +#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED void PNGAPI png_set_unknown_chunks(png_structp png_ptr, png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns) { - png_unknown_chunkp np; - int i; - - if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) - return; - - np = (png_unknown_chunkp)png_malloc_warn(png_ptr, - (info_ptr->unknown_chunks_num + num_unknowns) * - png_sizeof(png_unknown_chunk)); - if (np == NULL) - { - png_warning(png_ptr, - "Out of memory while processing unknown chunk."); - return; - } - - png_memcpy(np, info_ptr->unknown_chunks, - info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); - png_free(png_ptr, info_ptr->unknown_chunks); - info_ptr->unknown_chunks=NULL; - - for (i = 0; i < num_unknowns; i++) - { - png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; - png_unknown_chunkp from = unknowns + i; - - png_memcpy((png_charp)to->name, - (png_charp)from->name, - png_sizeof(from->name)); - to->name[png_sizeof(to->name)-1] = '\0'; - to->size = from->size; - /* note our location in the read or write sequence */ - to->location = (png_byte)(png_ptr->mode & 0xff); - - if (from->size == 0) - to->data=NULL; - else - { - to->data = (png_bytep)png_malloc_warn(png_ptr, from->size); - if (to->data == NULL) - { - png_warning(png_ptr, - "Out of memory while processing unknown chunk."); - to->size=0; - } - else - png_memcpy(to->data, from->data, from->size); - } - } - - info_ptr->unknown_chunks = np; - info_ptr->unknown_chunks_num += num_unknowns; + png_unknown_chunkp np; + int i; + + if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0) + return; + + np = (png_unknown_chunkp)png_malloc_warn(png_ptr, + (png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) * + png_sizeof(png_unknown_chunk))); + if (np == NULL) + { + png_warning(png_ptr, + "Out of memory while processing unknown chunk."); + return; + } + + png_memcpy(np, info_ptr->unknown_chunks, + info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk)); + png_free(png_ptr, info_ptr->unknown_chunks); + info_ptr->unknown_chunks=NULL; + + for (i = 0; i < num_unknowns; i++) + { + png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i; + png_unknown_chunkp from = unknowns + i; + + png_memcpy((png_charp)to->name, + (png_charp)from->name, + png_sizeof(from->name)); + to->name[png_sizeof(to->name)-1] = '\0'; + to->size = from->size; + /* Note our location in the read or write sequence */ + to->location = (png_byte)(png_ptr->mode & 0xff); + + if (from->size == 0) + to->data=NULL; + else + { + to->data = (png_bytep)png_malloc_warn(png_ptr, + (png_uint_32)from->size); + if (to->data == NULL) + { + png_warning(png_ptr, + "Out of memory while processing unknown chunk."); + to->size = 0; + } + else + png_memcpy(to->data, from->data, from->size); + } + } + + info_ptr->unknown_chunks = np; + info_ptr->unknown_chunks_num += num_unknowns; #ifdef PNG_FREE_ME_SUPPORTED - info_ptr->free_me |= PNG_FREE_UNKN; + info_ptr->free_me |= PNG_FREE_UNKN; #endif } void PNGAPI png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr, int chunk, int location) { - if(png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < + if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk < (int)info_ptr->unknown_chunks_num) info_ptr->unknown_chunks[chunk].location = (png_byte)location; } @@ -1104,7 +1109,9 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) { /* This function is deprecated in favor of png_permit_mng_features() and will be removed from libpng-1.3.0 */ - png_debug(1, "in png_permit_empty_plte, DEPRECATED.\n"); + + png_debug(1, "in png_permit_empty_plte, DEPRECATED."); + if (png_ptr == NULL) return; png_ptr->mng_features_permitted = (png_byte) @@ -1118,7 +1125,8 @@ png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted) png_uint_32 PNGAPI png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features) { - png_debug(1, "in png_permit_mng_features\n"); + png_debug(1, "in png_permit_mng_features"); + if (png_ptr == NULL) return (png_uint_32)0; png_ptr->mng_features_permitted = @@ -1132,43 +1140,44 @@ void PNGAPI png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep chunk_list, int num_chunks) { - png_bytep new_list, p; - int i, old_num_chunks; - if (png_ptr == NULL) - return; - if (num_chunks == 0) - { - if(keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) - png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; + png_bytep new_list, p; + int i, old_num_chunks; + if (png_ptr == NULL) + return; + if (num_chunks == 0) + { + if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE) + png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS; else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; + png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS; - if(keep == PNG_HANDLE_CHUNK_ALWAYS) - png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; + if (keep == PNG_HANDLE_CHUNK_ALWAYS) + png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS; else - png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; + png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS; return; - } - if (chunk_list == NULL) + } + if (chunk_list == NULL) return; - old_num_chunks=png_ptr->num_chunk_list; - new_list=(png_bytep)png_malloc(png_ptr, - (png_uint_32)(5*(num_chunks+old_num_chunks))); - if(png_ptr->chunk_list != NULL) - { - png_memcpy(new_list, png_ptr->chunk_list, - (png_size_t)(5*old_num_chunks)); - png_free(png_ptr, png_ptr->chunk_list); - png_ptr->chunk_list=NULL; - } - png_memcpy(new_list+5*old_num_chunks, chunk_list, - (png_size_t)(5*num_chunks)); - for (p=new_list+5*old_num_chunks+4, i=0; inum_chunk_list=old_num_chunks+num_chunks; - png_ptr->chunk_list=new_list; + old_num_chunks = png_ptr->num_chunk_list; + new_list=(png_bytep)png_malloc(png_ptr, + (png_uint_32) + (5*(num_chunks + old_num_chunks))); + if (png_ptr->chunk_list != NULL) + { + png_memcpy(new_list, png_ptr->chunk_list, + (png_size_t)(5*old_num_chunks)); + png_free(png_ptr, png_ptr->chunk_list); + png_ptr->chunk_list=NULL; + } + png_memcpy(new_list + 5*old_num_chunks, chunk_list, + (png_size_t)(5*num_chunks)); + for (p = new_list + 5*old_num_chunks + 4, i = 0; inum_chunk_list = old_num_chunks + num_chunks; + png_ptr->chunk_list = new_list; #ifdef PNG_FREE_ME_SUPPORTED - png_ptr->free_me |= PNG_FREE_LIST; + png_ptr->free_me |= PNG_FREE_LIST; #endif } #endif @@ -1178,9 +1187,11 @@ void PNGAPI png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn) { - png_debug(1, "in png_set_read_user_chunk_fn\n"); + png_debug(1, "in png_set_read_user_chunk_fn"); + if (png_ptr == NULL) return; + png_ptr->read_user_chunk_fn = read_user_chunk_fn; png_ptr->user_chunk_ptr = user_chunk_ptr; } @@ -1190,22 +1201,23 @@ png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr, void PNGAPI png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers) { - png_debug1(1, "in %s storage function\n", "rows"); + png_debug1(1, "in %s storage function", "rows"); if (png_ptr == NULL || info_ptr == NULL) return; - if(info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) + if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers)) png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0); info_ptr->row_pointers = row_pointers; - if(row_pointers) + if (row_pointers) info_ptr->valid |= PNG_INFO_IDAT; } #endif #ifdef PNG_WRITE_SUPPORTED void PNGAPI -png_set_compression_buffer_size(png_structp png_ptr, png_uint_32 size) +png_set_compression_buffer_size(png_structp png_ptr, + png_uint_32 size) { if (png_ptr == NULL) return; @@ -1227,16 +1239,17 @@ png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask) #ifndef PNG_1_0_X #ifdef PNG_ASSEMBLER_CODE_SUPPORTED -/* function was added to libpng 1.2.0 and should always exist by default */ +/* Function was added to libpng 1.2.0 and should always exist by default */ void PNGAPI png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags) { /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ if (png_ptr != NULL) png_ptr->asm_flags = 0; + asm_flags = asm_flags; /* Quiet the compiler */ } -/* this function was added to libpng 1.2.0 */ +/* This function was added to libpng 1.2.0 */ void PNGAPI png_set_mmx_thresholds (png_structp png_ptr, png_byte mmx_bitdepth_threshold, @@ -1245,22 +1258,26 @@ png_set_mmx_thresholds (png_structp png_ptr, /* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */ if (png_ptr == NULL) return; + /* Quiet the compiler */ + mmx_bitdepth_threshold = mmx_bitdepth_threshold; + mmx_rowbytes_threshold = mmx_rowbytes_threshold; } #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED -/* this function was added to libpng 1.2.6 */ +/* This function was added to libpng 1.2.6 */ void PNGAPI png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max) { - /* Images with dimensions larger than these limits will be - * rejected by png_set_IHDR(). To accept any PNG datastream - * regardless of dimensions, set both limits to 0x7ffffffL. - */ - if(png_ptr == NULL) return; - png_ptr->user_width_max = user_width_max; - png_ptr->user_height_max = user_height_max; + /* Images with dimensions larger than these limits will be + * rejected by png_set_IHDR(). To accept any PNG datastream + * regardless of dimensions, set both limits to 0x7ffffffL. + */ + if (png_ptr == NULL) + return; + png_ptr->user_width_max = user_width_max; + png_ptr->user_height_max = user_height_max; } #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ diff --git a/src/3rdparty/libpng/pngtest.c b/src/3rdparty/libpng/pngtest.c index 60980c2..4142fd8 100644 --- a/src/3rdparty/libpng/pngtest.c +++ b/src/3rdparty/libpng/pngtest.c @@ -1,12 +1,15 @@ /* pngtest.c - a simple test program to test libpng * - * Last changed in libpng 1.2.27 - [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Last changed in libpng 1.2.37 [June 4, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This program reads in a PNG image, writes it out again, and then * compares the two files. If the files are identical, this shows that * the basic chunk handling, filtering, and (de)compression code is working @@ -37,7 +40,7 @@ # include # include # define READFILE(file, data, length, check) \ - if (ReadFile(file, data, length, &check,NULL)) check = 0 + if (ReadFile(file, data, length, &check, NULL)) check = 0 # define WRITEFILE(file, data, length, check)) \ if (WriteFile(file, data, length, &check, NULL)) check = 0 # define FCLOSE(file) CloseHandle(file) @@ -45,9 +48,9 @@ # include # include # define READFILE(file, data, length, check) \ - check=(png_size_t)fread(data,(png_size_t)1,length,file) + check=(png_size_t)fread(data, (png_size_t)1, length, file) # define WRITEFILE(file, data, length, check) \ - check=(png_size_t)fwrite(data,(png_size_t)1, length, file) + check=(png_size_t)fwrite(data, (png_size_t)1, length, file) # define FCLOSE(file) fclose(file) #endif @@ -65,7 +68,7 @@ #endif #if !PNG_DEBUG -# define SINGLE_ROWBUF_ALLOC /* makes buffer overruns easier to nail */ +# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */ #endif /* Turn on CPU timing @@ -82,9 +85,9 @@ static float t_start, t_stop, t_decode, t_encode, t_misc; #endif #if defined(PNG_TIME_RFC1123_SUPPORTED) -#define PNG_tIME_STRING_LENGTH 30 -static int tIME_chunk_present=0; -static char tIME_string[PNG_tIME_STRING_LENGTH] = "no tIME chunk present in file"; +#define PNG_tIME_STRING_LENGTH 29 +static int tIME_chunk_present = 0; +static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present"; #endif static int verbose = 0; @@ -95,14 +98,9 @@ int test_one_file PNGARG((PNG_CONST char *inname, PNG_CONST char *outname)); #include #endif -/* defined so I can write to a file on gui/windowing platforms */ +/* Defined so I can write to a file on gui/windowing platforms */ /* #define STDERR stderr */ -#define STDERR stdout /* for DOS */ - -/* example of using row callbacks to make a simple progress meter */ -static int status_pass=1; -static int status_dots_requested=0; -static int status_dots=1; +#define STDERR stdout /* For DOS */ /* In case a system header (e.g., on AIX) defined jmpbuf */ #ifdef jmpbuf @@ -114,6 +112,11 @@ static int status_dots=1; # define png_jmpbuf(png_ptr) png_ptr->jmpbuf #endif +/* Example of using row callbacks to make a simple progress meter */ +static int status_pass = 1; +static int status_dots_requested = 0; +static int status_dots = 1; + void #ifdef PNG_1_0_X PNGAPI @@ -125,20 +128,21 @@ PNGAPI #endif read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) { - if(png_ptr == NULL || row_number > PNG_UINT_31_MAX) return; - if(status_pass != pass) - { - fprintf(stdout,"\n Pass %d: ",pass); - status_pass = pass; - status_dots = 31; - } - status_dots--; - if(status_dots == 0) - { - fprintf(stdout, "\n "); - status_dots=30; - } - fprintf(stdout, "r"); + if (png_ptr == NULL || row_number > PNG_UINT_31_MAX) + return; + if (status_pass != pass) + { + fprintf(stdout, "\n Pass %d: ", pass); + status_pass = pass; + status_dots = 31; + } + status_dots--; + if (status_dots == 0) + { + fprintf(stdout, "\n "); + status_dots=30; + } + fprintf(stdout, "r"); } void @@ -152,15 +156,17 @@ PNGAPI #endif write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass) { - if(png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) return; - fprintf(stdout, "w"); + if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7) + return; + fprintf(stdout, "w"); } #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) /* Example of using user transform callback (we don't transform anything, - but merely examine the row filters. We set this to 256 rather than - 5 in case illegal filter values are present.) */ + * but merely examine the row filters. We set this to 256 rather than + * 5 in case illegal filter values are present.) + */ static png_uint_32 filters_used[256]; void #ifdef PNG_1_0_X @@ -173,14 +179,15 @@ PNGAPI #endif count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data) { - if(png_ptr != NULL && row_info != NULL) - ++filters_used[*(data-1)]; + if (png_ptr != NULL && row_info != NULL) + ++filters_used[*(data - 1)]; } #endif #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -/* example of using user transform callback (we don't transform anything, - but merely count the zero samples) */ +/* Example of using user transform callback (we don't transform anything, + * but merely count the zero samples) + */ static png_uint_32 zero_samples; @@ -196,9 +203,9 @@ PNGAPI count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) { png_bytep dp = data; - if(png_ptr == NULL)return; + if (png_ptr == NULL)return; - /* contents of row_info: + /* Contents of row_info: * png_uint_32 width width of row * png_uint_32 rowbytes number of bytes in row * png_byte color_type color type of pixels @@ -207,74 +214,81 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data) * png_byte pixel_depth bits per pixel (depth*channels) */ + /* Counts the number of zero samples (or zero pixels if color_type is 3 */ - /* counts the number of zero samples (or zero pixels if color_type is 3 */ - - if(row_info->color_type == 0 || row_info->color_type == 3) + if (row_info->color_type == 0 || row_info->color_type == 3) { - int pos=0; + int pos = 0; png_uint_32 n, nstop; - for (n=0, nstop=row_info->width; nwidth; nbit_depth == 1) + if (row_info->bit_depth == 1) { - if(((*dp << pos++ ) & 0x80) == 0) zero_samples++; - if(pos == 8) + if (((*dp << pos++ ) & 0x80) == 0) + zero_samples++; + if (pos == 8) { pos = 0; dp++; } } - if(row_info->bit_depth == 2) + if (row_info->bit_depth == 2) { - if(((*dp << (pos+=2)) & 0xc0) == 0) zero_samples++; - if(pos == 8) + if (((*dp << (pos+=2)) & 0xc0) == 0) + zero_samples++; + if (pos == 8) { pos = 0; dp++; } } - if(row_info->bit_depth == 4) + if (row_info->bit_depth == 4) { - if(((*dp << (pos+=4)) & 0xf0) == 0) zero_samples++; - if(pos == 8) + if (((*dp << (pos+=4)) & 0xf0) == 0) + zero_samples++; + if (pos == 8) { pos = 0; dp++; } } - if(row_info->bit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) + if (row_info->bit_depth == 8) + if (*dp++ == 0) + zero_samples++; + if (row_info->bit_depth == 16) { - if((*dp | *(dp+1)) == 0) zero_samples++; + if ((*dp | *(dp+1)) == 0) + zero_samples++; dp+=2; } } } - else /* other color types */ + else /* Other color types */ { png_uint_32 n, nstop; int channel; int color_channels = row_info->channels; - if(row_info->color_type > 3)color_channels--; + if (row_info->color_type > 3)color_channels--; - for (n=0, nstop=row_info->width; nwidth; nbit_depth == 8) - if(*dp++ == 0) zero_samples++; - if(row_info->bit_depth == 16) + if (row_info->bit_depth == 8) + if (*dp++ == 0) + zero_samples++; + if (row_info->bit_depth == 16) { - if((*dp | *(dp+1)) == 0) zero_samples++; + if ((*dp | *(dp+1)) == 0) + zero_samples++; dp+=2; } } - if(row_info->color_type > 3) + if (row_info->color_type > 3) { dp++; - if(row_info->bit_depth == 16)dp++; + if (row_info->bit_depth == 16) + dp++; } } } @@ -285,12 +299,13 @@ static int wrote_question = 0; #if defined(PNG_NO_STDIO) /* START of code to validate stdio-free compilation */ -/* These copies of the default read/write functions come from pngrio.c and */ -/* pngwio.c. They allow "don't include stdio" testing of the library. */ -/* This is the function that does the actual reading of data. If you are - not reading from a standard C stream, you should create a replacement - read_data function and use it at run time with png_set_read_fn(), rather - than changing the library. */ +/* These copies of the default read/write functions come from pngrio.c and + * pngwio.c. They allow "don't include stdio" testing of the library. + * This is the function that does the actual reading of data. If you are + * not reading from a standard C stream, you should create a replacement + * read_data function and use it at run time with png_set_read_fn(), rather + * than changing the library. + */ #ifndef USE_FAR_KEYWORD static void @@ -309,7 +324,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) } } #else -/* this is the model-independent version. Since the standard I/O library +/* This is the model-independent version. Since the standard I/O library can't handle far buffers in the medium and small models, we have to copy the data. */ @@ -341,8 +356,8 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) { read = MIN(NEAR_BUF_SIZE, remaining); READFILE(io_ptr, buf, 1, err); - png_memcpy(data, buf, read); /* copy far buffer to near buffer */ - if(err != read) + png_memcpy(data, buf, read); /* Copy far buffer to near buffer */ + if (err != read) break; else check += err; @@ -352,9 +367,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) while (remaining != 0); } if (check != length) - { png_error(png_ptr, "read Error"); - } } #endif /* USE_FAR_KEYWORD */ @@ -362,19 +375,16 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, png_size_t length) static void pngtest_flush(png_structp png_ptr) { -#if !defined(_WIN32_WCE) - png_FILE_p io_ptr; - io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); -#endif + /* Do nothing; fflush() is said to be just a waste of energy. */ + png_ptr = png_ptr; /* Stifle compiler warning */ } #endif /* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ + * not writing to a standard C stream, you should create a replacement + * write_data function and use it at run time with png_set_write_fn(), rather + * than changing the library. + */ #ifndef USE_FAR_KEYWORD static void pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) @@ -388,7 +398,7 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) } } #else -/* this is the model-independent version. Since the standard I/O library +/* This is the model-independent version. Since the standard I/O library can't handle far buffers in the medium and small models, we have to copy the data. */ @@ -419,7 +429,7 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) do { written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ + png_memcpy(buf, data, written); /* Copy far buffer to near buffer */ WRITEFILE(io_ptr, buf, written, err); if (err != written) break; @@ -436,8 +446,6 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, png_size_t length) } } #endif /* USE_FAR_KEYWORD */ -#endif /* PNG_NO_STDIO */ -/* END of code to validate stdio-free compilation */ /* This function is called when there is a warning, but the library thinks * it can continue anyway. Replacement functions don't have to do anything @@ -463,20 +471,24 @@ pngtest_error(png_structp png_ptr, png_const_charp message) { pngtest_warning(png_ptr, message); /* We can return because png_error calls the default handler, which is - * actually OK in this case. */ + * actually OK in this case. + */ } +#endif /* PNG_NO_STDIO */ +/* END of code to validate stdio-free compilation */ /* START of code to validate memory allocation and deallocation */ #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG /* Allocate memory. For reasonable files, size should never exceed - 64K. However, zlib may allocate more then 64K if you don't tell - it not to. See zconf.h and png.h for more information. zlib does - need to allocate exactly 64K, so whatever you call here must - have the ability to do that. - - This piece of code can be compiled to validate max 64K allocations - by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. */ + * 64K. However, zlib may allocate more then 64K if you don't tell + * it not to. See zconf.h and png.h for more information. zlib does + * need to allocate exactly 64K, so whatever you call here must + * have the ability to do that. + * + * This piece of code can be compiled to validate max 64K allocations + * by setting MAXSEG_64K in zlib zconf.h *or* PNG_MAX_MALLOC_64K. + */ typedef struct memory_information { png_uint_32 size; @@ -499,7 +511,8 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size) { /* png_malloc has already tested for NULL; png_create_struct calls - png_debug_malloc directly, with png_ptr == NULL which is OK */ + * png_debug_malloc directly, with png_ptr == NULL which is OK + */ if (size == 0) return (NULL); @@ -511,7 +524,7 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size) memory_infop pinfo; png_set_mem_fn(png_ptr, NULL, NULL, NULL); pinfo = (memory_infop)png_malloc(png_ptr, - (png_uint_32)png_sizeof (*pinfo)); + (png_uint_32)png_sizeof(*pinfo)); pinfo->size = size; current_allocation += size; total_allocation += size; @@ -520,8 +533,9 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size) maximum_allocation = current_allocation; pinfo->pointer = (png_voidp)png_malloc(png_ptr, size); /* Restore malloc_fn and free_fn */ - png_set_mem_fn(png_ptr, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, - (png_free_ptr)png_debug_free); + png_set_mem_fn(png_ptr, + png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, + (png_free_ptr)png_debug_free); if (size != 0 && pinfo->pointer == NULL) { current_allocation -= size; @@ -533,9 +547,9 @@ png_debug_malloc(png_structp png_ptr, png_uint_32 size) pinformation = pinfo; /* Make sure the caller isn't assuming zeroed memory. */ png_memset(pinfo->pointer, 0xdd, pinfo->size); - if(verbose) - printf("png_malloc %lu bytes at %x\n",(unsigned long)size, - pinfo->pointer); + if (verbose) + printf("png_malloc %lu bytes at %x\n", (unsigned long)size, + pinfo->pointer); return (png_voidp)(pinfo->pointer); } } @@ -570,7 +584,7 @@ png_debug_free(png_structp png_ptr, png_voidp ptr) the memory that is to be freed. */ png_memset(ptr, 0x55, pinfo->size); png_free_default(png_ptr, pinfo); - pinfo=NULL; + pinfo = NULL; break; } if (pinfo->next == NULL) @@ -583,14 +597,82 @@ png_debug_free(png_structp png_ptr, png_voidp ptr) } /* Finally free the data. */ - if(verbose) - printf("Freeing %x\n",ptr); + if (verbose) + printf("Freeing %x\n", ptr); png_free_default(png_ptr, ptr); - ptr=NULL; + ptr = NULL; } #endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ /* END of code to test memory allocation/deallocation */ + +/* Demonstration of user chunk support of the sTER and vpAg chunks */ +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + +/* (sTER is a public chunk not yet known by libpng. vpAg is a private +chunk used in ImageMagick to store "virtual page" size). */ + +static png_uint_32 user_chunk_data[4]; + + /* 0: sTER mode + 1 + * 1: vpAg width + * 2: vpAg height + * 3: vpAg units + */ + +static int read_user_chunk_callback(png_struct *png_ptr, + png_unknown_chunkp chunk) +{ + png_uint_32 + *my_user_chunk_data; + + /* Return one of the following: + * return (-n); chunk had an error + * return (0); did not recognize + * return (n); success + * + * The unknown chunk structure contains the chunk data: + * png_byte name[5]; + * png_byte *data; + * png_size_t size; + * + * Note that libpng has already taken care of the CRC handling. + */ + + if (chunk->name[0] == 115 && chunk->name[1] == 84 && /* s T */ + chunk->name[2] == 69 && chunk->name[3] == 82) /* E R */ + { + /* Found sTER chunk */ + if (chunk->size != 1) + return (-1); /* Error return */ + if (chunk->data[0] != 0 && chunk->data[0] != 1) + return (-1); /* Invalid mode */ + my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr); + my_user_chunk_data[0]=chunk->data[0]+1; + return (1); + } + + if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */ + chunk->name[2] != 65 || chunk->name[3] != 103) /* A g */ + return (0); /* Did not recognize */ + + /* Found ImageMagick vpAg chunk */ + + if (chunk->size != 9) + return (-1); /* Error return */ + + my_user_chunk_data=(png_uint_32 *) png_get_user_chunk_ptr(png_ptr); + + my_user_chunk_data[1]=png_get_uint_31(png_ptr, chunk->data); + my_user_chunk_data[2]=png_get_uint_31(png_ptr, chunk->data + 4); + my_user_chunk_data[3]=(png_uint_32)chunk->data[8]; + + return (1); + +} +#endif +/* END of code to demonstrate user chunk support */ + /* Test one file */ int test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) @@ -649,30 +731,48 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) return (1); } - png_debug(0, "Allocating read and write structures\n"); + png_debug(0, "Allocating read and write structures"); #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + read_ptr = + png_create_read_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); #else - read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + read_ptr = + png_create_read_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL); #endif +#if defined(PNG_NO_STDIO) png_set_error_fn(read_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); +#endif + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + user_chunk_data[0] = 0; + user_chunk_data[1] = 0; + user_chunk_data[2] = 0; + user_chunk_data[3] = 0; + png_set_read_user_chunk_fn(read_ptr, user_chunk_data, + read_user_chunk_callback); + +#endif #ifdef PNG_WRITE_SUPPORTED #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG - write_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + write_ptr = + png_create_write_struct_2(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL, png_voidp_NULL, (png_malloc_ptr)png_debug_malloc, (png_free_ptr)png_debug_free); #else - write_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, + write_ptr = + png_create_write_struct(PNG_LIBPNG_VER_STRING, png_voidp_NULL, png_error_ptr_NULL, png_error_ptr_NULL); #endif +#if defined(PNG_NO_STDIO) png_set_error_fn(write_ptr, (png_voidp)inname, pngtest_error, pngtest_warning); #endif - png_debug(0, "Allocating read_info, write_info and end_info structures\n"); +#endif + png_debug(0, "Allocating read_info, write_info and end_info structures"); read_info_ptr = png_create_info_struct(read_ptr); end_info_ptr = png_create_info_struct(read_ptr); #ifdef PNG_WRITE_SUPPORTED @@ -681,7 +781,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #endif #ifdef PNG_SETJMP_SUPPORTED - png_debug(0, "Setting jmpbuf for read struct\n"); + png_debug(0, "Setting jmpbuf for read struct"); #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) #else @@ -690,6 +790,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) { fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname); png_free(read_ptr, row_buf); + row_buf = NULL; png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); #ifdef PNG_WRITE_SUPPORTED png_destroy_info_struct(write_ptr, &write_end_info_ptr); @@ -700,11 +801,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) return (1); } #ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(read_ptr),jmpbuf,png_sizeof(jmp_buf)); + png_memcpy(png_jmpbuf(read_ptr), jmpbuf, png_sizeof(jmp_buf)); #endif #ifdef PNG_WRITE_SUPPORTED - png_debug(0, "Setting jmpbuf for write struct\n"); + png_debug(0, "Setting jmpbuf for write struct"); #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) #else @@ -722,12 +823,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) return (1); } #ifdef USE_FAR_KEYWORD - png_memcpy(png_jmpbuf(write_ptr),jmpbuf,png_sizeof(jmp_buf)); + png_memcpy(png_jmpbuf(write_ptr), jmpbuf, png_sizeof(jmp_buf)); #endif #endif #endif - png_debug(0, "Initializing input and output streams\n"); + png_debug(0, "Initializing input and output streams"); #if !defined(PNG_NO_STDIO) png_init_io(read_ptr, fpin); # ifdef PNG_WRITE_SUPPORTED @@ -744,7 +845,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) # endif # endif #endif - if(status_dots_requested == 1) + if (status_dots_requested == 1) { #ifdef PNG_WRITE_SUPPORTED png_set_write_status_fn(write_ptr, write_row_callback); @@ -761,14 +862,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) { - int i; - for(i=0; i<256; i++) - filters_used[i]=0; - png_set_read_user_transform_fn(read_ptr, count_filters); + int i; + for (i = 0; i<256; i++) + filters_used[i] = 0; + png_set_read_user_transform_fn(read_ptr, count_filters); } #endif #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) - zero_samples=0; + zero_samples = 0; png_set_write_user_transform_fn(write_ptr, count_zero_samples); #endif @@ -787,10 +888,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_bytep_NULL, 0); #endif - png_debug(0, "Reading info struct\n"); + png_debug(0, "Reading info struct"); png_read_info(read_ptr, read_info_ptr); - png_debug(0, "Transferring info struct\n"); + png_debug(0, "Transferring info struct"); { int interlace_type, compression_type, filter_type; @@ -823,9 +924,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_fixed_point gamma; if (png_get_gAMA_fixed(read_ptr, read_info_ptr, &gamma)) - { png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma); - } } #endif #else /* Use floating point versions */ @@ -847,13 +946,11 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) double gamma; if (png_get_gAMA(read_ptr, read_info_ptr, &gamma)) - { png_set_gAMA(write_ptr, write_info_ptr, gamma); - } } #endif -#endif /* floating point */ -#endif /* fixed point */ +#endif /* Floating point */ +#endif /* Fixed point */ #if defined(PNG_iCCP_SUPPORTED) { png_charp name; @@ -874,9 +971,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int intent; if (png_get_sRGB(read_ptr, read_info_ptr, &intent)) - { png_set_sRGB(write_ptr, write_info_ptr, intent); - } } #endif { @@ -884,9 +979,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int num_palette; if (png_get_PLTE(read_ptr, read_info_ptr, &palette, &num_palette)) - { png_set_PLTE(write_ptr, write_info_ptr, palette, num_palette); - } } #if defined(PNG_bKGD_SUPPORTED) { @@ -903,9 +996,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_uint_16p hist; if (png_get_hIST(read_ptr, read_info_ptr, &hist)) - { png_set_hIST(write_ptr, write_info_ptr, hist); - } } #endif #if defined(PNG_oFFs_SUPPORTED) @@ -913,7 +1004,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_int_32 offset_x, offset_y; int unit_type; - if (png_get_oFFs(read_ptr, read_info_ptr,&offset_x,&offset_y,&unit_type)) + if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y, + &unit_type)) { png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type); } @@ -940,9 +1032,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int unit_type; if (png_get_pHYs(read_ptr, read_info_ptr, &res_x, &res_y, &unit_type)) - { png_set_pHYs(write_ptr, write_info_ptr, res_x, res_y, unit_type); - } } #endif #if defined(PNG_sBIT_SUPPORTED) @@ -950,9 +1040,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_color_8p sig_bit; if (png_get_sBIT(read_ptr, read_info_ptr, &sig_bit)) - { png_set_sBIT(write_ptr, write_info_ptr, sig_bit); - } } #endif #if defined(PNG_sCAL_SUPPORTED) @@ -989,7 +1077,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) if (png_get_text(read_ptr, read_info_ptr, &text_ptr, &num_text) > 0) { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); + png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text); png_set_text(write_ptr, write_info_ptr, text_ptr, num_text); } } @@ -1002,13 +1090,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) { png_set_tIME(write_ptr, write_info_ptr, mod_time); #if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_memcpy instead of "=" because the string - pointed to by png_convert_to_rfc1123() gets free'ed before - we use it */ + /* We have to use png_memcpy instead of "=" because the string + * pointed to by png_convert_to_rfc1123() gets free'ed before + * we use it. + */ png_memcpy(tIME_string, - png_convert_to_rfc1123(read_ptr, mod_time), + png_convert_to_rfc1123(read_ptr, mod_time), png_sizeof(tIME_string)); - tIME_string[png_sizeof(tIME_string)-1] = '\0'; + tIME_string[png_sizeof(tIME_string) - 1] = '\0'; tIME_chunk_present++; #endif /* PNG_TIME_RFC1123_SUPPORTED */ } @@ -1026,13 +1115,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) int sample_max = (1 << read_info_ptr->bit_depth); /* libpng doesn't reject a tRNS chunk with out-of-range samples */ if (!((read_info_ptr->color_type == PNG_COLOR_TYPE_GRAY && - (int)trans_values->gray > sample_max) || - (read_info_ptr->color_type == PNG_COLOR_TYPE_RGB && - ((int)trans_values->red > sample_max || - (int)trans_values->green > sample_max || - (int)trans_values->blue > sample_max)))) - png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans, - trans_values); + (int)trans_values->gray > sample_max) || + (read_info_ptr->color_type == PNG_COLOR_TYPE_RGB && + ((int)trans_values->red > sample_max || + (int)trans_values->green > sample_max || + (int)trans_values->blue > sample_max)))) + png_set_tRNS(write_ptr, write_info_ptr, trans, num_trans, + trans_values); } } #endif @@ -1046,9 +1135,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_size_t i; png_set_unknown_chunks(write_ptr, write_info_ptr, unknowns, num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_info_ptr are wrong because we - haven't written anything yet */ + /* Copy the locations from the read_info_ptr. The automatically + * generated locations in write_info_ptr are wrong because we + * haven't written anything yet. + */ for (i = 0; i < (png_size_t)num_unknowns; i++) png_set_unknown_chunk_location(write_ptr, write_info_ptr, i, unknowns[i].location); @@ -1057,21 +1147,55 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #endif #ifdef PNG_WRITE_SUPPORTED - png_debug(0, "\nWriting info struct\n"); + png_debug(0, "Writing info struct"); /* If we wanted, we could write info in two steps: - png_write_info_before_PLTE(write_ptr, write_info_ptr); + * png_write_info_before_PLTE(write_ptr, write_info_ptr); */ png_write_info(write_ptr, write_info_ptr); + +#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) + if (user_chunk_data[0] != 0) + { + png_byte png_sTER[5] = {115, 84, 69, 82, '\0'}; + + unsigned char + ster_chunk_data[1]; + + if (verbose) + fprintf(STDERR, "\n stereo mode = %lu\n", + (unsigned long)(user_chunk_data[0] - 1)); + ster_chunk_data[0]=(unsigned char)(user_chunk_data[0] - 1); + png_write_chunk(write_ptr, png_sTER, ster_chunk_data, 1); + } + if (user_chunk_data[1] != 0 || user_chunk_data[2] != 0) + { + png_byte png_vpAg[5] = {118, 112, 65, 103, '\0'}; + + unsigned char + vpag_chunk_data[9]; + + if (verbose) + fprintf(STDERR, " vpAg = %lu x %lu, units = %lu\n", + (unsigned long)user_chunk_data[1], + (unsigned long)user_chunk_data[2], + (unsigned long)user_chunk_data[3]); + png_save_uint_32(vpag_chunk_data, user_chunk_data[1]); + png_save_uint_32(vpag_chunk_data + 4, user_chunk_data[2]); + vpag_chunk_data[8] = (unsigned char)(user_chunk_data[3] & 0xff); + png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9); + } + +#endif #endif #ifdef SINGLE_ROWBUF_ALLOC - png_debug(0, "\nAllocating row buffer..."); + png_debug(0, "Allocating row buffer..."); row_buf = (png_bytep)png_malloc(read_ptr, png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug1(0, "0x%08lx\n\n", (unsigned long)row_buf); + png_debug1(0, "0x%08lx", (unsigned long)row_buf); #endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(0, "Writing row data\n"); + png_debug(0, "Writing row data"); #if defined(PNG_READ_INTERLACING_SUPPORTED) || \ defined(PNG_WRITE_INTERLACING_SUPPORTED) @@ -1080,7 +1204,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_set_interlace_handling(write_ptr); # endif #else - num_pass=1; + num_pass = 1; #endif #ifdef PNGTEST_TIMING @@ -1090,14 +1214,14 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #endif for (pass = 0; pass < num_pass; pass++) { - png_debug1(0, "Writing row data for pass %d\n",pass); + png_debug1(0, "Writing row data for pass %d", pass); for (y = 0; y < height; y++) { #ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "\nAllocating row buffer (pass %d, y = %ld)...", pass,y); + png_debug2(0, "Allocating row buffer (pass %d, y = %ld)...", pass, y); row_buf = (png_bytep)png_malloc(read_ptr, png_get_rowbytes(read_ptr, read_info_ptr)); - png_debug2(0, "0x%08lx (%ld bytes)\n", (unsigned long)row_buf, + png_debug2(0, "0x%08lx (%ld bytes)", (unsigned long)row_buf, png_get_rowbytes(read_ptr, read_info_ptr)); #endif /* !SINGLE_ROWBUF_ALLOC */ png_read_rows(read_ptr, (png_bytepp)&row_buf, png_bytepp_NULL, 1); @@ -1117,8 +1241,9 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #endif /* PNG_WRITE_SUPPORTED */ #ifndef SINGLE_ROWBUF_ALLOC - png_debug2(0, "Freeing row buffer (pass %d, y = %ld)\n\n", pass, y); + png_debug2(0, "Freeing row buffer (pass %d, y = %ld)", pass, y); png_free(read_ptr, row_buf); + row_buf = NULL; #endif /* !SINGLE_ROWBUF_ALLOC */ } } @@ -1130,7 +1255,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_free_data(write_ptr, write_info_ptr, PNG_FREE_UNKN, -1); #endif - png_debug(0, "Reading and writing end_info data\n"); + png_debug(0, "Reading and writing end_info data"); png_read_end(read_ptr, end_info_ptr); #if defined(PNG_TEXT_SUPPORTED) @@ -1140,7 +1265,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) if (png_get_text(read_ptr, end_info_ptr, &text_ptr, &num_text) > 0) { - png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks\n", num_text); + png_debug1(0, "Handling %d iTXt/tEXt/zTXt chunks", num_text); png_set_text(write_ptr, write_end_info_ptr, text_ptr, num_text); } } @@ -1153,13 +1278,13 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) { png_set_tIME(write_ptr, write_end_info_ptr, mod_time); #if defined(PNG_TIME_RFC1123_SUPPORTED) - /* we have to use png_memcpy instead of "=" because the string + /* We have to use png_memcpy instead of "=" because the string pointed to by png_convert_to_rfc1123() gets free'ed before we use it */ png_memcpy(tIME_string, png_convert_to_rfc1123(read_ptr, mod_time), png_sizeof(tIME_string)); - tIME_string[png_sizeof(tIME_string)-1] = '\0'; + tIME_string[png_sizeof(tIME_string) - 1] = '\0'; tIME_chunk_present++; #endif /* PNG_TIME_RFC1123_SUPPORTED */ } @@ -1176,9 +1301,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) png_size_t i; png_set_unknown_chunks(write_ptr, write_end_info_ptr, unknowns, num_unknowns); - /* copy the locations from the read_info_ptr. The automatically - generated locations in write_end_info_ptr are wrong because we - haven't written the end_info yet */ + /* Copy the locations from the read_info_ptr. The automatically + * generated locations in write_end_info_ptr are wrong because we + * haven't written the end_info yet. + */ for (i = 0; i < (png_size_t)num_unknowns; i++) png_set_unknown_chunk_location(write_ptr, write_end_info_ptr, i, unknowns[i].location); @@ -1190,36 +1316,36 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) #endif #ifdef PNG_EASY_ACCESS_SUPPORTED - if(verbose) + if (verbose) { png_uint_32 iwidth, iheight; iwidth = png_get_image_width(write_ptr, write_info_ptr); iheight = png_get_image_height(write_ptr, write_info_ptr); - fprintf(STDERR, "Image width = %lu, height = %lu\n", + fprintf(STDERR, "\n Image width = %lu, height = %lu\n", (unsigned long)iwidth, (unsigned long)iheight); } #endif - png_debug(0, "Destroying data structs\n"); + png_debug(0, "Destroying data structs"); #ifdef SINGLE_ROWBUF_ALLOC - png_debug(1, "destroying row_buf for read_ptr\n"); + png_debug(1, "destroying row_buf for read_ptr"); png_free(read_ptr, row_buf); - row_buf=NULL; + row_buf = NULL; #endif /* SINGLE_ROWBUF_ALLOC */ - png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr\n"); + png_debug(1, "destroying read_ptr, read_info_ptr, end_info_ptr"); png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr); #ifdef PNG_WRITE_SUPPORTED - png_debug(1, "destroying write_end_info_ptr\n"); + png_debug(1, "destroying write_end_info_ptr"); png_destroy_info_struct(write_ptr, &write_end_info_ptr); - png_debug(1, "destroying write_ptr, write_info_ptr\n"); + png_debug(1, "destroying write_ptr, write_info_ptr"); png_destroy_write_struct(&write_ptr, &write_info_ptr); #endif - png_debug(0, "Destruction complete.\n"); + png_debug(0, "Destruction complete."); FCLOSE(fpin); FCLOSE(fpout); - png_debug(0, "Opening files for comparison\n"); + png_debug(0, "Opening files for comparison"); #if defined(_WIN32_WCE) MultiByteToWideChar(CP_ACP, 0, inname, -1, path, MAX_PATH); if ((fpin = CreateFile(path, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL)) == INVALID_HANDLE_VALUE) @@ -1243,28 +1369,28 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) return (1); } - for(;;) + for (;;) { png_size_t num_in, num_out; - READFILE(fpin, inbuf, 1, num_in); - READFILE(fpout, outbuf, 1, num_out); + READFILE(fpin, inbuf, 1, num_in); + READFILE(fpout, outbuf, 1, num_out); if (num_in != num_out) { fprintf(STDERR, "\nFiles %s and %s are of a different size\n", inname, outname); - if(wrote_question == 0) + if (wrote_question == 0) { fprintf(STDERR, " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); + inname, PNG_ZBUF_SIZE); fprintf(STDERR, "\n filtering heuristic (libpng default), compression"); fprintf(STDERR, " level (zlib default),\n and zlib version (%s)?\n\n", ZLIB_VERSION); - wrote_question=1; + wrote_question = 1; } FCLOSE(fpin); FCLOSE(fpout); @@ -1277,17 +1403,17 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) if (png_memcmp(inbuf, outbuf, num_in)) { fprintf(STDERR, "\nFiles %s and %s are different\n", inname, outname); - if(wrote_question == 0) + if (wrote_question == 0) { fprintf(STDERR, " Was %s written with the same maximum IDAT chunk size (%d bytes),", - inname,PNG_ZBUF_SIZE); + inname, PNG_ZBUF_SIZE); fprintf(STDERR, "\n filtering heuristic (libpng default), compression"); fprintf(STDERR, " level (zlib default),\n and zlib version (%s)?\n\n", ZLIB_VERSION); - wrote_question=1; + wrote_question = 1; } FCLOSE(fpin); FCLOSE(fpout); @@ -1301,7 +1427,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname) return (0); } -/* input and output filenames */ +/* Input and output filenames */ #ifdef RISCOS static PNG_CONST char *inname = "pngtest/png"; static PNG_CONST char *outname = "pngout/png"; @@ -1316,23 +1442,24 @@ main(int argc, char *argv[]) int multiple = 0; int ierror = 0; - fprintf(STDERR, "Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); + fprintf(STDERR, "\n Testing libpng version %s\n", PNG_LIBPNG_VER_STRING); fprintf(STDERR, " with zlib version %s\n", ZLIB_VERSION); - fprintf(STDERR,"%s",png_get_copyright(NULL)); + fprintf(STDERR, "%s", png_get_copyright(NULL)); /* Show the version of libpng used in building the library */ - fprintf(STDERR," library (%lu):%s", + fprintf(STDERR, " library (%lu):%s", (unsigned long)png_access_version_number(), png_get_header_version(NULL)); /* Show the version of libpng used in building the application */ - fprintf(STDERR," pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, + fprintf(STDERR, " pngtest (%lu):%s", (unsigned long)PNG_LIBPNG_VER, PNG_HEADER_VERSION_STRING); - fprintf(STDERR," png_sizeof(png_struct)=%ld, png_sizeof(png_info)=%ld\n", + fprintf(STDERR, " sizeof(png_struct)=%ld, sizeof(png_info)=%ld\n", (long)png_sizeof(png_struct), (long)png_sizeof(png_info)); /* Do some consistency checking on the memory allocation settings, I'm - not sure this matters, but it is nice to know, the first of these - tests should be impossible because of the way the macros are set - in pngconf.h */ + * not sure this matters, but it is nice to know, the first of these + * tests should be impossible because of the way the macros are set + * in pngconf.h + */ #if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K) fprintf(STDERR, " NOTE: Zlib compiled for max 64k, libpng not\n"); #endif @@ -1377,10 +1504,10 @@ main(int argc, char *argv[]) } } - if (!multiple && argc == 3+verbose) - outname = argv[2+verbose]; + if (!multiple && argc == 3 + verbose) + outname = argv[2 + verbose]; - if ((!multiple && argc > 3+verbose) || (multiple && argc < 2)) + if ((!multiple && argc > 3 + verbose) || (multiple && argc < 2)) { fprintf(STDERR, "usage: %s [infile.png] [outfile.png]\n\t%s -m {infile.png}\n", @@ -1404,7 +1531,7 @@ main(int argc, char *argv[]) int k; #endif int kerror; - fprintf(STDERR, "Testing %s:",argv[i]); + fprintf(STDERR, "\n Testing %s:", argv[i]); kerror = test_one_file(argv[i], outname); if (kerror == 0) { @@ -1415,14 +1542,14 @@ main(int argc, char *argv[]) fprintf(STDERR, " PASS\n"); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - for (k=0; k<256; k++) - if(filters_used[k]) + for (k = 0; k<256; k++) + if (filters_used[k]) fprintf(STDERR, " Filter %d was used %lu times\n", - k,(unsigned long)filters_used[k]); + k, (unsigned long)filters_used[k]); #endif #if defined(PNG_TIME_RFC1123_SUPPORTED) - if(tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n",tIME_string); + if (tIME_chunk_present != 0) + fprintf(STDERR, " tIME = %s\n", tIME_string); tIME_chunk_present = 0; #endif /* PNG_TIME_RFC1123_SUPPORTED */ } @@ -1434,7 +1561,7 @@ main(int argc, char *argv[]) #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG if (allocation_now != current_allocation) fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation-allocation_now); + current_allocation - allocation_now); if (current_allocation != 0) { memory_infop pinfo = pinformation; @@ -1443,7 +1570,8 @@ main(int argc, char *argv[]) current_allocation); while (pinfo != NULL) { - fprintf(STDERR, " %lu bytes at %x\n", (unsigned long)pinfo->size, + fprintf(STDERR, " %lu bytes at %x\n", + (unsigned long)pinfo->size, (unsigned int) pinfo->pointer); pinfo = pinfo->next; } @@ -1464,20 +1592,20 @@ main(int argc, char *argv[]) else { int i; - for (i=0; i<3; ++i) + for (i = 0; i<3; ++i) { int kerror; #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG int allocation_now = current_allocation; #endif if (i == 1) status_dots_requested = 1; - else if(verbose == 0)status_dots_requested = 0; + else if (verbose == 0)status_dots_requested = 0; if (i == 0 || verbose == 1 || ierror != 0) - fprintf(STDERR, "Testing %s:",inname); + fprintf(STDERR, "\n Testing %s:", inname); kerror = test_one_file(inname, outname); - if(kerror == 0) + if (kerror == 0) { - if(verbose == 1 || i == 2) + if (verbose == 1 || i == 2) { #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) int k; @@ -1489,28 +1617,29 @@ main(int argc, char *argv[]) fprintf(STDERR, " PASS\n"); #endif #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) - for (k=0; k<256; k++) - if(filters_used[k]) + for (k = 0; k<256; k++) + if (filters_used[k]) fprintf(STDERR, " Filter %d was used %lu times\n", - k,(unsigned long)filters_used[k]); + k, + (unsigned long)filters_used[k]); #endif #if defined(PNG_TIME_RFC1123_SUPPORTED) - if(tIME_chunk_present != 0) - fprintf(STDERR, " tIME = %s\n",tIME_string); + if (tIME_chunk_present != 0) + fprintf(STDERR, " tIME = %s\n", tIME_string); #endif /* PNG_TIME_RFC1123_SUPPORTED */ } } else { - if(verbose == 0 && i != 2) - fprintf(STDERR, "Testing %s:",inname); + if (verbose == 0 && i != 2) + fprintf(STDERR, "\n Testing %s:", inname); fprintf(STDERR, " FAIL\n"); ierror += kerror; } #if defined(PNG_USER_MEM_SUPPORTED) && PNG_DEBUG if (allocation_now != current_allocation) fprintf(STDERR, "MEMORY ERROR: %d bytes lost\n", - current_allocation-allocation_now); + current_allocation - allocation_now); if (current_allocation != 0) { memory_infop pinfo = pinformation; @@ -1519,7 +1648,7 @@ main(int argc, char *argv[]) current_allocation); while (pinfo != NULL) { - fprintf(STDERR," %lu bytes at %x\n", + fprintf(STDERR, " %lu bytes at %x\n", (unsigned long)pinfo->size, (unsigned int)pinfo->pointer); pinfo = pinfo->next; } @@ -1542,22 +1671,22 @@ main(int argc, char *argv[]) t_stop = (float)clock(); t_misc += (t_stop - t_start); t_start = t_stop; - fprintf(STDERR," CPU time used = %.3f seconds", + fprintf(STDERR, " CPU time used = %.3f seconds", (t_misc+t_decode+t_encode)/(float)CLOCKS_PER_SEC); - fprintf(STDERR," (decoding %.3f,\n", + fprintf(STDERR, " (decoding %.3f,\n", t_decode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," encoding %.3f ,", + fprintf(STDERR, " encoding %.3f ,", t_encode/(float)CLOCKS_PER_SEC); - fprintf(STDERR," other %.3f seconds)\n\n", + fprintf(STDERR, " other %.3f seconds)\n\n", t_misc/(float)CLOCKS_PER_SEC); #endif if (ierror == 0) - fprintf(STDERR, "libpng passes test\n"); + fprintf(STDERR, " libpng passes test\n"); else - fprintf(STDERR, "libpng FAILS test\n"); + fprintf(STDERR, " libpng FAILS test\n"); return (int)(ierror != 0); } /* Generate a compiler error if there is an old png.h in the search path. */ -typedef version_1_2_29 your_png_h_is_not_version_1_2_29; +typedef version_1_2_40 your_png_h_is_not_version_1_2_40; diff --git a/src/3rdparty/libpng/pngtrans.c b/src/3rdparty/libpng/pngtrans.c index 1640095..6e1870c 100644 --- a/src/3rdparty/libpng/pngtrans.c +++ b/src/3rdparty/libpng/pngtrans.c @@ -1,47 +1,53 @@ /* pngtrans.c - transforms the data in a row (used by both readers and writers) * - * Last changed in libpng 1.2.17 May 15, 2007 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2007 Glenn Randers-Pehrson + * Last changed in libpng 1.2.36 [May 14, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ #define PNG_INTERNAL #include "png.h" - #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) + #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* turn on BGR-to-RGB mapping */ +/* Turn on BGR-to-RGB mapping */ void PNGAPI png_set_bgr(png_structp png_ptr) { - png_debug(1, "in png_set_bgr\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_bgr"); + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_BGR; } #endif #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* turn on 16 bit byte swapping */ +/* Turn on 16 bit byte swapping */ void PNGAPI png_set_swap(png_structp png_ptr) { - png_debug(1, "in png_set_swap\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_swap"); + if (png_ptr == NULL) + return; if (png_ptr->bit_depth == 16) png_ptr->transformations |= PNG_SWAP_BYTES; } #endif #if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* turn on pixel packing */ +/* Turn on pixel packing */ void PNGAPI png_set_packing(png_structp png_ptr) { - png_debug(1, "in png_set_packing\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_packing"); + if (png_ptr == NULL) + return; if (png_ptr->bit_depth < 8) { png_ptr->transformations |= PNG_PACK; @@ -51,12 +57,13 @@ png_set_packing(png_structp png_ptr) #endif #if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* turn on packed pixel swapping */ +/* Turn on packed pixel swapping */ void PNGAPI png_set_packswap(png_structp png_ptr) { - png_debug(1, "in png_set_packswap\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_packswap"); + if (png_ptr == NULL) + return; if (png_ptr->bit_depth < 8) png_ptr->transformations |= PNG_PACKSWAP; } @@ -66,8 +73,9 @@ png_set_packswap(png_structp png_ptr) void PNGAPI png_set_shift(png_structp png_ptr, png_color_8p true_bits) { - png_debug(1, "in png_set_shift\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_shift"); + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_SHIFT; png_ptr->shift = *true_bits; } @@ -78,7 +86,7 @@ png_set_shift(png_structp png_ptr, png_color_8p true_bits) int PNGAPI png_set_interlace_handling(png_structp png_ptr) { - png_debug(1, "in png_set_interlace handling\n"); + png_debug(1, "in png_set_interlace handling"); if (png_ptr && png_ptr->interlaced) { png_ptr->transformations |= PNG_INTERLACE; @@ -98,8 +106,9 @@ png_set_interlace_handling(png_structp png_ptr) void PNGAPI png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) { - png_debug(1, "in png_set_filler\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_filler"); + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_FILLER; png_ptr->filler = (png_byte)filler; if (filler_loc == PNG_FILLER_AFTER) @@ -131,8 +140,9 @@ png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc) void PNGAPI png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) { - png_debug(1, "in png_set_add_alpha\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_add_alpha"); + if (png_ptr == NULL) + return; png_set_filler(png_ptr, filler, filler_loc); png_ptr->transformations |= PNG_ADD_ALPHA; } @@ -145,8 +155,9 @@ png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc) void PNGAPI png_set_swap_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_swap_alpha\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_swap_alpha"); + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_SWAP_ALPHA; } #endif @@ -156,8 +167,9 @@ png_set_swap_alpha(png_structp png_ptr) void PNGAPI png_set_invert_alpha(png_structp png_ptr) { - png_debug(1, "in png_set_invert_alpha\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_invert_alpha"); + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_INVERT_ALPHA; } #endif @@ -166,16 +178,17 @@ png_set_invert_alpha(png_structp png_ptr) void PNGAPI png_set_invert_mono(png_structp png_ptr) { - png_debug(1, "in png_set_invert_mono\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_invert_mono"); + if (png_ptr == NULL) + return; png_ptr->transformations |= PNG_INVERT_MONO; } -/* invert monochrome grayscale data */ +/* Invert monochrome grayscale data */ void /* PRIVATE */ png_do_invert(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_invert\n"); + png_debug(1, "in png_do_invert"); /* This test removed from libpng version 1.0.13 and 1.2.0: * if (row_info->bit_depth == 1 && */ @@ -226,11 +239,11 @@ png_do_invert(png_row_infop row_info, png_bytep row) #endif #if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* swaps byte order on 16 bit depth images */ +/* Swaps byte order on 16 bit depth images */ void /* PRIVATE */ png_do_swap(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_swap\n"); + png_debug(1, "in png_do_swap"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -357,11 +370,11 @@ static PNG_CONST png_byte fourbppswaptable[256] = { 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF }; -/* swaps pixel packing order within bytes */ +/* Swaps pixel packing order within bytes */ void /* PRIVATE */ png_do_packswap(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_packswap\n"); + png_debug(1, "in png_do_packswap"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -389,11 +402,11 @@ png_do_packswap(png_row_infop row_info, png_bytep row) #if defined(PNG_WRITE_FILLER_SUPPORTED) || \ defined(PNG_READ_STRIP_ALPHA_SUPPORTED) -/* remove filler or alpha byte(s) */ +/* Remove filler or alpha byte(s) */ void /* PRIVATE */ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) { - png_debug(1, "in png_do_strip_filler\n"); + png_debug(1, "in png_do_strip_filler"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif @@ -404,9 +417,9 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) png_uint_32 i; if ((row_info->color_type == PNG_COLOR_TYPE_RGB || - (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && - (flags & PNG_FLAG_STRIP_ALPHA))) && - row_info->channels == 4) + (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA && + (flags & PNG_FLAG_STRIP_ALPHA))) && + row_info->channels == 4) { if (row_info->bit_depth == 8) { @@ -547,11 +560,11 @@ png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags) #endif #if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* swaps red and blue bytes within a pixel */ +/* Swaps red and blue bytes within a pixel */ void /* PRIVATE */ png_do_bgr(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_bgr\n"); + png_debug(1, "in png_do_bgr"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -624,20 +637,21 @@ png_do_bgr(png_row_infop row_info, png_bytep row) #endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_LEGACY_SUPPORTED) + defined(PNG_LEGACY_SUPPORTED) || \ + defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) void PNGAPI png_set_user_transform_info(png_structp png_ptr, png_voidp user_transform_ptr, int user_transform_depth, int user_transform_channels) { - png_debug(1, "in png_set_user_transform_info\n"); - if(png_ptr == NULL) return; + png_debug(1, "in png_set_user_transform_info"); + if (png_ptr == NULL) + return; #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) png_ptr->user_transform_ptr = user_transform_ptr; png_ptr->user_transform_depth = (png_byte)user_transform_depth; png_ptr->user_transform_channels = (png_byte)user_transform_channels; #else - if(user_transform_ptr || user_transform_depth || user_transform_channels) + if (user_transform_ptr || user_transform_depth || user_transform_channels) png_warning(png_ptr, "This version of libpng does not support user transform info"); #endif @@ -652,8 +666,9 @@ png_set_user_transform_info(png_structp png_ptr, png_voidp png_voidp PNGAPI png_get_user_transform_ptr(png_structp png_ptr) { + if (png_ptr == NULL) + return (NULL); #if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) - if (png_ptr == NULL) return (NULL); return ((png_voidp)png_ptr->user_transform_ptr); #else return (NULL); diff --git a/src/3rdparty/libpng/pngwio.c b/src/3rdparty/libpng/pngwio.c index 371a4fa..f77b2db 100644 --- a/src/3rdparty/libpng/pngwio.c +++ b/src/3rdparty/libpng/pngwio.c @@ -1,12 +1,15 @@ /* pngwio.c - functions for data output * - * Last changed in libpng 1.2.13 November 13, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * Last changed in libpng 1.2.37 [June 4, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h + * * This file provides a location for all output. Users who need * special handling are expected to write functions that have the same * arguments as these and perform similar functions, but that possibly @@ -20,10 +23,11 @@ #ifdef PNG_WRITE_SUPPORTED /* Write the data to whatever output you are using. The default routine - writes to a file pointer. Note that this routine sometimes gets called - with very small lengths, so you should implement some kind of simple - buffering if you are using unbuffered writes. This should never be asked - to write more than 64K on a 16 bit machine. */ + * writes to a file pointer. Note that this routine sometimes gets called + * with very small lengths, so you should implement some kind of simple + * buffering if you are using unbuffered writes. This should never be asked + * to write more than 64K on a 16 bit machine. + */ void /* PRIVATE */ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) @@ -36,16 +40,18 @@ png_write_data(png_structp png_ptr, png_bytep data, png_size_t length) #if !defined(PNG_NO_STDIO) /* This is the function that does the actual writing of data. If you are - not writing to a standard C stream, you should create a replacement - write_data function and use it at run time with png_set_write_fn(), rather - than changing the library. */ + * not writing to a standard C stream, you should create a replacement + * write_data function and use it at run time with png_set_write_fn(), rather + * than changing the library. + */ #ifndef USE_FAR_KEYWORD void PNGAPI png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { png_uint_32 check; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; #if defined(_WIN32_WCE) if ( !WriteFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) ) check = 0; @@ -56,10 +62,10 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) png_error(png_ptr, "Write Error"); } #else -/* this is the model-independent version. Since the standard I/O library - can't handle far buffers in the medium and small models, we have to copy - the data. -*/ +/* This is the model-independent version. Since the standard I/O library + * can't handle far buffers in the medium and small models, we have to copy + * the data. + */ #define NEAR_BUF_SIZE 1024 #define MIN(a,b) (a <= b ? a : b) @@ -71,7 +77,8 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ png_FILE_p io_ptr; - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; /* Check if data really is near. If so, use usual code. */ near_data = (png_byte *)CVT_PTR_NOCHECK(data); io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); @@ -93,7 +100,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) do { written = MIN(NEAR_BUF_SIZE, remaining); - png_memcpy(buf, data, written); /* copy far buffer to near buffer */ + png_memcpy(buf, data, written); /* Copy far buffer to near buffer */ #if defined(_WIN32_WCE) if ( !WriteFile(io_ptr, buf, written, &err, NULL) ) err = 0; @@ -102,8 +109,10 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) #endif if (err != written) break; + else check += err; + data += written; remaining -= written; } @@ -117,8 +126,9 @@ png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) #endif /* This function is called to output any data pending writing (normally - to disk). After png_flush is called, there should be no data pending - writing in any buffers. */ + * to disk). After png_flush is called, there should be no data pending + * writing in any buffers. + */ #if defined(PNG_WRITE_FLUSH_SUPPORTED) void /* PRIVATE */ png_flush(png_structp png_ptr) @@ -134,48 +144,58 @@ png_default_flush(png_structp png_ptr) #if !defined(_WIN32_WCE) png_FILE_p io_ptr; #endif - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; #if !defined(_WIN32_WCE) io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); - if (io_ptr != NULL) - fflush(io_ptr); + fflush(io_ptr); #endif } #endif #endif /* This function allows the application to supply new output functions for - libpng if standard C streams aren't being used. - - This function takes as its arguments: - png_ptr - pointer to a png output data structure - io_ptr - pointer to user supplied structure containing info about - the output functions. May be NULL. - write_data_fn - pointer to a new output function that takes as its - arguments a pointer to a png_struct, a pointer to - data to be written, and a 32-bit unsigned int that is - the number of bytes to be written. The new write - function should call png_error(png_ptr, "Error msg") - to exit and output any fatal error messages. - flush_data_fn - pointer to a new flush function that takes as its - arguments a pointer to a png_struct. After a call to - the flush function, there should be no data in any buffers - or pending transmission. If the output method doesn't do - any buffering of ouput, a function prototype must still be - supplied although it doesn't have to do anything. If - PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile - time, output_flush_fn will be ignored, although it must be - supplied for compatibility. */ + * libpng if standard C streams aren't being used. + * + * This function takes as its arguments: + * png_ptr - pointer to a png output data structure + * io_ptr - pointer to user supplied structure containing info about + * the output functions. May be NULL. + * write_data_fn - pointer to a new output function that takes as its + * arguments a pointer to a png_struct, a pointer to + * data to be written, and a 32-bit unsigned int that is + * the number of bytes to be written. The new write + * function should call png_error(png_ptr, "Error msg") + * to exit and output any fatal error messages. May be + * NULL, in which case libpng's default function will + * be used. + * flush_data_fn - pointer to a new flush function that takes as its + * arguments a pointer to a png_struct. After a call to + * the flush function, there should be no data in any buffers + * or pending transmission. If the output method doesn't do + * any buffering of ouput, a function prototype must still be + * supplied although it doesn't have to do anything. If + * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile + * time, output_flush_fn will be ignored, although it must be + * supplied for compatibility. May be NULL, in which case + * libpng's default function will be used, if + * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not + * a good idea if io_ptr does not point to a standard + * *FILE structure. + */ void PNGAPI png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; + png_ptr->io_ptr = io_ptr; #if !defined(PNG_NO_STDIO) if (write_data_fn != NULL) png_ptr->write_data_fn = write_data_fn; + else png_ptr->write_data_fn = png_default_write_data; #else @@ -186,6 +206,7 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, #if !defined(PNG_NO_STDIO) if (output_flush_fn != NULL) png_ptr->output_flush_fn = output_flush_fn; + else png_ptr->output_flush_fn = png_default_flush; #else @@ -206,27 +227,31 @@ png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, #if defined(USE_FAR_KEYWORD) #if defined(_MSC_VER) -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) +void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) { void *near_ptr; void FAR *far_ptr; FP_OFF(near_ptr) = FP_OFF(ptr); far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(FP_SEG(ptr) != FP_SEG(far_ptr)) - png_error(png_ptr,"segment lost in conversion"); + + if (check != 0) + if (FP_SEG(ptr) != FP_SEG(far_ptr)) + png_error(png_ptr, "segment lost in conversion"); + return(near_ptr); } # else -void *png_far_to_near(png_structp png_ptr,png_voidp ptr, int check) +void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) { void *near_ptr; void FAR *far_ptr; near_ptr = (void FAR *)ptr; far_ptr = (void FAR *)near_ptr; - if(check != 0) - if(far_ptr != ptr) - png_error(png_ptr,"segment lost in conversion"); + + if (check != 0) + if (far_ptr != ptr) + png_error(png_ptr, "segment lost in conversion"); + return(near_ptr); } # endif diff --git a/src/3rdparty/libpng/pngwrite.c b/src/3rdparty/libpng/pngwrite.c index 7d02ad7..0987612 100644 --- a/src/3rdparty/libpng/pngwrite.c +++ b/src/3rdparty/libpng/pngwrite.c @@ -1,14 +1,17 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Last changed in libpng 1.2.37 [June 4, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ -/* get internal access to png.h */ +/* Get internal access to png.h */ #define PNG_INTERNAL #include "png.h" #ifdef PNG_WRITE_SUPPORTED @@ -25,20 +28,20 @@ void PNGAPI png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_write_info_before_PLTE\n"); + png_debug(1, "in png_write_info_before_PLTE"); if (png_ptr == NULL || info_ptr == NULL) return; if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) { - png_write_sig(png_ptr); /* write PNG signature */ + png_write_sig(png_ptr); /* Write PNG signature */ #if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) + if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&(png_ptr->mng_features_permitted)) { - png_warning(png_ptr,"MNG features are not allowed in a PNG datastream"); + png_warning(png_ptr, "MNG features are not allowed in a PNG datastream"); png_ptr->mng_features_permitted=0; } #endif - /* write IHDR information. */ + /* Write IHDR information. */ png_write_IHDR(png_ptr, info_ptr->width, info_ptr->height, info_ptr->bit_depth, info_ptr->color_type, info_ptr->compression_type, info_ptr->filter_type, @@ -47,8 +50,9 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) #else 0); #endif - /* the rest of these check to see if the valid field has the appropriate - flag set, and if it does, writes the chunk. */ + /* The rest of these check to see if the valid field has the appropriate + * flag set, and if it does, writes the chunk. + */ #if defined(PNG_WRITE_gAMA_SUPPORTED) if (info_ptr->valid & PNG_INFO_gAMA) { @@ -97,14 +101,14 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) if (info_ptr->unknown_chunks_num) { - png_unknown_chunk *up; + png_unknown_chunk *up; - png_debug(5, "writing extra chunks\n"); + png_debug(5, "writing extra chunks"); - for (up = info_ptr->unknown_chunks; - up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; - up++) - { + for (up = info_ptr->unknown_chunks; + up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; + up++) + { int keep=png_handle_as_unknown(png_ptr, up->name); if (keep != PNG_HANDLE_CHUNK_NEVER && up->location && !(up->location & PNG_HAVE_PLTE) && @@ -116,7 +120,7 @@ png_write_info_before_PLTE(png_structp png_ptr, png_infop info_ptr) png_warning(png_ptr, "Writing zero-length unknown chunk"); png_write_chunk(png_ptr, up->name, up->data, up->size); } - } + } } #endif png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE; @@ -130,7 +134,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr) int i; #endif - png_debug(1, "in png_write_info\n"); + png_debug(1, "in png_write_info"); if (png_ptr == NULL || info_ptr == NULL) return; @@ -145,20 +149,20 @@ png_write_info(png_structp png_ptr, png_infop info_ptr) #if defined(PNG_WRITE_tRNS_SUPPORTED) if (info_ptr->valid & PNG_INFO_tRNS) - { + { #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel (in tRNS) */ - if ((png_ptr->transformations & PNG_INVERT_ALPHA) && - info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { - int j; - for (j=0; j<(int)info_ptr->num_trans; j++) - info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); - } + /* Invert the alpha channel (in tRNS) */ + if ((png_ptr->transformations & PNG_INVERT_ALPHA) && + info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + int j; + for (j=0; j<(int)info_ptr->num_trans; j++) + info_ptr->trans[j] = (png_byte)(255 - info_ptr->trans[j]); + } #endif png_write_tRNS(png_ptr, info_ptr->trans, &(info_ptr->trans_values), info_ptr->num_trans, info_ptr->color_type); - } + } #endif #if defined(PNG_WRITE_bKGD_SUPPORTED) if (info_ptr->valid & PNG_INFO_bKGD) @@ -179,49 +183,56 @@ png_write_info(png_structp png_ptr, png_infop info_ptr) info_ptr->pcal_X1, info_ptr->pcal_type, info_ptr->pcal_nparams, info_ptr->pcal_units, info_ptr->pcal_params); #endif -#if defined(PNG_WRITE_sCAL_SUPPORTED) + +#if defined(PNG_sCAL_SUPPORTED) if (info_ptr->valid & PNG_INFO_sCAL) +#if defined(PNG_WRITE_sCAL_SUPPORTED) #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) png_write_sCAL(png_ptr, (int)info_ptr->scal_unit, info_ptr->scal_pixel_width, info_ptr->scal_pixel_height); -#else +#else /* !FLOATING_POINT */ #ifdef PNG_FIXED_POINT_SUPPORTED png_write_sCAL_s(png_ptr, (int)info_ptr->scal_unit, info_ptr->scal_s_width, info_ptr->scal_s_height); -#else +#endif /* FIXED_POINT */ +#endif /* FLOATING_POINT */ +#else /* !WRITE_sCAL */ png_warning(png_ptr, "png_write_sCAL not supported; sCAL chunk not written."); -#endif -#endif -#endif +#endif /* WRITE_sCAL */ +#endif /* sCAL */ + #if defined(PNG_WRITE_pHYs_SUPPORTED) if (info_ptr->valid & PNG_INFO_pHYs) png_write_pHYs(png_ptr, info_ptr->x_pixels_per_unit, info_ptr->y_pixels_per_unit, info_ptr->phys_unit_type); -#endif +#endif /* pHYs */ + #if defined(PNG_WRITE_tIME_SUPPORTED) if (info_ptr->valid & PNG_INFO_tIME) { png_write_tIME(png_ptr, &(info_ptr->mod_time)); png_ptr->mode |= PNG_WROTE_tIME; } -#endif +#endif /* tIME */ + #if defined(PNG_WRITE_sPLT_SUPPORTED) if (info_ptr->valid & PNG_INFO_sPLT) for (i = 0; i < (int)info_ptr->splt_palettes_num; i++) png_write_sPLT(png_ptr, info_ptr->splt_palettes + i); -#endif +#endif /* sPLT */ + #if defined(PNG_WRITE_TEXT_SUPPORTED) /* Check to see if we need to write text chunks */ for (i = 0; i < info_ptr->num_text; i++) { - png_debug2(2, "Writing header text chunk %d, type %d\n", i, + png_debug2(2, "Writing header text chunk %d, type %d", i, info_ptr->text[i].compression); - /* an internationalized chunk? */ + /* An internationalized chunk? */ if (info_ptr->text[i].compression > 0) { #if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ + /* Write international chunk */ png_write_iTXt(png_ptr, info_ptr->text[i].compression, info_ptr->text[i].key, @@ -238,7 +249,7 @@ png_write_info(png_structp png_ptr, png_infop info_ptr) else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_zTXt) { #if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ + /* Write compressed chunk */ png_write_zTXt(png_ptr, info_ptr->text[i].key, info_ptr->text[i].text, 0, info_ptr->text[i].compression); @@ -251,24 +262,26 @@ png_write_info(png_structp png_ptr, png_infop info_ptr) else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) { #if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ + /* Write uncompressed chunk */ png_write_tEXt(png_ptr, info_ptr->text[i].key, info_ptr->text[i].text, 0); + /* Mark this chunk as written */ + info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; #else + /* Can't get here */ png_warning(png_ptr, "Unable to write uncompressed text"); #endif - /* Mark this chunk as written */ - info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR; } } -#endif +#endif /* tEXt */ + #if defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) if (info_ptr->unknown_chunks_num) { png_unknown_chunk *up; - png_debug(5, "writing extra chunks\n"); + png_debug(5, "writing extra chunks"); for (up = info_ptr->unknown_chunks; up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; @@ -296,35 +309,35 @@ png_write_info(png_structp png_ptr, png_infop info_ptr) void PNGAPI png_write_end(png_structp png_ptr, png_infop info_ptr) { - png_debug(1, "in png_write_end\n"); + png_debug(1, "in png_write_end"); if (png_ptr == NULL) return; if (!(png_ptr->mode & PNG_HAVE_IDAT)) png_error(png_ptr, "No IDATs written into file"); - /* see if user wants us to write information chunks */ + /* See if user wants us to write information chunks */ if (info_ptr != NULL) { #if defined(PNG_WRITE_TEXT_SUPPORTED) - int i; /* local index variable */ + int i; /* Local index variable */ #endif #if defined(PNG_WRITE_tIME_SUPPORTED) - /* check to see if user has supplied a time chunk */ + /* Check to see if user has supplied a time chunk */ if ((info_ptr->valid & PNG_INFO_tIME) && !(png_ptr->mode & PNG_WROTE_tIME)) png_write_tIME(png_ptr, &(info_ptr->mod_time)); #endif #if defined(PNG_WRITE_TEXT_SUPPORTED) - /* loop through comment chunks */ + /* Loop through comment chunks */ for (i = 0; i < info_ptr->num_text; i++) { - png_debug2(2, "Writing trailer text chunk %d, type %d\n", i, + png_debug2(2, "Writing trailer text chunk %d, type %d", i, info_ptr->text[i].compression); - /* an internationalized chunk? */ + /* An internationalized chunk? */ if (info_ptr->text[i].compression > 0) { #if defined(PNG_WRITE_iTXt_SUPPORTED) - /* write international chunk */ + /* Write international chunk */ png_write_iTXt(png_ptr, info_ptr->text[i].compression, info_ptr->text[i].key, @@ -340,7 +353,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr) else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt) { #if defined(PNG_WRITE_zTXt_SUPPORTED) - /* write compressed chunk */ + /* Write compressed chunk */ png_write_zTXt(png_ptr, info_ptr->text[i].key, info_ptr->text[i].text, 0, info_ptr->text[i].compression); @@ -353,7 +366,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr) else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE) { #if defined(PNG_WRITE_tEXt_SUPPORTED) - /* write uncompressed chunk */ + /* Write uncompressed chunk */ png_write_tEXt(png_ptr, info_ptr->text[i].key, info_ptr->text[i].text, 0); #else @@ -370,7 +383,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr) { png_unknown_chunk *up; - png_debug(5, "writing extra chunks\n"); + png_debug(5, "writing extra chunks"); for (up = info_ptr->unknown_chunks; up < info_ptr->unknown_chunks + info_ptr->unknown_chunks_num; @@ -391,8 +404,20 @@ png_write_end(png_structp png_ptr, png_infop info_ptr) png_ptr->mode |= PNG_AFTER_IDAT; - /* write end of PNG file */ + /* Write end of PNG file */ png_write_IEND(png_ptr); + /* This flush, added in libpng-1.0.8, removed from libpng-1.0.9beta03, + * and restored again in libpng-1.2.30, may cause some applications that + * do not set png_ptr->output_flush_fn to crash. If your application + * experiences a problem, please try building libpng with + * PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED defined, and report the event to + * png-mng-implement at lists.sf.net . This kludge will be removed + * from libpng-1.4.0. + */ +#if defined(PNG_WRITE_FLUSH_SUPPORTED) && \ + defined(PNG_WRITE_FLUSH_AFTER_IEND_SUPPORTED) + png_flush(png_ptr); +#endif } #if defined(PNG_WRITE_tIME_SUPPORTED) @@ -401,7 +426,7 @@ png_write_end(png_structp png_ptr, png_infop info_ptr) void PNGAPI png_convert_from_struct_tm(png_timep ptime, struct tm FAR * ttime) { - png_debug(1, "in png_convert_from_struct_tm\n"); + png_debug(1, "in png_convert_from_struct_tm"); ptime->year = (png_uint_16)(1900 + ttime->tm_year); ptime->month = (png_byte)(ttime->tm_mon + 1); ptime->day = (png_byte)ttime->tm_mday; @@ -415,7 +440,7 @@ png_convert_from_time_t(png_timep ptime, time_t ttime) { struct tm *tbuf; - png_debug(1, "in png_convert_from_time_t\n"); + png_debug(1, "in png_convert_from_time_t"); tbuf = gmtime(&ttime); png_convert_from_struct_tm(ptime, tbuf); } @@ -439,14 +464,17 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn) { #endif /* PNG_USER_MEM_SUPPORTED */ - png_structp png_ptr; +#ifdef PNG_SETJMP_SUPPORTED + volatile +#endif + png_structp png_ptr; #ifdef PNG_SETJMP_SUPPORTED #ifdef USE_FAR_KEYWORD jmp_buf jmpbuf; #endif #endif int i; - png_debug(1, "in png_create_write_struct\n"); + png_debug(1, "in png_create_write_struct"); #ifdef PNG_USER_MEM_SUPPORTED png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG, (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr); @@ -456,7 +484,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, if (png_ptr == NULL) return (NULL); - /* added at libpng-1.2.6 */ + /* Added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED png_ptr->user_width_max=PNG_USER_WIDTH_MAX; png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; @@ -470,12 +498,12 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, #endif { png_free(png_ptr, png_ptr->zbuf); - png_ptr->zbuf=NULL; + png_ptr->zbuf=NULL; png_destroy_struct(png_ptr); return (NULL); } #ifdef USE_FAR_KEYWORD - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); + png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); #endif #endif @@ -484,12 +512,12 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, #endif /* PNG_USER_MEM_SUPPORTED */ png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn); - if(user_png_ver) + if (user_png_ver) { i=0; do { - if(user_png_ver[i] != png_libpng_ver[i]) + if (user_png_ver[i] != png_libpng_ver[i]) png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH; } while (png_libpng_ver[i++]); } @@ -527,7 +555,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, } } - /* initialize zbuf - compression buffer */ + /* Initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); @@ -547,7 +575,7 @@ png_create_write_struct_2(png_const_charp user_png_ver, png_voidp error_ptr, #ifdef USE_FAR_KEYWORD if (setjmp(jmpbuf)) PNG_ABORT(); - png_memcpy(png_ptr->jmpbuf,jmpbuf,png_sizeof(jmp_buf)); + png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf)); #else if (setjmp(png_ptr->jmpbuf)) PNG_ABORT(); @@ -572,9 +600,9 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t png_info_size) { /* We only come here via pre-1.0.12-compiled applications */ - if(png_ptr == NULL) return; + if (png_ptr == NULL) return; #if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE) - if(png_sizeof(png_struct) > png_struct_size || + if (png_sizeof(png_struct) > png_struct_size || png_sizeof(png_info) > png_info_size) { char msg[80]; @@ -592,7 +620,7 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, png_warning(png_ptr, msg); } #endif - if(png_sizeof(png_struct) > png_struct_size) + if (png_sizeof(png_struct) > png_struct_size) { png_ptr->error_fn=NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED @@ -601,7 +629,7 @@ png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver, png_error(png_ptr, "The png struct allocated by the application for writing is too small."); } - if(png_sizeof(png_info) > png_info_size) + if (png_sizeof(png_info) > png_info_size) { png_ptr->error_fn=NULL; #ifdef PNG_ERROR_NUMBERS_SUPPORTED @@ -621,7 +649,7 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, { png_structp png_ptr=*ptr_ptr; #ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* to save current jump buffer */ + jmp_buf tmp_jmp; /* To save current jump buffer */ #endif int i = 0; @@ -638,17 +666,17 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, #else png_ptr->warning_fn=NULL; png_warning(png_ptr, - "Application uses deprecated png_write_init() and should be recompiled."); + "Application uses deprecated png_write_init() and should be recompiled."); break; #endif } } while (png_libpng_ver[i++]); - png_debug(1, "in png_write_init_3\n"); + png_debug(1, "in png_write_init_3"); #ifdef PNG_SETJMP_SUPPORTED - /* save jump buffer and error functions */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); + /* Save jump buffer and error functions */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); #endif if (png_sizeof(png_struct) > png_struct_size) @@ -658,24 +686,24 @@ png_write_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver, *ptr_ptr = png_ptr; } - /* reset all variables to 0 */ - png_memset(png_ptr, 0, png_sizeof (png_struct)); + /* Reset all variables to 0 */ + png_memset(png_ptr, 0, png_sizeof(png_struct)); - /* added at libpng-1.2.6 */ + /* Added at libpng-1.2.6 */ #ifdef PNG_SET_USER_LIMITS_SUPPORTED png_ptr->user_width_max=PNG_USER_WIDTH_MAX; png_ptr->user_height_max=PNG_USER_HEIGHT_MAX; #endif #ifdef PNG_SETJMP_SUPPORTED - /* restore jump buffer */ - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); + /* Restore jump buffer */ + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); #endif png_set_write_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL, png_flush_ptr_NULL); - /* initialize zbuf - compression buffer */ + /* Initialize zbuf - compression buffer */ png_ptr->zbuf_size = PNG_ZBUF_SIZE; png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); @@ -695,15 +723,15 @@ void PNGAPI png_write_rows(png_structp png_ptr, png_bytepp row, png_uint_32 num_rows) { - png_uint_32 i; /* row counter */ - png_bytepp rp; /* row pointer */ + png_uint_32 i; /* Row counter */ + png_bytepp rp; /* Row pointer */ - png_debug(1, "in png_write_rows\n"); + png_debug(1, "in png_write_rows"); if (png_ptr == NULL) return; - /* loop through the rows */ + /* Loop through the rows */ for (i = 0, rp = row; i < num_rows; i++, rp++) { png_write_row(png_ptr, *rp); @@ -716,25 +744,26 @@ png_write_rows(png_structp png_ptr, png_bytepp row, void PNGAPI png_write_image(png_structp png_ptr, png_bytepp image) { - png_uint_32 i; /* row index */ - int pass, num_pass; /* pass variables */ - png_bytepp rp; /* points to current row */ + png_uint_32 i; /* Row index */ + int pass, num_pass; /* Pass variables */ + png_bytepp rp; /* Points to current row */ if (png_ptr == NULL) return; - png_debug(1, "in png_write_image\n"); + png_debug(1, "in png_write_image"); #if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* intialize interlace handling. If image is not interlaced, - this will set pass to 1 */ + /* Initialize interlace handling. If image is not interlaced, + * this will set pass to 1 + */ num_pass = png_set_interlace_handling(png_ptr); #else num_pass = 1; #endif - /* loop through passes */ + /* Loop through passes */ for (pass = 0; pass < num_pass; pass++) { - /* loop through image */ + /* Loop through image */ for (i = 0, rp = image; i < png_ptr->height; i++, rp++) { png_write_row(png_ptr, *rp); @@ -742,58 +771,58 @@ png_write_image(png_structp png_ptr, png_bytepp image) } } -/* called by user to write a row of image data */ +/* Called by user to write a row of image data */ void PNGAPI png_write_row(png_structp png_ptr, png_bytep row) { if (png_ptr == NULL) return; - png_debug2(1, "in png_write_row (row %ld, pass %d)\n", + png_debug2(1, "in png_write_row (row %ld, pass %d)", png_ptr->row_number, png_ptr->pass); - /* initialize transformations and other stuff if first time */ + /* Initialize transformations and other stuff if first time */ if (png_ptr->row_number == 0 && png_ptr->pass == 0) { - /* make sure we wrote the header info */ - if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) - png_error(png_ptr, - "png_write_info was never called before png_write_row."); + /* Make sure we wrote the header info */ + if (!(png_ptr->mode & PNG_WROTE_INFO_BEFORE_PLTE)) + png_error(png_ptr, + "png_write_info was never called before png_write_row."); - /* check for transforms that have been set but were defined out */ + /* Check for transforms that have been set but were defined out */ #if !defined(PNG_WRITE_INVERT_SUPPORTED) && defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) - png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_INVERT_MONO) + png_warning(png_ptr, "PNG_WRITE_INVERT_SUPPORTED is not defined."); #endif #if !defined(PNG_WRITE_FILLER_SUPPORTED) && defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) - png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_FILLER) + png_warning(png_ptr, "PNG_WRITE_FILLER_SUPPORTED is not defined."); #endif #if !defined(PNG_WRITE_PACKSWAP_SUPPORTED) && defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) - png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_PACKSWAP) + png_warning(png_ptr, "PNG_WRITE_PACKSWAP_SUPPORTED is not defined."); #endif #if !defined(PNG_WRITE_PACK_SUPPORTED) && defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) - png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_PACK) + png_warning(png_ptr, "PNG_WRITE_PACK_SUPPORTED is not defined."); #endif #if !defined(PNG_WRITE_SHIFT_SUPPORTED) && defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) - png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_SHIFT) + png_warning(png_ptr, "PNG_WRITE_SHIFT_SUPPORTED is not defined."); #endif #if !defined(PNG_WRITE_BGR_SUPPORTED) && defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) - png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_BGR) + png_warning(png_ptr, "PNG_WRITE_BGR_SUPPORTED is not defined."); #endif #if !defined(PNG_WRITE_SWAP_SUPPORTED) && defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) - png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); + if (png_ptr->transformations & PNG_SWAP_BYTES) + png_warning(png_ptr, "PNG_WRITE_SWAP_SUPPORTED is not defined."); #endif png_write_start_row(png_ptr); } #if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* if interlaced and not interested in row, return */ + /* If interlaced and not interested in row, return */ if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) { switch (png_ptr->pass) @@ -851,7 +880,7 @@ png_write_row(png_structp png_ptr, png_bytep row) } #endif - /* set up row info for transformations */ + /* Set up row info for transformations */ png_ptr->row_info.color_type = png_ptr->color_type; png_ptr->row_info.width = png_ptr->usr_width; png_ptr->row_info.channels = png_ptr->usr_channels; @@ -862,25 +891,25 @@ png_write_row(png_structp png_ptr, png_bytep row) png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->row_info.width); - png_debug1(3, "row_info->color_type = %d\n", png_ptr->row_info.color_type); - png_debug1(3, "row_info->width = %lu\n", png_ptr->row_info.width); - png_debug1(3, "row_info->channels = %d\n", png_ptr->row_info.channels); - png_debug1(3, "row_info->bit_depth = %d\n", png_ptr->row_info.bit_depth); - png_debug1(3, "row_info->pixel_depth = %d\n", png_ptr->row_info.pixel_depth); - png_debug1(3, "row_info->rowbytes = %lu\n", png_ptr->row_info.rowbytes); + png_debug1(3, "row_info->color_type = %d", png_ptr->row_info.color_type); + png_debug1(3, "row_info->width = %lu", png_ptr->row_info.width); + png_debug1(3, "row_info->channels = %d", png_ptr->row_info.channels); + png_debug1(3, "row_info->bit_depth = %d", png_ptr->row_info.bit_depth); + png_debug1(3, "row_info->pixel_depth = %d", png_ptr->row_info.pixel_depth); + png_debug1(3, "row_info->rowbytes = %lu", png_ptr->row_info.rowbytes); /* Copy user's row into buffer, leaving room for filter byte. */ png_memcpy_check(png_ptr, png_ptr->row_buf + 1, row, png_ptr->row_info.rowbytes); #if defined(PNG_WRITE_INTERLACING_SUPPORTED) - /* handle interlacing */ + /* Handle interlacing */ if (png_ptr->interlaced && png_ptr->pass < 6 && (png_ptr->transformations & PNG_INTERLACE)) { png_do_write_interlace(&(png_ptr->row_info), png_ptr->row_buf + 1, png_ptr->pass); - /* this should always get caught above, but still ... */ + /* This should always get caught above, but still ... */ if (!(png_ptr->row_info.width)) { png_write_finish_row(png_ptr); @@ -889,7 +918,7 @@ png_write_row(png_structp png_ptr, png_bytep row) } #endif - /* handle other transformations */ + /* Handle other transformations */ if (png_ptr->transformations) png_do_write_transformations(png_ptr); @@ -903,7 +932,7 @@ png_write_row(png_structp png_ptr, png_bytep row) * 4. The filter_method is 64 and * 5. The color_type is RGB or RGBA */ - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) { /* Intrapixel differencing */ @@ -923,34 +952,34 @@ png_write_row(png_structp png_ptr, png_bytep row) void PNGAPI png_set_flush(png_structp png_ptr, int nrows) { - png_debug(1, "in png_set_flush\n"); + png_debug(1, "in png_set_flush"); if (png_ptr == NULL) return; png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); } -/* flush the current output buffers now */ +/* Flush the current output buffers now */ void PNGAPI png_write_flush(png_structp png_ptr) { int wrote_IDAT; - png_debug(1, "in png_write_flush\n"); + png_debug(1, "in png_write_flush"); if (png_ptr == NULL) return; /* We have already written out all of the data */ if (png_ptr->row_number >= png_ptr->num_rows) - return; + return; do { int ret; - /* compress the data */ + /* Compress the data */ ret = deflate(&png_ptr->zstream, Z_SYNC_FLUSH); wrote_IDAT = 0; - /* check for compression errors */ + /* Check for compression errors */ if (ret != Z_OK) { if (png_ptr->zstream.msg != NULL) @@ -961,7 +990,7 @@ png_write_flush(png_structp png_ptr) if (!(png_ptr->zstream.avail_out)) { - /* write the IDAT and reset the zlib output buffer */ + /* Write the IDAT and reset the zlib output buffer */ png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); png_ptr->zstream.next_out = png_ptr->zbuf; @@ -973,7 +1002,7 @@ png_write_flush(png_structp png_ptr) /* If there is any data left to be output, write it into a new IDAT */ if (png_ptr->zbuf_size != png_ptr->zstream.avail_out) { - /* write the IDAT and reset the zlib output buffer */ + /* Write the IDAT and reset the zlib output buffer */ png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - png_ptr->zstream.avail_out); png_ptr->zstream.next_out = png_ptr->zbuf; @@ -984,7 +1013,7 @@ png_write_flush(png_structp png_ptr) } #endif /* PNG_WRITE_FLUSH_SUPPORTED */ -/* free all memory used by the write */ +/* Free all memory used by the write */ void PNGAPI png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) { @@ -995,7 +1024,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) png_voidp mem_ptr = NULL; #endif - png_debug(1, "in png_destroy_write_struct\n"); + png_debug(1, "in png_destroy_write_struct"); if (png_ptr_ptr != NULL) { png_ptr = *png_ptr_ptr; @@ -1027,7 +1056,7 @@ png_destroy_write_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr) { png_free(png_ptr, png_ptr->chunk_list); png_ptr->chunk_list=NULL; - png_ptr->num_chunk_list=0; + png_ptr->num_chunk_list = 0; } #endif } @@ -1060,7 +1089,7 @@ void /* PRIVATE */ png_write_destroy(png_structp png_ptr) { #ifdef PNG_SETJMP_SUPPORTED - jmp_buf tmp_jmp; /* save jump buffer */ + jmp_buf tmp_jmp; /* Save jump buffer */ #endif png_error_ptr error_fn; png_error_ptr warning_fn; @@ -1069,14 +1098,14 @@ png_write_destroy(png_structp png_ptr) png_free_ptr free_fn; #endif - png_debug(1, "in png_write_destroy\n"); - /* free any memory zlib uses */ + png_debug(1, "in png_write_destroy"); + /* Free any memory zlib uses */ deflateEnd(&png_ptr->zstream); - /* free our memory. png_free checks NULL for us. */ + /* Free our memory. png_free checks NULL for us. */ png_free(png_ptr, png_ptr->zbuf); png_free(png_ptr, png_ptr->row_buf); -#ifndef PNG_NO_WRITE_FILTERING +#ifndef PNG_NO_WRITE_FILTER png_free(png_ptr, png_ptr->prev_row); png_free(png_ptr, png_ptr->sub_row); png_free(png_ptr, png_ptr->up_row); @@ -1097,8 +1126,8 @@ png_write_destroy(png_structp png_ptr) #endif #ifdef PNG_SETJMP_SUPPORTED - /* reset structure */ - png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof (jmp_buf)); + /* Reset structure */ + png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf)); #endif error_fn = png_ptr->error_fn; @@ -1108,7 +1137,7 @@ png_write_destroy(png_structp png_ptr) free_fn = png_ptr->free_fn; #endif - png_memset(png_ptr, 0, png_sizeof (png_struct)); + png_memset(png_ptr, 0, png_sizeof(png_struct)); png_ptr->error_fn = error_fn; png_ptr->warning_fn = warning_fn; @@ -1118,7 +1147,7 @@ png_write_destroy(png_structp png_ptr) #endif #ifdef PNG_SETJMP_SUPPORTED - png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof (jmp_buf)); + png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf)); #endif } @@ -1126,11 +1155,11 @@ png_write_destroy(png_structp png_ptr) void PNGAPI png_set_filter(png_structp png_ptr, int method, int filters) { - png_debug(1, "in png_set_filter\n"); + png_debug(1, "in png_set_filter"); if (png_ptr == NULL) return; #if defined(PNG_MNG_FEATURES_SUPPORTED) - if((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && (method == PNG_INTRAPIXEL_DIFFERENCING)) method = PNG_FILTER_TYPE_BASE; #endif @@ -1249,7 +1278,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, { int i; - png_debug(1, "in png_set_filter_heuristics\n"); + png_debug(1, "in png_set_filter_heuristics"); if (png_ptr == NULL) return; if (heuristic_method >= PNG_FILTER_HEURISTIC_LAST) @@ -1363,7 +1392,7 @@ png_set_filter_heuristics(png_structp png_ptr, int heuristic_method, void PNGAPI png_set_compression_level(png_structp png_ptr, int level) { - png_debug(1, "in png_set_compression_level\n"); + png_debug(1, "in png_set_compression_level"); if (png_ptr == NULL) return; png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_LEVEL; @@ -1373,7 +1402,7 @@ png_set_compression_level(png_structp png_ptr, int level) void PNGAPI png_set_compression_mem_level(png_structp png_ptr, int mem_level) { - png_debug(1, "in png_set_compression_mem_level\n"); + png_debug(1, "in png_set_compression_mem_level"); if (png_ptr == NULL) return; png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL; @@ -1383,7 +1412,7 @@ png_set_compression_mem_level(png_structp png_ptr, int mem_level) void PNGAPI png_set_compression_strategy(png_structp png_ptr, int strategy) { - png_debug(1, "in png_set_compression_strategy\n"); + png_debug(1, "in png_set_compression_strategy"); if (png_ptr == NULL) return; png_ptr->flags |= PNG_FLAG_ZLIB_CUSTOM_STRATEGY; @@ -1400,7 +1429,7 @@ png_set_compression_window_bits(png_structp png_ptr, int window_bits) else if (window_bits < 8) png_warning(png_ptr, "Only compression windows >= 256 supported by PNG"); #ifndef WBITS_8_OK - /* avoid libpng bug with 256-byte windows */ + /* Avoid libpng bug with 256-byte windows */ if (window_bits == 8) { png_warning(png_ptr, "Compression window is being reset to 512"); @@ -1414,7 +1443,7 @@ png_set_compression_window_bits(png_structp png_ptr, int window_bits) void PNGAPI png_set_compression_method(png_structp png_ptr, int method) { - png_debug(1, "in png_set_compression_method\n"); + png_debug(1, "in png_set_compression_method"); if (png_ptr == NULL) return; if (method != 8) @@ -1436,7 +1465,7 @@ void PNGAPI png_set_write_user_transform_fn(png_structp png_ptr, png_user_transform_ptr write_user_transform_fn) { - png_debug(1, "in png_set_write_user_transform_fn\n"); + png_debug(1, "in png_set_write_user_transform_fn"); if (png_ptr == NULL) return; png_ptr->transformations |= PNG_USER_TRANSFORM; @@ -1453,9 +1482,9 @@ png_write_png(png_structp png_ptr, png_infop info_ptr, if (png_ptr == NULL || info_ptr == NULL) return; #if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) - /* invert the alpha channel from opacity to transparency */ + /* Invert the alpha channel from opacity to transparency */ if (transforms & PNG_TRANSFORM_INVERT_ALPHA) - png_set_invert_alpha(png_ptr); + png_set_invert_alpha(png_ptr); #endif /* Write the file header information. */ @@ -1464,9 +1493,9 @@ png_write_png(png_structp png_ptr, png_infop info_ptr, /* ------ these transformations don't touch the info structure ------- */ #if defined(PNG_WRITE_INVERT_SUPPORTED) - /* invert monochrome pixels */ + /* Invert monochrome pixels */ if (transforms & PNG_TRANSFORM_INVERT_MONO) - png_set_invert_mono(png_ptr); + png_set_invert_mono(png_ptr); #endif #if defined(PNG_WRITE_SHIFT_SUPPORTED) @@ -1475,57 +1504,57 @@ png_write_png(png_structp png_ptr, png_infop info_ptr, */ if ((transforms & PNG_TRANSFORM_SHIFT) && (info_ptr->valid & PNG_INFO_sBIT)) - png_set_shift(png_ptr, &info_ptr->sig_bit); + png_set_shift(png_ptr, &info_ptr->sig_bit); #endif #if defined(PNG_WRITE_PACK_SUPPORTED) - /* pack pixels into bytes */ + /* Pack pixels into bytes */ if (transforms & PNG_TRANSFORM_PACKING) png_set_packing(png_ptr); #endif #if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) - /* swap location of alpha bytes from ARGB to RGBA */ + /* Swap location of alpha bytes from ARGB to RGBA */ if (transforms & PNG_TRANSFORM_SWAP_ALPHA) - png_set_swap_alpha(png_ptr); + png_set_swap_alpha(png_ptr); #endif #if defined(PNG_WRITE_FILLER_SUPPORTED) - /* Get rid of filler (OR ALPHA) bytes, pack XRGB/RGBX/ARGB/RGBA into - * RGB (4 channels -> 3 channels). The second parameter is not used. - */ - if (transforms & PNG_TRANSFORM_STRIP_FILLER) - png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); + /* Pack XRGB/RGBX/ARGB/RGBA into * RGB (4 channels -> 3 channels) */ + if (transforms & PNG_TRANSFORM_STRIP_FILLER_AFTER) + png_set_filler(png_ptr, 0, PNG_FILLER_AFTER); + else if (transforms & PNG_TRANSFORM_STRIP_FILLER_BEFORE) + png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); #endif #if defined(PNG_WRITE_BGR_SUPPORTED) - /* flip BGR pixels to RGB */ + /* Flip BGR pixels to RGB */ if (transforms & PNG_TRANSFORM_BGR) - png_set_bgr(png_ptr); + png_set_bgr(png_ptr); #endif #if defined(PNG_WRITE_SWAP_SUPPORTED) - /* swap bytes of 16-bit files to most significant byte first */ + /* Swap bytes of 16-bit files to most significant byte first */ if (transforms & PNG_TRANSFORM_SWAP_ENDIAN) - png_set_swap(png_ptr); + png_set_swap(png_ptr); #endif #if defined(PNG_WRITE_PACKSWAP_SUPPORTED) - /* swap bits of 1, 2, 4 bit packed pixel formats */ + /* Swap bits of 1, 2, 4 bit packed pixel formats */ if (transforms & PNG_TRANSFORM_PACKSWAP) - png_set_packswap(png_ptr); + png_set_packswap(png_ptr); #endif /* ----------------------- end of transformations ------------------- */ - /* write the bits */ + /* Write the bits */ if (info_ptr->valid & PNG_INFO_IDAT) png_write_image(png_ptr, info_ptr->row_pointers); /* It is REQUIRED to call this to finish writing the rest of the file */ png_write_end(png_ptr, info_ptr); - transforms = transforms; /* quiet compiler warnings */ + transforms = transforms; /* Quiet compiler warnings */ params = params; } #endif diff --git a/src/3rdparty/libpng/pngwtran.c b/src/3rdparty/libpng/pngwtran.c index 0372fe6..88a7d3c 100644 --- a/src/3rdparty/libpng/pngwtran.c +++ b/src/3rdparty/libpng/pngwtran.c @@ -1,11 +1,14 @@ /* pngwtran.c - transforms the data in a row for PNG writers * - * Last changed in libpng 1.2.9 April 14, 2006 - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2006 Glenn Randers-Pehrson + * Last changed in libpng 1.2.37 [June 4, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ #define PNG_INTERNAL @@ -18,15 +21,15 @@ void /* PRIVATE */ png_do_write_transformations(png_structp png_ptr) { - png_debug(1, "in png_do_write_transformations\n"); + png_debug(1, "in png_do_write_transformations"); if (png_ptr == NULL) return; #if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) if (png_ptr->transformations & PNG_USER_TRANSFORM) - if(png_ptr->write_user_transform_fn != NULL) - (*(png_ptr->write_user_transform_fn)) /* user write transform function */ + if (png_ptr->write_user_transform_fn != NULL) + (*(png_ptr->write_user_transform_fn)) /* User write transform function */ (png_ptr, /* png_ptr */ &(png_ptr->row_info), /* row_info: */ /* png_uint_32 width; width of row */ @@ -86,7 +89,7 @@ png_do_write_transformations(png_structp png_ptr) void /* PRIVATE */ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) { - png_debug(1, "in png_do_pack\n"); + png_debug(1, "in png_do_pack"); if (row_info->bit_depth == 8 && #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -212,7 +215,7 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) void /* PRIVATE */ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) { - png_debug(1, "in png_do_shift\n"); + png_debug(1, "in png_do_shift"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && #else @@ -248,7 +251,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) channels++; } - /* with low row depths, could only be grayscale, so one channel */ + /* With low row depths, could only be grayscale, so one channel */ if (row_info->bit_depth < 8) { png_bytep bp = row; @@ -336,7 +339,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, png_color_8p bit_depth) void /* PRIVATE */ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_swap_alpha\n"); + png_debug(1, "in png_do_write_swap_alpha"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif @@ -424,7 +427,7 @@ png_do_write_swap_alpha(png_row_infop row_info, png_bytep row) void /* PRIVATE */ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_invert_alpha\n"); + png_debug(1, "in png_do_write_invert_alpha"); #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL) #endif @@ -439,7 +442,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) png_uint_32 row_width = row_info->width; for (i = 0, sp = dp = row; i < row_width; i++) { - /* does nothing + /* Does nothing *(dp++) = *(sp++); *(dp++) = *(sp++); *(dp++) = *(sp++); @@ -457,7 +460,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) for (i = 0, sp = dp = row; i < row_width; i++) { - /* does nothing + /* Does nothing *(dp++) = *(sp++); *(dp++) = *(sp++); *(dp++) = *(sp++); @@ -495,7 +498,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) for (i = 0, sp = dp = row; i < row_width; i++) { - /* does nothing + /* Does nothing *(dp++) = *(sp++); *(dp++) = *(sp++); */ @@ -510,11 +513,11 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) #endif #if defined(PNG_MNG_FEATURES_SUPPORTED) -/* undoes intrapixel differencing */ +/* Undoes intrapixel differencing */ void /* PRIVATE */ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) { - png_debug(1, "in png_do_write_intrapixel\n"); + png_debug(1, "in png_do_write_intrapixel"); if ( #if defined(PNG_USELESS_TESTS_SUPPORTED) row != NULL && row_info != NULL && @@ -558,8 +561,8 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row) png_uint_32 s0 = (*(rp ) << 8) | *(rp+1); png_uint_32 s1 = (*(rp+2) << 8) | *(rp+3); png_uint_32 s2 = (*(rp+4) << 8) | *(rp+5); - png_uint_32 red = (png_uint_32)((s0-s1) & 0xffffL); - png_uint_32 blue = (png_uint_32)((s2-s1) & 0xffffL); + png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL); + png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL); *(rp ) = (png_byte)((red >> 8) & 0xff); *(rp+1) = (png_byte)(red & 0xff); *(rp+4) = (png_byte)((blue >> 8) & 0xff); diff --git a/src/3rdparty/libpng/pngwutil.c b/src/3rdparty/libpng/pngwutil.c index 0774080..f52495c 100644 --- a/src/3rdparty/libpng/pngwutil.c +++ b/src/3rdparty/libpng/pngwutil.c @@ -1,11 +1,14 @@ /* pngwutil.c - utilities to write a PNG file * - * Last changed in libpng 1.2.27 [April 29, 2008] - * For conditions of distribution and use, see copyright notice in png.h - * Copyright (c) 1998-2008 Glenn Randers-Pehrson + * Last changed in libpng 1.2.40 [September 10, 2009] + * Copyright (c) 1998-2009 Glenn Randers-Pehrson * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) + * + * This code is released under the libpng license. + * For conditions of distribution and use, see the disclaimer + * and license in png.h */ #define PNG_INTERNAL @@ -49,6 +52,24 @@ png_save_uint_16(png_bytep buf, unsigned int i) buf[1] = (png_byte)(i & 0xff); } +/* Simple function to write the signature. If we have already written + * the magic bytes of the signature, or more likely, the PNG stream is + * being embedded into another stream and doesn't need its own signature, + * we should call png_set_sig_bytes() to tell libpng how many of the + * bytes have already been written. + */ +void /* PRIVATE */ +png_write_sig(png_structp png_ptr) +{ + png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; + + /* Write the rest of the 8 byte signature */ + png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], + (png_size_t)(8 - png_ptr->sig_bytes)); + if (png_ptr->sig_bytes < 3) + png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; +} + /* Write a PNG chunk all at once. The type is an array of ASCII characters * representing the chunk name. The array must be at least 4 bytes in * length, and does not need to be null terminated. To be safe, pass the @@ -62,9 +83,10 @@ void PNGAPI png_write_chunk(png_structp png_ptr, png_bytep chunk_name, png_bytep data, png_size_t length) { - if(png_ptr == NULL) return; + if (png_ptr == NULL) + return; png_write_chunk_start(png_ptr, chunk_name, (png_uint_32)length); - png_write_chunk_data(png_ptr, data, length); + png_write_chunk_data(png_ptr, data, (png_size_t)length); png_write_chunk_end(png_ptr); } @@ -76,17 +98,21 @@ void PNGAPI png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, png_uint_32 length) { - png_byte buf[4]; - png_debug2(0, "Writing %s chunk (%lu bytes)\n", chunk_name, length); - if(png_ptr == NULL) return; + png_byte buf[8]; - /* write the length */ - png_save_uint_32(buf, length); - png_write_data(png_ptr, buf, (png_size_t)4); + png_debug2(0, "Writing %s chunk, length = %lu", chunk_name, + (unsigned long)length); - /* write the chunk name */ - png_write_data(png_ptr, chunk_name, (png_size_t)4); - /* reset the crc and run it over the chunk name */ + if (png_ptr == NULL) + return; + + /* Write the length and the chunk name */ + png_save_uint_32(buf, length); + png_memcpy(buf + 4, chunk_name, 4); + png_write_data(png_ptr, buf, (png_size_t)8); + /* Put the chunk name into png_ptr->chunk_name */ + png_memcpy(png_ptr->chunk_name, chunk_name, 4); + /* Reset the crc and run it over the chunk name */ png_reset_crc(png_ptr); png_calculate_crc(png_ptr, chunk_name, (png_size_t)4); } @@ -99,12 +125,16 @@ png_write_chunk_start(png_structp png_ptr, png_bytep chunk_name, void PNGAPI png_write_chunk_data(png_structp png_ptr, png_bytep data, png_size_t length) { - /* write the data, and run the CRC over it */ - if(png_ptr == NULL) return; + /* Write the data, and run the CRC over it */ + if (png_ptr == NULL) + return; if (data != NULL && length > 0) { - png_calculate_crc(png_ptr, data, length); png_write_data(png_ptr, data, length); + /* Update the CRC after writing the data, + * in case that the user I/O routine alters it. + */ + png_calculate_crc(png_ptr, data, length); } } @@ -114,34 +144,16 @@ png_write_chunk_end(png_structp png_ptr) { png_byte buf[4]; - if(png_ptr == NULL) return; + if (png_ptr == NULL) return; - /* write the crc */ + /* Write the crc in a single operation */ png_save_uint_32(buf, png_ptr->crc); png_write_data(png_ptr, buf, (png_size_t)4); } -/* Simple function to write the signature. If we have already written - * the magic bytes of the signature, or more likely, the PNG stream is - * being embedded into another stream and doesn't need its own signature, - * we should call png_set_sig_bytes() to tell libpng how many of the - * bytes have already been written. - */ -void /* PRIVATE */ -png_write_sig(png_structp png_ptr) -{ - png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10}; - /* write the rest of the 8 byte signature */ - png_write_data(png_ptr, &png_signature[png_ptr->sig_bytes], - (png_size_t)8 - png_ptr->sig_bytes); - if(png_ptr->sig_bytes < 3) - png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE; -} - #if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_iCCP_SUPPORTED) -/* - * This pair of functions encapsulates the operation of (a) compressing a +/* This pair of functions encapsulates the operation of (a) compressing a * text string, and (b) issuing it later as a series of chunk data writes. * The compression_state structure is shared context for these functions * set up by the caller in order to make the whole mess thread-safe. @@ -149,14 +161,14 @@ png_write_sig(png_structp png_ptr) typedef struct { - char *input; /* the uncompressed input data */ - int input_len; /* its length */ - int num_output_ptr; /* number of output pointers used */ - int max_output_ptr; /* size of output_ptr */ - png_charpp output_ptr; /* array of pointers to output */ + char *input; /* The uncompressed input data */ + int input_len; /* Its length */ + int num_output_ptr; /* Number of output pointers used */ + int max_output_ptr; /* Size of output_ptr */ + png_charpp output_ptr; /* Array of pointers to output */ } compression_state; -/* compress given text into storage in the png_ptr structure */ +/* Compress given text into storage in the png_ptr structure */ static int /* PRIVATE */ png_text_compress(png_structp png_ptr, png_charp text, png_size_t text_len, int compression, @@ -170,7 +182,7 @@ png_text_compress(png_structp png_ptr, comp->input = NULL; comp->input_len = 0; - /* we may just want to pass the text right through */ + /* We may just want to pass the text right through */ if (compression == PNG_TEXT_COMPRESSION_NONE) { comp->input = text; @@ -204,29 +216,29 @@ png_text_compress(png_structp png_ptr, * wouldn't cause a failure, just a slowdown due to swapping). */ - /* set up the compression buffers */ + /* Set up the compression buffers */ png_ptr->zstream.avail_in = (uInt)text_len; png_ptr->zstream.next_in = (Bytef *)text; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf; - /* this is the same compression loop as in png_write_row() */ + /* This is the same compression loop as in png_write_row() */ do { - /* compress the data */ + /* Compress the data */ ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); if (ret != Z_OK) { - /* error */ + /* Error */ if (png_ptr->zstream.msg != NULL) png_error(png_ptr, png_ptr->zstream.msg); else png_error(png_ptr, "zlib error"); } - /* check to see if we need more room */ + /* Check to see if we need more room */ if (!(png_ptr->zstream.avail_out)) { - /* make sure the output array has room */ + /* Make sure the output array has room */ if (comp->num_output_ptr >= comp->max_output_ptr) { int old_max; @@ -239,20 +251,21 @@ png_text_compress(png_structp png_ptr, old_ptr = comp->output_ptr; comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); + (png_uint_32) + (comp->max_output_ptr * png_sizeof(png_charpp))); png_memcpy(comp->output_ptr, old_ptr, old_max - * png_sizeof (png_charp)); + * png_sizeof(png_charp)); png_free(png_ptr, old_ptr); } else comp->output_ptr = (png_charpp)png_malloc(png_ptr, - (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); + (png_uint_32) + (comp->max_output_ptr * png_sizeof(png_charp))); } - /* save the data */ - comp->output_ptr[comp->num_output_ptr] = (png_charp)png_malloc(png_ptr, + /* Save the data */ + comp->output_ptr[comp->num_output_ptr] = + (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, png_ptr->zbuf_size); @@ -262,21 +275,21 @@ png_text_compress(png_structp png_ptr, png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; png_ptr->zstream.next_out = png_ptr->zbuf; } - /* continue until we don't have any more to compress */ + /* Continue until we don't have any more to compress */ } while (png_ptr->zstream.avail_in); - /* finish the compression */ + /* Finish the compression */ do { - /* tell zlib we are finished */ + /* Tell zlib we are finished */ ret = deflate(&png_ptr->zstream, Z_FINISH); if (ret == Z_OK) { - /* check to see if we need more room */ + /* Check to see if we need more room */ if (!(png_ptr->zstream.avail_out)) { - /* check to make sure our output array has room */ + /* Check to make sure our output array has room */ if (comp->num_output_ptr >= comp->max_output_ptr) { int old_max; @@ -291,20 +304,21 @@ png_text_compress(png_structp png_ptr, /* This could be optimized to realloc() */ comp->output_ptr = (png_charpp)png_malloc(png_ptr, (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charpp))); + png_sizeof(png_charp))); png_memcpy(comp->output_ptr, old_ptr, - old_max * png_sizeof (png_charp)); + old_max * png_sizeof(png_charp)); png_free(png_ptr, old_ptr); } else comp->output_ptr = (png_charpp)png_malloc(png_ptr, (png_uint_32)(comp->max_output_ptr * - png_sizeof (png_charp))); + png_sizeof(png_charp))); } - /* save off the data */ + /* Save the data */ comp->output_ptr[comp->num_output_ptr] = - (png_charp)png_malloc(png_ptr, (png_uint_32)png_ptr->zbuf_size); + (png_charp)png_malloc(png_ptr, + (png_uint_32)png_ptr->zbuf_size); png_memcpy(comp->output_ptr[comp->num_output_ptr], png_ptr->zbuf, png_ptr->zbuf_size); comp->num_output_ptr++; @@ -316,7 +330,7 @@ png_text_compress(png_structp png_ptr, } else if (ret != Z_STREAM_END) { - /* we got an error */ + /* We got an error */ if (png_ptr->zstream.msg != NULL) png_error(png_ptr, png_ptr->zstream.msg); else @@ -324,7 +338,7 @@ png_text_compress(png_structp png_ptr, } } while (ret != Z_STREAM_END); - /* text length is number of buffers plus last buffer */ + /* Text length is number of buffers plus last buffer */ text_len = png_ptr->zbuf_size * comp->num_output_ptr; if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) text_len += png_ptr->zbuf_size - (png_size_t)png_ptr->zstream.avail_out; @@ -332,37 +346,37 @@ png_text_compress(png_structp png_ptr, return((int)text_len); } -/* ship the compressed text out via chunk writes */ +/* Ship the compressed text out via chunk writes */ static void /* PRIVATE */ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp) { int i; - /* handle the no-compression case */ + /* Handle the no-compression case */ if (comp->input) { - png_write_chunk_data(png_ptr, (png_bytep)comp->input, + png_write_chunk_data(png_ptr, (png_bytep)comp->input, (png_size_t)comp->input_len); - return; + return; } - /* write saved output buffers, if any */ + /* Write saved output buffers, if any */ for (i = 0; i < comp->num_output_ptr; i++) { - png_write_chunk_data(png_ptr,(png_bytep)comp->output_ptr[i], - png_ptr->zbuf_size); + png_write_chunk_data(png_ptr, (png_bytep)comp->output_ptr[i], + (png_size_t)png_ptr->zbuf_size); png_free(png_ptr, comp->output_ptr[i]); - comp->output_ptr[i]=NULL; + comp->output_ptr[i]=NULL; } if (comp->max_output_ptr != 0) png_free(png_ptr, comp->output_ptr); - comp->output_ptr=NULL; - /* write anything left in zbuf */ + comp->output_ptr=NULL; + /* Write anything left in zbuf */ if (png_ptr->zstream.avail_out < (png_uint_32)png_ptr->zbuf_size) png_write_chunk_data(png_ptr, png_ptr->zbuf, - png_ptr->zbuf_size - png_ptr->zstream.avail_out); + (png_size_t)(png_ptr->zbuf_size - png_ptr->zstream.avail_out)); - /* reset zlib for another zTXt/iTXt or image data */ + /* Reset zlib for another zTXt/iTXt or image data */ deflateReset(&png_ptr->zstream); png_ptr->zstream.data_type = Z_BINARY; } @@ -382,9 +396,10 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, #endif int ret; - png_byte buf[13]; /* buffer to store the IHDR info */ + png_byte buf[13]; /* Buffer to store the IHDR info */ + + png_debug(1, "in png_write_IHDR"); - png_debug(1, "in png_write_IHDR\n"); /* Check that we have valid input data from the application info */ switch (color_type) { @@ -396,7 +411,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, case 4: case 8: case 16: png_ptr->channels = 1; break; - default: png_error(png_ptr,"Invalid bit depth for grayscale image"); + default: png_error(png_ptr, "Invalid bit depth for grayscale image"); } break; case PNG_COLOR_TYPE_RGB: @@ -468,7 +483,7 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, interlace_type=PNG_INTERLACE_NONE; #endif - /* save off the relevent information */ + /* Save the relevent information */ png_ptr->bit_depth = (png_byte)bit_depth; png_ptr->color_type = (png_byte)color_type; png_ptr->interlaced = (png_byte)interlace_type; @@ -481,12 +496,12 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, png_ptr->pixel_depth = (png_byte)(bit_depth * png_ptr->channels); png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, width); - /* set the usr info, so any transformations can modify it */ + /* Set the usr info, so any transformations can modify it */ png_ptr->usr_width = png_ptr->width; png_ptr->usr_bit_depth = png_ptr->bit_depth; png_ptr->usr_channels = png_ptr->channels; - /* pack the header information into the buffer */ + /* Pack the header information into the buffer */ png_save_uint_32(buf, width); png_save_uint_32(buf + 4, height); buf[8] = (png_byte)bit_depth; @@ -495,10 +510,10 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, buf[11] = (png_byte)filter_type; buf[12] = (png_byte)interlace_type; - /* write the chunk */ - png_write_chunk(png_ptr, png_IHDR, buf, (png_size_t)13); + /* Write the chunk */ + png_write_chunk(png_ptr, (png_bytep)png_IHDR, buf, (png_size_t)13); - /* initialize zlib with PNG info */ + /* Initialize zlib with PNG info */ png_ptr->zstream.zalloc = png_zalloc; png_ptr->zstream.zfree = png_zfree; png_ptr->zstream.opaque = (voidpf)png_ptr; @@ -541,13 +556,13 @@ png_write_IHDR(png_structp png_ptr, png_uint_32 width, png_uint_32 height, png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; /* libpng is not interested in zstream.data_type */ - /* set it to a predefined value, to avoid its evaluation inside zlib */ + /* Set it to a predefined value, to avoid its evaluation inside zlib */ png_ptr->zstream.data_type = Z_BINARY; png_ptr->mode = PNG_HAVE_IHDR; } -/* write the palette. We are careful not to trust png_color to be in the +/* Write the palette. We are careful not to trust png_color to be in the * correct order for PNG, so people can redefine it to any convenient * structure. */ @@ -561,7 +576,8 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) png_colorp pal_ptr; png_byte buf[3]; - png_debug(1, "in png_write_PLTE\n"); + png_debug(1, "in png_write_PLTE"); + if (( #if defined(PNG_MNG_FEATURES_SUPPORTED) !(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) && @@ -587,9 +603,10 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) } png_ptr->num_palette = (png_uint_16)num_pal; - png_debug1(3, "num_palette = %d\n", png_ptr->num_palette); + png_debug1(3, "num_palette = %d", png_ptr->num_palette); - png_write_chunk_start(png_ptr, png_PLTE, num_pal * 3); + png_write_chunk_start(png_ptr, (png_bytep)png_PLTE, + (png_uint_32)(num_pal * 3)); #ifndef PNG_NO_POINTER_INDEXING for (i = 0, pal_ptr = palette; i < num_pal; i++, pal_ptr++) { @@ -613,14 +630,15 @@ png_write_PLTE(png_structp png_ptr, png_colorp palette, png_uint_32 num_pal) png_ptr->mode |= PNG_HAVE_PLTE; } -/* write an IDAT chunk */ +/* Write an IDAT chunk */ void /* PRIVATE */ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_IDAT; #endif - png_debug(1, "in png_write_IDAT\n"); + + png_debug(1, "in png_write_IDAT"); /* Optimize the CMF field in the zlib stream. */ /* This hack of the zlib stream is compliant to the stream specification. */ @@ -630,9 +648,11 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) unsigned int z_cmf = data[0]; /* zlib compression method and flags */ if ((z_cmf & 0x0f) == 8 && (z_cmf & 0xf0) <= 0x70) { - /* Avoid memory underflows and multiplication overflows. */ - /* The conditions below are practically always satisfied; - however, they still must be checked. */ + /* Avoid memory underflows and multiplication overflows. + * + * The conditions below are practically always satisfied; + * however, they still must be checked. + */ if (length >= 2 && png_ptr->height < 16384 && png_ptr->width < 16384) { @@ -661,25 +681,27 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) "Invalid zlib compression method or flags in IDAT"); } - png_write_chunk(png_ptr, png_IDAT, data, length); + png_write_chunk(png_ptr, (png_bytep)png_IDAT, data, length); png_ptr->mode |= PNG_HAVE_IDAT; } -/* write an IEND chunk */ +/* Write an IEND chunk */ void /* PRIVATE */ png_write_IEND(png_structp png_ptr) { #ifdef PNG_USE_LOCAL_ARRAYS PNG_IEND; #endif - png_debug(1, "in png_write_IEND\n"); - png_write_chunk(png_ptr, png_IEND, png_bytep_NULL, + + png_debug(1, "in png_write_IEND"); + + png_write_chunk(png_ptr, (png_bytep)png_IEND, png_bytep_NULL, (png_size_t)0); png_ptr->mode |= PNG_HAVE_IEND; } #if defined(PNG_WRITE_gAMA_SUPPORTED) -/* write a gAMA chunk */ +/* Write a gAMA chunk */ #ifdef PNG_FLOATING_POINT_SUPPORTED void /* PRIVATE */ png_write_gAMA(png_structp png_ptr, double file_gamma) @@ -690,11 +712,12 @@ png_write_gAMA(png_structp png_ptr, double file_gamma) png_uint_32 igamma; png_byte buf[4]; - png_debug(1, "in png_write_gAMA\n"); + png_debug(1, "in png_write_gAMA"); + /* file_gamma is saved in 1/100,000ths */ igamma = (png_uint_32)(file_gamma * 100000.0 + 0.5); png_save_uint_32(buf, igamma); - png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); + png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); } #endif #ifdef PNG_FIXED_POINT_SUPPORTED @@ -706,16 +729,17 @@ png_write_gAMA_fixed(png_structp png_ptr, png_fixed_point file_gamma) #endif png_byte buf[4]; - png_debug(1, "in png_write_gAMA\n"); + png_debug(1, "in png_write_gAMA"); + /* file_gamma is saved in 1/100,000ths */ png_save_uint_32(buf, (png_uint_32)file_gamma); - png_write_chunk(png_ptr, png_gAMA, buf, (png_size_t)4); + png_write_chunk(png_ptr, (png_bytep)png_gAMA, buf, (png_size_t)4); } #endif #endif #if defined(PNG_WRITE_sRGB_SUPPORTED) -/* write a sRGB chunk */ +/* Write a sRGB chunk */ void /* PRIVATE */ png_write_sRGB(png_structp png_ptr, int srgb_intent) { @@ -724,17 +748,18 @@ png_write_sRGB(png_structp png_ptr, int srgb_intent) #endif png_byte buf[1]; - png_debug(1, "in png_write_sRGB\n"); - if(srgb_intent >= PNG_sRGB_INTENT_LAST) + png_debug(1, "in png_write_sRGB"); + + if (srgb_intent >= PNG_sRGB_INTENT_LAST) png_warning(png_ptr, "Invalid sRGB rendering intent specified"); buf[0]=(png_byte)srgb_intent; - png_write_chunk(png_ptr, png_sRGB, buf, (png_size_t)1); + png_write_chunk(png_ptr, (png_bytep)png_sRGB, buf, (png_size_t)1); } #endif #if defined(PNG_WRITE_iCCP_SUPPORTED) -/* write an iCCP chunk */ +/* Write an iCCP chunk */ void /* PRIVATE */ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, png_charp profile, int profile_len) @@ -747,7 +772,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, compression_state comp; int embedded_profile_len = 0; - png_debug(1, "in png_write_iCCP\n"); + png_debug(1, "in png_write_iCCP"); comp.num_output_ptr = 0; comp.max_output_ptr = 0; @@ -755,12 +780,9 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, comp.input = NULL; comp.input_len = 0; - if (name == NULL || (name_len = png_check_keyword(png_ptr, name, + if ((name_len = png_check_keyword(png_ptr, name, &new_name)) == 0) - { - png_warning(png_ptr, "Empty keyword in iCCP chunk"); return; - } if (compression_type != PNG_COMPRESSION_TYPE_BASE) png_warning(png_ptr, "Unknown compression type in iCCP chunk"); @@ -770,34 +792,44 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, if (profile_len > 3) embedded_profile_len = - ((*( (png_bytep)profile ))<<24) | - ((*( (png_bytep)profile+1))<<16) | - ((*( (png_bytep)profile+2))<< 8) | - ((*( (png_bytep)profile+3)) ); + ((*( (png_bytep)profile ))<<24) | + ((*( (png_bytep)profile + 1))<<16) | + ((*( (png_bytep)profile + 2))<< 8) | + ((*( (png_bytep)profile + 3)) ); + + if (embedded_profile_len < 0) + { + png_warning(png_ptr, + "Embedded profile length in iCCP chunk is negative"); + png_free(png_ptr, new_name); + return; + } if (profile_len < embedded_profile_len) - { - png_warning(png_ptr, - "Embedded profile length too large in iCCP chunk"); - return; - } + { + png_warning(png_ptr, + "Embedded profile length too large in iCCP chunk"); + png_free(png_ptr, new_name); + return; + } if (profile_len > embedded_profile_len) - { - png_warning(png_ptr, - "Truncating profile to actual length in iCCP chunk"); - profile_len = embedded_profile_len; - } + { + png_warning(png_ptr, + "Truncating profile to actual length in iCCP chunk"); + profile_len = embedded_profile_len; + } if (profile_len) - profile_len = png_text_compress(png_ptr, profile, (png_size_t)profile_len, - PNG_COMPRESSION_TYPE_BASE, &comp); + profile_len = png_text_compress(png_ptr, profile, + (png_size_t)profile_len, PNG_COMPRESSION_TYPE_BASE, &comp); - /* make sure we include the NULL after the name and the compression type */ - png_write_chunk_start(png_ptr, png_iCCP, - (png_uint_32)name_len+profile_len+2); - new_name[name_len+1]=0x00; - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 2); + /* Make sure we include the NULL after the name and the compression type */ + png_write_chunk_start(png_ptr, (png_bytep)png_iCCP, + (png_uint_32)(name_len + profile_len + 2)); + new_name[name_len + 1] = 0x00; + png_write_chunk_data(png_ptr, (png_bytep)new_name, + (png_size_t)(name_len + 2)); if (profile_len) png_write_compressed_data_out(png_ptr, &comp); @@ -808,7 +840,7 @@ png_write_iCCP(png_structp png_ptr, png_charp name, int compression_type, #endif #if defined(PNG_WRITE_sPLT_SUPPORTED) -/* write a sPLT chunk */ +/* Write a sPLT chunk */ void /* PRIVATE */ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) { @@ -825,63 +857,61 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) int i; #endif - png_debug(1, "in png_write_sPLT\n"); - if (spalette->name == NULL || (name_len = png_check_keyword(png_ptr, - spalette->name, &new_name))==0) - { - png_warning(png_ptr, "Empty keyword in sPLT chunk"); + png_debug(1, "in png_write_sPLT"); + + if ((name_len = png_check_keyword(png_ptr,spalette->name, &new_name))==0) return; - } - /* make sure we include the NULL after the name */ - png_write_chunk_start(png_ptr, png_sPLT, - (png_uint_32)(name_len + 2 + palette_size)); - png_write_chunk_data(png_ptr, (png_bytep)new_name, name_len + 1); - png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, 1); + /* Make sure we include the NULL after the name */ + png_write_chunk_start(png_ptr, (png_bytep)png_sPLT, + (png_uint_32)(name_len + 2 + palette_size)); + png_write_chunk_data(png_ptr, (png_bytep)new_name, + (png_size_t)(name_len + 1)); + png_write_chunk_data(png_ptr, (png_bytep)&spalette->depth, (png_size_t)1); - /* loop through each palette entry, writing appropriately */ + /* Loop through each palette entry, writing appropriately */ #ifndef PNG_NO_POINTER_INDEXING - for (ep = spalette->entries; epentries+spalette->nentries; ep++) - { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep->red; - entrybuf[1] = (png_byte)ep->green; - entrybuf[2] = (png_byte)ep->blue; - entrybuf[3] = (png_byte)ep->alpha; - png_save_uint_16(entrybuf + 4, ep->frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep->red); - png_save_uint_16(entrybuf + 2, ep->green); - png_save_uint_16(entrybuf + 4, ep->blue); - png_save_uint_16(entrybuf + 6, ep->alpha); - png_save_uint_16(entrybuf + 8, ep->frequency); - } - png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); + for (ep = spalette->entries; epentries + spalette->nentries; ep++) + { + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep->red; + entrybuf[1] = (png_byte)ep->green; + entrybuf[2] = (png_byte)ep->blue; + entrybuf[3] = (png_byte)ep->alpha; + png_save_uint_16(entrybuf + 4, ep->frequency); + } + else + { + png_save_uint_16(entrybuf + 0, ep->red); + png_save_uint_16(entrybuf + 2, ep->green); + png_save_uint_16(entrybuf + 4, ep->blue); + png_save_uint_16(entrybuf + 6, ep->alpha); + png_save_uint_16(entrybuf + 8, ep->frequency); + } + png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); } #else ep=spalette->entries; for (i=0; i>spalette->nentries; i++) { - if (spalette->depth == 8) - { - entrybuf[0] = (png_byte)ep[i].red; - entrybuf[1] = (png_byte)ep[i].green; - entrybuf[2] = (png_byte)ep[i].blue; - entrybuf[3] = (png_byte)ep[i].alpha; - png_save_uint_16(entrybuf + 4, ep[i].frequency); - } - else - { - png_save_uint_16(entrybuf + 0, ep[i].red); - png_save_uint_16(entrybuf + 2, ep[i].green); - png_save_uint_16(entrybuf + 4, ep[i].blue); - png_save_uint_16(entrybuf + 6, ep[i].alpha); - png_save_uint_16(entrybuf + 8, ep[i].frequency); - } - png_write_chunk_data(png_ptr, entrybuf, entry_size); + if (spalette->depth == 8) + { + entrybuf[0] = (png_byte)ep[i].red; + entrybuf[1] = (png_byte)ep[i].green; + entrybuf[2] = (png_byte)ep[i].blue; + entrybuf[3] = (png_byte)ep[i].alpha; + png_save_uint_16(entrybuf + 4, ep[i].frequency); + } + else + { + png_save_uint_16(entrybuf + 0, ep[i].red); + png_save_uint_16(entrybuf + 2, ep[i].green); + png_save_uint_16(entrybuf + 4, ep[i].blue); + png_save_uint_16(entrybuf + 6, ep[i].alpha); + png_save_uint_16(entrybuf + 8, ep[i].frequency); + } + png_write_chunk_data(png_ptr, entrybuf, (png_size_t)entry_size); } #endif @@ -891,7 +921,7 @@ png_write_sPLT(png_structp png_ptr, png_sPLT_tp spalette) #endif #if defined(PNG_WRITE_sBIT_SUPPORTED) -/* write the sBIT chunk */ +/* Write the sBIT chunk */ void /* PRIVATE */ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) { @@ -901,8 +931,9 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) png_byte buf[4]; png_size_t size; - png_debug(1, "in png_write_sBIT\n"); - /* make sure we don't depend upon the order of PNG_COLOR_8 */ + png_debug(1, "in png_write_sBIT"); + + /* Make sure we don't depend upon the order of PNG_COLOR_8 */ if (color_type & PNG_COLOR_MASK_COLOR) { png_byte maxbits; @@ -942,12 +973,12 @@ png_write_sBIT(png_structp png_ptr, png_color_8p sbit, int color_type) buf[size++] = sbit->alpha; } - png_write_chunk(png_ptr, png_sBIT, buf, size); + png_write_chunk(png_ptr, (png_bytep)png_sBIT, buf, size); } #endif #if defined(PNG_WRITE_cHRM_SUPPORTED) -/* write the cHRM chunk */ +/* Write the cHRM chunk */ #ifdef PNG_FLOATING_POINT_SUPPORTED void /* PRIVATE */ png_write_cHRM(png_structp png_ptr, double white_x, double white_y, @@ -958,55 +989,42 @@ png_write_cHRM(png_structp png_ptr, double white_x, double white_y, PNG_cHRM; #endif png_byte buf[32]; - png_uint_32 itemp; - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x < 0 || white_x > 0.8 || white_y < 0 || white_y > 0.8 || - white_x + white_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%f, white_y=%f\n",white_x, white_y); -#endif - return; - } - itemp = (png_uint_32)(white_x * 100000.0 + 0.5); - png_save_uint_32(buf, itemp); - itemp = (png_uint_32)(white_y * 100000.0 + 0.5); - png_save_uint_32(buf + 4, itemp); + png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, + int_green_x, int_green_y, int_blue_x, int_blue_y; - if (red_x < 0 || red_y < 0 || red_x + red_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM red point specified"); - return; - } - itemp = (png_uint_32)(red_x * 100000.0 + 0.5); - png_save_uint_32(buf + 8, itemp); - itemp = (png_uint_32)(red_y * 100000.0 + 0.5); - png_save_uint_32(buf + 12, itemp); + png_debug(1, "in png_write_cHRM"); - if (green_x < 0 || green_y < 0 || green_x + green_y > 1.0) - { - png_warning(png_ptr, "Invalid cHRM green point specified"); - return; - } - itemp = (png_uint_32)(green_x * 100000.0 + 0.5); - png_save_uint_32(buf + 16, itemp); - itemp = (png_uint_32)(green_y * 100000.0 + 0.5); - png_save_uint_32(buf + 20, itemp); + int_white_x = (png_uint_32)(white_x * 100000.0 + 0.5); + int_white_y = (png_uint_32)(white_y * 100000.0 + 0.5); + int_red_x = (png_uint_32)(red_x * 100000.0 + 0.5); + int_red_y = (png_uint_32)(red_y * 100000.0 + 0.5); + int_green_x = (png_uint_32)(green_x * 100000.0 + 0.5); + int_green_y = (png_uint_32)(green_y * 100000.0 + 0.5); + int_blue_x = (png_uint_32)(blue_x * 100000.0 + 0.5); + int_blue_y = (png_uint_32)(blue_y * 100000.0 + 0.5); - if (blue_x < 0 || blue_y < 0 || blue_x + blue_y > 1.0) +#if !defined(PNG_NO_CHECK_cHRM) + if (png_check_cHRM_fixed(png_ptr, int_white_x, int_white_y, + int_red_x, int_red_y, int_green_x, int_green_y, int_blue_x, int_blue_y)) +#endif { - png_warning(png_ptr, "Invalid cHRM blue point specified"); - return; - } - itemp = (png_uint_32)(blue_x * 100000.0 + 0.5); - png_save_uint_32(buf + 24, itemp); - itemp = (png_uint_32)(blue_y * 100000.0 + 0.5); - png_save_uint_32(buf + 28, itemp); + /* Each value is saved in 1/100,000ths */ + + png_save_uint_32(buf, int_white_x); + png_save_uint_32(buf + 4, int_white_y); + + png_save_uint_32(buf + 8, int_red_x); + png_save_uint_32(buf + 12, int_red_y); - png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32); + png_save_uint_32(buf + 16, int_green_x); + png_save_uint_32(buf + 20, int_green_y); + + png_save_uint_32(buf + 24, int_blue_x); + png_save_uint_32(buf + 28, int_blue_y); + + png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); + } } #endif #ifdef PNG_FIXED_POINT_SUPPORTED @@ -1021,50 +1039,34 @@ png_write_cHRM_fixed(png_structp png_ptr, png_fixed_point white_x, #endif png_byte buf[32]; - png_debug(1, "in png_write_cHRM\n"); - /* each value is saved in 1/100,000ths */ - if (white_x > 80000L || white_y > 80000L || white_x + white_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM white point specified"); -#if !defined(PNG_NO_CONSOLE_IO) - fprintf(stderr,"white_x=%ld, white_y=%ld\n",white_x, white_y); -#endif - return; - } - png_save_uint_32(buf, (png_uint_32)white_x); - png_save_uint_32(buf + 4, (png_uint_32)white_y); + png_debug(1, "in png_write_cHRM"); - if (red_x + red_y > 100000L) + /* Each value is saved in 1/100,000ths */ +#if !defined(PNG_NO_CHECK_cHRM) + if (png_check_cHRM_fixed(png_ptr, white_x, white_y, red_x, red_y, + green_x, green_y, blue_x, blue_y)) +#endif { - png_warning(png_ptr, "Invalid cHRM fixed red point specified"); - return; - } - png_save_uint_32(buf + 8, (png_uint_32)red_x); - png_save_uint_32(buf + 12, (png_uint_32)red_y); + png_save_uint_32(buf, (png_uint_32)white_x); + png_save_uint_32(buf + 4, (png_uint_32)white_y); - if (green_x + green_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM green point specified"); - return; - } - png_save_uint_32(buf + 16, (png_uint_32)green_x); - png_save_uint_32(buf + 20, (png_uint_32)green_y); + png_save_uint_32(buf + 8, (png_uint_32)red_x); + png_save_uint_32(buf + 12, (png_uint_32)red_y); - if (blue_x + blue_y > 100000L) - { - png_warning(png_ptr, "Invalid fixed cHRM blue point specified"); - return; - } - png_save_uint_32(buf + 24, (png_uint_32)blue_x); - png_save_uint_32(buf + 28, (png_uint_32)blue_y); + png_save_uint_32(buf + 16, (png_uint_32)green_x); + png_save_uint_32(buf + 20, (png_uint_32)green_y); + + png_save_uint_32(buf + 24, (png_uint_32)blue_x); + png_save_uint_32(buf + 28, (png_uint_32)blue_y); - png_write_chunk(png_ptr, png_cHRM, buf, (png_size_t)32); + png_write_chunk(png_ptr, (png_bytep)png_cHRM, buf, (png_size_t)32); + } } #endif #endif #if defined(PNG_WRITE_tRNS_SUPPORTED) -/* write the tRNS chunk */ +/* Write the tRNS chunk */ void /* PRIVATE */ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, int num_trans, int color_type) @@ -1074,42 +1076,44 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, #endif png_byte buf[6]; - png_debug(1, "in png_write_tRNS\n"); + png_debug(1, "in png_write_tRNS"); + if (color_type == PNG_COLOR_TYPE_PALETTE) { if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette) { - png_warning(png_ptr,"Invalid number of transparent colors specified"); + png_warning(png_ptr, "Invalid number of transparent colors specified"); return; } - /* write the chunk out as it is */ - png_write_chunk(png_ptr, png_tRNS, trans, (png_size_t)num_trans); + /* Write the chunk out as it is */ + png_write_chunk(png_ptr, (png_bytep)png_tRNS, trans, + (png_size_t)num_trans); } else if (color_type == PNG_COLOR_TYPE_GRAY) { - /* one 16 bit value */ - if(tran->gray >= (1 << png_ptr->bit_depth)) + /* One 16 bit value */ + if (tran->gray >= (1 << png_ptr->bit_depth)) { png_warning(png_ptr, "Ignoring attempt to write tRNS chunk out-of-range for bit_depth"); return; } png_save_uint_16(buf, tran->gray); - png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)2); + png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)2); } else if (color_type == PNG_COLOR_TYPE_RGB) { - /* three 16 bit values */ + /* Three 16 bit values */ png_save_uint_16(buf, tran->red); png_save_uint_16(buf + 2, tran->green); png_save_uint_16(buf + 4, tran->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, png_tRNS, buf, (png_size_t)6); + if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) + { + png_warning(png_ptr, + "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8"); + return; + } + png_write_chunk(png_ptr, (png_bytep)png_tRNS, buf, (png_size_t)6); } else { @@ -1119,7 +1123,7 @@ png_write_tRNS(png_structp png_ptr, png_bytep trans, png_color_16p tran, #endif #if defined(PNG_WRITE_bKGD_SUPPORTED) -/* write the background chunk */ +/* Write the background chunk */ void /* PRIVATE */ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) { @@ -1128,7 +1132,8 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) #endif png_byte buf[6]; - png_debug(1, "in png_write_bKGD\n"); + png_debug(1, "in png_write_bKGD"); + if (color_type == PNG_COLOR_TYPE_PALETTE) { if ( @@ -1136,43 +1141,43 @@ png_write_bKGD(png_structp png_ptr, png_color_16p back, int color_type) (png_ptr->num_palette || (!(png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE))) && #endif - back->index > png_ptr->num_palette) + back->index >= png_ptr->num_palette) { png_warning(png_ptr, "Invalid background palette index"); return; } buf[0] = back->index; - png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)1); + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)1); } else if (color_type & PNG_COLOR_MASK_COLOR) { png_save_uint_16(buf, back->red); png_save_uint_16(buf + 2, back->green); png_save_uint_16(buf + 4, back->blue); - if(png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) - { - png_warning(png_ptr, - "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); - return; - } - png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)6); + if (png_ptr->bit_depth == 8 && (buf[0] | buf[2] | buf[4])) + { + png_warning(png_ptr, + "Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8"); + return; + } + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)6); } else { - if(back->gray >= (1 << png_ptr->bit_depth)) + if (back->gray >= (1 << png_ptr->bit_depth)) { png_warning(png_ptr, "Ignoring attempt to write bKGD chunk out-of-range for bit_depth"); return; } png_save_uint_16(buf, back->gray); - png_write_chunk(png_ptr, png_bKGD, buf, (png_size_t)2); + png_write_chunk(png_ptr, (png_bytep)png_bKGD, buf, (png_size_t)2); } } #endif #if defined(PNG_WRITE_hIST_SUPPORTED) -/* write the histogram */ +/* Write the histogram */ void /* PRIVATE */ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) { @@ -1182,16 +1187,18 @@ png_write_hIST(png_structp png_ptr, png_uint_16p hist, int num_hist) int i; png_byte buf[3]; - png_debug(1, "in png_write_hIST\n"); + png_debug(1, "in png_write_hIST"); + if (num_hist > (int)png_ptr->num_palette) { - png_debug2(3, "num_hist = %d, num_palette = %d\n", num_hist, + png_debug2(3, "num_hist = %d, num_palette = %d", num_hist, png_ptr->num_palette); png_warning(png_ptr, "Invalid number of histogram entries specified"); return; } - png_write_chunk_start(png_ptr, png_hIST, (png_uint_32)(num_hist * 2)); + png_write_chunk_start(png_ptr, (png_bytep)png_hIST, + (png_uint_32)(num_hist * 2)); for (i = 0; i < num_hist; i++) { png_save_uint_16(buf, hist[i]); @@ -1221,7 +1228,8 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) int kflag; int kwarn=0; - png_debug(1, "in png_check_keyword\n"); + png_debug(1, "in png_check_keyword"); + *new_key = NULL; if (key == NULL || (key_len = png_strlen(key)) == 0) @@ -1230,7 +1238,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) return ((png_size_t)0); } - png_debug1(2, "Keyword to be checked is '%s'\n", key); + png_debug1(2, "Keyword to be checked is '%s'", key); *new_key = (png_charp)png_malloc_warn(png_ptr, (png_uint_32)(key_len + 2)); if (*new_key == NULL) @@ -1271,8 +1279,8 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) while (*kp == ' ') { - *(kp--) = '\0'; - key_len--; + *(kp--) = '\0'; + key_len--; } } @@ -1284,12 +1292,12 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) while (*kp == ' ') { - kp++; - key_len--; + kp++; + key_len--; } } - png_debug1(2, "Checking for multiple internal spaces in '%s'\n", kp); + png_debug1(2, "Checking for multiple internal spaces in '%s'", kp); /* Remove multiple internal spaces. */ for (kflag = 0, dp = *new_key; *kp != '\0'; kp++) @@ -1311,20 +1319,20 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) } } *dp = '\0'; - if(kwarn) + if (kwarn) png_warning(png_ptr, "extra interior spaces removed from keyword"); if (key_len == 0) { png_free(png_ptr, *new_key); - *new_key=NULL; + *new_key=NULL; png_warning(png_ptr, "Zero length keyword"); } if (key_len > 79) { png_warning(png_ptr, "keyword length must be 1 - 79 characters"); - new_key[79] = '\0'; + (*new_key)[79] = '\0'; key_len = 79; } @@ -1333,7 +1341,7 @@ png_check_keyword(png_structp png_ptr, png_charp key, png_charpp new_key) #endif #if defined(PNG_WRITE_tEXt_SUPPORTED) -/* write a tEXt chunk */ +/* Write a tEXt chunk */ void /* PRIVATE */ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len) @@ -1344,29 +1352,29 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, png_size_t key_len; png_charp new_key; - png_debug(1, "in png_write_tEXt\n"); - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in tEXt chunk"); + png_debug(1, "in png_write_tEXt"); + + if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0) return; - } if (text == NULL || *text == '\0') text_len = 0; else text_len = png_strlen(text); - /* make sure we include the 0 after the key */ - png_write_chunk_start(png_ptr, png_tEXt, (png_uint_32)key_len+text_len+1); + /* Make sure we include the 0 after the key */ + png_write_chunk_start(png_ptr, (png_bytep)png_tEXt, + (png_uint_32)(key_len + text_len + 1)); /* * We leave it to the application to meet PNG-1.0 requirements on the * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); + png_write_chunk_data(png_ptr, (png_bytep)new_key, + (png_size_t)(key_len + 1)); if (text_len) - png_write_chunk_data(png_ptr, (png_bytep)text, text_len); + png_write_chunk_data(png_ptr, (png_bytep)text, (png_size_t)text_len); png_write_chunk_end(png_ptr); png_free(png_ptr, new_key); @@ -1374,7 +1382,7 @@ png_write_tEXt(png_structp png_ptr, png_charp key, png_charp text, #endif #if defined(PNG_WRITE_zTXt_SUPPORTED) -/* write a compressed text chunk */ +/* Write a compressed text chunk */ void /* PRIVATE */ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, png_size_t text_len, int compression) @@ -1387,7 +1395,7 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, png_charp new_key; compression_state comp; - png_debug(1, "in png_write_zTXt\n"); + png_debug(1, "in png_write_zTXt"); comp.num_output_ptr = 0; comp.max_output_ptr = 0; @@ -1395,9 +1403,9 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, comp.input = NULL; comp.input_len = 0; - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) + if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0) { - png_warning(png_ptr, "Empty keyword in zTXt chunk"); + png_free(png_ptr, new_key); return; } @@ -1410,30 +1418,31 @@ png_write_zTXt(png_structp png_ptr, png_charp key, png_charp text, text_len = png_strlen(text); - /* compute the compressed data; do it now for the length */ + /* Compute the compressed data; do it now for the length */ text_len = png_text_compress(png_ptr, text, text_len, compression, &comp); - /* write start of chunk */ - png_write_chunk_start(png_ptr, png_zTXt, (png_uint_32) - (key_len+text_len+2)); - /* write key */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); + /* Write start of chunk */ + png_write_chunk_start(png_ptr, (png_bytep)png_zTXt, + (png_uint_32)(key_len+text_len + 2)); + /* Write key */ + png_write_chunk_data(png_ptr, (png_bytep)new_key, + (png_size_t)(key_len + 1)); png_free(png_ptr, new_key); buf[0] = (png_byte)compression; - /* write compression */ + /* Write compression */ png_write_chunk_data(png_ptr, (png_bytep)buf, (png_size_t)1); - /* write the compressed data */ + /* Write the compressed data */ png_write_compressed_data_out(png_ptr, &comp); - /* close the chunk */ + /* Close the chunk */ png_write_chunk_end(png_ptr); } #endif #if defined(PNG_WRITE_iTXt_SUPPORTED) -/* write an iTXt chunk */ +/* Write an iTXt chunk */ void /* PRIVATE */ png_write_iTXt(png_structp png_ptr, int compression, png_charp key, png_charp lang, png_charp lang_key, png_charp text) @@ -1442,23 +1451,22 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key, PNG_iTXt; #endif png_size_t lang_len, key_len, lang_key_len, text_len; - png_charp new_lang, new_key; + png_charp new_lang; + png_charp new_key = NULL; png_byte cbuf[2]; compression_state comp; - png_debug(1, "in png_write_iTXt\n"); + png_debug(1, "in png_write_iTXt"); comp.num_output_ptr = 0; comp.max_output_ptr = 0; comp.output_ptr = NULL; comp.input = NULL; - if (key == NULL || (key_len = png_check_keyword(png_ptr, key, &new_key))==0) - { - png_warning(png_ptr, "Empty keyword in iTXt chunk"); + if ((key_len = png_check_keyword(png_ptr, key, &new_key))==0) return; - } - if (lang == NULL || (lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0) + + if ((lang_len = png_check_keyword(png_ptr, lang, &new_lang))==0) { png_warning(png_ptr, "Empty language field in iTXt chunk"); new_lang = NULL; @@ -1466,24 +1474,24 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key, } if (lang_key == NULL) - lang_key_len = 0; + lang_key_len = 0; else - lang_key_len = png_strlen(lang_key); + lang_key_len = png_strlen(lang_key); if (text == NULL) text_len = 0; else - text_len = png_strlen(text); + text_len = png_strlen(text); - /* compute the compressed data; do it now for the length */ + /* Compute the compressed data; do it now for the length */ text_len = png_text_compress(png_ptr, text, text_len, compression-2, &comp); - /* make sure we include the compression flag, the compression byte, + /* Make sure we include the compression flag, the compression byte, * and the NULs after the key, lang, and lang_key parts */ - png_write_chunk_start(png_ptr, png_iTXt, + png_write_chunk_start(png_ptr, (png_bytep)png_iTXt, (png_uint_32)( 5 /* comp byte, comp flag, terminators for key, lang and lang_key */ + key_len @@ -1491,27 +1499,29 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key, + lang_key_len + text_len)); - /* - * We leave it to the application to meet PNG-1.0 requirements on the + /* We leave it to the application to meet PNG-1.0 requirements on the * contents of the text. PNG-1.0 through PNG-1.2 discourage the use of * any non-Latin-1 characters except for NEWLINE. ISO PNG will forbid them. * The NUL character is forbidden by PNG-1.0 through PNG-1.2 and ISO PNG. */ - png_write_chunk_data(png_ptr, (png_bytep)new_key, key_len + 1); + png_write_chunk_data(png_ptr, (png_bytep)new_key, + (png_size_t)(key_len + 1)); - /* set the compression flag */ + /* Set the compression flag */ if (compression == PNG_ITXT_COMPRESSION_NONE || \ compression == PNG_TEXT_COMPRESSION_NONE) cbuf[0] = 0; else /* compression == PNG_ITXT_COMPRESSION_zTXt */ cbuf[0] = 1; - /* set the compression method */ + /* Set the compression method */ cbuf[1] = 0; - png_write_chunk_data(png_ptr, cbuf, 2); + png_write_chunk_data(png_ptr, cbuf, (png_size_t)2); cbuf[0] = 0; - png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), lang_len + 1); - png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), lang_key_len + 1); + png_write_chunk_data(png_ptr, (new_lang ? (png_bytep)new_lang : cbuf), + (png_size_t)(lang_len + 1)); + png_write_chunk_data(png_ptr, (lang_key ? (png_bytep)lang_key : cbuf), + (png_size_t)(lang_key_len + 1)); png_write_compressed_data_out(png_ptr, &comp); png_write_chunk_end(png_ptr); @@ -1521,7 +1531,7 @@ png_write_iTXt(png_structp png_ptr, int compression, png_charp key, #endif #if defined(PNG_WRITE_oFFs_SUPPORTED) -/* write the oFFs chunk */ +/* Write the oFFs chunk */ void /* PRIVATE */ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, int unit_type) @@ -1531,7 +1541,8 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, #endif png_byte buf[9]; - png_debug(1, "in png_write_oFFs\n"); + png_debug(1, "in png_write_oFFs"); + if (unit_type >= PNG_OFFSET_LAST) png_warning(png_ptr, "Unrecognized unit type for oFFs chunk"); @@ -1539,11 +1550,11 @@ png_write_oFFs(png_structp png_ptr, png_int_32 x_offset, png_int_32 y_offset, png_save_int_32(buf + 4, y_offset); buf[8] = (png_byte)unit_type; - png_write_chunk(png_ptr, png_oFFs, buf, (png_size_t)9); + png_write_chunk(png_ptr, (png_bytep)png_oFFs, buf, (png_size_t)9); } #endif #if defined(PNG_WRITE_pCAL_SUPPORTED) -/* write the pCAL chunk (described in the PNG extensions document) */ +/* Write the pCAL chunk (described in the PNG extensions document) */ void /* PRIVATE */ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams, png_charp units, png_charpp params) @@ -1557,31 +1568,34 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, png_charp new_purpose; int i; - png_debug1(1, "in png_write_pCAL (%d parameters)\n", nparams); + png_debug1(1, "in png_write_pCAL (%d parameters)", nparams); + if (type >= PNG_EQUATION_LAST) png_warning(png_ptr, "Unrecognized equation type for pCAL chunk"); purpose_len = png_check_keyword(png_ptr, purpose, &new_purpose) + 1; - png_debug1(3, "pCAL purpose length = %d\n", (int)purpose_len); + png_debug1(3, "pCAL purpose length = %d", (int)purpose_len); units_len = png_strlen(units) + (nparams == 0 ? 0 : 1); - png_debug1(3, "pCAL units length = %d\n", (int)units_len); + png_debug1(3, "pCAL units length = %d", (int)units_len); total_len = purpose_len + units_len + 10; - params_len = (png_uint_32p)png_malloc(png_ptr, (png_uint_32)(nparams - *png_sizeof(png_uint_32))); + params_len = (png_uint_32p)png_malloc(png_ptr, + (png_uint_32)(nparams * png_sizeof(png_uint_32))); /* Find the length of each parameter, making sure we don't count the null terminator for the last parameter. */ for (i = 0; i < nparams; i++) { params_len[i] = png_strlen(params[i]) + (i == nparams - 1 ? 0 : 1); - png_debug2(3, "pCAL parameter %d length = %lu\n", i, params_len[i]); + png_debug2(3, "pCAL parameter %d length = %lu", i, + (unsigned long) params_len[i]); total_len += (png_size_t)params_len[i]; } - png_debug1(3, "pCAL total length = %d\n", (int)total_len); - png_write_chunk_start(png_ptr, png_pCAL, (png_uint_32)total_len); - png_write_chunk_data(png_ptr, (png_bytep)new_purpose, purpose_len); + png_debug1(3, "pCAL total length = %d", (int)total_len); + png_write_chunk_start(png_ptr, (png_bytep)png_pCAL, (png_uint_32)total_len); + png_write_chunk_data(png_ptr, (png_bytep)new_purpose, + (png_size_t)purpose_len); png_save_int_32(buf, X0); png_save_int_32(buf + 4, X1); buf[8] = (png_byte)type; @@ -1603,7 +1617,7 @@ png_write_pCAL(png_structp png_ptr, png_charp purpose, png_int_32 X0, #endif #if defined(PNG_WRITE_sCAL_SUPPORTED) -/* write the sCAL chunk */ +/* Write the sCAL chunk */ #if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO) void /* PRIVATE */ png_write_sCAL(png_structp png_ptr, int unit, double width, double height) @@ -1614,7 +1628,7 @@ png_write_sCAL(png_structp png_ptr, int unit, double width, double height) char buf[64]; png_size_t total_len; - png_debug(1, "in png_write_sCAL\n"); + png_debug(1, "in png_write_sCAL"); buf[0] = (char)unit; #if defined(_WIN32_WCE) @@ -1639,8 +1653,8 @@ png_write_sCAL(png_structp png_ptr, int unit, double width, double height) total_len += png_strlen(buf + total_len); #endif - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, png_sCAL, (png_bytep)buf, total_len); + png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); + png_write_chunk(png_ptr, (png_bytep)png_sCAL, (png_bytep)buf, total_len); } #else #ifdef PNG_FIXED_POINT_SUPPORTED @@ -1654,7 +1668,7 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, png_byte buf[64]; png_size_t wlen, hlen, total_len; - png_debug(1, "in png_write_sCAL_s\n"); + png_debug(1, "in png_write_sCAL_s"); wlen = png_strlen(width); hlen = png_strlen(height); @@ -1666,18 +1680,18 @@ png_write_sCAL_s(png_structp png_ptr, int unit, png_charp width, } buf[0] = (png_byte)unit; - png_memcpy(buf + 1, width, wlen + 1); /* append the '\0' here */ - png_memcpy(buf + wlen + 2, height, hlen); /* do NOT append the '\0' here */ + png_memcpy(buf + 1, width, wlen + 1); /* Append the '\0' here */ + png_memcpy(buf + wlen + 2, height, hlen); /* Do NOT append the '\0' here */ - png_debug1(3, "sCAL total length = %u\n", (unsigned int)total_len); - png_write_chunk(png_ptr, png_sCAL, buf, total_len); + png_debug1(3, "sCAL total length = %u", (unsigned int)total_len); + png_write_chunk(png_ptr, (png_bytep)png_sCAL, buf, total_len); } #endif #endif #endif #if defined(PNG_WRITE_pHYs_SUPPORTED) -/* write the pHYs chunk */ +/* Write the pHYs chunk */ void /* PRIVATE */ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit, @@ -1688,7 +1702,8 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, #endif png_byte buf[9]; - png_debug(1, "in png_write_pHYs\n"); + png_debug(1, "in png_write_pHYs"); + if (unit_type >= PNG_RESOLUTION_LAST) png_warning(png_ptr, "Unrecognized unit type for pHYs chunk"); @@ -1696,7 +1711,7 @@ png_write_pHYs(png_structp png_ptr, png_uint_32 x_pixels_per_unit, png_save_uint_32(buf + 4, y_pixels_per_unit); buf[8] = (png_byte)unit_type; - png_write_chunk(png_ptr, png_pHYs, buf, (png_size_t)9); + png_write_chunk(png_ptr, (png_bytep)png_pHYs, buf, (png_size_t)9); } #endif @@ -1712,7 +1727,8 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time) #endif png_byte buf[7]; - png_debug(1, "in png_write_tIME\n"); + png_debug(1, "in png_write_tIME"); + if (mod_time->month > 12 || mod_time->month < 1 || mod_time->day > 31 || mod_time->day < 1 || mod_time->hour > 23 || mod_time->second > 60) @@ -1728,83 +1744,86 @@ png_write_tIME(png_structp png_ptr, png_timep mod_time) buf[5] = mod_time->minute; buf[6] = mod_time->second; - png_write_chunk(png_ptr, png_tIME, buf, (png_size_t)7); + png_write_chunk(png_ptr, (png_bytep)png_tIME, buf, (png_size_t)7); } #endif -/* initializes the row writing capability of libpng */ +/* Initializes the row writing capability of libpng */ void /* PRIVATE */ png_write_start_row(png_structp png_ptr) { #ifdef PNG_WRITE_INTERLACING_SUPPORTED #ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ + /* Start of interlace block in the y direction */ int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ + /* Offset to next interlace block in the y direction */ int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif #endif png_size_t buf_size; - png_debug(1, "in png_write_start_row\n"); + png_debug(1, "in png_write_start_row"); + buf_size = (png_size_t)(PNG_ROWBYTES( - png_ptr->usr_channels*png_ptr->usr_bit_depth,png_ptr->width)+1); + png_ptr->usr_channels*png_ptr->usr_bit_depth, png_ptr->width) + 1); - /* set up row buffer */ - png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); + /* Set up row buffer */ + png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, + (png_uint_32)buf_size); png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE; -#ifndef PNG_NO_WRITE_FILTERING - /* set up filtering buffer, if using this filter */ +#ifndef PNG_NO_WRITE_FILTER + /* Set up filtering buffer, if using this filter */ if (png_ptr->do_filter & PNG_FILTER_SUB) { png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_uint_32)(png_ptr->rowbytes + 1)); png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; } /* We only need to keep the previous row if we are using one of these. */ if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) { - /* set up previous row buffer */ - png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)buf_size); - png_memset(png_ptr->prev_row, 0, buf_size); + /* Set up previous row buffer */ + png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, + (png_uint_32)buf_size); + png_memset(png_ptr->prev_row, 0, buf_size); if (png_ptr->do_filter & PNG_FILTER_UP) { png_ptr->up_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_uint_32)(png_ptr->rowbytes + 1)); png_ptr->up_row[0] = PNG_FILTER_VALUE_UP; } if (png_ptr->do_filter & PNG_FILTER_AVG) { png_ptr->avg_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_uint_32)(png_ptr->rowbytes + 1)); png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; } if (png_ptr->do_filter & PNG_FILTER_PAETH) { png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr, - (png_ptr->rowbytes + 1)); + (png_uint_32)(png_ptr->rowbytes + 1)); png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH; } -#endif /* PNG_NO_WRITE_FILTERING */ } +#endif /* PNG_NO_WRITE_FILTER */ #ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, we need to set up width and height of pass */ + /* If interlaced, we need to set up width and height of pass */ if (png_ptr->interlaced) { if (!(png_ptr->transformations & PNG_INTERLACE)) @@ -1836,34 +1855,35 @@ png_write_finish_row(png_structp png_ptr) { #ifdef PNG_WRITE_INTERLACING_SUPPORTED #ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; - /* start of interlace block in the y direction */ + /* Start of interlace block in the y direction */ int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1}; - /* offset to next interlace block in the y direction */ + /* Offset to next interlace block in the y direction */ int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; #endif #endif int ret; - png_debug(1, "in png_write_finish_row\n"); - /* next row */ + png_debug(1, "in png_write_finish_row"); + + /* Next row */ png_ptr->row_number++; - /* see if we are done */ + /* See if we are done */ if (png_ptr->row_number < png_ptr->num_rows) return; #ifdef PNG_WRITE_INTERLACING_SUPPORTED - /* if interlaced, go to next pass */ + /* If interlaced, go to next pass */ if (png_ptr->interlaced) { png_ptr->row_number = 0; @@ -1873,7 +1893,7 @@ png_write_finish_row(png_structp png_ptr) } else { - /* loop until we find a non-zero width or height pass */ + /* Loop until we find a non-zero width or height pass */ do { png_ptr->pass++; @@ -1893,28 +1913,28 @@ png_write_finish_row(png_structp png_ptr) } - /* reset the row above the image for the next pass */ + /* Reset the row above the image for the next pass */ if (png_ptr->pass < 7) { if (png_ptr->prev_row != NULL) png_memset(png_ptr->prev_row, 0, (png_size_t)(PNG_ROWBYTES(png_ptr->usr_channels* - png_ptr->usr_bit_depth,png_ptr->width))+1); + png_ptr->usr_bit_depth, png_ptr->width)) + 1); return; } } #endif - /* if we get here, we've just written the last row, so we need + /* If we get here, we've just written the last row, so we need to flush the compressor */ do { - /* tell the compressor we are done */ + /* Tell the compressor we are done */ ret = deflate(&png_ptr->zstream, Z_FINISH); - /* check for an error */ + /* Check for an error */ if (ret == Z_OK) { - /* check to see if we need more room */ + /* Check to see if we need more room */ if (!(png_ptr->zstream.avail_out)) { png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); @@ -1931,7 +1951,7 @@ png_write_finish_row(png_structp png_ptr) } } while (ret != Z_STREAM_END); - /* write any extra space */ + /* Write any extra space */ if (png_ptr->zstream.avail_out < png_ptr->zbuf_size) { png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size - @@ -1954,24 +1974,25 @@ void /* PRIVATE */ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) { #ifdef PNG_USE_LOCAL_ARRAYS - /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */ + /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ - /* start of interlace block */ + /* Start of interlace block */ int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0}; - /* offset to next interlace block */ + /* Offset to next interlace block */ int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; #endif - png_debug(1, "in png_do_write_interlace\n"); - /* we don't have to do anything on the last pass (6) */ + png_debug(1, "in png_do_write_interlace"); + + /* We don't have to do anything on the last pass (6) */ #if defined(PNG_USELESS_TESTS_SUPPORTED) if (row != NULL && row_info != NULL && pass < 6) #else if (pass < 6) #endif { - /* each pixel depth is handled separately */ + /* Each pixel depth is handled separately */ switch (row_info->pixel_depth) { case 1: @@ -2082,27 +2103,27 @@ png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass) png_uint_32 row_width = row_info->width; png_size_t pixel_bytes; - /* start at the beginning */ + /* Start at the beginning */ dp = row; - /* find out how many bytes each pixel takes up */ + /* Find out how many bytes each pixel takes up */ pixel_bytes = (row_info->pixel_depth >> 3); - /* loop through the row, only looking at the pixels that + /* Loop through the row, only looking at the pixels that matter */ for (i = png_pass_start[pass]; i < row_width; i += png_pass_inc[pass]) { - /* find out where the original pixel is */ + /* Find out where the original pixel is */ sp = row + (png_size_t)i * pixel_bytes; - /* move the pixel */ + /* Move the pixel */ if (dp != sp) png_memcpy(dp, sp, pixel_bytes); - /* next pixel */ + /* Next pixel */ dp += pixel_bytes; } break; } } - /* set new row width */ + /* Set new row width */ row_info->width = (row_info->width + png_pass_inc[pass] - 1 - png_pass_start[pass]) / @@ -2130,12 +2151,13 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) png_uint_32 mins, bpp; png_byte filter_to_do = png_ptr->do_filter; png_uint_32 row_bytes = row_info->rowbytes; -#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) +#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED int num_p_filters = (int)png_ptr->num_prev_filters; -#endif +#endif - png_debug(1, "in png_write_find_filter\n"); - /* find out how many bytes offset each pixel is */ + png_debug(1, "in png_write_find_filter"); + + /* Find out how many bytes offset each pixel is */ bpp = (row_info->pixel_depth + 7) >> 3; prev_row = png_ptr->prev_row; @@ -2222,9 +2244,9 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) mins = sum; } - /* sub filter */ + /* Sub filter */ if (filter_to_do == PNG_FILTER_SUB) - /* it's the only filter so no testing is needed */ + /* It's the only filter so no testing is needed */ { png_bytep rp, lp, dp; png_uint_32 i; @@ -2339,7 +2361,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) } } - /* up filter */ + /* Up filter */ if (filter_to_do == PNG_FILTER_UP) { png_bytep rp, dp, pp; @@ -2442,7 +2464,7 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) } } - /* avg filter */ + /* Avg filter */ if (filter_to_do == PNG_FILTER_AVG) { png_bytep rp, dp, pp, lp; @@ -2743,20 +2765,21 @@ png_write_find_filter(png_structp png_ptr, png_row_infop row_info) void /* PRIVATE */ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) { - png_debug(1, "in png_write_filtered_row\n"); - png_debug1(2, "filter = %d\n", filtered_row[0]); - /* set up the zlib input buffer */ + png_debug(1, "in png_write_filtered_row"); + + png_debug1(2, "filter = %d", filtered_row[0]); + /* Set up the zlib input buffer */ png_ptr->zstream.next_in = filtered_row; png_ptr->zstream.avail_in = (uInt)png_ptr->row_info.rowbytes + 1; - /* repeat until we have compressed all the data */ + /* Repeat until we have compressed all the data */ do { - int ret; /* return of zlib */ + int ret; /* Return of zlib */ - /* compress the data */ + /* Compress the data */ ret = deflate(&png_ptr->zstream, Z_NO_FLUSH); - /* check for compression errors */ + /* Check for compression errors */ if (ret != Z_OK) { if (png_ptr->zstream.msg != NULL) @@ -2765,18 +2788,18 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) png_error(png_ptr, "zlib error"); } - /* see if it is time to write another IDAT */ + /* See if it is time to write another IDAT */ if (!(png_ptr->zstream.avail_out)) { - /* write the IDAT and reset the zlib output buffer */ + /* Write the IDAT and reset the zlib output buffer */ png_write_IDAT(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size); png_ptr->zstream.next_out = png_ptr->zbuf; png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size; } - /* repeat until all data has been compressed */ + /* Repeat until all data has been compressed */ } while (png_ptr->zstream.avail_in); - /* swap the current and previous rows */ + /* Swap the current and previous rows */ if (png_ptr->prev_row != NULL) { png_bytep tptr; @@ -2786,7 +2809,7 @@ png_write_filtered_row(png_structp png_ptr, png_bytep filtered_row) png_ptr->row_buf = tptr; } - /* finish row - updates counters and flushes zlib if last row */ + /* Finish row - updates counters and flushes zlib if last row */ png_write_finish_row(png_ptr); #if defined(PNG_WRITE_FLUSH_SUPPORTED) diff --git a/src/3rdparty/libpng/scripts/CMakeLists.txt b/src/3rdparty/libpng/scripts/CMakeLists.txt index fceea62..c040c03 100644 --- a/src/3rdparty/libpng/scripts/CMakeLists.txt +++ b/src/3rdparty/libpng/scripts/CMakeLists.txt @@ -1,17 +1,24 @@ - -project(PNG) +project(PNG C) +cmake_minimum_required(VERSION 2.4.3) # Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h set(PNGLIB_MAJOR 1) set(PNGLIB_MINOR 2) -set(PNGLIB_RELEASE 29) +set(PNGLIB_RELEASE 40) set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) +set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) + # needed packages find_package(ZLIB REQUIRED) +include_directories(${ZLIB_INCLUDE_DIR}) + if(NOT WIN32) find_library(M_LIBRARY NAMES m @@ -20,24 +27,33 @@ if(NOT WIN32) if(NOT M_LIBRARY) message(STATUS "math library 'libm' not found - floating point support disabled") - endif(NOT M_LIBRARY) -else(NOT WIN32) + endif() +else() # not needed on windows set(M_LIBRARY "") -endif(NOT WIN32) - +endif() # COMMAND LINE OPTIONS -option(PNG_SHARED "Build shared lib" YES) -option(PNG_STATIC "Build static lib" YES) +if(DEFINED PNG_SHARED) + option(PNG_SHARED "Build shared lib" ${PNG_SHARED}) +else() + option(PNG_SHARED "Build shared lib" ON) +endif() +if(DEFINED PNG_STATIC) + option(PNG_STATIC "Build static lib" ${PNG_STATIC}) +else() + option(PNG_STATIC "Build static lib" ON) +endif() + if(MINGW) option(PNG_TESTS "Build pngtest" NO) else(MINGW) option(PNG_TESTS "Build pngtest" YES) endif(MINGW) + option(PNG_NO_CONSOLE_IO "FIXME" YES) option(PNG_NO_STDIO "FIXME" YES) -option(PNG_DEBUG "Build with debug output" YES) +option(PNG_DEBUG "Build with debug output" NO) option(PNGARG "FIXME" YES) #TODO: # PNG_CONSOLE_IO_SUPPORTED @@ -54,20 +70,16 @@ if(NOT WIN32) set(png_asm_tmp "OFF") endif("uname_output" MATCHES "^.*i[1-9]86.*$") endif(uname_executable) -else(NOT WIN32) +else() # this env var is normally only set on win64 SET(TEXT "ProgramFiles(x86)") if("$ENV{${TEXT}}" STREQUAL "") set(png_asm_tmp "ON") endif("$ENV{${TEXT}}" STREQUAL "") -endif(NOT WIN32) +endif() # SET LIBNAME -# msvc does not append 'lib' - do it here to have consistent name -if(MSVC) - set(PNG_LIB_NAME lib) -endif(MSVC) -set(PNG_LIB_NAME ${PNG_LIB_NAME}png${PNGLIB_MAJOR}${PNGLIB_MINOR}) +set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR}) # to distinguish between debug and release lib set(CMAKE_DEBUG_POSTFIX "d") @@ -101,54 +113,67 @@ if(MSVC) add_definitions(-DPNG_NO_MODULEDEF -D_CRT_SECURE_NO_DEPRECATE) endif(MSVC) -add_definitions(-DZLIB_DLL) +if(PNG_SHARED OR NOT MSVC) + #if building msvc static this has NOT do be defined + add_definitions(-DZLIB_DLL) +endif() add_definitions(-DLIBPNG_NO_MMX) add_definitions(-DPNG_NO_MMX_CODE) if(PNG_CONSOLE_IO_SUPPORTED) add_definitions(-DPNG_CONSOLE_IO_SUPPORTED) -endif(PNG_CONSOLE_IO_SUPPORTED) +endif() if(PNG_NO_CONSOLE_IO) add_definitions(-DPNG_NO_CONSOLE_IO) -endif(PNG_NO_CONSOLE_IO) +endif() if(PNG_NO_STDIO) add_definitions(-DPNG_NO_STDIO) -endif(PNG_NO_STDIO) +endif() if(PNG_DEBUG) add_definitions(-DPNG_DEBUG) -endif(PNG_DEBUG) +endif() if(NOT M_LIBRARY AND NOT WIN32) add_definitions(-DPNG_NO_FLOATING_POINT_SUPPORTED) -endif(NOT M_LIBRARY AND NOT WIN32) +endif() # NOW BUILD OUR TARGET include_directories(${PNG_SOURCE_DIR} ${ZLIB_INCLUDE_DIR}) if(PNG_SHARED) add_library(${PNG_LIB_NAME} SHARED ${libpng_sources}) + if(MSVC) + # msvc does not append 'lib' - do it here to have consistent name + set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib") + endif() target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY}) -endif(PNG_SHARED) +endif() + if(PNG_STATIC) # does not work without changing name set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static) add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources}) -endif(PNG_STATIC) + if(MSVC) + # msvc does not append 'lib' - do it here to have consistent name + set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib") + endif() +endif() + if(PNG_SHARED AND WIN32) set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL) -endif(PNG_SHARED AND WIN32) +endif() -if(PNG_TESTS) +if(PNG_TESTS AND PNG_SHARED) # does not work with msvc due to png_lib_ver issue add_executable(pngtest ${pngtest_sources}) target_link_libraries(pngtest ${PNG_LIB_NAME}) # add_test(pngtest ${PNG_SOURCE_DIR}/pngtest.png) -endif(PNG_TESTS) +endif() # CREATE PKGCONFIG FILES @@ -168,31 +193,49 @@ configure_file(${PNG_SOURCE_DIR}/scripts/libpng-config.in ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config) # SET UP LINKS -set_target_properties(${PNG_LIB_NAME} PROPERTIES -# VERSION 0.${PNGLIB_RELEASE}.1.2.29 +if(PNG_SHARED) + set_target_properties(${PNG_LIB_NAME} PROPERTIES +# VERSION 0.${PNGLIB_RELEASE}.1.2.40 VERSION 0.${PNGLIB_RELEASE}.0 SOVERSION 0 CLEAN_DIRECT_OUTPUT 1) -if(NOT WIN32) - # that's uncool on win32 - it overwrites our static import lib... - set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES - OUTPUT_NAME ${PNG_LIB_NAME} - CLEAN_DIRECT_OUTPUT 1) -endif(NOT WIN32) -# INSTALL -install_targets(/lib ${PNG_LIB_NAME}) +endif() if(PNG_STATIC) - install_targets(/lib ${PNG_LIB_NAME_STATIC}) -endif(PNG_STATIC) + if(NOT WIN32) + # that's uncool on win32 - it overwrites our static import lib... + set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES + OUTPUT_NAME ${PNG_LIB_NAME} + CLEAN_DIRECT_OUTPUT 1) + endif() +endif() +# INSTALL +if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) + if(PNG_SHARED) + install(TARGETS ${PNG_LIB_NAME} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + endif() + if(PNG_STATIC) + install(TARGETS ${PNG_LIB_NAME_STATIC} + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) + endif() +endif() + +if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL ) install(FILES png.h pngconf.h DESTINATION include) install(FILES png.h pngconf.h DESTINATION include/${PNGLIB_NAME}) -install(FILES libpng.3 libpngpf.3 DESTINATION man/man3) -install(FILES png.5 DESTINATION man/man5) -install(FILES ${PNG_BINARY_DIR}/libpng.pc DESTINATION lib/pkgconfig) -install(FILES ${PNG_BINARY_DIR}/libpng-config DESTINATION bin) -install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc DESTINATION lib/pkgconfig) -install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) +endif() +if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL ) + install(FILES libpng.3 libpngpf.3 DESTINATION man/man3) + install(FILES png.5 DESTINATION man/man5) + install(FILES ${PNG_BINARY_DIR}/libpng.pc DESTINATION lib/pkgconfig) + install(FILES ${PNG_BINARY_DIR}/libpng-config DESTINATION bin) + install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}.pc DESTINATION lib/pkgconfig) + install(FILES ${PNG_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin) +endif() # what's with libpng.txt and all the extra files? diff --git a/src/3rdparty/libpng/scripts/descrip.mms b/src/3rdparty/libpng/scripts/descrip.mms index 3584b0d..f3a8d7b 100644 --- a/src/3rdparty/libpng/scripts/descrip.mms +++ b/src/3rdparty/libpng/scripts/descrip.mms @@ -1,6 +1,6 @@ cc_defs = /inc=$(ZLIBSRC) -c_deb = +c_deb = .ifdef __DECC__ pref = /prefix=all @@ -29,7 +29,7 @@ test : pngtest.exe run pngtest clean : - delete *.obj;*,*.exe;* + delete *.obj;*,*.exe; # Other dependencies. @@ -44,9 +44,9 @@ pngerror.obj : png.h, pngconf.h pngmem.obj : png.h, pngconf.h pngrio.obj : png.h, pngconf.h pngwio.obj : png.h, pngconf.h -pngtest.obj : png.h, pngconf.h pngtrans.obj : png.h, pngconf.h pngwrite.obj : png.h, pngconf.h pngwtran.obj : png.h, pngconf.h pngwutil.obj : png.h, pngconf.h +pngtest.obj : png.h, pngconf.h diff --git a/src/3rdparty/libpng/scripts/libpng-config-head.in b/src/3rdparty/libpng/scripts/libpng-config-head.in index 1569938..38fcc08 100755 --- a/src/3rdparty/libpng/scripts/libpng-config-head.in +++ b/src/3rdparty/libpng/scripts/libpng-config-head.in @@ -4,11 +4,14 @@ # provides configuration info for libpng. # Copyright (C) 2002 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Modeled after libxml-config. -version=1.2.29 +version=1.2.40 prefix="" libdir="" libs="" diff --git a/src/3rdparty/libpng/scripts/libpng-config.in b/src/3rdparty/libpng/scripts/libpng-config.in index f227ee5..7ae7d50 100755 --- a/src/3rdparty/libpng/scripts/libpng-config.in +++ b/src/3rdparty/libpng/scripts/libpng-config.in @@ -4,7 +4,10 @@ # provides configuration info for libpng. # Copyright (C) 2002, 2004, 2006, 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Modeled after libxml-config. @@ -14,7 +17,7 @@ exec_prefix="@exec_prefix@" libdir="@libdir@" includedir="@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@" -all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ -lz -lm" +all_libs="-lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ @LIBS@" I_opts="-I${includedir}" L_opts="-L${libdir}" R_opts="" diff --git a/src/3rdparty/libpng/scripts/libpng.icc b/src/3rdparty/libpng/scripts/libpng.icc index f9c51af..6635963 100644 --- a/src/3rdparty/libpng/scripts/libpng.icc +++ b/src/3rdparty/libpng/scripts/libpng.icc @@ -1,13 +1,16 @@ // Project file for libpng (static) // IBM VisualAge/C++ version 4.0 or later // Copyright (C) 2000 Cosmin Truta -// For conditions of distribution and use, see copyright notice in png.h +// +// This code is released under the libpng license. +// For conditions of distribution and use, see the disclaimer +// and license in png.h +// // Notes: // All modules are compiled in C mode // Tested with IBM VAC++ 4.0 under Win32 // Expected to work with IBM VAC++ 4.0 or later under OS/2 and Win32 // Can be easily adapted for IBM VAC++ 4.0 or later under AIX -// For conditions of distribution and use, see copyright notice in png.h option incl(searchpath, "../zlib"), opt(level, "2"), link(libsearchpath, "../zlib") diff --git a/src/3rdparty/libpng/scripts/libpng.pc-configure.in b/src/3rdparty/libpng/scripts/libpng.pc-configure.in index e7c5e23..cadb555 100644 --- a/src/3rdparty/libpng/scripts/libpng.pc-configure.in +++ b/src/3rdparty/libpng/scripts/libpng.pc-configure.in @@ -1,10 +1,11 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ libdir=@libdir@ -includedir=@includedir@/libpng12 +includedir=@includedir@/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ Name: libpng Description: Loads and saves PNG files -Version: 1.2.29 -Libs: -L${libdir} -lpng12 +Version: @PNGLIB_VERSION@ +Libs: -L${libdir} -lpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ +Libs.private: @LIBS@ Cflags: -I${includedir} @LIBPNG_NO_MMX@ diff --git a/src/3rdparty/libpng/scripts/libpng.pc.in b/src/3rdparty/libpng/scripts/libpng.pc.in index bcf6162..f4ab0d2 100644 --- a/src/3rdparty/libpng/scripts/libpng.pc.in +++ b/src/3rdparty/libpng/scripts/libpng.pc.in @@ -5,6 +5,6 @@ includedir=@includedir@/libpng12 Name: libpng Description: Loads and saves PNG files -Version: 1.2.29 +Version: 1.2.40 Libs: -L${libdir} -lpng12 Cflags: -I${includedir} diff --git a/src/3rdparty/libpng/scripts/makefile.32sunu b/src/3rdparty/libpng/scripts/makefile.32sunu index 7b419f2..2ce4a3a 100644 --- a/src/3rdparty/libpng/scripts/makefile.32sunu +++ b/src/3rdparty/libpng/scripts/makefile.32sunu @@ -3,12 +3,15 @@ # Copyright (C) 2002, 2006 Glenn Randers-Pehrson # Copyright (C) 1998 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME=libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/src/3rdparty/libpng/scripts/makefile.64sunu b/src/3rdparty/libpng/scripts/makefile.64sunu index a7762cc..134e792 100644 --- a/src/3rdparty/libpng/scripts/makefile.64sunu +++ b/src/3rdparty/libpng/scripts/makefile.64sunu @@ -3,12 +3,15 @@ # Copyright (C) 2002, 2006 Glenn Randers-Pehrson # Copyright (C) 1998 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME=libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/src/3rdparty/libpng/scripts/makefile.acorn b/src/3rdparty/libpng/scripts/makefile.acorn index 470cf89..a0e577b 100644 --- a/src/3rdparty/libpng/scripts/makefile.acorn +++ b/src/3rdparty/libpng/scripts/makefile.acorn @@ -6,11 +6,10 @@ CCflags = -c -depend !Depend -IC:,Zlib: -g -throwback -DRISCOS -fnah C++flags = -c -depend !Depend -IC: -throwback Linkflags = -aif -c++ -o $@ ObjAsmflags = -throwback -NoCache -depend !Depend -CMHGflags = +CMHGflags = LibFileflags = -c -l -o $@ Squeezeflags = -o $@ - # Final targets: @.libpng-lib: @.o.png @.o.pngerror @.o.pngrio @.o.pngwio @.o.pngmem \ @.o.pngpread @.o.pngset @.o.pngget @.o.pngread @.o.pngrtran \ diff --git a/src/3rdparty/libpng/scripts/makefile.aix b/src/3rdparty/libpng/scripts/makefile.aix index 99e3868..2cb6e67 100644 --- a/src/3rdparty/libpng/scripts/makefile.aix +++ b/src/3rdparty/libpng/scripts/makefile.aix @@ -1,9 +1,12 @@ # makefile for libpng using gcc (generic, static library) -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006-2009 Glenn Randers-Pehrson # Copyright (C) 2000 Cosmin Truta # Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc) # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Location of the zlib library and include files ZLIBINC = ../zlib @@ -20,7 +23,7 @@ LN_SF = ln -f -s LIBNAME=libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) prefix=/usr/local @@ -44,7 +47,7 @@ CDEBUG = -g -DPNG_DEBUG=5 LDDEBUG = CRELEASE = -O2 LDRELEASE = -s -WARNMORE=-Wall +WARNMORE=-W -Wall CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) LDFLAGS = -L. -L$(ZLIBLIB) -lpng12 -lz -lm $(LDRELEASE) @@ -54,7 +57,7 @@ A=.a E= # Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ +OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) @@ -94,20 +97,20 @@ install: $(LIBNAME)$(A) clean: $(RM_F) *.o $(LIBNAME)$(A) pngtest pngout.png -png$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h pngrtran$(O): png.h pngconf.h pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h pngwrite$(O): png.h pngconf.h pngwtran$(O): png.h pngconf.h pngwutil$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.amiga b/src/3rdparty/libpng/scripts/makefile.amiga index 79cb424..50977c7 100644 --- a/src/3rdparty/libpng/scripts/makefile.amiga +++ b/src/3rdparty/libpng/scripts/makefile.amiga @@ -1,7 +1,10 @@ # Commodore Amiga Makefile # makefile for libpng and SAS C V6.5x compiler # Copyright (C) 1995-2000 Wolf Faust -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # # Note: Use #define PNG_READ_BIG_ENDIAN_SUPPORTED in pngconf.h # diff --git a/src/3rdparty/libpng/scripts/makefile.atari b/src/3rdparty/libpng/scripts/makefile.atari index 9566d5d..944337d 100644 --- a/src/3rdparty/libpng/scripts/makefile.atari +++ b/src/3rdparty/libpng/scripts/makefile.atari @@ -1,8 +1,12 @@ # makefile for libpng # Copyright (C) 2002 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h -# modified for LC56/ATARI assumes libz.lib is in same dir and uses default + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# Modified for LC56/ATARI assumes libz.lib is in same dir and uses default # rules for library management # CFLAGS=-I..\zlib -O diff --git a/src/3rdparty/libpng/scripts/makefile.bc32 b/src/3rdparty/libpng/scripts/makefile.bc32 index 04407dd..4b96231 100644 --- a/src/3rdparty/libpng/scripts/makefile.bc32 +++ b/src/3rdparty/libpng/scripts/makefile.bc32 @@ -11,7 +11,6 @@ ## Where zlib.h, zconf.h and zlib.lib are ZLIB_DIR=..\zlib - ## Compiler, linker and lib stuff CC=bcc32 LD=bcc32 @@ -49,7 +48,6 @@ CFLAGS=-I$(ZLIB_DIR) -O2 -d -k- -w $(TARGET_CPU) $(CDEBUG) # -M generate map file LDFLAGS=-L$(ZLIB_DIR) -M $(LDEBUG) - ## Variables OBJS = \ png.obj \ @@ -87,7 +85,6 @@ LIBOBJS = \ LIBNAME=libpng.lib - ## Implicit rules # Braces let make "batch" calls to the compiler, # 2 calls instead of 12; space is important. @@ -100,7 +97,6 @@ LIBNAME=libpng.lib .obj.exe: $(LD) $(LDFLAGS) $*.obj $(LIBNAME) zlib.lib $(NOEHLIB) - ## Major targets all: libpng pngtest @@ -111,25 +107,24 @@ pngtest: pngtest.exe test: pngtest.exe pngtest - ## Minor Targets -png.obj: png.c -pngerror.obj: pngerror.c -pngget.obj: pngget.c -pngmem.obj: pngmem.c -pngpread.obj: pngpread.c -pngread.obj: pngread.c -pngrio.obj: pngrio.c -pngrtran.obj: pngrtran.c -pngrutil.obj: pngrutil.c -pngset.obj: pngset.c -pngtrans.obj: pngtrans.c -pngwio.obj: pngwio.c -pngwrite.obj: pngwrite.c -pngwtran.obj: pngwtran.c -pngwutil.obj: pngwutil.c - +png.obj: png.c png.h pngconf.h +pngerror.obj: pngerror.c png.h pngconf.h +pngget.obj: pngget.c png.h pngconf.h +pngmem.obj: pngmem.c png.h pngconf.h +pngpread.obj: pngpread.c png.h pngconf.h +pngread.obj: pngread.c png.h pngconf.h +pngrio.obj: pngrio.c png.h pngconf.h +pngrtran.obj: pngrtran.c png.h pngconf.h +pngrutil.obj: pngrutil.c png.h pngconf.h +pngset.obj: pngset.c png.h pngconf.h +pngtrans.obj: pngtrans.c png.h pngconf.h +pngwio.obj: pngwio.c png.h pngconf.h +pngwrite.obj: pngwrite.c png.h pngconf.h +pngwtran.obj: pngwtran.c png.h pngconf.h +pngwutil.obj: pngwutil.c png.h pngconf.h +pngtest.obj: pngtest.c png.h pngconf.h $(LIBNAME): $(OBJS) -del $(LIBNAME) @@ -137,7 +132,6 @@ $(LIBNAME): $(OBJS) $(LIBOBJS), libpng | - # Cleanup clean: -del *.obj @@ -148,5 +142,4 @@ clean: -del *.tds -del pngout.png - # End of makefile for libpng diff --git a/src/3rdparty/libpng/scripts/makefile.beos b/src/3rdparty/libpng/scripts/makefile.beos index 341a57c..5dbf14c 100644 --- a/src/3rdparty/libpng/scripts/makefile.beos +++ b/src/3rdparty/libpng/scripts/makefile.beos @@ -1,14 +1,17 @@ # makefile for libpng on BeOS x86 ELF with gcc # modified from makefile.linux by Sander Stoks -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2008 Glenn Randers-Pehrson # Copyright (C) 1999 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME=libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -41,7 +44,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ # On BeOS, -O1 is actually better than -O3. This is a known bug but it's # still here in R4.5 -CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O1 -funroll-loops \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 # LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz LDFLAGS=-L. -Wl,-soname=$(LIBSOMAJ) -L$(ZLIBLIB) -lz @@ -223,4 +226,5 @@ pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwutil.o pngwutil.pic.o: png.h pngconf.h pngpread.o pngpread.pic.o: png.h pngconf.h + pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.bor b/src/3rdparty/libpng/scripts/makefile.bor index a5651aa..0a8ef00 100644 --- a/src/3rdparty/libpng/scripts/makefile.bor +++ b/src/3rdparty/libpng/scripts/makefile.bor @@ -12,7 +12,6 @@ ## Where zlib.h, zconf.h and zlib_MODEL.lib are ZLIB_DIR=..\zlib - ## Compiler, linker and lib stuff CC=bcc LD=bcc @@ -57,8 +56,8 @@ CFLAGS=-O2 -Z -X- -w -I$(ZLIB_DIR) -$(TARGET_CPU) $(MODEL_ARG) $(CDEBUG) # -M generate map file LDFLAGS=-M -L$(ZLIB_DIR) $(MODEL_ARG) $(LDEBUG) - ## Variables + OBJS = \ png.obj \ pngerror.obj \ @@ -95,8 +94,8 @@ LIBOBJS = \ LIBNAME=libpng$(MODEL).lib - ## Implicit rules + # Braces let make "batch" calls to the compiler, # 2 calls instead of 12; space is important. .c.obj: @@ -105,8 +104,8 @@ LIBNAME=libpng$(MODEL).lib .c.exe: $(CC) $(CFLAGS) $(LDFLAGS) $*.c $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) - ## Major targets + all: libpng pngtest libpng: $(LIBNAME) @@ -116,25 +115,23 @@ pngtest: pngtest$(MODEL).exe test: pngtest$(MODEL).exe pngtest$(MODEL) - ## Minor Targets -png.obj: png.c -pngerror.obj: pngerror.c -pngget.obj: pngget.c -pngmem.obj: pngmem.c -pngpread.obj: pngpread.c -pngread.obj: pngread.c -pngrio.obj: pngrio.c -pngrtran.obj: pngrtran.c -pngrutil.obj: pngrutil.c -pngset.obj: pngset.c -pngtrans.obj: pngtrans.c -pngwio.obj: pngwio.c -pngwrite.obj: pngwrite.c -pngwtran.obj: pngwtran.c -pngwutil.obj: pngwutil.c - +png.obj: png.c png.h pngconf.h +pngerror.obj: pngerror.c png.h pngconf.h +pngget.obj: pngget.c png.h pngconf.h +pngmem.obj: pngmem.c png.h pngconf.h +pngpread.obj: pngpread.c png.h pngconf.h +pngread.obj: pngread.c png.h pngconf.h +pngrio.obj: pngrio.c png.h pngconf.h +pngrtran.obj: pngrtran.c png.h pngconf.h +pngrutil.obj: pngrutil.c png.h pngconf.h +pngset.obj: pngset.c png.h pngconf.h +pngtrans.obj: pngtrans.c png.h pngconf.h +pngwio.obj: pngwio.c png.h pngconf.h +pngwrite.obj: pngwrite.c png.h pngconf.h +pngwtran.obj: pngwtran.c png.h pngconf.h +pngwutil.obj: pngwutil.c png.h pngconf.h $(LIBNAME): $(OBJS) -del $(LIBNAME) @@ -142,14 +139,12 @@ $(LIBNAME): $(OBJS) $(LIBOBJS), libpng$(MODEL) | - pngtest$(MODEL).obj: pngtest.c $(CC) $(CFLAGS) -opngtest$(MODEL) -c pngtest.c pngtest$(MODEL).exe: pngtest$(MODEL).obj $(LD) $(LDFLAGS) pngtest$(MODEL).obj $(LIBNAME) zlib_$(MODEL).lib $(NOEHLIB) - # Clean up anything else you want clean: -del *.obj @@ -158,5 +153,4 @@ clean: -del *.lst -del *.map - # End of makefile for libpng diff --git a/src/3rdparty/libpng/scripts/makefile.cygwin b/src/3rdparty/libpng/scripts/makefile.cygwin index bbf3e5f..2a19090 100644 --- a/src/3rdparty/libpng/scripts/makefile.cygwin +++ b/src/3rdparty/libpng/scripts/makefile.cygwin @@ -3,11 +3,14 @@ # of the library, and builds two copies of pngtest: one # statically linked and one dynamically linked. # -# Copyright (C) 2002, 2006, 2007 Soren Anderson, Charles Wilson, +# Copyright (C) 2002, 2006-2008 Soren Anderson, Charles Wilson, # and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: # Copyright (C) 1998-2000 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # This makefile intends to support building outside the src directory # if desired. When invoking it, specify an argument to SRCDIR on the @@ -60,21 +63,21 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ ### if you don't need thread safety, but want the asm accel #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \ -# $(addprefix -I,$(ZLIBINC)) -Wall -O $(ALIGN) -funroll-loops \ +# $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \ # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 ### if you need thread safety and want (minimal) asm accel #CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ -# -Wall -O $(ALIGN) -funroll-loops \ +# -W -Wall -O $(ALIGN) -funroll-loops \ # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 ### Normal (non-asm) compilation CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ + -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 LIBNAME = libpng12 PNGMAJ = 0 CYGDLL = 12 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) SHAREDLIB=cygpng$(CYGDLL).dll @@ -176,7 +179,7 @@ pngtest-stat$(EXE): pngtest.o $(STATLIB) pngtest.pic.o: pngtest.c $(CC) $(CFLAGS) -c $< -o $@ -pngtest.o: pngtest.c +pngtest.o: pngtest.c png.h pngconf.h $(CC) $(CFLAGS) -c $< -o $@ test: test-static test-shared diff --git a/src/3rdparty/libpng/scripts/makefile.darwin b/src/3rdparty/libpng/scripts/makefile.darwin index 76be8a6..c07880f 100644 --- a/src/3rdparty/libpng/scripts/makefile.darwin +++ b/src/3rdparty/libpng/scripts/makefile.darwin @@ -1,10 +1,13 @@ # makefile for libpng on Darwin / Mac OS X -# Copyright (C) 2002, 2004, 2006 Glenn Randers-Pehrson +# Copyright (C) 2002, 2004, 2006, 2008 Glenn Randers-Pehrson # Copyright (C) 2001 Christoph Pfisterer # derived from makefile.linux: # Copyright (C) 1998, 1999 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h prefix=/usr/local @@ -18,8 +21,8 @@ ZLIBINC=../zlib # Library name: LIBNAME = libpng12 -PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMAJ = 12 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -38,8 +41,8 @@ LN_SF=ln -sf RANLIB=ranlib RM_F=/bin/rm -f -# CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE -CFLAGS=-I$(ZLIBINC) -Wall -O -funroll-loops +# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE +CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz INCPATH=$(prefix)/include @@ -104,7 +107,7 @@ $(LIBSOMAJ): $(LIBSOVER) $(LIBSOVER): $(OBJSDLL) $(CC) -dynamiclib \ -install_name $(LIBPATH)/$(LIBSOMAJ) \ - -current_version $(PNGVER) -compatibility_version $(PNGVER) \ + -current_version 0 -compatibility_version 0 \ -o $(LIBSOVER) \ $(OBJSDLL) -L$(ZLIBLIB) -lz diff --git a/src/3rdparty/libpng/scripts/makefile.dec b/src/3rdparty/libpng/scripts/makefile.dec index de35c56..b8f99db 100644 --- a/src/3rdparty/libpng/scripts/makefile.dec +++ b/src/3rdparty/libpng/scripts/makefile.dec @@ -1,11 +1,14 @@ # makefile for libpng on DEC Alpha Unix # Copyright (C) 2000-2002, 2006 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) LIBNAME = libpng12 @@ -205,10 +208,10 @@ pngget.o: png.h pngconf.h pngread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h pngpread.o: png.h pngconf.h +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.dj2 b/src/3rdparty/libpng/scripts/makefile.dj2 index 09045c2..28821a4 100644 --- a/src/3rdparty/libpng/scripts/makefile.dj2 +++ b/src/3rdparty/libpng/scripts/makefile.dj2 @@ -1,7 +1,10 @@ # DJGPP (DOS gcc) makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2009 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # where make install will put libpng.a and png.h #prefix=/usr/local @@ -47,9 +50,9 @@ pngread.o: png.h pngconf.h pngpread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.elf b/src/3rdparty/libpng/scripts/makefile.elf index 1c1a8e9..126a9a1 100644 --- a/src/3rdparty/libpng/scripts/makefile.elf +++ b/src/3rdparty/libpng/scripts/makefile.elf @@ -1,7 +1,11 @@ # makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson +# Copyright (C) 1998, 1999, 2002, 2006, 2008 Greg Roelofs +# and Glenn Randers-Pehrson # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Modified for Debian by Junichi Uekawa and Josselin Mouette # Major modifications are: @@ -12,7 +16,7 @@ # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -53,7 +57,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-Wall -D_REENTRANT -O2 \ +CFLAGS=-W -Wall -D_REENTRANT -O2 \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -lpng12 diff --git a/src/3rdparty/libpng/scripts/makefile.freebsd b/src/3rdparty/libpng/scripts/makefile.freebsd index 59f3644..d9df1ee 100644 --- a/src/3rdparty/libpng/scripts/makefile.freebsd +++ b/src/3rdparty/libpng/scripts/makefile.freebsd @@ -1,6 +1,9 @@ # makefile for libpng under FreeBSD -# Copyright (C) 2002, 2007 Glenn Randers-Pehrson and Andrey A. Chernov -# For conditions of distribution and use, see copyright notice in png.h +# Copyright (C) 2002, 2007, 2009 Glenn Randers-Pehrson and Andrey A. Chernov + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h PREFIX?= /usr/local SHLIB_VER?= 5 diff --git a/src/3rdparty/libpng/scripts/makefile.gcc b/src/3rdparty/libpng/scripts/makefile.gcc index e899b10..d1fb867 100644 --- a/src/3rdparty/libpng/scripts/makefile.gcc +++ b/src/3rdparty/libpng/scripts/makefile.gcc @@ -1,7 +1,11 @@ # makefile for libpng using gcc (generic, static library) +# Copyright (C) 2008 Glenn Randers-Pehrson # Copyright (C) 2000 Cosmin Truta # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Location of the zlib library and include files ZLIBINC = ../zlib @@ -18,8 +22,8 @@ CDEBUG = -g -DPNG_DEBUG=5 LDDEBUG = CRELEASE = -O2 LDRELEASE = -s -#CFLAGS = -Wall $(CDEBUG) -CFLAGS = -Wall $(CRELEASE) +#CFLAGS = -W -Wall $(CDEBUG) +CFLAGS = -W -Wall $(CRELEASE) #LDFLAGS = $(LDDEBUG) LDFLAGS = $(LDRELEASE) LIBS = -lz -lm @@ -30,9 +34,9 @@ A=.a EXE= # Variables -OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ - pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ - pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) +OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \ + pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \ + pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O) # Targets all: static @@ -60,20 +64,20 @@ pngtest$(EXE): pngtest$(O) libpng$(A) clean: $(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png -png$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h pngrtran$(O): png.h pngconf.h pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h pngwrite$(O): png.h pngconf.h pngwtran$(O): png.h pngconf.h pngwutil$(O): png.h pngconf.h +pngtest$(O): png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.gcmmx b/src/3rdparty/libpng/scripts/makefile.gcmmx index f25d09f..b569e87 100644 --- a/src/3rdparty/libpng/scripts/makefile.gcmmx +++ b/src/3rdparty/libpng/scripts/makefile.gcmmx @@ -1,9 +1,12 @@ # makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX # assembler code -# Copyright 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson +# Copyright 2002, 2006, 2008 Greg Roelofs and Glenn Randers-Pehrson # Copyright 1998-2001 Greg Roelofs # Copyright 1996-1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier. @@ -14,7 +17,7 @@ # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -58,17 +61,17 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ # Remove -DPNG_THREAD_UNSAFE_OK if you need thread safety ### for generic gcc: -CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \ +CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ $(ALIGN) -funroll-loops \ -fomit-frame-pointer # $(WARNMORE) -g -DPNG_DEBUG=5 ### for gcc 2.95.2 on 686: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \ +#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ # -mcpu=i686 -malign-double -ffast-math -fstrict-aliasing \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer +# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer ### for gcc 2.7.2.3 on 486 and up: -#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -Wall -O \ +#CFLAGS=-DPNG_THREAD_UNSAFE_OK -I$(ZLIBINC) -W -Wall -O \ # -m486 -malign-double -ffast-math \ -# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer +# $(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm diff --git a/src/3rdparty/libpng/scripts/makefile.hp64 b/src/3rdparty/libpng/scripts/makefile.hp64 index c8895e7..27f6c23 100644 --- a/src/3rdparty/libpng/scripts/makefile.hp64 +++ b/src/3rdparty/libpng/scripts/makefile.hp64 @@ -1,8 +1,11 @@ # makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product. -# Copyright (C) 1999-2002 Glenn Randers-Pehrson +# Copyright (C) 1999-2002, 2006, 2009 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42 # contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Where the zlib library and include files are located ZLIBLIB=/opt/zlib/lib @@ -18,7 +21,7 @@ ZLIBINC=/opt/zlib/include # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -227,9 +230,10 @@ pngget.o: png.h pngconf.h pngread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h pngpread.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.hpgcc b/src/3rdparty/libpng/scripts/makefile.hpgcc index 785c1ed..dc05d5a 100644 --- a/src/3rdparty/libpng/scripts/makefile.hpgcc +++ b/src/3rdparty/libpng/scripts/makefile.hpgcc @@ -1,14 +1,17 @@ # makefile for libpng on HP-UX using GCC with the HP ANSI/C linker. -# Copyright (C) 2002, 2006, 2007 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006-2008 Glenn Randers-Pehrson # Copyright (C) 2001, Laurent faillie # Copyright (C) 1998, 1999 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -53,7 +56,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 #LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm LDFLAGS=-L. -L$(ZLIBLIB) -lpng12 -lz -lm diff --git a/src/3rdparty/libpng/scripts/makefile.hpux b/src/3rdparty/libpng/scripts/makefile.hpux index b0dfcdc..3160219 100644 --- a/src/3rdparty/libpng/scripts/makefile.hpux +++ b/src/3rdparty/libpng/scripts/makefile.hpux @@ -2,7 +2,10 @@ # Copyright (C) 1999-2002, 2006 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42 # contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Where the zlib library and include files are located ZLIBLIB=/opt/zlib/lib @@ -18,7 +21,7 @@ ZLIBINC=/opt/zlib/include # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -224,9 +227,10 @@ pngget.o: png.h pngconf.h pngread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h pngpread.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.ibmc b/src/3rdparty/libpng/scripts/makefile.ibmc index f09a62c..35d7f56 100644 --- a/src/3rdparty/libpng/scripts/makefile.ibmc +++ b/src/3rdparty/libpng/scripts/makefile.ibmc @@ -1,7 +1,12 @@ # Makefile for libpng (static) # IBM C version 3.x for Win32 and OS/2 +# Copyright (C) 2006 Glenn Randers-Pehrson # Copyright (C) 2000 Cosmin Truta -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + # Notes: # Derived from makefile.std # All modules are compiled in C mode @@ -53,19 +58,20 @@ clean: $(RM) pngtest$(E) $(RM) pngout.png -png$(O): png.h pngconf.h +png$(O): png.h pngconf.h pngerror$(O): png.h pngconf.h -pngget$(O): png.h pngconf.h -pngmem$(O): png.h pngconf.h +pngget$(O): png.h pngconf.h +pngmem$(O): png.h pngconf.h pngpread$(O): png.h pngconf.h -pngread$(O): png.h pngconf.h -pngrio$(O): png.h pngconf.h +pngread$(O): png.h pngconf.h +pngrio$(O): png.h pngconf.h pngrtran$(O): png.h pngconf.h pngrutil$(O): png.h pngconf.h -pngset$(O): png.h pngconf.h -pngtest$(O): png.h pngconf.h +pngset$(O): png.h pngconf.h pngtrans$(O): png.h pngconf.h -pngwio$(O): png.h pngconf.h +pngwio$(O): png.h pngconf.h pngwrite$(O): png.h pngconf.h pngwtran$(O): png.h pngconf.h pngwutil$(O): png.h pngconf.h + +pngtest$(O): png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.intel b/src/3rdparty/libpng/scripts/makefile.intel index b0b523a..88a2957 100644 --- a/src/3rdparty/libpng/scripts/makefile.intel +++ b/src/3rdparty/libpng/scripts/makefile.intel @@ -1,12 +1,17 @@ # Makefile for libpng # Microsoft Visual C++ with Intel C/C++ Compiler 4.0 and later +# Copyright (C) 2006 Glenn Randers-Pehrson # Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is # copyright 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # To use, do "nmake /f scripts\makefile.intel" +# ------------------- Intel C/C++ Compiler 4.0 and later ------------------- # Where the zlib library and include files are located ZLIBLIB=..\zlib @@ -26,7 +31,6 @@ CALLING=r # __fastcall # -------------------------------------------------------------------------- - CC=icl -c CFLAGS=-O2 -G$(CPU)$(CALLING) -Qip -Qunroll4 -I$(ZLIBINC) -nologo LD=link @@ -73,9 +77,6 @@ pngrio$(O): png.h pngconf.h pngwio$(O): png.h pngconf.h $(CC) $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h - $(CC) $(CFLAGS) $*.c $(ERRFILE) - pngtrans$(O): png.h pngconf.h $(CC) $(CFLAGS) $*.c $(ERRFILE) @@ -95,6 +96,9 @@ libpng.lib: $(OBJS) pngtest.exe: pngtest.obj libpng.lib $(LD) $(LDFLAGS) /OUT:pngtest.exe pngtest.obj libpng.lib $(ZLIBLIB)\zlib.lib +pngtest$(O): png.h pngconf.h + $(CC) $(CFLAGS) $*.c $(ERRFILE) + test: pngtest.exe pngtest.exe diff --git a/src/3rdparty/libpng/scripts/makefile.knr b/src/3rdparty/libpng/scripts/makefile.knr index 44ee538..7b46585 100644 --- a/src/3rdparty/libpng/scripts/makefile.knr +++ b/src/3rdparty/libpng/scripts/makefile.knr @@ -1,7 +1,10 @@ # makefile for libpng -# Copyright (C) 2002 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2009 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # This makefile requires the file ansi2knr.c, which you can get # from the Ghostscript ftp site at ftp://ftp.cs.wisc.edu/ghost/ @@ -58,7 +61,7 @@ pngtest: pngtest.o libpng.a test: pngtest ./pngtest -install: libpng.a +install: libpng.a png.h pngconf.h -@mkdir $(DESTDIR)$(INCPATH) -@mkdir $(DESTDIR)$(INCPATH)/libpng -@mkdir $(DESTDIR)$(LIBPATH) @@ -92,8 +95,9 @@ pngread.o: png.h pngconf.h pngpread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.linux b/src/3rdparty/libpng/scripts/makefile.linux index b07c58f..ba60a21 100644 --- a/src/3rdparty/libpng/scripts/makefile.linux +++ b/src/3rdparty/libpng/scripts/makefile.linux @@ -1,12 +1,16 @@ # makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006 Greg Roelofs and Glenn Randers-Pehrson +# Copyright (C) 1998, 1999, 2002, 2006, 2008 Greg Roelofs and +# Glenn Randers-Pehrson # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -47,7 +51,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm @@ -73,7 +77,7 @@ DI=$(DESTDIR)$(INCPATH) DL=$(DESTDIR)$(LIBPATH) DM=$(DESTDIR)$(MANPATH) -OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ +OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ pngwtran.o pngmem.o pngerror.o pngpread.o diff --git a/src/3rdparty/libpng/scripts/makefile.mingw b/src/3rdparty/libpng/scripts/makefile.mingw index 6df86e8..50c52ea 100644 --- a/src/3rdparty/libpng/scripts/makefile.mingw +++ b/src/3rdparty/libpng/scripts/makefile.mingw @@ -3,13 +3,16 @@ # of the library, and builds two copies of pngtest: one # statically linked and one dynamically linked. # -# Built from makefile.cygwin -# Copyright (C) 2002, 2006 Soren Anderson, Charles Wilson, +# Copyright (C) 2002, 2006, 2008 Soren Anderson, Charles Wilson, # and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by: # Copyright (C) 1998-2000, 2007 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + +# Built from makefile.cygwin # This makefile intends to support building outside the src directory # if desired. When invoking it, specify an argument to SRCDIR on the @@ -60,21 +63,21 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ ### if you don't need thread safety, but want the asm accel #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \ -# $(addprefix -I,$(ZLIBINC)) -Wall -O $(ALIGN) -funroll-loops \ +# $(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \ # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 ### if you need thread safety and want (minimal) asm accel #CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ -# -Wall -O $(ALIGN) -funroll-loops \ +# -W -Wall -O $(ALIGN) -funroll-loops \ # -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 ### Normal (non-asm) compilation CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ - -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ + -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \ -fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5 LIBNAME = libpng12 PNGMAJ = 0 MINGDLL = 12 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) SHAREDLIB=libpng$(MINGDLL).dll @@ -284,6 +287,3 @@ pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c pngtest.o pngtest.pic.o: png.h pngconf.h pngtest.c - - - diff --git a/src/3rdparty/libpng/scripts/makefile.mips b/src/3rdparty/libpng/scripts/makefile.mips index f1a557d..0e7484f 100644 --- a/src/3rdparty/libpng/scripts/makefile.mips +++ b/src/3rdparty/libpng/scripts/makefile.mips @@ -1,7 +1,10 @@ # makefile for libpng # Copyright (C) Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # where make install puts libpng.a and png.h prefix=/usr/local @@ -76,8 +79,9 @@ pngread.o: png.h pngconf.h pngpread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h + +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.msc b/src/3rdparty/libpng/scripts/makefile.msc index 1cbfd91..ab95ff8 100644 --- a/src/3rdparty/libpng/scripts/makefile.msc +++ b/src/3rdparty/libpng/scripts/makefile.msc @@ -1,6 +1,11 @@ # makefile for libpng # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h +# Copyright (C) 2006, 2009 Glenn Randers-Pehrson + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib # -------- Microsoft C 5.1 and later, does not use assembler code -------- @@ -55,9 +60,6 @@ pngrio$(O): png.h pngconf.h pngwio$(O): png.h pngconf.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - pngtrans$(O): png.h pngconf.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) @@ -76,6 +78,9 @@ libpng.lib: $(OBJS1) $(OBJS2) $(OBJS3) lib libpng $(OBJS2); lib libpng $(OBJS3); +pngtest$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + pngtest.exe: pngtest.obj libpng.lib $(LD) $(LDFLAGS) pngtest.obj,,,libpng.lib ..\zlib\zlib.lib ; diff --git a/src/3rdparty/libpng/scripts/makefile.ne12bsd b/src/3rdparty/libpng/scripts/makefile.ne12bsd index 4037c55..7457cbb 100644 --- a/src/3rdparty/libpng/scripts/makefile.ne12bsd +++ b/src/3rdparty/libpng/scripts/makefile.ne12bsd @@ -2,8 +2,11 @@ # make obj && make depend && make && make test # make includes && make install # Copyright (C) 2002 Patrick R.L. Welche -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h +# Copyright (C) 2007, 2009 Glenn Randers-Pehrson + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # You should also run makefile.netbsd @@ -14,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng12 LIB= png12 SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.2.29 +SHLIB_MINOR= 1.2.40 SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ pngwtran.c pngmem.c pngerror.c pngpread.c @@ -23,7 +26,8 @@ MAN= libpng.3 libpngpf.3 png.5 CPPFLAGS+=-I${.CURDIR} -# something like this for mmx assembler, but it core dumps for me at the moment +# We should be able to do something like this instead of the manual +# uncommenting, but it core dumps for me at the moment: # .if ${MACHINE_ARCH} == "i386" # CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK # MKLINT= no diff --git a/src/3rdparty/libpng/scripts/makefile.netbsd b/src/3rdparty/libpng/scripts/makefile.netbsd index d12ecad..b334bfd 100644 --- a/src/3rdparty/libpng/scripts/makefile.netbsd +++ b/src/3rdparty/libpng/scripts/makefile.netbsd @@ -2,8 +2,11 @@ # make obj && make depend && make && make test # make includes && make install # Copyright (C) 2002 Patrick R.L. Welche -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h +# Copyright (C) 2007, 2009 Glenn Randers-Pehrson + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # You should also run makefile.ne0bsd @@ -14,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng LIB= png SHLIB_MAJOR= 3 -SHLIB_MINOR= 1.2.29 +SHLIB_MINOR= 1.2.40 SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ pngwtran.c pngmem.c pngerror.c pngpread.c @@ -23,7 +26,8 @@ MAN= libpng.3 libpngpf.3 png.5 CPPFLAGS+=-I${.CURDIR} -# something like this for mmx assembler, but it core dumps for me at the moment +# We should be able to do something like this instead of the manual +# uncommenting, but it core dumps for me at the moment: # .if ${MACHINE_ARCH} == "i386" # CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK # MKLINT= no diff --git a/src/3rdparty/libpng/scripts/makefile.nommx b/src/3rdparty/libpng/scripts/makefile.nommx index 1958ceb..e2297d8 100644 --- a/src/3rdparty/libpng/scripts/makefile.nommx +++ b/src/3rdparty/libpng/scripts/makefile.nommx @@ -1,13 +1,16 @@ # makefile for libpng.a and libpng12.so on Linux ELF with gcc -# Copyright (C) 1998, 1999, 2002, 2006, 2007 Greg Roelofs and +# Copyright (C) 1998, 1999, 2002, 2006-2008 Greg Roelofs and # Glenn Randers-Pehrson # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -48,7 +51,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ # for pgcc version 2.95.1, -O3 is buggy; don't use it. -CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \ $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm @@ -233,20 +236,20 @@ writelock: # DO NOT DELETE THIS LINE -- make depend depends on it. -png.o png.pic.o: png.h pngconf.h -pngerror.o pngerror.pic.o: png.h pngconf.h -pngrio.o pngrio.pic.o: png.h pngconf.h -pngwio.o pngwio.pic.o: png.h pngconf.h -pngmem.o pngmem.pic.o: png.h pngconf.h -pngset.o pngset.pic.o: png.h pngconf.h -pngget.o pngget.pic.o: png.h pngconf.h -pngread.o pngread.pic.o: png.h pngconf.h -pngrtran.o pngrtran.pic.o: png.h pngconf.h -pngrutil.o pngrutil.pic.o: png.h pngconf.h -pngtrans.o pngtrans.pic.o: png.h pngconf.h -pngwrite.o pngwrite.pic.o: png.h pngconf.h -pngwtran.o pngwtran.pic.o: png.h pngconf.h -pngwutil.o pngwutil.pic.o: png.h pngconf.h -pngpread.o pngpread.pic.o: png.h pngconf.h - -pngtest.o: png.h pngconf.h +png.o png.pic.o: png.h pngconf.h png.c +pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c +pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c +pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c +pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c +pngset.o pngset.pic.o: png.h pngconf.h pngset.c +pngget.o pngget.pic.o: png.h pngconf.h pngget.c +pngread.o pngread.pic.o: png.h pngconf.h pngread.c +pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c +pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c +pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c +pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c +pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c +pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c +pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c + +pngtest.o: png.h pngconf.h pngtest.c diff --git a/src/3rdparty/libpng/scripts/makefile.openbsd b/src/3rdparty/libpng/scripts/makefile.openbsd index 7c2f107..533c6b8 100644 --- a/src/3rdparty/libpng/scripts/makefile.openbsd +++ b/src/3rdparty/libpng/scripts/makefile.openbsd @@ -1,14 +1,17 @@ # makefile for libpng # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# Copyright (C) 2007 Glenn Randers-Pehrson -# For conditions of distribution and use, see copyright notice in png.h +# Copyright (C) 2007-2008 Glenn Randers-Pehrson + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h PREFIX?= /usr/local LIBDIR= ${PREFIX}/lib MANDIR= ${PREFIX}/man/cat SHLIB_MAJOR= 0 -SHLIB_MINOR= 1.2.29 +SHLIB_MINOR= 1.2.40 LIB= png SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \ @@ -17,8 +20,8 @@ SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \ HDRS= png.h pngconf.h -CFLAGS+= -Wall -CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE +CFLAGS+= -W -Wall +CPPFLAGS+= -I${.CURDIR} -DPNG_NO_MMX_CODE NOPROFILE= Yes diff --git a/src/3rdparty/libpng/scripts/makefile.os2 b/src/3rdparty/libpng/scripts/makefile.os2 index 588067d..2df76ad 100644 --- a/src/3rdparty/libpng/scripts/makefile.os2 +++ b/src/3rdparty/libpng/scripts/makefile.os2 @@ -1,5 +1,8 @@ # makefile for libpng on OS/2 with gcc -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Related files: pngos2.def @@ -12,7 +15,7 @@ ZLIBINC=../zlib WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O6 -funroll-loops -malign-loops=2 \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O6 -funroll-loops -malign-loops=2 \ -malign-functions=2 #$(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lzdll -Zcrtdll AR=emxomfar diff --git a/src/3rdparty/libpng/scripts/makefile.sco b/src/3rdparty/libpng/scripts/makefile.sco index ac62735..186f79d 100644 --- a/src/3rdparty/libpng/scripts/makefile.sco +++ b/src/3rdparty/libpng/scripts/makefile.sco @@ -4,12 +4,15 @@ # Copyright (C) 2002, 2006 Glenn Randers-Pehrson # Copyright (C) 1998 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: diff --git a/src/3rdparty/libpng/scripts/makefile.sggcc b/src/3rdparty/libpng/scripts/makefile.sggcc index 810f1df..3b5f7f2 100644 --- a/src/3rdparty/libpng/scripts/makefile.sggcc +++ b/src/3rdparty/libpng/scripts/makefile.sggcc @@ -1,12 +1,15 @@ # makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' # Copyright (C) 2001-2002, 2006 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME=libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -212,10 +215,8 @@ test-installed: ./pngtesti pngtest.png clean: - $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \ - $(LIBSO) $(LIBSOMAJ)* \ - $(OLDSOVER) \ - so_locations + $(RM_F) libpng.a pngtest pngtesti pngout.png libpng.pc \ + so_locations libpng-config $(LIBSO) $(LIBSOMAJ)* $(OLDSOVER) DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO writelock: @@ -233,10 +234,10 @@ pngget.o: png.h pngconf.h pngread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h pngpread.o: png.h pngconf.h +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.sgi b/src/3rdparty/libpng/scripts/makefile.sgi index 7892bdf..cb48d8f 100644 --- a/src/3rdparty/libpng/scripts/makefile.sgi +++ b/src/3rdparty/libpng/scripts/makefile.sgi @@ -1,12 +1,15 @@ # makefile for libpng.a and libpng12.so, SGI IRIX with 'cc' # Copyright (C) 2001-2002, 2006, 2007 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME=libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -236,10 +239,10 @@ pngget.o: png.h pngconf.h pngread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h pngpread.o: png.h pngconf.h +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.so9 b/src/3rdparty/libpng/scripts/makefile.so9 index 8391ba5..d182f4d 100644 --- a/src/3rdparty/libpng/scripts/makefile.so9 +++ b/src/3rdparty/libpng/scripts/makefile.so9 @@ -1,14 +1,17 @@ # makefile for libpng on Solaris 9 (beta) with Forte cc # Updated by Chad Schrock for Solaris 9 # Contributed by William L. Sebok, based on makefile.linux -# Copyright (C) 2002, 2006 Glenn Randers-Pehrson +# Copyright (C) 2002, 2006, 2008 Glenn Randers-Pehrson # Copyright (C) 1998-2001 Greg Roelofs # Copyright (C) 1996-1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) LIBNAME = libpng12 @@ -47,7 +50,7 @@ ZLIBINC=/usr/include #WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -#CFLAGS=-I$(ZLIBINC) -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE +#CFLAGS=-I$(ZLIBINC) -W -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE CFLAGS=-I$(ZLIBINC) -O3 -DPNG_NO_MMX_CODE LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm diff --git a/src/3rdparty/libpng/scripts/makefile.solaris b/src/3rdparty/libpng/scripts/makefile.solaris index 920cd34..65c1c08 100644 --- a/src/3rdparty/libpng/scripts/makefile.solaris +++ b/src/3rdparty/libpng/scripts/makefile.solaris @@ -1,14 +1,17 @@ # makefile for libpng on Solaris 2.x with gcc -# Copyright (C) 2004, 2006, 2007 Glenn Randers-Pehrson +# Copyright (C) 2004, 2006-2008 Glenn Randers-Pehrson # Contributed by William L. Sebok, based on makefile.linux # Copyright (C) 1998 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -43,8 +46,7 @@ ZLIBINC=/usr/local/include WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O \ - -DPNG_NO_MMX_CODE; \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O -DPNG_NO_MMX_CODE; \ # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm diff --git a/src/3rdparty/libpng/scripts/makefile.solaris-x86 b/src/3rdparty/libpng/scripts/makefile.solaris-x86 index 03c1de4..581916e 100644 --- a/src/3rdparty/libpng/scripts/makefile.solaris-x86 +++ b/src/3rdparty/libpng/scripts/makefile.solaris-x86 @@ -1,14 +1,17 @@ # makefile for libpng on Solaris 2.x with gcc -# Copyright (C) 2004, 2006, 2007 Glenn Randers-Pehrson +# Copyright (C) 2004, 2006-2008 Glenn Randers-Pehrson # Contributed by William L. Sebok, based on makefile.linux # Copyright (C) 1998 Greg Roelofs # Copyright (C) 1996, 1997 Andreas Dilger -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # Library name: LIBNAME = libpng12 PNGMAJ = 0 -PNGMIN = 1.2.29 +PNGMIN = 1.2.40 PNGVER = $(PNGMAJ).$(PNGMIN) # Shared library names: @@ -43,7 +46,7 @@ ZLIBINC=/usr/local/include WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ -Wmissing-declarations -Wtraditional -Wcast-align \ -Wstrict-prototypes -Wmissing-prototypes #-Wconversion -CFLAGS=-I$(ZLIBINC) -Wall -O \ +CFLAGS=-I$(ZLIBINC) -W -Wall -O \ # $(WARNMORE) -g -DPNG_DEBUG=5 LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng12 -lz -lm diff --git a/src/3rdparty/libpng/scripts/makefile.std b/src/3rdparty/libpng/scripts/makefile.std index 9b1925d..bb5268a 100644 --- a/src/3rdparty/libpng/scripts/makefile.std +++ b/src/3rdparty/libpng/scripts/makefile.std @@ -1,7 +1,10 @@ # makefile for libpng # Copyright (C) 2002, 2006 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # where make install puts libpng.a and png.h prefix=/usr/local @@ -83,10 +86,10 @@ pngget.o: png.h pngconf.h pngread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h pngpread.o: png.h pngconf.h +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.sunos b/src/3rdparty/libpng/scripts/makefile.sunos index ff19591..31dff77 100644 --- a/src/3rdparty/libpng/scripts/makefile.sunos +++ b/src/3rdparty/libpng/scripts/makefile.sunos @@ -1,7 +1,10 @@ # makefile for libpng # Copyright (C) 2002, 2006 Glenn Randers-Pehrson # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # where make install puts libpng.a and png.h prefix=/usr/local @@ -88,10 +91,10 @@ pngget.o: png.h pngconf.h pngread.o: png.h pngconf.h pngrtran.o: png.h pngconf.h pngrutil.o: png.h pngconf.h -pngtest.o: png.h pngconf.h pngtrans.o: png.h pngconf.h pngwrite.o: png.h pngconf.h pngwtran.o: png.h pngconf.h pngwutil.o: png.h pngconf.h pngpread.o: png.h pngconf.h +pngtest.o: png.h pngconf.h diff --git a/src/3rdparty/libpng/scripts/makefile.vcawin32 b/src/3rdparty/libpng/scripts/makefile.vcawin32 index 99f5430..0b89d84 100644 --- a/src/3rdparty/libpng/scripts/makefile.vcawin32 +++ b/src/3rdparty/libpng/scripts/makefile.vcawin32 @@ -1,17 +1,22 @@ # makefile for libpng +# Copyright (C) 2006,2009 Glenn Randers-Pehrson # Copyright (C) 1998 Tim Wegner -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib # To use, do "nmake /f scripts\makefile.vcawin32" -# -------- Microsoft Visual C++ 5.0 and later, uses assembler code -------- +# -------- Microsoft Visual C++ 2.0 and later, no assembler code -------- # If you don't want to use assembler (MMX) code, use makefile.vcwin32 instead. # Compiler, linker, librarian, and other tools CC = cl LD = link AR = lib -CFLAGS = -DPNG_USE_PNGVCRD -nologo -MD -O2 -W3 -I..\zlib +CFLAGS = -nologo -DPNG_USE_PNGVCRD -MD -O2 -W3 -I..\zlib LDFLAGS = -nologo ARFLAGS = -nologo RM = del @@ -64,9 +69,6 @@ pngrio$(O): png.h pngconf.h pngwio$(O): png.h pngconf.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - pngtrans$(O): png.h pngconf.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) @@ -83,6 +85,9 @@ libpng.lib: $(OBJS) -$(RM) $@ $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) +pngtest$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + pngtest.exe: pngtest$(O) libpng.lib $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) diff --git a/src/3rdparty/libpng/scripts/makefile.vcwin32 b/src/3rdparty/libpng/scripts/makefile.vcwin32 index fc6ece6..8cd806a 100644 --- a/src/3rdparty/libpng/scripts/makefile.vcwin32 +++ b/src/3rdparty/libpng/scripts/makefile.vcwin32 @@ -1,6 +1,11 @@ # makefile for libpng # Copyright (C) 1998 Tim Wegner -# For conditions of distribution and use, see copyright notice in png.h +# Copyright (C) 2006,2009 Glenn Randers-Pehrson + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h + # Assumes that zlib.lib, zconf.h, and zlib.h have been copied to ..\zlib # To use, do "nmake /f scripts\makefile.vcwin32" @@ -64,9 +69,6 @@ pngrio$(O): png.h pngconf.h pngwio$(O): png.h pngconf.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) -pngtest$(O): png.h pngconf.h - $(CC) -c $(CFLAGS) $*.c $(ERRFILE) - pngtrans$(O): png.h pngconf.h $(CC) -c $(CFLAGS) $*.c $(ERRFILE) @@ -83,6 +85,9 @@ libpng.lib: $(OBJS) -$(RM) $@ $(AR) $(ARFLAGS) -out:$@ $(OBJS) $(ERRFILE) +pngtest$(O): png.h pngconf.h + $(CC) -c $(CFLAGS) $*.c $(ERRFILE) + pngtest.exe: pngtest$(O) libpng.lib $(LD) $(LDFLAGS) -out:$@ pngtest$(O) libpng.lib ..\zlib\zlib.lib $(ERRFILE) diff --git a/src/3rdparty/libpng/scripts/makefile.watcom b/src/3rdparty/libpng/scripts/makefile.watcom index 5e860fc..bbfeeeb 100644 --- a/src/3rdparty/libpng/scripts/makefile.watcom +++ b/src/3rdparty/libpng/scripts/makefile.watcom @@ -3,7 +3,10 @@ # Copyright (C) 2000, Pawel Mrochen, based on makefile.msc which is # copyright 1995 Guy Eric Schalnat, Group 42, Inc. -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h # To use, do "wmake /f scripts\makefile.watcom" diff --git a/src/3rdparty/libpng/scripts/makevms.com b/src/3rdparty/libpng/scripts/makevms.com index b9e3895..36d1190 100644 --- a/src/3rdparty/libpng/scripts/makevms.com +++ b/src/3rdparty/libpng/scripts/makevms.com @@ -55,8 +55,6 @@ $ then $ dele pngtest.obj;* $ CALL MAKE png.OBJ "cc ''CCOPT' png" - png.c png.h pngconf.h -$ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h $ CALL MAKE pngset.OBJ "cc ''CCOPT' pngset" - pngset.c png.h pngconf.h $ CALL MAKE pngget.OBJ "cc ''CCOPT' pngget" - @@ -64,7 +62,7 @@ $ CALL MAKE pngget.OBJ "cc ''CCOPT' pngget" - $ CALL MAKE pngread.OBJ "cc ''CCOPT' pngread" - pngread.c png.h pngconf.h $ CALL MAKE pngpread.OBJ "cc ''CCOPT' pngpread" - - pngpread.c png.h pngconf.h + pngpread.c png.h pngconf.h $ CALL MAKE pngrtran.OBJ "cc ''CCOPT' pngrtran" - pngrtran.c png.h pngconf.h $ CALL MAKE pngrutil.OBJ "cc ''CCOPT' pngrutil" - diff --git a/src/3rdparty/libpng/scripts/pngos2.def b/src/3rdparty/libpng/scripts/pngos2.def index 8ba7b41..0f371c8 100644 --- a/src/3rdparty/libpng/scripts/pngos2.def +++ b/src/3rdparty/libpng/scripts/pngos2.def @@ -2,7 +2,7 @@ ; PNG.LIB module definition file for OS/2 ;---------------------------------------- -; Version 1.2.29 +; Version 1.2.40 LIBRARY PNG DESCRIPTION "PNG image compression library for OS/2" diff --git a/src/3rdparty/libpng/scripts/pngw32.def b/src/3rdparty/libpng/scripts/pngw32.def index 3ea55e6..e455018 100644 --- a/src/3rdparty/libpng/scripts/pngw32.def +++ b/src/3rdparty/libpng/scripts/pngw32.def @@ -5,7 +5,7 @@ LIBRARY EXPORTS -;Version 1.2.29 +;Version 1.2.40 png_build_grayscale_palette @1 png_check_sig @2 png_chunk_error @3 @@ -189,6 +189,7 @@ EXPORTS ; Added at version 1.0.12 ; For compatibility with 1.0.7-1.0.11 ; png_info_init @174 +; png_read_init_3, png_info_init_3, and png_write_init_3 are deprecated. png_read_init_3 @175 png_write_init_3 @176 png_info_init_3 @177 diff --git a/src/3rdparty/libpng/scripts/smakefile.ppc b/src/3rdparty/libpng/scripts/smakefile.ppc index e5c0278..91df6c1 100644 --- a/src/3rdparty/libpng/scripts/smakefile.ppc +++ b/src/3rdparty/libpng/scripts/smakefile.ppc @@ -1,7 +1,10 @@ # Amiga powerUP (TM) Makefile # makefile for libpng and SAS C V6.58/7.00 PPC compiler # Copyright (C) 1998 by Andreas R. Kleinert -# For conditions of distribution and use, see copyright notice in png.h + +# This code is released under the libpng license. +# For conditions of distribution and use, see the disclaimer +# and license in png.h CC = scppc CFLAGS = NOSTKCHK NOSINT OPTIMIZE OPTGO OPTPEEP OPTINLOCAL OPTINL IDIR /zlib \ -- cgit v0.12 From c74240bf4ab182f13b18271831fd6deebfe573f6 Mon Sep 17 00:00:00 2001 From: aavit Date: Thu, 15 Oct 2009 15:01:05 +0200 Subject: Qt patches to libpng sources. This commit is the combination of earlier Qt patches to libpng, reapplied here after the upgrade to 1.2.40. --- src/3rdparty/libpng/pngconf.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/3rdparty/libpng/pngconf.h b/src/3rdparty/libpng/pngconf.h index 5530bde..c1c1d92 100644 --- a/src/3rdparty/libpng/pngconf.h +++ b/src/3rdparty/libpng/pngconf.h @@ -354,7 +354,7 @@ # endif /* __linux__ */ #endif /* PNG_SETJMP_SUPPORTED */ -#ifdef BSD +#if defined(BSD) && !defined(VXWORKS) # include #else # include @@ -1357,7 +1357,9 @@ typedef z_stream FAR * png_zstreamp; defined(WIN32) || defined(_WIN32) || defined(__WIN32__) )) # ifndef PNGAPI -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) +# if (defined(__GNUC__) && defined(__arm__)) || defined (__ARMCC__) +# define PNGAPI +# elif defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) || defined(__WINSCW__) # define PNGAPI __cdecl # else # define PNGAPI _cdecl @@ -1407,6 +1409,14 @@ typedef z_stream FAR * png_zstreamp; # if 0 /* ... other platforms, with other meanings */ # endif # endif + +# if !defined(PNG_IMPEXP) +# include +# if defined(QT_VISIBILITY_AVAILABLE) +# define PNG_IMPEXP __attribute__((visibility("default"))) +# endif +# endif + #endif #ifndef PNGAPI -- cgit v0.12 From 9dec5247be84ae4606d5d9baf5b99612c5feba8d Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 22 Oct 2009 13:26:28 +0200 Subject: QtScript: Compatibility with 4.5 We must register the same type as they were registered in Qt 4.5 Reported on qt4-preview-feedback mailing list. Reviewed-by: Kent Hansen --- src/script/api/qscriptengine.cpp | 4 ++++ .../qscriptextqobject/tst_qscriptextqobject.cpp | 24 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index 360036a..c3c8caf 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -797,6 +797,10 @@ QScriptEnginePrivate::QScriptEnginePrivate() registeredScriptStrings(0), inEval(false) { qMetaTypeId(); + qMetaTypeId >(); +#ifndef QT_NO_QOBJECT + qMetaTypeId(); +#endif JSC::initializeThreading(); // ### hmmm diff --git a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp index 320a429..44adf7e 100644 --- a/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp +++ b/tests/auto/qscriptextqobject/tst_qscriptextqobject.cpp @@ -317,6 +317,11 @@ public: Q_INVOKABLE QObject* myInvokableReturningMyQObjectAsQObject() { m_qtFunctionInvoked = 57; return this; } + Q_INVOKABLE QObjectList findObjects() const + { return findChildren(); } + Q_INVOKABLE QList myInvokableNumbers() const + { return QList() << 1 << 2 << 3; } + void emitMySignal() { emit mySignal(); } void emitMySignalWithIntArg(int arg) @@ -493,6 +498,7 @@ protected slots: } private slots: + void registeredTypes(); void getSetStaticProperty(); void getSetDynamicProperty(); void getSetChildren(); @@ -543,6 +549,24 @@ void tst_QScriptExtQObject::cleanup() delete m_myObject; } +// this test has to be first and test that some types are automatically registered +void tst_QScriptExtQObject::registeredTypes() +{ + QScriptEngine e; + QObject *t = new MyQObject; + QObject *c = new QObject(t); + c->setObjectName ("child1"); + + e.globalObject().setProperty("MyTest", e.newQObject(t)); + + QScriptValue v1 = e.evaluate("MyTest.findObjects()[0].objectName;"); + QCOMPARE(v1.toString(), c->objectName()); + + QScriptValue v2 = e.evaluate("MyTest.myInvokableNumbers()"); + QCOMPARE(qscriptvalue_cast >(v2), (QList() << 1 << 2 << 3)); +} + + static QScriptValue getSetProperty(QScriptContext *ctx, QScriptEngine *) { if (ctx->argumentCount() != 0) -- cgit v0.12 From 62cf25df02d2cce8957c5942b467dbbf050a763d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Wed, 21 Oct 2009 16:58:44 +0200 Subject: Fixed regression in translucent window creation on X11. When setting the TranslucentBackground flag after the window has been created, we should check whether the widget has a native window id, and not the WA_NativeWindow attribute which doesn't seem to be set by default for top-level widgets. Reviewed-by: Trond --- src/gui/kernel/qwidget_x11.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 663178f..28676da 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -950,7 +950,7 @@ static void qt_x11_recreateWidget(QWidget *widget) static void qt_x11_recreateNativeWidgetsRecursive(QWidget *widget) { - if (widget->testAttribute(Qt::WA_NativeWindow)) + if (widget->internalWinId()) qt_x11_recreateWidget(widget); const QObjectList &children = widget->children(); -- cgit v0.12 From f51e6e91c92810deff7029c8d1edf9b11f03a908 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Thu, 22 Oct 2009 12:05:41 +0200 Subject: Add Windows 7 with VC++2008 as a Tier 2 supported platform. --- doc/src/platforms/supported-platforms.qdoc | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/src/platforms/supported-platforms.qdoc b/doc/src/platforms/supported-platforms.qdoc index 4c3929a..302ecb4 100644 --- a/doc/src/platforms/supported-platforms.qdoc +++ b/doc/src/platforms/supported-platforms.qdoc @@ -106,10 +106,8 @@ \o Compilers \row \o Windows XP, Vista \o gcc 3.4.2 (MinGW) - \omit \row \o Windows 7 \o MSVC 2008 - \endomit \row \o Apple Mac OS X 10.6 "Snow Leopard" \o As provided by Apple \row \o Apple Mac OS X 10.4 "Tiger" -- cgit v0.12 From 079202d135908444c418b064928117b4a273e075 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Thu, 22 Oct 2009 10:46:32 +0200 Subject: QWidget painting regression on Windows. Problem occurred on Windows due to a call to repaint() on a top-level window from setDisabledStyle() in qwidget.cpp. This function is called whenever a window is blocking. In this particular case the children of the repainted window are opaque, and should therefore not be repainted, which also means that the top-level have to subtract the region of the opaque children when filling the background. This region is cached, and the problem was that the cached region was wrong. It was wrong because it was not invalidated properly. Task: QTBUG-4245 Reviewed-by: Paul --- src/gui/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 3e65101..85c1955 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -6954,7 +6954,7 @@ void QWidget::setVisible(bool visible) break; parent = parent->parentWidget(); } - if (parent && !d->getOpaqueRegion().isEmpty()) + if (parent) parent->d_func()->setDirtyOpaqueRegion(); } -- cgit v0.12 From abae4e913e91e64153edcc8cb771393062432ea2 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 22 Oct 2009 14:59:56 +0300 Subject: Lowering toplevel widget puts app to background. Since raising toplevel widget nowdays brings the whole app to top, logically lowering toplevel widget should put the app to background. Reviewed-by: axis --- src/gui/kernel/qwidget_s60.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index abf5ba5..cb615fe 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -564,8 +564,13 @@ void QWidgetPrivate::lower_sys() Q_Q(QWidget); Q_ASSERT(q->testAttribute(Qt::WA_WState_Created)); - if (q->internalWinId()) - q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); + if (q->internalWinId()) { + // If toplevel widget, lower app to background + if (q->isWindow()) + S60->wsSession().SetWindowGroupOrdinalPosition(S60->windowGroup().Identifier(), -1); + else + q->internalWinId()->DrawableWindow()->SetOrdinalPosition(-1); + } if (!q->isWindow()) invalidateBuffer(q->rect()); -- cgit v0.12 From dbff78d964d1a034459074f168b505b41bab0c98 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Thu, 22 Oct 2009 14:27:33 +0200 Subject: Use the qsreal type instead of double when working with QtScript numbers The idea is that qsreal can be typedef'ed to float on platforms where it's appropriate. Since the QScriptValue ctor takes a qsreal, we should not convert it to a double internally. Reviewed-by: Olivier Goffart --- src/script/api/qscriptengine.cpp | 2 +- src/script/api/qscriptengine_p.h | 2 +- src/script/api/qscriptvalue.cpp | 6 +++--- src/script/api/qscriptvalue_p.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/script/api/qscriptengine.cpp b/src/script/api/qscriptengine.cpp index c3c8caf..3f2c9b4 100644 --- a/src/script/api/qscriptengine.cpp +++ b/src/script/api/qscriptengine.cpp @@ -2577,7 +2577,7 @@ QScriptValue QScriptEnginePrivate::create(int type, const void *ptr) #endif break; case QMetaType::Double: - result = QScriptValue(*reinterpret_cast(ptr)); + result = QScriptValue(qsreal(*reinterpret_cast(ptr))); break; case QMetaType::QString: result = QScriptValue(q_func(), *reinterpret_cast(ptr)); diff --git a/src/script/api/qscriptengine_p.h b/src/script/api/qscriptengine_p.h index cde116d..3766559 100644 --- a/src/script/api/qscriptengine_p.h +++ b/src/script/api/qscriptengine_p.h @@ -451,7 +451,7 @@ inline void QScriptValuePrivate::initFrom(JSC::JSValue value) engine->registerScriptValue(this); } -inline void QScriptValuePrivate::initFrom(double value) +inline void QScriptValuePrivate::initFrom(qsreal value) { type = Number; numberValue = value; diff --git a/src/script/api/qscriptvalue.cpp b/src/script/api/qscriptvalue.cpp index b8340a7..26cd314 100644 --- a/src/script/api/qscriptvalue.cpp +++ b/src/script/api/qscriptvalue.cpp @@ -213,7 +213,7 @@ qint32 ToInt32(qsreal n) if (qIsNaN(n) || qIsInf(n) || (n == 0)) return 0; - double sign = (n < 0) ? -1.0 : 1.0; + qsreal sign = (n < 0) ? -1.0 : 1.0; qsreal abs_n = fabs(n); n = ::fmod(sign * ::floor(abs_n), D32); @@ -233,7 +233,7 @@ quint32 ToUint32(qsreal n) if (qIsNaN(n) || qIsInf(n) || (n == 0)) return 0; - double sign = (n < 0) ? -1.0 : 1.0; + qsreal sign = (n < 0) ? -1.0 : 1.0; qsreal abs_n = fabs(n); n = ::fmod(sign * ::floor(abs_n), D32); @@ -251,7 +251,7 @@ quint16 ToUint16(qsreal n) if (qIsNaN(n) || qIsInf(n) || (n == 0)) return 0; - double sign = (n < 0) ? -1.0 : 1.0; + qsreal sign = (n < 0) ? -1.0 : 1.0; qsreal abs_n = fabs(n); n = ::fmod(sign * ::floor(abs_n), D16); diff --git a/src/script/api/qscriptvalue_p.h b/src/script/api/qscriptvalue_p.h index 77b5084..9634515 100644 --- a/src/script/api/qscriptvalue_p.h +++ b/src/script/api/qscriptvalue_p.h @@ -81,7 +81,7 @@ public: inline ~QScriptValuePrivate(); inline void initFrom(JSC::JSValue value); - inline void initFrom(double value); + inline void initFrom(qsreal value); inline void initFrom(const QString &value); inline bool isJSC() const; @@ -124,7 +124,7 @@ public: QScriptEnginePrivate *engine; Type type; JSC::JSValue jscValue; - double numberValue; + qsreal numberValue; QString stringValue; // linked list of engine's script values -- cgit v0.12 From b63fc1726fe3df49c6577d8ac26095d0c8738925 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Oct 2009 14:53:17 +0200 Subject: Honor graphics system on Mac/Cocoa when exposing and resizing window When exposing or resizing a previously hidden window on Cocoa, we would go through the CoreGraphicsPaintEngine even when a different graphics system was set. This was because there were two different paths from the windowing system into our paint event. The one going through the virtual drawRect function in QCocoaView did not honor the graphics system. This patch makes sure the backing store is used for these types of events as well. Done with: Gunnar Reviewed-by: MortenS --- src/gui/kernel/qcocoaview_mac.mm | 8 ++++++++ src/gui/painting/qbackingstore_p.h | 13 +++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 4c2a14a..417d54c 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -503,6 +504,13 @@ extern "C" { - (void)drawRect:(NSRect)aRect { + qDebug("drawRect"); + if (QApplicationPrivate::graphicsSystem() != 0) { + if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore()) + bs->markDirty(qwidget->rect(), qwidget); + qwidgetprivate->syncBackingStore(qwidget->rect()); + return; + } CGContextRef cg = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; qwidgetprivate->hd = cg; CGContextSaveGState(cg); diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h index 94d756e..63518fb 100644 --- a/src/gui/painting/qbackingstore_p.h +++ b/src/gui/painting/qbackingstore_p.h @@ -1,4 +1,4 @@ -/**************************************************************************** + /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. @@ -97,6 +97,12 @@ public: ); } + // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore). + void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately = false, + bool invalidateBuffer = false); + void markDirty(const QRect &rect, QWidget *widget, bool updateImmediately = false, + bool invalidateBuffer = false); + private: QWidget *tlw; QRegion dirtyOnScreen; // needsFlush @@ -126,11 +132,6 @@ private: QRegion dirtyRegion(QWidget *widget = 0) const; QRegion staticContents(QWidget *widget = 0, const QRect &withinClipRect = QRect()) const; - // ### Qt 4.6: Merge into a template function (after MSVC isn't supported anymore). - void markDirty(const QRegion &rgn, QWidget *widget, bool updateImmediately = false, - bool invalidateBuffer = false); - void markDirty(const QRect &rect, QWidget *widget, bool updateImmediately = false, - bool invalidateBuffer = false); void markDirtyOnScreen(const QRegion &dirtyOnScreen, QWidget *widget, const QPoint &topLevelOffset); void removeDirtyWidget(QWidget *w); -- cgit v0.12 From 792e3b4402954bb68fcc2c44e8e3f1fa7e2fe77b Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Oct 2009 15:11:36 +0200 Subject: Remove debug output Oops. Reviewed-by: Trust me --- src/gui/kernel/qcocoaview_mac.mm | 1 - 1 file changed, 1 deletion(-) diff --git a/src/gui/kernel/qcocoaview_mac.mm b/src/gui/kernel/qcocoaview_mac.mm index 417d54c..d49c150 100644 --- a/src/gui/kernel/qcocoaview_mac.mm +++ b/src/gui/kernel/qcocoaview_mac.mm @@ -504,7 +504,6 @@ extern "C" { - (void)drawRect:(NSRect)aRect { - qDebug("drawRect"); if (QApplicationPrivate::graphicsSystem() != 0) { if (QWidgetBackingStore *bs = qwidgetprivate->maybeBackingStore()) bs->markDirty(qwidget->rect(), qwidget); -- cgit v0.12 From a392366b164081fe3b75c806dbf2030e64754eaf Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 22 Oct 2009 15:13:03 +0200 Subject: Remove whitespace before license header in qbackingstore_p.h This extra whitespace was introduced by mistake in a previous commit. Remove it again. Reviewed-by: Trust me --- src/gui/painting/qbackingstore_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qbackingstore_p.h b/src/gui/painting/qbackingstore_p.h index 63518fb..3288dae 100644 --- a/src/gui/painting/qbackingstore_p.h +++ b/src/gui/painting/qbackingstore_p.h @@ -1,4 +1,4 @@ - /**************************************************************************** +/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** All rights reserved. -- cgit v0.12 From e4954731369d9b339a79ec9fe737d70ef6dc4755 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 22 Oct 2009 15:38:25 +0200 Subject: In Vista style, renaming Animation, Transition and Pulse There is a name clash, so we prefixed them with QWindowsVista Reviewed-by: Benjamin Poulain --- src/gui/styles/qwindowsvistastyle.cpp | 50 +++++++++++++++++------------------ src/gui/styles/qwindowsvistastyle_p.h | 24 ++++++++--------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/gui/styles/qwindowsvistastyle.cpp b/src/gui/styles/qwindowsvistastyle.cpp index 6cb8b40..aafd087 100644 --- a/src/gui/styles/qwindowsvistastyle.cpp +++ b/src/gui/styles/qwindowsvistastyle.cpp @@ -159,7 +159,7 @@ QWindowsVistaStyle::QWindowsVistaStyle() } //convert Qt state flags to uxtheme button states -int buttonStateId(int flags, int partId) +static int buttonStateId(int flags, int partId) { int stateId = 0; if (partId == BP_RADIOBUTTON || partId == BP_CHECKBOX) { @@ -190,7 +190,7 @@ int buttonStateId(int flags, int partId) return stateId; } -void Animation::paint(QPainter *painter, const QStyleOption *option) +void QWindowsVistaAnimation::paint(QPainter *painter, const QStyleOption *option) { Q_UNUSED(option); Q_UNUSED(painter); @@ -205,7 +205,7 @@ void Animation::paint(QPainter *painter, const QStyleOption *option) + ((1-alpha)*_secondaryImage) */ -void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { +void QWindowsVistaAnimation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { if (_secondaryImage.isNull() || _primaryImage.isNull()) return; @@ -251,7 +251,7 @@ void Animation::drawBlendedImage(QPainter *painter, QRect rect, float alpha) { initial and final state of the transition, depending on the time difference between _startTime and current time. */ -void Transition::paint(QPainter *painter, const QStyleOption *option) +void QWindowsVistaTransition::paint(QPainter *painter, const QStyleOption *option) { float alpha = 1.0; if (_duration > 0) { @@ -278,7 +278,7 @@ void Transition::paint(QPainter *painter, const QStyleOption *option) secondary pulse images depending on the time difference between _startTime and current time. */ -void Pulse::paint(QPainter *painter, const QStyleOption *option) +void QWindowsVistaPulse::paint(QPainter *painter, const QStyleOption *option) { float alpha = 1.0; if (_duration > 0) { @@ -393,8 +393,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt startImage.fill(0); QPainter startPainter(&startImage); - Animation *anim = d->widgetAnimation(widget); - Transition *t = new Transition; + QWindowsVistaAnimation *anim = d->widgetAnimation(widget); + QWindowsVistaTransition *t = new QWindowsVistaTransition; t->setWidget(w); // If we have a running animation on the widget already, we will use that to paint the initial @@ -531,7 +531,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt case PE_IndicatorCheckBox: case PE_IndicatorRadioButton: { - if (Animation *a = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { a->paint(painter, option); } else { QWindowsXPStyle::drawPrimitive(element, option, painter, widget); @@ -644,7 +644,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt break; case PE_FrameLineEdit: - if (Animation *anim = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { anim->paint(painter, option); } else { QPainter *p = painter; @@ -929,13 +929,13 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (doTransition) { QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - Animation *anim = d->widgetAnimation(widget); + QWindowsVistaAnimation *anim = d->widgetAnimation(widget); QStyleOptionButton opt = *button; opt.state = (QStyle::State)oldState; startImage.fill(0); - Transition *t = new Transition; + QWindowsVistaTransition *t = new QWindowsVistaTransition; t->setWidget(w); QPainter startPainter(&startImage); @@ -972,7 +972,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (const QStyleOptionButton *btn = qstyleoption_cast(option)) { - if (Animation *anim = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { anim->paint(painter, option); } else { name = QLatin1String("BUTTON"); @@ -999,14 +999,14 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption !(state & (State_Sunken | State_On)) && !(state & State_MouseOver) && (state & State_Enabled) && (state & State_Active)) { - Animation *anim = d->widgetAnimation(widget); + QWindowsVistaAnimation *anim = d->widgetAnimation(widget); if (!anim && widget) { QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); startImage.fill(0); QImage alternateImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); alternateImage.fill(0); - Pulse *pulse = new Pulse; + QWindowsVistaPulse *pulse = new QWindowsVistaPulse; pulse->setWidget(const_cast(widget)); QPainter startPainter(&startImage); @@ -1079,7 +1079,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption if (const QProgressBar *progressbar = qobject_cast(widget)) { if (((progressbar->value() > 0 && d->transitionsEnabled()) || isIndeterminate)) { if (!d->widgetAnimation(progressbar) && progressbar->value() < progressbar->maximum()) { - Animation *a = new Animation; + QWindowsVistaAnimation *a = new QWindowsVistaAnimation; a->setWidget(const_cast(widget)); a->setStartTime(QTime::currentTime()); d->startAnimation(a); @@ -1095,7 +1095,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption QTime current = QTime::currentTime(); if (isIndeterminate) { - if (Animation *a = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { int glowSize = 120; int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); int animOffset = a->startTime().msecsTo(current) / 4; @@ -1165,7 +1165,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption } d->drawBackground(theme); - if (Animation *a = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *a = d->widgetAnimation(widget)) { int glowSize = 140; int animationWidth = glowSize * 2 + (vertical ? theme.rect.height() : theme.rect.width()); int animOffset = a->startTime().msecsTo(current) / 4; @@ -1603,8 +1603,8 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle if (doTransition) { QImage startImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); QImage endImage(option->rect.size(), QImage::Format_ARGB32_Premultiplied); - Animation *anim = d->widgetAnimation(widget); - Transition *t = new Transition; + QWindowsVistaAnimation *anim = d->widgetAnimation(widget); + QWindowsVistaTransition *t = new QWindowsVistaTransition; t->setWidget(w); if (!anim) { if (const QStyleOptionComboBox *combo = qstyleoption_cast(option)) { @@ -1651,7 +1651,7 @@ void QWindowsVistaStyle::drawComplexControl(ComplexControl control, const QStyle t->setDuration(500); } - if (Animation *anim = d->widgetAnimation(widget)) { + if (QWindowsVistaAnimation *anim = d->widgetAnimation(widget)) { anim->paint(painter, option); return; } @@ -2533,7 +2533,7 @@ void QWindowsVistaStylePrivate::timerEvent() !animations[i]->running() || !QWindowsVistaStylePrivate::useVista()) { - Animation *a = animations.takeAt(i); + QWindowsVistaAnimation *a = animations.takeAt(i); delete a; } } @@ -2546,14 +2546,14 @@ void QWindowsVistaStylePrivate::stopAnimation(const QWidget *w) { for (int i = animations.size() - 1 ; i >= 0 ; --i) { if (animations[i]->widget() == w) { - Animation *a = animations.takeAt(i); + QWindowsVistaAnimation *a = animations.takeAt(i); delete a; break; } } } -void QWindowsVistaStylePrivate::startAnimation(Animation *t) +void QWindowsVistaStylePrivate::startAnimation(QWindowsVistaAnimation *t) { Q_Q(QWindowsVistaStyle); stopAnimation(t->widget()); @@ -2575,11 +2575,11 @@ bool QWindowsVistaStylePrivate::transitionsEnabled() const } -Animation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const +QWindowsVistaAnimation * QWindowsVistaStylePrivate::widgetAnimation(const QWidget *widget) const { if (!widget) return 0; - foreach (Animation *a, animations) { + foreach (QWindowsVistaAnimation *a, animations) { if (a->widget() == widget) return a; } diff --git a/src/gui/styles/qwindowsvistastyle_p.h b/src/gui/styles/qwindowsvistastyle_p.h index e9bbb77..04823c1 100644 --- a/src/gui/styles/qwindowsvistastyle_p.h +++ b/src/gui/styles/qwindowsvistastyle_p.h @@ -136,11 +136,11 @@ QT_BEGIN_NAMESPACE #define TDLG_SECONDARYPANEL 8 #endif -class Animation +class QWindowsVistaAnimation { public : - Animation() : _running(true) { } - virtual ~Animation() { } + QWindowsVistaAnimation() : _running(true) { } + virtual ~QWindowsVistaAnimation() { } QWidget * widget() const { return _widget; } bool running() const { return _running; } const QTime &startTime() const { return _startTime; } @@ -161,11 +161,11 @@ protected: // Handles state transition animations -class Transition : public Animation +class QWindowsVistaTransition : public QWindowsVistaAnimation { public : - Transition() : Animation() {} - virtual ~Transition() { } + QWindowsVistaTransition() : QWindowsVistaAnimation() {} + virtual ~QWindowsVistaTransition() { } void setDuration(int duration) { _duration = duration; } void setStartImage(const QImage &image) { _primaryImage = image; } void setEndImage(const QImage &image) { _secondaryImage = image; } @@ -176,11 +176,11 @@ public : // Handles pulse animations (default buttons) -class Pulse: public Animation +class QWindowsVistaPulse: public QWindowsVistaAnimation { public : - Pulse() : Animation() {} - virtual ~Pulse() { } + QWindowsVistaPulse() : QWindowsVistaAnimation() {} + virtual ~QWindowsVistaPulse() { } void setDuration(int duration) { _duration = duration; } void setPrimaryImage(const QImage &image) { _primaryImage = image; } void setAlternateImage(const QImage &image) { _secondaryImage = image; } @@ -199,15 +199,15 @@ public: ~QWindowsVistaStylePrivate(); static bool resolveSymbols(); static inline bool useVista(); - void startAnimation(Animation *); + void startAnimation(QWindowsVistaAnimation *); void stopAnimation(const QWidget *); - Animation* widgetAnimation(const QWidget *) const; + QWindowsVistaAnimation* widgetAnimation(const QWidget *) const; void timerEvent(); bool transitionsEnabled() const; QWidget *treeViewHelper(); private: - QList animations; + QList animations; QBasicTimer animationTimer; QWidget *m_treeViewHelper; }; -- cgit v0.12 From cbbd7e084c7e46fd906db26b13032b8368c59093 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 22 Oct 2009 13:26:45 +0200 Subject: QtGui release/debug binary compatibility QtGui had some debug functions only exported in the debug build. Now these are exported in release mode as well, but as stubs (i.e. no debug output is generated). Reviewed-by: Thiago Macieira --- src/gui/graphicsview/qgraphicslinearlayout.cpp | 10 +++++----- src/gui/graphicsview/qgraphicslinearlayout.h | 2 -- src/gui/styles/qstyle.cpp | 4 ++-- src/gui/styles/qstyle.h | 2 -- src/gui/styles/qstyleoption.cpp | 10 +++++----- src/gui/styles/qstyleoption.h | 2 -- 6 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/gui/graphicsview/qgraphicslinearlayout.cpp b/src/gui/graphicsview/qgraphicslinearlayout.cpp index 7ff7c9b..5684f0e 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.cpp +++ b/src/gui/graphicsview/qgraphicslinearlayout.cpp @@ -59,7 +59,7 @@ You can add widgets, layouts, stretches (addStretch(), insertStretch() or setStretchFactor()), and spacings (setItemSpacing()) to a linear - layout. The layout takes ownership of the items. In some cases when the layout + layout. The layout takes ownership of the items. In some cases when the layout item also inherits from QGraphicsItem (such as QGraphicsWidget) there will be a ambiguity in ownership because the layout item belongs to two ownership hierarchies. See the documentation of QGraphicsLayoutItem::setOwnedByLayout() how to handle @@ -208,7 +208,7 @@ QGraphicsLinearLayout::~QGraphicsLinearLayout() for (int i = count() - 1; i >= 0; --i) { QGraphicsLayoutItem *item = itemAt(i); // The following lines can be removed, but this removes the item - // from the layout more efficiently than the implementation of + // from the layout more efficiently than the implementation of // ~QGraphicsLayoutItem. removeAt(i); if (item) { @@ -542,18 +542,18 @@ void QGraphicsLinearLayout::invalidate() QGraphicsLayout::invalidate(); } -#ifdef QT_DEBUG void QGraphicsLinearLayout::dump(int indent) const { +#ifdef QT_DEBUG if (qt_graphicsLayoutDebug()) { Q_D(const QGraphicsLinearLayout); qDebug("%*s%s layout", indent, "", d->orientation == Qt::Horizontal ? "Horizontal" : "Vertical"); d->engine.dump(indent + 1); } -} #endif +} QT_END_NAMESPACE - + #endif //QT_NO_GRAPHICSVIEW diff --git a/src/gui/graphicsview/qgraphicslinearlayout.h b/src/gui/graphicsview/qgraphicslinearlayout.h index 742392e..15fe81a 100644 --- a/src/gui/graphicsview/qgraphicslinearlayout.h +++ b/src/gui/graphicsview/qgraphicslinearlayout.h @@ -97,9 +97,7 @@ public: Q5SizePolicy::ControlTypes controlTypes(LayoutSide side) const; #endif -#ifdef QT_DEBUG void dump(int indent = 0) const; -#endif protected: #if 0 diff --git a/src/gui/styles/qstyle.cpp b/src/gui/styles/qstyle.cpp index eef1573..ec238a9 100644 --- a/src/gui/styles/qstyle.cpp +++ b/src/gui/styles/qstyle.cpp @@ -2417,13 +2417,13 @@ int QStyle::layoutSpacingImplementation(QSizePolicy::ControlType /* control1 */, return -1; } -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) QT_BEGIN_INCLUDE_NAMESPACE #include QT_END_INCLUDE_NAMESPACE QDebug operator<<(QDebug debug, QStyle::State state) { +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) debug << "QStyle::State("; QStringList states; @@ -2455,9 +2455,9 @@ QDebug operator<<(QDebug debug, QStyle::State state) qSort(states); debug << states.join(QLatin1String(" | ")); debug << ')'; +#endif return debug; } -#endif /*! \since 4.6 diff --git a/src/gui/styles/qstyle.h b/src/gui/styles/qstyle.h index 1f8d5c8..0014954 100644 --- a/src/gui/styles/qstyle.h +++ b/src/gui/styles/qstyle.h @@ -878,9 +878,7 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::State) Q_DECLARE_OPERATORS_FOR_FLAGS(QStyle::SubControls) -#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DEBUG) Q_GUI_EXPORT QDebug operator<<(QDebug debug, QStyle::State state); -#endif QT_END_NAMESPACE diff --git a/src/gui/styles/qstyleoption.cpp b/src/gui/styles/qstyleoption.cpp index 10a6b5b..061afcc 100644 --- a/src/gui/styles/qstyleoption.cpp +++ b/src/gui/styles/qstyleoption.cpp @@ -45,9 +45,7 @@ # include "private/qt_mac_p.h" # include "qmacstyle_mac.h" #endif -#ifndef QT_NO_DEBUG #include -#endif #include QT_BEGIN_NAMESPACE @@ -1254,7 +1252,7 @@ QStyleOptionViewItemV4::QStyleOptionViewItemV4(int version) \brief the features of the group box frame The frame is flat by default. - + \sa QStyleOptionFrameV2::FrameFeature */ @@ -5298,9 +5296,9 @@ QStyleHintReturnVariant::QStyleHintReturnVariant() : QStyleHintReturn(Version, T Returns a T or 0 depending on the type of \a hint. */ -#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) { +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) switch (optionType) { case QStyleOption::SO_Default: debug << "SO_Default"; break; @@ -5361,19 +5359,21 @@ QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType) case QStyleOption::SO_GraphicsItem: debug << "SO_GraphicsItem"; break; } +#endif return debug; } QDebug operator<<(QDebug debug, const QStyleOption &option) { +#if !defined(QT_NO_DEBUG) && !defined(QT_NO_DEBUG_STREAM) debug << "QStyleOption("; debug << QStyleOption::OptionType(option.type); debug << ',' << (option.direction == Qt::RightToLeft ? "RightToLeft" : "LeftToRight"); debug << ',' << option.state; debug << ',' << option.rect; debug << ')'; +#endif return debug; } -#endif QT_END_NAMESPACE diff --git a/src/gui/styles/qstyleoption.h b/src/gui/styles/qstyleoption.h index 2860664..bf8b479 100644 --- a/src/gui/styles/qstyleoption.h +++ b/src/gui/styles/qstyleoption.h @@ -938,10 +938,8 @@ T qstyleoption_cast(QStyleHintReturn *hint) return 0; } -#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DEBUG) Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption::OptionType &optionType); Q_GUI_EXPORT QDebug operator<<(QDebug debug, const QStyleOption &option); -#endif QT_END_NAMESPACE -- cgit v0.12 From 63b8a706c57ed292d82fc16a446daa543cf12a38 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 22 Oct 2009 15:21:29 +0200 Subject: stabilize QListView test --- tests/auto/qlistview/tst_qlistview.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/qlistview/tst_qlistview.cpp b/tests/auto/qlistview/tst_qlistview.cpp index 6e211ae..3968529 100644 --- a/tests/auto/qlistview/tst_qlistview.cpp +++ b/tests/auto/qlistview/tst_qlistview.cpp @@ -1132,6 +1132,7 @@ void tst_QListView::selection() #endif v.show(); + QTest::qWaitForWindowShown(&v); QApplication::processEvents(); v.setSelection(selectionRect, QItemSelectionModel::ClearAndSelect); @@ -1184,6 +1185,7 @@ void tst_QListView::scrollTo() lv.setModel(&model); lv.setFixedSize(100, 200); lv.show(); + QTest::qWaitForWindowShown(&lv); //by default, the list view scrolls per item and has no wrapping QModelIndex index = model.index(6,0); @@ -1782,12 +1784,13 @@ void tst_QListView::task262152_setModelColumnNavigate() view.setModelColumn(1); view.show(); - QTest::qWait(100); + QTest::qWaitForWindowShown(&view); + QTest::qWait(10); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(100); + QTest::qWait(10); QCOMPARE(view.currentIndex(), model.index(1,1)); QTest::keyClick(&view, Qt::Key_Down); - QTest::qWait(100); + QTest::qWait(10); QCOMPARE(view.currentIndex(), model.index(2,1)); } -- cgit v0.12 From 44aa15a08dd8e7e1ea428fd8868a8e531f5ba4d9 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 22 Oct 2009 16:04:34 +0200 Subject: Autotest fix for parallel animation group On macos (as on symbian), we need to leave some time for the application to become responsive. --- .../tst_qparallelanimationgroup.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 8578d36..8d937e9 100644 --- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -56,8 +56,7 @@ public: virtual ~tst_QParallelAnimationGroup(); public Q_SLOTS: - void init(); - void cleanup(); + void initTestCase(); private slots: void construction(); @@ -86,13 +85,13 @@ tst_QParallelAnimationGroup::~tst_QParallelAnimationGroup() { } -void tst_QParallelAnimationGroup::init() +void tst_QParallelAnimationGroup::initTestCase() { qRegisterMetaType("QAbstractAnimation::State"); -} - -void tst_QParallelAnimationGroup::cleanup() -{ +#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAC) || defined(Q_WS_WINCE) + // give the Symbian and mac app start event queue time to clear + QTest::qWait(1000); +#endif } void tst_QParallelAnimationGroup::construction() @@ -486,10 +485,6 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() void tst_QParallelAnimationGroup::deleteChildrenWithRunningGroup() { -#if defined(Q_OS_SYMBIAN) - // give the Symbian app start event queue time to clear - QTest::qWait(1000); -#endif // test if children can be activated when their group is stopped QParallelAnimationGroup group; -- cgit v0.12 From bff3c3daf29e581cd0b8b990491ff9444c63a3e9 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 22 Oct 2009 16:09:43 +0200 Subject: Update 4.6 def files Reviewed-by: TrustMe --- src/s60installs/eabi/QtCoreu.def | 2 ++ src/s60installs/eabi/QtGuiu.def | 44 ++++++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 2ecc48f..33df9fe 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3577,4 +3577,6 @@ EXPORTS uncompress @ 3576 NONAME zError @ 3577 NONAME zlibVersion @ 3578 NONAME + _ZNSsC1EPKcRKSaIcE @ 3579 NONAME + _ZNSsC2EPKcRKSaIcE @ 3580 NONAME diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 1f4be7a..0c47232 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -1511,13 +1511,13 @@ EXPORTS _ZN12QApplication13startDragTimeEv @ 1510 NONAME _ZN12QApplication14navigationModeEv @ 1511 NONAME _ZN12QApplication14overrideCursorEv @ 1512 NONAME - _ZN12QApplication14s60EventFilterEP8TWsEvent @ 1513 NONAME + _ZN12QApplication14s60EventFilterEP8TWsEvent @ 1513 NONAME ABSENT _ZN12QApplication14setGlobalStrutERK5QSize @ 1514 NONAME _ZN12QApplication15closeAllWindowsEv @ 1515 NONAME _ZN12QApplication15cursorFlashTimeEv @ 1516 NONAME _ZN12QApplication15isEffectEnabledEN2Qt8UIEffectE @ 1517 NONAME _ZN12QApplication15layoutDirectionEv @ 1518 NONAME - _ZN12QApplication15s60ProcessEventEP8TWsEvent @ 1519 NONAME + _ZN12QApplication15s60ProcessEventEP8TWsEvent @ 1519 NONAME ABSENT _ZN12QApplication15setActiveWindowEP7QWidget @ 1520 NONAME _ZN12QApplication15setInputContextEP13QInputContext @ 1521 NONAME _ZN12QApplication15topLevelWidgetsEv @ 1522 NONAME @@ -1546,10 +1546,10 @@ EXPORTS _ZN12QApplication20changeOverrideCursorERK7QCursor @ 1545 NONAME _ZN12QApplication20desktopSettingsAwareEv @ 1546 NONAME _ZN12QApplication20setStartDragDistanceEi @ 1547 NONAME - _ZN12QApplication20symbianHandleCommandEi @ 1548 NONAME + _ZN12QApplication20symbianHandleCommandEi @ 1548 NONAME ABSENT _ZN12QApplication21keyboardInputIntervalEv @ 1549 NONAME _ZN12QApplication21restoreOverrideCursorEv @ 1550 NONAME - _ZN12QApplication21symbianResourceChangeEi @ 1551 NONAME + _ZN12QApplication21symbianResourceChangeEi @ 1551 NONAME ABSENT _ZN12QApplication22keyboardInputDirectionEv @ 1552 NONAME _ZN12QApplication22quitOnLastWindowClosedEv @ 1553 NONAME _ZN12QApplication22setDoubleClickIntervalEi @ 1554 NONAME @@ -2458,7 +2458,7 @@ EXPORTS _ZN13QInputContext11qt_metacallEN11QMetaObject4CallEiPPv @ 2457 NONAME _ZN13QInputContext11qt_metacastEPKc @ 2458 NONAME _ZN13QInputContext12mouseHandlerEiP11QMouseEvent @ 2459 NONAME - _ZN13QInputContext14s60FilterEventEP7QWidgetP8TWsEvent @ 2460 NONAME + _ZN13QInputContext14s60FilterEventEP7QWidgetP8TWsEvent @ 2460 NONAME ABSENT _ZN13QInputContext14setFocusWidgetEP7QWidget @ 2461 NONAME _ZN13QInputContext15widgetDestroyedEP7QWidget @ 2462 NONAME _ZN13QInputContext16staticMetaObjectE @ 2463 NONAME DATA 16 @@ -5215,11 +5215,11 @@ EXPORTS _ZN24QGraphicsSceneWheelEventD1Ev @ 5214 NONAME _ZN24QGraphicsSceneWheelEventD2Ev @ 5215 NONAME _ZN24QImagePixmapCleanupHooks12addImageHookEPFvxE @ 5216 NONAME - _ZN24QImagePixmapCleanupHooks13addPixmapHookEPFvP7QPixmapE @ 5217 NONAME + _ZN24QImagePixmapCleanupHooks13addPixmapHookEPFvP7QPixmapE @ 5217 NONAME ABSENT _ZN24QImagePixmapCleanupHooks15removeImageHookEPFvxE @ 5218 NONAME - _ZN24QImagePixmapCleanupHooks16removePixmapHookEPFvP7QPixmapE @ 5219 NONAME + _ZN24QImagePixmapCleanupHooks16removePixmapHookEPFvP7QPixmapE @ 5219 NONAME ABSENT _ZN24QImagePixmapCleanupHooks17executeImageHooksEx @ 5220 NONAME - _ZN24QImagePixmapCleanupHooks18executePixmapHooksEP7QPixmap @ 5221 NONAME + _ZN24QImagePixmapCleanupHooks18executePixmapHooksEP7QPixmap @ 5221 NONAME ABSENT _ZN24QImagePixmapCleanupHooks8instanceEv @ 5222 NONAME _ZN24QImagePixmapCleanupHooksC1Ev @ 5223 NONAME _ZN24QImagePixmapCleanupHooksC2Ev @ 5224 NONAME @@ -11585,4 +11585,32 @@ EXPORTS _ZN14QWidgetPrivate17_q_delayedDestroyEP11CCoeControl @ 11584 NONAME _ZN14QWidgetPrivate21activateSymbianWindowEP11CCoeControl @ 11585 NONAME _ZNK17QRasterPixmapData26createCompatiblePixmapDataEv @ 11586 NONAME + _ZN12QApplication18symbianEventFilterEPK13QSymbianEvent @ 11587 NONAME + _ZN12QApplication19symbianProcessEventEPK13QSymbianEvent @ 11588 NONAME + _ZN13QInputContext18symbianFilterEventEP7QWidgetPK13QSymbianEvent @ 11589 NONAME + _ZN13QSymbianEventC1ENS_4TypeEi @ 11590 NONAME + _ZN13QSymbianEventC1EPK8TWsEvent @ 11591 NONAME + _ZN13QSymbianEventC2ENS_4TypeEi @ 11592 NONAME + _ZN13QSymbianEventC2EPK8TWsEvent @ 11593 NONAME + _ZN13QSymbianEventD1Ev @ 11594 NONAME + _ZN13QSymbianEventD2Ev @ 11595 NONAME + _ZN15QGraphicsAnchor13setSizePolicyEN11QSizePolicy6PolicyE @ 11596 NONAME + _ZN19QApplicationPrivate20symbianHandleCommandEi @ 11597 NONAME + _ZN19QApplicationPrivate21symbianProcessWsEventEPK8TWsEvent @ 11598 NONAME + _ZN19QApplicationPrivate21symbianResourceChangeEi @ 11599 NONAME + _ZN24QImagePixmapCleanupHooks24addPixmapDestructionHookEPFvP7QPixmapE @ 11600 NONAME + _ZN24QImagePixmapCleanupHooks25addPixmapModificationHookEPFvP7QPixmapE @ 11601 NONAME + _ZN24QImagePixmapCleanupHooks27removePixmapDestructionHookEPFvP7QPixmapE @ 11602 NONAME + _ZN24QImagePixmapCleanupHooks28removePixmapModificationHookEPFvP7QPixmapE @ 11603 NONAME + _ZN24QImagePixmapCleanupHooks29executePixmapDestructionHooksEP7QPixmap @ 11604 NONAME + _ZN24QImagePixmapCleanupHooks30executePixmapModificationHooksEP7QPixmap @ 11605 NONAME + _ZNK11QPixmapData26createCompatiblePixmapDataEv @ 11606 NONAME + _ZNK13QSymbianEvent17windowServerEventEv @ 11607 NONAME + _ZNK13QSymbianEvent18resourceChangeTypeEv @ 11608 NONAME + _ZNK13QSymbianEvent7commandEv @ 11609 NONAME + _ZNK15QGraphicsAnchor10sizePolicyEv @ 11610 NONAME + _ZNK21QGraphicsLinearLayout4dumpEi @ 11611 NONAME + _Zls6QDebug6QFlagsIN6QStyle9StateFlagEE @ 11612 NONAME + _Zls6QDebugRK12QStyleOption @ 11613 NONAME + _Zls6QDebugRKN12QStyleOption10OptionTypeE @ 11614 NONAME -- cgit v0.12 From a96c204078122b8dd06ac5bb4d49b76f87f686f5 Mon Sep 17 00:00:00 2001 From: ninerider Date: Thu, 22 Oct 2009 16:43:56 +0200 Subject: Description: Auto test fixes for Windows Mobile platform Reviewed-by: Joerg --- tests/auto/qfiledialog2/tst_qfiledialog2.cpp | 48 +++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp index 18f94a9..83ddd39 100644 --- a/tests/auto/qfiledialog2/tst_qfiledialog2.cpp +++ b/tests/auto/qfiledialog2/tst_qfiledialog2.cpp @@ -136,7 +136,10 @@ private: }; tst_QFiledialog::tst_QFiledialog() -{ +{ +#if defined(Q_OS_WINCE) + qApp->setAutoMaximizeThreshold(-1); +#endif } tst_QFiledialog::~tst_QFiledialog() @@ -168,13 +171,21 @@ void tst_QFiledialog::cleanup() void tst_QFiledialog::listRoot() { #if defined QT_BUILD_INTERNAL + QFileInfoGatherer fileInfoGatherer; + fileInfoGatherer.start(); + QTest::qWait(1500); + QFileInfoGatherer::fetchedRoot = false; QString dir(QDir::currentPath()); QNonNativeFileDialog fd(0, QString(), dir); fd.show(); QCOMPARE(QFileInfoGatherer::fetchedRoot,false); fd.setDirectory(""); +#ifdef Q_OS_WINCE + QTest::qWait(1500); +#else QTest::qWait(500); +#endif QCOMPARE(QFileInfoGatherer::fetchedRoot,true); #endif } @@ -297,6 +308,7 @@ void tst_QFiledialog::emptyUncPath() void tst_QFiledialog::task178897_minimumSize() { QNonNativeFileDialog fd; + QSize oldMs = fd.layout()->minimumSize(); QStringList history = fd.history(); history << QDir::toNativeSeparators("/verylongdirectory/" "aaaaaaaaaabbbbbbbbcccccccccccddddddddddddddeeeeeeeeeeeeffffffffffgggtggggggggghhhhhhhhiiiiiijjjk"); @@ -304,7 +316,7 @@ void tst_QFiledialog::task178897_minimumSize() fd.show(); QSize ms = fd.layout()->minimumSize(); - QVERIFY(ms.width() < 400); + QVERIFY(ms.width() <= oldMs.width()); } void tst_QFiledialog::task180459_lastDirectory_data() @@ -653,22 +665,33 @@ void tst_QFiledialog::task228844_ensurePreviousSorting() fd.setDirectory(current.absolutePath()); fd.setViewMode(QFileDialog::Detail); fd.show(); +#if defined(Q_OS_WINCE) + QTest::qWait(1500); +#else QTest::qWait(500); +#endif QTreeView *tree = qFindChild(&fd, "treeView"); tree->header()->setSortIndicator(3,Qt::DescendingOrder); QTest::qWait(200); QDialogButtonBox *buttonBox = qFindChild(&fd, "buttonBox"); QPushButton *button = buttonBox->button(QDialogButtonBox::Open); QTest::mouseClick(button, Qt::LeftButton); +#if defined(Q_OS_WINCE) + QTest::qWait(1500); +#else QTest::qWait(500); - +#endif QNonNativeFileDialog fd2; fd2.setFileMode(QFileDialog::Directory); fd2.restoreState(fd.saveState()); current.cd("aaaaaaaaaaaaaaaaaa"); fd2.setDirectory(current.absolutePath()); fd2.show(); +#if defined(Q_OS_WINCE) + QTest::qWait(1500); +#else QTest::qWait(500); +#endif QTreeView *tree2 = qFindChild(&fd2, "treeView"); tree2->setFocus(); @@ -678,15 +701,22 @@ void tst_QFiledialog::task228844_ensurePreviousSorting() QPushButton *button2 = buttonBox2->button(QDialogButtonBox::Open); fd2.selectFile("g"); QTest::mouseClick(button2, Qt::LeftButton); +#if defined(Q_OS_WINCE) + QTest::qWait(1500); +#else QTest::qWait(500); - +#endif QCOMPARE(fd2.selectedFiles().first(), current.absolutePath() + QChar('/') + QLatin1String("g")); QNonNativeFileDialog fd3(0, "This is a third file dialog", tempFile->fileName()); fd3.restoreState(fd.saveState()); fd3.setFileMode(QFileDialog::Directory); fd3.show(); +#if defined(Q_OS_WINCE) + QTest::qWait(1500); +#else QTest::qWait(500); +#endif QTreeView *tree3 = qFindChild(&fd3, "treeView"); tree3->setFocus(); @@ -695,8 +725,11 @@ void tst_QFiledialog::task228844_ensurePreviousSorting() QDialogButtonBox *buttonBox3 = qFindChild(&fd3, "buttonBox"); QPushButton *button3 = buttonBox3->button(QDialogButtonBox::Open); QTest::mouseClick(button3, Qt::LeftButton); +#if defined(Q_OS_WINCE) + QTest::qWait(1500); +#else QTest::qWait(500); - +#endif QCOMPARE(fd3.selectedFiles().first(), tempFile->fileName()); current.cd("aaaaaaaaaaaaaaaaaa"); @@ -777,7 +810,12 @@ void tst_QFiledialog::task251321_sideBarHiddenEntries() sidebar->setFocus(); sidebar->selectUrl(QUrl::fromLocalFile(hiddenSubDir.absolutePath())); QTest::mouseClick(sidebar->viewport(), Qt::LeftButton, 0, sidebar->visualRect(sidebar->model()->index(0, 0)).center()); + // give the background processes more time on windows mobile +#ifdef Q_OS_WINCE + QTest::qWait(1000); +#else QTest::qWait(250); +#endif QFileSystemModel *model = qFindChild(&fd, "qt_filesystem_model"); QCOMPARE(model->rowCount(model->index(hiddenSubDir.absolutePath())), 2); -- cgit v0.12 From 8a64af9c24c5c275cba22240760d9239d4b3fd6f Mon Sep 17 00:00:00 2001 From: ninerider Date: Thu, 22 Oct 2009 16:50:46 +0200 Subject: Changed qsrand() behavior for Windows to match the linux version A problem occurred related to the createUUid function on Windows Mobile. Calling rand() before srand() resulted in identical pseudo random sequences for different threads. Reviewed-by: Joerg --- src/corelib/global/qglobal.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 5a7b559..7d47944 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2479,7 +2479,7 @@ bool qputenv(const char *varName, const QByteArray& value) #endif } -#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) +#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) # if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500) // older versions of INTEGRITY used a long instead of a uint for the seed. @@ -2535,20 +2535,35 @@ void qsrand(uint seed) */ void qsrand() { -#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) +#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) SeedStorageType *pseed = randTLS()->localData(); if (pseed) { // already seeded return; } randTLS()->setLocalData(pseed = new SeedStorageType); - static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(0); + // start beyond 1 to avoid the sequence reset + static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2); *pseed = QDateTime::currentDateTime().toTime_t() + quintptr(&pseed) + serial.fetchAndAddRelaxed(1); -#else - // On Windows, we assume that rand() already does the right thing +#if defined(Q_OS_WIN) + // for Windows the srand function must still be called. + srand(*pseed); #endif + +#elif defined(Q_OS_WIN) + static unsigned int seed = 0; + + if (seed) + return; + + seed = GetTickCount(); + srand(seed); +#else + // Symbian? + +#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN) } /*! -- cgit v0.12 From 630df1da5d49ed6984dcaffdc5860598b143f66c Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 22 Oct 2009 16:52:18 +0200 Subject: update QtGui def file One private export has been changed from non-const to const pointer parameter Reviewed-by: TrustMe --- src/s60installs/eabi/QtGuiu.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 0c47232..0e1bc43 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -3141,7 +3141,7 @@ EXPORTS _ZN14QWidgetPrivate25setLayoutDirection_helperEN2Qt15LayoutDirectionE @ 3140 NONAME _ZN14QWidgetPrivate26adjustQuitOnCloseAttributeEv @ 3141 NONAME _ZN14QWidgetPrivate26createDefaultWindowSurfaceEv @ 3142 NONAME - _ZN14QWidgetPrivate26nearestGraphicsProxyWidgetEP7QWidget @ 3143 NONAME + _ZN14QWidgetPrivate26nearestGraphicsProxyWidgetEPK7QWidget @ 3143 NONAME _ZN14QWidgetPrivate27widgetInNavigationDirectionENS_9DirectionE @ 3144 NONAME _ZN14QWidgetPrivate29invalidateBuffer_resizeHelperERK6QPointRK5QSize @ 3145 NONAME _ZN14QWidgetPrivate30createDefaultWindowSurface_sysEv @ 3146 NONAME -- cgit v0.12 From 1b154ddf00473700d697411304804ac065ef32ac Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 12 Oct 2009 16:54:52 +0200 Subject: Extended an autotest for gestures. Make sure that when a gesture recognizer explicitely sets the targetObject to a QGraphicsObject, we deliver it only to the object and will not try to propagate. Reviewed-by: trustme --- tests/auto/gestures/tst_gestures.cpp | 56 ++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 46ed45e..baf90fa 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -241,6 +241,16 @@ static void sendCustomGesture(QObject *object) QApplication::sendEvent(object, &ev); } } +static void sendCustomGesture(QObject *object, QObject *target) +{ + CustomEvent ev; + ev.targetObject = target; + for (int i = CustomGesture::SerialMaybeThreshold; + i <= CustomGesture::SerialFinishedThreshold; ++i) { + ev.serial = i; + QApplication::sendEvent(object, &ev); + } +} class tst_Gestures : public QObject { @@ -265,6 +275,7 @@ private slots: void finishedWithoutStarted(); void unknownGesture(); void graphicsItemGesture(); + void explicitGraphicsObjectTarget(); }; tst_Gestures::tst_Gestures() @@ -624,5 +635,50 @@ void tst_Gestures::graphicsItemGesture() QCOMPARE(item->events.canceled.size(), 0); } +void tst_Gestures::explicitGraphicsObjectTarget() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + GestureItem *item1 = new GestureItem; + scene.addItem(item1); + item1->setPos(100, 100); + item1->grabGesture(CustomGesture::GestureType); + + GestureItem *item2 = new GestureItem; + scene.addItem(item2); + item2->setPos(100, 100); + item2->grabGesture(CustomGesture::GestureType); + + GestureItem *item3 = new GestureItem; + scene.addItem(item3); + item3->setParentItem(item2); + item3->setPos(0, 0); + item3->grabGesture(CustomGesture::GestureType); + + // sending events to item1, but the targetObject for the gesture is item2. + sendCustomGesture(item1, item3); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; + + QCOMPARE(item1->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item1->gestureEventsReceived, 0); + QCOMPARE(item1->gestureOverrideEventsReceived, 0); + QCOMPARE(item3->customEventsReceived, 0); + QCOMPARE(item3->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item3->gestureOverrideEventsReceived, 0); + QCOMPARE(item3->events.all.size(), TotalGestureEventsCount); + for(int i = 0; i < item3->events.all.size(); ++i) + QCOMPARE(item3->events.all.at(i), CustomGesture::GestureType); + QCOMPARE(item3->events.started.size(), 1); + QCOMPARE(item3->events.updated.size(), TotalGestureEventsCount - 2); + QCOMPARE(item3->events.finished.size(), 1); + QCOMPARE(item3->events.canceled.size(), 0); + QCOMPARE(item2->customEventsReceived, 0); + QCOMPARE(item2->gestureEventsReceived, 0); + QCOMPARE(item2->gestureOverrideEventsReceived, 0); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From d1a60dcbddbae46aaea655bb55c0c8fd46f38b2c Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 13 Oct 2009 10:11:54 +0200 Subject: Improved gesture event filtering inside QGraphicsView for QGraphicObjects Reviewed-by: trustme --- src/corelib/global/qnamespace.h | 5 +- src/gui/graphicsview/qgraphicsitem.h | 2 +- src/gui/graphicsview/qgraphicsscene.cpp | 40 +++++- src/gui/graphicsview/qgraphicsscene_p.h | 2 + src/gui/graphicsview/qgraphicsview.cpp | 13 ++ src/gui/kernel/qapplication.cpp | 9 +- src/gui/kernel/qevent.cpp | 16 +++ src/gui/kernel/qevent.h | 5 + src/gui/kernel/qgesture.cpp | 10 -- src/gui/kernel/qgesture.h | 4 - src/gui/kernel/qgesturemanager.cpp | 226 +++++++++++++++++--------------- src/gui/kernel/qgesturemanager_p.h | 10 +- tests/auto/gestures/tst_gestures.cpp | 215 ++++++++++++++++++++++-------- 13 files changed, 372 insertions(+), 185 deletions(-) diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h index f28f94e..2b62c6b 100644 --- a/src/corelib/global/qnamespace.h +++ b/src/corelib/global/qnamespace.h @@ -1631,7 +1631,10 @@ public: enum GestureContext { WidgetGesture = 0, - WidgetWithChildrenGesture = 3 + WidgetWithChildrenGesture = 3, + + ItemGesture = WidgetGesture, + ItemWithChildrenGesture = WidgetWithChildrenGesture }; enum NavigationMode diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 2665235..54a7a64 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -555,7 +555,7 @@ public: using QObject::children; #endif - void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::WidgetWithChildrenGesture); + void grabGesture(Qt::GestureType type, Qt::GestureContext context = Qt::ItemWithChildrenGesture); Q_SIGNALS: void parentChanged(); diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a624b10..373ee89 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -242,7 +242,6 @@ #include #include #include -#include #include #include #include @@ -251,6 +250,7 @@ #include #endif #include +#include QT_BEGIN_NAMESPACE @@ -1052,6 +1052,14 @@ bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event) */ bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event) { + if (QGraphicsObject *object = item->toGraphicsObject()) { + QApplicationPrivate *qAppPriv = QApplicationPrivate::instance(); + if (qAppPriv->gestureManager) { + if (qAppPriv->gestureManager->filterEvent(object, event)) + return true; + } + } + if (filterEvent(item, event)) return false; if (filterDescendantEvent(item, event)) @@ -3365,6 +3373,10 @@ bool QGraphicsScene::event(QEvent *event) case QEvent::TouchEnd: d->touchEventHandler(static_cast(event)); break; + case QEvent::Gesture: + case QEvent::GestureOverride: + d->gestureEventHandler(static_cast(event)); + break; default: return QObject::event(event); } @@ -5699,6 +5711,32 @@ void QGraphicsScenePrivate::leaveModal(QGraphicsItem *panel) dispatchHoverEvent(&hoverEvent); } +void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) +{ + QWidget *viewport = event->widget(); + QList gestures = event->allGestures(); + for (int i = 0; i < gestures.size(); ++i) { + QGesture *gesture = gestures.at(i); + Qt::GestureType gestureType = gesture->gestureType(); + QPoint screenPos = gesture->hotSpot().toPoint(); + QList items = itemsAtPosition(screenPos, QPointF(), viewport); + for (int j = 0; j < items.size(); ++j) { + QGraphicsObject *item = items.at(j)->toGraphicsObject(); + if (!item) + continue; + QGraphicsItemPrivate *d = item->QGraphicsItem::d_func(); + if (d->gestureContext.contains(gestureType)) { + QGestureEvent ev(QList() << gesture); + ev.t = event->t; + ev.spont = event->spont; + ev.setWidget(event->widget()); + sendEvent(item, &ev); + break; + } + } + } +} + QT_END_NAMESPACE #include "moc_qgraphicsscene.cpp" diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 8073695..4c82b49 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -282,6 +282,8 @@ public: bool allItemsIgnoreTouchEvents; void enableTouchEventsOnViews(); + void gestureEventHandler(QGestureEvent *event); + void updateInputMethodSensitivityInViews(); QList modalPanels; diff --git a/src/gui/graphicsview/qgraphicsview.cpp b/src/gui/graphicsview/qgraphicsview.cpp index 32747cc..710c745 100644 --- a/src/gui/graphicsview/qgraphicsview.cpp +++ b/src/gui/graphicsview/qgraphicsview.cpp @@ -2701,6 +2701,19 @@ bool QGraphicsView::viewportEvent(QEvent *event) return true; } + case QEvent::Gesture: + case QEvent::GestureOverride: + { + if (!isEnabled()) + return false; + + if (d->scene && d->sceneInteractionAllowed) { + QGestureEvent *gestureEvent = static_cast(event); + gestureEvent->setWidget(viewport()); + (void) QApplication::sendEvent(d->scene, gestureEvent); + } + return true; + } default: break; } diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index c4249d9..30440eb 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -3639,8 +3639,13 @@ bool QApplication::notify(QObject *receiver, QEvent *e) // walk through parents and check for gestures if (d->gestureManager) { - if (d->gestureManager->filterEvent(receiver, e)) - return true; + if (receiver->isWidgetType()) { + if (d->gestureManager->filterEvent(static_cast(receiver), e)) + return true; + } else if (QGesture *gesture = qobject_cast(receiver)) { + if (d->gestureManager->filterEvent(gesture, e)) + return true; + } } diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 2ff6d65..e49de02 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4318,6 +4318,22 @@ bool QGestureEvent::isAccepted(QGesture *gesture) const return gesture ? gesture->d_func()->accept : false; } +/*! + \internal +*/ +void QGestureEvent::setWidget(QWidget *widget) +{ + widget_ = widget; +} + +/*! + \internal +*/ +QWidget *QGestureEvent::widget() const +{ + return widget_; +} + #ifdef Q_NO_USING_KEYWORD /*! \fn void QGestureEvent::setAccepted(bool accepted) diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 3516222..6cba5fb 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -849,8 +849,13 @@ public: void ignore(QGesture *); bool isAccepted(QGesture *) const; + // internal + void setWidget(QWidget *widget); + QWidget *widget() const; + private: QList gestures_; + QWidget *widget_; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index fc8df49..e48fd8e 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -154,16 +154,6 @@ Qt::GestureState QGesture::state() const return d_func()->state; } -QObject *QGesture::targetObject() const -{ - return d_func()->targetObject; -} - -void QGesture::setTargetObject(QObject *value) -{ - d_func()->targetObject = value; -} - QPointF QGesture::hotSpot() const { return d_func()->hotSpot; diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 02eb526..9d1c11e 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -67,7 +67,6 @@ class Q_GUI_EXPORT QGesture : public QObject Q_PROPERTY(Qt::GestureType gestureType READ gestureType) Q_PROPERTY(QPointF hotSpot READ hotSpot WRITE setHotSpot RESET unsetHotSpot) Q_PROPERTY(bool hasHotSpot READ hasHotSpot) - Q_PROPERTY(QObject* targetObject READ targetObject WRITE setTargetObject) public: explicit QGesture(QObject *parent = 0); @@ -77,9 +76,6 @@ public: Qt::GestureState state() const; - QObject *targetObject() const; - void setTargetObject(QObject *value); - QPointF hotSpot() const; void setHotSpot(const QPointF &value); bool hasHotSpot() const; diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 0f0aef2..4f8a911 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -88,7 +88,8 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r { QGesture *dummy = recognizer->createGesture(0); if (!dummy) { - qWarning("QGestureManager::registerGestureRecognizer: the recognizer doesn't provide gesture object"); + qWarning("QGestureManager::registerGestureRecognizer: " + "the recognizer doesn't provide gesture object"); return Qt::GestureType(0); } Qt::GestureType type = dummy->gestureType(); @@ -107,7 +108,7 @@ void QGestureManager::unregisterGestureRecognizer(Qt::GestureType) } -QGesture* QGestureManager::getState(QObject *object, Qt::GestureType type) +QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) { // if the widget is being deleted we should be carefull and not to // create a new state, as it will create QWeakPointer which doesnt work @@ -115,9 +116,14 @@ QGesture* QGestureManager::getState(QObject *object, Qt::GestureType type) if (object->isWidgetType()) { if (static_cast(object)->d_func()->data.in_destructor) return 0; + } else if (QGesture *g = qobject_cast(object)) { + return g; + } else { + Q_ASSERT(qobject_cast(object)); } - QWeakPointer state = objectGestures.value(QGestureManager::ObjectGesture(object, type)); + QWeakPointer state = + objectGestures.value(QGestureManager::ObjectGesture(object, type)); if (!state) { QGestureRecognizer *recognizer = recognizers.value(type); if (recognizer) { @@ -136,7 +142,9 @@ QGesture* QGestureManager::getState(QObject *object, Qt::GestureType type) return state.data(); } -bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) +bool QGestureManager::filterEventThroughContexts(const QMap &contexts, + QObject *receiver, QEvent *event) { QSet triggeredGestures; QSet finishedGestures; @@ -144,93 +152,20 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) QSet canceledGestures; QSet notGestures; - QGraphicsObject *graphicsObject = qobject_cast(receiver); - if (receiver->isWidgetType() || graphicsObject) { - QMap contexts; - if (receiver->isWidgetType()) { - QWidget *w = static_cast(receiver); - if (!w->d_func()->gestureContext.isEmpty()) { - typedef QMap::const_iterator ContextIterator; - for(ContextIterator it = w->d_func()->gestureContext.begin(), - e = w->d_func()->gestureContext.end(); it != e; ++it) { - contexts.insertMulti(w, it.key()); - } - } - // find all gesture contexts for the widget tree - w = w->parentWidget(); - while (w) - { - typedef QMap::const_iterator ContextIterator; - for (ContextIterator it = w->d_func()->gestureContext.begin(), - e = w->d_func()->gestureContext.end(); it != e; ++it) { - if (it.value() == Qt::WidgetWithChildrenGesture) - contexts.insertMulti(w, it.key()); - } - w = w->parentWidget(); - } - } else { - QGraphicsObject *item = graphicsObject; - if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { - typedef QMap::const_iterator ContextIterator; - for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), - e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { - contexts.insertMulti(item, it.key()); - } - } - // find all gesture contexts for the widget tree - item = item->parentObject(); - while (item) - { - typedef QMap::const_iterator ContextIterator; - for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), - e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { - if (it.value() == Qt::WidgetWithChildrenGesture) - contexts.insertMulti(item, it.key()); - } - item = item->parentObject(); - } - } - // filter the event through recognizers - typedef QMap::const_iterator ContextIterator; - for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) { - Qt::GestureType gestureType = cit.value(); - QMap::const_iterator - rit = recognizers.lowerBound(gestureType), - re = recognizers.upperBound(gestureType); - for (; rit != re; ++rit) { - QGestureRecognizer *recognizer = rit.value(); - QObject *target = cit.key(); - QGesture *state = getState(target, gestureType); - if (!state) - continue; - QGestureRecognizer::Result result = recognizer->filterEvent(state, target, event); - QGestureRecognizer::Result type = result & QGestureRecognizer::ResultState_Mask; - if (type == QGestureRecognizer::GestureTriggered) { - DEBUG() << "QGestureManager: gesture triggered: " << state; - triggeredGestures << state; - } else if (type == QGestureRecognizer::GestureFinished) { - DEBUG() << "QGestureManager: gesture finished: " << state; - finishedGestures << state; - } else if (type == QGestureRecognizer::MaybeGesture) { - DEBUG() << "QGestureManager: maybe gesture: " << state; - newMaybeGestures << state; - } else if (type == QGestureRecognizer::NotGesture) { - DEBUG() << "QGestureManager: not gesture: " << state; - notGestures << state; - } else if (type == QGestureRecognizer::Ignore) { - DEBUG() << "QGestureManager: gesture ignored the event: " << state; - } else { - DEBUG() << "QGestureManager: hm, lets assume the recognizer ignored the event: " << state; - } - if (result & QGestureRecognizer::ConsumeEventHint) { - DEBUG() << "QGestureManager: we were asked to consume the event: " << state; - //TODO: consume events if asked - } - } - } - } else if (QGesture *state = qobject_cast(receiver)) { - if (QGestureRecognizer *recognizer = gestureToRecognizer.value(state)) { - QGestureRecognizer::Result result = recognizer->filterEvent(state, state, event); + // filter the event through recognizers + typedef QMap::const_iterator ContextIterator; + for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) { + Qt::GestureType gestureType = cit.value(); + QMap::const_iterator + rit = recognizers.lowerBound(gestureType), + re = recognizers.upperBound(gestureType); + for (; rit != re; ++rit) { + QGestureRecognizer *recognizer = rit.value(); + QObject *target = cit.key(); + QGesture *state = getState(target, gestureType); + if (!state) + continue; + QGestureRecognizer::Result result = recognizer->filterEvent(state, target, event); QGestureRecognizer::Result type = result & QGestureRecognizer::ResultState_Mask; if (type == QGestureRecognizer::GestureTriggered) { DEBUG() << "QGestureManager: gesture triggered: " << state; @@ -247,11 +182,15 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) } else if (type == QGestureRecognizer::Ignore) { DEBUG() << "QGestureManager: gesture ignored the event: " << state; } else { - DEBUG() << "QGestureManager: hm, lets assume the recognizer ignored the event: " << state; + DEBUG() << "QGestureManager: hm, lets assume the recognizer" + << "ignored the event: " << state; + } + if (result & QGestureRecognizer::ConsumeEventHint) { + DEBUG() << "QGestureManager: we were asked to consume the event: " + << state; + //TODO: consume events if asked } } - } else { - return false; } QSet startedGestures = triggeredGestures - activeGestures; @@ -260,7 +199,8 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) // check if a running gesture switched back to maybe state QSet activeToMaybeGestures = activeGestures & newMaybeGestures; - // check if a running gesture switched back to not gesture state, i.e. were canceled + // check if a running gesture switched back to not gesture state, + // i.e. were canceled QSet activeToCancelGestures = activeGestures & notGestures; canceledGestures += activeToCancelGestures; @@ -271,7 +211,9 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) timer.start(3000, this); } // kill timers for gestures that were in maybe state - QSet notMaybeGestures = (startedGestures | triggeredGestures | finishedGestures | canceledGestures | notGestures); + QSet notMaybeGestures = (startedGestures | triggeredGestures + | finishedGestures | canceledGestures + | notGestures); foreach(QGesture *gesture, notMaybeGestures) { QMap::iterator it = maybeGestures.find(gesture); @@ -294,7 +236,9 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) // probably those are "singleshot" gestures so we'll fake the started state. foreach (QGesture *gesture, notStarted) gesture->d_func()->state = Qt::GestureStarted; - deliverEvents(notStarted, receiver); + QSet undeliveredGestures; + deliverEvents(notStarted, receiver, &undeliveredGestures); + finishedGestures -= undeliveredGestures; } activeGestures += startedGestures; @@ -328,10 +272,15 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) << "\n\tcanceled:" << canceledGestures; } - deliverEvents(startedGestures+triggeredGestures+finishedGestures+canceledGestures, receiver); + QSet undeliveredGestures; + deliverEvents(startedGestures+triggeredGestures+finishedGestures+canceledGestures, + receiver, &undeliveredGestures); + + activeGestures -= undeliveredGestures; // reset gestures that ended - QSet endedGestures = finishedGestures + canceledGestures; + QSet endedGestures = + finishedGestures + canceledGestures + undeliveredGestures; foreach (QGesture *gesture, endedGestures) { if (QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0)) { recognizer->reset(gesture); @@ -341,7 +290,68 @@ bool QGestureManager::filterEvent(QObject *receiver, QEvent *event) return false; } -void QGestureManager::deliverEvents(const QSet &gestures, QObject *lastReceiver) +bool QGestureManager::filterEvent(QWidget *receiver, QEvent *event) +{ + QMap contexts; + QWidget *w = receiver; + if (!w->d_func()->gestureContext.isEmpty()) { + typedef QMap::const_iterator ContextIterator; + for(ContextIterator it = w->d_func()->gestureContext.begin(), + e = w->d_func()->gestureContext.end(); it != e; ++it) { + contexts.insertMulti(w, it.key()); + } + } + // find all gesture contexts for the widget tree + w = w->parentWidget(); + while (w) + { + typedef QMap::const_iterator ContextIterator; + for (ContextIterator it = w->d_func()->gestureContext.begin(), + e = w->d_func()->gestureContext.end(); it != e; ++it) { + if (it.value() == Qt::WidgetWithChildrenGesture) + contexts.insertMulti(w, it.key()); + } + w = w->parentWidget(); + } + return filterEventThroughContexts(contexts , receiver, event); +} + +bool QGestureManager::filterEvent(QGraphicsObject *graphicsObject, QEvent *event) +{ + QMap contexts; + QGraphicsObject *item = graphicsObject; + if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { + typedef QMap::const_iterator ContextIterator; + for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), + e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { + contexts.insertMulti(item, it.key()); + } + } + // find all gesture contexts for the graphics object tree + item = item->parentObject(); + while (item) + { + typedef QMap::const_iterator ContextIterator; + for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), + e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { + if (it.value() == Qt::ItemWithChildrenGesture) + contexts.insertMulti(item, it.key()); + } + item = item->parentObject(); + } + return filterEventThroughContexts(contexts, graphicsObject, event); +} + +bool QGestureManager::filterEvent(QGesture *state, QEvent *event) +{ + QMap contexts; + contexts.insert(state, state->gestureType()); + return filterEventThroughContexts(contexts, 0, event); +} + +void QGestureManager::deliverEvents(const QSet &gestures, + QObject *lastReceiver, + QSet *undeliveredGestures) { if (gestures.isEmpty()) return; @@ -360,16 +370,12 @@ void QGestureManager::deliverEvents(const QSet &gestures, QObject *la if (gesture->hasHotSpot()) { // guess the target using the hotspot of the gesture QPoint pt = gesture->hotSpot().toPoint(); - if (!pt.isNull()) { - if (QWidget *w = qApp->topLevelAt(pt)) - target = w->childAt(w->mapFromGlobal(pt)); + if (QWidget *w = qApp->topLevelAt(pt)) { + target = w->childAt(w->mapFromGlobal(pt)); } } - if (!target) { - target = gesture->targetObject(); - if (!target) - target = lastReceiver; - } + if (!target) + target = lastReceiver; } if (target) { gestureTargets.insert(gesture, target); @@ -379,11 +385,13 @@ void QGestureManager::deliverEvents(const QSet &gestures, QObject *la } else { qWarning() << "QGestureManager::deliverEvent: could not find the target for gesture" << gesture->gestureType(); + undeliveredGestures->insert(gesture); } } typedef QMultiHash::const_iterator ObjectGesturesIterator; - for (ObjectGesturesIterator it = objectGestures.begin(), e = objectGestures.end(); it != e; ++it) { + for (ObjectGesturesIterator it = objectGestures.begin(), + e = objectGestures.end(); it != e; ++it) { QObject *object1 = it.key(); QWidget *widget1 = qobject_cast(object1); QGraphicsObject *item1 = qobject_cast(object1); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index c61819f..5fc02ab 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE class QBasicTimer; +class QGraphicsObject; class QGestureManager : public QObject { Q_OBJECT @@ -71,13 +72,17 @@ public: Qt::GestureType registerGestureRecognizer(QGestureRecognizer *recognizer); void unregisterGestureRecognizer(Qt::GestureType type); - bool filterEvent(QObject *receiver, QEvent *event); + bool filterEvent(QWidget *receiver, QEvent *event); + bool filterEvent(QGesture *receiver, QEvent *event); + bool filterEvent(QGraphicsObject *receiver, QEvent *event); // declared in qapplication.cpp static QGestureManager* instance(); protected: void timerEvent(QTimerEvent *event); + bool filterEventThroughContexts(const QMap &contexts, + QObject *receiver, QEvent *event); private: QMultiMap recognizers; @@ -117,7 +122,8 @@ private: int lastCustomGestureId; QGesture *getState(QObject *widget, Qt::GestureType gesture); - void deliverEvents(const QSet &gestures, QObject *lastReceiver); + void deliverEvents(const QSet &gestures, QObject *lastReceiver, + QSet *undeliveredGestures); }; QT_END_NAMESPACE diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index baf90fa..3ce5b86 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -56,6 +56,11 @@ //TESTED_CLASS= //TESTED_FILES= +static QPointF mapToGlobal(const QPointF &pt, QGraphicsItem *item, QGraphicsView *view) +{ + return view->mapToGlobal(view->mapFromScene(item->mapToScene(pt))); +} + class CustomGesture : public QGesture { Q_OBJECT @@ -63,11 +68,10 @@ public: static Qt::GestureType GestureType; CustomGesture(QObject *parent = 0) - : QGesture(parent), target(0), serial(0) + : QGesture(parent), serial(0) { } - QObject *target; int serial; static const int SerialMaybeThreshold; @@ -86,13 +90,13 @@ public: CustomEvent(int serial_ = 0) : QEvent(QEvent::Type(CustomEvent::EventType)), - serial(serial_), targetObject(0) + serial(serial_), hasHotSpot(false) { } int serial; - QObject *targetObject; - QPoint hotSpot; + QPointF hotSpot; + bool hasHotSpot; }; int CustomEvent::EventType = 0; @@ -117,8 +121,8 @@ public: CustomGesture *g = static_cast(state); CustomEvent *e = static_cast(event); g->serial = e->serial; - g->setTargetObject(e->targetObject); - g->setHotSpot(e->hotSpot); + if (e->hasHotSpot) + g->setHotSpot(e->hotSpot); ++eventsCounter; if (g->serial >= CustomGesture::SerialFinishedThreshold) result |= QGestureRecognizer::GestureFinished; @@ -231,24 +235,15 @@ protected: } }; -static void sendCustomGesture(QObject *object) +static void sendCustomGesture(CustomEvent *event, QObject *object, QGraphicsScene *scene = 0) { - CustomEvent ev; - ev.targetObject = object; for (int i = CustomGesture::SerialMaybeThreshold; i <= CustomGesture::SerialFinishedThreshold; ++i) { - ev.serial = i; - QApplication::sendEvent(object, &ev); - } -} -static void sendCustomGesture(QObject *object, QObject *target) -{ - CustomEvent ev; - ev.targetObject = target; - for (int i = CustomGesture::SerialMaybeThreshold; - i <= CustomGesture::SerialFinishedThreshold; ++i) { - ev.serial = i; - QApplication::sendEvent(object, &ev); + event->serial = i; + if (scene) + scene->sendEvent(qobject_cast(object), event); + else + QApplication::sendEvent(object, event); } } @@ -276,6 +271,7 @@ private slots: void unknownGesture(); void graphicsItemGesture(); void explicitGraphicsObjectTarget(); + void gestureOverChildGraphicsItem(); }; tst_Gestures::tst_Gestures() @@ -309,7 +305,8 @@ void tst_Gestures::customGesture() { GestureWidget widget; widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); - sendCustomGesture(&widget); + CustomEvent event; + sendCustomGesture(&event, &widget); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; @@ -354,7 +351,8 @@ void tst_Gestures::gestureOverChild() widget.grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); - sendCustomGesture(child); + CustomEvent event; + sendCustomGesture(&event, child); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; @@ -372,7 +370,7 @@ void tst_Gestures::gestureOverChild() widget.reset(); child->reset(); - sendCustomGesture(child); + sendCustomGesture(&event, child); QCOMPARE(child->customEventsReceived, TotalCustomEventsCount); QCOMPARE(widget.customEventsReceived, 0); @@ -403,7 +401,8 @@ void tst_Gestures::multipleWidgetOnlyGestureInTree() static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; // sending events to the child and making sure there is no conflict - sendCustomGesture(child); + CustomEvent event; + sendCustomGesture(&event, child); QCOMPARE(child->customEventsReceived, TotalCustomEventsCount); QCOMPARE(parent.customEventsReceived, 0); @@ -416,7 +415,7 @@ void tst_Gestures::multipleWidgetOnlyGestureInTree() child->reset(); // same for the parent widget - sendCustomGesture(&parent); + sendCustomGesture(&event, &parent); QCOMPARE(child->customEventsReceived, 0); QCOMPARE(parent.customEventsReceived, TotalCustomEventsCount); @@ -443,7 +442,8 @@ void tst_Gestures::conflictingGestures() child->acceptGestureOverride = true; // sending events to the child and making sure there is no conflict - sendCustomGesture(child); + CustomEvent event; + sendCustomGesture(&event, child); QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount); QCOMPARE(child->gestureEventsReceived, 0); @@ -458,7 +458,7 @@ void tst_Gestures::conflictingGestures() child->acceptGestureOverride = false; // sending events to the child and making sure there is no conflict - sendCustomGesture(child); + sendCustomGesture(&event, child); QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount); QCOMPARE(child->gestureEventsReceived, 0); @@ -473,7 +473,7 @@ void tst_Gestures::conflictingGestures() child->acceptGestureOverride = false; // sending events to the child and making sure there is no conflict - sendCustomGesture(child); + sendCustomGesture(&event, child); QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount); QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); @@ -508,7 +508,8 @@ void tst_Gestures::unknownGesture() widget.grabGesture(Qt::CustomGesture, Qt::WidgetGesture); widget.grabGesture(Qt::GestureType(Qt::PanGesture+512), Qt::WidgetGesture); - sendCustomGesture(&widget); + CustomEvent event; + sendCustomGesture(&event, &widget); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; @@ -554,6 +555,15 @@ public: QRectF size; + void reset() + { + customEventsReceived = 0; + gestureEventsReceived = 0; + gestureOverrideEventsReceived = 0; + events.clear(); + overrideEvents.clear(); + } + protected: QRectF boundingRect() const { @@ -616,13 +626,37 @@ void tst_Gestures::graphicsItemGesture() scene.addItem(item); item->setPos(100, 100); - item->grabGesture(CustomGesture::GestureType); + view.show(); + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); - sendCustomGesture(item); + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + item->grabGesture(CustomGesture::GestureType); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; + CustomEvent event; + sendCustomGesture(&event, item, &scene); + + QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item->gestureOverrideEventsReceived, 0); + QCOMPARE(item->events.all.size(), TotalGestureEventsCount); + for(int i = 0; i < item->events.all.size(); ++i) + QCOMPARE(item->events.all.at(i), CustomGesture::GestureType); + QCOMPARE(item->events.started.size(), 1); + QCOMPARE(item->events.updated.size(), TotalGestureEventsCount - 2); + QCOMPARE(item->events.finished.size(), 1); + QCOMPARE(item->events.canceled.size(), 0); + + item->reset(); + + // make sure the event is properly delivered if only the hotspot is set. + event.hotSpot = mapToGlobal(QPointF(10, 10), item, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item, &scene); + QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount); QCOMPARE(item->gestureOverrideEventsReceived, 0); @@ -643,41 +677,112 @@ void tst_Gestures::explicitGraphicsObjectTarget() GestureItem *item1 = new GestureItem; scene.addItem(item1); item1->setPos(100, 100); - item1->grabGesture(CustomGesture::GestureType); GestureItem *item2 = new GestureItem; scene.addItem(item2); item2->setPos(100, 100); - item2->grabGesture(CustomGesture::GestureType); - GestureItem *item3 = new GestureItem; - scene.addItem(item3); - item3->setParentItem(item2); - item3->setPos(0, 0); - item3->grabGesture(CustomGesture::GestureType); + GestureItem *item2_child1 = new GestureItem; + scene.addItem(item2_child1); + item2_child1->setParentItem(item2); + item2_child1->setPos(10, 10); + + view.show(); + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); - // sending events to item1, but the targetObject for the gesture is item2. - sendCustomGesture(item1, item3); + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + item1->grabGesture(CustomGesture::GestureType, Qt::ItemGesture); + item2->grabGesture(CustomGesture::GestureType, Qt::ItemGesture); + item2_child1->grabGesture(CustomGesture::GestureType, Qt::ItemGesture); static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; - static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; - QCOMPARE(item1->customEventsReceived, TotalCustomEventsCount); + // sending events to item1, but the hotSpot is set to item2 + CustomEvent event; + event.hotSpot = mapToGlobal(QPointF(15, 15), item2, &view); + event.hasHotSpot = true; + + sendCustomGesture(&event, item1, &scene); + QCOMPARE(item1->gestureEventsReceived, 0); QCOMPARE(item1->gestureOverrideEventsReceived, 0); - QCOMPARE(item3->customEventsReceived, 0); - QCOMPARE(item3->gestureEventsReceived, TotalGestureEventsCount); - QCOMPARE(item3->gestureOverrideEventsReceived, 0); - QCOMPARE(item3->events.all.size(), TotalGestureEventsCount); - for(int i = 0; i < item3->events.all.size(); ++i) - QCOMPARE(item3->events.all.at(i), CustomGesture::GestureType); - QCOMPARE(item3->events.started.size(), 1); - QCOMPARE(item3->events.updated.size(), TotalGestureEventsCount - 2); - QCOMPARE(item3->events.finished.size(), 1); - QCOMPARE(item3->events.canceled.size(), 0); - QCOMPARE(item2->customEventsReceived, 0); + QCOMPARE(item2_child1->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); + QCOMPARE(item2_child1->events.all.size(), TotalGestureEventsCount); + for(int i = 0; i < item2_child1->events.all.size(); ++i) + QCOMPARE(item2_child1->events.all.at(i), CustomGesture::GestureType); + QCOMPARE(item2_child1->events.started.size(), 1); + QCOMPARE(item2_child1->events.updated.size(), TotalGestureEventsCount - 2); + QCOMPARE(item2_child1->events.finished.size(), 1); + QCOMPARE(item2_child1->events.canceled.size(), 0); + QCOMPARE(item2->gestureEventsReceived, 0); + QCOMPARE(item2->gestureOverrideEventsReceived, 0); +} + +void tst_Gestures::gestureOverChildGraphicsItem() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + GestureItem *item0 = new GestureItem; + scene.addItem(item0); + item0->setPos(0, 0); + + GestureItem *item1 = new GestureItem; + scene.addItem(item1); + item1->setPos(100, 100); + + GestureItem *item2 = new GestureItem; + scene.addItem(item2); + item2->setPos(100, 100); + + GestureItem *item2_child1 = new GestureItem; + scene.addItem(item2_child1); + item2_child1->setParentItem(item2); + item2_child1->setPos(0, 0); + + view.show(); + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); + + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + item1->grabGesture(CustomGesture::GestureType); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; + + CustomEvent event; + event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item0, &scene); + + QCOMPARE(item0->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item2_child1->gestureEventsReceived, 0); + QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); QCOMPARE(item2->gestureEventsReceived, 0); QCOMPARE(item2->gestureOverrideEventsReceived, 0); + QEXPECT_FAIL("", "need to fix gesture event propagation inside graphicsview", Continue); + QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item1->gestureOverrideEventsReceived, 0); + + item0->reset(); item1->reset(); item2->reset(); item2_child1->reset(); + item2->grabGesture(CustomGesture::GestureType); + + event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item0, &scene); + + QCOMPARE(item0->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item2_child1->gestureEventsReceived, 0); + QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); + QEXPECT_FAIL("", "need to fix gesture event propagation inside graphicsview", Continue); + QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount); + QEXPECT_FAIL("", "need to fix gesture event propagation inside graphicsview", Continue); + QCOMPARE(item2->gestureOverrideEventsReceived, TotalGestureEventsCount); + QCOMPARE(item1->gestureEventsReceived, 0); + QEXPECT_FAIL("", "need to fix gesture event propagation inside graphicsview", Continue); + QCOMPARE(item1->gestureOverrideEventsReceived, TotalGestureEventsCount); } QTEST_MAIN(tst_Gestures) -- cgit v0.12 From c5c1b878891b5ace5a71b95ea62229e26722fdba Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 14 Oct 2009 14:45:27 +0200 Subject: Fixed gesture event delivery when several gestures are triggered. When there are two different gestures are being triggered and they are supposed to be sent to different widgets, don't stop event "propagation" when the first event is successfully delivered. Reviewed-by: trustme --- src/gui/kernel/qapplication.cpp | 2 +- src/gui/kernel/qgesturemanager.cpp | 41 +++++++++++++++----------------- tests/auto/gestures/tst_gestures.cpp | 45 +++++++++++++++++++++++++++++++----- 3 files changed, 59 insertions(+), 29 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 30440eb..aee8afc 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4183,7 +4183,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) res = d->notify_helper(w, &ge); gestureEvent->spont = false; eventAccepted = ge.isAccepted(); - if (res && eventAccepted) + if (res && eventAccepted && allGestures.isEmpty()) break; if (!eventAccepted) { // ### two ways to ignore the event/gesture diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 4f8a911..8928d1c 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -361,7 +361,8 @@ void QGestureManager::deliverEvents(const QSet &gestures, GesturesPerReceiver groupedGestures; // for conflicted gestures the key is always the innermost widget (i.e. the child) GesturesPerReceiver conflictedGestures; - QMultiHash objectGestures; + typedef QMultiHash WidgetMultiGestures; + WidgetMultiGestures widgetMultiGestures; foreach (QGesture *gesture, gestures) { QObject *target = gestureTargets.value(gesture, 0); @@ -380,7 +381,7 @@ void QGestureManager::deliverEvents(const QSet &gestures, if (target) { gestureTargets.insert(gesture, target); if (target->isWidgetType()) - objectGestures.insert(target, gesture); + widgetMultiGestures.insert(static_cast(target), gesture); groupedGestures[target].append(gesture); } else { qWarning() << "QGestureManager::deliverEvent: could not find the target for gesture" @@ -389,30 +390,26 @@ void QGestureManager::deliverEvents(const QSet &gestures, } } - typedef QMultiHash::const_iterator ObjectGesturesIterator; - for (ObjectGesturesIterator it = objectGestures.begin(), - e = objectGestures.end(); it != e; ++it) { - QObject *object1 = it.key(); - QWidget *widget1 = qobject_cast(object1); - QGraphicsObject *item1 = qobject_cast(object1); + typedef WidgetMultiGestures::const_iterator WidgetMultiGesturesIterator; + for (WidgetMultiGesturesIterator it = widgetMultiGestures.begin(), + e = widgetMultiGestures.end(); it != e; ++it) { + QWidget *widget1 = it.key(); QGesture *gesture1 = it.value(); - ObjectGesturesIterator cit = it; + WidgetMultiGesturesIterator cit = it; for (++cit; cit != e; ++cit) { - QObject *object2 = cit.key(); - QWidget *widget2 = qobject_cast(object2); - QGraphicsObject *item2 = qobject_cast(object2); + QWidget *widget2 = cit.key(); QGesture *gesture2 = cit.value(); + if (gesture1->gestureType() != gesture2->gestureType()) + continue; // TODO: ugly, rewrite this. - if ((widget1 && widget2 && widget2->isAncestorOf(widget1)) || - (item1 && item2 && item2->isAncestorOf(item1))) { - groupedGestures[object2].removeOne(gesture2); - groupedGestures[object1].removeOne(gesture1); - conflictedGestures[object1].append(gesture1); - } else if ((widget1 && widget2 && widget1->isAncestorOf(widget2)) || - (item1 && item2 && item1->isAncestorOf(item2))) { - groupedGestures[object2].removeOne(gesture2); - groupedGestures[object1].removeOne(gesture1); - conflictedGestures[object2].append(gesture2); + if ((widget1 && widget2 && widget2->isAncestorOf(widget1))) { + groupedGestures[widget2].removeOne(gesture2); + groupedGestures[widget1].removeOne(gesture1); + conflictedGestures[widget1].append(gesture1); + } else if ((widget1 && widget2 && widget1->isAncestorOf(widget2))) { + groupedGestures[widget2].removeOne(gesture2); + groupedGestures[widget1].removeOne(gesture1); + conflictedGestures[widget2].append(gesture2); } } } diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 3ce5b86..a5e66cf 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -105,8 +105,8 @@ class CustomGestureRecognizer : public QGestureRecognizer public: CustomGestureRecognizer() { - CustomEvent::EventType = QEvent::registerEventType(); - eventsCounter = 0; + if (!CustomEvent::EventType) + CustomEvent::EventType = QEvent::registerEventType(); } QGesture* createGesture(QObject *) @@ -123,7 +123,6 @@ public: g->serial = e->serial; if (e->hasHotSpot) g->setHotSpot(e->hotSpot); - ++eventsCounter; if (g->serial >= CustomGesture::SerialFinishedThreshold) result |= QGestureRecognizer::GestureFinished; else if (g->serial >= CustomGesture::SerialStartedThreshold) @@ -143,9 +142,6 @@ public: g->serial = 0; QGestureRecognizer::reset(state); } - - int eventsCounter; - QString name; }; class GestureWidget : public QWidget @@ -272,6 +268,7 @@ private slots: void graphicsItemGesture(); void explicitGraphicsObjectTarget(); void gestureOverChildGraphicsItem(); + void multipleGestures(); }; tst_Gestures::tst_Gestures() @@ -785,5 +782,41 @@ void tst_Gestures::gestureOverChildGraphicsItem() QCOMPARE(item1->gestureOverrideEventsReceived, TotalGestureEventsCount); } +void tst_Gestures::multipleGestures() +{ + GestureWidget parent("parent"); + QVBoxLayout *l = new QVBoxLayout(&parent); + GestureWidget *child = new GestureWidget("child"); + l->addWidget(child); + + Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + + parent.grabGesture(CustomGesture::GestureType, Qt::WidgetWithChildrenGesture); + child->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); + + CustomEvent event; + // sending events that form a gesture to one widget, but they will be + // filtered by two different gesture recognizers and will generate two + // QGesture objects. Check that those gesture objects are delivered to + // different widgets properly. + sendCustomGesture(&event, child); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; + + QCOMPARE(child->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(child->gestureOverrideEventsReceived, 0); + QCOMPARE(child->events.all.size(), TotalGestureEventsCount); + for(int i = 0; i < child->events.all.size(); ++i) + QCOMPARE(child->events.all.at(i), SecondGesture); + + QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(parent.gestureOverrideEventsReceived, 0); + QCOMPARE(parent.events.all.size(), TotalGestureEventsCount); + for(int i = 0; i < child->events.all.size(); ++i) + QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 0b61c5e284462376afab15ac9189d759b859ec46 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 15 Oct 2009 21:00:24 +0200 Subject: Improving gesture event delivery for widgets. Reviewed-by: trustme --- src/gui/kernel/qapplication.cpp | 1 + src/gui/kernel/qevent.h | 2 + src/gui/kernel/qgesturemanager.cpp | 214 ++++++++++++++++++++++------------- src/gui/kernel/qgesturemanager_p.h | 12 +- tests/auto/gestures/tst_gestures.cpp | 184 ++++++++++++++++++++++++++++-- 5 files changed, 324 insertions(+), 89 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index aee8afc..af1c1c8 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4204,6 +4204,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) w = w->parentWidget(); } gestureEvent->m_accept = eventAccepted; + gestureEvent->gestures_ = allGestures; } else { res = d->notify_helper(receiver, e); } diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 6cba5fb..1ba2d41 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -856,6 +856,8 @@ public: private: QList gestures_; QWidget *widget_; + + friend class QApplication; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 8928d1c..f8e1e49 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -122,7 +122,7 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) Q_ASSERT(qobject_cast(object)); } - QWeakPointer state = + QGesture *state = objectGestures.value(QGestureManager::ObjectGesture(object, type)); if (!state) { QGestureRecognizer *recognizer = recognizers.value(type); @@ -130,21 +130,25 @@ QGesture *QGestureManager::getState(QObject *object, Qt::GestureType type) state = recognizer->createGesture(object); if (!state) return 0; - if (state.data()->gestureType() == Qt::CustomGesture) { + if (state->gestureType() == Qt::CustomGesture) { // if the recognizer didn't fill in the gesture type, then this // is a custom gesture with autogenerated it and we fill it. - state.data()->d_func()->gestureType = type; + state->d_func()->gestureType = type; +#if defined(GESTURE_DEBUG) + state->setObjectName(QString::number((int)type)); +#endif } objectGestures.insert(QGestureManager::ObjectGesture(object, type), state); - gestureToRecognizer[state.data()] = recognizer; + gestureToRecognizer[state] = recognizer; + gestureOwners[state] = object; } } - return state.data(); + return state; } bool QGestureManager::filterEventThroughContexts(const QMap &contexts, - QObject *receiver, QEvent *event) + QEvent *event) { QSet triggeredGestures; QSet finishedGestures; @@ -152,6 +156,9 @@ bool QGestureManager::filterEventThroughContexts(const QMap canceledGestures; QSet notGestures; + // TODO: sort contexts by the gesture type and check if one of the contexts + // is already active. + // filter the event through recognizers typedef QMap::const_iterator ContextIterator; for (ContextIterator cit = contexts.begin(), ce = contexts.end(); cit != ce; ++cit) { @@ -237,7 +244,7 @@ bool QGestureManager::filterEventThroughContexts(const QMapd_func()->state = Qt::GestureStarted; QSet undeliveredGestures; - deliverEvents(notStarted, receiver, &undeliveredGestures); + deliverEvents(notStarted, &undeliveredGestures); finishedGestures -= undeliveredGestures; } @@ -274,7 +281,7 @@ bool QGestureManager::filterEventThroughContexts(const QMap undeliveredGestures; deliverEvents(startedGestures+triggeredGestures+finishedGestures+canceledGestures, - receiver, &undeliveredGestures); + &undeliveredGestures); activeGestures -= undeliveredGestures; @@ -292,38 +299,47 @@ bool QGestureManager::filterEventThroughContexts(const QMap types; QMap contexts; QWidget *w = receiver; + typedef QMap::const_iterator ContextIterator; if (!w->d_func()->gestureContext.isEmpty()) { - typedef QMap::const_iterator ContextIterator; for(ContextIterator it = w->d_func()->gestureContext.begin(), e = w->d_func()->gestureContext.end(); it != e; ++it) { + types.insert(it.key()); contexts.insertMulti(w, it.key()); } } // find all gesture contexts for the widget tree - w = w->parentWidget(); + w = w->isWindow() ? 0 : w->parentWidget(); while (w) { - typedef QMap::const_iterator ContextIterator; for (ContextIterator it = w->d_func()->gestureContext.begin(), e = w->d_func()->gestureContext.end(); it != e; ++it) { - if (it.value() == Qt::WidgetWithChildrenGesture) - contexts.insertMulti(w, it.key()); + if (it.value() == Qt::WidgetWithChildrenGesture) { + if (!types.contains(it.key())) { + types.insert(it.key()); + contexts.insertMulti(w, it.key()); + } + } } + if (w->isWindow()) + break; w = w->parentWidget(); } - return filterEventThroughContexts(contexts , receiver, event); + return filterEventThroughContexts(contexts, event); } -bool QGestureManager::filterEvent(QGraphicsObject *graphicsObject, QEvent *event) +bool QGestureManager::filterEvent(QGraphicsObject *receiver, QEvent *event) { + QSet types; QMap contexts; - QGraphicsObject *item = graphicsObject; + QGraphicsObject *item = receiver; if (!item->QGraphicsItem::d_func()->gestureContext.isEmpty()) { typedef QMap::const_iterator ContextIterator; for(ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { + types.insert(it.key()); contexts.insertMulti(item, it.key()); } } @@ -334,55 +350,110 @@ bool QGestureManager::filterEvent(QGraphicsObject *graphicsObject, QEvent *event typedef QMap::const_iterator ContextIterator; for (ContextIterator it = item->QGraphicsItem::d_func()->gestureContext.begin(), e = item->QGraphicsItem::d_func()->gestureContext.end(); it != e; ++it) { - if (it.value() == Qt::ItemWithChildrenGesture) - contexts.insertMulti(item, it.key()); + if (it.value() == Qt::ItemWithChildrenGesture) { + if (!types.contains(it.key())) + contexts.insertMulti(item, it.key()); + } } item = item->parentObject(); } - return filterEventThroughContexts(contexts, graphicsObject, event); + return filterEventThroughContexts(contexts, event); } bool QGestureManager::filterEvent(QGesture *state, QEvent *event) { QMap contexts; contexts.insert(state, state->gestureType()); - return filterEventThroughContexts(contexts, 0, event); + return filterEventThroughContexts(contexts, event); +} + +void QGestureManager::getGestureTargets(const QSet &gestures, + QMap > *conflicts, + QMap > *normal) +{ + typedef QHash > GestureByTypes; + GestureByTypes gestureByTypes; + + // sort gestures by types + foreach (QGesture *gesture, gestures) { + QWidget *receiver = gestureTargets.value(gesture, 0); + Q_ASSERT(receiver); + gestureByTypes[gesture->gestureType()].insert(receiver, gesture); + } + + // for each gesture type + foreach (Qt::GestureType type, gestureByTypes.keys()) { + QHash gestures = gestureByTypes.value(type); + foreach (QWidget *widget, gestures.keys()) { + QWidget *w = widget->parentWidget(); + while (w) { + QMap::const_iterator it + = w->d_func()->gestureContext.find(type); + if (it != w->d_func()->gestureContext.end()) { + // i.e. 'w' listens to gesture 'type' + Qt::GestureContext context = it.value(); + if (context == Qt::WidgetWithChildrenGesture && w != widget) { + // conflicting gesture! + (*conflicts)[widget].append(gestures[widget]); + break; + } + } + if (w->isWindow()) { + w = 0; + break; + } + w = w->parentWidget(); + } + if (!w) + (*normal)[widget].append(gestures[widget]); + } + } } -void QGestureManager::deliverEvents(const QSet &gestures, - QObject *lastReceiver, +void QGestureManager::deliverEvents(const QSet &gestures, QSet *undeliveredGestures) { if (gestures.isEmpty()) return; - // group gestures by widgets - typedef QMap > GesturesPerReceiver; - GesturesPerReceiver groupedGestures; - // for conflicted gestures the key is always the innermost widget (i.e. the child) - GesturesPerReceiver conflictedGestures; - typedef QMultiHash WidgetMultiGestures; - WidgetMultiGestures widgetMultiGestures; + typedef QMap > GesturesPerWidget; + GesturesPerWidget conflictedGestures; + GesturesPerWidget normalStartedGestures; - foreach (QGesture *gesture, gestures) { - QObject *target = gestureTargets.value(gesture, 0); + QSet startedGestures; + // first figure out the initial receivers of gestures + for (QSet::const_iterator it = gestures.begin(), + e = gestures.end(); it != e; ++it) { + QGesture *gesture = *it; + QWidget *target = gestureTargets.value(gesture, 0); if (!target) { + // the gesture has just started and doesn't have a target yet. Q_ASSERT(gesture->state() == Qt::GestureStarted); if (gesture->hasHotSpot()) { - // guess the target using the hotspot of the gesture + // guess the target widget using the hotspot of the gesture QPoint pt = gesture->hotSpot().toPoint(); if (QWidget *w = qApp->topLevelAt(pt)) { target = w->childAt(w->mapFromGlobal(pt)); } + } else { + // or use the context of the gesture + QObject *context = gestureOwners.value(gesture, 0); + if (context->isWidgetType()) + target = static_cast(context); } - if (!target) - target = lastReceiver; + if (target) + gestureTargets.insert(gesture, target); } + + Qt::GestureType gestureType = gesture->gestureType(); + Q_ASSERT(gestureType != Qt::CustomGesture); + if (target) { - gestureTargets.insert(gesture, target); - if (target->isWidgetType()) - widgetMultiGestures.insert(static_cast(target), gesture); - groupedGestures[target].append(gesture); + if (gesture->state() == Qt::GestureStarted) { + startedGestures.insert(gesture); + } else { + normalStartedGestures[target].append(gesture); + } } else { qWarning() << "QGestureManager::deliverEvent: could not find the target for gesture" << gesture->gestureType(); @@ -390,56 +461,44 @@ void QGestureManager::deliverEvents(const QSet &gestures, } } - typedef WidgetMultiGestures::const_iterator WidgetMultiGesturesIterator; - for (WidgetMultiGesturesIterator it = widgetMultiGestures.begin(), - e = widgetMultiGestures.end(); it != e; ++it) { - QWidget *widget1 = it.key(); - QGesture *gesture1 = it.value(); - WidgetMultiGesturesIterator cit = it; - for (++cit; cit != e; ++cit) { - QWidget *widget2 = cit.key(); - QGesture *gesture2 = cit.value(); - if (gesture1->gestureType() != gesture2->gestureType()) - continue; - // TODO: ugly, rewrite this. - if ((widget1 && widget2 && widget2->isAncestorOf(widget1))) { - groupedGestures[widget2].removeOne(gesture2); - groupedGestures[widget1].removeOne(gesture1); - conflictedGestures[widget1].append(gesture1); - } else if ((widget1 && widget2 && widget1->isAncestorOf(widget2))) { - groupedGestures[widget2].removeOne(gesture2); - groupedGestures[widget1].removeOne(gesture1); - conflictedGestures[widget2].append(gesture2); - } - } - } - - DEBUG() << "deliverEvents: conflicted =" << conflictedGestures.values() - << " grouped =" << groupedGestures.values(); + getGestureTargets(startedGestures, &conflictedGestures, &normalStartedGestures); + DEBUG() << "QGestureManager::deliverEvents:" + << "\nstarted: " << startedGestures + << "\nconflicted: " << conflictedGestures + << "\nnormal: " << normalStartedGestures + << "\n"; // if there are conflicting gestures, send the GestureOverride event - for (GesturesPerReceiver::const_iterator it = conflictedGestures.begin(), + for (GesturesPerWidget::const_iterator it = conflictedGestures.begin(), e = conflictedGestures.end(); it != e; ++it) { + QWidget *receiver = it.key(); + QList gestures = it.value(); DEBUG() << "QGestureManager::deliverEvents: sending GestureOverride to" - << it.key() - << " gestures:" << it.value(); - QGestureEvent event(it.value()); + << receiver + << "gestures:" << gestures; + QGestureEvent event(gestures); event.t = QEvent::GestureOverride; event.ignore(); - QApplication::sendEvent(it.key(), &event); + QApplication::sendEvent(receiver, &event); if (!event.isAccepted()) { - // nobody accepted the GestureOverride, put it back to deliver to - // the closest context (i.e. to the inner-most widget). - DEBUG() <<" override was not accepted"; - groupedGestures[it.key()].append(it.value()); + // nobody accepted the GestureOverride, put gestures that were not + // accepted back to deliver as usual + QList &gestures = normalStartedGestures[receiver]; + foreach(QGesture *gesture, event.allGestures()) { + if (!event.isAccepted(gesture)) { + DEBUG() << "override event wasn't accepted. putting back:" << gesture; + gestures.append(gesture); + } + } } } - for (GesturesPerReceiver::const_iterator it = groupedGestures.begin(), - e = groupedGestures.end(); it != e; ++it) { + // delivering gestures that are not in conflicted state + for (GesturesPerWidget::const_iterator it = normalStartedGestures.begin(), + e = normalStartedGestures.end(); it != e; ++it) { if (!it.value().isEmpty()) { DEBUG() << "QGestureManager::deliverEvents: sending to" << it.key() - << " gestures:" << it.value(); + << "gestures:" << it.value(); QGestureEvent event(it.value()); QApplication::sendEvent(it.key(), &event); } @@ -457,7 +516,8 @@ void QGestureManager::timerEvent(QTimerEvent *event) timer.stop(); QGesture *gesture = it.key(); it = maybeGestures.erase(it); - DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:" << gesture; + DEBUG() << "QGestureManager::timerEvent: gesture stopped due to timeout:" + << gesture; QGestureRecognizer *recognizer = gestureToRecognizer.value(gesture, 0); if (recognizer) recognizer->reset(gesture); diff --git a/src/gui/kernel/qgesturemanager_p.h b/src/gui/kernel/qgesturemanager_p.h index 5fc02ab..f0e7225 100644 --- a/src/gui/kernel/qgesturemanager_p.h +++ b/src/gui/kernel/qgesturemanager_p.h @@ -82,7 +82,7 @@ public: protected: void timerEvent(QTimerEvent *event); bool filterEventThroughContexts(const QMap &contexts, - QObject *receiver, QEvent *event); + QEvent *event); private: QMultiMap recognizers; @@ -114,16 +114,20 @@ private: } }; - QMap > objectGestures; + QMap objectGestures; QMap gestureToRecognizer; + QHash gestureOwners; - QHash gestureTargets; + QHash gestureTargets; int lastCustomGestureId; QGesture *getState(QObject *widget, Qt::GestureType gesture); - void deliverEvents(const QSet &gestures, QObject *lastReceiver, + void deliverEvents(const QSet &gestures, QSet *undeliveredGestures); + void getGestureTargets(const QSet &gestures, + QMap > *conflicts, + QMap > *normal); }; QT_END_NAMESPACE diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index a5e66cf..4d072bc 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -148,7 +148,8 @@ class GestureWidget : public QWidget { Q_OBJECT public: - GestureWidget(const char *name = 0) + GestureWidget(const char *name = 0, QWidget *parent = 0) + : QWidget(parent) { if (name) setObjectName(QLatin1String(name)); @@ -186,14 +187,18 @@ public: } events, overrideEvents; bool acceptGestureOverride; + QSet ignoredGestures; protected: bool event(QEvent *event) { Events *eventsPtr = 0; if (event->type() == QEvent::Gesture) { + QGestureEvent *e = static_cast(event); ++gestureEventsReceived; eventsPtr = &events; + foreach(Qt::GestureType type, ignoredGestures) + e->ignore(e->gesture(type)); } else if (event->type() == QEvent::GestureOverride) { ++gestureOverrideEventsReceived; eventsPtr = &overrideEvents; @@ -268,7 +273,9 @@ private slots: void graphicsItemGesture(); void explicitGraphicsObjectTarget(); void gestureOverChildGraphicsItem(); - void multipleGestures(); + void twoGesturesOnDifferentLevel(); + void multipleGesturesInTree(); + void multipleGesturesInComplexTree(); }; tst_Gestures::tst_Gestures() @@ -442,7 +449,7 @@ void tst_Gestures::conflictingGestures() CustomEvent event; sendCustomGesture(&event, child); - QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount); + QCOMPARE(child->gestureOverrideEventsReceived, 1); QCOMPARE(child->gestureEventsReceived, 0); QCOMPARE(parent.gestureOverrideEventsReceived, 0); QCOMPARE(parent.gestureEventsReceived, 0); @@ -457,9 +464,9 @@ void tst_Gestures::conflictingGestures() // sending events to the child and making sure there is no conflict sendCustomGesture(&event, child); - QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount); + QCOMPARE(child->gestureOverrideEventsReceived, 1); QCOMPARE(child->gestureEventsReceived, 0); - QCOMPARE(parent.gestureOverrideEventsReceived, TotalGestureEventsCount); + QCOMPARE(parent.gestureOverrideEventsReceived, 1); QCOMPARE(parent.gestureEventsReceived, 0); parent.reset(); @@ -472,9 +479,9 @@ void tst_Gestures::conflictingGestures() // sending events to the child and making sure there is no conflict sendCustomGesture(&event, child); - QCOMPARE(child->gestureOverrideEventsReceived, TotalGestureEventsCount); + QCOMPARE(child->gestureOverrideEventsReceived, 1); QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); - QCOMPARE(parent.gestureOverrideEventsReceived, TotalGestureEventsCount); + QCOMPARE(parent.gestureOverrideEventsReceived, 1); QCOMPARE(parent.gestureEventsReceived, 0); } @@ -782,7 +789,7 @@ void tst_Gestures::gestureOverChildGraphicsItem() QCOMPARE(item1->gestureOverrideEventsReceived, TotalGestureEventsCount); } -void tst_Gestures::multipleGestures() +void tst_Gestures::twoGesturesOnDifferentLevel() { GestureWidget parent("parent"); QVBoxLayout *l = new QVBoxLayout(&parent); @@ -818,5 +825,166 @@ void tst_Gestures::multipleGestures() QCOMPARE(parent.events.all.at(i), CustomGesture::GestureType); } +void tst_Gestures::multipleGesturesInTree() +{ + GestureWidget a("A"); + GestureWidget *A = &a; + GestureWidget *B = new GestureWidget("B", A); + GestureWidget *C = new GestureWidget("C", B); + GestureWidget *D = new GestureWidget("D", C); + + Qt::GestureType FirstGesture = CustomGesture::GestureType; + Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + + A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1 3] + A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | + B->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); // B [ 2 3] + B->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | + C->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // C [1 2 3] + C->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); // | + C->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // D [1 3] + D->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); + D->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); + + // make sure all widgets ignore events, so they get propagated. + A->ignoredGestures << FirstGesture << ThirdGesture; + B->ignoredGestures << SecondGesture << ThirdGesture; + C->ignoredGestures << FirstGesture << SecondGesture << ThirdGesture; + D->ignoredGestures << FirstGesture << ThirdGesture; + + CustomEvent event; + sendCustomGesture(&event, D); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + + // gesture override events + QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1); + QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0); + QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1); + + QCOMPARE(C->overrideEvents.all.count(FirstGesture), 1); + QCOMPARE(C->overrideEvents.all.count(SecondGesture), 1); + QCOMPARE(C->overrideEvents.all.count(ThirdGesture), 1); + + QCOMPARE(B->overrideEvents.all.count(FirstGesture), 0); + QCOMPARE(B->overrideEvents.all.count(SecondGesture), 1); + QCOMPARE(B->overrideEvents.all.count(ThirdGesture), 1); + + QCOMPARE(A->overrideEvents.all.count(FirstGesture), 1); + QCOMPARE(A->overrideEvents.all.count(SecondGesture), 0); + QCOMPARE(A->overrideEvents.all.count(ThirdGesture), 1); + + // normal gesture events + QCOMPARE(D->events.all.count(FirstGesture), TotalGestureEventsCount); + QCOMPARE(D->events.all.count(SecondGesture), 0); + QCOMPARE(D->events.all.count(ThirdGesture), TotalGestureEventsCount); + + QCOMPARE(C->events.all.count(FirstGesture), TotalGestureEventsCount); + QCOMPARE(C->events.all.count(SecondGesture), TotalGestureEventsCount); + QCOMPARE(C->events.all.count(ThirdGesture), TotalGestureEventsCount); + + QCOMPARE(B->events.all.count(FirstGesture), 0); + QCOMPARE(B->events.all.count(SecondGesture), TotalGestureEventsCount); + QCOMPARE(B->events.all.count(ThirdGesture), TotalGestureEventsCount); + + QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount); + QCOMPARE(A->events.all.count(SecondGesture), 0); + QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount); +} + +void tst_Gestures::multipleGesturesInComplexTree() +{ + GestureWidget a("A"); + GestureWidget *A = &a; + GestureWidget *B = new GestureWidget("B", A); + GestureWidget *C = new GestureWidget("C", B); + GestureWidget *D = new GestureWidget("D", C); + + Qt::GestureType FirstGesture = CustomGesture::GestureType; + Qt::GestureType SecondGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType ThirdGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType FourthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType FifthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SixthGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + Qt::GestureType SeventhGesture = qApp->registerGestureRecognizer(new CustomGestureRecognizer); + + A->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // A [1,3,4] + A->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // | + A->grabGesture(FourthGesture, Qt::WidgetWithChildrenGesture); // B [2,3,5] + B->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); // | + B->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); // C [1,2,3,6] + B->grabGesture(FifthGesture, Qt::WidgetWithChildrenGesture); // | + C->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); // D [1,3,7] + C->grabGesture(SecondGesture, Qt::WidgetWithChildrenGesture); + C->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); + C->grabGesture(SixthGesture, Qt::WidgetWithChildrenGesture); + D->grabGesture(FirstGesture, Qt::WidgetWithChildrenGesture); + D->grabGesture(ThirdGesture, Qt::WidgetWithChildrenGesture); + D->grabGesture(SeventhGesture, Qt::WidgetWithChildrenGesture); + + // make sure all widgets ignore events, so they get propagated. + QSet allGestureTypes; + allGestureTypes << FirstGesture << SecondGesture << ThirdGesture + << FourthGesture << FifthGesture << SixthGesture << SeventhGesture; + A->ignoredGestures = B->ignoredGestures = allGestureTypes; + C->ignoredGestures = D->ignoredGestures = allGestureTypes; + + CustomEvent event; + sendCustomGesture(&event, D); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + + // gesture override events + QCOMPARE(D->overrideEvents.all.count(FirstGesture), 1); + QCOMPARE(D->overrideEvents.all.count(SecondGesture), 0); + QCOMPARE(D->overrideEvents.all.count(ThirdGesture), 1); + + QCOMPARE(C->overrideEvents.all.count(FirstGesture), 1); + QCOMPARE(C->overrideEvents.all.count(SecondGesture), 1); + QCOMPARE(C->overrideEvents.all.count(ThirdGesture), 1); + + QCOMPARE(B->overrideEvents.all.count(FirstGesture), 0); + QCOMPARE(B->overrideEvents.all.count(SecondGesture), 1); + QCOMPARE(B->overrideEvents.all.count(ThirdGesture), 1); + + QCOMPARE(A->overrideEvents.all.count(FirstGesture), 1); + QCOMPARE(A->overrideEvents.all.count(SecondGesture), 0); + QCOMPARE(A->overrideEvents.all.count(ThirdGesture), 1); + + // normal gesture events + QCOMPARE(D->events.all.count(FirstGesture), TotalGestureEventsCount); + QCOMPARE(D->events.all.count(SecondGesture), 0); + QCOMPARE(D->events.all.count(ThirdGesture), TotalGestureEventsCount); + QCOMPARE(D->events.all.count(FourthGesture), 0); + QCOMPARE(D->events.all.count(FifthGesture), 0); + QCOMPARE(D->events.all.count(SixthGesture), 0); + QCOMPARE(D->events.all.count(SeventhGesture), TotalGestureEventsCount); + + QCOMPARE(C->events.all.count(FirstGesture), TotalGestureEventsCount); + QCOMPARE(C->events.all.count(SecondGesture), TotalGestureEventsCount); + QCOMPARE(C->events.all.count(ThirdGesture), TotalGestureEventsCount); + QCOMPARE(C->events.all.count(FourthGesture), 0); + QCOMPARE(C->events.all.count(FifthGesture), 0); + QCOMPARE(C->events.all.count(SixthGesture), TotalGestureEventsCount); + QCOMPARE(C->events.all.count(SeventhGesture), 0); + + QCOMPARE(B->events.all.count(FirstGesture), 0); + QCOMPARE(B->events.all.count(SecondGesture), TotalGestureEventsCount); + QCOMPARE(B->events.all.count(ThirdGesture), TotalGestureEventsCount); + QCOMPARE(B->events.all.count(FourthGesture), 0); + QCOMPARE(B->events.all.count(FifthGesture), TotalGestureEventsCount); + QCOMPARE(B->events.all.count(SixthGesture), 0); + QCOMPARE(B->events.all.count(SeventhGesture), 0); + + QCOMPARE(A->events.all.count(FirstGesture), TotalGestureEventsCount); + QCOMPARE(A->events.all.count(SecondGesture), 0); + QCOMPARE(A->events.all.count(ThirdGesture), TotalGestureEventsCount); + QCOMPARE(A->events.all.count(FourthGesture), TotalGestureEventsCount); + QCOMPARE(A->events.all.count(FifthGesture), 0); + QCOMPARE(A->events.all.count(SixthGesture), 0); + QCOMPARE(A->events.all.count(SeventhGesture), 0); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 0c7254e1c5a20450495afe80c1ad5246e5e48314 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 19 Oct 2009 14:20:02 +0200 Subject: Improvements for gesture event delivery When delivering GestureOverride events by default both the event and individual gestures will be ignored. We also store the acceptance state of individual gesture in the event and not in the gesture object, along with its target. Reviewed-by: Thomas Zander --- src/gui/kernel/qapplication.cpp | 32 ++++++++--------- src/gui/kernel/qevent.cpp | 48 ++++++++++++++++++++------ src/gui/kernel/qevent.h | 7 ++-- src/gui/kernel/qevent_p.h | 14 ++++++++ src/gui/kernel/qgesture_p.h | 3 +- src/gui/kernel/qgesturemanager.cpp | 28 ++++++++++----- tests/auto/gestures/tst_gestures.cpp | 66 ++++++++++++++++++++++++++++++++++-- 7 files changed, 156 insertions(+), 42 deletions(-) diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index af1c1c8..7c38d4b 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -4170,41 +4170,41 @@ bool QApplication::notify(QObject *receiver, QEvent *e) if (wd->gestureContext.contains(type)) { allGestures.removeAt(i); gestures.append(g); - gestureEvent->setAccepted(g, false); } else { ++i; } } - if (!gestures.isEmpty()) { + if (!gestures.isEmpty()) { // we have gestures for this w QGestureEvent ge(gestures); ge.t = gestureEvent->t; ge.spont = gestureEvent->spont; ge.m_accept = wasAccepted; + ge.d_func()->accepted = gestureEvent->d_func()->accepted; res = d->notify_helper(w, &ge); gestureEvent->spont = false; eventAccepted = ge.isAccepted(); - if (res && eventAccepted && allGestures.isEmpty()) - break; - if (!eventAccepted) { - // ### two ways to ignore the event/gesture - - // if the whole event wasn't accepted, put back those - // gestures that were not accepted. - for (int i = 0; i < gestures.size(); ++i) { - QGesture *g = gestures.at(i); - if (!ge.isAccepted(g)) - allGestures.append(g); + for (int i = 0; i < gestures.size(); ++i) { + QGesture *g = gestures.at(i); + if ((res && eventAccepted) || (!eventAccepted && ge.isAccepted(g))) { + // if the gesture was accepted, mark the target widget for it + gestureEvent->d_func()->targetWidgets[g->gestureType()] = w; + gestureEvent->setAccepted(g, true); + } else if (!eventAccepted && !ge.isAccepted(g)) { + // if the gesture was explicitly ignored by the application, + // put it back so a parent can get it + allGestures.append(g); } } } - if (allGestures.isEmpty()) + if (allGestures.isEmpty()) // everything delivered break; if (w->isWindow()) break; w = w->parentWidget(); } - gestureEvent->m_accept = eventAccepted; - gestureEvent->gestures_ = allGestures; + foreach (QGesture *g, allGestures) + gestureEvent->setAccepted(g, false); + gestureEvent->m_accept = false; // to make sure we check individual gestures } else { res = d->notify_helper(receiver, e); } diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index e49de02..1c6a820 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4223,8 +4223,17 @@ QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::T Creates new QGestureEvent containing a list of \a gestures. */ QGestureEvent::QGestureEvent(const QList &gestures) - : QEvent(QEvent::Gesture), gestures_(gestures) + : QEvent(QEvent::Gesture) { + d = reinterpret_cast(new QGestureEventPrivate(gestures)); +} + +/*! + Destroys QGestureEvent. +*/ +QGestureEvent::~QGestureEvent() +{ + delete reinterpret_cast(d); } /*! @@ -4232,7 +4241,7 @@ QGestureEvent::QGestureEvent(const QList &gestures) */ QList QGestureEvent::allGestures() const { - return gestures_; + return d_func()->gestures; } /*! @@ -4240,9 +4249,10 @@ QList QGestureEvent::allGestures() const */ QGesture *QGestureEvent::gesture(Qt::GestureType type) const { - for(int i = 0; i < gestures_.size(); ++i) - if (gestures_.at(i)->gestureType() == type) - return gestures_.at(i); + const QGestureEventPrivate *d = d_func(); + for(int i = 0; i < d->gestures.size(); ++i) + if (d->gestures.at(i)->gestureType() == type) + return d->gestures.at(i); return 0; } @@ -4251,7 +4261,7 @@ QGesture *QGestureEvent::gesture(Qt::GestureType type) const */ QList QGestureEvent::activeGestures() const { - return gestures_; + return d_func()->gestures; } /*! @@ -4259,7 +4269,7 @@ QList QGestureEvent::activeGestures() const */ QList QGestureEvent::canceledGestures() const { - return gestures_; + return d_func()->gestures; } /*! @@ -4279,7 +4289,7 @@ void QGestureEvent::setAccepted(QGesture *gesture, bool value) { setAccepted(false); if (gesture) - gesture->d_func()->accept = value; + d_func()->accepted[gesture->gestureType()] = value; } /*! @@ -4315,7 +4325,7 @@ void QGestureEvent::ignore(QGesture *gesture) */ bool QGestureEvent::isAccepted(QGesture *gesture) const { - return gesture ? gesture->d_func()->accept : false; + return gesture ? d_func()->accepted.value(gesture->gestureType(), true) : false; } /*! @@ -4323,7 +4333,7 @@ bool QGestureEvent::isAccepted(QGesture *gesture) const */ void QGestureEvent::setWidget(QWidget *widget) { - widget_ = widget; + d_func()->widget = widget; } /*! @@ -4331,7 +4341,23 @@ void QGestureEvent::setWidget(QWidget *widget) */ QWidget *QGestureEvent::widget() const { - return widget_; + return d_func()->widget; +} + +/*! + \internal +*/ +QGestureEventPrivate *QGestureEvent::d_func() +{ + return reinterpret_cast(d); +} + +/*! + \internal +*/ +const QGestureEventPrivate *QGestureEvent::d_func() const +{ + return reinterpret_cast(d); } #ifdef Q_NO_USING_KEYWORD diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 1ba2d41..5eefc2d 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -820,10 +820,12 @@ protected: }; class QGesture; +class QGestureEventPrivate; class Q_GUI_EXPORT QGestureEvent : public QEvent { public: QGestureEvent(const QList &gestures); + ~QGestureEvent(); QList allGestures() const; QGesture *gesture(Qt::GestureType type) const; @@ -854,10 +856,11 @@ public: QWidget *widget() const; private: - QList gestures_; - QWidget *widget_; + QGestureEventPrivate *d_func(); + const QGestureEventPrivate *d_func() const; friend class QApplication; + friend class QGestureManager; }; QT_END_NAMESPACE diff --git a/src/gui/kernel/qevent_p.h b/src/gui/kernel/qevent_p.h index c7a4975..6e6ab01 100644 --- a/src/gui/kernel/qevent_p.h +++ b/src/gui/kernel/qevent_p.h @@ -150,6 +150,20 @@ public: #endif }; +class QGestureEventPrivate +{ +public: + inline QGestureEventPrivate(const QList &list) + : gestures(list), widget(0) + { + } + + QList gestures; + QWidget *widget; + QMap accepted; + QMap targetWidgets; +}; + QT_END_NAMESPACE #endif // QEVENT_P_H diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index 7f69a4e..10887f6 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -68,7 +68,7 @@ class QGesturePrivate : public QObjectPrivate public: QGesturePrivate() : gestureType(Qt::CustomGesture), state(Qt::NoGesture), isHotSpotSet(false), - targetObject(0), accept(true) + targetObject(0) { } @@ -77,7 +77,6 @@ public: QPointF hotSpot; bool isHotSpotSet; QObject *targetObject; - bool accept; }; class QPanGesturePrivate : public QGesturePrivate diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index f8e1e49..b4913f0 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -44,6 +44,7 @@ #include "private/qwidget_p.h" #include "private/qgesture_p.h" #include "private/qgraphicsitem_p.h" +#include "private/qevent_p.h" #include "qgesture.h" #include "qevent.h" #include "qgraphicsitem.h" @@ -478,17 +479,26 @@ void QGestureManager::deliverEvents(const QSet &gestures, << "gestures:" << gestures; QGestureEvent event(gestures); event.t = QEvent::GestureOverride; + // mark event and individual gestures as ignored event.ignore(); + foreach(QGesture *g, gestures) + event.setAccepted(g, false); + QApplication::sendEvent(receiver, &event); - if (!event.isAccepted()) { - // nobody accepted the GestureOverride, put gestures that were not - // accepted back to deliver as usual - QList &gestures = normalStartedGestures[receiver]; - foreach(QGesture *gesture, event.allGestures()) { - if (!event.isAccepted(gesture)) { - DEBUG() << "override event wasn't accepted. putting back:" << gesture; - gestures.append(gesture); - } + bool eventAccepted = event.isAccepted(); + foreach(QGesture *gesture, event.allGestures()) { + if (eventAccepted || event.isAccepted(gesture)) { + QWidget *w = event.d_func()->targetWidgets.value(gesture->gestureType(), 0); + Q_ASSERT(w); + DEBUG() << "override event: gesture was accepted:" << gesture << w; + QList &gestures = normalStartedGestures[w]; + gestures.append(gesture); + // override the target + gestureTargets[gesture] = w; + } else { + DEBUG() << "override event: gesture wasn't accepted. putting back:" << gesture; + QList &gestures = normalStartedGestures[receiver]; + gestures.append(gesture); } } } diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 4d072bc..28dd40c 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -144,6 +144,49 @@ public: } }; +// same as CustomGestureRecognizer but triggers early without the maybe state +class CustomContinuousGestureRecognizer : public QGestureRecognizer +{ +public: + CustomContinuousGestureRecognizer() + { + if (!CustomEvent::EventType) + CustomEvent::EventType = QEvent::registerEventType(); + } + + QGesture* createGesture(QObject *) + { + return new CustomGesture; + } + + QGestureRecognizer::Result filterEvent(QGesture *state, QObject*, QEvent *event) + { + if (event->type() == CustomEvent::EventType) { + QGestureRecognizer::Result result = QGestureRecognizer::ConsumeEventHint; + CustomGesture *g = static_cast(state); + CustomEvent *e = static_cast(event); + g->serial = e->serial; + if (e->hasHotSpot) + g->setHotSpot(e->hotSpot); + if (g->serial >= CustomGesture::SerialFinishedThreshold) + result |= QGestureRecognizer::GestureFinished; + else if (g->serial >= CustomGesture::SerialMaybeThreshold) + result |= QGestureRecognizer::GestureTriggered; + else + result = QGestureRecognizer::NotGesture; + return result; + } + return QGestureRecognizer::Ignore; + } + + void reset(QGesture *state) + { + CustomGesture *g = static_cast(state); + g->serial = 0; + QGestureRecognizer::reset(state); + } +}; + class GestureWidget : public QWidget { Q_OBJECT @@ -163,6 +206,7 @@ public: gestureOverrideEventsReceived = 0; events.clear(); overrideEvents.clear(); + ignoredGestures.clear(); } int customEventsReceived; @@ -450,7 +494,7 @@ void tst_Gestures::conflictingGestures() sendCustomGesture(&event, child); QCOMPARE(child->gestureOverrideEventsReceived, 1); - QCOMPARE(child->gestureEventsReceived, 0); + QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); QCOMPARE(parent.gestureOverrideEventsReceived, 0); QCOMPARE(parent.gestureEventsReceived, 0); @@ -467,7 +511,7 @@ void tst_Gestures::conflictingGestures() QCOMPARE(child->gestureOverrideEventsReceived, 1); QCOMPARE(child->gestureEventsReceived, 0); QCOMPARE(parent.gestureOverrideEventsReceived, 1); - QCOMPARE(parent.gestureEventsReceived, 0); + QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); parent.reset(); child->reset(); @@ -475,6 +519,7 @@ void tst_Gestures::conflictingGestures() // nobody accepts the override, we will send normal events to the closest context (to the child) parent.acceptGestureOverride = false; child->acceptGestureOverride = false; + child->ignoredGestures << CustomGesture::GestureType; // sending events to the child and making sure there is no conflict sendCustomGesture(&event, child); @@ -482,6 +527,23 @@ void tst_Gestures::conflictingGestures() QCOMPARE(child->gestureOverrideEventsReceived, 1); QCOMPARE(child->gestureEventsReceived, TotalGestureEventsCount); QCOMPARE(parent.gestureOverrideEventsReceived, 1); + QCOMPARE(parent.gestureEventsReceived, TotalGestureEventsCount); + + parent.reset(); + child->reset(); + + Qt::GestureType ContinuousGesture = qApp->registerGestureRecognizer(new CustomContinuousGestureRecognizer); + static const int ContinuousGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; + child->grabGesture(ContinuousGesture); + // child accepts override. And it also receives another custom gesture. + parent.acceptGestureOverride = false; + child->acceptGestureOverride = true; + sendCustomGesture(&event, child); + + QCOMPARE(child->gestureOverrideEventsReceived, 1); + QVERIFY(child->gestureEventsReceived > TotalGestureEventsCount); + QCOMPARE(child->events.all.count(), TotalGestureEventsCount + ContinuousGestureEventsCount); + QCOMPARE(parent.gestureOverrideEventsReceived, 0); QCOMPARE(parent.gestureEventsReceived, 0); } -- cgit v0.12 From 75599a71e957cae29ddd4d3df9e89d9d4edc0b3d Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Mon, 19 Oct 2009 17:21:59 +0200 Subject: Fix for the gestures autotest. Reviewed-by: trustme --- src/gui/kernel/qgesturemanager.cpp | 3 ++- tests/auto/gestures/tst_gestures.cpp | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index b4913f0..6f1aec4 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -456,8 +456,9 @@ void QGestureManager::deliverEvents(const QSet &gestures, normalStartedGestures[target].append(gesture); } } else { - qWarning() << "QGestureManager::deliverEvent: could not find the target for gesture" + DEBUG() << "QGestureManager::deliverEvent: could not find the target for gesture" << gesture->gestureType(); + qWarning("QGestureManager::deliverEvent: could not find the target for gesture"); undeliveredGestures->insert(gesture); } } diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 28dd40c..0c09265 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -703,18 +703,16 @@ void tst_Gestures::graphicsItemGesture() static const int TotalCustomEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialMaybeThreshold + 1; CustomEvent event; + // gesture without hotspot should not be delivered to items in the view + QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); + QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); + QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); + QTest::ignoreMessage(QtWarningMsg, "QGestureManager::deliverEvent: could not find the target for gesture"); sendCustomGesture(&event, item, &scene); QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); - QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item->gestureEventsReceived, 0); QCOMPARE(item->gestureOverrideEventsReceived, 0); - QCOMPARE(item->events.all.size(), TotalGestureEventsCount); - for(int i = 0; i < item->events.all.size(); ++i) - QCOMPARE(item->events.all.at(i), CustomGesture::GestureType); - QCOMPARE(item->events.started.size(), 1); - QCOMPARE(item->events.updated.size(), TotalGestureEventsCount - 2); - QCOMPARE(item->events.finished.size(), 1); - QCOMPARE(item->events.canceled.size(), 0); item->reset(); -- cgit v0.12 From 0f1f53414de3e7d1b62149ee42a334c6f2d01f78 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Mon, 19 Oct 2009 19:11:19 +0200 Subject: Add QGestureEvent::mapToScene for better graphicsView integration --- src/gui/kernel/qevent.cpp | 18 ++++++++++++++++++ src/gui/kernel/qevent.h | 2 ++ src/gui/kernel/qgesture.cpp | 4 ++++ tests/auto/gestures/tst_gestures.cpp | 26 ++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 1c6a820..ef74f06 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -45,6 +45,7 @@ #include "private/qapplication_p.h" #include "private/qkeysequence_p.h" #include "qwidget.h" +#include "qgraphicsview.h" #include "qdebug.h" #include "qmime.h" #include "qdnd_p.h" @@ -4345,6 +4346,23 @@ QWidget *QGestureEvent::widget() const } /*! + Returns the scene-local coordinates if the \a gesturePoint is inside a graphics view. + + \sa QPointF::isNull(). +*/ +QPointF QGestureEvent::mapToScene(const QPointF &gesturePoint) const +{ + QWidget *w = widget(); + if (w) // we get the viewport as widget, not the graphics view + w = w->parentWidget(); + QGraphicsView *view = qobject_cast(w); + if (view) { + return view->mapToScene(view->mapFromGlobal(gesturePoint.toPoint())); + } + return QPointF(); +} + +/*! \internal */ QGestureEventPrivate *QGestureEvent::d_func() diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 5eefc2d..249c45a 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -855,6 +855,8 @@ public: void setWidget(QWidget *widget); QWidget *widget() const; + QPointF mapToScene(const QPointF &gesturePoint) const; + private: QGestureEventPrivate *d_func(); const QGestureEventPrivate *d_func() const; diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index e48fd8e..f044c09 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -129,6 +129,10 @@ QGesture::~QGesture() \brief The point that is used to find the receiver for the gesture event. + The hot-spot is a point in the global coordinate system, use + QWidget::mapFromGlobal() or QGestureEvent::mapToScene() to get a + local hot-spot. + If the hot-spot is not set, the targetObject is used as the receiver of the gesture event. */ diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 0c09265..09da7d6 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -320,6 +320,7 @@ private slots: void twoGesturesOnDifferentLevel(); void multipleGesturesInTree(); void multipleGesturesInComplexTree(); + void testMapToScene(); }; tst_Gestures::tst_Gestures() @@ -1046,5 +1047,30 @@ void tst_Gestures::multipleGesturesInComplexTree() QCOMPARE(A->events.all.count(SeventhGesture), 0); } +void tst_Gestures::testMapToScene() +{ + QGesture gesture; + QList list; + list << &gesture; + QGestureEvent event(list); + QCOMPARE(event.mapToScene(gesture.hotSpot()), QPointF()); // not set, can't do much + + QGraphicsScene scene; + QGraphicsView view(&scene); + + GestureItem *item0 = new GestureItem; + scene.addItem(item0); + item0->setPos(14, 16); + + view.show(); // need to show to give it a global coordinate + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); + + QPoint origin = view.mapToGlobal(QPoint()); + event.setWidget(view.viewport()); + + QCOMPARE(event.mapToScene(origin + QPoint(100, 200)), view.mapToScene(QPoint(100, 200))); +} + QTEST_MAIN(tst_Gestures) #include "tst_gestures.moc" -- cgit v0.12 From 6406a786990a7526120871dceb318ff788d609e2 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 20 Oct 2009 21:01:02 +0200 Subject: Added debug operator for QGraphicsObject Reviewed-by: Alexis Menard --- src/gui/graphicsview/qgraphicsitem.cpp | 17 +++++++++++++++++ src/gui/graphicsview/qgraphicsitem.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 4b2ff52..709066c 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -10742,6 +10742,23 @@ QDebug operator<<(QDebug debug, QGraphicsItem *item) return debug; } +QDebug operator<<(QDebug debug, QGraphicsObject *item) +{ + if (!item) { + debug << "QGraphicsObject(0)"; + return debug; + } + + debug.nospace() << item->metaObject()->className() << '(' << (void*)item; + if (!item->objectName().isEmpty()) + debug << ", name = " << item->objectName(); + debug.nospace() << ", parent = " << ((void*)item->parentItem()) + << ", pos = " << item->pos() + << ", z = " << item->zValue() << ", flags = " + << item->flags() << ')'; + return debug.space(); +} + QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change) { const char *str = "UnknownChange"; diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 54a7a64..f3fe99c 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -1120,6 +1120,7 @@ template inline T qgraphicsitem_cast(const QGraphicsItem *item) #ifndef QT_NO_DEBUG_STREAM Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem *item); +Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsObject *item); Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change); Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag); Q_GUI_EXPORT QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags); -- cgit v0.12 From 9cf2b77328fce9b7663876966112af6ed374df5b Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Tue, 20 Oct 2009 21:01:56 +0200 Subject: Implemented gesture event delivery and propagation inside QGraphicsView. Reviewed-by: Thomas Zander --- src/gui/graphicsview/qgraphicsscene.cpp | 249 +++++++++++++++++++++++++++++--- src/gui/graphicsview/qgraphicsscene_p.h | 5 + tests/auto/gestures/tst_gestures.cpp | 134 ++++++++++++++--- 3 files changed, 350 insertions(+), 38 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index 373ee89..005563e 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -252,6 +252,13 @@ #include #include +// #define GESTURE_DEBUG +#ifndef GESTURE_DEBUG +# define DEBUG if (0) qDebug +#else +# define DEBUG qDebug +#endif + QT_BEGIN_NAMESPACE bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); @@ -5711,28 +5718,234 @@ void QGraphicsScenePrivate::leaveModal(QGraphicsItem *panel) dispatchHoverEvent(&hoverEvent); } +void QGraphicsScenePrivate::getGestureTargets(const QSet &gestures, + QWidget *viewport, + QMap *conflictedGestures, + QList > *conflictedItems, + QHash *normalGestures) +{ + foreach (QGesture *gesture, gestures) { + Qt::GestureType gestureType = gesture->gestureType(); + if (gesture->hasHotSpot()) { + QPoint screenPos = gesture->hotSpot().toPoint(); + QList items = itemsAtPosition(screenPos, QPointF(), viewport); + QList result; + for (int j = 0; j < items.size(); ++j) { + QGraphicsObject *item = items.at(j)->toGraphicsObject(); + if (!item) + continue; + QGraphicsItemPrivate *d = item->QGraphicsItem::d_func(); + if (d->gestureContext.contains(gestureType)) { + result.append(item); + } + } + DEBUG() << "QGraphicsScenePrivate::getGestureTargets:" + << gesture << result; + if (result.size() == 1) { + normalGestures->insert(gesture, result.first()); + } else if (!result.isEmpty()) { + conflictedGestures->insert(gestureType, gesture); + conflictedItems->append(result); + } + } + } +} + void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) { QWidget *viewport = event->widget(); - QList gestures = event->allGestures(); - for (int i = 0; i < gestures.size(); ++i) { - QGesture *gesture = gestures.at(i); - Qt::GestureType gestureType = gesture->gestureType(); - QPoint screenPos = gesture->hotSpot().toPoint(); - QList items = itemsAtPosition(screenPos, QPointF(), viewport); - for (int j = 0; j < items.size(); ++j) { - QGraphicsObject *item = items.at(j)->toGraphicsObject(); - if (!item) - continue; - QGraphicsItemPrivate *d = item->QGraphicsItem::d_func(); - if (d->gestureContext.contains(gestureType)) { - QGestureEvent ev(QList() << gesture); - ev.t = event->t; - ev.spont = event->spont; - ev.setWidget(event->widget()); - sendEvent(item, &ev); - break; + if (!viewport) + return; + QList allGestures = event->allGestures(); + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "Delivering gestures:" << allGestures; + + typedef QHash > GesturesPerItem; + GesturesPerItem gesturesPerItem; + + QSet startedGestures; + foreach (QGesture *gesture, allGestures) { + QGraphicsObject *target = gestureTargets.value(gesture, 0); + if (!target) { + // when we are not in started mode but don't have a target + // then the only one interested in gesture is the view/scene + if (gesture->state() == Qt::GestureStarted) + startedGestures.insert(gesture); + } else { + gesturesPerItem[target].append(gesture); + } + } + + QMap conflictedGestures; + QList > conflictedItems; + QHash normalGestures; + getGestureTargets(startedGestures, viewport, &conflictedGestures, &conflictedItems, + &normalGestures); + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "Conflicting gestures:" << conflictedGestures.values() << conflictedItems; + Q_ASSERT((conflictedGestures.isEmpty() && conflictedItems.isEmpty()) || + (!conflictedGestures.isEmpty() && !conflictedItems.isEmpty())); + + // gestures that were sent as override events, but no one accepted them + QHash ignoredConflictedGestures; + + // deliver conflicted gestures as override events first + while (!conflictedGestures.isEmpty() && !conflictedItems.isEmpty()) { + // get the topmost item to deliver the override event + Q_ASSERT(!conflictedItems.isEmpty()); + Q_ASSERT(!conflictedItems.first().isEmpty()); + QGraphicsObject *topmost = conflictedItems.first().first(); + for (int i = 1; i < conflictedItems.size(); ++i) { + QGraphicsObject *item = conflictedItems.at(i).first(); + if (qt_closestItemFirst(item, topmost)) { + topmost = item; + } + } + // get a list of gestures to send to the item + QList grabbedGestures = + topmost->QGraphicsItem::d_func()->gestureContext.keys(); + QList gestures; + for (int i = 0; i < grabbedGestures.size(); ++i) { + if (QGesture *g = conflictedGestures.value(grabbedGestures.at(i), 0)) { + gestures.append(g); + if (!ignoredConflictedGestures.contains(g)) + ignoredConflictedGestures.insert(g, topmost); + } + } + + // send gesture override to the topmost item + QGestureEvent ev(gestures); + ev.t = QEvent::GestureOverride; + ev.setWidget(event->widget()); + // mark event and individual gestures as ignored + ev.ignore(); + foreach(QGesture *g, gestures) + ev.setAccepted(g, false); + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "delivering override to" + << topmost << gestures; + sendEvent(topmost, &ev); + // mark all accepted gestures to deliver them as normal gesture events + foreach (QGesture *g, gestures) { + if (ev.isAccepted() || ev.isAccepted(g)) { + conflictedGestures.remove(g->gestureType()); + gestureTargets.remove(g); + // add the gesture to the list of normal delivered gestures + normalGestures.insert(g, topmost); + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "override was accepted:" + << g << topmost; + ignoredConflictedGestures.remove(g); + } + } + // remove the item that we've already delivered from the list + for (int i = 0; i < conflictedItems.size(); ) { + QList &items = conflictedItems[i]; + if (items.first() == topmost) { + items.removeFirst(); + if (items.isEmpty()) { + conflictedItems.removeAt(i); + continue; + } } + ++i; + } + } + + // put back those started gestures that are not in the conflicted state + // and remember their targets + QHash::const_iterator it = normalGestures.begin(), + e = normalGestures.end(); + for (; it != e; ++it) { + QGesture *g = it.key(); + QGraphicsObject *receiver = it.value(); + Q_ASSERT(!gestureTargets.contains(g)); + gestureTargets.insert(g, receiver); + gesturesPerItem[receiver].append(g); + } + it = ignoredConflictedGestures.begin(); + e = ignoredConflictedGestures.end(); + for (; it != e; ++it) { + QGesture *g = it.key(); + QGraphicsObject *receiver = it.value(); + Q_ASSERT(!gestureTargets.contains(g)); + gestureTargets.insert(g, receiver); + gesturesPerItem[receiver].append(g); + } + + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "Started gestures:" << normalGestures.keys() + << "All gestures:" << gesturesPerItem.values(); + + // deliver all events + QList alreadyIgnoredGestures; + QHash > itemIgnoredGestures; + QList targetItems = gesturesPerItem.keys(); + qSort(targetItems.begin(), targetItems.end(), qt_closestItemFirst); + for (int i = 0; i < targetItems.size(); ++i) { + QGraphicsObject *item = targetItems.at(i); + QList gestures = gesturesPerItem.value(item); + // remove gestures that were already delivered once and were ignored + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "already ignored gestures for item" + << item << ":" << itemIgnoredGestures.value(item); + + if (itemIgnoredGestures.contains(item)) // don't deliver twice to the same item + continue; + + QGraphicsItemPrivate *gid = item->QGraphicsItem::d_func(); + foreach(QGesture *g, alreadyIgnoredGestures) { + if (gid->gestureContext.contains(g->gestureType())) + gestures += g; + } + if (gestures.isEmpty()) + continue; + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "delivering to" + << item << gestures; + QGestureEvent ev(gestures); + ev.setWidget(event->widget()); + sendEvent(item, &ev); + QSet ignoredGestures; + foreach (QGesture *g, gestures) { + if (!ev.isAccepted() && !ev.isAccepted(g)) + ignoredGestures.insert(g); + } + if (!ignoredGestures.isEmpty()) { + // get a list of items under the (current) hotspot of each ignored + // gesture and start delivery again from the beginning + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "item has ignored the event, will propagate." + << item << ignoredGestures; + itemIgnoredGestures[item] += ignoredGestures; + QMap conflictedGestures; + QList > itemsForConflictedGestures; + QHash normalGestures; + getGestureTargets(ignoredGestures, viewport, + &conflictedGestures, &itemsForConflictedGestures, + &normalGestures); + QSet itemsSet = targetItems.toSet(); + for (int k = 0; k < itemsForConflictedGestures.size(); ++k) + itemsSet += itemsForConflictedGestures.at(k).toSet(); + targetItems = itemsSet.toList(); + qSort(targetItems.begin(), targetItems.end(), qt_closestItemFirst); + alreadyIgnoredGestures = conflictedGestures.values(); + DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:" + << "new targets:" << targetItems; + i = -1; // start delivery again + continue; + } + } + + // forget about targets for gestures that have ended + foreach (QGesture *g, allGestures) { + switch (g->state()) { + case Qt::GestureFinished: + case Qt::GestureCanceled: + gestureTargets.remove(g); + break; + default: + break; } } } diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 4c82b49..cd20fd0 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -282,7 +282,12 @@ public: bool allItemsIgnoreTouchEvents; void enableTouchEventsOnViews(); + QHash gestureTargets; void gestureEventHandler(QGestureEvent *event); + void getGestureTargets(const QSet &gestures, QWidget *viewport, + QMap *conflictedGestures, + QList > *conflictedItems, + QHash *normalGestures); void updateInputMethodSensitivityInViews(); diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp index 09da7d6..92f979f 100644 --- a/tests/auto/gestures/tst_gestures.cpp +++ b/tests/auto/gestures/tst_gestures.cpp @@ -315,6 +315,7 @@ private slots: void finishedWithoutStarted(); void unknownGesture(); void graphicsItemGesture(); + void graphicsItemTreeGesture(); void explicitGraphicsObjectTarget(); void gestureOverChildGraphicsItem(); void twoGesturesOnDifferentLevel(); @@ -583,11 +584,20 @@ void tst_Gestures::unknownGesture() QCOMPARE(widget.gestureEventsReceived, TotalGestureEventsCount); } +static const QColor InstanceColors[] = { + Qt::blue, Qt::red, Qt::green, Qt::gray, Qt::yellow +}; + class GestureItem : public QGraphicsObject { + static int InstanceCount; + public: - GestureItem() + GestureItem(const char *name = 0) { + instanceNumber = InstanceCount++; + if (name) + setObjectName(QLatin1String(name)); size = QRectF(0, 0, 100, 100); customEventsReceived = 0; gestureEventsReceived = 0; @@ -596,6 +606,10 @@ public: overrideEvents.clear(); acceptGestureOverride = false; } + ~GestureItem() + { + --InstanceCount; + } int customEventsReceived; int gestureEventsReceived; @@ -619,8 +633,10 @@ public: } events, overrideEvents; bool acceptGestureOverride; + QSet ignoredGestures; QRectF size; + int instanceNumber; void reset() { @@ -629,6 +645,7 @@ public: gestureOverrideEventsReceived = 0; events.clear(); overrideEvents.clear(); + ignoredGestures.clear(); } protected: @@ -638,7 +655,8 @@ protected: } void paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { - p->fillRect(boundingRect(), Qt::blue); + QColor color = InstanceColors[instanceNumber % (sizeof(InstanceColors)/sizeof(InstanceColors[0]))]; + p->fillRect(boundingRect(), color); } bool event(QEvent *event) @@ -647,6 +665,9 @@ protected: if (event->type() == QEvent::Gesture) { ++gestureEventsReceived; eventsPtr = &events; + QGestureEvent *e = static_cast(event); + foreach(Qt::GestureType type, ignoredGestures) + e->ignore(e->gesture(type)); } else if (event->type() == QEvent::GestureOverride) { ++gestureOverrideEventsReceived; eventsPtr = &overrideEvents; @@ -683,13 +704,14 @@ protected: return true; } }; +int GestureItem::InstanceCount = 0; void tst_Gestures::graphicsItemGesture() { QGraphicsScene scene; QGraphicsView view(&scene); - GestureItem *item = new GestureItem; + GestureItem *item = new GestureItem("item"); scene.addItem(item); item->setPos(100, 100); @@ -732,6 +754,75 @@ void tst_Gestures::graphicsItemGesture() QCOMPARE(item->events.updated.size(), TotalGestureEventsCount - 2); QCOMPARE(item->events.finished.size(), 1); QCOMPARE(item->events.canceled.size(), 0); + + item->reset(); + + // send gesture to the item which ignores it. + item->ignoredGestures << CustomGesture::GestureType; + + event.hotSpot = mapToGlobal(QPointF(10, 10), item, &view); + event.hasHotSpot = true; + sendCustomGesture(&event, item, &scene); + QCOMPARE(item->customEventsReceived, TotalCustomEventsCount); + QCOMPARE(item->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item->gestureOverrideEventsReceived, 0); +} + +void tst_Gestures::graphicsItemTreeGesture() +{ + QGraphicsScene scene; + QGraphicsView view(&scene); + + GestureItem *item1 = new GestureItem("item1"); + item1->setPos(100, 100); + item1->size = QRectF(0, 0, 350, 200); + scene.addItem(item1); + + GestureItem *item1_child1 = new GestureItem("item1_child1"); + item1_child1->setPos(50, 50); + item1_child1->size = QRectF(0, 0, 100, 100); + item1_child1->setParentItem(item1); + + GestureItem *item1_child2 = new GestureItem("item1_child2"); + item1_child2->size = QRectF(0, 0, 100, 100); + item1_child2->setPos(200, 50); + item1_child2->setParentItem(item1); + + view.show(); + QTest::qWaitForWindowShown(&view); + view.ensureVisible(scene.sceneRect()); + + view.viewport()->grabGesture(CustomGesture::GestureType, Qt::WidgetGesture); + item1->grabGesture(CustomGesture::GestureType); + + static const int TotalGestureEventsCount = CustomGesture::SerialFinishedThreshold - CustomGesture::SerialStartedThreshold + 1; + + CustomEvent event; + event.hotSpot = mapToGlobal(QPointF(10, 10), item1_child1, &view); + event.hasHotSpot = true; + + item1->ignoredGestures << CustomGesture::GestureType; + sendCustomGesture(&event, item1_child1, &scene); + QCOMPARE(item1_child1->gestureOverrideEventsReceived, 0); + QCOMPARE(item1_child1->gestureEventsReceived, 0); + QCOMPARE(item1_child2->gestureEventsReceived, 0); + QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0); + QCOMPARE(item1->gestureOverrideEventsReceived, 0); + QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); + + item1->reset(); item1_child1->reset(); item1_child2->reset(); + + item1_child1->grabGesture(CustomGesture::GestureType); + + item1->ignoredGestures << CustomGesture::GestureType; + item1_child1->ignoredGestures << CustomGesture::GestureType; + sendCustomGesture(&event, item1_child1, &scene); + QCOMPARE(item1_child1->gestureOverrideEventsReceived, 1); + QCOMPARE(item1_child1->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item1_child2->gestureEventsReceived, 0); + QCOMPARE(item1_child2->gestureOverrideEventsReceived, 0); + QCOMPARE(item1->gestureOverrideEventsReceived, 1); + QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); } void tst_Gestures::explicitGraphicsObjectTarget() @@ -739,15 +830,17 @@ void tst_Gestures::explicitGraphicsObjectTarget() QGraphicsScene scene; QGraphicsView view(&scene); - GestureItem *item1 = new GestureItem; + GestureItem *item1 = new GestureItem("item1"); scene.addItem(item1); item1->setPos(100, 100); + item1->setZValue(1); - GestureItem *item2 = new GestureItem; + GestureItem *item2 = new GestureItem("item2"); scene.addItem(item2); item2->setPos(100, 100); + item2->setZValue(5); - GestureItem *item2_child1 = new GestureItem; + GestureItem *item2_child1 = new GestureItem("item2_child1"); scene.addItem(item2_child1); item2_child1->setParentItem(item2); item2_child1->setPos(10, 10); @@ -771,9 +864,9 @@ void tst_Gestures::explicitGraphicsObjectTarget() sendCustomGesture(&event, item1, &scene); QCOMPARE(item1->gestureEventsReceived, 0); - QCOMPARE(item1->gestureOverrideEventsReceived, 0); + QCOMPARE(item1->gestureOverrideEventsReceived, 1); QCOMPARE(item2_child1->gestureEventsReceived, TotalGestureEventsCount); - QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); + QCOMPARE(item2_child1->gestureOverrideEventsReceived, 1); QCOMPARE(item2_child1->events.all.size(), TotalGestureEventsCount); for(int i = 0; i < item2_child1->events.all.size(); ++i) QCOMPARE(item2_child1->events.all.at(i), CustomGesture::GestureType); @@ -782,7 +875,7 @@ void tst_Gestures::explicitGraphicsObjectTarget() QCOMPARE(item2_child1->events.finished.size(), 1); QCOMPARE(item2_child1->events.canceled.size(), 0); QCOMPARE(item2->gestureEventsReceived, 0); - QCOMPARE(item2->gestureOverrideEventsReceived, 0); + QCOMPARE(item2->gestureOverrideEventsReceived, 1); } void tst_Gestures::gestureOverChildGraphicsItem() @@ -790,19 +883,23 @@ void tst_Gestures::gestureOverChildGraphicsItem() QGraphicsScene scene; QGraphicsView view(&scene); - GestureItem *item0 = new GestureItem; + GestureItem *item0 = new GestureItem("item0"); scene.addItem(item0); item0->setPos(0, 0); + item0->grabGesture(CustomGesture::GestureType); + item0->setZValue(1); - GestureItem *item1 = new GestureItem; + GestureItem *item1 = new GestureItem("item1"); scene.addItem(item1); item1->setPos(100, 100); + item1->setZValue(5); - GestureItem *item2 = new GestureItem; + GestureItem *item2 = new GestureItem("item2"); scene.addItem(item2); item2->setPos(100, 100); + item2->setZValue(10); - GestureItem *item2_child1 = new GestureItem; + GestureItem *item2_child1 = new GestureItem("item2_child1"); scene.addItem(item2_child1); item2_child1->setParentItem(item2); item2_child1->setPos(0, 0); @@ -827,12 +924,12 @@ void tst_Gestures::gestureOverChildGraphicsItem() QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); QCOMPARE(item2->gestureEventsReceived, 0); QCOMPARE(item2->gestureOverrideEventsReceived, 0); - QEXPECT_FAIL("", "need to fix gesture event propagation inside graphicsview", Continue); QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); QCOMPARE(item1->gestureOverrideEventsReceived, 0); item0->reset(); item1->reset(); item2->reset(); item2_child1->reset(); item2->grabGesture(CustomGesture::GestureType); + item2->ignoredGestures << CustomGesture::GestureType; event.hotSpot = mapToGlobal(QPointF(10, 10), item2_child1, &view); event.hasHotSpot = true; @@ -841,13 +938,10 @@ void tst_Gestures::gestureOverChildGraphicsItem() QCOMPARE(item0->customEventsReceived, TotalCustomEventsCount); QCOMPARE(item2_child1->gestureEventsReceived, 0); QCOMPARE(item2_child1->gestureOverrideEventsReceived, 0); - QEXPECT_FAIL("", "need to fix gesture event propagation inside graphicsview", Continue); QCOMPARE(item2->gestureEventsReceived, TotalGestureEventsCount); - QEXPECT_FAIL("", "need to fix gesture event propagation inside graphicsview", Continue); - QCOMPARE(item2->gestureOverrideEventsReceived, TotalGestureEventsCount); - QCOMPARE(item1->gestureEventsReceived, 0); - QEXPECT_FAIL("", "need to fix gesture event propagation inside graphicsview", Continue); - QCOMPARE(item1->gestureOverrideEventsReceived, TotalGestureEventsCount); + QCOMPARE(item2->gestureOverrideEventsReceived, 1); + QCOMPARE(item1->gestureEventsReceived, TotalGestureEventsCount); + QCOMPARE(item1->gestureOverrideEventsReceived, 1); } void tst_Gestures::twoGesturesOnDifferentLevel() -- cgit v0.12 From 6c7d3f73e361c460ad5523f1d9c9d9d6ebc81299 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 21 Oct 2009 16:33:11 +0200 Subject: Fixed the gestures/graphicsview manualtest --- tests/manual/gestures/graphicsview/main.cpp | 2 ++ .../graphicsview/mousepangesturerecognizer.cpp | 25 ++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp index 263a963..b4d74e4 100644 --- a/tests/manual/gestures/graphicsview/main.cpp +++ b/tests/manual/gestures/graphicsview/main.cpp @@ -126,6 +126,8 @@ public: scene = new QGraphicsScene(this); scene->setSceneRect(-2000, -2000, 4000, 4000); view = new QGraphicsView(scene, 0); + view->viewport()->grabGesture(Qt::PanGesture); + view->viewport()->grabGesture(ThreeFingerSlideGesture::Type); QVBoxLayout *l = new QVBoxLayout(this); l->addWidget(view); } diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp index 0e7f538..acd525f 100644 --- a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp @@ -42,6 +42,8 @@ #include "mousepangesturerecognizer.h" #include +#include +#include #include #include @@ -57,16 +59,31 @@ QGesture* MousePanGestureRecognizer::createGesture(QObject *) QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *state, QObject *, QEvent *event) { QPanGesture *g = static_cast(state); - QMouseEvent *me = static_cast(event); + QPoint globalPos; + switch (event->type()) { + case QEvent::GraphicsSceneMousePress: + case QEvent::GraphicsSceneMouseDoubleClick: + case QEvent::GraphicsSceneMouseMove: + case QEvent::GraphicsSceneMouseRelease: + globalPos = static_cast(event)->screenPos(); + break; + case QEvent::MouseButtonPress: + case QEvent::MouseMove: + case QEvent::MouseButtonRelease: + globalPos = static_cast(event)->globalPos(); + break; + default: + break; + } if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::MouseButtonDblClick || event->type() == QEvent::GraphicsSceneMousePress || event->type() == QEvent::GraphicsSceneMouseDoubleClick) { - g->setHotSpot(me->globalPos()); - g->setProperty("lastPos", me->globalPos()); + g->setHotSpot(globalPos); + g->setProperty("lastPos", globalPos); g->setProperty("pressed", QVariant::fromValue(true)); return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; } else if (event->type() == QEvent::MouseMove || event->type() == QEvent::GraphicsSceneMouseMove) { if (g->property("pressed").toBool()) { - QPoint pos = me->globalPos(); + QPoint pos = globalPos; QPoint lastPos = g->property("lastPos").toPoint(); g->setLastOffset(g->offset()); lastPos = pos - lastPos; -- cgit v0.12 From ee6d3a13a04c2fb5cfef8a18fd370ef1f605555a Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 20 Oct 2009 15:09:58 +0200 Subject: Make the already-public calls be documented and public --- src/gui/kernel/qevent.cpp | 4 ++-- src/gui/kernel/qevent.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ef74f06..065bd09 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4330,7 +4330,7 @@ bool QGestureEvent::isAccepted(QGesture *gesture) const } /*! - \internal + Sets the widget for this event. */ void QGestureEvent::setWidget(QWidget *widget) { @@ -4338,7 +4338,7 @@ void QGestureEvent::setWidget(QWidget *widget) } /*! - \internal + Returns the widget on which the event occurred. */ QWidget *QGestureEvent::widget() const { diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 249c45a..b7370fd 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -851,7 +851,6 @@ public: void ignore(QGesture *); bool isAccepted(QGesture *) const; - // internal void setWidget(QWidget *widget); QWidget *widget() const; -- cgit v0.12 From 04302702c5e7938fb4ae8bc41d78486725e62ae7 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Tue, 20 Oct 2009 15:43:05 +0200 Subject: Change API; the pan gesture now has points for distance, not size. --- src/gui/kernel/qgesture.cpp | 12 ++++++------ src/gui/kernel/qgesture.h | 18 +++++++++--------- src/gui/kernel/qgesture_p.h | 6 +++--- src/gui/kernel/qstandardgestures.cpp | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index f044c09..ecdd661 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -235,17 +235,17 @@ QPanGesture::QPanGesture(QObject *parent) d_func()->gestureType = Qt::PanGesture; } -QSizeF QPanGesture::totalOffset() const +QPointF QPanGesture::totalOffset() const { return d_func()->totalOffset; } -QSizeF QPanGesture::lastOffset() const +QPointF QPanGesture::lastOffset() const { return d_func()->lastOffset; } -QSizeF QPanGesture::offset() const +QPointF QPanGesture::offset() const { return d_func()->offset; } @@ -256,17 +256,17 @@ qreal QPanGesture::acceleration() const } -void QPanGesture::setTotalOffset(const QSizeF &value) +void QPanGesture::setTotalOffset(const QPointF &value) { d_func()->totalOffset = value; } -void QPanGesture::setLastOffset(const QSizeF &value) +void QPanGesture::setLastOffset(const QPointF &value) { d_func()->lastOffset = value; } -void QPanGesture::setOffset(const QSizeF &value) +void QPanGesture::setOffset(const QPointF &value) { d_func()->offset = value; } diff --git a/src/gui/kernel/qgesture.h b/src/gui/kernel/qgesture.h index 9d1c11e..6469959 100644 --- a/src/gui/kernel/qgesture.h +++ b/src/gui/kernel/qgesture.h @@ -96,22 +96,22 @@ class Q_GUI_EXPORT QPanGesture : public QGesture Q_OBJECT Q_DECLARE_PRIVATE(QPanGesture) - Q_PROPERTY(QSizeF totalOffset READ totalOffset WRITE setTotalOffset) - Q_PROPERTY(QSizeF lastOffset READ lastOffset WRITE setLastOffset) - Q_PROPERTY(QSizeF offset READ offset WRITE setOffset) + Q_PROPERTY(QPointF totalOffset READ totalOffset WRITE setTotalOffset) + Q_PROPERTY(QPointF lastOffset READ lastOffset WRITE setLastOffset) + Q_PROPERTY(QPointF offset READ offset WRITE setOffset) Q_PROPERTY(qreal acceleration READ acceleration WRITE setAcceleration) public: QPanGesture(QObject *parent = 0); - QSizeF totalOffset() const; - QSizeF lastOffset() const; - QSizeF offset() const; + QPointF totalOffset() const; + QPointF lastOffset() const; + QPointF offset() const; qreal acceleration() const; - void setTotalOffset(const QSizeF &value); - void setLastOffset(const QSizeF &value); - void setOffset(const QSizeF &value); + void setTotalOffset(const QPointF &value); + void setLastOffset(const QPointF &value); + void setOffset(const QPointF &value); void setAcceleration(qreal value); friend class QPanGestureRecognizer; diff --git a/src/gui/kernel/qgesture_p.h b/src/gui/kernel/qgesture_p.h index 10887f6..975c0c9 100644 --- a/src/gui/kernel/qgesture_p.h +++ b/src/gui/kernel/qgesture_p.h @@ -89,9 +89,9 @@ public: { } - QSizeF totalOffset; - QSizeF lastOffset; - QSizeF offset; + QPointF totalOffset; + QPointF lastOffset; + QPointF offset; QPoint lastPosition; qreal acceleration; }; diff --git a/src/gui/kernel/qstandardgestures.cpp b/src/gui/kernel/qstandardgestures.cpp index dfc3499..a136379 100644 --- a/src/gui/kernel/qstandardgestures.cpp +++ b/src/gui/kernel/qstandardgestures.cpp @@ -73,7 +73,7 @@ QGestureRecognizer::Result QPanGestureRecognizer::filterEvent(QGesture *state, Q result = QGestureRecognizer::MaybeGesture; QTouchEvent::TouchPoint p = ev->touchPoints().at(0); d->lastPosition = p.pos().toPoint(); - d->lastOffset = d->totalOffset = d->offset = QSize(); + d->lastOffset = d->totalOffset = d->offset = QPointF(); break; } case QEvent::TouchEnd: { @@ -83,7 +83,7 @@ QGestureRecognizer::Result QPanGestureRecognizer::filterEvent(QGesture *state, Q QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1); d->lastOffset = d->offset; d->offset = - QSize(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(), + QPointF(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(), p1.pos().y() - p1.lastPos().y() + p2.pos().y() - p2.lastPos().y()) / 2; d->totalOffset += d->offset; } @@ -99,11 +99,11 @@ QGestureRecognizer::Result QPanGestureRecognizer::filterEvent(QGesture *state, Q QTouchEvent::TouchPoint p2 = ev->touchPoints().at(1); d->lastOffset = d->offset; d->offset = - QSize(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(), + QPointF(p1.pos().x() - p1.lastPos().x() + p2.pos().x() - p2.lastPos().x(), p1.pos().y() - p1.lastPos().y() + p2.pos().y() - p2.lastPos().y()) / 2; d->totalOffset += d->offset; - if (d->totalOffset.width() > 10 || d->totalOffset.height() > 10 || - d->totalOffset.width() < -10 || d->totalOffset.height() < -10) { + if (d->totalOffset.x() > 10 || d->totalOffset.y() > 10 || + d->totalOffset.x() < -10 || d->totalOffset.y() < -10) { result = QGestureRecognizer::GestureTriggered; } else { result = QGestureRecognizer::MaybeGesture; @@ -128,7 +128,7 @@ void QPanGestureRecognizer::reset(QGesture *state) QPanGesture *pan = static_cast(state); QPanGesturePrivate *d = pan->d_func(); - d->totalOffset = d->lastOffset = d->offset = QSizeF(); + d->totalOffset = d->lastOffset = d->offset = QPointF(); d->lastPosition = QPoint(); d->acceleration = 0; -- cgit v0.12 From 0e4d5715992f9d7d7e1c598527907797e0b98427 Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 21 Oct 2009 12:40:29 +0200 Subject: Make warning more helpful. Also fix grammer and avoid using combined words. --- src/gui/kernel/qgesturemanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qgesturemanager.cpp b/src/gui/kernel/qgesturemanager.cpp index 6f1aec4..ed8e744 100644 --- a/src/gui/kernel/qgesturemanager.cpp +++ b/src/gui/kernel/qgesturemanager.cpp @@ -90,7 +90,7 @@ Qt::GestureType QGestureManager::registerGestureRecognizer(QGestureRecognizer *r QGesture *dummy = recognizer->createGesture(0); if (!dummy) { qWarning("QGestureManager::registerGestureRecognizer: " - "the recognizer doesn't provide gesture object"); + "the recognizer fails to create a gesture object, skipping registration."); return Qt::GestureType(0); } Qt::GestureType type = dummy->gestureType(); -- cgit v0.12 From 760f221e7f1550ecc8198fb0c01c65ee13ded7f4 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 22 Oct 2009 11:31:27 +0200 Subject: QSslSocket: Trigger a SSL transmission when reading from the socket. In certain cases a SSL transfer stalled when a readBufferSize was set. This change triggers a SSL transmission when there is data on the socket waiting to be decrypted. Task-number: QTBUG-3860 Reviewed-by: Thiago --- src/network/ssl/qsslsocket.cpp | 15 ++++++++ src/network/ssl/qsslsocket.h | 1 + src/network/ssl/qsslsocket_p.h | 1 + tests/auto/qsslsocket/tst_qsslsocket.cpp | 61 ++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+) diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index ad766c1..2c88130 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -1740,6 +1740,11 @@ qint64 QSslSocket::readData(char *data, qint64 maxlen) #ifdef QSSLSOCKET_DEBUG qDebug() << "QSslSocket::readData(" << (void *)data << ',' << maxlen << ") ==" << readBytes; #endif + + // possibly trigger another transmit() to decrypt more data from the socket + if (d->readBuffer.isEmpty() && d->plainSocket->bytesAvailable()) + QMetaObject::invokeMethod(this, "_q_flushReadBuffer", Qt::QueuedConnection); + return readBytes; } @@ -2134,6 +2139,16 @@ void QSslSocketPrivate::_q_flushWriteBuffer() q->flush(); } +/*! + \internal +*/ +void QSslSocketPrivate::_q_flushReadBuffer() +{ + // trigger a read from the plainSocket into SSL + if (mode != QSslSocket::UnencryptedMode) + transmit(); +} + QT_END_NAMESPACE // For private slots diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h index adb206c..82cda35 100644 --- a/src/network/ssl/qsslsocket.h +++ b/src/network/ssl/qsslsocket.h @@ -207,6 +207,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_readyReadSlot()) Q_PRIVATE_SLOT(d_func(), void _q_bytesWrittenSlot(qint64)) Q_PRIVATE_SLOT(d_func(), void _q_flushWriteBuffer()) + Q_PRIVATE_SLOT(d_func(), void _q_flushReadBuffer()) friend class QSslSocketBackendPrivate; }; diff --git a/src/network/ssl/qsslsocket_p.h b/src/network/ssl/qsslsocket_p.h index 24d4ebe..ee21956 100644 --- a/src/network/ssl/qsslsocket_p.h +++ b/src/network/ssl/qsslsocket_p.h @@ -120,6 +120,7 @@ public: void _q_readyReadSlot(); void _q_bytesWrittenSlot(qint64); void _q_flushWriteBuffer(); + void _q_flushReadBuffer(); // Platform specific functions virtual void startClientEncryption() = 0; diff --git a/tests/auto/qsslsocket/tst_qsslsocket.cpp b/tests/auto/qsslsocket/tst_qsslsocket.cpp index d576201..2bd1684 100644 --- a/tests/auto/qsslsocket/tst_qsslsocket.cpp +++ b/tests/auto/qsslsocket/tst_qsslsocket.cpp @@ -170,6 +170,7 @@ private slots: void setEmptyKey(); void spontaneousWrite(); void setReadBufferSize(); + void setReadBufferSize_task_250027(); void waitForMinusOne(); void verifyMode(); void verifyDepth(); @@ -1241,6 +1242,66 @@ void tst_QSslSocket::setReadBufferSize() QVERIFY(receiver->bytesAvailable() > oldBytesAvailable); } +class SetReadBufferSize_task_250027_handler : public QObject { + Q_OBJECT +public slots: + void readyReadSlot() { + QTestEventLoop::instance().exitLoop(); + } + void waitSomeMore(QSslSocket *socket) { + QTime t; + t.start(); + while (!socket->encryptedBytesAvailable()) { + QCoreApplication::processEvents(QEventLoop::AllEvents | QEventLoop::WaitForMoreEvents, 250); + if (t.elapsed() > 1000 || socket->state() != QAbstractSocket::ConnectedState) + return; + } + } +}; + +void tst_QSslSocket::setReadBufferSize_task_250027() +{ + // do not execute this when a proxy is set. + QFETCH_GLOBAL(bool, setProxy); + if (setProxy) + return; + + QSslSocketPtr socket = newSocket(); + socket->setReadBufferSize(1000); // limit to 1 kb/sec + socket->ignoreSslErrors(); + socket->connectToHostEncrypted(QtNetworkSettings::serverName(), 443); + socket->ignoreSslErrors(); + QVERIFY(socket->waitForConnected(10*1000)); + QVERIFY(socket->waitForEncrypted(10*1000)); + + // exit the event loop as soon as we receive a readyRead() + SetReadBufferSize_task_250027_handler setReadBufferSize_task_250027_handler; + connect(socket, SIGNAL(readyRead()), &setReadBufferSize_task_250027_handler, SLOT(readyReadSlot())); + + // provoke a response by sending a request + socket->write("GET /gif/fluke.gif HTTP/1.0\n"); // this file is 27 KB + socket->write("Host: "); + socket->write(QtNetworkSettings::serverName().toLocal8Bit().constData()); + socket->write("\n"); + socket->write("Connection: close\n"); + socket->write("\n"); + socket->flush(); + + QTestEventLoop::instance().enterLoop(10); + setReadBufferSize_task_250027_handler.waitSomeMore(socket); + QByteArray firstRead = socket->readAll(); + // First read should be some data, but not the whole file + QVERIFY(firstRead.size() > 0 && firstRead.size() < 20*1024); + + QTestEventLoop::instance().enterLoop(10); + setReadBufferSize_task_250027_handler.waitSomeMore(socket); + QByteArray secondRead = socket->readAll(); + // second read should be some more data + QVERIFY(secondRead.size() > 0); + + socket->close(); +} + class SslServer3 : public QTcpServer { Q_OBJECT -- cgit v0.12 From f182dcb82c4b0f4807a99bc8fb05bb6d07d8ddd3 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 14 Oct 2009 11:59:44 +0200 Subject: QHttp: Fix bug related to SSL and big POST data QHttp is deprecated, but let's be nice and fix this. POST/PUT now properly works over HTTPS without buffering the whole data when it is not needed. Reviewed-by: Peter Hartmann --- src/network/access/qhttp.cpp | 28 +++++++++++++++++++++++++++ src/network/access/qhttp.h | 3 +++ tests/auto/qhttp/tst_qhttp.cpp | 43 +++++++++++++++++++++++++++++++++++------- 3 files changed, 67 insertions(+), 7 deletions(-) diff --git a/src/network/access/qhttp.cpp b/src/network/access/qhttp.cpp index 69faee3..f006fba 100644 --- a/src/network/access/qhttp.cpp +++ b/src/network/access/qhttp.cpp @@ -121,6 +121,9 @@ public: void _q_slotError(QAbstractSocket::SocketError); void _q_slotClosed(); void _q_slotBytesWritten(qint64 numBytes); +#ifndef QT_NO_OPENSSL + void _q_slotEncryptedBytesWritten(qint64 numBytes); +#endif void _q_slotDoFinished(); void _q_slotSendRequest(); void _q_continuePost(); @@ -135,6 +138,8 @@ public: void closeConn(); void setSock(QTcpSocket *sock); + void postMoreData(); + QTcpSocket *socket; int reconnectAttempts; bool deleteSocket; @@ -2659,19 +2664,40 @@ void QHttpPrivate::_q_slotError(QAbstractSocket::SocketError err) closeConn(); } +#ifndef QT_NO_OPENSSL +void QHttpPrivate::_q_slotEncryptedBytesWritten(qint64 written) +{ + Q_UNUSED(written); + postMoreData(); +} +#endif + void QHttpPrivate::_q_slotBytesWritten(qint64 written) { Q_Q(QHttp); bytesDone += written; emit q->dataSendProgress(bytesDone, bytesTotal); + postMoreData(); +} +// Send the POST data +void QHttpPrivate::postMoreData() +{ if (pendingPost) return; if (!postDevice) return; + // the following is backported code from Qt 4.6 QNetworkAccessManager. + // We also have to check the encryptedBytesToWrite() if it is an SSL socket. +#ifndef QT_NO_OPENSSL + QSslSocket *sslSocket = qobject_cast(socket); + // if it is really an ssl socket, check more than just bytesToWrite() + if ((socket->bytesToWrite() + (sslSocket ? sslSocket->encryptedBytesToWrite() : 0)) == 0) { +#else if (socket->bytesToWrite() == 0) { +#endif int max = qMin(4096, postDevice->size() - postDevice->pos()); QByteArray arr; arr.resize(max); @@ -3097,6 +3123,8 @@ void QHttpPrivate::setSock(QTcpSocket *sock) if (qobject_cast(socket)) { QObject::connect(socket, SIGNAL(sslErrors(const QList &)), q, SIGNAL(sslErrors(const QList &))); + QObject::connect(socket, SIGNAL(encryptedBytesWritten(qint64)), + q, SLOT(_q_slotEncryptedBytesWritten(qint64))); } #endif } diff --git a/src/network/access/qhttp.h b/src/network/access/qhttp.h index e5061ca..f30def2 100644 --- a/src/network/access/qhttp.h +++ b/src/network/access/qhttp.h @@ -290,6 +290,9 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_slotError(QAbstractSocket::SocketError)) Q_PRIVATE_SLOT(d_func(), void _q_slotClosed()) Q_PRIVATE_SLOT(d_func(), void _q_slotBytesWritten(qint64 numBytes)) +#ifndef QT_NO_OPENSSL + Q_PRIVATE_SLOT(d_func(), void _q_slotEncryptedBytesWritten(qint64 numBytes)) +#endif Q_PRIVATE_SLOT(d_func(), void _q_slotDoFinished()) Q_PRIVATE_SLOT(d_func(), void _q_slotSendRequest()) Q_PRIVATE_SLOT(d_func(), void _q_continuePost()) diff --git a/tests/auto/qhttp/tst_qhttp.cpp b/tests/auto/qhttp/tst_qhttp.cpp index f6d5e3e..0ea0d15 100644 --- a/tests/auto/qhttp/tst_qhttp.cpp +++ b/tests/auto/qhttp/tst_qhttp.cpp @@ -484,6 +484,7 @@ void tst_QHttp::post_data() QTest::addColumn("useProxy"); QTest::addColumn("host"); QTest::addColumn("port"); + QTest::addColumn("ssl"); QTest::addColumn("path"); QTest::addColumn("result"); @@ -491,25 +492,48 @@ void tst_QHttp::post_data() md5sum = "d41d8cd98f00b204e9800998ecf8427e"; QTest::newRow("empty-data") << QString() << false << false - << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" << md5sum; + << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum; QTest::newRow("empty-device") << QString() << true << false - << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" << md5sum; + << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum; QTest::newRow("proxy-empty-data") << QString() << false << true - << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" << md5sum; + << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum; md5sum = "b3e32ac459b99d3f59318f3ac31e4bee"; QTest::newRow("data") << "rfc3252.txt" << false << false - << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" + << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum; QTest::newRow("device") << "rfc3252.txt" << true << false - << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" + << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum; QTest::newRow("proxy-data") << "rfc3252.txt" << false << true - << QtNetworkSettings::serverName() << 80 << "/qtest/cgi-bin/md5sum.cgi" + << QtNetworkSettings::serverName() << 80 << false << "/qtest/cgi-bin/md5sum.cgi" << md5sum; +#ifndef QT_NO_OPENSSL + md5sum = "d41d8cd98f00b204e9800998ecf8427e"; + QTest::newRow("empty-data-ssl") + << QString() << false << false + << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" << md5sum; + QTest::newRow("empty-device-ssl") + << QString() << true << false + << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" << md5sum; + QTest::newRow("proxy-empty-data-ssl") + << QString() << false << true + << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" << md5sum; + md5sum = "b3e32ac459b99d3f59318f3ac31e4bee"; + QTest::newRow("data-ssl") << "rfc3252.txt" << false << false + << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" + << md5sum; + QTest::newRow("device-ssl") << "rfc3252.txt" << true << false + << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" + << md5sum; + QTest::newRow("proxy-data-ssl") << "rfc3252.txt" << false << true + << QtNetworkSettings::serverName() << 443 << true << "/qtest/cgi-bin/md5sum.cgi" + << md5sum; +#endif + // the following test won't work. See task 185996 /* QTest::newRow("proxy-device") << "rfc3252.txt" << true << true @@ -525,14 +549,19 @@ void tst_QHttp::post() QFETCH(bool, useProxy); QFETCH(QString, host); QFETCH(int, port); + QFETCH(bool, ssl); QFETCH(QString, path); http = newHttp(useProxy); +#ifndef QT_NO_OPENSSL + QObject::connect(http, SIGNAL(sslErrors(const QList &)), + http, SLOT(ignoreSslErrors())); +#endif QCOMPARE(http->currentId(), 0); QCOMPARE((int)http->state(), (int)QHttp::Unconnected); if (useProxy) addRequest(QHttpRequestHeader(), http->setProxy(QtNetworkSettings::serverName(), 3129)); - addRequest(QHttpRequestHeader(), http->setHost(host, port)); + addRequest(QHttpRequestHeader(), http->setHost(host, (ssl ? QHttp::ConnectionModeHttps : QHttp::ConnectionModeHttp), port)); // add the POST request QFile file(SRCDIR + source); -- cgit v0.12 From 30b66e1b92b54b8f035da3c66ad086340befcf5b Mon Sep 17 00:00:00 2001 From: Liang QI Date: Thu, 22 Oct 2009 17:37:25 +0200 Subject: QTextEdit: Fix the wrong order for call of Qt::WA_InputMethodEnabled in setReadOnly. Should set Qt::WA_InputMethodEnabled after set the flags, just because shouldEnableInputMethod() will read the flags. Task-number: QTBUG-4917 Reviewed-by: Shane Kearns --- src/gui/widgets/qtextedit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qtextedit.cpp b/src/gui/widgets/qtextedit.cpp index b894aa8..f477fee 100644 --- a/src/gui/widgets/qtextedit.cpp +++ b/src/gui/widgets/qtextedit.cpp @@ -2079,8 +2079,8 @@ void QTextEdit::setReadOnly(bool ro) } else { flags = Qt::TextEditorInteraction; } - setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); d->control->setTextInteractionFlags(flags); + setAttribute(Qt::WA_InputMethodEnabled, shouldEnableInputMethod(this)); } /*! -- cgit v0.12 From 82caa7b3f97c6cda0ebceb477856442653a83699 Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 22 Oct 2009 18:11:19 +0200 Subject: Warning -- Reviewed-by:TrustMe --- src/gui/graphicsview/qgraphicsproxywidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsproxywidget.cpp b/src/gui/graphicsview/qgraphicsproxywidget.cpp index 64c51ad..e9173a9 100644 --- a/src/gui/graphicsview/qgraphicsproxywidget.cpp +++ b/src/gui/graphicsview/qgraphicsproxywidget.cpp @@ -397,7 +397,7 @@ QWidget *QGraphicsProxyWidgetPrivate::findFocusChild(QWidget *child, bool next) do { if (child->isEnabled() && child->isVisibleTo(widget) - && (child->focusPolicy() & focus_flag == focus_flag) + && ((child->focusPolicy() & focus_flag) == focus_flag) && !(child->d_func()->extra && child->d_func()->extra->focus_proxy)) { return child; } -- cgit v0.12 From a5f7f88932c6911fb65552d65d62efdcf496beec Mon Sep 17 00:00:00 2001 From: Alexis Menard Date: Thu, 22 Oct 2009 18:11:34 +0200 Subject: Fix crash in QGraphicsView BSP discovered in Amarok. Basically some items were not properly remove in the BSP which means that if you delete one of items, the BSP tree may contain dangling pointers. The problem was in removeItemHelper in QGraphicsScene were the child were removed after reparenting to 0 the topmost parent. The sceneBoundingRect for children was invalid which means that we were removing them in the wrong position inside the BSP. Reparenting to 0 means that the sceneBoundingRect will be the boundingRect but wasn't the case before (for the topmost parent). Reviewed-by:bnilsen --- src/gui/graphicsview/qgraphicsscene.cpp | 14 +++--- .../tst_qgraphicssceneindex.cpp | 58 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 6 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a624b10..03c8a97 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -518,6 +518,14 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) item->d_func()->scene = 0; + //We need to remove all children first because they might use their parent + //attributes (e.g. sceneTransform). + if (!item->d_ptr->inDestructor) { + // Remove all children recursively + for (int i = 0; i < item->d_ptr->children.size(); ++i) + q->removeItem(item->d_ptr->children.at(i)); + } + // Unregister focus proxy. item->d_ptr->resetFocusProxy(); @@ -564,12 +572,6 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) ++iterator; } - if (!item->d_ptr->inDestructor) { - // Remove all children recursively - for (int i = 0; i < item->d_ptr->children.size(); ++i) - q->removeItem(item->d_ptr->children.at(i)); - } - if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal) leaveModal(item); diff --git a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp index 1109e5e..9dfd486 100644 --- a/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp +++ b/tests/auto/qgraphicssceneindex/tst_qgraphicssceneindex.cpp @@ -66,6 +66,7 @@ private slots: void movingItems(); void connectedToSceneRectChanged(); void items(); + void removeItems(); void clear(); private: @@ -268,6 +269,63 @@ void tst_QGraphicsSceneIndex::items() QCOMPARE(scene.items().size(), 3); } +class RectWidget : public QGraphicsWidget +{ + Q_OBJECT +public: + RectWidget(QGraphicsItem *parent = 0) : QGraphicsWidget(parent) + { + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + painter->setBrush(brush); + painter->drawRect(boundingRect()); + } +public: + QBrush brush; +}; + +void tst_QGraphicsSceneIndex::removeItems() +{ + QGraphicsScene scene; + + RectWidget *parent = new RectWidget; + parent->brush = QBrush(QColor(Qt::magenta)); + parent->setGeometry(250, 250, 400, 400); + + RectWidget *widget = new RectWidget(parent); + widget->brush = QBrush(QColor(Qt::blue)); + widget->setGeometry(10, 10, 200, 200); + + RectWidget *widgetChild1 = new RectWidget(widget); + widgetChild1->brush = QBrush(QColor(Qt::green)); + widgetChild1->setGeometry(20, 20, 100, 100); + + RectWidget *widgetChild2 = new RectWidget(widgetChild1); + widgetChild2->brush = QBrush(QColor(Qt::yellow)); + widgetChild2->setGeometry(25, 25, 50, 50); + + scene.addItem(parent); + + QGraphicsView view(&scene); + view.resize(600, 600); + view.show(); + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + + QApplication::processEvents(); + + scene.removeItem(widgetChild1); + + delete widgetChild1; + + //We move the parent + scene.items(295, 295, 50, 50); + + //This should not crash +} + void tst_QGraphicsSceneIndex::clear() { class MyItem : public QGraphicsItem -- cgit v0.12 From 5de213210ef4f14e698c3fd970cf7e6c5b27c72d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 16 Oct 2009 09:55:28 +0200 Subject: Added caching of graphics effect source pixmaps to speed up effects. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If an effect is applied repeatedly on the same source, just with varying parameters, we can save a lot by caching the source pixmaps. Reviewed-by: Bjørn Erik Nilsen --- src/gui/effects/qgraphicseffect.cpp | 19 ++++++++++++++++++- src/gui/effects/qgraphicseffect.h | 1 + src/gui/effects/qgraphicseffect_p.h | 12 +++++++++++- src/gui/graphicsview/qgraphicsitem.cpp | 27 +++++++++++++++++++++------ src/gui/graphicsview/qgraphicsitem_p.h | 11 +++++++++-- src/gui/graphicsview/qgraphicsscene.cpp | 5 +++++ src/gui/kernel/qwidget.cpp | 22 ++++++++++++++++++++++ src/gui/kernel/qwidget_p.h | 13 ++++++++++--- src/gui/painting/qbackingstore.cpp | 5 +++++ 9 files changed, 102 insertions(+), 13 deletions(-) diff --git a/src/gui/effects/qgraphicseffect.cpp b/src/gui/effects/qgraphicseffect.cpp index 91641b0..96d35b0 100644 --- a/src/gui/effects/qgraphicseffect.cpp +++ b/src/gui/effects/qgraphicseffect.cpp @@ -253,7 +253,24 @@ bool QGraphicsEffectSource::isPixmap() const */ QPixmap QGraphicsEffectSource::pixmap(Qt::CoordinateSystem system, QPoint *offset) const { - return d_func()->pixmap(system, offset); + Q_D(const QGraphicsEffectSource); + + QPixmap pm; + if (d->m_cachedSystem == system) + QPixmapCache::find(d->m_cacheKey, &pm); + + if (pm.isNull()) { + pm = d->pixmap(system, &d->m_cachedOffset); + d->m_cachedSystem = system; + + d->invalidateCache(); + d->m_cacheKey = QPixmapCache::insert(pm); + } + + if (offset) + *offset = d->m_cachedOffset; + + return pm; } /*! diff --git a/src/gui/effects/qgraphicseffect.h b/src/gui/effects/qgraphicseffect.h index c5d3ede..c89851e 100644 --- a/src/gui/effects/qgraphicseffect.h +++ b/src/gui/effects/qgraphicseffect.h @@ -87,6 +87,7 @@ private: friend class QGraphicsEffectPrivate; friend class QGraphicsScenePrivate; friend class QGraphicsItem; + friend class QGraphicsItemPrivate; friend class QWidget; friend class QWidgetPrivate; }; diff --git a/src/gui/effects/qgraphicseffect_p.h b/src/gui/effects/qgraphicseffect_p.h index ff2fb85..8fb55d8 100644 --- a/src/gui/effects/qgraphicseffect_p.h +++ b/src/gui/effects/qgraphicseffect_p.h @@ -55,6 +55,8 @@ #include "qgraphicseffect.h" +#include + #include #include @@ -65,7 +67,7 @@ class QGraphicsEffectSourcePrivate : public QObjectPrivate Q_DECLARE_PUBLIC(QGraphicsEffectSource) public: QGraphicsEffectSourcePrivate() : QObjectPrivate() {} - virtual ~QGraphicsEffectSourcePrivate() {} + virtual ~QGraphicsEffectSourcePrivate() { invalidateCache(); } virtual void detach() = 0; virtual QRectF boundingRect(Qt::CoordinateSystem system) const = 0; virtual QRect deviceRect() const = 0; @@ -77,9 +79,16 @@ public: virtual bool isPixmap() const = 0; virtual QPixmap pixmap(Qt::CoordinateSystem system, QPoint *offset = 0) const = 0; virtual void effectBoundingRectChanged() = 0; + void invalidateCache() const { QPixmapCache::remove(m_cacheKey); } + friend class QGraphicsScenePrivate; friend class QGraphicsItem; friend class QGraphicsItemPrivate; + +private: + mutable Qt::CoordinateSystem m_cachedSystem; + mutable QPoint m_cachedOffset; + mutable QPixmapCache::Key m_cacheKey; }; class Q_GUI_EXPORT QGraphicsEffectPrivate : public QObjectPrivate @@ -94,6 +103,7 @@ public: if (source) { flags |= QGraphicsEffect::SourceDetached; source->d_func()->detach(); + source->d_func()->invalidateCache(); delete source; } source = newSource; diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 45627f6..5153783 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -2482,12 +2482,14 @@ void QGraphicsItem::setOpacity(qreal opacity) itemChange(ItemOpacityHasChanged, newOpacityVariant); // Update. - if (d_ptr->scene) + if (d_ptr->scene) { + d_ptr->invalidateGraphicsEffectsRecursively(); d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*maybeDirtyClipPath=*/false, /*force=*/false, /*ignoreOpacity=*/true); + } if (d_ptr->isObject) emit static_cast(this)->opacityChanged(); @@ -4949,6 +4951,22 @@ int QGraphicsItemPrivate::depth() const /*! \internal */ +void QGraphicsItemPrivate::invalidateGraphicsEffectsRecursively() +{ + QGraphicsItemPrivate *itemPrivate = this; + do { + if (itemPrivate->graphicsEffect) { + itemPrivate->notifyInvalidated = 1; + + if (!itemPrivate->updateDueToGraphicsEffect) + static_cast(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache(); + } + } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0)); +} + +/*! + \internal +*/ void QGraphicsItemPrivate::invalidateDepthRecursively() { if (itemDepth == -1) @@ -5280,11 +5298,7 @@ void QGraphicsItem::update(const QRectF &rect) return; // Make sure we notify effects about invalidated source. - QGraphicsItem *item = this; - do { - if (item->d_ptr->graphicsEffect) - item->d_ptr->notifyInvalidated = 1; - } while ((item = item->d_ptr->parent)); + d_ptr->invalidateGraphicsEffectsRecursively(); if (CacheMode(d_ptr->cacheMode) != NoCache) { // Invalidate cache. @@ -10721,6 +10735,7 @@ QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QP } pixmapPainter.end(); + return pixmap; } diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 6550362..8fd1a75 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -177,6 +177,7 @@ public: wantsActive(0), holesInSiblingIndex(0), sequentialOrdering(1), + updateDueToGraphicsEffect(0), globalStackingOrder(-1), q_ptr(0) { @@ -221,6 +222,7 @@ public: bool discardUpdateRequest(bool ignoreClipping = false, bool ignoreVisibleBit = false, bool ignoreDirtyBit = false, bool ignoreOpacity = false) const; int depth() const; + void invalidateGraphicsEffectsRecursively(); void invalidateDepthRecursively(); void resolveDepth(); void addChild(QGraphicsItem *child); @@ -502,6 +504,7 @@ public: quint32 wantsActive : 1; quint32 holesInSiblingIndex : 1; quint32 sequentialOrdering : 1; + quint32 updateDueToGraphicsEffect : 1; // Optional stacking order int globalStackingOrder; @@ -589,8 +592,11 @@ public: inline const QWidget *widget() const { return 0; } - inline void update() - { item->update(); } + inline void update() { + item->d_ptr->updateDueToGraphicsEffect = true; + item->update(); + item->d_ptr->updateDueToGraphicsEffect = false; + } inline void effectBoundingRectChanged() { item->prepareGeometryChange(); } @@ -619,6 +625,7 @@ public: QGraphicsItem *item; QGraphicsItemPaintInfo *info; + QTransform lastEffectTransform; }; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index a624b10..fc8ce8a 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -4569,6 +4569,11 @@ void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter * else painter->setWorldTransform(*transformPtr); painter->setOpacity(opacity); + + if (sourced->lastEffectTransform != painter->worldTransform()) { + sourced->lastEffectTransform = painter->worldTransform(); + sourced->invalidateCache(); + } item->d_ptr->graphicsEffect->draw(painter, source); painter->setWorldTransform(restoreTransform); sourced->info = 0; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index de08312..088197e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -93,6 +93,7 @@ # include "qx11info_x11.h" #endif +#include #include #include #ifdef Q_WS_MAC @@ -1806,12 +1807,29 @@ QRegion QWidgetPrivate::clipRegion() const return r; } +void QWidgetPrivate::invalidateGraphicsEffectsRecursively() +{ + Q_Q(QWidget); + QWidget *w = q; + do { + if (w->graphicsEffect()) { + QWidgetEffectSourcePrivate *sourced = + static_cast(w->graphicsEffect()->source()->d_func()); + if (!sourced->updateDueToGraphicsEffect) + w->graphicsEffect()->source()->d_func()->invalidateCache(); + } + w = w->parentWidget(); + } while (w); +} + void QWidgetPrivate::setDirtyOpaqueRegion() { Q_Q(QWidget); dirtyOpaqueChildren = true; + invalidateGraphicsEffectsRecursively(); + if (q->isWindow()) return; @@ -5215,6 +5233,10 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP paintEngine->d_func()->systemClip = QRegion(); } else { context.painter = sharedPainter; + if (sharedPainter->worldTransform() != sourced->lastEffectTransform) { + sourced->invalidateCache(); + sourced->lastEffectTransform = sharedPainter->worldTransform(); + } sharedPainter->save(); sharedPainter->translate(offset); graphicsEffect->draw(sharedPainter, source); diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index f7c2712..a109f32 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -360,6 +360,7 @@ public: void setOpaque(bool opaque); void updateIsTranslucent(); bool paintOnScreen() const; + void invalidateGraphicsEffectsRecursively(); QRegion getOpaqueRegion() const; const QRegion &getOpaqueChildren() const; @@ -729,7 +730,7 @@ class QWidgetEffectSourcePrivate : public QGraphicsEffectSourcePrivate { public: QWidgetEffectSourcePrivate(QWidget *widget) - : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0) + : QGraphicsEffectSourcePrivate(), m_widget(widget), context(0), updateDueToGraphicsEffect(false) {} inline void detach() @@ -742,7 +743,11 @@ public: { return m_widget; } inline void update() - { m_widget->update(); } + { + updateDueToGraphicsEffect = true; + m_widget->update(); + updateDueToGraphicsEffect = false; + } inline bool isPixmap() const { return false; } @@ -754,7 +759,7 @@ public: if (QWidget *parent = m_widget->parentWidget()) parent->update(); else - m_widget->update(); + update(); } inline const QStyleOption *styleOption() const @@ -769,6 +774,8 @@ public: QWidget *m_widget; QWidgetPaintContext *context; + QTransform lastEffectTransform; + bool updateDueToGraphicsEffect; }; inline QWExtra *QWidgetPrivate::extraData() const diff --git a/src/gui/painting/qbackingstore.cpp b/src/gui/painting/qbackingstore.cpp index 7c07df8..3cd1402 100644 --- a/src/gui/painting/qbackingstore.cpp +++ b/src/gui/painting/qbackingstore.cpp @@ -56,6 +56,7 @@ #include #include #include +#include #include "qgraphicssystem_p.h" @@ -540,6 +541,8 @@ void QWidgetBackingStore::markDirty(const QRegion &rgn, QWidget *widget, bool up Q_ASSERT(widget->window() == tlw); Q_ASSERT(!rgn.isEmpty()); + widget->d_func()->invalidateGraphicsEffectsRecursively(); + if (widget->d_func()->paintOnScreen()) { if (widget->d_func()->dirty.isEmpty()) { widget->d_func()->dirty = rgn; @@ -615,6 +618,8 @@ void QWidgetBackingStore::markDirty(const QRect &rect, QWidget *widget, bool upd Q_ASSERT(widget->window() == tlw); Q_ASSERT(!rect.isEmpty()); + widget->d_func()->invalidateGraphicsEffectsRecursively(); + if (widget->d_func()->paintOnScreen()) { if (widget->d_func()->dirty.isEmpty()) { widget->d_func()->dirty = QRegion(rect); -- cgit v0.12 From 363c2d0ee8342a014282326b6c660a9a0e919423 Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 22 Oct 2009 18:54:33 +0200 Subject: Fix def file error for qtcore Problem caused by freezing with wrong openC version in environment Reviewed-by: TrustMe --- src/s60installs/eabi/QtCoreu.def | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/s60installs/eabi/QtCoreu.def b/src/s60installs/eabi/QtCoreu.def index 33df9fe..2ecc48f 100644 --- a/src/s60installs/eabi/QtCoreu.def +++ b/src/s60installs/eabi/QtCoreu.def @@ -3577,6 +3577,4 @@ EXPORTS uncompress @ 3576 NONAME zError @ 3577 NONAME zlibVersion @ 3578 NONAME - _ZNSsC1EPKcRKSaIcE @ 3579 NONAME - _ZNSsC2EPKcRKSaIcE @ 3580 NONAME -- cgit v0.12 From 18acf933474577a4cec31560eeee22de04111e1e Mon Sep 17 00:00:00 2001 From: Shane Kearns Date: Thu, 22 Oct 2009 18:59:09 +0200 Subject: QtGui def file update Two new APIs in QDesktopWidget --- src/s60installs/eabi/QtGuiu.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/s60installs/eabi/QtGuiu.def b/src/s60installs/eabi/QtGuiu.def index 0e1bc43..ae69475 100644 --- a/src/s60installs/eabi/QtGuiu.def +++ b/src/s60installs/eabi/QtGuiu.def @@ -11613,4 +11613,6 @@ EXPORTS _Zls6QDebug6QFlagsIN6QStyle9StateFlagEE @ 11612 NONAME _Zls6QDebugRK12QStyleOption @ 11613 NONAME _Zls6QDebugRKN12QStyleOption10OptionTypeE @ 11614 NONAME + _ZNK14QDesktopWidget14screenGeometryEPK7QWidget @ 11615 NONAME + _ZNK14QDesktopWidget17availableGeometryEPK7QWidget @ 11616 NONAME -- cgit v0.12 From 7856c0397a42d26fa4fdd3ead3df7886b408b8ed Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Thu, 22 Oct 2009 20:15:36 +0200 Subject: Compile fix. QPanGesture was changed to use QPointF instead of QSizeF, also need to change all usages of the pan gesture. Reviewed-by: trustme --- examples/gestures/imagegestures/imagewidget.cpp | 6 ++-- src/gui/kernel/qmacgesturerecognizer_mac.mm | 8 ++--- tests/manual/gestures/graphicsview/main.cpp | 6 ++-- .../graphicsview/mousepangesturerecognizer.cpp | 10 +++--- tests/manual/gestures/scrollarea/main.cpp | 36 +++++++++++----------- .../scrollarea/mousepangesturerecognizer.cpp | 10 +++--- 6 files changed, 38 insertions(+), 38 deletions(-) diff --git a/examples/gestures/imagegestures/imagewidget.cpp b/examples/gestures/imagegestures/imagewidget.cpp index 95525c5..28de6da 100644 --- a/examples/gestures/imagegestures/imagewidget.cpp +++ b/examples/gestures/imagegestures/imagewidget.cpp @@ -128,9 +128,9 @@ void ImageWidget::panTriggered(QPanGesture *gesture) setCursor(Qt::ArrowCursor); } #endif - QSizeF lastOffset = gesture->offset(); - horizontalOffset += lastOffset.width(); - verticalOffset += lastOffset.height(); + QPointF lastOffset = gesture->offset(); + horizontalOffset += lastOffset.x(); + verticalOffset += lastOffset.y(); update(); } diff --git a/src/gui/kernel/qmacgesturerecognizer_mac.mm b/src/gui/kernel/qmacgesturerecognizer_mac.mm index 7b19a54..7019580 100644 --- a/src/gui/kernel/qmacgesturerecognizer_mac.mm +++ b/src/gui/kernel/qmacgesturerecognizer_mac.mm @@ -218,7 +218,7 @@ QMacPanGestureRecognizer::filterEvent(QGesture *gesture, QObject *target, QEvent const QPointF p = QCursor::pos(); const QPointF posOffset = p - _lastPos; g->setLastOffset(g->offset()); - g->setOffset(QSizeF(posOffset.x(), posOffset.y())); + g->setOffset(QPointF(posOffset.x(), posOffset.y())); g->setTotalOffset(g->lastOffset() + g->offset()); _lastPos = p; return QGestureRecognizer::GestureTriggered; @@ -256,9 +256,9 @@ void QMacPanGestureRecognizer::reset(QGesture *gesture) _startPos = QPointF(); _lastPos = QPointF(); _panCanceled = true; - g->setOffset(QSizeF(0, 0)); - g->setLastOffset(QSizeF(0, 0)); - g->setTotalOffset(QSizeF(0, 0)); + g->setOffset(QPointF(0, 0)); + g->setLastOffset(QPointF(0, 0)); + g->setTotalOffset(QPointF(0, 0)); g->setAcceleration(qreal(1)); QGestureRecognizer::reset(gesture); } diff --git a/tests/manual/gestures/graphicsview/main.cpp b/tests/manual/gestures/graphicsview/main.cpp index b4d74e4..e9065eb 100644 --- a/tests/manual/gestures/graphicsview/main.cpp +++ b/tests/manual/gestures/graphicsview/main.cpp @@ -66,11 +66,11 @@ protected: default: qDebug("view: Pan: "); break; } - const QSizeF offset = pan->offset(); + const QPointF offset = pan->offset(); QScrollBar *vbar = verticalScrollBar(); QScrollBar *hbar = horizontalScrollBar(); - vbar->setValue(vbar->value() - offset.height()); - hbar->setValue(hbar->value() - offset.width()); + vbar->setValue(vbar->value() - offset.y()); + hbar->setValue(hbar->value() - offset.x()); ge->accept(pan); return true; } diff --git a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp index acd525f..6cdbe12 100644 --- a/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/graphicsview/mousepangesturerecognizer.cpp @@ -87,8 +87,8 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat QPoint lastPos = g->property("lastPos").toPoint(); g->setLastOffset(g->offset()); lastPos = pos - lastPos; - g->setOffset(QSizeF(lastPos.x(), lastPos.y())); - g->setTotalOffset(g->totalOffset() + QSizeF(lastPos.x(), lastPos.y())); + g->setOffset(QPointF(lastPos.x(), lastPos.y())); + g->setTotalOffset(g->totalOffset() + QPointF(lastPos.x(), lastPos.y())); g->setProperty("lastPos", pos); return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; } @@ -102,9 +102,9 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat void MousePanGestureRecognizer::reset(QGesture *state) { QPanGesture *g = static_cast(state); - g->setTotalOffset(QSizeF()); - g->setLastOffset(QSizeF()); - g->setOffset(QSizeF()); + g->setTotalOffset(QPointF()); + g->setLastOffset(QPointF()); + g->setOffset(QPointF()); g->setAcceleration(0); g->setProperty("lastPos", QVariant()); g->setProperty("pressed", QVariant::fromValue(false)); diff --git a/tests/manual/gestures/scrollarea/main.cpp b/tests/manual/gestures/scrollarea/main.cpp index 2796637..f90f6c6 100644 --- a/tests/manual/gestures/scrollarea/main.cpp +++ b/tests/manual/gestures/scrollarea/main.cpp @@ -87,23 +87,23 @@ protected: if (outside) return; - const QSizeF offset = pan->offset(); - const QSizeF totalOffset = pan->totalOffset(); + const QPointF offset = pan->offset(); + const QPointF totalOffset = pan->totalOffset(); QScrollBar *vbar = verticalScrollBar(); QScrollBar *hbar = horizontalScrollBar(); - if ((vbar->value() == vbar->minimum() && totalOffset.height() > 10) || - (vbar->value() == vbar->maximum() && totalOffset.height() < -10)) { + if ((vbar->value() == vbar->minimum() && totalOffset.y() > 10) || + (vbar->value() == vbar->maximum() && totalOffset.y() < -10)) { outside = true; return; } - if ((hbar->value() == hbar->minimum() && totalOffset.width() > 10) || - (hbar->value() == hbar->maximum() && totalOffset.width() < -10)) { + if ((hbar->value() == hbar->minimum() && totalOffset.x() > 10) || + (hbar->value() == hbar->maximum() && totalOffset.x() < -10)) { outside = true; return; } - vbar->setValue(vbar->value() - offset.height()); - hbar->setValue(hbar->value() - offset.width()); + vbar->setValue(vbar->value() - offset.y()); + hbar->setValue(hbar->value() - offset.x()); event->accept(pan); } } @@ -147,28 +147,28 @@ protected: event->ignore(pan); if (outside) return; - const QSizeF offset = pan->offset(); - const QSizeF totalOffset = pan->totalOffset(); + const QPointF offset = pan->offset(); + const QPointF totalOffset = pan->totalOffset(); if (orientation() == Qt::Horizontal) { - if ((value() == minimum() && totalOffset.width() < -10) || - (value() == maximum() && totalOffset.width() > 10)) { + if ((value() == minimum() && totalOffset.x() < -10) || + (value() == maximum() && totalOffset.x() > 10)) { outside = true; return; } - if (totalOffset.height() < 40 && totalOffset.height() > -40) { - setValue(value() + offset.width()); + if (totalOffset.y() < 40 && totalOffset.y() > -40) { + setValue(value() + offset.x()); event->accept(pan); } else { outside = true; } } else if (orientation() == Qt::Vertical) { - if ((value() == maximum() && totalOffset.height() < -10) || - (value() == minimum() && totalOffset.height() > 10)) { + if ((value() == maximum() && totalOffset.y() < -10) || + (value() == minimum() && totalOffset.y() > 10)) { outside = true; return; } - if (totalOffset.width() < 40 && totalOffset.width() > -40) { - setValue(value() - offset.height()); + if (totalOffset.x() < 40 && totalOffset.x() > -40) { + setValue(value() - offset.y()); event->accept(pan); } else { outside = true; diff --git a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp index 79b633e..5f94dbc 100644 --- a/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp +++ b/tests/manual/gestures/scrollarea/mousepangesturerecognizer.cpp @@ -69,8 +69,8 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat QPoint lastPos = g->property("lastPos").toPoint(); g->setLastOffset(g->offset()); lastPos = pos - lastPos; - g->setOffset(QSizeF(lastPos.x(), lastPos.y())); - g->setTotalOffset(g->totalOffset() + QSizeF(lastPos.x(), lastPos.y())); + g->setOffset(QPointF(lastPos.x(), lastPos.y())); + g->setTotalOffset(g->totalOffset() + QPointF(lastPos.x(), lastPos.y())); g->setProperty("lastPos", pos); return QGestureRecognizer::GestureTriggered | QGestureRecognizer::ConsumeEventHint; } @@ -84,9 +84,9 @@ QGestureRecognizer::Result MousePanGestureRecognizer::filterEvent(QGesture *stat void MousePanGestureRecognizer::reset(QGesture *state) { QPanGesture *g = static_cast(state); - g->setTotalOffset(QSizeF()); - g->setLastOffset(QSizeF()); - g->setOffset(QSizeF()); + g->setTotalOffset(QPointF()); + g->setLastOffset(QPointF()); + g->setOffset(QPointF()); g->setAcceleration(0); g->setProperty("lastPos", QVariant()); g->setProperty("pressed", QVariant::fromValue(false)); -- cgit v0.12 From 96db5d5367344e1cfd474991cb8d6992776db186 Mon Sep 17 00:00:00 2001 From: Anders Bakken Date: Thu, 22 Oct 2009 11:28:49 -0700 Subject: Remove declaration of QDirectFBScreen::scroll This function has been declared since the initial commit but was never actually implemented. The function exists in QDirectFBWindowSurface. Reviewed-by: Donald Carr --- src/plugins/gfxdrivers/directfb/qdirectfbscreen.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h index 0520cdc..6330582 100644 --- a/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h +++ b/src/plugins/gfxdrivers/directfb/qdirectfbscreen.h @@ -154,7 +154,6 @@ public: void shutdownDevice(); void exposeRegion(QRegion r, int changing); - void scroll(const QRegion ®ion, const QPoint &offset); void solidFill(const QColor &color, const QRegion ®ion); void setMode(int width, int height, int depth); -- cgit v0.12 From 5baebfc68dd67def412bcbaa7c61b43d05e6ee42 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Thu, 22 Oct 2009 18:43:22 +0200 Subject: Update mkdist-webkit script with latest tag. Not-reviewed: No-big-deal --- util/webkit/mkdist-webkit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index 9611d38..f88f10e 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -5,7 +5,7 @@ die() { exit 1 } -default_tag="qtwebkit-4.6-snapshot-30092009-2" +default_tag="qtwebkit-4.6-snapshot-22102009" if [ $# -eq 0 ]; then tag="$default_tag" -- cgit v0.12 From 57f1983c164bc8553c6b6aa7ac320f00e5405548 Mon Sep 17 00:00:00 2001 From: Jocelyn Turcotte Date: Thu, 22 Oct 2009 19:50:52 +0200 Subject: Updated WebKit from /home/jturcott/dev/webkit/ to qtwebkit-4.6-snapshot-22102009 ( 0639bb8e812c8923287cd5523248ca64fa5f7a50 ) Changes in WebKit/qt since the last update: Jocelyn: fatal error from script, sha1 in src/3rdparty/webkit/VERSION is bad --- src/3rdparty/webkit/ChangeLog | 111 + src/3rdparty/webkit/JavaScriptCore/API/APICast.h | 2 + .../JavaScriptCore/API/JSCallbackConstructor.h | 5 +- .../webkit/JavaScriptCore/API/JSCallbackFunction.h | 2 +- .../webkit/JavaScriptCore/API/JSCallbackObject.h | 5 +- .../webkit/JavaScriptCore/API/JSContextRef.cpp | 10 + .../JavaScriptCore/API/JSContextRefPrivate.h | 53 + src/3rdparty/webkit/JavaScriptCore/ChangeLog | 1167 ++- .../webkit/JavaScriptCore/JavaScriptCore.gypi | 2 +- .../webkit/JavaScriptCore/JavaScriptCore.pri | 7 +- .../webkit/JavaScriptCore/JavaScriptCore.pro | 1 - .../assembler/MacroAssemblerCodeRef.h | 6 + .../webkit/JavaScriptCore/bytecode/CodeBlock.cpp | 47 +- .../webkit/JavaScriptCore/bytecode/Opcode.h | 4 +- .../bytecompiler/BytecodeGenerator.cpp | 112 +- .../bytecompiler/BytecodeGenerator.h | 4 +- .../webkit/JavaScriptCore/bytecompiler/Label.h | 14 +- .../JavaScriptCore/debugger/DebuggerActivation.h | 5 +- .../webkit/JavaScriptCore/generated/Grammar.cpp | 2 +- .../JavaScriptCore/generated/StringPrototype.lut.h | 7 +- .../JavaScriptCore/interpreter/Interpreter.cpp | 775 +- .../JavaScriptCore/interpreter/Interpreter.h | 1 - .../JavaScriptCore/jit/ExecutableAllocator.h | 3 + .../jit/ExecutableAllocatorSymbian.cpp | 75 + src/3rdparty/webkit/JavaScriptCore/jit/JIT.cpp | 10 +- src/3rdparty/webkit/JavaScriptCore/jit/JIT.h | 3 + .../webkit/JavaScriptCore/jit/JITArithmetic.cpp | 60 +- src/3rdparty/webkit/JavaScriptCore/jit/JITCall.cpp | 32 +- .../webkit/JavaScriptCore/jit/JITOpcodes.cpp | 518 +- .../JavaScriptCore/jit/JITPropertyAccess.cpp | 182 +- .../webkit/JavaScriptCore/jit/JITStubCall.h | 20 +- .../webkit/JavaScriptCore/jit/JITStubs.cpp | 96 +- src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.h | 5 +- src/3rdparty/webkit/JavaScriptCore/jsc.cpp | 1 + src/3rdparty/webkit/JavaScriptCore/jsc.pro | 31 - .../webkit/JavaScriptCore/parser/Grammar.y | 2 +- .../webkit/JavaScriptCore/parser/Lexer.cpp | 6 - src/3rdparty/webkit/JavaScriptCore/parser/Lexer.h | 6 + .../webkit/JavaScriptCore/parser/Nodes.cpp | 12 +- .../webkit/JavaScriptCore/parser/ParserArena.h | 2 +- .../webkit/JavaScriptCore/runtime/Arguments.h | 5 +- .../JavaScriptCore/runtime/ArrayConstructor.cpp | 2 +- .../JavaScriptCore/runtime/ArrayPrototype.cpp | 51 +- .../webkit/JavaScriptCore/runtime/BooleanObject.h | 2 +- .../webkit/JavaScriptCore/runtime/Collector.cpp | 58 +- .../webkit/JavaScriptCore/runtime/Collector.h | 10 - .../webkit/JavaScriptCore/runtime/DateInstance.cpp | 9 + .../webkit/JavaScriptCore/runtime/DateInstance.h | 3 +- .../webkit/JavaScriptCore/runtime/DatePrototype.h | 6 +- .../JavaScriptCore/runtime/ExceptionHelpers.cpp | 5 + .../JavaScriptCore/runtime/ExceptionHelpers.h | 1 + .../JavaScriptCore/runtime/FunctionPrototype.h | 2 +- .../webkit/JavaScriptCore/runtime/GetterSetter.h | 2 +- .../JavaScriptCore/runtime/GlobalEvalFunction.h | 5 +- .../JavaScriptCore/runtime/InternalFunction.h | 4 +- .../JavaScriptCore/runtime/JSAPIValueWrapper.h | 2 +- .../webkit/JavaScriptCore/runtime/JSActivation.h | 5 +- .../webkit/JavaScriptCore/runtime/JSArray.cpp | 121 +- .../webkit/JavaScriptCore/runtime/JSArray.h | 24 +- .../webkit/JavaScriptCore/runtime/JSByteArray.cpp | 2 +- .../webkit/JavaScriptCore/runtime/JSByteArray.h | 3 + .../webkit/JavaScriptCore/runtime/JSCell.cpp | 4 - .../webkit/JavaScriptCore/runtime/JSCell.h | 17 - .../webkit/JavaScriptCore/runtime/JSFunction.h | 5 +- .../JavaScriptCore/runtime/JSGlobalObject.cpp | 21 +- .../webkit/JavaScriptCore/runtime/JSGlobalObject.h | 5 +- .../webkit/JavaScriptCore/runtime/JSNotAnObject.h | 5 +- .../webkit/JavaScriptCore/runtime/JSNumberCell.h | 10 +- .../webkit/JavaScriptCore/runtime/JSONObject.h | 5 +- .../webkit/JavaScriptCore/runtime/JSObject.cpp | 40 +- .../webkit/JavaScriptCore/runtime/JSObject.h | 8 +- .../runtime/JSPropertyNameIterator.cpp | 48 +- .../runtime/JSPropertyNameIterator.h | 85 +- .../JavaScriptCore/runtime/JSStaticScopeObject.h | 5 +- .../webkit/JavaScriptCore/runtime/JSString.cpp | 41 - .../webkit/JavaScriptCore/runtime/JSString.h | 43 +- .../webkit/JavaScriptCore/runtime/JSTypeInfo.h | 12 +- .../webkit/JavaScriptCore/runtime/JSValue.cpp | 5 +- .../webkit/JavaScriptCore/runtime/JSValue.h | 26 +- .../JavaScriptCore/runtime/JSVariableObject.h | 3 +- .../JavaScriptCore/runtime/JSWrapperObject.h | 2 +- .../webkit/JavaScriptCore/runtime/MarkStack.h | 2 +- .../webkit/JavaScriptCore/runtime/MathObject.h | 5 +- .../JavaScriptCore/runtime/NumberConstructor.h | 5 +- .../webkit/JavaScriptCore/runtime/NumberObject.h | 14 +- .../JavaScriptCore/runtime/ObjectConstructor.cpp | 1 + .../webkit/JavaScriptCore/runtime/Operations.h | 27 +- .../JavaScriptCore/runtime/PropertyNameArray.cpp | 5 +- .../JavaScriptCore/runtime/PropertyNameArray.h | 35 +- .../webkit/JavaScriptCore/runtime/Protect.h | 2 +- .../JavaScriptCore/runtime/RegExpConstructor.cpp | 46 - .../JavaScriptCore/runtime/RegExpConstructor.h | 52 +- .../webkit/JavaScriptCore/runtime/RegExpObject.cpp | 2 +- .../webkit/JavaScriptCore/runtime/RegExpObject.h | 5 +- .../webkit/JavaScriptCore/runtime/StringObject.h | 3 +- .../StringObjectThatMasqueradesAsUndefined.h | 4 +- .../JavaScriptCore/runtime/StringPrototype.cpp | 63 +- .../webkit/JavaScriptCore/runtime/Structure.cpp | 87 +- .../webkit/JavaScriptCore/runtime/Structure.h | 17 +- .../JavaScriptCore/runtime/StructureChain.cpp | 14 - .../webkit/JavaScriptCore/runtime/StructureChain.h | 3 +- src/3rdparty/webkit/JavaScriptCore/wscript | 2 +- .../JavaScriptCore/wtf/CrossThreadRefCounted.h | 14 +- .../webkit/JavaScriptCore/wtf/FastMalloc.cpp | 6 +- .../webkit/JavaScriptCore/wtf/FastMalloc.h | 5 + .../webkit/JavaScriptCore/wtf/ListRefPtr.h | 3 + .../webkit/JavaScriptCore/wtf/MathExtras.h | 2 + src/3rdparty/webkit/JavaScriptCore/wtf/Platform.h | 96 +- .../webkit/JavaScriptCore/wtf/RandomNumber.cpp | 17 + .../webkit/JavaScriptCore/wtf/StringExtras.h | 4 +- .../webkit/JavaScriptCore/yarr/RegexJIT.cpp | 8 - src/3rdparty/webkit/JavaScriptCore/yarr/RegexJIT.h | 9 +- src/3rdparty/webkit/VERSION | 4 +- src/3rdparty/webkit/WebCore/ChangeLog | 9158 +++++++++++++++++++- src/3rdparty/webkit/WebCore/DerivedSources.cpp | 2 + .../ForwardingHeaders/runtime/ExceptionHelpers.h | 4 + .../WebCore/ForwardingHeaders/runtime/JSCell.h | 4 + .../ForwardingHeaders/runtime/StructureChain.h | 5 + .../webkit/WebCore/WebCore.3DRendering.exp | 1 + .../webkit/WebCore/WebCore.SVG.Filters.exp | 1 + src/3rdparty/webkit/WebCore/WebCore.Video.exp | 14 + src/3rdparty/webkit/WebCore/WebCore.gypi | 47 +- src/3rdparty/webkit/WebCore/WebCore.order | 1 + src/3rdparty/webkit/WebCore/WebCore.pro | 134 +- src/3rdparty/webkit/WebCore/WebCore.qrc | 3 - .../accessibility/AccessibilityMediaControls.cpp | 3 + .../WebCore/bindings/ScriptControllerBase.cpp | 84 + .../WebCore/bindings/js/JSAbstractWorkerCustom.cpp | 8 - .../webkit/WebCore/bindings/js/JSCallbackData.cpp | 77 + .../webkit/WebCore/bindings/js/JSCallbackData.h | 70 + .../bindings/js/JSCanvasArrayBufferConstructor.h | 3 +- .../WebCore/bindings/js/JSCanvasArrayCustom.cpp | 33 +- .../bindings/js/JSCustomPositionCallback.cpp | 34 +- .../WebCore/bindings/js/JSCustomPositionCallback.h | 9 +- .../bindings/js/JSCustomPositionErrorCallback.cpp | 33 +- .../bindings/js/JSCustomPositionErrorCallback.h | 8 +- .../bindings/js/JSCustomSQLStatementCallback.cpp | 45 +- .../bindings/js/JSCustomSQLStatementCallback.h | 8 +- .../js/JSCustomSQLStatementErrorCallback.cpp | 59 +- .../js/JSCustomSQLStatementErrorCallback.h | 10 +- .../bindings/js/JSCustomSQLTransactionCallback.cpp | 69 +- .../bindings/js/JSCustomSQLTransactionCallback.h | 6 +- .../js/JSCustomSQLTransactionErrorCallback.cpp | 48 +- .../js/JSCustomSQLTransactionErrorCallback.h | 6 +- .../WebCore/bindings/js/JSCustomVoidCallback.cpp | 43 +- .../WebCore/bindings/js/JSCustomVoidCallback.h | 7 +- .../bindings/js/JSDOMApplicationCacheCustom.cpp | 8 - .../webkit/WebCore/bindings/js/JSDOMBinding.cpp | 5 + .../webkit/WebCore/bindings/js/JSDOMBinding.h | 7 +- .../WebCore/bindings/js/JSDOMGlobalObject.cpp | 2 +- .../webkit/WebCore/bindings/js/JSDOMGlobalObject.h | 6 + .../webkit/WebCore/bindings/js/JSDOMWindowBase.cpp | 11 +- .../webkit/WebCore/bindings/js/JSDOMWindowBase.h | 9 +- .../WebCore/bindings/js/JSDOMWindowCustom.cpp | 28 +- .../webkit/WebCore/bindings/js/JSDOMWindowShell.h | 4 +- .../bindings/js/JSDesktopNotificationsCustom.cpp | 12 +- .../WebCore/bindings/js/JSDocumentCustom.cpp | 2 +- .../webkit/WebCore/bindings/js/JSEventCustom.cpp | 5 +- .../WebCore/bindings/js/JSEventSourceCustom.cpp | 8 - .../webkit/WebCore/bindings/js/JSExceptionBase.cpp | 64 + .../webkit/WebCore/bindings/js/JSExceptionBase.h | 43 + .../WebCore/bindings/js/JSHTMLAllCollection.h | 4 +- .../bindings/js/JSInspectorBackendCustom.cpp | 43 +- .../WebCore/bindings/js/JSLocationCustom.cpp | 4 +- .../WebCore/bindings/js/JSMessageEventCustom.cpp | 2 +- .../WebCore/bindings/js/JSMessagePortCustom.cpp | 8 - .../WebCore/bindings/js/JSMessagePortCustom.h | 2 +- .../webkit/WebCore/bindings/js/JSNodeCustom.cpp | 16 - .../bindings/js/JSQuarantinedObjectWrapper.h | 4 +- .../bindings/js/JSSVGElementInstanceCustom.cpp | 8 - .../WebCore/bindings/js/JSWebSocketCustom.cpp | 21 +- .../WebCore/bindings/js/JSXMLHttpRequestCustom.cpp | 8 - .../bindings/js/JSXMLHttpRequestUploadCustom.cpp | 8 - .../webkit/WebCore/bindings/js/ScheduledAction.cpp | 2 +- .../webkit/WebCore/bindings/js/ScheduledAction.h | 1 + .../WebCore/bindings/js/ScriptCachedFrameData.cpp | 2 +- .../WebCore/bindings/js/ScriptController.cpp | 6 +- .../webkit/WebCore/bindings/js/ScriptController.h | 8 + .../webkit/WebCore/bindings/js/ScriptObject.cpp | 8 + .../webkit/WebCore/bindings/js/ScriptObject.h | 1 + .../WebCore/bindings/js/SerializedScriptValue.cpp | 839 ++ .../WebCore/bindings/js/SerializedScriptValue.h | 199 + .../WebCore/bindings/scripts/CodeGenerator.pm | 14 + .../WebCore/bindings/scripts/CodeGeneratorCOM.pm | 16 +- .../WebCore/bindings/scripts/CodeGeneratorJS.pm | 99 +- .../WebCore/bindings/scripts/CodeGeneratorObjC.pm | 43 +- .../WebCore/bindings/scripts/CodeGeneratorV8.pm | 396 +- src/3rdparty/webkit/WebCore/bridge/IdentifierRep.h | 3 +- .../webkit/WebCore/bridge/c/c_instance.cpp | 18 +- src/3rdparty/webkit/WebCore/bridge/npapi.h | 13 +- src/3rdparty/webkit/WebCore/bridge/qt/qt_runtime.h | 2 +- src/3rdparty/webkit/WebCore/bridge/runtime_array.h | 3 +- .../webkit/WebCore/bridge/runtime_method.h | 3 +- .../webkit/WebCore/bridge/runtime_object.h | 3 +- src/3rdparty/webkit/WebCore/bridge/runtime_root.h | 2 + .../WebCore/css/CSSComputedStyleDeclaration.cpp | 22 +- src/3rdparty/webkit/WebCore/css/CSSGrammar.y | 4 +- src/3rdparty/webkit/WebCore/css/CSSParser.cpp | 34 +- src/3rdparty/webkit/WebCore/css/CSSParserValues.h | 2 +- .../webkit/WebCore/css/CSSPrimitiveValue.cpp | 105 +- .../webkit/WebCore/css/CSSPrimitiveValueMappings.h | 78 +- .../webkit/WebCore/css/CSSPropertyNames.in | 3 +- src/3rdparty/webkit/WebCore/css/CSSSelector.cpp | 12 +- src/3rdparty/webkit/WebCore/css/CSSSelector.h | 3 +- .../webkit/WebCore/css/CSSStyleSelector.cpp | 23 +- .../webkit/WebCore/css/CSSValueKeywords.in | 7 + .../WebCore/css/SVGCSSComputedStyleDeclaration.cpp | 2 - src/3rdparty/webkit/WebCore/css/SVGCSSParser.cpp | 6 - .../webkit/WebCore/css/SVGCSSPropertyNames.in | 2 +- .../webkit/WebCore/css/SVGCSSStyleSelector.cpp | 7 - .../webkit/WebCore/css/SVGCSSValueKeywords.in | 9 +- src/3rdparty/webkit/WebCore/css/html.css | 5 + src/3rdparty/webkit/WebCore/css/makevalues.pl | 2 +- .../webkit/WebCore/css/mediaControlsChromium.css | 6 +- .../webkit/WebCore/css/mediaControlsQT.css | 177 - .../webkit/WebCore/css/mediaControlsQt.css | 138 + .../webkit/WebCore/css/mediaControlsQuickTime.css | 177 + .../webkit/WebCore/css/qt/mediaControls-extras.css | 101 - src/3rdparty/webkit/WebCore/dom/BeforeLoadEvent.h | 67 + .../webkit/WebCore/dom/BeforeLoadEvent.idl | 39 + src/3rdparty/webkit/WebCore/dom/ContainerNode.cpp | 12 + src/3rdparty/webkit/WebCore/dom/ContainerNode.h | 2 + src/3rdparty/webkit/WebCore/dom/Document.cpp | 123 +- src/3rdparty/webkit/WebCore/dom/Document.h | 4 +- src/3rdparty/webkit/WebCore/dom/Document.idl | 3 + src/3rdparty/webkit/WebCore/dom/Element.cpp | 3 +- src/3rdparty/webkit/WebCore/dom/Event.cpp | 7 + src/3rdparty/webkit/WebCore/dom/Event.h | 7 + src/3rdparty/webkit/WebCore/dom/EventNames.h | 2 +- src/3rdparty/webkit/WebCore/dom/ExceptionBase.cpp | 1 + src/3rdparty/webkit/WebCore/dom/ExceptionBase.h | 2 + src/3rdparty/webkit/WebCore/dom/ExceptionCode.cpp | 60 + src/3rdparty/webkit/WebCore/dom/ExceptionCode.h | 1 + src/3rdparty/webkit/WebCore/dom/MessageEvent.cpp | 7 +- src/3rdparty/webkit/WebCore/dom/MessageEvent.h | 13 +- src/3rdparty/webkit/WebCore/dom/MessageEvent.idl | 6 +- src/3rdparty/webkit/WebCore/dom/MessagePort.cpp | 6 +- src/3rdparty/webkit/WebCore/dom/MessagePort.h | 6 +- .../webkit/WebCore/dom/MessagePortChannel.cpp | 6 +- .../webkit/WebCore/dom/MessagePortChannel.h | 11 +- .../webkit/WebCore/dom/MouseRelatedEvent.cpp | 4 +- .../webkit/WebCore/dom/ProcessingInstruction.cpp | 22 +- src/3rdparty/webkit/WebCore/dom/QualifiedName.cpp | 7 + src/3rdparty/webkit/WebCore/dom/QualifiedName.h | 10 +- src/3rdparty/webkit/WebCore/dom/ScriptElement.cpp | 3 + src/3rdparty/webkit/WebCore/dom/StyledElement.cpp | 4 +- src/3rdparty/webkit/WebCore/dom/XMLTokenizer.cpp | 6 +- .../webkit/WebCore/dom/XMLTokenizerLibxml2.cpp | 9 +- src/3rdparty/webkit/WebCore/dom/XMLTokenizerQt.cpp | 5 +- .../webkit/WebCore/editing/ApplyStyleCommand.cpp | 89 +- .../webkit/WebCore/editing/ApplyStyleCommand.h | 1 + .../webkit/WebCore/editing/EditorCommand.cpp | 48 +- .../WebCore/editing/IndentOutdentCommand.cpp | 140 +- .../webkit/WebCore/editing/IndentOutdentCommand.h | 6 +- .../WebCore/editing/ReplaceSelectionCommand.cpp | 13 + .../webkit/WebCore/editing/VisibleSelection.cpp | 2 +- src/3rdparty/webkit/WebCore/editing/markup.cpp | 10 +- .../webkit/WebCore/generated/CSSGrammar.cpp | 1050 ++- .../webkit/WebCore/generated/CSSPropertyNames.cpp | 374 +- .../webkit/WebCore/generated/CSSPropertyNames.h | 362 +- .../webkit/WebCore/generated/CSSValueKeywords.c | 777 +- .../webkit/WebCore/generated/CSSValueKeywords.h | 455 +- src/3rdparty/webkit/WebCore/generated/Grammar.cpp | 2 +- .../webkit/WebCore/generated/HTMLNames.cpp | 8 +- src/3rdparty/webkit/WebCore/generated/HTMLNames.h | 2 +- .../webkit/WebCore/generated/JSAbstractWorker.cpp | 5 +- .../webkit/WebCore/generated/JSAbstractWorker.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSAttr.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSAttr.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSBarInfo.h | 10 +- .../webkit/WebCore/generated/JSBeforeLoadEvent.cpp | 188 + .../webkit/WebCore/generated/JSBeforeLoadEvent.h | 78 + .../webkit/WebCore/generated/JSCDATASection.cpp | 5 +- .../webkit/WebCore/generated/JSCDATASection.h | 10 +- .../webkit/WebCore/generated/JSCSSCharsetRule.cpp | 5 +- .../webkit/WebCore/generated/JSCSSCharsetRule.h | 10 +- .../webkit/WebCore/generated/JSCSSFontFaceRule.cpp | 5 +- .../webkit/WebCore/generated/JSCSSFontFaceRule.h | 10 +- .../webkit/WebCore/generated/JSCSSImportRule.cpp | 5 +- .../webkit/WebCore/generated/JSCSSImportRule.h | 10 +- .../webkit/WebCore/generated/JSCSSMediaRule.cpp | 5 +- .../webkit/WebCore/generated/JSCSSMediaRule.h | 8 +- .../webkit/WebCore/generated/JSCSSPageRule.cpp | 5 +- .../webkit/WebCore/generated/JSCSSPageRule.h | 10 +- .../WebCore/generated/JSCSSPrimitiveValue.cpp | 5 +- .../webkit/WebCore/generated/JSCSSPrimitiveValue.h | 8 +- .../webkit/WebCore/generated/JSCSSRule.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSCSSRule.h | 8 +- .../webkit/WebCore/generated/JSCSSRuleList.cpp | 5 +- .../webkit/WebCore/generated/JSCSSRuleList.h | 8 +- .../WebCore/generated/JSCSSStyleDeclaration.cpp | 5 +- .../WebCore/generated/JSCSSStyleDeclaration.h | 8 +- .../webkit/WebCore/generated/JSCSSStyleRule.cpp | 5 +- .../webkit/WebCore/generated/JSCSSStyleRule.h | 10 +- .../webkit/WebCore/generated/JSCSSStyleSheet.cpp | 5 +- .../webkit/WebCore/generated/JSCSSStyleSheet.h | 8 +- .../webkit/WebCore/generated/JSCSSValue.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSCSSValue.h | 8 +- .../webkit/WebCore/generated/JSCSSValueList.cpp | 5 +- .../webkit/WebCore/generated/JSCSSValueList.h | 8 +- .../generated/JSCSSVariablesDeclaration.cpp | 5 +- .../WebCore/generated/JSCSSVariablesDeclaration.h | 8 +- .../WebCore/generated/JSCSSVariablesRule.cpp | 5 +- .../webkit/WebCore/generated/JSCSSVariablesRule.h | 10 +- .../webkit/WebCore/generated/JSCanvasArray.cpp | 4 - .../webkit/WebCore/generated/JSCanvasArray.h | 8 +- .../webkit/WebCore/generated/JSCanvasArrayBuffer.h | 10 +- .../webkit/WebCore/generated/JSCanvasByteArray.h | 10 +- .../webkit/WebCore/generated/JSCanvasFloatArray.h | 10 +- .../webkit/WebCore/generated/JSCanvasGradient.h | 11 +- .../webkit/WebCore/generated/JSCanvasIntArray.h | 10 +- .../webkit/WebCore/generated/JSCanvasPattern.h | 13 + .../WebCore/generated/JSCanvasRenderingContext.cpp | 5 +- .../WebCore/generated/JSCanvasRenderingContext.h | 10 +- .../generated/JSCanvasRenderingContext2D.cpp | 5 +- .../WebCore/generated/JSCanvasRenderingContext2D.h | 8 +- .../generated/JSCanvasRenderingContext3D.cpp | 69 +- .../WebCore/generated/JSCanvasRenderingContext3D.h | 11 +- .../webkit/WebCore/generated/JSCanvasShortArray.h | 10 +- .../WebCore/generated/JSCanvasUnsignedByteArray.h | 10 +- .../WebCore/generated/JSCanvasUnsignedIntArray.h | 10 +- .../WebCore/generated/JSCanvasUnsignedShortArray.h | 10 +- .../webkit/WebCore/generated/JSCharacterData.cpp | 5 +- .../webkit/WebCore/generated/JSCharacterData.h | 8 +- .../webkit/WebCore/generated/JSClientRect.cpp | 5 +- .../webkit/WebCore/generated/JSClientRect.h | 10 +- .../webkit/WebCore/generated/JSClientRectList.cpp | 5 +- .../webkit/WebCore/generated/JSClientRectList.h | 8 +- .../webkit/WebCore/generated/JSClipboard.cpp | 5 +- .../webkit/WebCore/generated/JSClipboard.h | 8 +- .../webkit/WebCore/generated/JSComment.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSComment.h | 10 +- src/3rdparty/webkit/WebCore/generated/JSConsole.h | 8 +- .../webkit/WebCore/generated/JSCoordinates.h | 10 +- .../webkit/WebCore/generated/JSCounter.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSCounter.h | 10 +- .../WebCore/generated/JSDOMApplicationCache.h | 8 +- .../WebCore/generated/JSDOMCoreException.cpp | 5 +- .../webkit/WebCore/generated/JSDOMCoreException.h | 8 +- .../WebCore/generated/JSDOMImplementation.cpp | 5 +- .../webkit/WebCore/generated/JSDOMImplementation.h | 8 +- .../webkit/WebCore/generated/JSDOMParser.cpp | 5 +- .../webkit/WebCore/generated/JSDOMParser.h | 8 +- .../webkit/WebCore/generated/JSDOMSelection.h | 8 +- .../webkit/WebCore/generated/JSDOMWindow.cpp | 20 +- .../webkit/WebCore/generated/JSDOMWindow.h | 10 +- .../webkit/WebCore/generated/JSDataGridColumn.cpp | 5 +- .../webkit/WebCore/generated/JSDataGridColumn.h | 8 +- .../WebCore/generated/JSDataGridColumnList.cpp | 5 +- .../WebCore/generated/JSDataGridColumnList.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSDatabase.h | 8 +- .../WebCore/generated/JSDedicatedWorkerContext.h | 8 +- .../webkit/WebCore/generated/JSDocument.cpp | 18 +- src/3rdparty/webkit/WebCore/generated/JSDocument.h | 9 +- .../WebCore/generated/JSDocumentFragment.cpp | 5 +- .../webkit/WebCore/generated/JSDocumentFragment.h | 8 +- .../webkit/WebCore/generated/JSDocumentType.cpp | 5 +- .../webkit/WebCore/generated/JSDocumentType.h | 10 +- .../webkit/WebCore/generated/JSElement.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSElement.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSEntity.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSEntity.h | 10 +- .../webkit/WebCore/generated/JSEntityReference.cpp | 5 +- .../webkit/WebCore/generated/JSEntityReference.h | 10 +- .../webkit/WebCore/generated/JSErrorEvent.cpp | 5 +- .../webkit/WebCore/generated/JSErrorEvent.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSEvent.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSEvent.h | 8 +- .../webkit/WebCore/generated/JSEventException.cpp | 5 +- .../webkit/WebCore/generated/JSEventException.h | 8 +- .../webkit/WebCore/generated/JSEventSource.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSFile.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSFile.h | 10 +- .../webkit/WebCore/generated/JSFileList.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSFileList.h | 8 +- .../webkit/WebCore/generated/JSGeolocation.h | 8 +- .../webkit/WebCore/generated/JSGeoposition.h | 10 +- .../WebCore/generated/JSHTMLAnchorElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLAnchorElement.h | 8 +- .../WebCore/generated/JSHTMLAppletElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLAppletElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLAreaElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLAreaElement.h | 10 +- .../WebCore/generated/JSHTMLAudioElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLAudioElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLBRElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLBRElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLBaseElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLBaseElement.h | 10 +- .../WebCore/generated/JSHTMLBaseFontElement.cpp | 5 +- .../WebCore/generated/JSHTMLBaseFontElement.h | 10 +- .../WebCore/generated/JSHTMLBlockquoteElement.cpp | 5 +- .../WebCore/generated/JSHTMLBlockquoteElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLBodyElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLBodyElement.h | 10 +- .../WebCore/generated/JSHTMLButtonElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLButtonElement.h | 8 +- .../WebCore/generated/JSHTMLCanvasElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLCanvasElement.h | 8 +- .../webkit/WebCore/generated/JSHTMLCollection.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLCollection.h | 8 +- .../WebCore/generated/JSHTMLDListElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLDListElement.h | 10 +- .../generated/JSHTMLDataGridCellElement.cpp | 5 +- .../WebCore/generated/JSHTMLDataGridCellElement.h | 10 +- .../WebCore/generated/JSHTMLDataGridColElement.cpp | 5 +- .../WebCore/generated/JSHTMLDataGridColElement.h | 10 +- .../WebCore/generated/JSHTMLDataGridElement.cpp | 5 +- .../WebCore/generated/JSHTMLDataGridElement.h | 10 +- .../WebCore/generated/JSHTMLDataGridRowElement.cpp | 5 +- .../WebCore/generated/JSHTMLDataGridRowElement.h | 10 +- .../WebCore/generated/JSHTMLDataListElement.cpp | 5 +- .../WebCore/generated/JSHTMLDataListElement.h | 10 +- .../WebCore/generated/JSHTMLDirectoryElement.cpp | 5 +- .../WebCore/generated/JSHTMLDirectoryElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLDivElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLDivElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLDocument.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLDocument.h | 8 +- .../webkit/WebCore/generated/JSHTMLElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLElement.h | 8 +- .../WebCore/generated/JSHTMLEmbedElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLEmbedElement.h | 8 +- .../WebCore/generated/JSHTMLFieldSetElement.cpp | 5 +- .../WebCore/generated/JSHTMLFieldSetElement.h | 8 +- .../webkit/WebCore/generated/JSHTMLFontElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLFontElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLFormElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLFormElement.h | 8 +- .../WebCore/generated/JSHTMLFrameElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLFrameElement.h | 8 +- .../WebCore/generated/JSHTMLFrameSetElement.cpp | 5 +- .../WebCore/generated/JSHTMLFrameSetElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLHRElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLHRElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLHeadElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLHeadElement.h | 10 +- .../WebCore/generated/JSHTMLHeadingElement.cpp | 5 +- .../WebCore/generated/JSHTMLHeadingElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLHtmlElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLHtmlElement.h | 10 +- .../WebCore/generated/JSHTMLIFrameElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLIFrameElement.h | 8 +- .../WebCore/generated/JSHTMLImageElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLImageElement.h | 10 +- .../WebCore/generated/JSHTMLInputElement.cpp | 39 +- .../webkit/WebCore/generated/JSHTMLInputElement.h | 12 +- .../WebCore/generated/JSHTMLIsIndexElement.cpp | 5 +- .../WebCore/generated/JSHTMLIsIndexElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLLIElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLLIElement.h | 10 +- .../WebCore/generated/JSHTMLLabelElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLLabelElement.h | 10 +- .../WebCore/generated/JSHTMLLegendElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLLegendElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLLinkElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLLinkElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLMapElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLMapElement.h | 10 +- .../WebCore/generated/JSHTMLMarqueeElement.cpp | 5 +- .../WebCore/generated/JSHTMLMarqueeElement.h | 8 +- .../WebCore/generated/JSHTMLMediaElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLMediaElement.h | 8 +- .../webkit/WebCore/generated/JSHTMLMenuElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLMenuElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLMetaElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLMetaElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLModElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLModElement.h | 10 +- .../WebCore/generated/JSHTMLOListElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLOListElement.h | 10 +- .../WebCore/generated/JSHTMLObjectElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLObjectElement.h | 8 +- .../WebCore/generated/JSHTMLOptGroupElement.cpp | 5 +- .../WebCore/generated/JSHTMLOptGroupElement.h | 10 +- .../WebCore/generated/JSHTMLOptionElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLOptionElement.h | 10 +- .../WebCore/generated/JSHTMLOptionsCollection.h | 8 +- .../WebCore/generated/JSHTMLParagraphElement.cpp | 5 +- .../WebCore/generated/JSHTMLParagraphElement.h | 10 +- .../WebCore/generated/JSHTMLParamElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLParamElement.h | 10 +- .../webkit/WebCore/generated/JSHTMLPreElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLPreElement.h | 10 +- .../WebCore/generated/JSHTMLQuoteElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLQuoteElement.h | 10 +- .../WebCore/generated/JSHTMLScriptElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLScriptElement.h | 10 +- .../WebCore/generated/JSHTMLSelectElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLSelectElement.h | 8 +- .../WebCore/generated/JSHTMLSourceElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLSourceElement.h | 10 +- .../WebCore/generated/JSHTMLStyleElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLStyleElement.h | 10 +- .../generated/JSHTMLTableCaptionElement.cpp | 5 +- .../WebCore/generated/JSHTMLTableCaptionElement.h | 10 +- .../WebCore/generated/JSHTMLTableCellElement.cpp | 5 +- .../WebCore/generated/JSHTMLTableCellElement.h | 10 +- .../WebCore/generated/JSHTMLTableColElement.cpp | 5 +- .../WebCore/generated/JSHTMLTableColElement.h | 10 +- .../WebCore/generated/JSHTMLTableElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLTableElement.h | 8 +- .../WebCore/generated/JSHTMLTableRowElement.cpp | 5 +- .../WebCore/generated/JSHTMLTableRowElement.h | 8 +- .../generated/JSHTMLTableSectionElement.cpp | 5 +- .../WebCore/generated/JSHTMLTableSectionElement.h | 8 +- .../WebCore/generated/JSHTMLTextAreaElement.cpp | 5 +- .../WebCore/generated/JSHTMLTextAreaElement.h | 8 +- .../WebCore/generated/JSHTMLTitleElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLTitleElement.h | 10 +- .../WebCore/generated/JSHTMLUListElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLUListElement.h | 10 +- .../WebCore/generated/JSHTMLVideoElement.cpp | 5 +- .../webkit/WebCore/generated/JSHTMLVideoElement.h | 10 +- src/3rdparty/webkit/WebCore/generated/JSHistory.h | 8 +- .../webkit/WebCore/generated/JSImageData.cpp | 5 +- .../webkit/WebCore/generated/JSImageData.h | 10 +- .../WebCore/generated/JSInspectorBackend.cpp | 152 +- .../webkit/WebCore/generated/JSInspectorBackend.h | 27 +- .../WebCore/generated/JSJavaScriptCallFrame.h | 8 +- .../webkit/WebCore/generated/JSKeyboardEvent.cpp | 5 +- .../webkit/WebCore/generated/JSKeyboardEvent.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSLocation.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSMedia.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSMedia.h | 8 +- .../webkit/WebCore/generated/JSMediaError.cpp | 5 +- .../webkit/WebCore/generated/JSMediaError.h | 8 +- .../webkit/WebCore/generated/JSMediaList.cpp | 5 +- .../webkit/WebCore/generated/JSMediaList.h | 8 +- .../webkit/WebCore/generated/JSMessageChannel.h | 8 +- .../webkit/WebCore/generated/JSMessageEvent.cpp | 8 +- .../webkit/WebCore/generated/JSMessageEvent.h | 8 +- .../webkit/WebCore/generated/JSMessagePort.cpp | 5 +- .../webkit/WebCore/generated/JSMessagePort.h | 8 +- .../webkit/WebCore/generated/JSMimeType.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSMimeType.h | 10 +- .../webkit/WebCore/generated/JSMimeTypeArray.cpp | 5 +- .../webkit/WebCore/generated/JSMimeTypeArray.h | 8 +- .../webkit/WebCore/generated/JSMouseEvent.cpp | 5 +- .../webkit/WebCore/generated/JSMouseEvent.h | 8 +- .../webkit/WebCore/generated/JSMutationEvent.cpp | 5 +- .../webkit/WebCore/generated/JSMutationEvent.h | 8 +- .../webkit/WebCore/generated/JSNamedNodeMap.cpp | 5 +- .../webkit/WebCore/generated/JSNamedNodeMap.h | 8 +- .../webkit/WebCore/generated/JSNavigator.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSNode.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSNode.h | 8 +- .../webkit/WebCore/generated/JSNodeFilter.cpp | 5 +- .../webkit/WebCore/generated/JSNodeFilter.h | 8 +- .../webkit/WebCore/generated/JSNodeIterator.cpp | 5 +- .../webkit/WebCore/generated/JSNodeIterator.h | 8 +- .../webkit/WebCore/generated/JSNodeList.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSNodeList.h | 8 +- .../webkit/WebCore/generated/JSNotation.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSNotation.h | 10 +- .../webkit/WebCore/generated/JSOverflowEvent.cpp | 5 +- .../webkit/WebCore/generated/JSOverflowEvent.h | 8 +- .../WebCore/generated/JSPageTransitionEvent.cpp | 5 +- .../WebCore/generated/JSPageTransitionEvent.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSPlugin.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSPlugin.h | 8 +- .../webkit/WebCore/generated/JSPluginArray.cpp | 5 +- .../webkit/WebCore/generated/JSPluginArray.h | 8 +- .../webkit/WebCore/generated/JSPositionError.cpp | 5 +- .../webkit/WebCore/generated/JSPositionError.h | 8 +- .../WebCore/generated/JSProcessingInstruction.cpp | 5 +- .../WebCore/generated/JSProcessingInstruction.h | 10 +- .../webkit/WebCore/generated/JSProgressEvent.cpp | 5 +- .../webkit/WebCore/generated/JSProgressEvent.h | 8 +- .../webkit/WebCore/generated/JSRGBColor.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSRGBColor.h | 10 +- src/3rdparty/webkit/WebCore/generated/JSRange.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSRange.h | 8 +- .../webkit/WebCore/generated/JSRangeException.cpp | 5 +- .../webkit/WebCore/generated/JSRangeException.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSRect.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSRect.h | 10 +- src/3rdparty/webkit/WebCore/generated/JSSQLError.h | 10 +- .../webkit/WebCore/generated/JSSQLResultSet.h | 10 +- .../WebCore/generated/JSSQLResultSetRowList.h | 8 +- .../webkit/WebCore/generated/JSSQLTransaction.h | 11 +- .../webkit/WebCore/generated/JSSVGAElement.h | 8 +- .../WebCore/generated/JSSVGAltGlyphElement.h | 10 +- .../webkit/WebCore/generated/JSSVGAngle.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSSVGAngle.h | 8 +- .../WebCore/generated/JSSVGAnimateColorElement.h | 13 + .../webkit/WebCore/generated/JSSVGAnimateElement.h | 13 + .../generated/JSSVGAnimateTransformElement.h | 13 + .../webkit/WebCore/generated/JSSVGAnimatedAngle.h | 10 +- .../WebCore/generated/JSSVGAnimatedBoolean.h | 10 +- .../WebCore/generated/JSSVGAnimatedEnumeration.h | 10 +- .../WebCore/generated/JSSVGAnimatedInteger.h | 10 +- .../webkit/WebCore/generated/JSSVGAnimatedLength.h | 10 +- .../WebCore/generated/JSSVGAnimatedLengthList.h | 10 +- .../webkit/WebCore/generated/JSSVGAnimatedNumber.h | 10 +- .../WebCore/generated/JSSVGAnimatedNumberList.h | 10 +- .../generated/JSSVGAnimatedPreserveAspectRatio.h | 10 +- .../webkit/WebCore/generated/JSSVGAnimatedRect.h | 10 +- .../webkit/WebCore/generated/JSSVGAnimatedString.h | 10 +- .../WebCore/generated/JSSVGAnimatedTransformList.h | 10 +- .../WebCore/generated/JSSVGAnimationElement.h | 8 +- .../webkit/WebCore/generated/JSSVGCircleElement.h | 8 +- .../WebCore/generated/JSSVGClipPathElement.h | 8 +- .../webkit/WebCore/generated/JSSVGColor.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSSVGColor.h | 8 +- .../JSSVGComponentTransferFunctionElement.cpp | 5 +- .../JSSVGComponentTransferFunctionElement.h | 8 +- .../webkit/WebCore/generated/JSSVGCursorElement.h | 8 +- .../webkit/WebCore/generated/JSSVGDefsElement.h | 8 +- .../webkit/WebCore/generated/JSSVGDescElement.h | 8 +- .../webkit/WebCore/generated/JSSVGDocument.h | 8 +- .../webkit/WebCore/generated/JSSVGElement.cpp | 5 +- .../webkit/WebCore/generated/JSSVGElement.h | 10 +- .../WebCore/generated/JSSVGElementInstance.h | 8 +- .../WebCore/generated/JSSVGElementInstanceList.h | 8 +- .../webkit/WebCore/generated/JSSVGEllipseElement.h | 8 +- .../webkit/WebCore/generated/JSSVGException.cpp | 5 +- .../webkit/WebCore/generated/JSSVGException.h | 8 +- .../WebCore/generated/JSSVGFEBlendElement.cpp | 5 +- .../webkit/WebCore/generated/JSSVGFEBlendElement.h | 8 +- .../generated/JSSVGFEColorMatrixElement.cpp | 5 +- .../WebCore/generated/JSSVGFEColorMatrixElement.h | 8 +- .../generated/JSSVGFEComponentTransferElement.h | 8 +- .../WebCore/generated/JSSVGFECompositeElement.cpp | 9 +- .../WebCore/generated/JSSVGFECompositeElement.h | 10 +- .../generated/JSSVGFEDiffuseLightingElement.h | 8 +- .../generated/JSSVGFEDisplacementMapElement.cpp | 5 +- .../generated/JSSVGFEDisplacementMapElement.h | 8 +- .../WebCore/generated/JSSVGFEDistantLightElement.h | 10 +- .../WebCore/generated/JSSVGFEFloodElement.cpp | 19 +- .../webkit/WebCore/generated/JSSVGFEFloodElement.h | 9 +- .../webkit/WebCore/generated/JSSVGFEFuncAElement.h | 13 + .../webkit/WebCore/generated/JSSVGFEFuncBElement.h | 13 + .../webkit/WebCore/generated/JSSVGFEFuncGElement.h | 13 + .../webkit/WebCore/generated/JSSVGFEFuncRElement.h | 13 + .../WebCore/generated/JSSVGFEGaussianBlurElement.h | 8 +- .../webkit/WebCore/generated/JSSVGFEImageElement.h | 8 +- .../webkit/WebCore/generated/JSSVGFEMergeElement.h | 8 +- .../WebCore/generated/JSSVGFEMergeNodeElement.h | 10 +- .../WebCore/generated/JSSVGFEMorphologyElement.cpp | 336 + .../WebCore/generated/JSSVGFEMorphologyElement.h | 99 + .../WebCore/generated/JSSVGFEOffsetElement.h | 8 +- .../WebCore/generated/JSSVGFEPointLightElement.h | 10 +- .../generated/JSSVGFESpecularLightingElement.h | 8 +- .../WebCore/generated/JSSVGFESpotLightElement.h | 10 +- .../webkit/WebCore/generated/JSSVGFETileElement.h | 8 +- .../WebCore/generated/JSSVGFETurbulenceElement.cpp | 5 +- .../WebCore/generated/JSSVGFETurbulenceElement.h | 8 +- .../webkit/WebCore/generated/JSSVGFilterElement.h | 8 +- .../webkit/WebCore/generated/JSSVGFontElement.h | 13 + .../WebCore/generated/JSSVGFontFaceElement.h | 13 + .../WebCore/generated/JSSVGFontFaceFormatElement.h | 13 + .../WebCore/generated/JSSVGFontFaceNameElement.h | 13 + .../WebCore/generated/JSSVGFontFaceSrcElement.h | 13 + .../WebCore/generated/JSSVGFontFaceUriElement.h | 13 + .../WebCore/generated/JSSVGForeignObjectElement.h | 8 +- .../webkit/WebCore/generated/JSSVGGElement.h | 8 +- .../webkit/WebCore/generated/JSSVGGlyphElement.h | 13 + .../WebCore/generated/JSSVGGradientElement.cpp | 5 +- .../WebCore/generated/JSSVGGradientElement.h | 8 +- .../webkit/WebCore/generated/JSSVGHKernElement.h | 13 + .../webkit/WebCore/generated/JSSVGImageElement.h | 8 +- .../webkit/WebCore/generated/JSSVGLength.cpp | 5 +- .../webkit/WebCore/generated/JSSVGLength.h | 8 +- .../webkit/WebCore/generated/JSSVGLengthList.h | 8 +- .../webkit/WebCore/generated/JSSVGLineElement.h | 8 +- .../WebCore/generated/JSSVGLinearGradientElement.h | 10 +- .../WebCore/generated/JSSVGMarkerElement.cpp | 5 +- .../webkit/WebCore/generated/JSSVGMarkerElement.h | 8 +- .../webkit/WebCore/generated/JSSVGMaskElement.h | 8 +- .../webkit/WebCore/generated/JSSVGMatrix.h | 8 +- .../WebCore/generated/JSSVGMetadataElement.h | 13 + .../WebCore/generated/JSSVGMissingGlyphElement.h | 13 + .../webkit/WebCore/generated/JSSVGNumber.h | 10 +- .../webkit/WebCore/generated/JSSVGNumberList.h | 8 +- .../webkit/WebCore/generated/JSSVGPaint.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSSVGPaint.h | 8 +- .../webkit/WebCore/generated/JSSVGPathElement.h | 8 +- .../webkit/WebCore/generated/JSSVGPathSeg.cpp | 5 +- .../webkit/WebCore/generated/JSSVGPathSeg.h | 8 +- .../webkit/WebCore/generated/JSSVGPathSegArcAbs.h | 10 +- .../webkit/WebCore/generated/JSSVGPathSegArcRel.h | 10 +- .../WebCore/generated/JSSVGPathSegClosePath.h | 13 + .../generated/JSSVGPathSegCurvetoCubicAbs.h | 10 +- .../generated/JSSVGPathSegCurvetoCubicRel.h | 10 +- .../generated/JSSVGPathSegCurvetoCubicSmoothAbs.h | 10 +- .../generated/JSSVGPathSegCurvetoCubicSmoothRel.h | 10 +- .../generated/JSSVGPathSegCurvetoQuadraticAbs.h | 10 +- .../generated/JSSVGPathSegCurvetoQuadraticRel.h | 10 +- .../JSSVGPathSegCurvetoQuadraticSmoothAbs.h | 10 +- .../JSSVGPathSegCurvetoQuadraticSmoothRel.h | 10 +- .../WebCore/generated/JSSVGPathSegLinetoAbs.h | 10 +- .../generated/JSSVGPathSegLinetoHorizontalAbs.h | 10 +- .../generated/JSSVGPathSegLinetoHorizontalRel.h | 10 +- .../WebCore/generated/JSSVGPathSegLinetoRel.h | 10 +- .../generated/JSSVGPathSegLinetoVerticalAbs.h | 10 +- .../generated/JSSVGPathSegLinetoVerticalRel.h | 10 +- .../webkit/WebCore/generated/JSSVGPathSegList.h | 8 +- .../WebCore/generated/JSSVGPathSegMovetoAbs.h | 10 +- .../WebCore/generated/JSSVGPathSegMovetoRel.h | 10 +- .../webkit/WebCore/generated/JSSVGPatternElement.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSSVGPoint.h | 8 +- .../webkit/WebCore/generated/JSSVGPointList.h | 8 +- .../webkit/WebCore/generated/JSSVGPolygonElement.h | 8 +- .../WebCore/generated/JSSVGPolylineElement.h | 8 +- .../WebCore/generated/JSSVGPreserveAspectRatio.cpp | 5 +- .../WebCore/generated/JSSVGPreserveAspectRatio.h | 8 +- .../WebCore/generated/JSSVGRadialGradientElement.h | 10 +- src/3rdparty/webkit/WebCore/generated/JSSVGRect.h | 10 +- .../webkit/WebCore/generated/JSSVGRectElement.h | 8 +- .../WebCore/generated/JSSVGRenderingIntent.cpp | 5 +- .../WebCore/generated/JSSVGRenderingIntent.h | 8 +- .../webkit/WebCore/generated/JSSVGSVGElement.h | 8 +- .../webkit/WebCore/generated/JSSVGScriptElement.h | 10 +- .../webkit/WebCore/generated/JSSVGSetElement.h | 13 + .../webkit/WebCore/generated/JSSVGStopElement.h | 8 +- .../webkit/WebCore/generated/JSSVGStringList.h | 8 +- .../webkit/WebCore/generated/JSSVGStyleElement.h | 10 +- .../webkit/WebCore/generated/JSSVGSwitchElement.h | 8 +- .../webkit/WebCore/generated/JSSVGSymbolElement.h | 8 +- .../webkit/WebCore/generated/JSSVGTRefElement.h | 10 +- .../webkit/WebCore/generated/JSSVGTSpanElement.h | 13 + .../WebCore/generated/JSSVGTextContentElement.cpp | 5 +- .../WebCore/generated/JSSVGTextContentElement.h | 8 +- .../webkit/WebCore/generated/JSSVGTextElement.h | 8 +- .../WebCore/generated/JSSVGTextPathElement.cpp | 5 +- .../WebCore/generated/JSSVGTextPathElement.h | 8 +- .../generated/JSSVGTextPositioningElement.h | 10 +- .../webkit/WebCore/generated/JSSVGTitleElement.h | 8 +- .../webkit/WebCore/generated/JSSVGTransform.cpp | 5 +- .../webkit/WebCore/generated/JSSVGTransform.h | 8 +- .../webkit/WebCore/generated/JSSVGTransformList.h | 8 +- .../webkit/WebCore/generated/JSSVGUnitTypes.cpp | 5 +- .../webkit/WebCore/generated/JSSVGUnitTypes.h | 8 +- .../webkit/WebCore/generated/JSSVGUseElement.h | 8 +- .../webkit/WebCore/generated/JSSVGViewElement.h | 8 +- .../webkit/WebCore/generated/JSSVGZoomEvent.h | 10 +- src/3rdparty/webkit/WebCore/generated/JSScreen.h | 10 +- .../webkit/WebCore/generated/JSSharedWorker.h | 8 +- .../WebCore/generated/JSSharedWorkerContext.h | 10 +- .../webkit/WebCore/generated/JSStorage.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSStorage.h | 8 +- .../webkit/WebCore/generated/JSStorageEvent.cpp | 25 +- .../webkit/WebCore/generated/JSStorageEvent.h | 9 +- .../webkit/WebCore/generated/JSStyleSheet.cpp | 5 +- .../webkit/WebCore/generated/JSStyleSheet.h | 8 +- .../webkit/WebCore/generated/JSStyleSheetList.cpp | 5 +- .../webkit/WebCore/generated/JSStyleSheetList.h | 8 +- src/3rdparty/webkit/WebCore/generated/JSText.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSText.h | 8 +- .../webkit/WebCore/generated/JSTextEvent.cpp | 5 +- .../webkit/WebCore/generated/JSTextEvent.h | 8 +- .../webkit/WebCore/generated/JSTextMetrics.cpp | 5 +- .../webkit/WebCore/generated/JSTextMetrics.h | 10 +- .../webkit/WebCore/generated/JSTimeRanges.h | 8 +- .../webkit/WebCore/generated/JSTreeWalker.cpp | 5 +- .../webkit/WebCore/generated/JSTreeWalker.h | 8 +- .../webkit/WebCore/generated/JSUIEvent.cpp | 5 +- src/3rdparty/webkit/WebCore/generated/JSUIEvent.h | 8 +- .../webkit/WebCore/generated/JSValidityState.h | 10 +- .../webkit/WebCore/generated/JSVoidCallback.h | 11 +- .../WebCore/generated/JSWebKitAnimationEvent.cpp | 5 +- .../WebCore/generated/JSWebKitAnimationEvent.h | 8 +- .../WebCore/generated/JSWebKitCSSKeyframeRule.cpp | 5 +- .../WebCore/generated/JSWebKitCSSKeyframeRule.h | 10 +- .../WebCore/generated/JSWebKitCSSKeyframesRule.cpp | 5 +- .../WebCore/generated/JSWebKitCSSKeyframesRule.h | 8 +- .../webkit/WebCore/generated/JSWebKitCSSMatrix.h | 8 +- .../generated/JSWebKitCSSTransformValue.cpp | 5 +- .../WebCore/generated/JSWebKitCSSTransformValue.h | 8 +- .../webkit/WebCore/generated/JSWebKitPoint.h | 10 +- .../WebCore/generated/JSWebKitTransitionEvent.cpp | 5 +- .../WebCore/generated/JSWebKitTransitionEvent.h | 8 +- .../webkit/WebCore/generated/JSWebSocket.cpp | 41 +- .../webkit/WebCore/generated/JSWebSocket.h | 13 +- .../webkit/WebCore/generated/JSWheelEvent.cpp | 5 +- .../webkit/WebCore/generated/JSWheelEvent.h | 10 +- src/3rdparty/webkit/WebCore/generated/JSWorker.h | 8 +- .../webkit/WebCore/generated/JSWorkerContext.h | 8 +- .../webkit/WebCore/generated/JSWorkerLocation.cpp | 5 +- .../webkit/WebCore/generated/JSWorkerLocation.h | 8 +- .../webkit/WebCore/generated/JSWorkerNavigator.h | 10 +- .../webkit/WebCore/generated/JSXMLHttpRequest.h | 8 +- .../generated/JSXMLHttpRequestException.cpp | 5 +- .../WebCore/generated/JSXMLHttpRequestException.h | 8 +- .../generated/JSXMLHttpRequestProgressEvent.cpp | 5 +- .../generated/JSXMLHttpRequestProgressEvent.h | 10 +- .../WebCore/generated/JSXMLHttpRequestUpload.cpp | 5 +- .../WebCore/generated/JSXMLHttpRequestUpload.h | 8 +- .../webkit/WebCore/generated/JSXMLSerializer.cpp | 5 +- .../webkit/WebCore/generated/JSXMLSerializer.h | 8 +- .../webkit/WebCore/generated/JSXPathEvaluator.cpp | 5 +- .../webkit/WebCore/generated/JSXPathEvaluator.h | 8 +- .../webkit/WebCore/generated/JSXPathException.cpp | 5 +- .../webkit/WebCore/generated/JSXPathException.h | 8 +- .../webkit/WebCore/generated/JSXPathExpression.cpp | 5 +- .../webkit/WebCore/generated/JSXPathExpression.h | 8 +- .../webkit/WebCore/generated/JSXPathNSResolver.h | 11 +- .../webkit/WebCore/generated/JSXPathResult.cpp | 5 +- .../webkit/WebCore/generated/JSXPathResult.h | 8 +- .../webkit/WebCore/generated/JSXSLTProcessor.h | 11 +- .../webkit/WebCore/generated/StringPrototype.lut.h | 7 +- .../WebCore/generated/UserAgentStyleSheets.h | 3 +- .../WebCore/generated/UserAgentStyleSheetsData.cpp | 721 +- .../webkit/WebCore/generated/WebKitVersion.h | 2 +- .../webkit/WebCore/html/HTMLAnchorElement.cpp | 27 +- .../webkit/WebCore/html/HTMLAnchorElement.h | 27 + .../webkit/WebCore/html/HTMLAttributeNames.in | 2 +- .../webkit/WebCore/html/HTMLCanvasElement.cpp | 4 +- src/3rdparty/webkit/WebCore/html/HTMLDocument.cpp | 3 +- src/3rdparty/webkit/WebCore/html/HTMLElement.cpp | 2 +- .../webkit/WebCore/html/HTMLFormControlElement.cpp | 100 +- .../webkit/WebCore/html/HTMLFormControlElement.h | 24 +- .../webkit/WebCore/html/HTMLFrameElementBase.cpp | 6 +- .../webkit/WebCore/html/HTMLImageElement.cpp | 4 +- .../webkit/WebCore/html/HTMLInputElement.cpp | 189 +- .../webkit/WebCore/html/HTMLInputElement.h | 20 +- .../webkit/WebCore/html/HTMLInputElement.idl | 6 + .../webkit/WebCore/html/HTMLLinkElement.cpp | 31 +- .../webkit/WebCore/html/HTMLMediaElement.cpp | 146 +- .../webkit/WebCore/html/HTMLMediaElement.h | 13 +- .../webkit/WebCore/html/HTMLObjectElement.cpp | 6 +- .../webkit/WebCore/html/HTMLScriptElement.cpp | 4 +- .../webkit/WebCore/html/HTMLTextAreaElement.cpp | 89 +- .../webkit/WebCore/html/HTMLTextAreaElement.h | 14 +- src/3rdparty/webkit/WebCore/html/HTMLTokenizer.cpp | 19 +- .../webkit/WebCore/html/HTMLVideoElement.cpp | 13 + .../webkit/WebCore/html/HTMLVideoElement.h | 2 +- src/3rdparty/webkit/WebCore/html/ValidityState.cpp | 48 + src/3rdparty/webkit/WebCore/html/ValidityState.h | 7 +- .../webkit/WebCore/html/canvas/CanvasActiveInfo.h | 62 + .../WebCore/html/canvas/CanvasActiveInfo.idl | 36 + .../webkit/WebCore/html/canvas/CanvasArray.cpp | 2 +- .../webkit/WebCore/html/canvas/CanvasArray.h | 8 + .../webkit/WebCore/html/canvas/CanvasArray.idl | 2 +- .../webkit/WebCore/html/canvas/CanvasByteArray.cpp | 11 +- .../webkit/WebCore/html/canvas/CanvasByteArray.h | 3 + .../WebCore/html/canvas/CanvasFloatArray.cpp | 13 +- .../webkit/WebCore/html/canvas/CanvasFloatArray.h | 2 + .../webkit/WebCore/html/canvas/CanvasIntArray.cpp | 14 +- .../webkit/WebCore/html/canvas/CanvasIntArray.h | 3 + .../webkit/WebCore/html/canvas/CanvasObject.h | 6 +- .../html/canvas/CanvasRenderingContext2D.cpp | 2 +- .../html/canvas/CanvasRenderingContext3D.cpp | 29 + .../WebCore/html/canvas/CanvasRenderingContext3D.h | 9 +- .../html/canvas/CanvasRenderingContext3D.idl | 10 +- .../WebCore/html/canvas/CanvasShortArray.cpp | 12 +- .../webkit/WebCore/html/canvas/CanvasShortArray.h | 3 + .../html/canvas/CanvasUnsignedByteArray.cpp | 9 +- .../WebCore/html/canvas/CanvasUnsignedByteArray.h | 3 + .../WebCore/html/canvas/CanvasUnsignedIntArray.cpp | 9 +- .../WebCore/html/canvas/CanvasUnsignedIntArray.h | 3 + .../html/canvas/CanvasUnsignedShortArray.cpp | 9 +- .../WebCore/html/canvas/CanvasUnsignedShortArray.h | 3 + .../webkit/WebCore/inspector/InspectorBackend.cpp | 126 +- .../webkit/WebCore/inspector/InspectorBackend.h | 28 +- .../webkit/WebCore/inspector/InspectorBackend.idl | 26 +- .../WebCore/inspector/InspectorController.cpp | 347 +- .../webkit/WebCore/inspector/InspectorController.h | 52 +- .../webkit/WebCore/inspector/InspectorDOMAgent.cpp | 38 - .../webkit/WebCore/inspector/InspectorDOMAgent.h | 6 - .../inspector/InspectorDOMStorageResource.cpp | 2 +- .../inspector/InspectorDatabaseResource.cpp | 5 +- .../WebCore/inspector/InspectorDatabaseResource.h | 5 +- .../webkit/WebCore/inspector/InspectorFrontend.cpp | 105 +- .../webkit/WebCore/inspector/InspectorFrontend.h | 15 +- .../webkit/WebCore/inspector/InspectorResource.cpp | 18 + .../webkit/WebCore/inspector/InspectorResource.h | 4 + .../webkit/WebCore/inspector/JavaScriptCallFrame.h | 8 +- .../WebCore/inspector/JavaScriptProfileNode.cpp | 50 - .../WebCore/inspector/front-end/ConsoleView.js | 69 +- .../WebCore/inspector/front-end/CookieItemsView.js | 15 +- .../webkit/WebCore/inspector/front-end/DOMAgent.js | 15 +- .../webkit/WebCore/inspector/front-end/Database.js | 47 +- .../WebCore/inspector/front-end/ElementsPanel.js | 4 +- .../inspector/front-end/ElementsTreeOutline.js | 242 +- .../WebCore/inspector/front-end/InjectedScript.js | 107 +- .../inspector/front-end/InjectedScriptAccess.js | 42 +- .../webkit/WebCore/inspector/front-end/Object.js | 6 +- .../WebCore/inspector/front-end/ProfileView.js | 125 +- .../WebCore/inspector/front-end/ProfilesPanel.js | 228 +- .../WebCore/inspector/front-end/ResourceView.js | 1 + .../WebCore/inspector/front-end/ResourcesPanel.js | 114 +- .../inspector/front-end/ScopeChainSidebarPane.js | 12 +- .../WebCore/inspector/front-end/ScriptsPanel.js | 24 +- .../WebCore/inspector/front-end/SourceFrame.js | 528 +- .../WebCore/inspector/front-end/SourceView.js | 9 +- .../WebCore/inspector/front-end/StoragePanel.js | 62 +- .../WebCore/inspector/front-end/TestController.js | 65 + .../WebCore/inspector/front-end/TextPrompt.js | 2 +- .../WebCore/inspector/front-end/TimelineAgent.js | 4 +- .../front-end/WatchExpressionsSidebarPane.js | 7 +- .../webkit/WebCore/inspector/front-end/WebKit.qrc | 2 + .../WebCore/inspector/front-end/inspector.css | 68 +- .../WebCore/inspector/front-end/inspector.html | 5 +- .../WebCore/inspector/front-end/inspector.js | 92 +- .../front-end/inspectorSyntaxHighlight.css | 71 + .../WebCore/inspector/front-end/utilities.js | 145 +- src/3rdparty/webkit/WebCore/loader/Cache.cpp | 3 +- .../webkit/WebCore/loader/CachedResourceClient.h | 4 +- .../webkit/WebCore/loader/CachedResourceHandle.h | 7 +- src/3rdparty/webkit/WebCore/loader/EmptyClients.h | 1 + src/3rdparty/webkit/WebCore/loader/FrameLoader.cpp | 1743 +--- src/3rdparty/webkit/WebCore/loader/FrameLoader.h | 813 +- .../webkit/WebCore/loader/FrameLoaderClient.h | 3 +- .../webkit/WebCore/loader/FrameLoaderTypes.h | 5 + .../webkit/WebCore/loader/HistoryController.cpp | 627 ++ .../webkit/WebCore/loader/HistoryController.h | 95 + src/3rdparty/webkit/WebCore/loader/ImageLoader.cpp | 112 +- src/3rdparty/webkit/WebCore/loader/ImageLoader.h | 9 +- .../webkit/WebCore/loader/MainResourceLoader.cpp | 28 +- .../webkit/WebCore/loader/PolicyCallback.cpp | 133 + .../webkit/WebCore/loader/PolicyCallback.h | 80 + .../webkit/WebCore/loader/PolicyChecker.cpp | 197 + src/3rdparty/webkit/WebCore/loader/PolicyChecker.h | 97 + .../webkit/WebCore/loader/RedirectScheduler.cpp | 374 + .../webkit/WebCore/loader/RedirectScheduler.h | 81 + .../webkit/WebCore/loader/ResourceLoadNotifier.cpp | 177 + .../webkit/WebCore/loader/ResourceLoadNotifier.h | 74 + .../webkit/WebCore/loader/ResourceLoader.cpp | 22 +- .../webkit/WebCore/loader/SubresourceLoader.cpp | 7 +- .../WebCore/loader/WorkerThreadableLoader.cpp | 2 +- .../loader/appcache/ApplicationCacheGroup.cpp | 2 +- .../webkit/WebCore/loader/icon/IconDatabase.cpp | 26 +- .../WebCore/loader/icon/IconDatabaseNone.cpp | 2 +- src/3rdparty/webkit/WebCore/page/ChromeClient.h | 4 + .../webkit/WebCore/page/ContextMenuController.cpp | 8 +- src/3rdparty/webkit/WebCore/page/DOMWindow.cpp | 24 +- src/3rdparty/webkit/WebCore/page/DOMWindow.h | 5 +- src/3rdparty/webkit/WebCore/page/DOMWindow.idl | 37 +- .../webkit/WebCore/page/DragController.cpp | 6 + src/3rdparty/webkit/WebCore/page/EventHandler.cpp | 17 +- src/3rdparty/webkit/WebCore/page/EventSource.cpp | 3 +- src/3rdparty/webkit/WebCore/page/Frame.cpp | 10 +- src/3rdparty/webkit/WebCore/page/Frame.h | 3 + src/3rdparty/webkit/WebCore/page/FrameView.cpp | 79 + src/3rdparty/webkit/WebCore/page/FrameView.h | 2 + src/3rdparty/webkit/WebCore/page/History.cpp | 10 +- src/3rdparty/webkit/WebCore/page/Page.cpp | 68 +- src/3rdparty/webkit/WebCore/page/Page.h | 9 +- src/3rdparty/webkit/WebCore/page/PageGroup.cpp | 110 +- src/3rdparty/webkit/WebCore/page/PageGroup.h | 19 +- src/3rdparty/webkit/WebCore/page/PluginHalter.cpp | 7 +- src/3rdparty/webkit/WebCore/page/PluginHalter.h | 5 +- .../webkit/WebCore/page/PluginHalterClient.h | 1 + src/3rdparty/webkit/WebCore/page/PrintContext.cpp | 30 +- .../webkit/WebCore/page/SecurityOrigin.cpp | 66 +- src/3rdparty/webkit/WebCore/page/SecurityOrigin.h | 21 +- src/3rdparty/webkit/WebCore/page/Settings.cpp | 41 +- src/3rdparty/webkit/WebCore/page/Settings.h | 31 +- .../webkit/WebCore/page/UserContentURLPattern.cpp | 32 +- .../webkit/WebCore/page/UserContentURLPattern.h | 2 +- src/3rdparty/webkit/WebCore/page/UserScript.h | 14 +- src/3rdparty/webkit/WebCore/page/UserStyleSheet.h | 13 +- src/3rdparty/webkit/WebCore/page/XSSAuditor.cpp | 67 +- src/3rdparty/webkit/WebCore/page/XSSAuditor.h | 15 +- .../WebCore/page/animation/AnimationBase.cpp | 10 +- .../WebCore/page/animation/AnimationController.cpp | 21 +- .../page/animation/AnimationControllerPrivate.h | 16 +- .../WebCore/page/animation/ImplicitAnimation.cpp | 6 +- .../WebCore/page/animation/KeyframeAnimation.cpp | 6 +- .../webkit/WebCore/platform/ContextMenu.cpp | 8 +- src/3rdparty/webkit/WebCore/platform/Cookie.h | 19 + .../webkit/WebCore/platform/CrossThreadCopier.cpp | 2 +- src/3rdparty/webkit/WebCore/platform/KURL.cpp | 2 +- .../webkit/WebCore/platform/KURLGoogle.cpp | 2 +- .../webkit/WebCore/platform/ScrollView.cpp | 29 +- src/3rdparty/webkit/WebCore/platform/ScrollView.h | 4 +- .../webkit/WebCore/platform/SuddenTermination.h | 3 + src/3rdparty/webkit/WebCore/platform/ThemeTypes.h | 2 +- .../webkit/WebCore/platform/graphics/BitmapImage.h | 1 + .../WebCore/platform/graphics/FontDescription.h | 8 +- .../WebCore/platform/graphics/FontFastPath.cpp | 4 + .../WebCore/platform/graphics/GraphicsContext.h | 5 + .../WebCore/platform/graphics/GraphicsContext3D.h | 21 +- .../WebCore/platform/graphics/GraphicsLayer.cpp | 10 + .../WebCore/platform/graphics/GraphicsLayer.h | 3 + .../WebCore/platform/graphics/ImageSource.cpp | 4 - .../WebCore/platform/graphics/MediaPlayer.cpp | 24 +- .../webkit/WebCore/platform/graphics/MediaPlayer.h | 23 +- .../WebCore/platform/graphics/MediaPlayerPrivate.h | 7 +- .../WebCore/platform/graphics/SimpleFontData.h | 3 +- .../WebCore/platform/graphics/TextRenderingMode.h | 35 + .../platform/graphics/filters/FEComposite.cpp | 2 +- .../platform/graphics/filters/FEGaussianBlur.cpp | 139 + .../platform/graphics/filters/FEGaussianBlur.h | 57 + .../platform/graphics/filters/FilterEffect.cpp | 7 +- .../platform/graphics/filters/FilterEffect.h | 18 +- .../platform/graphics/filters/SourceAlpha.cpp | 25 +- .../platform/graphics/filters/SourceAlpha.h | 2 +- .../WebCore/platform/graphics/qt/ColorQt.cpp | 5 +- .../platform/graphics/qt/GraphicsContextQt.cpp | 65 +- .../platform/graphics/qt/ImageDecoderQt.cpp | 379 +- .../WebCore/platform/graphics/qt/ImageDecoderQt.h | 49 +- .../WebCore/platform/graphics/qt/ImageQt.cpp | 1 + .../WebCore/platform/graphics/qt/ImageSourceQt.cpp | 67 - .../WebCore/platform/image-decoders/ImageDecoder.h | 16 +- .../platform/image-decoders/qt/RGBA32BufferQt.cpp | 144 + .../webkit/WebCore/platform/mac/ClipboardMac.mm | 21 +- .../webkit/WebCore/platform/mac/ThemeMac.mm | 26 + .../WebCore/platform/network/CredentialStorage.cpp | 125 +- .../WebCore/platform/network/CredentialStorage.h | 6 +- .../WebCore/platform/network/HTTPHeaderMap.cpp | 2 +- .../WebCore/platform/network/ResourceErrorBase.cpp | 6 +- .../platform/network/ResourceRequestBase.cpp | 4 +- .../platform/network/ResourceResponseBase.cpp | 8 +- .../platform/network/qt/QNetworkReplyHandler.cpp | 84 +- .../platform/network/qt/QNetworkReplyHandler.h | 4 - .../webkit/WebCore/platform/qt/ClipboardQt.cpp | 4 +- .../webkit/WebCore/platform/qt/Localizations.cpp | 4 +- .../platform/qt/PlatformKeyboardEventQt.cpp | 2 +- .../WebCore/platform/qt/PlatformScreenQt.cpp | 2 +- .../webkit/WebCore/platform/qt/PopupMenuQt.cpp | 2 +- .../webkit/WebCore/platform/qt/QWebPageClient.h | 14 +- .../webkit/WebCore/platform/qt/RenderThemeQt.cpp | 9 +- .../webkit/WebCore/platform/sql/SQLValue.cpp | 8 +- .../webkit/WebCore/platform/sql/SQLValue.h | 4 +- .../webkit/WebCore/platform/sql/SQLiteDatabase.h | 4 +- .../webkit/WebCore/platform/text/AtomicString.cpp | 22 +- .../webkit/WebCore/platform/text/AtomicString.h | 3 + .../webkit/WebCore/platform/text/PlatformString.h | 13 +- .../webkit/WebCore/platform/text/String.cpp | 18 +- .../webkit/WebCore/platform/text/StringImpl.cpp | 219 +- .../webkit/WebCore/platform/text/StringImpl.h | 47 +- .../WebCore/platform/text/TextEncodingRegistry.cpp | 30 + .../WebCore/platform/text/qt/TextCodecQt.cpp | 2 +- .../webkit/WebCore/plugins/PluginDataNone.cpp | 4 - .../webkit/WebCore/plugins/PluginDatabase.cpp | 6 +- .../webkit/WebCore/plugins/PluginPackage.cpp | 3 + .../webkit/WebCore/plugins/PluginPackage.h | 13 + .../webkit/WebCore/plugins/PluginPackageNone.cpp | 32 - .../webkit/WebCore/plugins/PluginQuirkSet.h | 1 + src/3rdparty/webkit/WebCore/plugins/PluginView.cpp | 45 +- src/3rdparty/webkit/WebCore/plugins/PluginView.h | 29 +- .../webkit/WebCore/plugins/PluginViewNone.cpp | 32 +- .../WebCore/plugins/mac/PluginPackageMac.cpp | 3 +- .../webkit/WebCore/plugins/mac/PluginViewMac.cpp | 12 +- .../WebCore/plugins/qt/PluginContainerQt.cpp | 1 + .../webkit/WebCore/plugins/qt/PluginPackageQt.cpp | 16 + .../webkit/WebCore/plugins/qt/PluginViewQt.cpp | 498 +- .../plugins/symbian/PluginContainerSymbian.cpp | 77 + .../plugins/symbian/PluginContainerSymbian.h | 50 + .../plugins/symbian/PluginDatabaseSymbian.cpp | 79 + .../plugins/symbian/PluginPackageSymbian.cpp | 177 + .../WebCore/plugins/symbian/PluginViewSymbian.cpp | 462 + .../webkit/WebCore/plugins/symbian/npinterface.h | 37 + .../webkit/WebCore/plugins/win/PluginViewWin.cpp | 43 +- .../webkit/WebCore/rendering/CounterNode.cpp | 12 +- .../webkit/WebCore/rendering/InlineFlowBox.cpp | 41 +- .../WebCore/rendering/MediaControlElements.cpp | 16 +- .../WebCore/rendering/MediaControlElements.h | 2 + src/3rdparty/webkit/WebCore/rendering/RenderBR.cpp | 2 +- .../webkit/WebCore/rendering/RenderBlock.cpp | 4 +- .../webkit/WebCore/rendering/RenderBox.cpp | 10 +- .../webkit/WebCore/rendering/RenderCounter.cpp | 25 +- .../webkit/WebCore/rendering/RenderImage.cpp | 2 +- .../webkit/WebCore/rendering/RenderInline.cpp | 2 +- .../webkit/WebCore/rendering/RenderLayer.cpp | 32 +- .../webkit/WebCore/rendering/RenderLayer.h | 6 +- .../WebCore/rendering/RenderLayerBacking.cpp | 32 +- .../webkit/WebCore/rendering/RenderLayerBacking.h | 6 +- .../WebCore/rendering/RenderLayerCompositor.cpp | 1 + .../webkit/WebCore/rendering/RenderListBox.cpp | 2 +- .../webkit/WebCore/rendering/RenderListBox.h | 2 +- .../WebCore/rendering/RenderMediaControls.cpp | 15 +- .../rendering/RenderMediaControlsChromium.cpp | 287 + .../rendering/RenderMediaControlsChromium.h | 46 + .../webkit/WebCore/rendering/RenderObject.cpp | 19 +- .../webkit/WebCore/rendering/RenderObject.h | 2 + .../webkit/WebCore/rendering/RenderPartObject.cpp | 10 +- .../webkit/WebCore/rendering/RenderSlider.cpp | 18 +- .../rendering/RenderTextControlMultiLine.cpp | 6 +- .../rendering/RenderTextControlSingleLine.cpp | 4 +- .../rendering/RenderTextControlSingleLine.h | 2 +- .../webkit/WebCore/rendering/RenderTheme.cpp | 6 + .../WebCore/rendering/RenderThemeChromiumMac.h | 1 + .../WebCore/rendering/RenderThemeChromiumMac.mm | 174 +- .../WebCore/rendering/RenderThemeChromiumSkia.cpp | 188 +- .../WebCore/rendering/RenderThemeChromiumWin.h | 2 +- .../webkit/WebCore/rendering/RenderThemeMac.h | 2 + .../webkit/WebCore/rendering/RenderThemeSafari.cpp | 2 +- .../webkit/WebCore/rendering/RenderWidget.cpp | 11 +- .../webkit/WebCore/rendering/RenderWidget.h | 3 + .../webkit/WebCore/rendering/SVGRenderSupport.cpp | 2 +- .../webkit/WebCore/rendering/style/RenderStyle.h | 2 +- .../WebCore/rendering/style/RenderStyleConstants.h | 1 + .../WebCore/rendering/style/SVGRenderStyle.h | 4 - .../WebCore/rendering/style/SVGRenderStyleDefs.h | 4 - .../WebCore/storage/ChangeVersionWrapper.cpp | 4 +- src/3rdparty/webkit/WebCore/storage/Database.cpp | 76 +- .../webkit/WebCore/storage/DatabaseTracker.cpp | 2 +- .../webkit/WebCore/storage/LocalStorageTask.cpp | 8 +- .../webkit/WebCore/storage/LocalStorageTask.h | 14 +- .../webkit/WebCore/storage/LocalStorageThread.cpp | 4 +- .../webkit/WebCore/storage/LocalStorageThread.h | 4 +- .../webkit/WebCore/storage/OriginQuotaManager.cpp | 2 +- src/3rdparty/webkit/WebCore/storage/SQLError.h | 4 +- .../webkit/WebCore/storage/SQLStatement.cpp | 2 +- .../webkit/WebCore/storage/SQLTransaction.cpp | 10 +- src/3rdparty/webkit/WebCore/storage/StorageArea.h | 4 +- .../webkit/WebCore/storage/StorageAreaImpl.cpp | 81 +- .../webkit/WebCore/storage/StorageAreaImpl.h | 6 +- .../webkit/WebCore/storage/StorageAreaSync.cpp | 4 +- .../webkit/WebCore/storage/StorageEvent.cpp | 11 +- src/3rdparty/webkit/WebCore/storage/StorageEvent.h | 11 +- .../webkit/WebCore/storage/StorageEvent.idl | 5 +- .../WebCore/storage/StorageEventDispatcher.cpp | 77 + src/3rdparty/webkit/WebCore/storage/StorageMap.cpp | 53 +- src/3rdparty/webkit/WebCore/storage/StorageMap.h | 26 +- .../webkit/WebCore/storage/StorageNamespace.cpp | 4 +- .../webkit/WebCore/storage/StorageNamespace.h | 2 +- .../WebCore/storage/StorageNamespaceImpl.cpp | 16 +- .../webkit/WebCore/storage/StorageNamespaceImpl.h | 5 +- .../webkit/WebCore/storage/StorageSyncManager.cpp | 8 +- .../webkit/WebCore/storage/StorageSyncManager.h | 4 +- .../webkit/WebCore/svg/LinearGradientAttributes.h | 32 +- .../webkit/WebCore/svg/RadialGradientAttributes.h | 40 +- src/3rdparty/webkit/WebCore/svg/SVGAElement.cpp | 5 +- src/3rdparty/webkit/WebCore/svg/SVGAElement.h | 13 +- src/3rdparty/webkit/WebCore/svg/SVGAllInOne.cpp | 2 + .../webkit/WebCore/svg/SVGAltGlyphElement.cpp | 1 + .../webkit/WebCore/svg/SVGAltGlyphElement.h | 5 +- .../webkit/WebCore/svg/SVGAnimatedProperty.h | 126 +- .../webkit/WebCore/svg/SVGAnimatedTemplate.h | 2 +- .../webkit/WebCore/svg/SVGAnimationElement.cpp | 3 +- .../webkit/WebCore/svg/SVGAnimationElement.h | 11 +- .../webkit/WebCore/svg/SVGCircleElement.cpp | 1 + src/3rdparty/webkit/WebCore/svg/SVGCircleElement.h | 8 +- .../webkit/WebCore/svg/SVGClipPathElement.cpp | 1 + .../webkit/WebCore/svg/SVGClipPathElement.h | 10 +- .../webkit/WebCore/svg/SVGCursorElement.cpp | 2 + src/3rdparty/webkit/WebCore/svg/SVGCursorElement.h | 13 +- src/3rdparty/webkit/WebCore/svg/SVGDefsElement.cpp | 1 + src/3rdparty/webkit/WebCore/svg/SVGDefsElement.h | 9 +- src/3rdparty/webkit/WebCore/svg/SVGElement.cpp | 17 +- src/3rdparty/webkit/WebCore/svg/SVGElement.h | 35 +- src/3rdparty/webkit/WebCore/svg/SVGElement.idl | 2 +- .../webkit/WebCore/svg/SVGEllipseElement.cpp | 1 + .../webkit/WebCore/svg/SVGEllipseElement.h | 8 +- .../WebCore/svg/SVGExternalResourcesRequired.cpp | 1 - .../WebCore/svg/SVGExternalResourcesRequired.h | 25 +- .../webkit/WebCore/svg/SVGFECompositeElement.idl | 2 +- .../webkit/WebCore/svg/SVGFEFloodElement.cpp | 19 +- .../webkit/WebCore/svg/SVGFEFloodElement.h | 6 +- .../webkit/WebCore/svg/SVGFEFloodElement.idl | 3 - .../webkit/WebCore/svg/SVGFEGaussianBlurElement.h | 2 +- .../webkit/WebCore/svg/SVGFEImageElement.cpp | 2 + .../webkit/WebCore/svg/SVGFEImageElement.h | 13 +- .../webkit/WebCore/svg/SVGFELightElement.h | 3 - .../webkit/WebCore/svg/SVGFEMergeElement.cpp | 2 + .../webkit/WebCore/svg/SVGFEMergeNodeElement.h | 5 - .../webkit/WebCore/svg/SVGFEMorphologyElement.cpp | 88 + .../webkit/WebCore/svg/SVGFEMorphologyElement.h | 52 + .../webkit/WebCore/svg/SVGFEMorphologyElement.idl | 43 + .../webkit/WebCore/svg/SVGFilterElement.cpp | 68 +- src/3rdparty/webkit/WebCore/svg/SVGFilterElement.h | 19 +- .../svg/SVGFilterPrimitiveStandardAttributes.cpp | 59 +- .../svg/SVGFilterPrimitiveStandardAttributes.h | 3 - .../webkit/WebCore/svg/SVGFitToViewBox.cpp | 20 +- src/3rdparty/webkit/WebCore/svg/SVGFitToViewBox.h | 16 +- src/3rdparty/webkit/WebCore/svg/SVGFontElement.cpp | 3 +- src/3rdparty/webkit/WebCore/svg/SVGFontElement.h | 8 +- .../webkit/WebCore/svg/SVGForeignObjectElement.cpp | 2 + .../webkit/WebCore/svg/SVGForeignObjectElement.h | 13 +- src/3rdparty/webkit/WebCore/svg/SVGGElement.cpp | 1 + src/3rdparty/webkit/WebCore/svg/SVGGElement.h | 10 +- .../webkit/WebCore/svg/SVGGradientElement.cpp | 2 + .../webkit/WebCore/svg/SVGGradientElement.h | 12 +- .../webkit/WebCore/svg/SVGImageElement.cpp | 4 +- src/3rdparty/webkit/WebCore/svg/SVGImageElement.h | 11 +- src/3rdparty/webkit/WebCore/svg/SVGLineElement.cpp | 1 + src/3rdparty/webkit/WebCore/svg/SVGLineElement.h | 8 +- .../WebCore/svg/SVGLinearGradientElement.cpp | 19 +- .../webkit/WebCore/svg/SVGMPathElement.cpp | 4 +- src/3rdparty/webkit/WebCore/svg/SVGMPathElement.h | 54 +- .../webkit/WebCore/svg/SVGMarkerElement.cpp | 10 +- src/3rdparty/webkit/WebCore/svg/SVGMarkerElement.h | 14 +- src/3rdparty/webkit/WebCore/svg/SVGMaskElement.cpp | 52 +- src/3rdparty/webkit/WebCore/svg/SVGMaskElement.h | 13 +- src/3rdparty/webkit/WebCore/svg/SVGPathElement.cpp | 1 + src/3rdparty/webkit/WebCore/svg/SVGPathElement.h | 10 +- .../webkit/WebCore/svg/SVGPatternElement.cpp | 8 +- .../webkit/WebCore/svg/SVGPatternElement.h | 17 +- src/3rdparty/webkit/WebCore/svg/SVGPolyElement.cpp | 3 +- src/3rdparty/webkit/WebCore/svg/SVGPolyElement.h | 10 +- .../WebCore/svg/SVGRadialGradientElement.cpp | 48 +- src/3rdparty/webkit/WebCore/svg/SVGRectElement.cpp | 1 + src/3rdparty/webkit/WebCore/svg/SVGRectElement.h | 8 +- src/3rdparty/webkit/WebCore/svg/SVGSVGElement.cpp | 14 +- src/3rdparty/webkit/WebCore/svg/SVGSVGElement.h | 15 +- .../webkit/WebCore/svg/SVGScriptElement.cpp | 2 + src/3rdparty/webkit/WebCore/svg/SVGScriptElement.h | 12 +- .../webkit/WebCore/svg/SVGSwitchElement.cpp | 1 + src/3rdparty/webkit/WebCore/svg/SVGSwitchElement.h | 16 +- .../webkit/WebCore/svg/SVGSymbolElement.cpp | 5 +- src/3rdparty/webkit/WebCore/svg/SVGSymbolElement.h | 17 +- src/3rdparty/webkit/WebCore/svg/SVGTRefElement.cpp | 1 + src/3rdparty/webkit/WebCore/svg/SVGTRefElement.h | 8 +- .../webkit/WebCore/svg/SVGTextContentElement.cpp | 1 + .../webkit/WebCore/svg/SVGTextContentElement.h | 10 +- .../webkit/WebCore/svg/SVGTextPathElement.cpp | 1 + .../webkit/WebCore/svg/SVGTextPathElement.h | 8 +- .../webkit/WebCore/svg/SVGURIReference.cpp | 1 - src/3rdparty/webkit/WebCore/svg/SVGURIReference.h | 8 +- src/3rdparty/webkit/WebCore/svg/SVGUseElement.cpp | 10 +- src/3rdparty/webkit/WebCore/svg/SVGUseElement.h | 13 +- src/3rdparty/webkit/WebCore/svg/SVGViewElement.cpp | 5 +- src/3rdparty/webkit/WebCore/svg/SVGViewElement.h | 14 +- src/3rdparty/webkit/WebCore/svg/SVGViewSpec.cpp | 17 +- src/3rdparty/webkit/WebCore/svg/SVGViewSpec.h | 11 +- .../svg/SynchronizablePropertyController.cpp | 163 + .../WebCore/svg/SynchronizablePropertyController.h | 122 + .../webkit/WebCore/svg/graphics/SVGImage.cpp | 7 +- .../WebCore/svg/graphics/SVGResourceFilter.cpp | 38 +- .../WebCore/svg/graphics/SVGResourceFilter.h | 27 +- .../WebCore/svg/graphics/filters/SVGFEFlood.cpp | 7 +- .../WebCore/svg/graphics/filters/SVGFEFlood.h | 5 +- .../svg/graphics/filters/SVGFEGaussianBlur.cpp | 82 - .../svg/graphics/filters/SVGFEGaussianBlur.h | 58 - .../svg/graphics/filters/SVGFEMorphology.cpp | 8 +- .../WebCore/svg/graphics/filters/SVGFEMorphology.h | 6 +- .../WebCore/svg/graphics/filters/SVGFilter.cpp | 24 +- .../WebCore/svg/graphics/filters/SVGFilter.h | 5 +- src/3rdparty/webkit/WebCore/svg/svgtags.in | 2 - .../webkit/WebCore/websockets/WebSocket.cpp | 18 +- src/3rdparty/webkit/WebCore/websockets/WebSocket.h | 4 + .../webkit/WebCore/websockets/WebSocket.idl | 16 +- .../webkit/WebCore/wml/WMLImageElement.cpp | 5 +- .../WebCore/workers/DedicatedWorkerContext.cpp | 6 +- .../WebCore/workers/DedicatedWorkerContext.h | 6 +- .../WebCore/workers/DedicatedWorkerContext.idl | 2 +- .../workers/DefaultSharedWorkerRepository.cpp | 22 +- .../WebCore/workers/SharedWorkerRepository.h | 3 + .../webkit/WebCore/workers/SharedWorkerThread.cpp | 2 +- src/3rdparty/webkit/WebCore/workers/Worker.cpp | 6 +- src/3rdparty/webkit/WebCore/workers/Worker.h | 6 +- src/3rdparty/webkit/WebCore/workers/Worker.idl | 4 +- .../webkit/WebCore/workers/WorkerContextProxy.h | 2 +- .../WebCore/workers/WorkerMessagingProxy.cpp | 24 +- .../webkit/WebCore/workers/WorkerMessagingProxy.h | 4 +- .../webkit/WebCore/workers/WorkerObjectProxy.h | 2 +- .../webkit/WebCore/workers/WorkerRunLoop.cpp | 4 +- .../webkit/WebCore/workers/WorkerThread.cpp | 4 +- src/3rdparty/webkit/WebKit.pri | 5 +- src/3rdparty/webkit/WebKit/ChangeLog | 133 + .../WebKit/mac/Configurations/Version.xcconfig | 2 +- .../webkit/WebKit/qt/Api/qgraphicswebview.cpp | 78 +- .../webkit/WebKit/qt/Api/qgraphicswebview.h | 3 +- src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp | 39 + src/3rdparty/webkit/WebKit/qt/Api/qwebelement.h | 6 + src/3rdparty/webkit/WebKit/qt/Api/qwebframe.cpp | 42 +- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.cpp | 83 +- src/3rdparty/webkit/WebKit/qt/Api/qwebpage.h | 12 +- src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.cpp | 70 +- src/3rdparty/webkit/WebKit/qt/Api/qwebsettings.h | 6 + src/3rdparty/webkit/WebKit/qt/Api/qwebview.cpp | 32 +- src/3rdparty/webkit/WebKit/qt/ChangeLog | 650 ++ .../webkit/WebKit/qt/Plugins/ICOHandler.cpp | 460 - src/3rdparty/webkit/WebKit/qt/Plugins/ICOHandler.h | 52 - src/3rdparty/webkit/WebKit/qt/Plugins/Plugins.pro | 14 - .../WebKit/qt/WebCoreSupport/DragClientQt.cpp | 2 + .../qt/WebCoreSupport/FrameLoaderClientQt.cpp | 93 +- .../WebKit/qt/WebCoreSupport/InspectorClientQt.cpp | 3 - .../qgraphicswebview/tst_qgraphicswebview.cpp | 76 + .../webkit/WebKit/qt/tests/qwebelement/image.png | Bin 0 -> 14743 bytes .../WebKit/qt/tests/qwebelement/qwebelement.qrc | 1 + .../qt/tests/qwebelement/tst_qwebelement.cpp | 75 + .../webkit/WebKit/qt/tests/qwebframe/qwebframe.pro | 1 + .../WebKit/qt/tests/qwebframe/tst_qwebframe.cpp | 24 + .../webkit/WebKit/qt/tests/qwebpage/qwebpage.pro | 1 + .../WebKit/qt/tests/qwebpage/tst_qwebpage.cpp | 214 +- .../webkit/WebKit/qt/tests/qwebview/qwebview.pro | 1 + .../WebKit/qt/tests/qwebview/tst_qwebview.cpp | 45 + .../webkit/WebKit/qt/tests/resources/test.swf | Bin 0 -> 10085 bytes 1274 files changed, 34097 insertions(+), 12040 deletions(-) create mode 100644 src/3rdparty/webkit/JavaScriptCore/API/JSContextRefPrivate.h create mode 100644 src/3rdparty/webkit/JavaScriptCore/jit/ExecutableAllocatorSymbian.cpp delete mode 100644 src/3rdparty/webkit/JavaScriptCore/jsc.pro create mode 100644 src/3rdparty/webkit/WebCore/ForwardingHeaders/runtime/ExceptionHelpers.h create mode 100644 src/3rdparty/webkit/WebCore/ForwardingHeaders/runtime/JSCell.h create mode 100644 src/3rdparty/webkit/WebCore/ForwardingHeaders/runtime/StructureChain.h create mode 100644 src/3rdparty/webkit/WebCore/WebCore.3DRendering.exp create mode 100644 src/3rdparty/webkit/WebCore/WebCore.Video.exp create mode 100644 src/3rdparty/webkit/WebCore/bindings/ScriptControllerBase.cpp create mode 100644 src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.cpp create mode 100644 src/3rdparty/webkit/WebCore/bindings/js/JSCallbackData.h create mode 100644 src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.cpp create mode 100644 src/3rdparty/webkit/WebCore/bindings/js/JSExceptionBase.h create mode 100644 src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.cpp create mode 100644 src/3rdparty/webkit/WebCore/bindings/js/SerializedScriptValue.h delete mode 100644 src/3rdparty/webkit/WebCore/css/mediaControlsQT.css create mode 100644 src/3rdparty/webkit/WebCore/css/mediaControlsQt.css create mode 100644 src/3rdparty/webkit/WebCore/css/mediaControlsQuickTime.css delete mode 100644 src/3rdparty/webkit/WebCore/css/qt/mediaControls-extras.css create mode 100644 src/3rdparty/webkit/WebCore/dom/BeforeLoadEvent.h create mode 100644 src/3rdparty/webkit/WebCore/dom/BeforeLoadEvent.idl create mode 100644 src/3rdparty/webkit/WebCore/generated/JSBeforeLoadEvent.cpp create mode 100644 src/3rdparty/webkit/WebCore/generated/JSBeforeLoadEvent.h create mode 100644 src/3rdparty/webkit/WebCore/generated/JSSVGFEMorphologyElement.cpp create mode 100644 src/3rdparty/webkit/WebCore/generated/JSSVGFEMorphologyElement.h create mode 100644 src/3rdparty/webkit/WebCore/html/canvas/CanvasActiveInfo.h create mode 100644 src/3rdparty/webkit/WebCore/html/canvas/CanvasActiveInfo.idl create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/TestController.js create mode 100644 src/3rdparty/webkit/WebCore/inspector/front-end/inspectorSyntaxHighlight.css create mode 100644 src/3rdparty/webkit/WebCore/loader/HistoryController.cpp create mode 100644 src/3rdparty/webkit/WebCore/loader/HistoryController.h create mode 100644 src/3rdparty/webkit/WebCore/loader/PolicyCallback.cpp create mode 100644 src/3rdparty/webkit/WebCore/loader/PolicyCallback.h create mode 100644 src/3rdparty/webkit/WebCore/loader/PolicyChecker.cpp create mode 100644 src/3rdparty/webkit/WebCore/loader/PolicyChecker.h create mode 100644 src/3rdparty/webkit/WebCore/loader/RedirectScheduler.cpp create mode 100644 src/3rdparty/webkit/WebCore/loader/RedirectScheduler.h create mode 100644 src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.cpp create mode 100644 src/3rdparty/webkit/WebCore/loader/ResourceLoadNotifier.h create mode 100644 src/3rdparty/webkit/WebCore/platform/graphics/TextRenderingMode.h create mode 100644 src/3rdparty/webkit/WebCore/platform/graphics/filters/FEGaussianBlur.cpp create mode 100644 src/3rdparty/webkit/WebCore/platform/graphics/filters/FEGaussianBlur.h delete mode 100644 src/3rdparty/webkit/WebCore/platform/graphics/qt/ImageSourceQt.cpp create mode 100644 src/3rdparty/webkit/WebCore/platform/image-decoders/qt/RGBA32BufferQt.cpp create mode 100644 src/3rdparty/webkit/WebCore/plugins/symbian/PluginContainerSymbian.cpp create mode 100644 src/3rdparty/webkit/WebCore/plugins/symbian/PluginContainerSymbian.h create mode 100644 src/3rdparty/webkit/WebCore/plugins/symbian/PluginDatabaseSymbian.cpp create mode 100644 src/3rdparty/webkit/WebCore/plugins/symbian/PluginPackageSymbian.cpp create mode 100644 src/3rdparty/webkit/WebCore/plugins/symbian/PluginViewSymbian.cpp create mode 100644 src/3rdparty/webkit/WebCore/plugins/symbian/npinterface.h create mode 100644 src/3rdparty/webkit/WebCore/rendering/RenderMediaControlsChromium.cpp create mode 100644 src/3rdparty/webkit/WebCore/rendering/RenderMediaControlsChromium.h create mode 100644 src/3rdparty/webkit/WebCore/storage/StorageEventDispatcher.cpp create mode 100644 src/3rdparty/webkit/WebCore/svg/SVGFEMorphologyElement.cpp create mode 100644 src/3rdparty/webkit/WebCore/svg/SVGFEMorphologyElement.h create mode 100644 src/3rdparty/webkit/WebCore/svg/SVGFEMorphologyElement.idl create mode 100644 src/3rdparty/webkit/WebCore/svg/SynchronizablePropertyController.cpp create mode 100644 src/3rdparty/webkit/WebCore/svg/SynchronizablePropertyController.h delete mode 100644 src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.cpp delete mode 100644 src/3rdparty/webkit/WebCore/svg/graphics/filters/SVGFEGaussianBlur.h delete mode 100644 src/3rdparty/webkit/WebKit/qt/Plugins/ICOHandler.cpp delete mode 100644 src/3rdparty/webkit/WebKit/qt/Plugins/ICOHandler.h delete mode 100644 src/3rdparty/webkit/WebKit/qt/Plugins/Plugins.pro create mode 100644 src/3rdparty/webkit/WebKit/qt/tests/qwebelement/image.png create mode 100644 src/3rdparty/webkit/WebKit/qt/tests/resources/test.swf diff --git a/src/3rdparty/webkit/ChangeLog b/src/3rdparty/webkit/ChangeLog index e2c1ef5..fb7dddf 100644 --- a/src/3rdparty/webkit/ChangeLog +++ b/src/3rdparty/webkit/ChangeLog @@ -1,3 +1,114 @@ +2009-10-18 Jan Michael Alonzo + + Reviewed by Holger Freyther. + + [GTK] Add MathML to the build system + https://bugs.webkit.org/show_bug.cgi?id=30487 + + Add --enable-mathml to configure. + + * configure.ac: + +2009-10-15 Jan Michael Alonzo + + Reviewed by Xan Lopez. + + [GTK] marshal stamp files are not cleaned after a distclean + https://bugs.webkit.org/show_bug.cgi?id=30156 + + Add the stamp files directly to cleanfiles. Also rearrange the + variable declarations so we don't miss any files that need to be + cleaned up during the clean targets. + + * GNUmakefile.am: + +2009-10-15 Gustavo Noronha Silva + + Unreviewed. Help text fix - Web Sockets default is no, not yes. + + * configure.ac: + +2009-10-12 Jan Michael Alonzo + + Rubberstamped by Eric Seidel. + + [Gtk] Fix icu CFLAG for Darwin + https://bugs.webkit.org/show_bug.cgi?id=29517 + + Don't escape the srcdir variable. Also use $host instead of the + os_foo variables. + + * autotools/webkit.m4: + +2009-10-12 Jan Michael Alonzo + + Reviewed by Gustavo Noronha. + + [Gtk] Use the SQLite3 headers from WebKitLibraries if sqlite3 is undetected + https://bugs.webkit.org/show_bug.cgi?id=29518 + + * configure.ac: + +2009-10-05 Zoltan Horvath + + Reviewed by Simon Hausmann. + + [Qt] Disable TCmalloc for Windows port at the present, because MinGW + hasn't got built-in pthread library. + + * WebKit.pri: + +2009-10-02 Prasanth Ullattil + + Reviewed by Simon Hausmann. + + Disable a few more harmless MSVC warnings. + + * WebKit.pri: + +2009-10-01 Laszlo Gombos + + Unreviewed, build fix. + + [Qt] Symbian build break after r48976. + unix is set for Symbian in the Qt build system. + + * WebKit.pri: + +2009-10-01 Zoltan Horvath + + Reviewed by Simon Hausmann. + + [Qt] Enable TCmalloc for the Linux, Mac and Windows Qt-port + https://bugs.webkit.org/show_bug.cgi?id=27029 + + Remove USE_SYSTEM_MALLOC for Linux, Mac and Windows Qt-port from WebKit.pri, + so these Qt-ports will use TCmalloc as other ports. + + * WebKit.pri: + +2009-10-01 Martin Robinson + + Reviewed by Xan Lopez. + + [GTK] GtkIMContext filtering interferes with DOM key events + https://bugs.webkit.org/show_bug.cgi?id=28733 + + Add new key event test ensuring that IME keypresses are handled. + + * GNUmakefile.am: + +2009-10-01 Philippe Normand + + Reviewed by Xan Lopez. + + [GTK] data: uri support in media player + https://bugs.webkit.org/show_bug.cgi?id=29842 + + Check presence of gstreamer-pbutils-0.10. + + * configure.ac: + 2009-09-26 David Kilzer GTK BUILD FIX: add ENABLE_ORIENTATION_EVENTS support to configure.ac diff --git a/src/3rdparty/webkit/JavaScriptCore/API/APICast.h b/src/3rdparty/webkit/JavaScriptCore/API/APICast.h index b6d1532..b9167a8 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/APICast.h +++ b/src/3rdparty/webkit/JavaScriptCore/API/APICast.h @@ -27,6 +27,7 @@ #define APICast_h #include "JSAPIValueWrapper.h" +#include "JSGlobalObject.h" #include "JSValue.h" #include #include @@ -118,6 +119,7 @@ inline JSContextRef toRef(JSC::ExecState* e) inline JSGlobalContextRef toGlobalRef(JSC::ExecState* e) { + ASSERT(e == e->lexicalGlobalObject()->globalExec()); return reinterpret_cast(e); } diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackConstructor.h b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackConstructor.h index 202b119..c4bd7ad 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackConstructor.h +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackConstructor.h @@ -41,9 +41,12 @@ public: static PassRefPtr createStructure(JSValue proto) { - return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | HasStandardGetOwnPropertySlot | HasDefaultMark | HasDefaultGetPropertyNames)); + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); } +protected: + static const unsigned StructureFlags = ImplementsHasInstance | JSObject::StructureFlags; + private: virtual ConstructType getConstructData(ConstructData&); virtual const ClassInfo* classInfo() const { return &info; } diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackFunction.h b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackFunction.h index 3a17fa2..0cf25c4 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackFunction.h +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackFunction.h @@ -41,7 +41,7 @@ public: // refactor the code so this override isn't necessary static PassRefPtr createStructure(JSValue proto) { - return Structure::create(proto, TypeInfo(ObjectType, HasStandardGetOwnPropertySlot | HasDefaultMark)); + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); } private: diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObject.h b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObject.h index 86f2f32..d19890a 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObject.h +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObject.h @@ -50,9 +50,12 @@ public: static PassRefPtr createStructure(JSValue proto) { - return Structure::create(proto, TypeInfo(ObjectType, ImplementsHasInstance | OverridesHasInstance)); + return Structure::create(proto, TypeInfo(ObjectType, StructureFlags)); } +protected: + static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesHasInstance | OverridesMarkChildren | OverridesGetPropertyNames | Base::StructureFlags; + private: virtual UString className() const; diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSContextRef.cpp b/src/3rdparty/webkit/JavaScriptCore/API/JSContextRef.cpp index c358a84..e6626b7 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSContextRef.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSContextRef.cpp @@ -25,6 +25,7 @@ #include "config.h" #include "JSContextRef.h" +#include "JSContextRefPrivate.h" #include "APICast.h" #include "InitializeThreading.h" @@ -152,3 +153,12 @@ JSContextGroupRef JSContextGetGroup(JSContextRef ctx) ExecState* exec = toJS(ctx); return toRef(&exec->globalData()); } + +JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx) +{ + ExecState* exec = toJS(ctx); + exec->globalData().heap.registerThread(); + JSLock lock(exec); + + return toGlobalRef(exec->lexicalGlobalObject()->globalExec()); +} diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSContextRefPrivate.h b/src/3rdparty/webkit/JavaScriptCore/API/JSContextRefPrivate.h new file mode 100644 index 0000000..ff014ec --- /dev/null +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSContextRefPrivate.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2009 Apple Computer, Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JSContextRefPrivate_h +#define JSContextRefPrivate_h + +#include +#include +#include + +#ifndef __cplusplus +#include +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/*! +@function +@abstract Gets the global context of a JavaScript execution context. +@param ctx The JSContext whose global context you want to get. +@result ctx's global context. +*/ +JS_EXPORT JSGlobalContextRef JSContextGetGlobalContext(JSContextRef ctx); + +#ifdef __cplusplus +} +#endif + +#endif /* JSContextRefPrivate_h */ diff --git a/src/3rdparty/webkit/JavaScriptCore/ChangeLog b/src/3rdparty/webkit/JavaScriptCore/ChangeLog index 05f90b9..8d6c2df 100644 --- a/src/3rdparty/webkit/JavaScriptCore/ChangeLog +++ b/src/3rdparty/webkit/JavaScriptCore/ChangeLog @@ -1,17 +1,1180 @@ +2009-10-19 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Tightened up some put_by_id_transition code generation. + https://bugs.webkit.org/show_bug.cgi?id=30539 + + * jit/JIT.h: + * jit/JITPropertyAccess.cpp: + (JSC::JIT::testPrototype): + (JSC::JIT::privateCompilePutByIdTransition): No need to do object type + checks or read Structures and prototypes from objects: they're all known + constants at compile time. + +2009-10-19 Geoffrey Garen + + Reviewed by Sam Weinig. + + Added a private API for getting a global context from a context, for + clients who want to preserve a context for a later callback. + + * API/APICast.h: + (toGlobalRef): Added an ASSERT, since this function is used more often + than before. + + * API/JSContextRef.cpp: + * API/JSContextRefPrivate.h: Added. The new API. + + * API/tests/testapi.c: + (print_callAsFunction): + (main): Test the new API. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: Build and export the new API. + +2009-10-17 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Tightened up some instanceof code generation. + https://bugs.webkit.org/show_bug.cgi?id=30488 + + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_instanceof): + (JSC::JIT::emitSlow_op_instanceof): No need to do object type checks - + cell type checks and ImplementsDefaultHasIntance checks implicitly + supersede object type checks. + +2009-10-18 Kwang Yul Seo + + Reviewed by Darin Adler. + + Use _stricmp and _strnicmp instead of deprecated stricmp and strnicmp. + https://bugs.webkit.org/show_bug.cgi?id=30474 + + stricmp and strnicmp are deprecated beginning in Visual + C++ 2005. Use _stricmp and _strnicmp instead in StringExtras.h. + + * wtf/StringExtras.h: + (strncasecmp): + (strcasecmp): + +2009-10-16 Geoffrey Garen + + Build fix: apparently we shouldn't export those symbols? + + * JavaScriptCore.exp: + +2009-10-16 Geoffrey Garen + + Build fix: export some symbols. + + * JavaScriptCore.exp: + +2009-10-16 Oliver Hunt + + Reviewed by Gavin Barraclough. + + structure typeinfo flags should be inherited. + https://bugs.webkit.org/show_bug.cgi?id=30468 + + Add StructureFlag constant to the various JSC classes and use + it for the TypeInfo construction. This allows us to simply + accumulate flags by basing each classes StructureInfo on its parents. + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * API/JSCallbackFunction.h: + (JSC::JSCallbackFunction::createStructure): + * API/JSCallbackObject.h: + (JSC::JSCallbackObject::createStructure): + * debugger/DebuggerActivation.h: + (JSC::DebuggerActivation::createStructure): + * runtime/Arguments.h: + (JSC::Arguments::createStructure): + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/DatePrototype.h: + (JSC::DatePrototype::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/GlobalEvalFunction.h: + (JSC::GlobalEvalFunction::createStructure): + * runtime/InternalFunction.h: + (JSC::InternalFunction::createStructure): + * runtime/JSActivation.h: + (JSC::JSActivation::createStructure): + * runtime/JSArray.h: + (JSC::JSArray::createStructure): + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::createStructure): + * runtime/JSByteArray.h: + * runtime/JSFunction.h: + (JSC::JSFunction::createStructure): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::createStructure): + * runtime/JSNotAnObject.h: + (JSC::JSNotAnObject::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.h: + (JSC::JSObject::createStructure): + * runtime/JSStaticScopeObject.h: + (JSC::JSStaticScopeObject::createStructure): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::createStructure): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StringObject.h: + (JSC::StringObject::createStructure): + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): + +2009-10-16 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fast for-in enumeration: Cache JSPropertyNameIterator; cache JSStrings + in JSPropertyNameIterator; inline more code. + + 1.024x as fast on SunSpider (fasta: 1.43x as fast). + + * bytecode/CodeBlock.cpp: + (JSC::CodeBlock::dump): + * bytecode/Opcode.h: + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitGetPropertyNames): + (JSC::BytecodeGenerator::emitNextPropertyName): + * bytecompiler/BytecodeGenerator.h: Added a few extra operands to + op_get_pnames and op_next_pname so that we can track iteration state + in the register file instead of in the JSPropertyNameIterator. (To be + cacheable, the JSPropertyNameIterator must be stateless.) + + * interpreter/Interpreter.cpp: + (JSC::Interpreter::tryCachePutByID): + (JSC::Interpreter::tryCacheGetByID): Updated for rename to + "normalizePrototypeChain" and removal of "isCacheable". + + (JSC::Interpreter::privateExecute): Updated for in-RegisterFile + iteration state tracking. + + * jit/JIT.cpp: + (JSC::JIT::privateCompileMainPass): + * jit/JIT.h: + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_get_pnames): Updated for in-RegisterFile + iteration state tracking. + + (JSC::JIT::emit_op_next_pname): Inlined code generation for op_next_pname. + + * jit/JITStubs.cpp: + (JSC::JITThunks::tryCachePutByID): + (JSC::JITThunks::tryCacheGetByID): Updated for rename to + "normalizePrototypeChain" and removal of "isCacheable". + + (JSC::DEFINE_STUB_FUNCTION): + * jit/JITStubs.h: + (JSC::): Added has_property and to_object stubs. Removed op_next_pname + stub, since has_property is all we need anymore. + + * parser/Nodes.cpp: + (JSC::ForInNode::emitBytecode): Updated for in-RegisterFile + iteration state tracking. + + * runtime/JSCell.h: + * runtime/JSObject.cpp: + (JSC::JSObject::getPropertyNames): Don't do caching at this layer + anymore, since we don't create a JSPropertyNameIterator at this layer. + + * runtime/JSPropertyNameIterator.cpp: + (JSC::JSPropertyNameIterator::create): Do do caching at this layer. + (JSC::JSPropertyNameIterator::get): Updated for in-RegisterFile + iteration state tracking. + (JSC::JSPropertyNameIterator::markChildren): Mark our JSStrings. + + * runtime/JSPropertyNameIterator.h: + (JSC::JSPropertyNameIterator::size): + (JSC::JSPropertyNameIterator::setCachedStructure): + (JSC::JSPropertyNameIterator::cachedStructure): + (JSC::JSPropertyNameIterator::setCachedPrototypeChain): + (JSC::JSPropertyNameIterator::cachedPrototypeChain): + (JSC::JSPropertyNameIterator::JSPropertyNameIterator): + (JSC::Structure::setEnumerationCache): Don't store iteration state in + a JSPropertyNameIterator. Do cache a JSPropertyNameIterator in a + Structure. + + * runtime/JSValue.h: + (JSC::asCell): + * runtime/MarkStack.h: Make those mischievous #include gods happy. + + * runtime/ObjectConstructor.cpp: + + * runtime/Operations.h: + (JSC::normalizePrototypeChain): Renamed countPrototypeChainEntriesAndCheckForProxies + to normalizePrototypeChain, since it changes dictionary prototypes to + non-dictionary objects. + + * runtime/PropertyNameArray.cpp: + (JSC::PropertyNameArray::add): + * runtime/PropertyNameArray.h: + (JSC::PropertyNameArrayData::PropertyNameArrayData): + (JSC::PropertyNameArray::data): + (JSC::PropertyNameArray::size): + (JSC::PropertyNameArray::begin): + (JSC::PropertyNameArray::end): Simplified some code here to help with + current and future refactoring. + + * runtime/Protect.h: + * runtime/Structure.cpp: + (JSC::Structure::~Structure): + (JSC::Structure::addPropertyWithoutTransition): + (JSC::Structure::removePropertyWithoutTransition): No need to clear + the enumeration cache with adding / removing properties without + transition. It is an error to add / remove properties without transition + once an object has been observed, and we can ASSERT to catch that. + + * runtime/Structure.h: + (JSC::Structure::enumerationCache): Changed the enumeration cache to + hold a JSPropertyNameIterator. + + * runtime/StructureChain.cpp: + * runtime/StructureChain.h: + (JSC::StructureChain::head): Removed StructureChain::isCacheable because + it was wrong-headed in two ways: (1) It gave up when a prototype was a + dictionary, but instead we want un-dictionary heavily accessed + prototypes; (2) It folded a test for hasDefaultGetPropertyNames() into + a generic test for "cacheable-ness", but hasDefaultGetPropertyNames() + is only releavant to for-in caching. + +2009-10-16 Steve Falkenburg + + Reviewed by Adam Roben. + + Add a Debug_All configuration to build entire stack as debug. + Change Debug_Internal to: + - stop using _debug suffix for all WebKit/Safari binaries + - not use _debug as a DLL naming suffix + - use non-debug C runtime lib. + + * JavaScriptCore.vcproj/JavaScriptCore.make: Debug build in makefile should build Debug_All. + * JavaScriptCore.vcproj/JavaScriptCore.sln: Add Debug_All configuration. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj: Add Debug_All configuration. + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCoreGenerated.vcproj: Renamed single configuration from "Release" to "all". + * JavaScriptCore.vcproj/JavaScriptCoreSubmit.sln: Add Debug_All configuration. + * JavaScriptCore.vcproj/WTF/WTF.vcproj: Add Debug_All configuration. + * JavaScriptCore.vcproj/jsc/jsc.vcproj: Add Debug_All configuration. + * JavaScriptCore.vcproj/testapi/testapi.vcproj: Add Debug_All configuration. + +2009-10-16 Oliver Hunt + + Reviewed by Gavin Barraclough. + + Make typeinfo flags default to false + https://bugs.webkit.org/show_bug.cgi?id=30372 + + Last part -- replace HasDefaultGetPropertyNames with OverridesGetPropertyNames + flag. + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * API/JSCallbackObject.h: + (JSC::JSCallbackObject::createStructure): + * debugger/DebuggerActivation.h: + (JSC::DebuggerActivation::createStructure): + * runtime/Arguments.h: + (JSC::Arguments::createStructure): + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/DatePrototype.h: + (JSC::DatePrototype::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/GlobalEvalFunction.h: + (JSC::GlobalEvalFunction::createStructure): + * runtime/JSAPIValueWrapper.h: + (JSC::JSAPIValueWrapper::createStructure): + * runtime/JSActivation.h: + (JSC::JSActivation::createStructure): + * runtime/JSArray.h: + (JSC::JSArray::createStructure): + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::createStructure): + * runtime/JSFunction.h: + (JSC::JSFunction::createStructure): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::createStructure): + * runtime/JSNotAnObject.h: + (JSC::JSNotAnObject::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.cpp: + (JSC::JSObject::getPropertyNames): + * runtime/JSObject.h: + (JSC::JSObject::createStructure): + * runtime/JSStaticScopeObject.h: + (JSC::JSStaticScopeObject::createStructure): + * runtime/JSTypeInfo.h: + (JSC::TypeInfo::overridesGetPropertyNames): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::createStructure): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StringObject.h: + (JSC::StringObject::createStructure): + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): + * runtime/StructureChain.cpp: + (JSC::StructureChain::isCacheable): + +2009-10-16 Kevin Ollivier + + wxMSW build fix, we can't use the simple hash there because the PlatformModuleVersion + structure differs. + + * wtf/Platform.h: + +2009-10-16 Laszlo Gombos + + Reviewed by Simon Hausmann. + + [Qt] Implement ExecutableAllocator for Symbian + https://bugs.webkit.org/show_bug.cgi?id=29946 + + Tested with YARR JIT enabled for Symbian; + This patch does not (yet) enable YARR JIT by default. + + * JavaScriptCore.pri: + * jit/ExecutableAllocator.h: + * jit/ExecutableAllocatorSymbian.cpp: Added. + (JSC::ExecutableAllocator::intializePageSize): + (JSC::ExecutablePool::systemAlloc): + (JSC::ExecutablePool::systemRelease): + +2009-10-15 Oliver Hunt + + Reviewed by Darin Adler. + + Make typeinfo flags default to false + https://bugs.webkit.org/show_bug.cgi?id=30372 + + Part 2 -- Reverse the TypeInfo HasDefaultMark flag to OverridesMarkChildren, etc + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * API/JSCallbackFunction.h: + (JSC::JSCallbackFunction::createStructure): + * API/JSCallbackObject.h: + (JSC::JSCallbackObject::createStructure): + * debugger/DebuggerActivation.h: + (JSC::DebuggerActivation::createStructure): + * runtime/Arguments.h: + (JSC::Arguments::createStructure): + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/DatePrototype.h: + (JSC::DatePrototype::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/GetterSetter.h: + (JSC::GetterSetter::createStructure): + * runtime/GlobalEvalFunction.h: + (JSC::GlobalEvalFunction::createStructure): + * runtime/InternalFunction.h: + (JSC::InternalFunction::createStructure): + * runtime/JSAPIValueWrapper.h: + (JSC::JSAPIValueWrapper::createStructure): + * runtime/JSActivation.h: + (JSC::JSActivation::createStructure): + * runtime/JSArray.h: + (JSC::JSArray::createStructure): + (JSC::MarkStack::markChildren): + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::createStructure): + * runtime/JSFunction.h: + (JSC::JSFunction::createStructure): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::createStructure): + * runtime/JSNotAnObject.h: + (JSC::JSNotAnObject::createStructure): + * runtime/JSNumberCell.h: + (JSC::JSNumberCell::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.h: + (JSC::JSObject::createStructure): + * runtime/JSPropertyNameIterator.h: + (JSC::JSPropertyNameIterator::createStructure): + * runtime/JSStaticScopeObject.h: + (JSC::JSStaticScopeObject::createStructure): + * runtime/JSString.h: + (JSC::JSString::createStructure): + * runtime/JSTypeInfo.h: + (JSC::TypeInfo::overridesMarkChildren): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::createStructure): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StringObject.h: + (JSC::StringObject::createStructure): + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): + +2009-10-14 Oliver Hunt + + Reviewed by Geoff Garen. + + Make typeinfo flags default to false + https://bugs.webkit.org/show_bug.cgi?id=30372 + + Part 1. Reverse the HasStandardGetOwnPropertySlot flag. + + * API/JSCallbackConstructor.h: + (JSC::JSCallbackConstructor::createStructure): + * API/JSCallbackFunction.h: + (JSC::JSCallbackFunction::createStructure): + * API/JSCallbackObject.h: + (JSC::JSCallbackObject::createStructure): + * debugger/DebuggerActivation.h: + (JSC::DebuggerActivation::createStructure): + * jit/JITStubs.cpp: + (JSC::DEFINE_STUB_FUNCTION): + * runtime/Arguments.h: + (JSC::Arguments::createStructure): + * runtime/BooleanObject.h: + (JSC::BooleanObject::createStructure): + * runtime/DatePrototype.h: + (JSC::DatePrototype::createStructure): + * runtime/FunctionPrototype.h: + (JSC::FunctionPrototype::createStructure): + * runtime/GlobalEvalFunction.h: + (JSC::GlobalEvalFunction::createStructure): + * runtime/InternalFunction.h: + (JSC::InternalFunction::createStructure): + * runtime/JSActivation.h: + (JSC::JSActivation::createStructure): + * runtime/JSArray.h: + (JSC::JSArray::createStructure): + * runtime/JSByteArray.cpp: + (JSC::JSByteArray::createStructure): + * runtime/JSFunction.h: + (JSC::JSFunction::createStructure): + * runtime/JSGlobalObject.h: + (JSC::JSGlobalObject::createStructure): + * runtime/JSNumberCell.h: + (JSC::JSNumberCell::createStructure): + * runtime/JSONObject.h: + (JSC::JSONObject::createStructure): + * runtime/JSObject.h: + (JSC::JSObject::createStructure): + (JSC::JSCell::fastGetOwnPropertySlot): + * runtime/JSStaticScopeObject.h: + (JSC::JSStaticScopeObject::createStructure): + * runtime/JSString.h: + (JSC::JSString::createStructure): + * runtime/JSTypeInfo.h: + (JSC::TypeInfo::overridesGetOwnPropertySlot): + * runtime/JSVariableObject.h: + (JSC::JSVariableObject::createStructure): + * runtime/JSWrapperObject.h: + (JSC::JSWrapperObject::createStructure): + * runtime/MathObject.h: + (JSC::MathObject::createStructure): + * runtime/NumberConstructor.h: + (JSC::NumberConstructor::createStructure): + * runtime/NumberObject.h: + (JSC::NumberObject::createStructure): + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructor::createStructure): + * runtime/RegExpObject.h: + (JSC::RegExpObject::createStructure): + * runtime/StringObject.h: + (JSC::StringObject::createStructure): + * runtime/StringObjectThatMasqueradesAsUndefined.h: + (JSC::StringObjectThatMasqueradesAsUndefined::createStructure): + +2009-10-14 Kevin Ollivier +2009-10-14 Darin Adler + + Additions so fix for https://bugs.webkit.org/show_bug.cgi?id=18994 + can build on Windows. + + * wtf/MathExtras.h: Added llround and llroundf for Windows. + +2009-10-14 Kevin Ollivier + + wx build fix. Set ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH for plugins while we're still building stubs. + + * wtf/Platform.h: + +2009-10-13 Laszlo Gombos + + Reviewed by Simon Hausmann. + + Refactor ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH + https://bugs.webkit.org/show_bug.cgi?id=30278 + + Move the definition of ENABLE_PLUGIN_PACKAGE_SIMPLE_HASH + from the make system into common code. + + * wtf/Platform.h: + +2009-10-13 Laszlo Gombos + + Reviewed by Darin Adler. + + ARM compiler does not understand reinterpret_cast + https://bugs.webkit.org/show_bug.cgi?id=29034 + + Change reinterpret_cast to regular C style (void*) cast + for the ARM RVCT compiler. + + * assembler/MacroAssemblerCodeRef.h: + (JSC::FunctionPtr::FunctionPtr): + * jit/JITOpcodes.cpp: Cast to FunctionPtr first + instead of directly casting to reinterpret_cast + * jit/JITStubCall.h: Ditto + change the type of m_stub + from void* to FunctionPtr. + (JSC::JITStubCall::JITStubCall): + (JSC::JITStubCall::call): + * jit/JITStubs.cpp: Ditto. + (JSC::DEFINE_STUB_FUNCTION(EncodedJSValue, op_throw)): + +2009-10-11 Oliver Hunt + + Re-enable the JIT. + + * wtf/Platform.h: + +2009-10-10 Oliver Hunt + + Reviewed by Maciej Stachowiak. + + Support for String.trim(), String.trimLeft() and String.trimRight() methods + https://bugs.webkit.org/show_bug.cgi?id=26590 + + Implement trim, trimLeft, and trimRight + + * runtime/StringPrototype.cpp: + (JSC::isTrimWhitespace): + Our normal string whitespace function does not include U+200B which + is needed for compatibility with mozilla's implementation of trim. + U+200B does not appear to be expected according to spec, however I am + choosing to be lax, and match mozilla behavior so have added this + exception. + (JSC::trimString): + +2009-10-09 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Eliminated some legacy bytecode weirdness. + + Use vPC[x] subscripting instead of ++vPC to access instruction operands. + This is simpler, and often more efficient. + + To support this, and to remove use of hard-coded offsets in bytecode and + JIT code generation and dumping, calculate jump offsets from the beginning + of an instruction, rather than the middle or end. + + Also, use OPCODE_LENGTH instead of hard-coded constants for the sizes of + opcodes. + + SunSpider reports no change in JIT mode, and a 1.01x speedup in Interpreter + mode. + + * bytecode/CodeBlock.cpp: + (JSC::printConditionalJump): + (JSC::CodeBlock::dump): + * bytecompiler/BytecodeGenerator.cpp: + (JSC::BytecodeGenerator::emitJump): + (JSC::BytecodeGenerator::emitJumpIfTrue): + (JSC::BytecodeGenerator::emitJumpIfFalse): + (JSC::BytecodeGenerator::emitJumpIfNotFunctionCall): + (JSC::BytecodeGenerator::emitJumpIfNotFunctionApply): + (JSC::BytecodeGenerator::emitComplexJumpScopes): + (JSC::BytecodeGenerator::emitJumpScopes): + (JSC::BytecodeGenerator::emitNextPropertyName): + (JSC::BytecodeGenerator::emitCatch): + (JSC::BytecodeGenerator::emitJumpSubroutine): + (JSC::prepareJumpTableForImmediateSwitch): + (JSC::prepareJumpTableForCharacterSwitch): + (JSC::prepareJumpTableForStringSwitch): + (JSC::BytecodeGenerator::endSwitch): + * bytecompiler/Label.h: + (JSC::Label::setLocation): + (JSC::Label::bind): + * interpreter/Interpreter.cpp: + (JSC::Interpreter::resolve): + (JSC::Interpreter::resolveSkip): + (JSC::Interpreter::resolveGlobal): + (JSC::Interpreter::resolveBase): + (JSC::Interpreter::resolveBaseAndProperty): + (JSC::Interpreter::createExceptionScope): + (JSC::Interpreter::privateExecute): + * interpreter/Interpreter.h: + * jit/JIT.cpp: + (JSC::JIT::privateCompile): + * jit/JITArithmetic.cpp: + (JSC::JIT::emit_op_jnless): + (JSC::JIT::emitSlow_op_jnless): + (JSC::JIT::emit_op_jnlesseq): + (JSC::JIT::emitSlow_op_jnlesseq): + (JSC::JIT::emitBinaryDoubleOp): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_jmp): + (JSC::JIT::emit_op_loop): + (JSC::JIT::emit_op_loop_if_less): + (JSC::JIT::emitSlow_op_loop_if_less): + (JSC::JIT::emit_op_loop_if_lesseq): + (JSC::JIT::emitSlow_op_loop_if_lesseq): + (JSC::JIT::emit_op_loop_if_true): + (JSC::JIT::emitSlow_op_loop_if_true): + (JSC::JIT::emit_op_jfalse): + (JSC::JIT::emitSlow_op_jfalse): + (JSC::JIT::emit_op_jtrue): + (JSC::JIT::emitSlow_op_jtrue): + (JSC::JIT::emit_op_jeq_null): + (JSC::JIT::emit_op_jneq_null): + (JSC::JIT::emit_op_jneq_ptr): + (JSC::JIT::emit_op_jsr): + (JSC::JIT::emit_op_next_pname): + (JSC::JIT::emit_op_jmp_scopes): + +2009-10-09 Geoffrey Garen + + Reviewed by Sam Weinig. + + Migrated some code that didn't belong out of Structure. + + SunSpider says maybe 1.03x faster. + + * runtime/JSCell.h: Nixed Structure::markAggregate, and made marking of + a Structure's prototype the direct responsility of the object using it. + (Giving Structure a mark function was misleading because it implied that + all live structures get marked during GC, when they don't.) + + * runtime/JSGlobalObject.cpp: + (JSC::markIfNeeded): + (JSC::JSGlobalObject::markChildren): Added code to mark prototypes stored + on the global object. Maybe this wasn't necessary, but now we don't have + to wonder. + + * runtime/JSObject.cpp: + (JSC::JSObject::getPropertyNames): + (JSC::JSObject::getOwnPropertyNames): + (JSC::JSObject::getEnumerableNamesFromClassInfoTable): + * runtime/JSObject.h: + (JSC::JSObject::markChildrenDirect): + * runtime/PropertyNameArray.h: + * runtime/Structure.cpp: + * runtime/Structure.h: + (JSC::Structure::setEnumerationCache): + (JSC::Structure::enumerationCache): Moved property name gathering code + from Structure to JSObject because having a Structure iterate its JSObject + was a layering violation. A JSObject is implemented using a Structure; not + the other way around. + +2009-10-09 Mark Rowe + + Attempt to fix the GTK release build. + + * GNUmakefile.am: Include Grammar.cpp in release builds now that + AllInOneFile.cpp is gone. + +2009-10-09 Gabor Loki + + Rubber-stamped by Eric Seidel. + + Add ARM JIT support for Gtk port (disabled by default) + https://bugs.webkit.org/show_bug.cgi?id=30228 + + * GNUmakefile.am: + +2009-10-08 Geoffrey Garen + + Tiger build fix: added a few more variable initializations. + + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncReplace): + (JSC::stringProtoFuncSearch): + +2009-10-08 Geoffrey Garen + + Qt build fix: added missing #include. + + * jsc.cpp: + +2009-10-08 Geoffrey Garen + + Tiger build fix: initialize variable whose initialization the compiler + can't otherwise figure out. + + * runtime/RegExpObject.cpp: + (JSC::RegExpObject::match): + +2009-10-08 Geoffrey Garen + + Windows build fix: updated exports. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-10-08 Geoffrey Garen + + Tiger build fix: fixed file name case. + + * JavaScriptCore.xcodeproj/project.pbxproj: + +2009-10-08 Geoffrey Garen + + Reviewed by Maciej Stachowiak. + + At long last, I pronounce the death of AllInOneFile.cpp. + + SunSpider reports a 1.01x speedup. + + * AllInOneFile.cpp: Removed. + * GNUmakefile.am: + * JavaScriptCore.exp: + * JavaScriptCore.gypi: + * JavaScriptCore.xcodeproj/project.pbxproj: Added missing project files + to compilation stages. + + * parser/Grammar.y: + * parser/Lexer.cpp: + * parser/Lexer.h: + (JSC::jscyylex): + * runtime/ArrayConstructor.cpp: + (JSC::constructArrayWithSizeQuirk): + * runtime/Collector.h: + * runtime/JSCell.cpp: + (JSC::JSCell::operator new): + * runtime/JSCell.h: + (JSC::JSCell::operator new): + * runtime/JSGlobalObject.cpp: + (JSC::JSGlobalObject::operator new): + * runtime/JSNumberCell.h: + (JSC::JSNumberCell::operator new): + * runtime/JSString.cpp: + * runtime/JSString.h: + (JSC::jsString): + (JSC::jsSubstring): + (JSC::jsOwnedString): + * runtime/RegExpConstructor.cpp: + * runtime/RegExpConstructor.h: + (JSC::RegExpConstructorPrivate::RegExpConstructorPrivate): + (JSC::RegExpConstructorPrivate::lastOvector): + (JSC::RegExpConstructorPrivate::tempOvector): + (JSC::RegExpConstructorPrivate::changeLastOvector): + (JSC::RegExpConstructor::performMatch): + * runtime/StringPrototype.cpp: + (JSC::stringProtoFuncMatch): + * yarr/RegexJIT.cpp: + * yarr/RegexJIT.h: + (JSC::Yarr::executeRegex): Inlined a few things that Shark said + were hot, on the presumption that AllInOneFile.cpp used to inline them + automatically. + +2009-10-08 Zoltan Herczeg + + Reviewed by Gavin Barraclough. + + Fix for JIT'ed op_call instructions (evals, constructs, etc.) + when !ENABLE(JIT_OPTIMIZE_CALL) && USE(JSVALUE32_64) + + https://bugs.webkit.org/show_bug.cgi?id=30201 + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): + +2009-10-07 Geoffrey Garen + + Windows build fix: removed no longer exported symbol. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-10-07 Geoffrey Garen + + Reviewed by Oliver Hunt. + + Fixed Database code takes JSLock on secondary + thread, permanently slowing down JavaScript + + Removed the optional lock from Heap::protect, Heap::unprotect, and friends, + since WebCore no longer uses it. + + * JavaScriptCore.exp: + * runtime/Collector.cpp: + (JSC::Heap::protect): + (JSC::Heap::unprotect): + (JSC::Heap::markProtectedObjects): + (JSC::Heap::protectedGlobalObjectCount): + (JSC::Heap::protectedObjectCount): + (JSC::Heap::protectedObjectTypeCounts): + * runtime/Collector.h: + +2009-10-07 Zoltan Horvath + + Reviewed by Darin Adler. + + Allow custom memory allocation control for JavaScriptCore's IdentifierArena + https://bugs.webkit.org/show_bug.cgi?id=30158 + + Inherits IdentifierArena class from FastAllocBase because it has been + instantiated by 'new' in JavaScriptCore/parser/ParserArena.cpp:36. + + * parser/ParserArena.h: + +2009-10-07 Adam Roben + + Export DateInstance::info in a way that works on Windows + + Fixes + fast/dom/Window/window-postmessage-clone.html fails on Windows + + Reviewed by Anders Carlsson. + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + Removed the export of DateInstance::info from here. + + * runtime/DateInstance.h: Use JS_EXPORTDATA to export + DateInstance::info, which is the required way of exporting data on + Windows. + +2009-10-07 Jørgen Lind + + Reviewed by Simon Hausmann. + + When enabling or disabling the JIT through .qmake.cache, make sure + to also toggle ENABLE_YARR_JIT. + + * JavaScriptCore.pri: + +2009-10-06 Priit Laes + + Reviewed by Gavin Barraclough. + + Linking fails with "relocation R_X86_64_PC32 against symbol + `cti_vm_throw'" + https://bugs.webkit.org/show_bug.cgi?id=28422 + + * jit/JITStubs.cpp: + Mark cti_vm_throw symbol as PLT-indirect symbol, so it doesn't end up + in text segment causing relocation errors on amd64 architecture. + Introduced new define SYMBOL_STRING_RELOCATION for such symbols. + +2009-10-06 Oliver Hunt + + Windows linking fix + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def: + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore_debug.def: + +2009-10-06 Oliver Hunt + + Reviewed by NOBODY (build fix). + + Windows build fix. + + * runtime/DateInstance.cpp: + +2009-10-05 Oliver Hunt + + Reviewed by Gavin Barraclough. + + It should be possible to post (clone) built-in JS objects to Workers + https://bugs.webkit.org/show_bug.cgi?id=22878 + + Expose helpers to throw correct exceptions during object graph walk + used for cloning and add a helper function to create Date instances + without going through the JS Date constructor function. + + * JavaScriptCore.exp: + * JavaScriptCore.xcodeproj/project.pbxproj: + * runtime/DateInstance.cpp: + (JSC::DateInstance::DateInstance): + * runtime/DateInstance.h: + * runtime/ExceptionHelpers.cpp: + (JSC::createTypeError): + * runtime/ExceptionHelpers.h: + +2009-10-06 David Levin + + Reviewed by Oliver Hunt. + + StringImpl needs a method to get an instance for another thread which doesn't copy the underlying buffer. + https://bugs.webkit.org/show_bug.cgi?id=30095 + + * wtf/CrossThreadRefCounted.h: + Removed an unused function and assert improvement. + (WTF::CrossThreadRefCounted::isOwnedByCurrentThread): Moved out common code from asserts. + (WTF::CrossThreadRefCounted::ref): Changed assert to use the common method. + (WTF::CrossThreadRefCounted::deref): Changed assert to use the common method. + (WTF::CrossThreadRefCounted::crossThreadCopy): Since this includes a potentially + non-threadsafe operation, add an assert that the class is owned by the current thread. + +2009-10-05 Kevin Ollivier + + wx build fix. Add Symbian files to the list of excludes. + + * wscript: + +2009-10-05 Jocelyn Turcotte + + Reviewed by Simon Hausmann. + + [Qt] Remove precompiled header from JavaScriptCore compilation to + prevent qmake warning during autonomous compilation. + https://bugs.webkit.org/show_bug.cgi?id=30069 + + * JavaScriptCore.pro: + +2009-10-02 Geoffrey Garen + + Reviewed by Sam Weinig. + + Removed the concept of a "fast access cutoff" in arrays, because it + punished some patterns of array access too much, and made things too + complex for inlining in some cases. + + 1.3% speedup on SunSpider. + + * jit/JITOpcodes.cpp: + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emitSlow_op_put_by_val): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emit_op_get_by_val): + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emit_op_put_by_val): + (JSC::JIT::emitSlow_op_put_by_val): + * jit/JITStubs.cpp: + * jit/JITStubs.h: + (JSC::): Check m_vectorLength instead of m_fastAccessCutoff when + getting / putting from / to an array. Inline putting past the end of + the array. + + * runtime/JSArray.cpp: + (JSC::JSArray::JSArray): + (JSC::JSArray::getOwnPropertySlot): + (JSC::JSArray::getOwnPropertyDescriptor): + (JSC::JSArray::put): + (JSC::JSArray::putSlowCase): + (JSC::JSArray::deleteProperty): + (JSC::JSArray::getOwnPropertyNames): + (JSC::JSArray::increaseVectorLength): + (JSC::JSArray::setLength): + (JSC::JSArray::pop): + (JSC::JSArray::push): + (JSC::JSArray::sort): + (JSC::JSArray::fillArgList): + (JSC::JSArray::copyToRegisters): + (JSC::JSArray::compactForSorting): + (JSC::JSArray::checkConsistency): + * runtime/JSArray.h: + (JSC::JSArray::canGetIndex): + (JSC::JSArray::canSetIndex): + (JSC::JSArray::setIndex): + (JSC::JSArray::markChildrenDirect): Removed m_fastAccessCutoff, and + replaced with checks for JSValue() to detect reads and writes from / to + uninitialized parts of the array. + +2009-10-02 Jonni Rainisto + + Reviewed by Darin Adler. + + Math.random() gives too low values on Win32 when _CRT_RAND_S is not defined + https://bugs.webkit.org/show_bug.cgi?id=29956 + + * wtf/RandomNumber.cpp: + (WTF::randomNumber): Added PLATFORM(WIN_OS) to handle 15bit rand() + +2009-10-02 Geoffrey Garen + + Reviewed by Sam Weinig. + + Take one branch instead of two to test for JSValue(). + + 1.1% SunSpider speedup. + + * jit/JITCall.cpp: + (JSC::JIT::compileOpCall): + * jit/JITOpcodes.cpp: + (JSC::JIT::emit_op_to_jsnumber): + (JSC::JIT::emit_op_create_arguments): + * jit/JITPropertyAccess.cpp: + (JSC::JIT::emitSlow_op_get_by_val): + (JSC::JIT::emit_op_put_by_val): Test for the empty value tag, instead + of testing for the cell tag with a 0 payload. + + * runtime/JSValue.cpp: + (JSC::JSValue::description): Added support for dumping the new empty value, + and deleted values, in debug builds. + + * runtime/JSValue.h: + (JSC::JSValue::JSValue()): Construct JSValue() with the empty value tag. + + (JSC::JSValue::JSValue(JSCell*)): Convert null pointer to the empty value + tag, to avoid having two different c++ versions of null / empty. + + (JSC::JSValue::operator bool): Test for the empty value tag, instead + of testing for the cell tag with a 0 payload. + +2009-10-02 Steve Falkenburg + + Reviewed by Mark Rowe. + + + Safari version number shouldn't be exposed in WebKit code + + For a WebKit version of 532.3.4: + Product version is: 5.32.3.4 (was 4.0.3.0) + File version is: 5.32.3.4 (was 4.532.3.4) + + * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.rc: + +2009-10-02 Tor Arne Vestbø + + Rubber-stamped by Simon Hausmann. + + Fix the Qt on Mac OS X build. + + * wtf/FastMalloc.cpp: + +2009-10-02 Jørgen Lind + + Reviewed by Simon Hausmann. + + Allow enabling and disabling of the JIT through a qmake variable. + + Qt's configure may set this variable through .qmake.cache if a + commandline option is given and/or the compile test for hwcap.h + failed/succeeded. + + * JavaScriptCore.pri: + +2009-10-01 Mark Rowe + + Fix the Tiger build. Don't unconditionally enable 3D canvas as it is not supported on Tiger. + + * Configurations/FeatureDefines.xcconfig: + +2009-10-01 Yongjun Zhang + + Reviewed by Darin Adler. + + https://bugs.webkit.org/show_bug.cgi?id=29187 + + Don't inline ~ListRefPtr() to work around winscw compiler forward declaration + bug regarding templated classes. + + The compiler bug is reported at: + https://xdabug001.ext.nokia.com/bugzilla/show_bug.cgi?id=9812 + + The change will be reverted when the above bug is fixed in winscw compiler. + + * wtf/ListRefPtr.h: + (WTF::::~ListRefPtr): + +2009-10-01 Zoltan Horvath + + Reviewed by Simon Hausmann. + + [Qt] Allow custom memory allocation control for the whole JavaScriptCore + https://bugs.webkit.org/show_bug.cgi?id=27029 + + Since in JavaScriptCore almost every class which has been instantiated by operator new is + inherited from FastAllocBase (bug #20422), we disable customizing global operator new for the Qt-port + when USE_SYSTEM_MALLOC=0. + + Add #include to FastMalloc.cpp because it's used by TCMalloc_PageHeap::scavengerThread(). + (It's needed for the functionality of TCmalloc.) + + Add TCSystemAlloc.cpp to JavaScriptCore.pri if USE_SYSTEM_MALLOC is disabled. + + * JavaScriptCore.pri: + * wtf/FastMalloc.cpp: + (WTF::sleep): + * wtf/FastMalloc.h: + +2009-09-30 Gabor Loki + + Reviewed by George Staikos. + + Defines two pseudo-platforms for ARM and Thumb-2 instruction set. + https://bugs.webkit.org/show_bug.cgi?id=29122 + + Introduces WTF_PLATFORM_ARM_TRADITIONAL and WTF_PLATFORM_ARM_THUMB2 + macros on ARM platforms. The PLATFORM(ARM_THUMB2) should be used + when Thumb-2 instruction set is the required target. The + PLATFORM(ARM_TRADITIONAL) is for generic ARM instruction set. In + case where the code is common the PLATFORM(ARM) have to be used. + + Modified by George Wright to correctly work + with the RVCT-defined __TARGET_ARCH_ARM and __TARGET_ARCH_THUMB + compiler macros, as well as adding readability changes. + + * wtf/Platform.h: + +2009-09-30 Oliver Hunt + + Reviewed by Geoff Garen. + + Devirtualise array toString conversion + + Tweak the implementation of Array.prototype.toString to have a fast path + when acting on a true JSArray. + + * runtime/ArrayPrototype.cpp: + (JSC::arrayProtoFuncToString): + 2009-09-30 Csaba Osztrogonac - Reviewed by NOBODY (OOPS!). + Reviewed by Geoffrey Garen. Buildfix for platforms using JSVALUE32. https://bugs.webkit.org/show_bug.cgi?id=29915 After http://trac.webkit.org/changeset/48905 the build broke in JSVALUE32 case. + Also removed unreachable code. * jit/JITArithmetic.cpp: (JSC::JIT::emit_op_add): - Declaration of "OperandTypes types" moved before first use. - Typos fixed: dst modified to result, regT2 added. - - Unnecessary code removed. + - Unreachable code removed. (JSC::JIT::emitSlow_op_add): - Missing declaration of "OperandTypes types" added. diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi index 15a0c0f..4b316c8 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.gypi @@ -1,7 +1,6 @@ { 'variables': { 'javascriptcore_files': [ - 'AllInOneFile.cpp', 'API/APICast.h', 'API/JavaScript.h', 'API/JavaScriptCore.h', @@ -19,6 +18,7 @@ 'API/JSClassRef.h', 'API/JSContextRef.cpp', 'API/JSContextRef.h', + 'API/JSContextRefPrivate.h', 'API/JSObjectRef.cpp', 'API/JSObjectRef.h', 'API/JSProfilerPrivate.cpp', diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri index 2b08980..89c483e 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pri @@ -137,7 +137,8 @@ SOURCES += \ interpreter/RegisterFile.cpp symbian { - SOURCES += runtime/MarkStackSymbian.cpp + SOURCES += jit/ExecutableAllocatorSymbian.cpp \ + runtime/MarkStackSymbian.cpp } else { win32-*|wince* { SOURCES += jit/ExecutableAllocatorWin.cpp \ @@ -148,6 +149,10 @@ symbian { } } +!contains(DEFINES, USE_SYSTEM_MALLOC) { + SOURCES += wtf/TCSystemAlloc.cpp +} + # AllInOneFile.cpp helps gcc analize and optimize code # Other compilers may be able to do this at link time SOURCES += \ diff --git a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro index 0cd2e1a..a1affd4 100644 --- a/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro +++ b/src/3rdparty/webkit/JavaScriptCore/JavaScriptCore.pro @@ -16,7 +16,6 @@ CONFIG(QTDIR_build) { include($$QT_SOURCE_TREE/src/qbase.pri) INSTALLS = DESTDIR = $$OLDDESTDIR - PRECOMPILED_HEADER = $$PWD/../WebKit/qt/WebKit_pch.h DEFINES *= NDEBUG } diff --git a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h index 568260a..3681af8 100644 --- a/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h +++ b/src/3rdparty/webkit/JavaScriptCore/assembler/MacroAssemblerCodeRef.h @@ -69,7 +69,13 @@ public: template explicit FunctionPtr(FunctionType* value) +#if COMPILER(RVCT) + // RVTC compiler needs C-style cast as it fails with the following error + // Error: #694: reinterpret_cast cannot cast away const or other type qualifiers + : m_value((void*)(value)) +#else : m_value(reinterpret_cast(value)) +#endif { ASSERT_VALID_CODE_POINTER(m_value); } diff --git a/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.cpp b/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.cpp index 6bac9b9..18ca2ae 100644 --- a/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/bytecode/CodeBlock.cpp @@ -135,11 +135,6 @@ NEVER_INLINE static const char* debugHookName(int debugHookID) return ""; } -static int locationForOffset(const Vector::const_iterator& begin, Vector::const_iterator& it, int offset) -{ - return it - begin + offset; -} - static void printUnaryOp(int location, Vector::const_iterator& it, const char* op) { int r0 = (++it)->u.operand; @@ -156,11 +151,11 @@ static void printBinaryOp(int location, Vector::const_iterator& it, printf("[%4d] %s\t\t %s, %s, %s\n", location, op, registerName(r0).c_str(), registerName(r1).c_str(), registerName(r2).c_str()); } -static void printConditionalJump(const Vector::const_iterator& begin, Vector::const_iterator& it, int location, const char* op) +static void printConditionalJump(const Vector::const_iterator&, Vector::const_iterator& it, int location, const char* op) { int r0 = (++it)->u.operand; int offset = (++it)->u.operand; - printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(r0).c_str(), offset, locationForOffset(begin, it, offset)); + printf("[%4d] %s\t\t %s, %d(->%d)\n", location, op, registerName(r0).c_str(), offset, location + offset); } static void printGetByIdOp(int location, Vector::const_iterator& it, const Vector& m_identifiers, const char* op) @@ -852,12 +847,12 @@ void CodeBlock::dump(ExecState* exec, const Vector::const_iterator& } case op_jmp: { int offset = (++it)->u.operand; - printf("[%4d] jmp\t\t %d(->%d)\n", location, offset, locationForOffset(begin, it, offset)); + printf("[%4d] jmp\t\t %d(->%d)\n", location, offset, location + offset); break; } case op_loop: { int offset = (++it)->u.operand; - printf("[%4d] loop\t\t %d(->%d)\n", location, offset, locationForOffset(begin, it, offset)); + printf("[%4d] loop\t\t %d(->%d)\n", location, offset, location + offset); break; } case op_jtrue: { @@ -884,56 +879,56 @@ void CodeBlock::dump(ExecState* exec, const Vector::const_iterator& int r0 = (++it)->u.operand; int r1 = (++it)->u.operand; int offset = (++it)->u.operand; - printf("[%4d] jneq_ptr\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); + printf("[%4d] jneq_ptr\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset); break; } case op_jnless: { int r0 = (++it)->u.operand; int r1 = (++it)->u.operand; int offset = (++it)->u.operand; - printf("[%4d] jnless\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); + printf("[%4d] jnless\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset); break; } case op_jnlesseq: { int r0 = (++it)->u.operand; int r1 = (++it)->u.operand; int offset = (++it)->u.operand; - printf("[%4d] jnlesseq\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); + printf("[%4d] jnlesseq\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset); break; } case op_loop_if_less: { int r0 = (++it)->u.operand; int r1 = (++it)->u.operand; int offset = (++it)->u.operand; - printf("[%4d] loop_if_less\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); + printf("[%4d] loop_if_less\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset); break; } case op_loop_if_lesseq: { int r0 = (++it)->u.operand; int r1 = (++it)->u.operand; int offset = (++it)->u.operand; - printf("[%4d] loop_if_lesseq\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, locationForOffset(begin, it, offset)); + printf("[%4d] loop_if_lesseq\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, location + offset); break; } case op_switch_imm: { int tableIndex = (++it)->u.operand; int defaultTarget = (++it)->u.operand; int scrutineeRegister = (++it)->u.operand; - printf("[%4d] switch_imm\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str()); + printf("[%4d] switch_imm\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).c_str()); break; } case op_switch_char: { int tableIndex = (++it)->u.operand; int defaultTarget = (++it)->u.operand; int scrutineeRegister = (++it)->u.operand; - printf("[%4d] switch_char\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str()); + printf("[%4d] switch_char\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).c_str()); break; } case op_switch_string: { int tableIndex = (++it)->u.operand; int defaultTarget = (++it)->u.operand; int scrutineeRegister = (++it)->u.operand; - printf("[%4d] switch_string\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, locationForOffset(begin, it, defaultTarget), registerName(scrutineeRegister).c_str()); + printf("[%4d] switch_string\t %d, %d(->%d), %s\n", location, tableIndex, defaultTarget, location + defaultTarget, registerName(scrutineeRegister).c_str()); break; } case op_new_func: { @@ -1020,16 +1015,18 @@ void CodeBlock::dump(ExecState* exec, const Vector::const_iterator& break; } case op_get_pnames: { - int r0 = (++it)->u.operand; - int r1 = (++it)->u.operand; + int r0 = it[0].u.operand; + int r1 = it[1].u.operand; printf("[%4d] get_pnames\t %s, %s\n", location, registerName(r0).c_str(), registerName(r1).c_str()); + it += OPCODE_LENGTH(op_get_pnames) - 1; break; } case op_next_pname: { - int dest = (++it)->u.operand; - int iter = (++it)->u.operand; - int offset = (++it)->u.operand; - printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(dest).c_str(), registerName(iter).c_str(), offset, locationForOffset(begin, it, offset)); + int dest = it[0].u.operand; + int iter = it[4].u.operand; + int offset = it[5].u.operand; + printf("[%4d] next_pname\t %s, %s, %d(->%d)\n", location, registerName(dest).c_str(), registerName(iter).c_str(), offset, location + offset); + it += OPCODE_LENGTH(op_next_pname) - 1; break; } case op_push_scope: { @@ -1051,7 +1048,7 @@ void CodeBlock::dump(ExecState* exec, const Vector::const_iterator& case op_jmp_scopes: { int scopeDelta = (++it)->u.operand; int offset = (++it)->u.operand; - printf("[%4d] jmp_scopes\t^%d, %d(->%d)\n", location, scopeDelta, offset, locationForOffset(begin, it, offset)); + printf("[%4d] jmp_scopes\t^%d, %d(->%d)\n", location, scopeDelta, offset, location + offset); break; } case op_catch: { @@ -1074,7 +1071,7 @@ void CodeBlock::dump(ExecState* exec, const Vector::const_iterator& case op_jsr: { int retAddrDst = (++it)->u.operand; int offset = (++it)->u.operand; - printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(retAddrDst).c_str(), offset, locationForOffset(begin, it, offset)); + printf("[%4d] jsr\t\t %s, %d(->%d)\n", location, registerName(retAddrDst).c_str(), offset, location + offset); break; } case op_sret: { diff --git a/src/3rdparty/webkit/JavaScriptCore/bytecode/Opcode.h b/src/3rdparty/webkit/JavaScriptCore/bytecode/Opcode.h index c9196ce..8968252 100644 --- a/src/3rdparty/webkit/JavaScriptCore/bytecode/Opcode.h +++ b/src/3rdparty/webkit/JavaScriptCore/bytecode/Opcode.h @@ -152,8 +152,8 @@ namespace JSC { macro(op_strcat, 4) \ macro(op_to_primitive, 3) \ \ - macro(op_get_pnames, 3) \ - macro(op_next_pname, 4) \ + macro(op_get_pnames, 6) \ + macro(op_next_pname, 7) \ \ macro(op_push_scope, 2) \ macro(op_pop_scope, 1) \ diff --git a/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp b/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp index 8951ce3..41b5c39 100644 --- a/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp @@ -608,8 +608,9 @@ void ALWAYS_INLINE BytecodeGenerator::rewindUnaryOp() PassRefPtr