OSDN Git Service

remove redundant QPixmapData members
authorIvailo Monev <xakepa10@gmail.com>
Thu, 10 Nov 2022 15:50:36 +0000 (17:50 +0200)
committerIvailo Monev <xakepa10@gmail.com>
Thu, 10 Nov 2022 15:50:36 +0000 (17:50 +0200)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
src/gui/image/qpixmapdata.cpp
src/gui/image/qpixmapdata_p.h

index 9688893..8b64f6e 100644 (file)
@@ -39,11 +39,7 @@ QPixmapData *QPixmapData::create(int w, int h, PixelType type)
 
 
 QPixmapData::QPixmapData(PixelType pixelType)
-    : w(0),
-      h(0),
-      d(0),
-      is_null(true),
-      ref(0),
+    : ref(0),
       detach_no(0),
       type(pixelType),
       ser_no(0)
@@ -218,21 +214,21 @@ QPaintEngine* QPixmapData::paintEngine() const
 
 int QPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
 {
-    if (!image.d)
+    if (isNull())
         return 0;
 
     // override the image dpi with the screen dpi when rendering to a pixmap
     switch (metric) {
     case QPaintDevice::PdmWidth:
-        return w;
+        return width();
     case QPaintDevice::PdmHeight:
-        return h;
+        return height();
     case QPaintDevice::PdmWidthMM:
-        return qRound(image.d->width * 25.4 / QX11Info::appDpiX());
+        return qRound(width() * 25.4 / QX11Info::appDpiX());
     case QPaintDevice::PdmHeightMM:
-        return qRound(image.d->height * 25.4 / QX11Info::appDpiY());
+        return qRound(height() * 25.4 / QX11Info::appDpiY());
     case QPaintDevice::PdmNumColors:
-        if (image.d->depth == 1)
+        if (depth() == 1)
             return 2;
         return 0;
     case QPaintDevice::PdmDepth:
@@ -285,10 +281,6 @@ void QPixmapData::resize(int width, int height)
     }
 
     image = QImage(width, height, format);
-    w = width;
-    h = height;
-    d = image.depth();
-    is_null = (w <= 0 || h <= 0);
 
     if (pixelType() == BitmapType && !image.isNull()) {
         image.setColorTable(monoColorTable());
@@ -318,15 +310,6 @@ void QPixmapData::fromImage(const QImage &sourceImage,
 
     image = sourceImage.convertToFormat(format);
 
-    if (image.d) {
-        w = image.d->width;
-        h = image.d->height;
-        d = image.d->depth;
-    } else {
-        w = h = d = 0;
-    }
-    is_null = (w <= 0 || h <= 0);
-
     setSerialNumber(image.cacheKey()  >> 32);
 }
 
index ace28cc..c0eb20a 100644 (file)
@@ -86,10 +86,10 @@ public:
 
     QImage* buffer();
 
-    inline int width() const { return w; }
-    inline int height() const { return h; }
-    inline int depth() const { return d; }
-    inline bool isNull() const { return is_null; }
+    inline int width() const { return image.width(); }
+    inline int height() const { return image.height(); }
+    inline int depth() const { return image.depth(); }
+    inline bool isNull() const { return image.isNull(); }
     inline qint64 cacheKey() const {
         return ((static_cast<qint64>(ser_no) << 32)
                 | (static_cast<qint64>(detach_no)));
@@ -100,10 +100,6 @@ public:
 
 protected:
     void setSerialNumber(int serNo);
-    int w;
-    int h;
-    int d;
-    bool is_null;
 
 private:
     friend class QPixmap;