Commit dab6f4b0 authored by Carl Olsson's avatar Carl Olsson

Merge remote-tracking branch 'upstream/master' into palettize

parents 91b8cfdf 1c6f88cb
......@@ -36,7 +36,6 @@ if (WIN32)
set(ext_qt_PATCH_COMMAND
${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-Use-fast-path-for-unsupported-mime-types.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0002-Hack-always-return-we-support-DIBV5.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/tiff.patch
)
# Tablet support patches
......@@ -110,7 +109,6 @@ elseif (NOT APPLE)
PATCH_COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0012-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0013-Poison-Qt-s-headers-with-a-mark-about-presence-of-En.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/tiff.patch
CMAKE_ARGS -DOPENSSL_LIBS='-L${EXTPREFIX_qt}/lib -lssl -lcrypto'
......@@ -216,7 +214,6 @@ else( APPLE )
set(ext_qt_PATCH_COMMAND ${PATCH_COMMAND}} -p1 -b -d <SOURCE_DIR>/qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/mac_standardpaths_qtbug-61159.diff
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0012-Synthesize-Enter-LeaveEvent-for-accepted-QTabletEven.patch
COMMAND ${PATCH_COMMAND} -p1 -d qtbase -i ${CMAKE_CURRENT_SOURCE_DIR}/0013-Poison-Qt-s-headers-with-a-mark-about-presence-of-En.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/tiff.patch
#COMMAND ${PATCH_COMMAND} -p1 -b -d <SOURCE_DIR>/qtbase/mkspecs/features/mac -i ${CMAKE_CURRENT_SOURCE_DIR}/mac-default.patch
)
......
diff --git a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
index e6c71753a..cd70fb9fa 100644
--- a/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
+++ b/qtimageformats/src/plugins/imageformats/tiff/qtiffhandler.cpp
@@ -272,6 +272,8 @@ bool QTiffHandlerPrivate::readHeaders(QIODevice *device)
format = QImage::Format_Mono;
else if (photometric == PHOTOMETRIC_MINISBLACK && bitPerSample == 8 && samplesPerPixel == 1)
format = QImage::Format_Grayscale8;
+ else if (photometric == PHOTOMETRIC_MINISBLACK && bitPerSample == 16 && samplesPerPixel == 1)
+ format = QImage::Format_Grayscale16;
else if ((grayscale || photometric == PHOTOMETRIC_PALETTE) && bitPerSample == 8 && samplesPerPixel == 1)
format = QImage::Format_Indexed8;
else if (samplesPerPixel < 4)
@@ -402,9 +404,11 @@ bool QTiffHandler::read(QImage *image)
}
}
bool format8bit = (format == QImage::Format_Mono || format == QImage::Format_Indexed8 || format == QImage::Format_Grayscale8);
+ bool format16bit = (format == QImage::Format_Grayscale16);
bool format64bit = (format == QImage::Format_RGBX64 || format == QImage::Format_RGBA64 || format == QImage::Format_RGBA64_Premultiplied);
- if (format8bit || format64bit) {
+ // Formats we read directly, instead of over RGBA32:
+ if (format8bit || format16bit || format64bit) {
int bytesPerPixel = image->depth() / 8;
if (format == QImage::Format_RGBX64)
bytesPerPixel = 6;
@@ -513,6 +517,7 @@ static QVector<QRgb> effectiveColorTable(const QImage &image)
colors[i] = qRgba(0, 0, 0, i);
break;
case QImage::Format_Grayscale8:
+ case QImage::Format_Grayscale16:
colors.resize(256);
for (int i = 0; i < 256; ++i)
colors[i] = qRgb(i, i, i);
@@ -622,6 +627,7 @@ bool QTiffHandler::write(const QImage &image)
TIFFClose(tiff);
} else if (format == QImage::Format_Indexed8
|| format == QImage::Format_Grayscale8
+ || format == QImage::Format_Grayscale16
|| format == QImage::Format_Alpha8) {
QVector<QRgb> colorTable = effectiveColorTable(image);
bool isGrayscale = checkGrayscale(colorTable);
@@ -631,7 +637,7 @@ bool QTiffHandler::write(const QImage &image)
photometric = PHOTOMETRIC_MINISWHITE;
if (!TIFFSetField(tiff, TIFFTAG_PHOTOMETRIC, photometric)
|| !TIFFSetField(tiff, TIFFTAG_COMPRESSION, compression == NoCompression ? COMPRESSION_NONE : COMPRESSION_LZW)
- || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, 8)
+ || !TIFFSetField(tiff, TIFFTAG_BITSPERSAMPLE, image.depth())
|| !TIFFSetField(tiff, TIFFTAG_ROWSPERSTRIP, defaultStripSize(tiff))) {
TIFFClose(tiff);
return false;
......@@ -149,15 +149,18 @@ void KisMirrorAxis::drawDecoration(QPainter& gc, const QRectF& updateArea, const
gc.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
QOpenGLContext *ctx = QOpenGLContext::currentContext();
bool hasMultisample = ((gc.paintEngine()->type() == QPaintEngine::OpenGL2) &&
(ctx->hasExtension("GL_ARB_multisample")));
// QPainter cannot anti-alias the edges of circles etc. when using OpenGL
// So instead, use native OpenGL anti-aliasing when available.
if (hasMultisample) {
gc.beginNativePainting();
ctx->functions()->glEnable(GL_MULTISAMPLE);
gc.endNativePainting();
bool hasMultisample = false;
if (ctx) {
hasMultisample = ((gc.paintEngine()->type() == QPaintEngine::OpenGL2) &&
(ctx->hasExtension("GL_ARB_multisample")));
// QPainter cannot anti-alias the edges of circles etc. when using OpenGL
// So instead, use native OpenGL anti-aliasing when available.
if (hasMultisample) {
gc.beginNativePainting();
ctx->functions()->glEnable(GL_MULTISAMPLE);
gc.endNativePainting();
}
}
float halfHandleSize = d->config.handleSize() / 2;
......@@ -166,8 +169,8 @@ void KisMirrorAxis::drawDecoration(QPainter& gc, const QRectF& updateArea, const
if(d->config.mirrorHorizontal() && !d->config.hideHorizontalDecoration()) {
if (!d->horizontalAxis.isNull()) {
// QPointF horizontalIndicatorCenter = d->horizontalAxis.unitVector().pointAt(15);
// QRectF horizontalIndicator = QRectF(horizontalIndicatorCenter.x() - halfHandleSize, horizontalIndicatorCenter.y() - halfHandleSize, d->config.handleSize(), d->config.handleSize());
// QPointF horizontalIndicatorCenter = d->horizontalAxis.unitVector().pointAt(15);
// QRectF horizontalIndicator = QRectF(horizontalIndicatorCenter.x() - halfHandleSize, horizontalIndicatorCenter.y() - halfHandleSize, d->config.handleSize(), d->config.handleSize());
float horizontalHandlePosition = qBound<float>(d->minHandlePosition, d->config.horizontalHandlePosition(), d->horizontalAxis.length() - d->minHandlePosition);
QPointF horizontalHandleCenter = d->horizontalAxis.unitVector().pointAt(horizontalHandlePosition);
......@@ -176,8 +179,8 @@ void KisMirrorAxis::drawDecoration(QPainter& gc, const QRectF& updateArea, const
gc.setPen(QPen(QColor(0, 0, 0, 64), 2, Qt::DashDotDotLine, Qt::RoundCap, Qt::RoundJoin));
gc.drawLine(d->horizontalAxis);
// gc.drawEllipse(horizontalIndicator);
// gc.drawPixmap(horizontalIndicator.adjusted(5, 5, -5, -5).toRect(), d->horizontalIcon);
// gc.drawEllipse(horizontalIndicator);
// gc.drawPixmap(horizontalIndicator.adjusted(5, 5, -5, -5).toRect(), d->horizontalIcon);
// don't draw the handles if we are locking the axis for movement
if (!d->config.lockHorizontal()) {
......@@ -198,8 +201,8 @@ void KisMirrorAxis::drawDecoration(QPainter& gc, const QRectF& updateArea, const
gc.drawLine(d->verticalAxis);
// QPointF verticalIndicatorCenter = d->verticalAxis.unitVector().pointAt(15);
// QRectF verticalIndicator = QRectF(verticalIndicatorCenter.x() - halfHandleSize, verticalIndicatorCenter.y() - halfHandleSize, d->config.handleSize(), d->config.handleSize());
// QPointF verticalIndicatorCenter = d->verticalAxis.unitVector().pointAt(15);
// QRectF verticalIndicator = QRectF(verticalIndicatorCenter.x() - halfHandleSize, verticalIndicatorCenter.y() - halfHandleSize, d->config.handleSize(), d->config.handleSize());
float verticalHandlePosition = qBound<float>(d->minHandlePosition, d->config.verticalHandlePosition(), d->verticalAxis.length() - d->minHandlePosition);
QPointF verticalHandleCenter = d->verticalAxis.unitVector().pointAt(verticalHandlePosition);
......@@ -232,7 +235,7 @@ bool KisMirrorAxis::eventFilter(QObject* target, QEvent* event)
if (!visible()) return false;
QObject *expectedCanvasWidget = view() ?
view()->canvasBase()->canvasWidget() : 0;
view()->canvasBase()->canvasWidget() : 0;
if (!expectedCanvasWidget || target != expectedCanvasWidget) return false;
......
......@@ -80,7 +80,9 @@ struct KisScreenInformationAdapter::Private
KisScreenInformationAdapter::KisScreenInformationAdapter(QOpenGLContext *context)
: m_d(new Private)
{
m_d->initialize(context);
if (context) {
m_d->initialize(context);
}
}
KisScreenInformationAdapter::~KisScreenInformationAdapter()
......
......@@ -23,6 +23,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QVector>
#include <QAction>
#include <KoSelection.h>
#include <KoShapeRegistry.h>
......@@ -90,7 +91,7 @@ void ToolReferenceImages::addReferenceImage()
auto kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
KIS_ASSERT_RECOVER_RETURN(kisCanvas)
KoFileDialog dialog(kisCanvas->viewManager()->mainWindow(), KoFileDialog::OpenFile, "OpenReferenceImage");
KoFileDialog dialog(kisCanvas->viewManager()->mainWindow(), KoFileDialog::OpenFile, "OpenReferenceImage");
dialog.setCaption(i18n("Select a Reference Image"));
QStringList locations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
......@@ -115,7 +116,7 @@ void ToolReferenceImages::pasteReferenceImage()
KisCanvas2* kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
KIS_ASSERT_RECOVER_RETURN(kisCanvas)
KisReferenceImage* reference = KisReferenceImage::fromClipboard(*kisCanvas->coordinatesConverter());
KisReferenceImage* reference = KisReferenceImage::fromClipboard(*kisCanvas->coordinatesConverter());
if(reference) {
KisDocument *doc = document();
doc->addCommand(KisReferenceImagesLayer::addReferenceImages(doc, {reference}));
......@@ -137,7 +138,7 @@ void ToolReferenceImages::loadReferenceImages()
auto kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
KIS_ASSERT_RECOVER_RETURN(kisCanvas)
KoFileDialog dialog(kisCanvas->viewManager()->mainWindow(), KoFileDialog::OpenFile, "OpenReferenceImageCollection");
KoFileDialog dialog(kisCanvas->viewManager()->mainWindow(), KoFileDialog::OpenFile, "OpenReferenceImageCollection");
dialog.setMimeTypeFilters(QStringList() << "application/x-krita-reference-images");
dialog.setCaption(i18n("Load Reference Images"));
......@@ -179,7 +180,7 @@ void ToolReferenceImages::saveReferenceImages()
auto kisCanvas = dynamic_cast<KisCanvas2*>(canvas());
KIS_ASSERT_RECOVER_RETURN(kisCanvas)
KoFileDialog dialog(kisCanvas->viewManager()->mainWindow(), KoFileDialog::SaveFile, "SaveReferenceImageCollection");
KoFileDialog dialog(kisCanvas->viewManager()->mainWindow(), KoFileDialog::SaveFile, "SaveReferenceImageCollection");
dialog.setMimeTypeFilters(QStringList() << "application/x-krita-reference-images");
dialog.setCaption(i18n("Save Reference Images"));
......@@ -232,7 +233,7 @@ QWidget *ToolReferenceImages::createOptionWidget()
m_optionsWidget->layout()->addWidget(specialSpacer);
}
return m_optionsWidget;
}
}
bool ToolReferenceImages::isValidForCurrentLayer() const
{
......@@ -281,24 +282,25 @@ KisDocument *ToolReferenceImages::document() const
QList<QAction *> ToolReferenceImagesFactory::createActionsImpl()
{
KisActionRegistry *actionRegistry = KisActionRegistry::instance();
QList<QAction *> actions = DefaultToolFactory::createActionsImpl();
actions << actionRegistry->makeQAction("object_order_front");
actions << actionRegistry->makeQAction("object_order_raise");
actions << actionRegistry->makeQAction("object_order_lower");
actions << actionRegistry->makeQAction("object_order_back");
actions << actionRegistry->makeQAction("object_group");
actions << actionRegistry->makeQAction("object_ungroup");
actions << actionRegistry->makeQAction("object_transform_rotate_90_cw");
actions << actionRegistry->makeQAction("object_transform_rotate_90_ccw");
actions << actionRegistry->makeQAction("object_transform_rotate_180");
actions << actionRegistry->makeQAction("object_transform_mirror_horizontally");
actions << actionRegistry->makeQAction("object_transform_mirror_vertically");
actions << actionRegistry->makeQAction("object_transform_reset");
actions << actionRegistry->makeQAction("object_unite");
actions << actionRegistry->makeQAction("object_intersect");
actions << actionRegistry->makeQAction("object_subtract");
actions << actionRegistry->makeQAction("object_split");
QList<QAction *> defaultActions = DefaultToolFactory::createActionsImpl();
QList<QAction *> actions;
QStringList actionNames;
actionNames << "object_order_front"
<< "object_order_raise"
<< "object_order_lower"
<< "object_order_back"
<< "object_transform_rotate_90_cw"
<< "object_transform_rotate_90_ccw"
<< "object_transform_rotate_180"
<< "object_transform_mirror_horizontally"
<< "object_transform_mirror_vertically"
<< "object_transform_reset";
Q_FOREACH(QAction *action, defaultActions) {
if (actionNames.contains(action->objectName())) {
actions << action;
}
}
return actions;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment