Merge 5.10 into 5.10.0
Change-Id: Ibfbaa8ef89cf45b87a2c65f1da4a708e5464f259
This commit is contained in:
commit
bb3872d609
6
.gitignore
vendored
6
.gitignore
vendored
@ -26,6 +26,9 @@
|
|||||||
/src/corelib/global/qconfig.cpp
|
/src/corelib/global/qconfig.cpp
|
||||||
/src/corelib/global/qconfig.h
|
/src/corelib/global/qconfig.h
|
||||||
/src/corelib/global/qconfig_p.h
|
/src/corelib/global/qconfig_p.h
|
||||||
|
/src/gui/vulkan/qvulkanfunctions.h
|
||||||
|
/src/gui/vulkan/qvulkanfunctions_p.cpp
|
||||||
|
/src/gui/vulkan/qvulkanfunctions_p.h
|
||||||
/bin/qt.conf
|
/bin/qt.conf
|
||||||
/bin/qmake
|
/bin/qmake
|
||||||
/bin/qvkgen
|
/bin/qvkgen
|
||||||
@ -50,7 +53,8 @@ qt*-config.pri
|
|||||||
/doc/qt*/*
|
/doc/qt*/*
|
||||||
|
|
||||||
/src/angle/src/QtANGLE/*.def
|
/src/angle/src/QtANGLE/*.def
|
||||||
/src/angle/src/QtANGLE/libANGLE
|
/src/angle/src/QtANGLE/libANGLE/
|
||||||
|
/src/angle/src/libGLESv2/libANGLE/
|
||||||
|
|
||||||
/src/corelib/global/qfloat16tables.cpp
|
/src/corelib/global/qfloat16tables.cpp
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ void Server::sendFortune()
|
|||||||
QByteArray block;
|
QByteArray block;
|
||||||
QDataStream out(&block, QIODevice::WriteOnly);
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
out.setVersion(QDataStream::Qt_5_10);
|
out.setVersion(QDataStream::Qt_5_10);
|
||||||
const int fortuneIndex = QRandomGenerator::bounded(0, fortunes.size());
|
const int fortuneIndex = QRandomGenerator::global()->bounded(0, fortunes.size());
|
||||||
const QString &message = fortunes.at(fortuneIndex);
|
const QString &message = fortunes.at(fortuneIndex);
|
||||||
out << quint32(message.size());
|
out << quint32(message.size());
|
||||||
out << message;
|
out << message;
|
||||||
|
@ -72,7 +72,7 @@ void Game::newGame()
|
|||||||
mPlayer = Character();
|
mPlayer = Character();
|
||||||
mPlayer.setName(QStringLiteral("Hero"));
|
mPlayer.setName(QStringLiteral("Hero"));
|
||||||
mPlayer.setClassType(Character::Archer);
|
mPlayer.setClassType(Character::Archer);
|
||||||
mPlayer.setLevel(QRandomGenerator::bounded(15, 21));
|
mPlayer.setLevel(QRandomGenerator::global()->bounded(15, 21));
|
||||||
|
|
||||||
mLevels.clear();
|
mLevels.clear();
|
||||||
mLevels.reserve(2);
|
mLevels.reserve(2);
|
||||||
@ -81,10 +81,10 @@ void Game::newGame()
|
|||||||
QVector<Character> villageNpcs;
|
QVector<Character> villageNpcs;
|
||||||
villageNpcs.reserve(2);
|
villageNpcs.reserve(2);
|
||||||
villageNpcs.append(Character(QStringLiteral("Barry the Blacksmith"),
|
villageNpcs.append(Character(QStringLiteral("Barry the Blacksmith"),
|
||||||
QRandomGenerator::bounded(8, 11),
|
QRandomGenerator::global()->bounded(8, 11),
|
||||||
Character::Warrior));
|
Character::Warrior));
|
||||||
villageNpcs.append(Character(QStringLiteral("Terry the Trader"),
|
villageNpcs.append(Character(QStringLiteral("Terry the Trader"),
|
||||||
QRandomGenerator::bounded(6, 8),
|
QRandomGenerator::global()->bounded(6, 8),
|
||||||
Character::Warrior));
|
Character::Warrior));
|
||||||
village.setNpcs(villageNpcs);
|
village.setNpcs(villageNpcs);
|
||||||
mLevels.append(village);
|
mLevels.append(village);
|
||||||
@ -93,13 +93,13 @@ void Game::newGame()
|
|||||||
QVector<Character> dungeonNpcs;
|
QVector<Character> dungeonNpcs;
|
||||||
dungeonNpcs.reserve(3);
|
dungeonNpcs.reserve(3);
|
||||||
dungeonNpcs.append(Character(QStringLiteral("Eric the Evil"),
|
dungeonNpcs.append(Character(QStringLiteral("Eric the Evil"),
|
||||||
QRandomGenerator::bounded(18, 26),
|
QRandomGenerator::global()->bounded(18, 26),
|
||||||
Character::Mage));
|
Character::Mage));
|
||||||
dungeonNpcs.append(Character(QStringLiteral("Eric's Left Minion"),
|
dungeonNpcs.append(Character(QStringLiteral("Eric's Left Minion"),
|
||||||
QRandomGenerator::bounded(5, 7),
|
QRandomGenerator::global()->bounded(5, 7),
|
||||||
Character::Warrior));
|
Character::Warrior));
|
||||||
dungeonNpcs.append(Character(QStringLiteral("Eric's Right Minion"),
|
dungeonNpcs.append(Character(QStringLiteral("Eric's Right Minion"),
|
||||||
QRandomGenerator::bounded(4, 9),
|
QRandomGenerator::global()->bounded(4, 9),
|
||||||
Character::Warrior));
|
Character::Warrior));
|
||||||
dungeon.setNpcs(dungeonNpcs);
|
dungeon.setNpcs(dungeonNpcs);
|
||||||
mLevels.append(dungeon);
|
mLevels.append(dungeon);
|
||||||
|
@ -126,7 +126,6 @@ int main(int argc, char *argv[])
|
|||||||
//! [main start] //! [register meta-type for queued communications]
|
//! [main start] //! [register meta-type for queued communications]
|
||||||
qRegisterMetaType<Block>();
|
qRegisterMetaType<Block>();
|
||||||
//! [register meta-type for queued communications]
|
//! [register meta-type for queued communications]
|
||||||
qsrand(QTime::currentTime().elapsed());
|
|
||||||
|
|
||||||
Window window;
|
Window window;
|
||||||
window.show();
|
window.show();
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
|
|
||||||
#include "renderthread.h"
|
#include "renderthread.h"
|
||||||
|
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
RenderThread::RenderThread(QObject *parent)
|
RenderThread::RenderThread(QObject *parent)
|
||||||
: QThread(parent)
|
: QThread(parent)
|
||||||
{
|
{
|
||||||
@ -82,9 +84,9 @@ void RenderThread::run()
|
|||||||
for (int s = size; s > 0; --s) {
|
for (int s = size; s > 0; --s) {
|
||||||
for (int c = 0; c < 400; ++c) {
|
for (int c = 0; c < 400; ++c) {
|
||||||
//![processing the image (start)]
|
//![processing the image (start)]
|
||||||
int x1 = qMax(0, (qrand() % m_image.width()) - s/2);
|
int x1 = qMax(0, QRandomGenerator::global()->bounded(m_image.width()) - s/2);
|
||||||
int x2 = qMin(x1 + s/2 + 1, m_image.width());
|
int x2 = qMin(x1 + s/2 + 1, m_image.width());
|
||||||
int y1 = qMax(0, (qrand() % m_image.height()) - s/2);
|
int y1 = qMax(0, QRandomGenerator::global()->bounded(m_image.height()) - s/2);
|
||||||
int y2 = qMin(y1 + s/2 + 1, m_image.height());
|
int y2 = qMin(y1 + s/2 + 1, m_image.height());
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int red = 0;
|
int red = 0;
|
||||||
|
@ -70,10 +70,9 @@ class Producer : public QThread
|
|||||||
public:
|
public:
|
||||||
void run() override
|
void run() override
|
||||||
{
|
{
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
for (int i = 0; i < DataSize; ++i) {
|
for (int i = 0; i < DataSize; ++i) {
|
||||||
freeBytes.acquire();
|
freeBytes.acquire();
|
||||||
buffer[i % BufferSize] = "ACGT"[(int)qrand() % 4];
|
buffer[i % BufferSize] = "ACGT"[QRandomGenerator::global()->bounded(4)];
|
||||||
usedBytes.release();
|
usedBytes.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,15 +76,13 @@ public:
|
|||||||
|
|
||||||
void run() override
|
void run() override
|
||||||
{
|
{
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
|
|
||||||
for (int i = 0; i < DataSize; ++i) {
|
for (int i = 0; i < DataSize; ++i) {
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
if (numUsedBytes == BufferSize)
|
if (numUsedBytes == BufferSize)
|
||||||
bufferNotFull.wait(&mutex);
|
bufferNotFull.wait(&mutex);
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
buffer[i % BufferSize] = "ACGT"[(int)qrand() % 4];
|
buffer[i % BufferSize] = "ACGT"[QRandomGenerator::global()->bounded(4)];
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
++numUsedBytes;
|
++numUsedBytes;
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "randomlistmodel.h"
|
#include "randomlistmodel.h"
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
static const int bufferSize(500);
|
static const int bufferSize(500);
|
||||||
@ -101,6 +102,6 @@ void RandomListModel::cacheRows(int from, int to) const
|
|||||||
//![1]
|
//![1]
|
||||||
QString RandomListModel::fetchRow(int position) const
|
QString RandomListModel::fetchRow(int position) const
|
||||||
{
|
{
|
||||||
return QString::number(rand() % ++position);
|
return QString::number(QRandomGenerator::global()->bounded(++position));
|
||||||
}
|
}
|
||||||
//![1]
|
//![1]
|
||||||
|
@ -72,7 +72,7 @@ static QStringList colorPairs(int max)
|
|||||||
// randomize it
|
// randomize it
|
||||||
colors.clear();
|
colors.clear();
|
||||||
while (combinedColors.count()) {
|
while (combinedColors.count()) {
|
||||||
int i = qrand() % combinedColors.count();
|
int i = QRandomGenerator::global()->bounded(combinedColors.count());
|
||||||
colors << combinedColors[i];
|
colors << combinedColors[i];
|
||||||
combinedColors.removeAt(i);
|
combinedColors.removeAt(i);
|
||||||
if (colors.count() == max)
|
if (colors.count() == max)
|
||||||
|
@ -182,7 +182,7 @@ void Server::sendFortune()
|
|||||||
QDataStream out(&block, QIODevice::WriteOnly);
|
QDataStream out(&block, QIODevice::WriteOnly);
|
||||||
out.setVersion(QDataStream::Qt_5_10);
|
out.setVersion(QDataStream::Qt_5_10);
|
||||||
|
|
||||||
out << fortunes[QRandomGenerator::bounded(fortunes.size())];
|
out << fortunes[QRandomGenerator::global()->bounded(fortunes.size())];
|
||||||
//! [4] //! [7]
|
//! [4] //! [7]
|
||||||
|
|
||||||
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
|
QTcpSocket *clientConnection = tcpServer->nextPendingConnection();
|
||||||
|
@ -51,6 +51,8 @@
|
|||||||
#include "fortuneserver.h"
|
#include "fortuneserver.h"
|
||||||
#include "fortunethread.h"
|
#include "fortunethread.h"
|
||||||
|
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
@ -70,7 +72,7 @@ FortuneServer::FortuneServer(QObject *parent)
|
|||||||
//! [1]
|
//! [1]
|
||||||
void FortuneServer::incomingConnection(qintptr socketDescriptor)
|
void FortuneServer::incomingConnection(qintptr socketDescriptor)
|
||||||
{
|
{
|
||||||
QString fortune = fortunes.at(qrand() % fortunes.size());
|
QString fortune = fortunes.at(QRandomGenerator::global()->bounded(fortunes.size()));
|
||||||
FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
|
FortuneThread *thread = new FortuneThread(socketDescriptor, fortune, this);
|
||||||
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
|
||||||
thread->start();
|
thread->start();
|
||||||
|
@ -60,6 +60,5 @@ int main(int argc, char *argv[])
|
|||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
Dialog dialog;
|
Dialog dialog;
|
||||||
dialog.show();
|
dialog.show();
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,6 @@
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
|
|
||||||
Q_INIT_RESOURCE(icons);
|
Q_INIT_RESOURCE(icons);
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ void TorrentClient::connectToPeers()
|
|||||||
|
|
||||||
// Start as many connections as we can
|
// Start as many connections as we can
|
||||||
while (!weighedPeers.isEmpty() && ConnectionManager::instance()->canAddConnection()
|
while (!weighedPeers.isEmpty() && ConnectionManager::instance()->canAddConnection()
|
||||||
&& (qrand() % (ConnectionManager::instance()->maxConnections() / 2))) {
|
&& (QRandomGenerator::global()->bounded(ConnectionManager::instance()->maxConnections() / 2))) {
|
||||||
PeerWireClient *client = new PeerWireClient(ConnectionManager::instance()->clientId(), this);
|
PeerWireClient *client = new PeerWireClient(ConnectionManager::instance()->clientId(), this);
|
||||||
RateController::instance()->addSocket(client);
|
RateController::instance()->addSocket(client);
|
||||||
ConnectionManager::instance()->addConnection(client);
|
ConnectionManager::instance()->addConnection(client);
|
||||||
@ -701,7 +701,7 @@ void TorrentClient::connectToPeers()
|
|||||||
d->connections << client;
|
d->connections << client;
|
||||||
|
|
||||||
// Pick a random peer from the list of weighed peers.
|
// Pick a random peer from the list of weighed peers.
|
||||||
TorrentPeer *peer = weighedPeers.takeAt(qrand() % weighedPeers.size());
|
TorrentPeer *peer = weighedPeers.takeAt(QRandomGenerator::global()->bounded(weighedPeers.size()));
|
||||||
weighedPeers.removeAll(peer);
|
weighedPeers.removeAll(peer);
|
||||||
peer->connectStart = QDateTime::currentSecsSinceEpoch();
|
peer->connectStart = QDateTime::currentSecsSinceEpoch();
|
||||||
peer->lastVisited = peer->connectStart;
|
peer->lastVisited = peer->connectStart;
|
||||||
@ -1114,7 +1114,7 @@ void TorrentClient::scheduleUploads()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((client->peerWireState() & PeerWireClient::ChokingPeer) == 0) {
|
if ((client->peerWireState() & PeerWireClient::ChokingPeer) == 0) {
|
||||||
if ((qrand() % 10) == 0)
|
if ((QRandomGenerator::global()->bounded(10)) == 0)
|
||||||
client->abort();
|
client->abort();
|
||||||
else
|
else
|
||||||
client->chokePeer();
|
client->chokePeer();
|
||||||
@ -1128,7 +1128,7 @@ void TorrentClient::scheduleUploads()
|
|||||||
// random peer to allow it to compete for a position among the
|
// random peer to allow it to compete for a position among the
|
||||||
// downloaders. (This is known as an "optimistic unchoke".)
|
// downloaders. (This is known as an "optimistic unchoke".)
|
||||||
if (!allClients.isEmpty()) {
|
if (!allClients.isEmpty()) {
|
||||||
PeerWireClient *client = allClients[qrand() % allClients.size()];
|
PeerWireClient *client = allClients[QRandomGenerator::global()->bounded(allClients.size())];
|
||||||
if (client->peerWireState() & PeerWireClient::ChokingPeer)
|
if (client->peerWireState() & PeerWireClient::ChokingPeer)
|
||||||
client->unchokePeer();
|
client->unchokePeer();
|
||||||
}
|
}
|
||||||
@ -1189,7 +1189,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
|
|||||||
piece = d->payloads.value(client);
|
piece = d->payloads.value(client);
|
||||||
if (!piece) {
|
if (!piece) {
|
||||||
QList<TorrentPiece *> values = d->pendingPieces.values();
|
QList<TorrentPiece *> values = d->pendingPieces.values();
|
||||||
piece = values.value(qrand() % values.size());
|
piece = values.value(QRandomGenerator::global()->bounded(values.size()));
|
||||||
piece->inProgress = true;
|
piece->inProgress = true;
|
||||||
d->payloads.insert(client, piece);
|
d->payloads.insert(client, piece);
|
||||||
}
|
}
|
||||||
@ -1246,14 +1246,14 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
|
|||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
if (!partialPieces.isEmpty())
|
if (!partialPieces.isEmpty())
|
||||||
piece = partialPieces.value(qrand() % partialPieces.size());
|
piece = partialPieces.value(QRandomGenerator::global()->bounded(partialPieces.size()));
|
||||||
|
|
||||||
if (!piece) {
|
if (!piece) {
|
||||||
// Pick a random piece 3 out of 4 times; otherwise, pick either
|
// Pick a random piece 3 out of 4 times; otherwise, pick either
|
||||||
// one of the most common or the least common pieces available,
|
// one of the most common or the least common pieces available,
|
||||||
// depending on the state we're in.
|
// depending on the state we're in.
|
||||||
int pieceIndex = 0;
|
int pieceIndex = 0;
|
||||||
if (d->state == WarmingUp || (qrand() & 4) == 0) {
|
if (d->state == WarmingUp || (QRandomGenerator::global()->generate() & 4) == 0) {
|
||||||
int *occurrences = new int[d->pieceCount];
|
int *occurrences = new int[d->pieceCount];
|
||||||
memset(occurrences, 0, d->pieceCount * sizeof(int));
|
memset(occurrences, 0, d->pieceCount * sizeof(int));
|
||||||
|
|
||||||
@ -1293,7 +1293,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Select one piece randomly
|
// Select one piece randomly
|
||||||
pieceIndex = piecesReadyForDownload.at(qrand() % piecesReadyForDownload.size());
|
pieceIndex = piecesReadyForDownload.at(QRandomGenerator::global()->bounded(piecesReadyForDownload.size()));
|
||||||
delete [] occurrences;
|
delete [] occurrences;
|
||||||
} else {
|
} else {
|
||||||
// Make up a list of available piece indices, and pick
|
// Make up a list of available piece indices, and pick
|
||||||
@ -1304,7 +1304,7 @@ void TorrentClient::schedulePieceForClient(PeerWireClient *client)
|
|||||||
if (incompletePiecesAvailableToClient.testBit(i))
|
if (incompletePiecesAvailableToClient.testBit(i))
|
||||||
values << i;
|
values << i;
|
||||||
}
|
}
|
||||||
pieceIndex = values.at(qrand() % values.size());
|
pieceIndex = values.at(QRandomGenerator::global()->bounded(values.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a new TorrentPiece and fill in all initial
|
// Create a new TorrentPiece and fill in all initial
|
||||||
@ -1396,8 +1396,8 @@ int TorrentClient::requestBlocks(PeerWireClient *client, TorrentPiece *piece, in
|
|||||||
// speedup comes from an increased chance of receiving
|
// speedup comes from an increased chance of receiving
|
||||||
// different blocks from the different peers.
|
// different blocks from the different peers.
|
||||||
for (int i = 0; i < bits.size(); ++i) {
|
for (int i = 0; i < bits.size(); ++i) {
|
||||||
int a = qrand() % bits.size();
|
int a = QRandomGenerator::global()->bounded(bits.size());
|
||||||
int b = qrand() % bits.size();
|
int b = QRandomGenerator::global()->bounded(bits.size());
|
||||||
int tmp = bits[a];
|
int tmp = bits[a];
|
||||||
bits[a] = bits[b];
|
bits[a] = bits[b];
|
||||||
bits[b] = tmp;
|
bits[b] = tmp;
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
|
||||||
Renderer::Renderer(const QSurfaceFormat &format, Renderer *share, QScreen *screen)
|
Renderer::Renderer(const QSurfaceFormat &format, Renderer *share, QScreen *screen)
|
||||||
@ -68,9 +69,9 @@ Renderer::Renderer(const QSurfaceFormat &format, Renderer *share, QScreen *scree
|
|||||||
m_context->create();
|
m_context->create();
|
||||||
|
|
||||||
m_backgroundColor = QColor::fromRgbF(0.1f, 0.1f, 0.2f, 1.0f);
|
m_backgroundColor = QColor::fromRgbF(0.1f, 0.1f, 0.2f, 1.0f);
|
||||||
m_backgroundColor.setRed(qrand() % 64);
|
m_backgroundColor.setRed(QRandomGenerator::global()->bounded(64));
|
||||||
m_backgroundColor.setGreen(qrand() % 128);
|
m_backgroundColor.setGreen(QRandomGenerator::global()->bounded(128));
|
||||||
m_backgroundColor.setBlue(qrand() % 256);
|
m_backgroundColor.setBlue(QRandomGenerator::global()->bounded(256));
|
||||||
}
|
}
|
||||||
|
|
||||||
HelloWindow::HelloWindow(const QSharedPointer<Renderer> &renderer, QScreen *screen)
|
HelloWindow::HelloWindow(const QSharedPointer<Renderer> &renderer, QScreen *screen)
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
|
|
||||||
#include "bubble.h"
|
#include "bubble.h"
|
||||||
|
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
Bubble::Bubble(const QPointF &position, qreal radius, const QPointF &velocity)
|
Bubble::Bubble(const QPointF &position, qreal radius, const QPointF &velocity)
|
||||||
: position(position), vel(velocity), radius(radius)
|
: position(position), vel(velocity), radius(radius)
|
||||||
{
|
{
|
||||||
@ -80,10 +82,10 @@ void Bubble::drawBubble(QPainter *painter)
|
|||||||
|
|
||||||
QColor Bubble::randomColor()
|
QColor Bubble::randomColor()
|
||||||
{
|
{
|
||||||
int red = int(205 + 50.0*qrand()/(RAND_MAX+1.0));
|
int red = int(205 + QRandomGenerator::global()->bounded(50));
|
||||||
int green = int(205 + 50.0*qrand()/(RAND_MAX+1.0));
|
int green = int(205 + QRandomGenerator::global()->bounded(50));
|
||||||
int blue = int(205 + 50.0*qrand()/(RAND_MAX+1.0));
|
int blue = int(205 + QRandomGenerator::global()->bounded(50));
|
||||||
int alpha = int(91 + 100.0*qrand()/(RAND_MAX+1.0));
|
int alpha = int(91 + QRandomGenerator::global()->bounded(100));
|
||||||
|
|
||||||
return QColor(red, green, blue, alpha);
|
return QColor(red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "glwidget.h"
|
#include "glwidget.h"
|
||||||
|
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
@ -67,7 +68,6 @@ GLWidget::GLWidget(QWidget *parent)
|
|||||||
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
|
: QGLWidget(QGLFormat(QGL::SampleBuffers), parent)
|
||||||
{
|
{
|
||||||
QTime midnight(0, 0, 0);
|
QTime midnight(0, 0, 0);
|
||||||
qsrand(midnight.secsTo(QTime::currentTime()));
|
|
||||||
|
|
||||||
logo = 0;
|
logo = 0;
|
||||||
xRot = 0;
|
xRot = 0;
|
||||||
@ -234,11 +234,11 @@ QSize GLWidget::sizeHint() const
|
|||||||
void GLWidget::createBubbles(int number)
|
void GLWidget::createBubbles(int number)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < number; ++i) {
|
for (int i = 0; i < number; ++i) {
|
||||||
QPointF position(width()*(0.1 + (0.8*qrand()/(RAND_MAX+1.0))),
|
QPointF position(width()*(0.1 + QRandomGenerator::global()->bounded(0.8)),
|
||||||
height()*(0.1 + (0.8*qrand()/(RAND_MAX+1.0))));
|
height()*(0.1 + QRandomGenerator::global()->bounded(0.8)));
|
||||||
qreal radius = qMin(width(), height())*(0.0125 + 0.0875*qrand()/(RAND_MAX+1.0));
|
qreal radius = qMin(width(), height())*(0.0125 + QRandomGenerator::global()->bounded(0.0875));
|
||||||
QPointF velocity(width()*0.0125*(-0.5 + qrand()/(RAND_MAX+1.0)),
|
QPointF velocity(width()*0.0125*(-0.5 + QRandomGenerator::global()->bounded(1.0)),
|
||||||
height()*0.0125*(-0.5 + qrand()/(RAND_MAX+1.0)));
|
height()*0.0125*(-0.5 + QRandomGenerator::global()->bounded(1.0)));
|
||||||
|
|
||||||
bubbles.append(new Bubble(position, radius, velocity));
|
bubbles.append(new Bubble(position, radius, velocity));
|
||||||
}
|
}
|
||||||
|
@ -109,10 +109,10 @@ void Bubble::drawBubble(QPainter *painter)
|
|||||||
|
|
||||||
QColor Bubble::randomColor()
|
QColor Bubble::randomColor()
|
||||||
{
|
{
|
||||||
int red = int(185 + 70.0*qrand()/(RAND_MAX+1.0));
|
int red = int(185 + QRandomGenerator::global()->bounded(70));
|
||||||
int green = int(185 + 70.0*qrand()/(RAND_MAX+1.0));
|
int green = int(185 + QRandomGenerator::global()->bounded(70));
|
||||||
int blue = int(205 + 50.0*qrand()/(RAND_MAX+1.0));
|
int blue = int(205 + QRandomGenerator::global()->bounded(50));
|
||||||
int alpha = int(91 + 100.0*qrand()/(RAND_MAX+1.0));
|
int alpha = int(91 + QRandomGenerator::global()->bounded(100));
|
||||||
|
|
||||||
return QColor(red, green, blue, alpha);
|
return QColor(red, green, blue, alpha);
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include <QPaintEngine>
|
#include <QPaintEngine>
|
||||||
#include <QOpenGLShaderProgram>
|
#include <QOpenGLShaderProgram>
|
||||||
#include <QOpenGLTexture>
|
#include <QOpenGLTexture>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
|
||||||
@ -420,11 +421,11 @@ void GLWidget::paintGL()
|
|||||||
void GLWidget::createBubbles(int number)
|
void GLWidget::createBubbles(int number)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < number; ++i) {
|
for (int i = 0; i < number; ++i) {
|
||||||
QPointF position(width()*(0.1 + (0.8*qrand()/(RAND_MAX+1.0))),
|
QPointF position(width()*(0.1 + QRandomGenerator::global()->bounded(0.8)),
|
||||||
height()*(0.1 + (0.8*qrand()/(RAND_MAX+1.0))));
|
height()*(0.1 + QRandomGenerator::global()->bounded(0.8)));
|
||||||
qreal radius = qMin(width(), height())*(0.0175 + 0.0875*qrand()/(RAND_MAX+1.0));
|
qreal radius = qMin(width(), height())*(0.0175 + QRandomGenerator::global()->bounded(0.0875));
|
||||||
QPointF velocity(width()*0.0175*(-0.5 + qrand()/(RAND_MAX+1.0)),
|
QPointF velocity(width()*0.0175*(-0.5 + QRandomGenerator::global()->bounded(1.0)),
|
||||||
height()*0.0175*(-0.5 + qrand()/(RAND_MAX+1.0)));
|
height()*0.0175*(-0.5 + QRandomGenerator::global()->bounded(1.0)));
|
||||||
|
|
||||||
m_bubbles.append(new Bubble(position, radius, velocity));
|
m_bubbles.append(new Bubble(position, radius, velocity));
|
||||||
}
|
}
|
||||||
|
@ -56,6 +56,7 @@
|
|||||||
#include <QSlider>
|
#include <QSlider>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
|
|
||||||
@ -155,7 +156,9 @@ void MainWindow::addNew()
|
|||||||
{
|
{
|
||||||
if (m_nextY == 4)
|
if (m_nextY == 4)
|
||||||
return;
|
return;
|
||||||
GLWidget *w = new GLWidget(this, false, qRgb(qrand() % 256, qrand() % 256, qrand() % 256));
|
GLWidget *w = new GLWidget(this, false, qRgb(QRandomGenerator::global()->bounded(256),
|
||||||
|
QRandomGenerator::global()->bounded(256),
|
||||||
|
QRandomGenerator::global()->bounded(256)));
|
||||||
m_glWidgets << w;
|
m_glWidgets << w;
|
||||||
connect(m_timer, &QTimer::timeout, w, QOverload<>::of(&QWidget::update));
|
connect(m_timer, &QTimer::timeout, w, QOverload<>::of(&QWidget::update));
|
||||||
m_layout->addWidget(w, m_nextY, m_nextX, 1, 1);
|
m_layout->addWidget(w, m_nextY, m_nextX, 1, 1);
|
||||||
|
@ -48,15 +48,10 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#include "imagescaling.h"
|
#include "imagescaling.h"
|
||||||
|
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
|
||||||
const int imageSize = 100;
|
#include <functional>
|
||||||
|
|
||||||
QImage scale(const QString &imageFileName)
|
|
||||||
{
|
|
||||||
QImage image(imageFileName);
|
|
||||||
return image.scaled(QSize(imageSize, imageSize), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
||||||
}
|
|
||||||
|
|
||||||
Images::Images(QWidget *parent)
|
Images::Images(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
@ -65,19 +60,19 @@ Images::Images(QWidget *parent)
|
|||||||
resize(800, 600);
|
resize(800, 600);
|
||||||
|
|
||||||
imageScaling = new QFutureWatcher<QImage>(this);
|
imageScaling = new QFutureWatcher<QImage>(this);
|
||||||
connect(imageScaling, SIGNAL(resultReadyAt(int)), SLOT(showImage(int)));
|
connect(imageScaling, &QFutureWatcher<QImage>::resultReadyAt, this, &Images::showImage);
|
||||||
connect(imageScaling, SIGNAL(finished()), SLOT(finished()));
|
connect(imageScaling, &QFutureWatcher<QImage>::finished, this, &Images::finished);
|
||||||
|
|
||||||
openButton = new QPushButton(tr("Open Images"));
|
openButton = new QPushButton(tr("Open Images"));
|
||||||
connect(openButton, SIGNAL(clicked()), SLOT(open()));
|
connect(openButton, &QPushButton::clicked, this, &Images::open);
|
||||||
|
|
||||||
cancelButton = new QPushButton(tr("Cancel"));
|
cancelButton = new QPushButton(tr("Cancel"));
|
||||||
cancelButton->setEnabled(false);
|
cancelButton->setEnabled(false);
|
||||||
connect(cancelButton, SIGNAL(clicked()), imageScaling, SLOT(cancel()));
|
connect(cancelButton, &QPushButton::clicked, imageScaling, &QFutureWatcher<QImage>::cancel);
|
||||||
|
|
||||||
pauseButton = new QPushButton(tr("Pause/Resume"));
|
pauseButton = new QPushButton(tr("Pause/Resume"));
|
||||||
pauseButton->setEnabled(false);
|
pauseButton->setEnabled(false);
|
||||||
connect(pauseButton, SIGNAL(clicked()), imageScaling, SLOT(togglePaused()));
|
connect(pauseButton, &QPushButton::clicked, imageScaling, &QFutureWatcher<QImage>::togglePaused);
|
||||||
|
|
||||||
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
QHBoxLayout *buttonLayout = new QHBoxLayout();
|
||||||
buttonLayout->addWidget(openButton);
|
buttonLayout->addWidget(openButton);
|
||||||
@ -113,9 +108,11 @@ void Images::open()
|
|||||||
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation),
|
QStandardPaths::writableLocation(QStandardPaths::PicturesLocation),
|
||||||
"*.jpg *.png");
|
"*.jpg *.png");
|
||||||
|
|
||||||
if (files.count() == 0)
|
if (files.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const int imageSize = 100;
|
||||||
|
|
||||||
// Do a simple layout.
|
// Do a simple layout.
|
||||||
qDeleteAll(labels);
|
qDeleteAll(labels);
|
||||||
labels.clear();
|
labels.clear();
|
||||||
@ -130,6 +127,11 @@ void Images::open()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::function<QImage(const QString&)> scale = [imageSize](const QString &imageFileName) {
|
||||||
|
QImage image(imageFileName);
|
||||||
|
return image.scaled(QSize(imageSize, imageSize), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
|
};
|
||||||
|
|
||||||
// Use mapped to run the thread safe scale function on the files.
|
// Use mapped to run the thread safe scale function on the files.
|
||||||
imageScaling->setFuture(QtConcurrent::mapped(files, scale));
|
imageScaling->setFuture(QtConcurrent::mapped(files, scale));
|
||||||
|
|
||||||
|
@ -57,9 +57,9 @@ class Images : public QWidget
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Images(QWidget *parent = 0);
|
Images(QWidget *parent = nullptr);
|
||||||
~Images();
|
~Images();
|
||||||
public Q_SLOTS:
|
public slots:
|
||||||
void open();
|
void open();
|
||||||
void showImage(int num);
|
void showImage(int num);
|
||||||
void finished();
|
void finished();
|
||||||
|
@ -55,11 +55,7 @@
|
|||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <qtconcurrentmap.h>
|
#include <qtconcurrentmap.h>
|
||||||
|
|
||||||
QImage scale(const QImage &image)
|
#include <functional>
|
||||||
{
|
|
||||||
qDebug() << "Scaling image in thread" << QThread::currentThread();
|
|
||||||
return image.scaled(QSize(100, 100), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -72,6 +68,12 @@ int main(int argc, char *argv[])
|
|||||||
for (int i = 0; i < imageCount; ++i)
|
for (int i = 0; i < imageCount; ++i)
|
||||||
images.append(QImage(1600, 1200, QImage::Format_ARGB32_Premultiplied));
|
images.append(QImage(1600, 1200, QImage::Format_ARGB32_Premultiplied));
|
||||||
|
|
||||||
|
std::function<QImage(const QImage&)> scale = [](const QImage &image) -> QImage
|
||||||
|
{
|
||||||
|
qDebug() << "Scaling image in thread" << QThread::currentThread();
|
||||||
|
return image.scaled(QSize(100, 100), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
|
};
|
||||||
|
|
||||||
// Use QtConcurrentBlocking::mapped to apply the scale function to all the
|
// Use QtConcurrentBlocking::mapped to apply the scale function to all the
|
||||||
// images in the list.
|
// images in the list.
|
||||||
QList<QImage> thumbnails = QtConcurrent::blockingMapped(images, scale);
|
QList<QImage> thumbnails = QtConcurrent::blockingMapped(images, scale);
|
||||||
|
@ -51,24 +51,16 @@
|
|||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#include <QtConcurrent>
|
#include <QtConcurrent>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
|
|
||||||
using namespace QtConcurrent;
|
using namespace QtConcurrent;
|
||||||
|
|
||||||
const int iterations = 20;
|
|
||||||
|
|
||||||
void spin(int &iteration)
|
|
||||||
{
|
|
||||||
const int work = 1000 * 1000 * 40;
|
|
||||||
volatile int v = 0;
|
|
||||||
for (int j = 0; j < work; ++j)
|
|
||||||
++v;
|
|
||||||
|
|
||||||
qDebug() << "iteration" << iteration << "in thread" << QThread::currentThreadId();
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
|
const int iterations = 20;
|
||||||
|
|
||||||
// Prepare the vector.
|
// Prepare the vector.
|
||||||
QVector<int> vector;
|
QVector<int> vector;
|
||||||
for (int i = 0; i < iterations; ++i)
|
for (int i = 0; i < iterations; ++i)
|
||||||
@ -80,10 +72,20 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
// Create a QFutureWatcher and connect signals and slots.
|
// Create a QFutureWatcher and connect signals and slots.
|
||||||
QFutureWatcher<void> futureWatcher;
|
QFutureWatcher<void> futureWatcher;
|
||||||
QObject::connect(&futureWatcher, SIGNAL(finished()), &dialog, SLOT(reset()));
|
QObject::connect(&futureWatcher, &QFutureWatcher<void>::finished, &dialog, &QProgressDialog::reset);
|
||||||
QObject::connect(&dialog, SIGNAL(canceled()), &futureWatcher, SLOT(cancel()));
|
QObject::connect(&dialog, &QProgressDialog::canceled, &futureWatcher, &QFutureWatcher<void>::cancel);
|
||||||
QObject::connect(&futureWatcher, SIGNAL(progressRangeChanged(int,int)), &dialog, SLOT(setRange(int,int)));
|
QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressRangeChanged, &dialog, &QProgressDialog::setRange);
|
||||||
QObject::connect(&futureWatcher, SIGNAL(progressValueChanged(int)), &dialog, SLOT(setValue(int)));
|
QObject::connect(&futureWatcher, &QFutureWatcher<void>::progressValueChanged, &dialog, &QProgressDialog::setValue);
|
||||||
|
|
||||||
|
// Our function to compute
|
||||||
|
std::function<void(int&)> spin = [](int &iteration) {
|
||||||
|
const int work = 1000 * 1000 * 40;
|
||||||
|
volatile int v = 0;
|
||||||
|
for (int j = 0; j < work; ++j)
|
||||||
|
++v;
|
||||||
|
|
||||||
|
qDebug() << "iteration" << iteration << "in thread" << QThread::currentThreadId();
|
||||||
|
};
|
||||||
|
|
||||||
// Start the computation.
|
// Start the computation.
|
||||||
futureWatcher.setFuture(QtConcurrent::map(vector, spin));
|
futureWatcher.setFuture(QtConcurrent::map(vector, spin));
|
||||||
|
@ -65,15 +65,17 @@ using namespace QtConcurrent;
|
|||||||
/*
|
/*
|
||||||
Utility function that recursivily searches for files.
|
Utility function that recursivily searches for files.
|
||||||
*/
|
*/
|
||||||
QStringList findFiles(const QString &startDir, QStringList filters)
|
QStringList findFiles(const QString &startDir, const QStringList &filters)
|
||||||
{
|
{
|
||||||
QStringList names;
|
QStringList names;
|
||||||
QDir dir(startDir);
|
QDir dir(startDir);
|
||||||
|
|
||||||
foreach (QString file, dir.entryList(filters, QDir::Files))
|
const auto files = dir.entryList(filters, QDir::Files);
|
||||||
|
for (const QString &file : files)
|
||||||
names += startDir + '/' + file;
|
names += startDir + '/' + file;
|
||||||
|
|
||||||
foreach (QString subdir, dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot))
|
const auto subdirs = dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||||
|
for (const QString &subdir : subdirs)
|
||||||
names += findFiles(startDir + '/' + subdir, filters);
|
names += findFiles(startDir + '/' + subdir, filters);
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
@ -83,17 +85,18 @@ typedef QMap<QString, int> WordCount;
|
|||||||
/*
|
/*
|
||||||
Single threaded word counter function.
|
Single threaded word counter function.
|
||||||
*/
|
*/
|
||||||
WordCount singleThreadedWordCount(QStringList files)
|
WordCount singleThreadedWordCount(const QStringList &files)
|
||||||
{
|
{
|
||||||
WordCount wordCount;
|
WordCount wordCount;
|
||||||
foreach (QString file, files) {
|
for (const QString &file : files) {
|
||||||
QFile f(file);
|
QFile f(file);
|
||||||
f.open(QIODevice::ReadOnly);
|
f.open(QIODevice::ReadOnly);
|
||||||
QTextStream textStream(&f);
|
QTextStream textStream(&f);
|
||||||
while (textStream.atEnd() == false)
|
while (!textStream.atEnd()) {
|
||||||
foreach (const QString &word, textStream.readLine().split(' '))
|
const auto words = textStream.readLine().split(' ');
|
||||||
|
for (const QString &word : words)
|
||||||
wordCount[word] += 1;
|
wordCount[word] += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return wordCount;
|
return wordCount;
|
||||||
}
|
}
|
||||||
@ -109,9 +112,11 @@ WordCount countWords(const QString &file)
|
|||||||
QTextStream textStream(&f);
|
QTextStream textStream(&f);
|
||||||
WordCount wordCount;
|
WordCount wordCount;
|
||||||
|
|
||||||
while (textStream.atEnd() == false)
|
while (!textStream.atEnd()) {
|
||||||
foreach (const QString &word, textStream.readLine().split(' '))
|
const auto words = textStream.readLine().split(' ');
|
||||||
|
for (const QString &word : words)
|
||||||
wordCount[word] += 1;
|
wordCount[word] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
return wordCount;
|
return wordCount;
|
||||||
}
|
}
|
||||||
@ -137,8 +142,6 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
qDebug() << "warmup";
|
qDebug() << "warmup";
|
||||||
{
|
{
|
||||||
QTime time;
|
|
||||||
time.start();
|
|
||||||
WordCount total = singleThreadedWordCount(files);
|
WordCount total = singleThreadedWordCount(files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,6 @@ static const int MouseCount = 7;
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
//! [1]
|
//! [1]
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
|
||||||
@ -70,9 +71,9 @@ static qreal normalizeAngle(qreal angle)
|
|||||||
//! [0]
|
//! [0]
|
||||||
Mouse::Mouse()
|
Mouse::Mouse()
|
||||||
: angle(0), speed(0), mouseEyeDirection(0),
|
: angle(0), speed(0), mouseEyeDirection(0),
|
||||||
color(qrand() % 256, qrand() % 256, qrand() % 256)
|
color(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))
|
||||||
{
|
{
|
||||||
setTransform(QTransform().rotate(qrand() % (360 * 16)), true);
|
setTransform(QTransform().rotate(QRandomGenerator::global()->bounded(360 * 16)), true);
|
||||||
startTimer(1000 / 33);
|
startTimer(1000 / 33);
|
||||||
}
|
}
|
||||||
//! [0]
|
//! [0]
|
||||||
@ -184,16 +185,16 @@ void Mouse::timerEvent(QTimerEvent *)
|
|||||||
|
|
||||||
// Add some random movement
|
// Add some random movement
|
||||||
//! [10]
|
//! [10]
|
||||||
if (dangerMice.size() > 1 && (qrand() % 10) == 0) {
|
if (dangerMice.size() > 1 && QRandomGenerator::global()->bounded(10) == 0) {
|
||||||
if (qrand() % 1)
|
if (QRandomGenerator::global()->bounded(1))
|
||||||
angle += (qrand() % 100) / 500.0;
|
angle += QRandomGenerator::global()->bounded(1 / 500.0);
|
||||||
else
|
else
|
||||||
angle -= (qrand() % 100) / 500.0;
|
angle -= QRandomGenerator::global()->bounded(1 / 500.0);
|
||||||
}
|
}
|
||||||
//! [10]
|
//! [10]
|
||||||
|
|
||||||
//! [11]
|
//! [11]
|
||||||
speed += (-50 + qrand() % 100) / 100.0;
|
speed += (-50 + QRandomGenerator::global()->bounded(100)) / 100.0;
|
||||||
|
|
||||||
qreal dx = ::sin(angle) * 10;
|
qreal dx = ::sin(angle) * 10;
|
||||||
mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5;
|
mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5;
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
#include <QtWidgets>
|
#include <QtWidgets>
|
||||||
#include <QtCore/qmath.h>
|
#include <QtCore/qmath.h>
|
||||||
|
#include <QtCore/qrandom.h>
|
||||||
#include <QtCore/qstate.h>
|
#include <QtCore/qstate.h>
|
||||||
|
|
||||||
class Pixmap : public QObject, public QGraphicsPixmapItem
|
class Pixmap : public QObject, public QGraphicsPixmapItem
|
||||||
@ -202,8 +203,8 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
// Random
|
// Random
|
||||||
randomState->assignProperty(item, "pos",
|
randomState->assignProperty(item, "pos",
|
||||||
QPointF(-250 + qrand() % 500,
|
QPointF(-250 + QRandomGenerator::global()->bounded(500),
|
||||||
-250 + qrand() % 500));
|
-250 + QRandomGenerator::global()->bounded(500)));
|
||||||
|
|
||||||
// Tiled
|
// Tiled
|
||||||
tiledState->assignProperty(item, "pos",
|
tiledState->assignProperty(item, "pos",
|
||||||
|
@ -125,7 +125,7 @@ public:
|
|||||||
void onEntry(QEvent *) override
|
void onEntry(QEvent *) override
|
||||||
{
|
{
|
||||||
int n;
|
int n;
|
||||||
while ((n = (qrand() % m_stateCount + 1)) == m_lastIndex)
|
while ((n = QRandomGenerator::global()->bounded(m_stateCount) + 1) == m_lastIndex)
|
||||||
{ }
|
{ }
|
||||||
m_lastIndex = n;
|
m_lastIndex = n;
|
||||||
machine()->postEvent(new StateSwitchEvent(n));
|
machine()->postEvent(new StateSwitchEvent(n));
|
||||||
@ -323,8 +323,6 @@ int main(int argc, char **argv)
|
|||||||
window.resize(300, 300);
|
window.resize(300, 300);
|
||||||
window.show();
|
window.show();
|
||||||
|
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,13 +91,12 @@ public:
|
|||||||
: QEventTransition(this, QEvent::Timer)
|
: QEventTransition(this, QEvent::Timer)
|
||||||
{
|
{
|
||||||
setTargetState(target);
|
setTargetState(target);
|
||||||
qsrand((uint)QDateTime::currentSecsSinceEpoch());
|
|
||||||
startTimer(1000);
|
startTimer(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool eventTest(QEvent *e) override
|
bool eventTest(QEvent *e) override
|
||||||
{
|
{
|
||||||
return QEventTransition::eventTest(e) && ((qrand() % 50) == 0);
|
return QEventTransition::eventTest(e) && QRandomGenerator::global()->bounded(50) == 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
//! [4]
|
//! [4]
|
||||||
|
@ -57,8 +57,6 @@ int main(int argc, char *argv[])
|
|||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
Q_INIT_RESOURCE(subattaq);
|
Q_INIT_RESOURCE(subattaq);
|
||||||
|
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
#include <QtCore/QStateMachine>
|
#include <QtCore/QStateMachine>
|
||||||
#include <QtWidgets/QKeyEventTransition>
|
#include <QtWidgets/QKeyEventTransition>
|
||||||
#include <QtCore/QFinalState>
|
#include <QtCore/QFinalState>
|
||||||
|
#include <QtCore/QRandomGenerator>
|
||||||
|
|
||||||
PlayState::PlayState(GraphicsScene *scene, QState *parent)
|
PlayState::PlayState(GraphicsScene *scene, QState *parent)
|
||||||
: QState(parent),
|
: QState(parent),
|
||||||
@ -193,12 +194,12 @@ void LevelState::initializeLevel()
|
|||||||
for (int j = 0; j < subContent.second; ++j ) {
|
for (int j = 0; j < subContent.second; ++j ) {
|
||||||
SubMarine *sub = new SubMarine(submarineDesc.type, submarineDesc.name, submarineDesc.points);
|
SubMarine *sub = new SubMarine(submarineDesc.type, submarineDesc.name, submarineDesc.points);
|
||||||
scene->addItem(sub);
|
scene->addItem(sub);
|
||||||
int random = (qrand() % 15 + 1);
|
int random = QRandomGenerator::global()->bounded(15) + 1;
|
||||||
qreal x = random == 13 || random == 5 ? 0 : scene->width() - sub->size().width();
|
qreal x = random == 13 || random == 5 ? 0 : scene->width() - sub->size().width();
|
||||||
qreal y = scene->height() -(qrand() % 150 + 1) - sub->size().height();
|
qreal y = scene->height() -(QRandomGenerator::global()->bounded(150) + 1) - sub->size().height();
|
||||||
sub->setPos(x,y);
|
sub->setPos(x,y);
|
||||||
sub->setCurrentDirection(x == 0 ? SubMarine::Right : SubMarine::Left);
|
sub->setCurrentDirection(x == 0 ? SubMarine::Right : SubMarine::Left);
|
||||||
sub->setCurrentSpeed(qrand() % 3 + 1);
|
sub->setCurrentSpeed(QRandomGenerator::global()->bounded(3) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -69,6 +69,7 @@
|
|||||||
|
|
||||||
//Qt
|
//Qt
|
||||||
#include <QtCore/QPropertyAnimation>
|
#include <QtCore/QPropertyAnimation>
|
||||||
|
#include <QtCore/QRandomGenerator>
|
||||||
#include <QtWidgets/QGraphicsScene>
|
#include <QtWidgets/QGraphicsScene>
|
||||||
|
|
||||||
//This state is describing when the boat is moving right
|
//This state is describing when the boat is moving right
|
||||||
@ -88,8 +89,8 @@ public:
|
|||||||
protected slots:
|
protected slots:
|
||||||
void onAnimationMovementValueChanged(const QVariant &)
|
void onAnimationMovementValueChanged(const QVariant &)
|
||||||
{
|
{
|
||||||
if (qrand() % 200 + 1 == 3)
|
if (QRandomGenerator::global()->bounded(200) + 1 == 3)
|
||||||
submarine->launchTorpedo(qrand() % 3 + 1);
|
submarine->launchTorpedo(QRandomGenerator::global()->bounded(3) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -80,8 +80,7 @@
|
|||||||
\snippet graphicsview/collidingmice/mouse.cpp 0
|
\snippet graphicsview/collidingmice/mouse.cpp 0
|
||||||
|
|
||||||
To calculate the various components of the mouse's color, we use
|
To calculate the various components of the mouse's color, we use
|
||||||
the global qrand() function which is a thread-safe version of the
|
\l QRandomGenerator.
|
||||||
standard C++ rand() function.
|
|
||||||
|
|
||||||
Then we call the \l {QGraphicsItem::setRotation()}{setRotation()} function
|
Then we call the \l {QGraphicsItem::setRotation()}{setRotation()} function
|
||||||
inherited from QGraphicsItem. Items live in their own local
|
inherited from QGraphicsItem. Items live in their own local
|
||||||
@ -178,12 +177,7 @@
|
|||||||
|
|
||||||
\snippet graphicsview/collidingmice/main.cpp 0
|
\snippet graphicsview/collidingmice/main.cpp 0
|
||||||
|
|
||||||
First, we create an application object and call the global
|
First, we create an application object and create the scene:
|
||||||
qsrand() function to specify the seed used to generate a new
|
|
||||||
random number sequence of pseudo random integers with the
|
|
||||||
previously mentioned qrand() function.
|
|
||||||
|
|
||||||
Then it is time to create the scene:
|
|
||||||
|
|
||||||
\snippet graphicsview/collidingmice/main.cpp 1
|
\snippet graphicsview/collidingmice/main.cpp 1
|
||||||
|
|
||||||
|
@ -257,7 +257,7 @@
|
|||||||
\snippet graphicsview/dragdroprobot/coloritem.cpp 0
|
\snippet graphicsview/dragdroprobot/coloritem.cpp 0
|
||||||
|
|
||||||
\c ColorItem's constructor assigns an opaque random color to its color
|
\c ColorItem's constructor assigns an opaque random color to its color
|
||||||
member by making use of qrand(). For improved usability, it assigns a
|
member by making use of \l QRandomGenerator. For improved usability, it assigns a
|
||||||
tooltip that provides a useful hint to the user, and it also sets a
|
tooltip that provides a useful hint to the user, and it also sets a
|
||||||
suitable cursor. This ensures that the cursor will chance to
|
suitable cursor. This ensures that the cursor will chance to
|
||||||
Qt::OpenHandCursor when the mouse pointer hovers over the item.
|
Qt::OpenHandCursor when the mouse pointer hovers over the item.
|
||||||
|
@ -424,9 +424,8 @@
|
|||||||
\section1 The main() Function
|
\section1 The main() Function
|
||||||
|
|
||||||
In contrast to the complexity of the rest of this example, the \c main()
|
In contrast to the complexity of the rest of this example, the \c main()
|
||||||
function is very simple: We create a QApplication instance, seed the
|
function is very simple: We create a QApplication instance, then create and
|
||||||
randomizer using qsrand(), and then create and show an instance of \c
|
show an instance of \c GraphWidget. Because all nodes in the grid are moved
|
||||||
GraphWidget. Because all nodes in the grid are moved initially, the \c
|
initially, the \c GraphWidget timer will start immediately after control
|
||||||
GraphWidget timer will start immediately after control has returned to the
|
has returned to the event loop.
|
||||||
event loop.
|
|
||||||
*/
|
*/
|
||||||
|
@ -122,10 +122,8 @@ void MainWindow::setupPuzzle()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qsrand(QCursor::pos().x() ^ QCursor::pos().y());
|
|
||||||
|
|
||||||
for (int i = 0; i < piecesList->count(); ++i) {
|
for (int i = 0; i < piecesList->count(); ++i) {
|
||||||
if (int(2.0*qrand()/(RAND_MAX+1.0)) == 1) {
|
if (QRandomGenerator::global()->bounded(2) == 1) {
|
||||||
QListWidgetItem *item = piecesList->takeItem(i);
|
QListWidgetItem *item = piecesList->takeItem(i);
|
||||||
piecesList->insertItem(0, item);
|
piecesList->insertItem(0, item);
|
||||||
}
|
}
|
||||||
|
@ -414,7 +414,7 @@ void QtBox::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
|
|||||||
|
|
||||||
CircleItem::CircleItem(int size, int x, int y) : ItemBase(size, x, y)
|
CircleItem::CircleItem(int size, int x, int y) : ItemBase(size, x, y)
|
||||||
{
|
{
|
||||||
m_color = QColor::fromHsv(rand() % 360, 255, 255);
|
m_color = QColor::fromHsv(QRandomGenerator::global()->bounded(360), 255, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CircleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
void CircleItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include "scene.h"
|
#include "scene.h"
|
||||||
|
#include <QtCore/QRandomGenerator>
|
||||||
#include <QtGui/qmatrix4x4.h>
|
#include <QtGui/qmatrix4x4.h>
|
||||||
#include <QtGui/qvector3d.h>
|
#include <QtGui/qvector3d.h>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
@ -1072,13 +1073,16 @@ void Scene::newItem(ItemDialog::ItemType type)
|
|||||||
QSize size = sceneRect().size().toSize();
|
QSize size = sceneRect().size().toSize();
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case ItemDialog::QtBoxItem:
|
case ItemDialog::QtBoxItem:
|
||||||
addItem(new QtBox(64, rand() % (size.width() - 64) + 32, rand() % (size.height() - 64) + 32));
|
addItem(new QtBox(64, QRandomGenerator::global()->bounded(size.width() - 64) + 32,
|
||||||
|
QRandomGenerator::global()->bounded(size.height() - 64) + 32));
|
||||||
break;
|
break;
|
||||||
case ItemDialog::CircleItem:
|
case ItemDialog::CircleItem:
|
||||||
addItem(new CircleItem(64, rand() % (size.width() - 64) + 32, rand() % (size.height() - 64) + 32));
|
addItem(new CircleItem(64, QRandomGenerator::global()->bounded(size.width() - 64) + 32,
|
||||||
|
QRandomGenerator::global()->bounded(size.height() - 64) + 32));
|
||||||
break;
|
break;
|
||||||
case ItemDialog::SquareItem:
|
case ItemDialog::SquareItem:
|
||||||
addItem(new SquareItem(64, rand() % (size.width() - 64) + 32, rand() % (size.height() - 64) + 32));
|
addItem(new SquareItem(64, QRandomGenerator::global()->bounded(size.width() - 64) + 32,
|
||||||
|
QRandomGenerator::global()->bounded(size.height() - 64) + 32));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -60,7 +60,6 @@ static const int MouseCount = 7;
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
qsrand(QTime(0, 0, 0).secsTo(QTime::currentTime()));
|
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
//! [1]
|
//! [1]
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include <QGraphicsScene>
|
#include <QGraphicsScene>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QStyleOption>
|
#include <QStyleOption>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
|
||||||
@ -70,9 +71,9 @@ static qreal normalizeAngle(qreal angle)
|
|||||||
//! [0]
|
//! [0]
|
||||||
Mouse::Mouse()
|
Mouse::Mouse()
|
||||||
: angle(0), speed(0), mouseEyeDirection(0),
|
: angle(0), speed(0), mouseEyeDirection(0),
|
||||||
color(qrand() % 256, qrand() % 256, qrand() % 256)
|
color(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))
|
||||||
{
|
{
|
||||||
setRotation(qrand() % (360 * 16));
|
setRotation(QRandomGenerator::global()->bounded(360 * 16));
|
||||||
}
|
}
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
@ -185,16 +186,16 @@ void Mouse::advance(int step)
|
|||||||
|
|
||||||
// Add some random movement
|
// Add some random movement
|
||||||
//! [10]
|
//! [10]
|
||||||
if (dangerMice.size() > 1 && (qrand() % 10) == 0) {
|
if (dangerMice.size() > 1 && QRandomGenerator::global()->bounded(10) == 0) {
|
||||||
if (qrand() % 1)
|
if (QRandomGenerator::global()->bounded(1))
|
||||||
angle += (qrand() % 100) / 500.0;
|
angle += QRandomGenerator::global()->bounded(1 / 500.0);
|
||||||
else
|
else
|
||||||
angle -= (qrand() % 100) / 500.0;
|
angle -= QRandomGenerator::global()->bounded(1 / 500.0);
|
||||||
}
|
}
|
||||||
//! [10]
|
//! [10]
|
||||||
|
|
||||||
//! [11]
|
//! [11]
|
||||||
speed += (-50 + qrand() % 100) / 100.0;
|
speed += (-50 + QRandomGenerator::global()->bounded(100)) / 100.0;
|
||||||
|
|
||||||
qreal dx = ::sin(angle) * 10;
|
qreal dx = ::sin(angle) * 10;
|
||||||
mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5;
|
mouseEyeDirection = (qAbs(dx / 5) < 1) ? 0 : dx / 5;
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
ColorItem::ColorItem()
|
ColorItem::ColorItem()
|
||||||
: color(qrand() % 256, qrand() % 256, qrand() % 256)
|
: color(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256))
|
||||||
{
|
{
|
||||||
setToolTip(QString("QColor(%1, %2, %3)\n%4")
|
setToolTip(QString("QColor(%1, %2, %3)\n%4")
|
||||||
.arg(color.red()).arg(color.green()).arg(color.blue())
|
.arg(color.red()).arg(color.green()).arg(color.blue())
|
||||||
@ -107,7 +107,7 @@ void ColorItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||||||
|
|
||||||
//! [6]
|
//! [6]
|
||||||
static int n = 0;
|
static int n = 0;
|
||||||
if (n++ > 2 && (qrand() % 3) == 0) {
|
if (n++ > 2 && QRandomGenerator::global()->bounded(3) == 0) {
|
||||||
QImage image(":/images/head.png");
|
QImage image(":/images/head.png");
|
||||||
mime->setImageData(image);
|
mime->setImageData(image);
|
||||||
|
|
||||||
|
@ -73,7 +73,6 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
//! [0]
|
//! [0]
|
||||||
//! [1]
|
//! [1]
|
||||||
QGraphicsScene scene(-200, -200, 400, 400);
|
QGraphicsScene scene(-200, -200, 400, 400);
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
GraphWidget::GraphWidget(QWidget *parent)
|
GraphWidget::GraphWidget(QWidget *parent)
|
||||||
@ -247,7 +248,7 @@ void GraphWidget::shuffle()
|
|||||||
{
|
{
|
||||||
foreach (QGraphicsItem *item, scene()->items()) {
|
foreach (QGraphicsItem *item, scene()->items()) {
|
||||||
if (qgraphicsitem_cast<Node *>(item))
|
if (qgraphicsitem_cast<Node *>(item))
|
||||||
item->setPos(-150 + qrand() % 300, -150 + qrand() % 300);
|
item->setPos(-150 + QRandomGenerator::global()->bounded(300), -150 + QRandomGenerator::global()->bounded(300));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
|
|
||||||
GraphWidget *widget = new GraphWidget;
|
GraphWidget *widget = new GraphWidget;
|
||||||
|
|
||||||
|
@ -114,8 +114,6 @@ void MainWindow::setupPuzzle()
|
|||||||
(puzzleImage.height() - size) / 2, size, size).scaled(puzzleWidget->imageSize(),
|
(puzzleImage.height() - size) / 2, size, size).scaled(puzzleWidget->imageSize(),
|
||||||
puzzleWidget->imageSize(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
puzzleWidget->imageSize(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||||
|
|
||||||
qsrand(QCursor::pos().x() ^ QCursor::pos().y());
|
|
||||||
|
|
||||||
model->addPieces(puzzleImage);
|
model->addPieces(puzzleImage);
|
||||||
puzzleWidget->clear();
|
puzzleWidget->clear();
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
PiecesModel::PiecesModel(int pieceSize, QObject *parent)
|
PiecesModel::PiecesModel(int pieceSize, QObject *parent)
|
||||||
: QAbstractListModel(parent), m_PieceSize(pieceSize)
|
: QAbstractListModel(parent), m_PieceSize(pieceSize)
|
||||||
@ -77,7 +78,7 @@ QVariant PiecesModel::data(const QModelIndex &index, int role) const
|
|||||||
void PiecesModel::addPiece(const QPixmap &pixmap, const QPoint &location)
|
void PiecesModel::addPiece(const QPixmap &pixmap, const QPoint &location)
|
||||||
{
|
{
|
||||||
int row;
|
int row;
|
||||||
if (int(2.0 * qrand() / (RAND_MAX + 1.0)) == 1)
|
if (QRandomGenerator::global()->bounded(2) == 1)
|
||||||
row = 0;
|
row = 0;
|
||||||
else
|
else
|
||||||
row = pixmaps.size();
|
row = pixmaps.size();
|
||||||
|
@ -50,6 +50,8 @@
|
|||||||
|
|
||||||
#include "toolbar.h"
|
#include "toolbar.h"
|
||||||
|
|
||||||
|
#include <QRandomGenerator>
|
||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
@ -257,7 +259,7 @@ void ToolBar::randomize()
|
|||||||
QList<QAction *> randomized;
|
QList<QAction *> randomized;
|
||||||
QList<QAction *> actions = this->actions();
|
QList<QAction *> actions = this->actions();
|
||||||
while (!actions.isEmpty()) {
|
while (!actions.isEmpty()) {
|
||||||
QAction *action = actions.takeAt(rand() % actions.size());
|
QAction *action = actions.takeAt(QRandomGenerator::global()->bounded(actions.size()));
|
||||||
randomized.append(action);
|
randomized.append(action);
|
||||||
}
|
}
|
||||||
clear();
|
clear();
|
||||||
|
@ -248,11 +248,9 @@ void Window::movePlayer(Direction direction)
|
|||||||
|
|
||||||
void Window::setupMap()
|
void Window::setupMap()
|
||||||
{
|
{
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
|
|
||||||
for (int x = 0; x < WIDTH; ++x)
|
for (int x = 0; x < WIDTH; ++x)
|
||||||
for (int y = 0; y < HEIGHT; ++y) {
|
for (int y = 0; y < HEIGHT; ++y) {
|
||||||
if (x == 0 || x == WIDTH - 1 || y == 0 || y == HEIGHT - 1 || qrand() % 40 == 0)
|
if (x == 0 || x == WIDTH - 1 || y == 0 || y == HEIGHT - 1 || QRandomGenerator::global()->bounded(40) == 0)
|
||||||
map[x][y] = '#';
|
map[x][y] = '#';
|
||||||
else
|
else
|
||||||
map[x][y] = '.';
|
map[x][y] = '.';
|
||||||
|
@ -101,7 +101,7 @@ QRect BasicToolsPlugin::mouseMove(const QString &brush, QPainter &painter,
|
|||||||
thickness, thickness);
|
thickness, thickness);
|
||||||
}
|
}
|
||||||
} else if (brush == tr("Random Letters")) {
|
} else if (brush == tr("Random Letters")) {
|
||||||
QChar ch('A' + (qrand() % 26));
|
QChar ch(QRandomGenerator::global()->bounded('A', 'Z' + 1));
|
||||||
|
|
||||||
QFont biggerFont = painter.font();
|
QFont biggerFont = painter.font();
|
||||||
biggerFont.setBold(true);
|
biggerFont.setBold(true);
|
||||||
|
@ -52,6 +52,7 @@
|
|||||||
#include <QUndoStack>
|
#include <QUndoStack>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QRandomGenerator>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
@ -321,7 +322,7 @@ void MainWindow::newDocument()
|
|||||||
|
|
||||||
static QColor randomColor()
|
static QColor randomColor()
|
||||||
{
|
{
|
||||||
int r = (int) (3.0*(rand()/(RAND_MAX + 1.0)));
|
int r = QRandomGenerator::global()->bounded(3);
|
||||||
switch (r) {
|
switch (r) {
|
||||||
case 0:
|
case 0:
|
||||||
return Qt::red;
|
return Qt::red;
|
||||||
@ -337,10 +338,10 @@ static QRect randomRect(const QSize &s)
|
|||||||
{
|
{
|
||||||
QSize min = Shape::minSize;
|
QSize min = Shape::minSize;
|
||||||
|
|
||||||
int left = (int) ((0.0 + s.width() - min.width())*(rand()/(RAND_MAX + 1.0)));
|
int left = (int) ((0.0 + s.width() - min.width())*(QRandomGenerator::global()->bounded(1.0)));
|
||||||
int top = (int) ((0.0 + s.height() - min.height())*(rand()/(RAND_MAX + 1.0)));
|
int top = (int) ((0.0 + s.height() - min.height())*(QRandomGenerator::global()->bounded(1.0)));
|
||||||
int width = (int) ((0.0 + s.width() - left - min.width())*(rand()/(RAND_MAX + 1.0))) + min.width();
|
int width = (int) ((0.0 + s.width() - left - min.width())*(QRandomGenerator::global()->bounded(1.0))) + min.width();
|
||||||
int height = (int) ((0.0 + s.height() - top - min.height())*(rand()/(RAND_MAX + 1.0))) + min.height();
|
int height = (int) ((0.0 + s.height() - top - min.height())*(QRandomGenerator::global()->bounded(1.0))) + min.height();
|
||||||
|
|
||||||
return QRect(left, top, width, height);
|
return QRect(left, top, width, height);
|
||||||
}
|
}
|
||||||
|
@ -65,8 +65,7 @@ DiagramItem::DiagramItem(DiagramType diagramType, QGraphicsItem *item)
|
|||||||
setPolygon(trianglePolygon);
|
setPolygon(trianglePolygon);
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor color(static_cast<int>(qrand()) % 256,
|
QColor color(QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256), QRandomGenerator::global()->bounded(256));
|
||||||
static_cast<int>(qrand()) % 256, static_cast<int>(qrand()) % 256);
|
|
||||||
QBrush brush(color);
|
QBrush brush(color);
|
||||||
setBrush(brush);
|
setBrush(brush);
|
||||||
setFlag(QGraphicsItem::ItemIsSelectable);
|
setFlag(QGraphicsItem::ItemIsSelectable);
|
||||||
|
@ -59,6 +59,5 @@ int main(int argc, char *argv[])
|
|||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
TetrixWindow window;
|
TetrixWindow window;
|
||||||
window.show();
|
window.show();
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
return app.exec();
|
return app.exec();
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
//! [0]
|
//! [0]
|
||||||
void TetrixPiece::setRandomShape()
|
void TetrixPiece::setRandomShape()
|
||||||
{
|
{
|
||||||
setShape(TetrixShape(qrand() % 7 + 1));
|
setShape(TetrixShape(QRandomGenerator::global()->bounded(7) + 1));
|
||||||
}
|
}
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
|
@ -57,7 +57,6 @@ int main(int argc, char *argv[])
|
|||||||
Q_INIT_RESOURCE(tooltips);
|
Q_INIT_RESOURCE(tooltips);
|
||||||
|
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
qsrand(QTime(0,0,0).secsTo(QTime::currentTime()));
|
|
||||||
SortingBox sortingBox;
|
SortingBox sortingBox;
|
||||||
sortingBox.show();
|
sortingBox.show();
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
@ -292,7 +292,7 @@ QPoint SortingBox::initialItemPosition(const QPainterPath &path)
|
|||||||
//! [24]
|
//! [24]
|
||||||
QPoint SortingBox::randomItemPosition()
|
QPoint SortingBox::randomItemPosition()
|
||||||
{
|
{
|
||||||
return QPoint(qrand() % (width() - 120), qrand() % (height() - 120));
|
return QPoint(QRandomGenerator::global()->bounded(width() - 120), QRandomGenerator::global()->bounded(height() - 120));
|
||||||
}
|
}
|
||||||
//! [24]
|
//! [24]
|
||||||
|
|
||||||
@ -306,6 +306,6 @@ QColor SortingBox::initialItemColor()
|
|||||||
//! [26]
|
//! [26]
|
||||||
QColor SortingBox::randomItemColor()
|
QColor SortingBox::randomItemColor()
|
||||||
{
|
{
|
||||||
return QColor::fromHsv(qrand() % 256, 255, 190);
|
return QColor::fromHsv(QRandomGenerator::global()->bounded(256), 255, 190);
|
||||||
}
|
}
|
||||||
//! [26]
|
//! [26]
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2015 The Qt Company Ltd.
|
|
||||||
** Contact: http://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of the FOO module of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:BSD-OLD$
|
|
||||||
** You may use this file under the terms of the BSD license as follows:
|
|
||||||
**
|
|
||||||
** "Redistribution and use in source and binary forms, with or without
|
|
||||||
** modification, are permitted provided that the following conditions are
|
|
||||||
** met:
|
|
||||||
** * Redistributions of source code must retain the above copyright
|
|
||||||
** notice, this list of conditions and the following disclaimer.
|
|
||||||
** * 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.
|
|
||||||
** * Neither the name of The Qt Company Ltd nor the names of its
|
|
||||||
** contributors may be used to endorse or promote products derived
|
|
||||||
** from this software without specific prior written permission.
|
|
||||||
**
|
|
||||||
**
|
|
||||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
** "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 THE COPYRIGHT
|
|
||||||
** OWNER 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."
|
|
||||||
**
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
@ -1,27 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
**
|
|
||||||
** Copyright (C) 2015 The Qt Company Ltd.
|
|
||||||
** Contact: http://www.qt.io/licensing/
|
|
||||||
**
|
|
||||||
** This file is part of the documentation of the Qt Toolkit.
|
|
||||||
**
|
|
||||||
** $QT_BEGIN_LICENSE:FDL-OLD$
|
|
||||||
** Commercial License Usage
|
|
||||||
** Licensees holding valid commercial Qt licenses may use this file in
|
|
||||||
** accordance with the commercial license agreement provided with the
|
|
||||||
** Software or, alternatively, in accordance with the terms contained in
|
|
||||||
** a written agreement between you and The Qt Company. For licensing terms
|
|
||||||
** and conditions see http://www.qt.io/terms-conditions. For further
|
|
||||||
** information use the contact form at http://www.qt.io/contact-us.
|
|
||||||
**
|
|
||||||
** GNU Free Documentation License Usage
|
|
||||||
** Alternatively, this file may be used under the terms of the GNU Free
|
|
||||||
** Documentation License version 1.3 as published by the Free Software
|
|
||||||
** Foundation and appearing in the file included in the packaging of
|
|
||||||
** this file. Please review the following information to ensure
|
|
||||||
** the GNU Free Documentation License version 1.3 requirements
|
|
||||||
** will be met: http://www.gnu.org/copyleft/fdl.html.
|
|
||||||
** $QT_END_LICENSE$
|
|
||||||
**
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
@ -40,10 +40,12 @@
|
|||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
booted_simulator=$($DIR/devices.pl "$1" "Booted" "NOT unavailable" | tail -n 1)
|
scheme=$1
|
||||||
|
shift
|
||||||
|
booted_simulator=$($DIR/devices.py --state booted $@ | tail -n 1)
|
||||||
echo "SIMULATOR_DEVICES = $booted_simulator"
|
echo "SIMULATOR_DEVICES = $booted_simulator"
|
||||||
|
|
||||||
xcodebuild test -scheme $2 -destination 'id=0' -destination-timeout 1 2>&1| sed -n 's/{ \(platform:.*\) }/\1/p' | while read destination; do
|
xcodebuild test -scheme $scheme -destination 'id=0' -destination-timeout 1 2>&1| sed -n 's/{ \(platform:.*\) }/\1/p' | while read destination; do
|
||||||
id=$(echo $destination | sed -n -E 's/.*id:([^ ,]+).*/\1/p')
|
id=$(echo $destination | sed -n -E 's/.*id:([^ ,]+).*/\1/p')
|
||||||
[[ $id == *"placeholder"* ]] && continue
|
[[ $id == *"placeholder"* ]] && continue
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/python
|
||||||
|
|
||||||
#############################################################################
|
#############################################################################
|
||||||
##
|
##
|
||||||
@ -39,18 +39,44 @@
|
|||||||
##
|
##
|
||||||
#############################################################################
|
#############################################################################
|
||||||
|
|
||||||
$output = `xcrun simctl list devices --json 2>&1`;
|
from __future__ import print_function
|
||||||
$output =~ s/\n//g;
|
|
||||||
|
|
||||||
BLOCK:
|
import argparse
|
||||||
foreach $block ($output =~ /{.*?}/g) {
|
import json
|
||||||
foreach $filter (@ARGV) {
|
import subprocess
|
||||||
if ($filter =~ /^NOT\s(.*)/) {
|
from distutils.version import StrictVersion
|
||||||
$block =~ /$1/ && next BLOCK;
|
|
||||||
} else {
|
def is_suitable_runtime(runtimes, runtime_name, platform, min_version):
|
||||||
$block =~ /$filter/ || next BLOCK;
|
for runtime in runtimes:
|
||||||
}
|
identifier = runtime["identifier"]
|
||||||
}
|
if (runtime["name"] == runtime_name or identifier == runtime_name) \
|
||||||
$block =~ /udid[:|\s|\"]+(.*)\"/;
|
and "unavailable" not in runtime["availability"] \
|
||||||
print "$1\n";
|
and identifier.startswith("com.apple.CoreSimulator.SimRuntime.{}".format(platform)) \
|
||||||
}
|
and StrictVersion(runtime["version"]) >= min_version:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def simctl_runtimes():
|
||||||
|
return json.loads(subprocess.check_output(
|
||||||
|
["/usr/bin/xcrun", "simctl", "list", "runtimes", "--json"]))["runtimes"]
|
||||||
|
|
||||||
|
def simctl_devices():
|
||||||
|
return json.loads(subprocess.check_output(
|
||||||
|
["/usr/bin/xcrun", "simctl", "list", "devices", "--json"]))["devices"]
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('--platform', choices=['iOS', 'tvOS', 'watchOS'], required=True)
|
||||||
|
parser.add_argument('--minimum-deployment-target', type=StrictVersion, default='0.0')
|
||||||
|
parser.add_argument('--state',
|
||||||
|
choices=['booted', 'shutdown', 'creating', 'booting', 'shutting-down'], action='append')
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
runtimes = simctl_runtimes()
|
||||||
|
device_dict = simctl_devices()
|
||||||
|
for runtime_name in device_dict:
|
||||||
|
if is_suitable_runtime(runtimes, runtime_name, args.platform, args.minimum_deployment_target):
|
||||||
|
for device in device_dict[runtime_name]:
|
||||||
|
if "unavailable" not in device["availability"] \
|
||||||
|
and (args.state is None or device["state"].lower() in args.state):
|
||||||
|
print(device["udid"])
|
@ -63,7 +63,7 @@ ifneq ($(filter check%,$(MAKECMDGOALS)),)
|
|||||||
ifeq ($(DEVICES),)
|
ifeq ($(DEVICES),)
|
||||||
$(info Enumerating test destinations (you may override this by setting DEVICES explicitly), please wait...)
|
$(info Enumerating test destinations (you may override this by setting DEVICES explicitly), please wait...)
|
||||||
DESTINATIONS_INCLUDE = /tmp/device_destinations.mk
|
DESTINATIONS_INCLUDE = /tmp/device_destinations.mk
|
||||||
$(shell $(MAKEFILE_DIR)device_destinations.sh '$(EXPORT_DEVICE_FILTER)' $(TARGET) > $(DESTINATIONS_INCLUDE))
|
$(shell $(MAKEFILE_DIR)device_destinations.sh $(TARGET) $(EXPORT_DEVICE_FILTER) > $(DESTINATIONS_INCLUDE))
|
||||||
include $(DESTINATIONS_INCLUDE)
|
include $(DESTINATIONS_INCLUDE)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
@ -72,7 +72,7 @@ endif
|
|||||||
%-device: DEVICES = $(HARDWARE_DEVICES)
|
%-device: DEVICES = $(HARDWARE_DEVICES)
|
||||||
|
|
||||||
GENERIC_DEVICE_DESTINATION := $(EXPORT_GENERIC_DEVICE_DESTINATION)
|
GENERIC_DEVICE_DESTINATION := $(EXPORT_GENERIC_DEVICE_DESTINATION)
|
||||||
GENERIC_SIMULATOR_DESTINATION := "id=$(shell $(MAKEFILE_DIR)devices.pl '$(EXPORT_DEVICE_FILTER)' "NOT unavailable" | tail -n 1)"
|
GENERIC_SIMULATOR_DESTINATION := "id=$(shell $(MAKEFILE_DIR)devices.py $(EXPORT_DEVICE_FILTER) | tail -n 1)"
|
||||||
|
|
||||||
%-simulator: DESTINATION = $(if $(DESTINATION_ID),"id=$(DESTINATION_ID)",$(GENERIC_SIMULATOR_DESTINATION))
|
%-simulator: DESTINATION = $(if $(DESTINATION_ID),"id=$(DESTINATION_ID)",$(GENERIC_SIMULATOR_DESTINATION))
|
||||||
%-device: DESTINATION = $(if $(DESTINATION_ID),"id=$(DESTINATION_ID)",$(GENERIC_DEVICE_DESTINATION))
|
%-device: DESTINATION = $(if $(DESTINATION_ID),"id=$(DESTINATION_ID)",$(GENERIC_DEVICE_DESTINATION))
|
||||||
|
@ -40,15 +40,15 @@ CONFIG += no_default_goal_deps
|
|||||||
DEVICE_SDK = $${device.sdk}
|
DEVICE_SDK = $${device.sdk}
|
||||||
SIMULATOR_SDK = $${simulator.sdk}
|
SIMULATOR_SDK = $${simulator.sdk}
|
||||||
ios {
|
ios {
|
||||||
DEVICE_FILTER = "iPhone|iPad"
|
DEVICE_FILTER = --platform iOS --minimum-deployment-target $$QMAKE_IOS_DEPLOYMENT_TARGET
|
||||||
GENERIC_DEVICE_DESTINATION = "generic/platform=iOS"
|
GENERIC_DEVICE_DESTINATION = "generic/platform=iOS"
|
||||||
}
|
}
|
||||||
tvos {
|
tvos {
|
||||||
DEVICE_FILTER = "Apple TV"
|
DEVICE_FILTER = --platform tvOS --minimum-deployment-target $$QMAKE_TVOS_DEPLOYMENT_TARGET
|
||||||
GENERIC_DEVICE_DESTINATION = "generic/platform=tvOS"
|
GENERIC_DEVICE_DESTINATION = "generic/platform=tvOS"
|
||||||
}
|
}
|
||||||
watchos {
|
watchos {
|
||||||
DEVICE_FILTER = "Apple Watch"
|
DEVICE_FILTER = --platform watchOS --minimum-deployment-target $$QMAKE_WATCHOS_DEPLOYMENT_TARGET
|
||||||
GENERIC_DEVICE_DESTINATION = "generic/platform=watchOS"
|
GENERIC_DEVICE_DESTINATION = "generic/platform=watchOS"
|
||||||
}
|
}
|
||||||
QMAKE_EXTRA_VARIABLES += DEVICE_SDK SIMULATOR_SDK DEVICE_FILTER GENERIC_DEVICE_DESTINATION
|
QMAKE_EXTRA_VARIABLES += DEVICE_SDK SIMULATOR_SDK DEVICE_FILTER GENERIC_DEVICE_DESTINATION
|
||||||
|
@ -62,6 +62,7 @@
|
|||||||
useCustomWorkingDirectory = "NO"
|
useCustomWorkingDirectory = "NO"
|
||||||
buildConfiguration = "Debug"
|
buildConfiguration = "Debug"
|
||||||
ignoresPersistentStateOnLaunch = "NO"
|
ignoresPersistentStateOnLaunch = "NO"
|
||||||
|
disableMainThreadChecker = "YES"
|
||||||
debugDocumentVersioning = "NO"
|
debugDocumentVersioning = "NO"
|
||||||
allowLocationSimulation = "YES">
|
allowLocationSimulation = "YES">
|
||||||
<BuildableProductRunnable>
|
<BuildableProductRunnable>
|
||||||
|
77
src/3rdparty/libpng/ANNOUNCE
vendored
77
src/3rdparty/libpng/ANNOUNCE
vendored
@ -1,4 +1,4 @@
|
|||||||
Libpng 1.6.32 - August 24, 2017
|
Libpng 1.6.34 - September 29, 2017
|
||||||
|
|
||||||
This is a public release of libpng, intended for use in production codes.
|
This is a public release of libpng, intended for use in production codes.
|
||||||
|
|
||||||
@ -7,79 +7,24 @@ Files available for download:
|
|||||||
Source files with LF line endings (for Unix/Linux) and with a
|
Source files with LF line endings (for Unix/Linux) and with a
|
||||||
"configure" script
|
"configure" script
|
||||||
|
|
||||||
libpng-1.6.32.tar.xz (LZMA-compressed, recommended)
|
libpng-1.6.34.tar.xz (LZMA-compressed, recommended)
|
||||||
libpng-1.6.32.tar.gz
|
libpng-1.6.34.tar.gz
|
||||||
|
|
||||||
Source files with CRLF line endings (for Windows), without the
|
Source files with CRLF line endings (for Windows), without the
|
||||||
"configure" script
|
"configure" script
|
||||||
|
|
||||||
lpng1632.7z (LZMA-compressed, recommended)
|
lpng1634.7z (LZMA-compressed, recommended)
|
||||||
lpng1632.zip
|
lpng1634.zip
|
||||||
|
|
||||||
Other information:
|
Other information:
|
||||||
|
|
||||||
libpng-1.6.32-README.txt
|
libpng-1.6.34-README.txt
|
||||||
libpng-1.6.32-LICENSE.txt
|
libpng-1.6.34-LICENSE.txt
|
||||||
libpng-1.6.32-*.asc (armored detached GPG signatures)
|
libpng-1.6.34-*.asc (armored detached GPG signatures)
|
||||||
|
|
||||||
Changes since the last public release (1.6.31):
|
Changes since the last public release (1.6.33):
|
||||||
Avoid possible NULL dereference in png_handle_eXIf when benign_errors
|
Removed contrib/pngsuite/i*.png; some of these were incorrect and caused
|
||||||
are allowed. Avoid leaking the input buffer "eXIf_buf".
|
test failures.
|
||||||
Eliminated png_ptr->num_exif member from pngstruct.h and added num_exif
|
|
||||||
to arguments for png_get_eXIf() and png_set_eXIf().
|
|
||||||
Added calls to png_handle_eXIf(() in pngread.c and png_write_eXIf() in
|
|
||||||
pngwrite.c, and made various other fixes to png_write_eXIf().
|
|
||||||
Changed name of png_get_eXIF and png_set_eXIf() to png_get_eXIf_1() and
|
|
||||||
png_set_eXIf_1(), respectively, to avoid breaking API compatibility
|
|
||||||
with libpng-1.6.31.
|
|
||||||
Updated contrib/libtests/pngunknown.c with eXIf chunk.
|
|
||||||
Initialized btoa[] in pngstest.c
|
|
||||||
Stop memory leak when returning from png_handle_eXIf() with an error
|
|
||||||
(Bug report from the OSS-fuzz project).
|
|
||||||
Replaced local eXIf_buf with info_ptr-eXIf_buf in png_handle_eXIf().
|
|
||||||
Update libpng.3 and libpng-manual.txt about eXIf functions.
|
|
||||||
Restored png_get_eXIf() and png_set_eXIf() to maintain API compatability.
|
|
||||||
Removed png_get_eXIf_1() and png_set_eXIf_1().
|
|
||||||
Check length of all chunks except IDAT against user limit to fix an
|
|
||||||
OSS-fuzz issue.
|
|
||||||
Check length of IDAT against maximum possible IDAT size, accounting
|
|
||||||
for height, rowbytes, interlacing and zlib/deflate overhead.
|
|
||||||
Restored png_get_eXIf_1() and png_set_eXIf_1(), because strlen(eXIf_buf)
|
|
||||||
does not work (the eXIf chunk data can contain zeroes).
|
|
||||||
Require cmake-2.8.8 in CMakeLists.txt. Revised symlink creation,
|
|
||||||
no longer using deprecated cmake LOCATION feature (Clifford Yapp).
|
|
||||||
Fixed five-byte error in the calculation of IDAT maximum possible size.
|
|
||||||
Moved chunk-length check into a png_check_chunk_length() private
|
|
||||||
function (Suggested by Max Stepin).
|
|
||||||
Moved bad pngs from tests to contrib/libtests/crashers
|
|
||||||
Moved testing of bad pngs into a separate tests/pngtest-badpngs script
|
|
||||||
Added the --xfail (expected FAIL) option to pngtest.c. It writes XFAIL
|
|
||||||
in the output but PASS for the libpng test.
|
|
||||||
Require cmake-3.0.2 in CMakeLists.txt (Clifford Yapp).
|
|
||||||
Fix "const" declaration info_ptr argument to png_get_eXIf_1() and the
|
|
||||||
num_exif argument to png_get_eXIf_1() (Github Issue 171).
|
|
||||||
Added "eXIf" to "chunks_to_ignore[]" in png_set_keep_unknown_chunks().
|
|
||||||
Added huge_IDAT.png and empty_ancillary_chunks.png to testpngs/crashers.
|
|
||||||
Make pngtest --strict, --relax, --xfail options imply -m (multiple).
|
|
||||||
Removed unused chunk_name parameter from png_check_chunk_length().
|
|
||||||
Relocated setting free_me for eXIf data, to stop an OSS-fuzz leak.
|
|
||||||
Initialize profile_header[] in png_handle_iCCP() to fix OSS-fuzz issue.
|
|
||||||
Initialize png_ptr->row_buf[0] to 255 in png_read_row() to fix OSS-fuzz UMR.
|
|
||||||
Attempt to fix a UMR in png_set_text_2() to fix OSS-fuzz issue.
|
|
||||||
Increase minimum zlib stream from 9 to 14 in png_handle_iCCP(), to account
|
|
||||||
for the minimum 'deflate' stream, and relocate the test to a point
|
|
||||||
after the keyword has been read.
|
|
||||||
Check that the eXIf chunk has at least 2 bytes and begins with "II" or "MM".
|
|
||||||
Added a set of "huge_xxxx_chunk.png" files to contrib/testpngs/crashers,
|
|
||||||
one for each known chunk type, with length = 2GB-1.
|
|
||||||
Check for 0 return from png_get_rowbytes() and added some (size_t) typecasts
|
|
||||||
in contrib/pngminus/*.c to stop some Coverity issues (162705, 162706,
|
|
||||||
and 162707).
|
|
||||||
Renamed chunks in contrib/testpngs/crashers to avoid having files whose
|
|
||||||
names differ only in case; this causes problems with some platforms
|
|
||||||
(github issue #172).
|
|
||||||
Added contrib/oss-fuzz directory which contains files used by the oss-fuzz
|
|
||||||
project (https://github.com/google/oss-fuzz/tree/master/projects/libpng).
|
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
|
51
src/3rdparty/libpng/CHANGES
vendored
51
src/3rdparty/libpng/CHANGES
vendored
@ -833,7 +833,7 @@ Version 1.0.7beta11 [May 7, 2000]
|
|||||||
Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
|
Removed the new PNG_CREATED_READ_STRUCT and PNG_CREATED_WRITE_STRUCT modes
|
||||||
which are no longer used.
|
which are no longer used.
|
||||||
Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is
|
Eliminated the three new members of png_text when PNG_LEGACY_SUPPORTED is
|
||||||
defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXT_SUPPORTED
|
defined or when neither PNG_READ_iTXt_SUPPORTED nor PNG_WRITE_iTXt_SUPPORTED
|
||||||
is defined.
|
is defined.
|
||||||
Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory
|
Made PNG_NO_READ|WRITE_iTXt the default setting, to avoid memory
|
||||||
overrun when old applications fill the info_ptr->text structure directly.
|
overrun when old applications fill the info_ptr->text structure directly.
|
||||||
@ -5939,7 +5939,7 @@ Version 1.6.32beta06 [August 2, 2017]
|
|||||||
|
|
||||||
Version 1.6.32beta07 [August 3, 2017]
|
Version 1.6.32beta07 [August 3, 2017]
|
||||||
Check length of all chunks except IDAT against user limit to fix an
|
Check length of all chunks except IDAT against user limit to fix an
|
||||||
OSS-fuzz issue.
|
OSS-fuzz issue (Fixes CVE-2017-12652).
|
||||||
|
|
||||||
Version 1.6.32beta08 [August 3, 2017]
|
Version 1.6.32beta08 [August 3, 2017]
|
||||||
Check length of IDAT against maximum possible IDAT size, accounting
|
Check length of IDAT against maximum possible IDAT size, accounting
|
||||||
@ -5994,6 +5994,53 @@ Version 1.6.32rc02 [August 22, 2017]
|
|||||||
Version 1.6.32 [August 24, 2017]
|
Version 1.6.32 [August 24, 2017]
|
||||||
No changes.
|
No changes.
|
||||||
|
|
||||||
|
Version 1.6.33beta01 [August 28, 2017]
|
||||||
|
Added PNGMINUS_UNUSED macro to contrib/pngminus/p*.c and added missing
|
||||||
|
parenthesis in contrib/pngminus/pnm2png.c (bug report by Christian Hesse).
|
||||||
|
Fixed off-by-one error in png_do_check_palette_indexes() (Bug report
|
||||||
|
by Mick P., Source Forge Issue #269).
|
||||||
|
|
||||||
|
Version 1.6.33beta02 [September 3, 2017]
|
||||||
|
Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc
|
||||||
|
to fix shortlived oss-fuzz issue 3234.
|
||||||
|
Compute a larger limit on IDAT because some applications write a deflate
|
||||||
|
buffer for each row (Bug report by Andrew Church).
|
||||||
|
Use current date (DATE) instead of release-date (RDATE) in last
|
||||||
|
changed date of contrib/oss-fuzz files.
|
||||||
|
Enabled ARM support in CMakeLists.txt (Bernd Kuhls).
|
||||||
|
|
||||||
|
Version 1.6.33beta03 [September 14, 2017]
|
||||||
|
Fixed incorrect typecast of some arguments to png_malloc() and
|
||||||
|
png_calloc() that were png_uint_32 instead of png_alloc_size_t
|
||||||
|
(Bug report by "irwir" in Github libpng issue #175).
|
||||||
|
Use pnglibconf.h.prebuilt when building for ANDROID with cmake (Github
|
||||||
|
issue 162, by rcdailey).
|
||||||
|
|
||||||
|
Version 1.6.33rc01 [September 20, 2017]
|
||||||
|
Initialize memory allocated by png_inflate to zero, using memset, to
|
||||||
|
stop an oss-fuzz "use of uninitialized value" detection in png_set_text_2()
|
||||||
|
due to truncated iTXt or zTXt chunk.
|
||||||
|
Initialize memory allocated by png_read_buffer to zero, using memset, to
|
||||||
|
stop an oss-fuzz "use of uninitialized value" detection in
|
||||||
|
png_icc_check_tag_table() due to truncated iCCP chunk.
|
||||||
|
Removed a redundant test (suggested by "irwir" in Github issue #180).
|
||||||
|
|
||||||
|
Version 1.6.33rc02 [September 23, 2017]
|
||||||
|
Added an interlaced version of each file in contrib/pngsuite.
|
||||||
|
Relocate new memset() call in pngrutil.c.
|
||||||
|
Removed more redundant tests (suggested by "irwir" in Github issue #180).
|
||||||
|
Add support for loading images with associated alpha in the Simplified
|
||||||
|
API (Samuel Williams).
|
||||||
|
|
||||||
|
Version 1.6.33 [September 28, 2017]
|
||||||
|
Revert contrib/oss-fuzz/libpng_read_fuzzer.cc to libpng-1.6.32 state.
|
||||||
|
Initialize png_handler.row_ptr in contrib/oss-fuzz/libpng_read_fuzzer.cc
|
||||||
|
Add end_info structure and png_read_end() to the libpng fuzzer.
|
||||||
|
|
||||||
|
Version 1.6.34 [September 29, 2017]
|
||||||
|
Removed contrib/pngsuite/i*.png; some of these were incorrect and caused
|
||||||
|
test failures.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||||
(subscription required; visit
|
(subscription required; visit
|
||||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||||
|
4
src/3rdparty/libpng/LICENSE
vendored
4
src/3rdparty/libpng/LICENSE
vendored
@ -10,7 +10,7 @@ this sentence.
|
|||||||
|
|
||||||
This code is released under the libpng license.
|
This code is released under the libpng license.
|
||||||
|
|
||||||
libpng versions 1.0.7, July 1, 2000 through 1.6.32, August 24, 2017 are
|
libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are
|
||||||
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
||||||
derived from libpng-1.0.6, and are distributed according to the same
|
derived from libpng-1.0.6, and are distributed according to the same
|
||||||
disclaimer and license as libpng-1.0.6 with the following individuals
|
disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
@ -130,4 +130,4 @@ any encryption software. See the EAR, paragraphs 734.3(b)(3) and
|
|||||||
|
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
glennrp at users.sourceforge.net
|
glennrp at users.sourceforge.net
|
||||||
April 1, 2017
|
September 29, 2017
|
||||||
|
2
src/3rdparty/libpng/README
vendored
2
src/3rdparty/libpng/README
vendored
@ -1,4 +1,4 @@
|
|||||||
README for libpng version 1.6.32 - August 24, 2017 (shared library 16.0)
|
README for libpng version 1.6.34 - September 29, 2017 (shared library 16.0)
|
||||||
See the note about version numbers near the top of png.h
|
See the note about version numbers near the top of png.h
|
||||||
|
|
||||||
See INSTALL for instructions on how to install libpng.
|
See INSTALL for instructions on how to install libpng.
|
||||||
|
21
src/3rdparty/libpng/libpng-manual.txt
vendored
21
src/3rdparty/libpng/libpng-manual.txt
vendored
@ -1,6 +1,6 @@
|
|||||||
libpng-manual.txt - A description on how to use and modify libpng
|
libpng-manual.txt - A description on how to use and modify libpng
|
||||||
|
|
||||||
libpng version 1.6.32 - August 24, 2017
|
libpng version 1.6.34 - September 29, 2017
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
<glennrp at users.sourceforge.net>
|
<glennrp at users.sourceforge.net>
|
||||||
Copyright (c) 1998-2017 Glenn Randers-Pehrson
|
Copyright (c) 1998-2017 Glenn Randers-Pehrson
|
||||||
@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
|
|||||||
|
|
||||||
Based on:
|
Based on:
|
||||||
|
|
||||||
libpng versions 0.97, January 1998, through 1.6.32 - August 24, 2017
|
libpng versions 0.97, January 1998, through 1.6.34 - September 29, 2017
|
||||||
Updated and distributed by Glenn Randers-Pehrson
|
Updated and distributed by Glenn Randers-Pehrson
|
||||||
Copyright (c) 1998-2017 Glenn Randers-Pehrson
|
Copyright (c) 1998-2017 Glenn Randers-Pehrson
|
||||||
|
|
||||||
@ -986,8 +986,17 @@ premultiplication.
|
|||||||
|
|
||||||
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
|
png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB);
|
||||||
|
|
||||||
This is the default libpng handling of the alpha channel - it is not
|
Choices for the alpha_mode are
|
||||||
pre-multiplied into the color components. In addition the call states
|
|
||||||
|
PNG_ALPHA_PNG 0 /* according to the PNG standard */
|
||||||
|
PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */
|
||||||
|
PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */
|
||||||
|
PNG_ALPHA_PREMULTIPLIED 1 /* as above */
|
||||||
|
PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */
|
||||||
|
PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */
|
||||||
|
|
||||||
|
PNG_ALPHA_PNG is the default libpng handling of the alpha channel. It is not
|
||||||
|
pre-multiplied into the color components. In addition the call states
|
||||||
that the output is for a sRGB system and causes all PNG files without gAMA
|
that the output is for a sRGB system and causes all PNG files without gAMA
|
||||||
chunks to be assumed to be encoded using sRGB.
|
chunks to be assumed to be encoded using sRGB.
|
||||||
|
|
||||||
@ -1002,7 +1011,7 @@ early Mac systems behaved.
|
|||||||
This is the classic Jim Blinn approach and will work in academic
|
This is the classic Jim Blinn approach and will work in academic
|
||||||
environments where everything is done by the book. It has the shortcoming
|
environments where everything is done by the book. It has the shortcoming
|
||||||
of assuming that input PNG data with no gamma information is linear - this
|
of assuming that input PNG data with no gamma information is linear - this
|
||||||
is unlikely to be correct unless the PNG files where generated locally.
|
is unlikely to be correct unless the PNG files were generated locally.
|
||||||
Most of the time the output precision will be so low as to show
|
Most of the time the output precision will be so low as to show
|
||||||
significant banding in dark areas of the image.
|
significant banding in dark areas of the image.
|
||||||
|
|
||||||
@ -5405,7 +5414,7 @@ Since the PNG Development group is an ad-hoc body, we can't make
|
|||||||
an official declaration.
|
an official declaration.
|
||||||
|
|
||||||
This is your unofficial assurance that libpng from version 0.71 and
|
This is your unofficial assurance that libpng from version 0.71 and
|
||||||
upward through 1.6.32 are Y2K compliant. It is my belief that earlier
|
upward through 1.6.34 are Y2K compliant. It is my belief that earlier
|
||||||
versions were also Y2K compliant.
|
versions were also Y2K compliant.
|
||||||
|
|
||||||
Libpng only has two year fields. One is a 2-byte unsigned integer
|
Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||||
|
34
src/3rdparty/libpng/png.c
vendored
34
src/3rdparty/libpng/png.c
vendored
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.c - location for general purpose libpng functions
|
/* png.c - location for general purpose libpng functions
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
@ -14,7 +14,7 @@
|
|||||||
#include "pngpriv.h"
|
#include "pngpriv.h"
|
||||||
|
|
||||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||||
typedef png_libpng_version_1_6_32 Your_png_h_is_not_version_1_6_32;
|
typedef png_libpng_version_1_6_34 Your_png_h_is_not_version_1_6_34;
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
/* The version tests may need to be added to, but the problem warning has
|
/* The version tests may need to be added to, but the problem warning has
|
||||||
@ -816,14 +816,14 @@ png_get_copyright(png_const_structrp png_ptr)
|
|||||||
#else
|
#else
|
||||||
# ifdef __STDC__
|
# ifdef __STDC__
|
||||||
return PNG_STRING_NEWLINE \
|
return PNG_STRING_NEWLINE \
|
||||||
"libpng version 1.6.32 - August 24, 2017" PNG_STRING_NEWLINE \
|
"libpng version 1.6.34 - September 29, 2017" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
|
"Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson" \
|
||||||
PNG_STRING_NEWLINE \
|
PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||||
PNG_STRING_NEWLINE;
|
PNG_STRING_NEWLINE;
|
||||||
# else
|
# else
|
||||||
return "libpng version 1.6.32 - August 24, 2017\
|
return "libpng version 1.6.34 - September 29, 2017\
|
||||||
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
|
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
|
||||||
Copyright (c) 1996-1997 Andreas Dilger\
|
Copyright (c) 1996-1997 Andreas Dilger\
|
||||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||||
@ -1913,12 +1913,12 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
*/
|
*/
|
||||||
if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)
|
if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)
|
||||||
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
||||||
(unsigned)intent, "invalid sRGB rendering intent");
|
(png_alloc_size_t)intent, "invalid sRGB rendering intent");
|
||||||
|
|
||||||
if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
|
if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
|
||||||
colorspace->rendering_intent != intent)
|
colorspace->rendering_intent != intent)
|
||||||
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
return png_icc_profile_error(png_ptr, colorspace, "sRGB",
|
||||||
(unsigned)intent, "inconsistent rendering intents");
|
(png_alloc_size_t)intent, "inconsistent rendering intents");
|
||||||
|
|
||||||
if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0)
|
if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0)
|
||||||
{
|
{
|
||||||
@ -1979,7 +1979,6 @@ icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
if (profile_length < 132)
|
if (profile_length < 132)
|
||||||
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||||
"too short");
|
"too short");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2224,15 +2223,6 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
* being in range. All defined tag types have an 8 byte header - a 4 byte
|
* being in range. All defined tag types have an 8 byte header - a 4 byte
|
||||||
* type signature then 0.
|
* type signature then 0.
|
||||||
*/
|
*/
|
||||||
if ((tag_start & 3) != 0)
|
|
||||||
{
|
|
||||||
/* CNHP730S.icc shipped with Microsoft Windows 64 violates this, it is
|
|
||||||
* only a warning here because libpng does not care about the
|
|
||||||
* alignment.
|
|
||||||
*/
|
|
||||||
(void)png_icc_profile_error(png_ptr, NULL, name, tag_id,
|
|
||||||
"ICC profile tag start not a multiple of 4");
|
|
||||||
}
|
|
||||||
|
|
||||||
/* This is a hard error; potentially it can cause read outside the
|
/* This is a hard error; potentially it can cause read outside the
|
||||||
* profile.
|
* profile.
|
||||||
@ -2240,6 +2230,16 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||||||
if (tag_start > profile_length || tag_length > profile_length - tag_start)
|
if (tag_start > profile_length || tag_length > profile_length - tag_start)
|
||||||
return png_icc_profile_error(png_ptr, colorspace, name, tag_id,
|
return png_icc_profile_error(png_ptr, colorspace, name, tag_id,
|
||||||
"ICC profile tag outside profile");
|
"ICC profile tag outside profile");
|
||||||
|
|
||||||
|
if ((tag_start & 3) != 0)
|
||||||
|
{
|
||||||
|
/* CNHP730S.icc shipped with Microsoft Windows 64 violates this; it is
|
||||||
|
* only a warning here because libpng does not care about the
|
||||||
|
* alignment.
|
||||||
|
*/
|
||||||
|
(void)png_icc_profile_error(png_ptr, NULL, name, tag_id,
|
||||||
|
"ICC profile tag start not a multiple of 4");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1; /* success, maybe with warnings */
|
return 1; /* success, maybe with warnings */
|
||||||
@ -3761,7 +3761,7 @@ png_log16bit(png_uint_32 x)
|
|||||||
* of getting this accuracy in practice.
|
* of getting this accuracy in practice.
|
||||||
*
|
*
|
||||||
* To deal with this the following exp() function works out the exponent of the
|
* To deal with this the following exp() function works out the exponent of the
|
||||||
* frational part of the logarithm by using an accurate 32-bit value from the
|
* fractional part of the logarithm by using an accurate 32-bit value from the
|
||||||
* top four fractional bits then multiplying in the remaining bits.
|
* top four fractional bits then multiplying in the remaining bits.
|
||||||
*/
|
*/
|
||||||
static const png_uint_32
|
static const png_uint_32
|
||||||
|
28
src/3rdparty/libpng/png.h
vendored
28
src/3rdparty/libpng/png.h
vendored
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.6.32, August 24, 2017
|
* libpng version 1.6.34, September 29, 2017
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
@ -12,7 +12,7 @@
|
|||||||
* Authors and maintainers:
|
* Authors and maintainers:
|
||||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.6.32, August 24, 2017:
|
* libpng versions 0.97, January 1998, through 1.6.34, September 29, 2017:
|
||||||
* Glenn Randers-Pehrson.
|
* Glenn Randers-Pehrson.
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*/
|
*/
|
||||||
@ -25,7 +25,7 @@
|
|||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
*
|
*
|
||||||
* libpng versions 1.0.7, July 1, 2000 through 1.6.32, August 24, 2017 are
|
* libpng versions 1.0.7, July 1, 2000 through 1.6.34, September 29, 2017 are
|
||||||
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
||||||
* derived from libpng-1.0.6, and are distributed according to the same
|
* derived from libpng-1.0.6, and are distributed according to the same
|
||||||
* disclaimer and license as libpng-1.0.6 with the following individuals
|
* disclaimer and license as libpng-1.0.6 with the following individuals
|
||||||
@ -209,11 +209,11 @@
|
|||||||
* ...
|
* ...
|
||||||
* 1.0.19 10 10019 10.so.0.19[.0]
|
* 1.0.19 10 10019 10.so.0.19[.0]
|
||||||
* ...
|
* ...
|
||||||
* 1.2.57 13 10257 12.so.0.57[.0]
|
* 1.2.59 13 10257 12.so.0.59[.0]
|
||||||
* ...
|
* ...
|
||||||
* 1.5.28 15 10527 15.so.15.28[.0]
|
* 1.5.30 15 10527 15.so.15.30[.0]
|
||||||
* ...
|
* ...
|
||||||
* 1.6.32 16 10632 16.so.16.32[.0]
|
* 1.6.34 16 10633 16.so.16.34[.0]
|
||||||
*
|
*
|
||||||
* Henceforth the source version will match the shared-library major
|
* Henceforth the source version will match the shared-library major
|
||||||
* and minor numbers; the shared-library major version number will be
|
* and minor numbers; the shared-library major version number will be
|
||||||
@ -241,13 +241,13 @@
|
|||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* August 24, 2017
|
* September 29, 2017
|
||||||
*
|
*
|
||||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||||
* an official declaration.
|
* an official declaration.
|
||||||
*
|
*
|
||||||
* This is your unofficial assurance that libpng from version 0.71 and
|
* This is your unofficial assurance that libpng from version 0.71 and
|
||||||
* upward through 1.6.32 are Y2K compliant. It is my belief that
|
* upward through 1.6.34 are Y2K compliant. It is my belief that
|
||||||
* earlier versions were also Y2K compliant.
|
* earlier versions were also Y2K compliant.
|
||||||
*
|
*
|
||||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||||
@ -309,8 +309,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Version information for png.h - this should match the version in png.c */
|
/* Version information for png.h - this should match the version in png.c */
|
||||||
#define PNG_LIBPNG_VER_STRING "1.6.32"
|
#define PNG_LIBPNG_VER_STRING "1.6.34"
|
||||||
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.32 - August 24, 2017\n"
|
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.34 - September 29, 2017\n"
|
||||||
|
|
||||||
#define PNG_LIBPNG_VER_SONUM 16
|
#define PNG_LIBPNG_VER_SONUM 16
|
||||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||||
@ -318,7 +318,7 @@
|
|||||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||||
#define PNG_LIBPNG_VER_MAJOR 1
|
#define PNG_LIBPNG_VER_MAJOR 1
|
||||||
#define PNG_LIBPNG_VER_MINOR 6
|
#define PNG_LIBPNG_VER_MINOR 6
|
||||||
#define PNG_LIBPNG_VER_RELEASE 32
|
#define PNG_LIBPNG_VER_RELEASE 34
|
||||||
|
|
||||||
/* This should match the numeric part of the final component of
|
/* 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:
|
||||||
@ -349,7 +349,7 @@
|
|||||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
* 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
|
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||||
*/
|
*/
|
||||||
#define PNG_LIBPNG_VER 10632 /* 1.6.32 */
|
#define PNG_LIBPNG_VER 10634 /* 1.6.34 */
|
||||||
|
|
||||||
/* Library configuration: these options cannot be changed after
|
/* Library configuration: these options cannot be changed after
|
||||||
* the library has been built.
|
* the library has been built.
|
||||||
@ -459,7 +459,7 @@ extern "C" {
|
|||||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||||
* do not agree upon the version number.
|
* do not agree upon the version number.
|
||||||
*/
|
*/
|
||||||
typedef char* png_libpng_version_1_6_32;
|
typedef char* png_libpng_version_1_6_34;
|
||||||
|
|
||||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||||
*
|
*
|
||||||
@ -2819,6 +2819,8 @@ typedef struct
|
|||||||
# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */
|
# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define PNG_FORMAT_FLAG_ASSOCIATED_ALPHA 0x40U /* alpha channel is associated */
|
||||||
|
|
||||||
/* Commonly used formats have predefined macros.
|
/* Commonly used formats have predefined macros.
|
||||||
*
|
*
|
||||||
* First the single byte (sRGB) formats:
|
* First the single byte (sRGB) formats:
|
||||||
|
2
src/3rdparty/libpng/pngconf.h
vendored
2
src/3rdparty/libpng/pngconf.h
vendored
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.6.32, August 24, 2017
|
* libpng version 1.6.34, September 29, 2017
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
4
src/3rdparty/libpng/pnglibconf.h
vendored
4
src/3rdparty/libpng/pnglibconf.h
vendored
@ -1,8 +1,8 @@
|
|||||||
/* libpng 1.6.32 STANDARD API DEFINITION */
|
/* libpng 1.6.34 STANDARD API DEFINITION */
|
||||||
|
|
||||||
/* pnglibconf.h - library build configuration */
|
/* pnglibconf.h - library build configuration */
|
||||||
|
|
||||||
/* Libpng version 1.6.32 - August 24, 2017 */
|
/* Libpng version 1.6.34 - September 29, 2017 */
|
||||||
|
|
||||||
/* Copyright (c) 1998-2017 Glenn Randers-Pehrson */
|
/* Copyright (c) 1998-2017 Glenn Randers-Pehrson */
|
||||||
|
|
||||||
|
14
src/3rdparty/libpng/pngread.c
vendored
14
src/3rdparty/libpng/pngread.c
vendored
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngread.c - read a PNG file
|
/* pngread.c - read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
@ -3759,7 +3759,13 @@ png_image_read_direct(png_voidp argument)
|
|||||||
mode = PNG_ALPHA_PNG;
|
mode = PNG_ALPHA_PNG;
|
||||||
output_gamma = PNG_DEFAULT_sRGB;
|
output_gamma = PNG_DEFAULT_sRGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((change & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0)
|
||||||
|
{
|
||||||
|
mode = PNG_ALPHA_OPTIMIZED;
|
||||||
|
change &= ~PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
|
||||||
|
}
|
||||||
|
|
||||||
/* If 'do_local_background' is set check for the presence of gamma
|
/* If 'do_local_background' is set check for the presence of gamma
|
||||||
* correction; this is part of the work-round for the libpng bug
|
* correction; this is part of the work-round for the libpng bug
|
||||||
* described above.
|
* described above.
|
||||||
@ -3985,6 +3991,10 @@ png_image_read_direct(png_voidp argument)
|
|||||||
else if (do_local_compose != 0) /* internal error */
|
else if (do_local_compose != 0) /* internal error */
|
||||||
png_error(png_ptr, "png_image_read: alpha channel lost");
|
png_error(png_ptr, "png_image_read: alpha channel lost");
|
||||||
|
|
||||||
|
if ((format & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) {
|
||||||
|
info_format |= PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
|
||||||
|
}
|
||||||
|
|
||||||
if (info_ptr->bit_depth == 16)
|
if (info_ptr->bit_depth == 16)
|
||||||
info_format |= PNG_FORMAT_FLAG_LINEAR;
|
info_format |= PNG_FORMAT_FLAG_LINEAR;
|
||||||
|
|
||||||
|
22
src/3rdparty/libpng/pngrtran.c
vendored
22
src/3rdparty/libpng/pngrtran.c
vendored
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.31 [July 27, 2017]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
@ -430,7 +430,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
|
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
png_ptr->quantize_index[i] = (png_byte)i;
|
png_ptr->quantize_index[i] = (png_byte)i;
|
||||||
}
|
}
|
||||||
@ -447,7 +447,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
|
|
||||||
/* Initialize an array to sort colors */
|
/* Initialize an array to sort colors */
|
||||||
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
|
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||||
|
|
||||||
/* Initialize the quantize_sort array */
|
/* Initialize the quantize_sort array */
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
@ -581,9 +581,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
|
|
||||||
/* Initialize palette index arrays */
|
/* Initialize palette index arrays */
|
||||||
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
|
(png_alloc_size_t)((png_uint_32)num_palette *
|
||||||
|
(sizeof (png_byte))));
|
||||||
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||||
(png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
|
(png_alloc_size_t)((png_uint_32)num_palette *
|
||||||
|
(sizeof (png_byte))));
|
||||||
|
|
||||||
/* Initialize the sort array */
|
/* Initialize the sort array */
|
||||||
for (i = 0; i < num_palette; i++)
|
for (i = 0; i < num_palette; i++)
|
||||||
@ -592,7 +594,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
png_ptr->palette_to_index[i] = (png_byte)i;
|
png_ptr->palette_to_index[i] = (png_byte)i;
|
||||||
}
|
}
|
||||||
|
|
||||||
hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
|
hash = (png_dsortpp)png_calloc(png_ptr, (png_alloc_size_t)(769 *
|
||||||
(sizeof (png_dsortp))));
|
(sizeof (png_dsortp))));
|
||||||
|
|
||||||
num_new_palette = num_palette;
|
num_new_palette = num_palette;
|
||||||
@ -623,7 +625,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
{
|
{
|
||||||
|
|
||||||
t = (png_dsortp)png_malloc_warn(png_ptr,
|
t = (png_dsortp)png_malloc_warn(png_ptr,
|
||||||
(png_uint_32)(sizeof (png_dsort)));
|
(png_alloc_size_t)(sizeof (png_dsort)));
|
||||||
|
|
||||||
if (t == NULL)
|
if (t == NULL)
|
||||||
break;
|
break;
|
||||||
@ -748,9 +750,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||||||
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
png_size_t num_entries = ((png_size_t)1 << total_bits);
|
||||||
|
|
||||||
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
|
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
|
||||||
(png_uint_32)(num_entries * (sizeof (png_byte))));
|
(png_alloc_size_t)(num_entries * (sizeof (png_byte))));
|
||||||
|
|
||||||
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
|
distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries *
|
||||||
(sizeof (png_byte))));
|
(sizeof (png_byte))));
|
||||||
|
|
||||||
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
||||||
@ -3322,7 +3324,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||||||
== png_ptr->trans_color.gray)
|
== png_ptr->trans_color.gray)
|
||||||
{
|
{
|
||||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||||
tmp |=
|
tmp |=
|
||||||
(unsigned int)(png_ptr->background.gray << shift);
|
(unsigned int)(png_ptr->background.gray << shift);
|
||||||
*sp = (png_byte)(tmp & 0xff);
|
*sp = (png_byte)(tmp & 0xff);
|
||||||
}
|
}
|
||||||
|
47
src/3rdparty/libpng/pngrutil.c
vendored
47
src/3rdparty/libpng/pngrutil.c
vendored
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngrutil.c - utilities to read a PNG file
|
/* pngrutil.c - utilities to read a PNG file
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
@ -314,6 +314,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
|
|||||||
|
|
||||||
if (buffer != NULL)
|
if (buffer != NULL)
|
||||||
{
|
{
|
||||||
|
memset(buffer, 0, new_size); /* just in case */
|
||||||
png_ptr->read_buffer = buffer;
|
png_ptr->read_buffer = buffer;
|
||||||
png_ptr->read_buffer_size = new_size;
|
png_ptr->read_buffer_size = new_size;
|
||||||
}
|
}
|
||||||
@ -673,6 +674,8 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||||||
|
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
{
|
{
|
||||||
|
memset(text, 0, buffer_size);
|
||||||
|
|
||||||
ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
|
ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
|
||||||
png_ptr->read_buffer + prefix_size, &lzsize,
|
png_ptr->read_buffer + prefix_size, &lzsize,
|
||||||
text + prefix_size, newlength);
|
text + prefix_size, newlength);
|
||||||
@ -736,9 +739,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||||||
{
|
{
|
||||||
/* inflateReset failed, store the error message */
|
/* inflateReset failed, store the error message */
|
||||||
png_zstream_error(png_ptr, ret);
|
png_zstream_error(png_ptr, ret);
|
||||||
|
ret = PNG_UNEXPECTED_ZLIB_RETURN;
|
||||||
if (ret == Z_STREAM_END)
|
|
||||||
ret = PNG_UNEXPECTED_ZLIB_RETURN;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1476,7 +1477,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
/* Now read the tag table; a variable size buffer is
|
/* Now read the tag table; a variable size buffer is
|
||||||
* needed at this point, allocate one for the whole
|
* needed at this point, allocate one for the whole
|
||||||
* profile. The header check has already validated
|
* profile. The header check has already validated
|
||||||
* that none of these stuff will overflow.
|
* that none of this stuff will overflow.
|
||||||
*/
|
*/
|
||||||
const png_uint_32 tag_count = png_get_uint_32(
|
const png_uint_32 tag_count = png_get_uint_32(
|
||||||
profile_header+128);
|
profile_header+128);
|
||||||
@ -1583,19 +1584,11 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (errmsg == NULL)
|
||||||
else if (size > 0)
|
|
||||||
errmsg = "truncated";
|
|
||||||
|
|
||||||
#ifndef __COVERITY__
|
|
||||||
else
|
|
||||||
errmsg = png_ptr->zstream.msg;
|
errmsg = png_ptr->zstream.msg;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* else png_icc_check_tag_table output an error */
|
/* else png_icc_check_tag_table output an error */
|
||||||
}
|
}
|
||||||
|
|
||||||
else /* profile truncated */
|
else /* profile truncated */
|
||||||
errmsg = png_ptr->zstream.msg;
|
errmsg = png_ptr->zstream.msg;
|
||||||
}
|
}
|
||||||
@ -3144,28 +3137,28 @@ png_check_chunk_length(png_const_structrp png_ptr, const png_uint_32 length)
|
|||||||
{
|
{
|
||||||
png_alloc_size_t limit = PNG_UINT_31_MAX;
|
png_alloc_size_t limit = PNG_UINT_31_MAX;
|
||||||
|
|
||||||
if (png_ptr->chunk_name != png_IDAT)
|
|
||||||
{
|
|
||||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||||
png_ptr->user_chunk_malloc_max < limit)
|
png_ptr->user_chunk_malloc_max < limit)
|
||||||
limit = png_ptr->user_chunk_malloc_max;
|
limit = png_ptr->user_chunk_malloc_max;
|
||||||
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
|
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
|
||||||
if (PNG_USER_CHUNK_MALLOC_MAX < limit)
|
if (PNG_USER_CHUNK_MALLOC_MAX < limit)
|
||||||
limit = PNG_USER_CHUNK_MALLOC_MAX;
|
limit = PNG_USER_CHUNK_MALLOC_MAX;
|
||||||
# endif
|
# endif
|
||||||
}
|
if (png_ptr->chunk_name == png_IDAT)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
png_alloc_size_t idat_limit = PNG_UINT_31_MAX;
|
||||||
size_t row_factor =
|
size_t row_factor =
|
||||||
(png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1)
|
(png_ptr->width * png_ptr->channels * (png_ptr->bit_depth > 8? 2: 1)
|
||||||
+ 1 + (png_ptr->interlaced? 6: 0));
|
+ 1 + (png_ptr->interlaced? 6: 0));
|
||||||
if (png_ptr->height > PNG_UINT_32_MAX/row_factor)
|
if (png_ptr->height > PNG_UINT_32_MAX/row_factor)
|
||||||
limit=PNG_UINT_31_MAX;
|
idat_limit=PNG_UINT_31_MAX;
|
||||||
else
|
else
|
||||||
limit = png_ptr->height * row_factor;
|
idat_limit = png_ptr->height * row_factor;
|
||||||
limit += 6 + 5*(limit/32566+1); /* zlib+deflate overhead */
|
row_factor = row_factor > 32566? 32566 : row_factor;
|
||||||
limit=limit < PNG_UINT_31_MAX? limit : PNG_UINT_31_MAX;
|
idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */
|
||||||
|
idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX;
|
||||||
|
limit = limit < idat_limit? idat_limit : limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > limit)
|
if (length > limit)
|
||||||
|
6
src/3rdparty/libpng/pngtrans.c
vendored
6
src/3rdparty/libpng/pngtrans.c
vendored
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.30 [June 28, 2017]
|
* Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||||
@ -609,7 +609,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
|||||||
return; /* The filler channel has gone already */
|
return; /* The filler channel has gone already */
|
||||||
|
|
||||||
/* Fix the rowbytes value. */
|
/* Fix the rowbytes value. */
|
||||||
row_info->rowbytes = (unsigned int)(dp-row);
|
row_info->rowbytes = (png_size_t)(dp-row);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -708,7 +708,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
|||||||
* forms produced on either GCC or MSVC.
|
* forms produced on either GCC or MSVC.
|
||||||
*/
|
*/
|
||||||
int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
|
int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
|
||||||
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
|
png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1;
|
||||||
|
|
||||||
switch (row_info->bit_depth)
|
switch (row_info->bit_depth)
|
||||||
{
|
{
|
||||||
|
2
src/3rdparty/libpng/pngwrite.c
vendored
2
src/3rdparty/libpng/pngwrite.c
vendored
@ -1940,7 +1940,7 @@ png_image_write_main(png_voidp argument)
|
|||||||
int colormap = (format & PNG_FORMAT_FLAG_COLORMAP);
|
int colormap = (format & PNG_FORMAT_FLAG_COLORMAP);
|
||||||
int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */
|
int linear = !colormap && (format & PNG_FORMAT_FLAG_LINEAR); /* input */
|
||||||
int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA);
|
int alpha = !colormap && (format & PNG_FORMAT_FLAG_ALPHA);
|
||||||
int write_16bit = linear && !colormap && (display->convert_to_8bit == 0);
|
int write_16bit = linear && (display->convert_to_8bit == 0);
|
||||||
|
|
||||||
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
/* Make sure we error out on any bad situation */
|
/* Make sure we error out on any bad situation */
|
||||||
|
2
src/3rdparty/libpng/qt_attribution.json
vendored
2
src/3rdparty/libpng/qt_attribution.json
vendored
@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
"Description": "libpng is the official PNG reference library.",
|
"Description": "libpng is the official PNG reference library.",
|
||||||
"Homepage": "http://www.libpng.org/pub/png/libpng.html",
|
"Homepage": "http://www.libpng.org/pub/png/libpng.html",
|
||||||
"Version": "1.6.32",
|
"Version": "1.6.34",
|
||||||
"License": "libpng License",
|
"License": "libpng License",
|
||||||
"LicenseId": "Libpng",
|
"LicenseId": "Libpng",
|
||||||
"LicenseFile": "LICENSE",
|
"LicenseFile": "LICENSE",
|
||||||
|
@ -1347,12 +1347,12 @@
|
|||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#if QT_HAS_CPP_ATTRIBUTE(fallthrough)
|
#if QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
|
||||||
# define Q_FALLTHROUGH() [[fallthrough]]
|
|
||||||
#elif QT_HAS_CPP_ATTRIBUTE(clang::fallthrough)
|
|
||||||
# define Q_FALLTHROUGH() [[clang::fallthrough]]
|
# define Q_FALLTHROUGH() [[clang::fallthrough]]
|
||||||
#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
|
#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough)
|
||||||
# define Q_FALLTHROUGH() [[gnu::fallthrough]]
|
# define Q_FALLTHROUGH() [[gnu::fallthrough]]
|
||||||
|
#elif QT_HAS_CPP_ATTRIBUTE(fallthrough)
|
||||||
|
# define Q_FALLTHROUGH() [[fallthrough]]
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#ifndef Q_FALLTHROUGH
|
#ifndef Q_FALLTHROUGH
|
||||||
|
@ -121,7 +121,7 @@ inline qfloat16::qfloat16(float f) Q_DECL_NOTHROW
|
|||||||
__m128i packhalf = _mm_cvtps_ph(packsingle, 0);
|
__m128i packhalf = _mm_cvtps_ph(packsingle, 0);
|
||||||
b16 = _mm_extract_epi16(packhalf, 0);
|
b16 = _mm_extract_epi16(packhalf, 0);
|
||||||
#elif defined (__ARM_FP16_FORMAT_IEEE)
|
#elif defined (__ARM_FP16_FORMAT_IEEE)
|
||||||
__fp16 f16 = f;
|
__fp16 f16 = __fp16(f);
|
||||||
memcpy(&b16, &f16, sizeof(quint16));
|
memcpy(&b16, &f16, sizeof(quint16));
|
||||||
#else
|
#else
|
||||||
quint32 u;
|
quint32 u;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#include <QtCore/qglobal.h>
|
#include <QtCore/qglobal.h>
|
||||||
#include <algorithm> // for std::generate
|
#include <algorithm> // for std::generate
|
||||||
|
#include <random> // for std::mt19937
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
@ -51,19 +52,43 @@ class QRandomGenerator
|
|||||||
template <typename UInt> using IfValidUInt =
|
template <typename UInt> using IfValidUInt =
|
||||||
typename std::enable_if<std::is_unsigned<UInt>::value && sizeof(UInt) >= sizeof(uint), bool>::type;
|
typename std::enable_if<std::is_unsigned<UInt>::value && sizeof(UInt) >= sizeof(uint), bool>::type;
|
||||||
public:
|
public:
|
||||||
static QRandomGenerator system() { return {}; }
|
QRandomGenerator(quint32 seedValue = 1)
|
||||||
static QRandomGenerator global() { return {}; }
|
: QRandomGenerator(&seedValue, 1)
|
||||||
QRandomGenerator() = default;
|
{}
|
||||||
|
template <qssize_t N> QRandomGenerator(const quint32 (&seedBuffer)[N])
|
||||||
|
: QRandomGenerator(seedBuffer, seedBuffer + N)
|
||||||
|
{}
|
||||||
|
QRandomGenerator(const quint32 *seedBuffer, qssize_t len)
|
||||||
|
: QRandomGenerator(seedBuffer, seedBuffer + len)
|
||||||
|
{}
|
||||||
|
Q_CORE_EXPORT QRandomGenerator(std::seed_seq &sseq) Q_DECL_NOTHROW;
|
||||||
|
Q_CORE_EXPORT QRandomGenerator(const quint32 *begin, const quint32 *end);
|
||||||
|
|
||||||
// ### REMOVE BEFORE 5.10
|
// copy constructor & assignment operator (move unnecessary)
|
||||||
QRandomGenerator *operator->() { return this; }
|
Q_CORE_EXPORT QRandomGenerator(const QRandomGenerator &other);
|
||||||
static quint32 get32() { return generate(); }
|
Q_CORE_EXPORT QRandomGenerator &operator=(const QRandomGenerator &other);
|
||||||
static quint64 get64() { return generate64(); }
|
|
||||||
static qreal getReal() { return generateDouble(); }
|
|
||||||
|
|
||||||
static Q_CORE_EXPORT quint32 generate();
|
friend Q_CORE_EXPORT bool operator==(const QRandomGenerator &rng1, const QRandomGenerator &rng2);
|
||||||
static Q_CORE_EXPORT quint64 generate64();
|
friend bool operator!=(const QRandomGenerator &rng1, const QRandomGenerator &rng2)
|
||||||
static double generateDouble()
|
{
|
||||||
|
return !(rng1 == rng2);
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 generate()
|
||||||
|
{
|
||||||
|
quint32 ret;
|
||||||
|
fillRange(&ret, 1);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
quint64 generate64()
|
||||||
|
{
|
||||||
|
quint32 buf[2];
|
||||||
|
fillRange(buf);
|
||||||
|
return buf[0] | (quint64(buf[1]) << 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
double generateDouble()
|
||||||
{
|
{
|
||||||
// IEEE 754 double precision has:
|
// IEEE 754 double precision has:
|
||||||
// 1 bit sign
|
// 1 bit sign
|
||||||
@ -77,87 +102,161 @@ public:
|
|||||||
return double(x) / double(limit);
|
return double(x) / double(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static qreal bounded(qreal sup)
|
double bounded(double highest)
|
||||||
{
|
{
|
||||||
return generateDouble() * sup;
|
return generateDouble() * highest;
|
||||||
}
|
}
|
||||||
|
|
||||||
static quint32 bounded(quint32 sup)
|
quint32 bounded(quint32 highest)
|
||||||
{
|
{
|
||||||
quint64 value = generate();
|
quint64 value = generate();
|
||||||
value *= sup;
|
value *= highest;
|
||||||
value /= (max)() + quint64(1);
|
value /= (max)() + quint64(1);
|
||||||
return quint32(value);
|
return quint32(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bounded(int sup)
|
int bounded(int highest)
|
||||||
{
|
{
|
||||||
return int(bounded(quint32(sup)));
|
return int(bounded(quint32(highest)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static quint32 bounded(quint32 min, quint32 sup)
|
quint32 bounded(quint32 lowest, quint32 highest)
|
||||||
{
|
{
|
||||||
return bounded(sup - min) + min;
|
return bounded(highest - lowest) + lowest;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int bounded(int min, int sup)
|
int bounded(int lowest, int highest)
|
||||||
{
|
{
|
||||||
return bounded(sup - min) + min;
|
return bounded(highest - lowest) + lowest;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename UInt, IfValidUInt<UInt> = true>
|
template <typename UInt, IfValidUInt<UInt> = true>
|
||||||
static void fillRange(UInt *buffer, qssize_t count)
|
void fillRange(UInt *buffer, qssize_t count)
|
||||||
{
|
{
|
||||||
fillRange_helper(buffer, buffer + count);
|
_fillRange(buffer, buffer + count);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename UInt, size_t N, IfValidUInt<UInt> = true>
|
template <typename UInt, size_t N, IfValidUInt<UInt> = true>
|
||||||
static void fillRange(UInt (&buffer)[N])
|
void fillRange(UInt (&buffer)[N])
|
||||||
{
|
{
|
||||||
fillRange_helper(buffer, buffer + N);
|
_fillRange(buffer, buffer + N);
|
||||||
}
|
}
|
||||||
|
|
||||||
// API like std::seed_seq
|
// API like std::seed_seq
|
||||||
template <typename ForwardIterator>
|
template <typename ForwardIterator>
|
||||||
void generate(ForwardIterator begin, ForwardIterator end)
|
void generate(ForwardIterator begin, ForwardIterator end)
|
||||||
{
|
{
|
||||||
auto generator = static_cast<quint32 (*)()>(&QRandomGenerator::generate);
|
std::generate(begin, end, [this]() { return generate(); });
|
||||||
std::generate(begin, end, generator);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void generate(quint32 *begin, quint32 *end)
|
void generate(quint32 *begin, quint32 *end)
|
||||||
{
|
{
|
||||||
fillRange_helper(begin, end);
|
_fillRange(begin, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// API like std::random_device
|
// API like std:: random engines
|
||||||
typedef quint32 result_type;
|
typedef quint32 result_type;
|
||||||
result_type operator()() { return generate(); }
|
result_type operator()() { return generate(); }
|
||||||
double entropy() const Q_DECL_NOTHROW { return 0.0; }
|
void seed(quint32 s = 1) { *this = { s }; }
|
||||||
|
void seed(std::seed_seq &sseq) Q_DECL_NOTHROW { *this = { sseq }; }
|
||||||
|
Q_CORE_EXPORT void discard(unsigned long long z);
|
||||||
static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
|
static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
|
||||||
static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
|
static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
|
||||||
|
|
||||||
|
static inline Q_DECL_CONST_FUNCTION QRandomGenerator *system();
|
||||||
|
static inline Q_DECL_CONST_FUNCTION QRandomGenerator *global();
|
||||||
|
static inline QRandomGenerator securelySeeded();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
enum System {};
|
||||||
|
QRandomGenerator(System);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static Q_CORE_EXPORT void fillRange_helper(void *buffer, void *bufferEnd);
|
Q_CORE_EXPORT void _fillRange(void *buffer, void *bufferEnd);
|
||||||
|
|
||||||
|
friend class QRandomGenerator64;
|
||||||
|
struct SystemGenerator;
|
||||||
|
struct SystemAndGlobalGenerators;
|
||||||
|
typedef std::mt19937 RandomEngine;
|
||||||
|
|
||||||
|
union Storage {
|
||||||
|
uint dummy;
|
||||||
|
#ifdef Q_COMPILER_UNRESTRICTED_UNIONS
|
||||||
|
RandomEngine twister;
|
||||||
|
RandomEngine &engine() { return twister; }
|
||||||
|
const RandomEngine &engine() const { return twister; }
|
||||||
|
#else
|
||||||
|
std::aligned_storage<sizeof(RandomEngine), Q_ALIGNOF(RandomEngine)>::type buffer;
|
||||||
|
RandomEngine &engine() { return reinterpret_cast<RandomEngine &>(buffer); }
|
||||||
|
const RandomEngine &engine() const { return reinterpret_cast<const RandomEngine &>(buffer); }
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Q_STATIC_ASSERT_X(std::is_trivially_destructible<RandomEngine>::value,
|
||||||
|
"std::mersenne_twister not trivially destructible as expected");
|
||||||
|
Q_DECL_CONSTEXPR Storage();
|
||||||
|
};
|
||||||
|
uint type;
|
||||||
|
Storage storage;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QRandomGenerator64
|
class QRandomGenerator64 : public QRandomGenerator
|
||||||
{
|
{
|
||||||
|
QRandomGenerator64(System);
|
||||||
public:
|
public:
|
||||||
static QRandomGenerator64 system() { return {}; }
|
// unshadow generate() overloads, since we'll override.
|
||||||
static QRandomGenerator64 global() { return {}; }
|
using QRandomGenerator::generate;
|
||||||
QRandomGenerator64() = default;
|
quint64 generate() { return generate64(); }
|
||||||
|
|
||||||
static quint64 generate() { return QRandomGenerator::generate64(); }
|
|
||||||
|
|
||||||
// API like std::random_device
|
|
||||||
typedef quint64 result_type;
|
typedef quint64 result_type;
|
||||||
result_type operator()() { return QRandomGenerator::generate64(); }
|
result_type operator()() { return generate64(); }
|
||||||
double entropy() const Q_DECL_NOTHROW { return 0.0; }
|
|
||||||
|
#ifndef Q_QDOC
|
||||||
|
QRandomGenerator64(quint32 seedValue = 1)
|
||||||
|
: QRandomGenerator(seedValue)
|
||||||
|
{}
|
||||||
|
template <qssize_t N> QRandomGenerator64(const quint32 (&seedBuffer)[N])
|
||||||
|
: QRandomGenerator(seedBuffer)
|
||||||
|
{}
|
||||||
|
QRandomGenerator64(const quint32 *seedBuffer, qssize_t len)
|
||||||
|
: QRandomGenerator(seedBuffer, len)
|
||||||
|
{}
|
||||||
|
QRandomGenerator64(std::seed_seq &sseq) Q_DECL_NOTHROW
|
||||||
|
: QRandomGenerator(sseq)
|
||||||
|
{}
|
||||||
|
QRandomGenerator64(const quint32 *begin, const quint32 *end)
|
||||||
|
: QRandomGenerator(begin, end)
|
||||||
|
{}
|
||||||
|
QRandomGenerator64(const QRandomGenerator &other) : QRandomGenerator(other) {}
|
||||||
|
|
||||||
|
void discard(unsigned long long z)
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(z * 2 > z, "QRandomGenerator64::discard",
|
||||||
|
"Overflow. Are you sure you want to skip over 9 quintillion samples?");
|
||||||
|
QRandomGenerator::discard(z * 2);
|
||||||
|
}
|
||||||
|
|
||||||
static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
|
static Q_DECL_CONSTEXPR result_type min() { return (std::numeric_limits<result_type>::min)(); }
|
||||||
static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
|
static Q_DECL_CONSTEXPR result_type max() { return (std::numeric_limits<result_type>::max)(); }
|
||||||
|
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *system();
|
||||||
|
static Q_DECL_CONST_FUNCTION Q_CORE_EXPORT QRandomGenerator64 *global();
|
||||||
|
static Q_CORE_EXPORT QRandomGenerator64 securelySeeded();
|
||||||
|
#endif // Q_QDOC
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline QRandomGenerator *QRandomGenerator::system()
|
||||||
|
{
|
||||||
|
return QRandomGenerator64::system();
|
||||||
|
}
|
||||||
|
|
||||||
|
inline QRandomGenerator *QRandomGenerator::global()
|
||||||
|
{
|
||||||
|
return QRandomGenerator64::global();
|
||||||
|
}
|
||||||
|
|
||||||
|
QRandomGenerator QRandomGenerator::securelySeeded()
|
||||||
|
{
|
||||||
|
return QRandomGenerator64::securelySeeded();
|
||||||
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
@ -52,11 +52,12 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "qglobal_p.h"
|
#include "qglobal_p.h"
|
||||||
|
#include <private/qsimd_p.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
enum QRandomGeneratorControl {
|
enum QRandomGeneratorControl {
|
||||||
SkipMemfill = 1,
|
UseSystemRNG = 1,
|
||||||
SkipSystemRNG = 2,
|
SkipSystemRNG = 2,
|
||||||
SkipHWRNG = 4,
|
SkipHWRNG = 4,
|
||||||
SetRandomData = 8,
|
SetRandomData = 8,
|
||||||
@ -65,6 +66,11 @@ enum QRandomGeneratorControl {
|
|||||||
RandomDataMask = 0xfffffff0
|
RandomDataMask = 0xfffffff0
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum RNGType {
|
||||||
|
SystemRNG = 0,
|
||||||
|
MersenneTwister = 1
|
||||||
|
};
|
||||||
|
|
||||||
#if defined(QT_BUILD_INTERNAL) && defined(QT_BUILD_CORE_LIB)
|
#if defined(QT_BUILD_INTERNAL) && defined(QT_BUILD_CORE_LIB)
|
||||||
Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control = Q_BASIC_ATOMIC_INITIALIZER(0U);
|
Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control = Q_BASIC_ATOMIC_INITIALIZER(0U);
|
||||||
#elif defined(QT_BUILD_INTERNAL)
|
#elif defined(QT_BUILD_INTERNAL)
|
||||||
@ -73,6 +79,16 @@ extern Q_CORE_EXPORT QBasicAtomicInteger<uint> qt_randomdevice_control;
|
|||||||
enum { qt_randomdevice_control = 0 };
|
enum { qt_randomdevice_control = 0 };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
inline bool qt_has_hwrng()
|
||||||
|
{
|
||||||
|
#if defined(Q_PROCESSOR_X86) && QT_COMPILER_SUPPORTS_HERE(RDRND)
|
||||||
|
return qCpuHasFeature(RDRND);
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
#endif // QRANDOM_P_H
|
#endif // QRANDOM_P_H
|
||||||
|
@ -308,7 +308,7 @@ void QWindowsRemovableDriveListener::addPath(const QString &p)
|
|||||||
notify.dbch_size = sizeof(notify);
|
notify.dbch_size = sizeof(notify);
|
||||||
notify.dbch_devicetype = DBT_DEVTYP_HANDLE;
|
notify.dbch_devicetype = DBT_DEVTYP_HANDLE;
|
||||||
notify.dbch_handle = volumeHandle;
|
notify.dbch_handle = volumeHandle;
|
||||||
QEventDispatcherWin32 *winEventDispatcher = static_cast<QEventDispatcherWin32 *>(QCoreApplication::eventDispatcher());
|
QEventDispatcherWin32 *winEventDispatcher = static_cast<QEventDispatcherWin32 *>(QAbstractEventDispatcher::instance());
|
||||||
re.devNotify = RegisterDeviceNotification(winEventDispatcher->internalHwnd(),
|
re.devNotify = RegisterDeviceNotification(winEventDispatcher->internalHwnd(),
|
||||||
¬ify, DEVICE_NOTIFY_WINDOW_HANDLE);
|
¬ify, DEVICE_NOTIFY_WINDOW_HANDLE);
|
||||||
// Empirically found: The notifications also work when the handle is immediately
|
// Empirically found: The notifications also work when the handle is immediately
|
||||||
@ -336,7 +336,7 @@ QWindowsFileSystemWatcherEngine::QWindowsFileSystemWatcherEngine(QObject *parent
|
|||||||
: QFileSystemWatcherEngine(parent)
|
: QFileSystemWatcherEngine(parent)
|
||||||
{
|
{
|
||||||
#ifndef Q_OS_WINRT
|
#ifndef Q_OS_WINRT
|
||||||
if (QAbstractEventDispatcher *eventDispatcher = QCoreApplication::eventDispatcher()) {
|
if (QAbstractEventDispatcher *eventDispatcher = QAbstractEventDispatcher::instance()) {
|
||||||
m_driveListener = new QWindowsRemovableDriveListener(this);
|
m_driveListener = new QWindowsRemovableDriveListener(this);
|
||||||
eventDispatcher->installNativeEventFilter(m_driveListener);
|
eventDispatcher->installNativeEventFilter(m_driveListener);
|
||||||
parent->setProperty("_q_driveListener",
|
parent->setProperty("_q_driveListener",
|
||||||
|
@ -775,6 +775,7 @@ bool QIODevice::open(OpenMode mode)
|
|||||||
d->writeBuffers.clear();
|
d->writeBuffers.clear();
|
||||||
d->setReadChannelCount(isReadable() ? 1 : 0);
|
d->setReadChannelCount(isReadable() ? 1 : 0);
|
||||||
d->setWriteChannelCount(isWritable() ? 1 : 0);
|
d->setWriteChannelCount(isWritable() ? 1 : 0);
|
||||||
|
d->errorString.clear();
|
||||||
#if defined QIODEVICE_DEBUG
|
#if defined QIODEVICE_DEBUG
|
||||||
printf("%p QIODevice::open(0x%x)\n", this, quint32(mode));
|
printf("%p QIODevice::open(0x%x)\n", this, quint32(mode));
|
||||||
#endif
|
#endif
|
||||||
@ -801,7 +802,6 @@ void QIODevice::close()
|
|||||||
emit aboutToClose();
|
emit aboutToClose();
|
||||||
#endif
|
#endif
|
||||||
d->openMode = NotOpen;
|
d->openMode = NotOpen;
|
||||||
d->errorString.clear();
|
|
||||||
d->pos = 0;
|
d->pos = 0;
|
||||||
d->transactionStarted = false;
|
d->transactionStarted = false;
|
||||||
d->transactionPos = 0;
|
d->transactionPos = 0;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2016 The Qt Company Ltd.
|
** Copyright (C) 2016 The Qt Company Ltd.
|
||||||
** Copyright (C) 2016 Intel Corporation.
|
** Copyright (C) 2017 Intel Corporation.
|
||||||
** Contact: https://www.qt.io/licensing/
|
** Contact: https://www.qt.io/licensing/
|
||||||
**
|
**
|
||||||
** This file is part of the QtCore module of the Qt Toolkit.
|
** This file is part of the QtCore module of the Qt Toolkit.
|
||||||
@ -48,6 +48,7 @@
|
|||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
#include <qelapsedtimer.h>
|
#include <qelapsedtimer.h>
|
||||||
#include <qfileinfo.h>
|
#include <qfileinfo.h>
|
||||||
|
#include <qrandom.h>
|
||||||
#include <qregexp.h>
|
#include <qregexp.h>
|
||||||
#include <qwineventnotifier.h>
|
#include <qwineventnotifier.h>
|
||||||
#include <private/qsystemlibrary_p.h>
|
#include <private/qsystemlibrary_p.h>
|
||||||
@ -99,10 +100,8 @@ static void qt_create_pipe(Q_PIPE *pipe, bool isInputPipe)
|
|||||||
wchar_t pipeName[256];
|
wchar_t pipeName[256];
|
||||||
unsigned int attempts = 1000;
|
unsigned int attempts = 1000;
|
||||||
forever {
|
forever {
|
||||||
// ### The user must make sure to call qsrand() to make the pipe names less predictable.
|
|
||||||
// ### Replace the call to qrand() with a secure version, once we have it in Qt.
|
|
||||||
_snwprintf(pipeName, sizeof(pipeName) / sizeof(pipeName[0]),
|
_snwprintf(pipeName, sizeof(pipeName) / sizeof(pipeName[0]),
|
||||||
L"\\\\.\\pipe\\qt-%X", qrand());
|
L"\\\\.\\pipe\\qt-%X", QRandomGenerator::global()->generate());
|
||||||
|
|
||||||
DWORD dwOpenMode = FILE_FLAG_OVERLAPPED;
|
DWORD dwOpenMode = FILE_FLAG_OVERLAPPED;
|
||||||
DWORD dwOutputBufferSize = 0;
|
DWORD dwOutputBufferSize = 0;
|
||||||
|
@ -544,6 +544,38 @@ void QStorageInfoPrivate::initRootPath()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
// udev encodes the labels with ID_LABEL_FS_ENC which is done with
|
||||||
|
// blkid_encode_string(). Within this function some 1-byte utf-8
|
||||||
|
// characters not considered safe (e.g. '\' or ' ') are encoded as hex
|
||||||
|
static QString decodeFsEncString(const QString &str)
|
||||||
|
{
|
||||||
|
QString decoded;
|
||||||
|
decoded.reserve(str.size());
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
while (i < str.size()) {
|
||||||
|
if (i <= str.size() - 4) { // we need at least four characters \xAB
|
||||||
|
if (str.at(i) == QLatin1Char('\\') &&
|
||||||
|
str.at(i+1) == QLatin1Char('x')) {
|
||||||
|
bool bOk;
|
||||||
|
const int code = str.midRef(i+2, 2).toInt(&bOk, 16);
|
||||||
|
// only decode characters between 0x20 and 0x7f but not
|
||||||
|
// the backslash to prevent collisions
|
||||||
|
if (bOk && code >= 0x20 && code < 0x80 && code != '\\') {
|
||||||
|
decoded += QChar(code);
|
||||||
|
i += 4;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
decoded += str.at(i);
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
return decoded;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline QString retrieveLabel(const QByteArray &device)
|
static inline QString retrieveLabel(const QByteArray &device)
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_LINUX
|
#ifdef Q_OS_LINUX
|
||||||
@ -557,7 +589,7 @@ static inline QString retrieveLabel(const QByteArray &device)
|
|||||||
it.next();
|
it.next();
|
||||||
QFileInfo fileInfo(it.fileInfo());
|
QFileInfo fileInfo(it.fileInfo());
|
||||||
if (fileInfo.isSymLink() && fileInfo.symLinkTarget() == devicePath)
|
if (fileInfo.isSymLink() && fileInfo.symLinkTarget() == devicePath)
|
||||||
return fileInfo.fileName();
|
return decodeFsEncString(fileInfo.fileName());
|
||||||
}
|
}
|
||||||
#elif defined Q_OS_HAIKU
|
#elif defined Q_OS_HAIKU
|
||||||
fs_info fsInfo;
|
fs_info fsInfo;
|
||||||
|
@ -165,7 +165,7 @@ QFileSystemEntry::NativePath QTemporaryFileName::generateNext()
|
|||||||
|
|
||||||
Char *rIter = placeholderEnd;
|
Char *rIter = placeholderEnd;
|
||||||
while (rIter != placeholderStart) {
|
while (rIter != placeholderStart) {
|
||||||
quint32 rnd = QRandomGenerator::generate();
|
quint32 rnd = QRandomGenerator::global()->generate();
|
||||||
auto applyOne = [&]() {
|
auto applyOne = [&]() {
|
||||||
quint32 v = rnd & ((1 << BitsPerCharacter) - 1);
|
quint32 v = rnd & ((1 << BitsPerCharacter) - 1);
|
||||||
rnd >>= BitsPerCharacter;
|
rnd >>= BitsPerCharacter;
|
||||||
|
@ -67,6 +67,12 @@ class QMutexData;
|
|||||||
class Q_CORE_EXPORT QBasicMutex
|
class Q_CORE_EXPORT QBasicMutex
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
#ifdef Q_COMPILER_CONSTEXPR
|
||||||
|
constexpr QBasicMutex()
|
||||||
|
: d_ptr(nullptr)
|
||||||
|
{}
|
||||||
|
#endif
|
||||||
|
|
||||||
// BasicLockable concept
|
// BasicLockable concept
|
||||||
inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
|
inline void lock() QT_MUTEX_LOCK_NOEXCEPT {
|
||||||
if (!fastTryLock())
|
if (!fastTryLock())
|
||||||
|
@ -71,8 +71,6 @@ private:
|
|||||||
|
|
||||||
class QSemaphoreReleaser
|
class QSemaphoreReleaser
|
||||||
{
|
{
|
||||||
QSemaphore *m_sem = nullptr;
|
|
||||||
int m_n;
|
|
||||||
public:
|
public:
|
||||||
QSemaphoreReleaser() = default;
|
QSemaphoreReleaser() = default;
|
||||||
explicit QSemaphoreReleaser(QSemaphore &sem, int n = 1) Q_DECL_NOTHROW
|
explicit QSemaphoreReleaser(QSemaphore &sem, int n = 1) Q_DECL_NOTHROW
|
||||||
@ -106,6 +104,10 @@ public:
|
|||||||
m_sem = nullptr;
|
m_sem = nullptr;
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSemaphore *m_sem = nullptr;
|
||||||
|
int m_n;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_NO_THREAD
|
#endif // QT_NO_THREAD
|
||||||
|
@ -339,6 +339,7 @@ static void qt_initialize_qhash_seed()
|
|||||||
*/
|
*/
|
||||||
int qGlobalQHashSeed()
|
int qGlobalQHashSeed()
|
||||||
{
|
{
|
||||||
|
qt_initialize_qhash_seed();
|
||||||
return qt_qhash_seed.load();
|
return qt_qhash_seed.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -652,32 +652,6 @@ Q_CORE_EXPORT QBasicAtomicInteger<unsigned> qt_cpu_features[2] = { Q_BASIC_ATOMI
|
|||||||
|
|
||||||
void qDetectCpuFeatures()
|
void qDetectCpuFeatures()
|
||||||
{
|
{
|
||||||
#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
|
|
||||||
# if Q_CC_GNU < 403
|
|
||||||
// GCC 4.2 (at least the one that comes with Apple's XCode, on Mac) is
|
|
||||||
// known to be broken beyond repair in dealing with the inline assembly
|
|
||||||
// above. It will generate bad code that could corrupt important registers
|
|
||||||
// like the PIC register. The behaviour of code after this function would
|
|
||||||
// be totally unpredictable.
|
|
||||||
//
|
|
||||||
// For that reason, simply forego the CPUID check at all and return the set
|
|
||||||
// of features that we found at compile time, through the #defines from the
|
|
||||||
// compiler. This should at least allow code to execute, even if none of
|
|
||||||
// the specialized code found in Qt GUI and elsewhere will ever be enabled
|
|
||||||
// (it's the user's fault for using a broken compiler).
|
|
||||||
//
|
|
||||||
// This also disables the runtime checking that the processor actually
|
|
||||||
// contains all the features that the code required. Qt 4 ran for years
|
|
||||||
// like that, so it shouldn't be a problem.
|
|
||||||
|
|
||||||
qt_cpu_features[0].store(minFeature | quint32(QSimdInitialized));
|
|
||||||
#ifndef Q_ATOMIC_INT64_IS_SUPPORTED
|
|
||||||
qt_cpu_features[1].store(minFeature >> 32);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return;
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
quint64 f = detectProcessorFeatures();
|
quint64 f = detectProcessorFeatures();
|
||||||
QByteArray disable = qgetenv("QT_NO_CPU_FEATURE");
|
QByteArray disable = qgetenv("QT_NO_CPU_FEATURE");
|
||||||
if (!disable.isEmpty()) {
|
if (!disable.isEmpty()) {
|
||||||
|
@ -388,7 +388,7 @@ QVersionNumber QVersionNumber::commonPrefix(const QVersionNumber &v1,
|
|||||||
/*!
|
/*!
|
||||||
\fn QString QVersionNumber::toString() const
|
\fn QString QVersionNumber::toString() const
|
||||||
|
|
||||||
Returns a string with all of the segments delimited by a '.'.
|
Returns a string with all of the segments delimited by a period (\c{.}).
|
||||||
|
|
||||||
\sa majorVersion(), minorVersion(), microVersion(), segments()
|
\sa majorVersion(), minorVersion(), microVersion(), segments()
|
||||||
*/
|
*/
|
||||||
@ -409,7 +409,7 @@ QString QVersionNumber::toString() const
|
|||||||
#if QT_STRINGVIEW_LEVEL < 2
|
#if QT_STRINGVIEW_LEVEL < 2
|
||||||
/*!
|
/*!
|
||||||
Constructs a QVersionNumber from a specially formatted \a string of
|
Constructs a QVersionNumber from a specially formatted \a string of
|
||||||
non-negative decimal numbers delimited by '.'.
|
non-negative decimal numbers delimited by a period (\c{.}).
|
||||||
|
|
||||||
Once the numerical segments have been parsed, the remainder of the string
|
Once the numerical segments have been parsed, the remainder of the string
|
||||||
is considered to be the suffix string. The start index of that string will be
|
is considered to be the suffix string. The start index of that string will be
|
||||||
|
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include <qpainter.h>
|
#include <qpainter.h>
|
||||||
#include <qimage.h>
|
#include <qimage.h>
|
||||||
|
#include <qrandom.h>
|
||||||
#include <qscreen.h>
|
#include <qscreen.h>
|
||||||
|
|
||||||
#include <private/qguiapplication_p.h>
|
#include <private/qguiapplication_p.h>
|
||||||
@ -252,7 +253,7 @@ QImage *QBlittablePlatformPixmap::overlay()
|
|||||||
m_rasterOverlay->size() != QSize(w,h)){
|
m_rasterOverlay->size() != QSize(w,h)){
|
||||||
m_rasterOverlay = new QImage(w,h,QImage::Format_ARGB32_Premultiplied);
|
m_rasterOverlay = new QImage(w,h,QImage::Format_ARGB32_Premultiplied);
|
||||||
m_rasterOverlay->fill(0x00000000);
|
m_rasterOverlay->fill(0x00000000);
|
||||||
uint color = (qrand() % 11)+7;
|
uint color = QRandomGenerator::global()->bounded(11)+7;
|
||||||
m_overlayColor = QColor(Qt::GlobalColor(color));
|
m_overlayColor = QColor(Qt::GlobalColor(color));
|
||||||
m_overlayColor.setAlpha(0x88);
|
m_overlayColor.setAlpha(0x88);
|
||||||
|
|
||||||
|
@ -402,7 +402,8 @@ inline QRegion fromNativeLocalExposedRegion(const QRegion &pixelRegion, const QW
|
|||||||
const QPointF topLeftP = rect.topLeft() / scaleFactor;
|
const QPointF topLeftP = rect.topLeft() / scaleFactor;
|
||||||
const QSizeF sizeP = rect.size() / scaleFactor;
|
const QSizeF sizeP = rect.size() / scaleFactor;
|
||||||
pointRegion += QRect(QPoint(qFloor(topLeftP.x()), qFloor(topLeftP.y())),
|
pointRegion += QRect(QPoint(qFloor(topLeftP.x()), qFloor(topLeftP.y())),
|
||||||
QSize(qCeil(sizeP.width()), qCeil(sizeP.height())));
|
QPoint(qCeil(topLeftP.x() + sizeP.width() - 1.0),
|
||||||
|
qCeil(topLeftP.y() + sizeP.height() - 1.0)));
|
||||||
}
|
}
|
||||||
return pointRegion;
|
return pointRegion;
|
||||||
}
|
}
|
||||||
|
@ -1008,6 +1008,7 @@ bool QOpenGLContext::makeCurrent(QSurface *surface)
|
|||||||
|| qstrncmp(rendererString, "Adreno 4xx", 8) == 0 // Same as above but without the '(TM)'
|
|| qstrncmp(rendererString, "Adreno 4xx", 8) == 0 // Same as above but without the '(TM)'
|
||||||
|| qstrcmp(rendererString, "GC800 core") == 0
|
|| qstrcmp(rendererString, "GC800 core") == 0
|
||||||
|| qstrcmp(rendererString, "GC1000 core") == 0
|
|| qstrcmp(rendererString, "GC1000 core") == 0
|
||||||
|
|| strstr(rendererString, "GC2000") != 0
|
||||||
|| qstrcmp(rendererString, "Immersion.16") == 0;
|
|| qstrcmp(rendererString, "Immersion.16") == 0;
|
||||||
}
|
}
|
||||||
needsWorkaroundSet = true;
|
needsWorkaroundSet = true;
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
# include "qaccessible.h"
|
# include "qaccessible.h"
|
||||||
#endif
|
#endif
|
||||||
#include "qhighdpiscaling_p.h"
|
#include "qhighdpiscaling_p.h"
|
||||||
|
#include "qshapedpixmapdndwindow_p.h"
|
||||||
|
|
||||||
#include <private/qevent_p.h>
|
#include <private/qevent_p.h>
|
||||||
|
|
||||||
@ -379,7 +380,9 @@ void QWindowPrivate::setVisible(bool visible)
|
|||||||
QGuiApplicationPrivate::showModalWindow(q);
|
QGuiApplicationPrivate::showModalWindow(q);
|
||||||
else
|
else
|
||||||
QGuiApplicationPrivate::hideModalWindow(q);
|
QGuiApplicationPrivate::hideModalWindow(q);
|
||||||
} else if (visible && QGuiApplication::modalWindow()) {
|
// QShapedPixmapWindow is used on some platforms for showing a drag pixmap, so don't block
|
||||||
|
// input to this window as it is performing a drag - QTBUG-63846
|
||||||
|
} else if (visible && QGuiApplication::modalWindow() && !qobject_cast<QShapedPixmapWindow *>(q)) {
|
||||||
QGuiApplicationPrivate::updateBlockedStatus(q);
|
QGuiApplicationPrivate::updateBlockedStatus(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +42,7 @@
|
|||||||
#include <private/qopenglcontext_p.h>
|
#include <private/qopenglcontext_p.h>
|
||||||
#include <private/qrgba64_p.h>
|
#include <private/qrgba64_p.h>
|
||||||
#include <QtCore/qmutex.h>
|
#include <QtCore/qmutex.h>
|
||||||
|
#include <QtCore/qrandom.h>
|
||||||
#include "qopenglfunctions.h"
|
#include "qopenglfunctions.h"
|
||||||
#include "qopenglextensions_p.h"
|
#include "qopenglextensions_p.h"
|
||||||
|
|
||||||
@ -137,7 +138,7 @@ GLuint QOpenGL2GradientCache::addCacheElement(quint64 hash_val, const QGradient
|
|||||||
{
|
{
|
||||||
QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
|
QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
|
||||||
if (cache.size() == maxCacheSize()) {
|
if (cache.size() == maxCacheSize()) {
|
||||||
int elem_to_remove = qrand() % maxCacheSize();
|
int elem_to_remove = QRandomGenerator::global()->bounded(maxCacheSize());
|
||||||
quint64 key = cache.keys()[elem_to_remove];
|
quint64 key = cache.keys()[elem_to_remove];
|
||||||
|
|
||||||
// need to call glDeleteTextures on each removed cache entry:
|
// need to call glDeleteTextures on each removed cache entry:
|
||||||
|
@ -110,6 +110,7 @@ NSImage *qt_mac_create_nsimage(const QPixmap &pm)
|
|||||||
QImage image = pm.toImage();
|
QImage image = pm.toImage();
|
||||||
CGImageRef cgImage = qt_mac_toCGImage(image);
|
CGImageRef cgImage = qt_mac_toCGImage(image);
|
||||||
NSImage *nsImage = qt_mac_cgimage_to_nsimage(cgImage);
|
NSImage *nsImage = qt_mac_cgimage_to_nsimage(cgImage);
|
||||||
|
nsImage.size = (pm.size() / pm.devicePixelRatioF()).toCGSize();
|
||||||
CGImageRelease(cgImage);
|
CGImageRelease(cgImage);
|
||||||
return nsImage;
|
return nsImage;
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <qbitmap.h>
|
#include <qbitmap.h>
|
||||||
#include <qmath.h>
|
#include <qmath.h>
|
||||||
|
#include <qrandom.h>
|
||||||
|
|
||||||
// #include <private/qdatabuffer_p.h>
|
// #include <private/qdatabuffer_p.h>
|
||||||
// #include <private/qpainter_p.h>
|
// #include <private/qpainter_p.h>
|
||||||
@ -4229,7 +4230,7 @@ protected:
|
|||||||
QSharedPointer<const CacheInfo> addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
|
QSharedPointer<const CacheInfo> addCacheElement(quint64 hash_val, const QGradient &gradient, int opacity) {
|
||||||
if (cache.size() == maxCacheSize()) {
|
if (cache.size() == maxCacheSize()) {
|
||||||
// may remove more than 1, but OK
|
// may remove more than 1, but OK
|
||||||
cache.erase(cache.begin() + (qrand() % maxCacheSize()));
|
cache.erase(cache.begin() + QRandomGenerator::global()->bounded(maxCacheSize()));
|
||||||
}
|
}
|
||||||
auto cache_entry = QSharedPointer<CacheInfo>::create(gradient.stops(), opacity, gradient.interpolationMode());
|
auto cache_entry = QSharedPointer<CacheInfo>::create(gradient.stops(), opacity, gradient.interpolationMode());
|
||||||
generateGradientColorTable(gradient, cache_entry->buffer64, paletteSize(), opacity);
|
generateGradientColorTable(gradient, cache_entry->buffer64, paletteSize(), opacity);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user