Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qimagescale_p.h
Go to the documentation of this file.
1// Copyright (C) 2019 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4#ifndef QIMAGESCALE_P_H
5#define QIMAGESCALE_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <qimage.h>
19#include <private/qtguiglobal_p.h>
20
21#if QT_CONFIG(qtgui_threadpool)
22#include <qthreadpool.h>
23#include <private/qguiapplication_p.h>
24#include <private/qlatch_p.h>
25#include <private/qthreadpool_p.h>
26#endif
27
29
30/*
31 This version accepts only supported formats.
32*/
33QImage qSmoothScaleImage(const QImage &img, int w, int h);
34
35namespace QImageScale {
37 int *xpoints{nullptr};
38 const unsigned int **ypoints{nullptr};
39 int *xapoints{nullptr};
40 int *yapoints{nullptr};
41 int xup_yup{0};
42 int sh = 0;
43 int sw = 0;
44 };
45
46 template<typename T>
47 void multithread_pixels_function(QImageScaleInfo *isi, int dh, const T &scaleSection)
48 {
49#if QT_CONFIG(qtgui_threadpool)
50 int segments = (qsizetype(isi->sh) * isi->sw) / (1<<16);
51 segments = std::min(segments, dh);
52 QThreadPool *threadPool = QGuiApplicationPrivate::qtGuiThreadPool();
53 if (segments > 1 && threadPool && !threadPool->contains(QThread::currentThread())) {
54 QLatch latch(segments);
55 int y = 0;
56 for (int i = 0; i < segments; ++i) {
57 int yn = (dh - y) / (segments - i);
58 threadPool->start([&, y, yn]() {
59 scaleSection(y, y + yn);
60 latch.countDown();
61 });
62 y += yn;
63 }
64 latch.wait();
65 return;
66 }
67#else
68 Q_UNUSED(isi);
69#endif
70 scaleSection(0, dh);
71 }
72}
73
74QT_END_NAMESPACE
75
76#endif
void multithread_pixels_function(QImageScaleInfo *isi, int dh, const T &scaleSection)
Combined button and popup list for selecting options.
const unsigned int ** ypoints