summaryrefslogtreecommitdiffstats
path: root/chalk/core/kis_transform_worker.h
blob: a48b85896edd9386519eb0d5599418207a1d06d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
 *  Copyright (c) 2004 Michael Thaler <michael.thaler@physik.tu-muenchen.de>
 *  Copyright (c) 2005 Casper Boemann <cbr@boemann.dk>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef KIS_TRANSFORM_WORKER_H_
#define KIS_TRANSFORM_WORKER_H_

#include "kis_types.h"
#include "kis_progress_subject.h"

class KisPaintDevice;
class KisProgressDisplayInterface;
class KisHLineIteratorPixel;
class KisVLineIteratorPixel;
class KisFilterStrategy;

class KisTransformWorker : public KisProgressSubject {
    typedef KisProgressSubject super;

public:
    KisTransformWorker(KisPaintDeviceSP dev, double  xscale, double  yscale,
        double  xshear, double  yshear, double rotation,
        TQ_INT32  xtranslate, TQ_INT32  ytranslate,
        KisProgressDisplayInterface *progress, KisFilterStrategy *filter, bool fixBorderAlpha=false);
    ~KisTransformWorker();

public:
    bool isCanceled() { return m_cancelRequested;};

    bool run();

private:    
    // XXX (BSAR): Why didn't we use the shared-pointer versions of the paint device classes?
    template <class T> void transformPass(KisPaintDevice *src, KisPaintDevice *dst, double xscale, double  shear, TQ_INT32 dx,   KisFilterStrategy *filterStrategy, bool fixBorderAlpha);
    
public:    
    void rotateNone(KisPaintDeviceSP src, KisPaintDeviceSP dst);
    void rotateRight90(KisPaintDeviceSP src, KisPaintDeviceSP dst);
    void rotateLeft90(KisPaintDeviceSP src, KisPaintDeviceSP dst);
    void rotate180(KisPaintDeviceSP src, KisPaintDeviceSP dst);

private:
    KisPaintDeviceSP m_dev;
    double  m_xscale, m_yscale;
    double  m_xshear, m_yshear, m_rotation;
    TQ_INT32  m_xtranslate, m_ytranslate;
    KisProgressDisplayInterface *m_progress;
    KisFilterStrategy *m_filter;
    // Implement KisProgressSubject
    bool m_cancelRequested;
    virtual void cancel() { m_cancelRequested = true; }
    TQ_INT32 m_progressTotalSteps;
    TQ_INT32 m_progressStep;
    TQ_INT32 m_progressScaler;
    TQ_INT32 m_lastProgressReport;
    bool m_fixBorderAlpha;
};


inline KisTransformWorker::~KisTransformWorker()
{
}

#endif // KIS_TRANSFORM_VISITOR_H_