File indexing completed on 2024-04-28 04:32:45

0001 /*
0002     SPDX-FileCopyrightText: 2006 Tobias Koenig <tokoe@kde.org>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #ifndef _OKULAR_ROTATIONJOB_P_H_
0008 #define _OKULAR_ROTATIONJOB_P_H_
0009 
0010 #include <QImage>
0011 #include <QTransform>
0012 
0013 #include <threadweaver/job.h>
0014 #include <threadweaver/qobjectdecorator.h>
0015 
0016 #include "core/area.h"
0017 #include "core/global.h"
0018 
0019 namespace Okular
0020 {
0021 class DocumentObserver;
0022 class PagePrivate;
0023 
0024 class RotationJobInternal : public ThreadWeaver::Job
0025 {
0026     friend class RotationJob;
0027 
0028 public:
0029     QImage image() const;
0030     Rotation rotation() const;
0031     NormalizedRect rect() const;
0032 
0033     RotationJobInternal(const RotationJobInternal &) = delete;
0034     RotationJobInternal &operator=(const RotationJobInternal &) = delete;
0035 
0036 protected:
0037     void run(ThreadWeaver::JobPointer self, ThreadWeaver::Thread *thread) override;
0038 
0039 private:
0040     RotationJobInternal(const QImage &image, Rotation oldRotation, Rotation newRotation);
0041 
0042     const QImage mImage;
0043     Rotation mOldRotation;
0044     Rotation mNewRotation;
0045     QImage mRotatedImage;
0046 };
0047 
0048 class RotationJob : public ThreadWeaver::QObjectDecorator
0049 {
0050     Q_OBJECT
0051 public:
0052     RotationJob(const QImage &image, Rotation oldRotation, Rotation newRotation, DocumentObserver *observer);
0053 
0054     void setPage(PagePrivate *pd);
0055     void setRect(const NormalizedRect &rect);
0056     void setIsPartialUpdate(bool partialUpdate);
0057 
0058     QImage image() const
0059     {
0060         return static_cast<const RotationJobInternal *>(job())->image();
0061     }
0062     Rotation rotation() const
0063     {
0064         return static_cast<const RotationJobInternal *>(job())->rotation();
0065     }
0066     DocumentObserver *observer() const;
0067     PagePrivate *page() const;
0068     NormalizedRect rect() const;
0069     bool isPartialUpdate() const;
0070 
0071     static QTransform rotationMatrix(Rotation from, Rotation to);
0072 
0073 private:
0074     DocumentObserver *mObserver;
0075     PagePrivate *m_pd;
0076     NormalizedRect mRect;
0077     bool mIsPartialUpdate;
0078 };
0079 
0080 }
0081 
0082 #endif