mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-24 19:02:59 +00:00
getting rid of QMacPixmapData and the (virtual) native graphics system
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
parent
77a82b78e5
commit
f5e96e50dc
11 changed files with 14 additions and 1464 deletions
|
@ -161,15 +161,6 @@ if(KATIE_PLATFORM STREQUAL "win32")
|
|||
${GUI_SOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image/qpixmap_win.cpp
|
||||
)
|
||||
elseif(KATIE_PLATFORM STREQUAL "mac")
|
||||
set(GUI_HEADERS
|
||||
${GUI_HEADERS}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image/qpixmap_mac_p.h
|
||||
)
|
||||
set(GUI_SOURCES
|
||||
${GUI_SOURCES}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/image/qpixmap_mac.cpp
|
||||
)
|
||||
elseif(WITH_X11 AND X11_FOUND)
|
||||
set(GUI_HEADERS
|
||||
${GUI_HEADERS}
|
||||
|
|
|
@ -1691,16 +1691,6 @@ void QPixmap::detach()
|
|||
if (data->is_cached && data->ref == 1)
|
||||
QImagePixmapCleanupHooks::executePixmapDataModificationHooks(data.data());
|
||||
|
||||
#if defined(Q_WS_MAC)
|
||||
QMacPixmapData *macData = id == QPixmapData::MacClass ? static_cast<QMacPixmapData*>(pd) : 0;
|
||||
if (macData) {
|
||||
if (macData->cg_mask) {
|
||||
CGImageRelease(macData->cg_mask);
|
||||
macData->cg_mask = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data->ref != 1) {
|
||||
*this = copy();
|
||||
}
|
||||
|
@ -1717,11 +1707,6 @@ void QPixmap::detach()
|
|||
d->hd2 = 0;
|
||||
}
|
||||
}
|
||||
#elif defined(Q_WS_MAC)
|
||||
if (macData) {
|
||||
macData->macReleaseCGImageRef();
|
||||
macData->uninit = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -222,7 +222,6 @@ private:
|
|||
#endif
|
||||
friend class QPixmapData;
|
||||
friend class QX11PixmapData;
|
||||
friend class QMacPixmapData;
|
||||
friend class QBitmap;
|
||||
friend class QPaintDevice;
|
||||
friend class QPainter;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,133 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Contact: http://www.qt.io/licensing/
|
||||
**
|
||||
** This file is part of the QtGui module of the Qt Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
** 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 Lesser General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
** General Public License version 2.1 or version 3 as published by the Free
|
||||
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||
** following information to ensure the GNU Lesser General Public License
|
||||
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
**
|
||||
** As a special exception, The Qt Company gives you certain additional
|
||||
** rights. These rights are described in The Qt Company LGPL Exception
|
||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
**
|
||||
** GNU General Public License Usage
|
||||
** Alternatively, this file may be used under the terms of the GNU
|
||||
** General Public License version 3.0 as published by the Free Software
|
||||
** Foundation and appearing in the file LICENSE.GPL included in the
|
||||
** packaging of this file. Please review the following information to
|
||||
** ensure the GNU General Public License version 3.0 requirements will be
|
||||
** met: http://www.gnu.org/copyleft/gpl.html.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QPIXMAP_MAC_P_H
|
||||
#define QPIXMAP_MAC_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtGui/qpixmapdata_p.h>
|
||||
#include <QtGui/qt_mac_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QMacPixmapData : public QPixmapData
|
||||
{
|
||||
public:
|
||||
QMacPixmapData(PixelType type);
|
||||
~QMacPixmapData();
|
||||
|
||||
QPixmapData *createCompatiblePixmapData() const;
|
||||
|
||||
void resize(int width, int height);
|
||||
void fromImage(const QImage &image, Qt::ImageConversionFlags flags);
|
||||
void copy(const QPixmapData *data, const QRect &rect);
|
||||
bool scroll(int dx, int dy, const QRect &rect);
|
||||
|
||||
int metric(QPaintDevice::PaintDeviceMetric metric) const;
|
||||
void fill(const QColor &color);
|
||||
QBitmap mask() const;
|
||||
void setMask(const QBitmap &mask);
|
||||
bool hasAlphaChannel() const;
|
||||
// QPixmap transformed(const QTransform &matrix,
|
||||
// Qt::TransformationMode mode) const;
|
||||
void setAlphaChannel(const QPixmap &alphaChannel);
|
||||
QPixmap alphaChannel() const;
|
||||
QImage toImage() const;
|
||||
QPaintEngine* paintEngine() const;
|
||||
|
||||
private:
|
||||
|
||||
uint has_alpha : 1, has_mask : 1, uninit : 1;
|
||||
|
||||
void macSetHasAlpha(bool b);
|
||||
void macGetAlphaChannel(QMacPixmapData *, bool asMask) const;
|
||||
void macSetAlphaChannel(const QMacPixmapData *, bool asMask);
|
||||
void macCreateCGImageRef();
|
||||
void macCreatePixels();
|
||||
void macReleaseCGImageRef();
|
||||
/*
|
||||
pixels stores the pixmap data. pixelsToFree is either 0 or some memory
|
||||
block that was bound to a CGImageRef and released, and for which the
|
||||
release callback has been called. There are two uses to pixelsToFree:
|
||||
|
||||
1. If pixels == pixelsToFree, then we know that the CGImageRef is done\
|
||||
with the data and we can modify pixels without breaking CGImageRef's
|
||||
mutability invariant.
|
||||
|
||||
2. If pixels != pixelsToFree and pixelsToFree != 0, then we can reuse
|
||||
pixelsToFree later on instead of malloc'ing memory.
|
||||
*/
|
||||
quint32 *pixels;
|
||||
uint pixelsSize;
|
||||
quint32 *pixelsToFree;
|
||||
uint bytesPerRow;
|
||||
QRectF cg_mask_rect;
|
||||
CGImageRef cg_data, cg_dataBeingReleased, cg_mask;
|
||||
static QSet<QMacPixmapData*> validDataPointers;
|
||||
|
||||
QPaintEngine *pengine;
|
||||
|
||||
friend class QPixmap;
|
||||
friend class QRasterBuffer;
|
||||
friend class QRasterPaintEngine;
|
||||
friend class QCoreGraphicsPaintEngine;
|
||||
friend CGImageRef qt_mac_create_imagemask(const QPixmap&, const QRectF&);
|
||||
friend quint32 *qt_mac_pixmap_get_base(const QPixmap*);
|
||||
friend int qt_mac_pixmap_get_bytes_per_line(const QPixmap*);
|
||||
friend void qt_mac_cgimage_data_free(void *, const void*, size_t);
|
||||
friend IconRef qt_mac_create_iconref(const QPixmap&);
|
||||
friend CGContextRef qt_mac_cg_context(const QPaintDevice*);
|
||||
friend QColor qcolorForThemeTextColor(ThemeTextColor themeColor);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QPIXMAP_MAC_P_H
|
|
@ -69,9 +69,7 @@ public:
|
|||
// Must match QPixmap::Type
|
||||
PixmapType, BitmapType
|
||||
};
|
||||
enum ClassId { RasterClass, X11Class, MacClass,
|
||||
OpenGLClass,
|
||||
CustomClass = 1024 };
|
||||
enum ClassId { RasterClass, X11Class, OpenGLClass };
|
||||
|
||||
QPixmapData(PixelType pixelType, int classId);
|
||||
virtual ~QPixmapData();
|
||||
|
|
|
@ -732,18 +732,6 @@ void QApplicationPrivate::construct(
|
|||
if (graphics_system_name.isEmpty())
|
||||
graphics_system_name = QString::fromLocal8Bit(qgetenv("QT_GRAPHICSSYSTEM"));
|
||||
|
||||
#if defined(Q_WS_X11) && !defined(QT_NO_EGL)
|
||||
if (graphics_system_name.isEmpty()) {
|
||||
bool linksWithMeeGoTouch = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libmeegotouchcore"));
|
||||
bool linksWithMeeGoGraphicsSystemHelper = dl_iterate_phdr(qt_matchLibraryName, const_cast<char *>("libQtMeeGoGraphicsSystemHelper"));
|
||||
|
||||
if (linksWithMeeGoTouch && !linksWithMeeGoGraphicsSystemHelper) {
|
||||
qWarning("Running non-meego graphics system enabled MeeGo touch, forcing native graphicssystem\n");
|
||||
graphics_system_name = QLatin1String("native");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Must be called before initialize()
|
||||
qt_init(this, qt_appType
|
||||
#ifdef Q_WS_X11
|
||||
|
@ -1496,8 +1484,8 @@ QStyle* QApplication::setStyle(const QString& style)
|
|||
\since 4.5
|
||||
|
||||
Sets the default graphics backend to \a system, which will be used for
|
||||
on-screen widgets and QPixmaps. The available systems are \c{"native"},
|
||||
\c{"raster"} and \c{"opengl"}.
|
||||
on-screen widgets and QPixmaps. The available systems are \c{"raster"}
|
||||
and \c{"opengl"}.
|
||||
|
||||
There are several ways to set the graphics backend, in order of decreasing
|
||||
precedence:
|
||||
|
@ -1675,9 +1663,7 @@ void QApplicationPrivate::setPalette_helper(const QPalette &palette, const char*
|
|||
the "color", "background-color", "selection-color",
|
||||
"selection-background-color" and "alternate-background-color".
|
||||
|
||||
\note Some styles do not use the palette for all drawing, for instance, if
|
||||
they make use of native theme engines. This is the case for the Windows XP,
|
||||
Windows Vista, and Mac OS X styles.
|
||||
\note Some styles do not use the palette for all drawing.
|
||||
|
||||
\sa QWidget::setPalette(), palette(), QStyle::polish()
|
||||
*/
|
||||
|
|
|
@ -41,36 +41,12 @@
|
|||
|
||||
#include "qgraphicssystem_p.h"
|
||||
|
||||
#ifdef Q_WS_X11
|
||||
# include <qpixmap_x11_p.h>
|
||||
#endif
|
||||
#if defined(Q_WS_WIN)
|
||||
# include <qpixmap_raster_p.h>
|
||||
#endif
|
||||
#ifdef Q_WS_MAC
|
||||
# include <qpixmap_mac_p.h>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QGraphicsSystem::~QGraphicsSystem()
|
||||
{
|
||||
}
|
||||
|
||||
QPixmapData *QGraphicsSystem::createDefaultPixmapData(QPixmapData::PixelType type)
|
||||
{
|
||||
#if defined(Q_WS_X11)
|
||||
return new QX11PixmapData(type);
|
||||
#elif defined(Q_WS_WIN)
|
||||
return new QRasterPixmapData(type);
|
||||
#elif defined(Q_WS_MAC)
|
||||
return new QMacPixmapData(type);
|
||||
#else
|
||||
#error QGraphicsSystem::createDefaultPixmapData() not implemented
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
QPixmapData *QGraphicsSystem::createPixmapData(QPixmapData *origin) const
|
||||
{
|
||||
return createPixmapData(origin->pixelType());
|
||||
|
|
|
@ -53,8 +53,13 @@
|
|||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qpixmapdata_p.h"
|
||||
#include "qwindowsurface_p.h"
|
||||
#if defined(Q_WS_X11) || defined(Q_WS_WIN) || defined(Q_WS_MAC)
|
||||
# include <qpixmap_raster_p.h>
|
||||
#else
|
||||
#error QGraphicsSystem::createDefaultPixmapData() not implemented
|
||||
#endif
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
@ -67,9 +72,8 @@ public:
|
|||
|
||||
virtual ~QGraphicsSystem();
|
||||
|
||||
//### Remove this & change qpixmap.cpp & qbitmap.cpp once every platform is gaurenteed
|
||||
// to have a graphics system.
|
||||
static QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type);
|
||||
static inline QPixmapData *createDefaultPixmapData(QPixmapData::PixelType type)
|
||||
{ return new QRasterPixmapData(type); };
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -72,7 +72,7 @@ QGraphicsSystem *QGraphicsSystemFactory::create(const QString& key)
|
|||
|
||||
if (system == QLatin1String("raster"))
|
||||
return new QRasterGraphicsSystem;
|
||||
else if (system.isEmpty() || system == QLatin1String("native"))
|
||||
else if (system.isEmpty())
|
||||
return 0;
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
|
|
|
@ -122,15 +122,7 @@ Q_GUI_EXPORT CGContextRef qt_mac_cg_context(const QPaintDevice *pdev)
|
|||
|
||||
// It would make sense to put this into a mac #ifdef'ed
|
||||
// virtual function in the QPixmapData at some point
|
||||
if (pm->data->classId() == QPixmapData::MacClass) {
|
||||
const QMacPixmapData *pmData = static_cast<const QMacPixmapData*>(pm->data.data());
|
||||
ret = CGBitmapContextCreate(pmData->pixels, pmData->w, pmData->h,
|
||||
8, pmData->bytesPerRow, colorspace,
|
||||
flags);
|
||||
if(!ret)
|
||||
qWarning("QPaintDevice: Unable to create context for pixmap (%d/%d/%d)",
|
||||
pmData->w, pmData->h, (pmData->bytesPerRow * pmData->h));
|
||||
} else if (pm->data->classId() == QPixmapData::RasterClass) {
|
||||
if (pm->data->classId() == QPixmapData::RasterClass) {
|
||||
QImage *image = pm->data->buffer();
|
||||
ret = CGBitmapContextCreate(image->bits(), image->width(), image->height(),
|
||||
8, image->bytesPerLine(), colorspace, flags);
|
||||
|
|
Loading…
Add table
Reference in a new issue