kis_update_info.cpp 2.96 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 *  Copyright (c) 2010, Dmitry Kazakov <dimula73@gmail.com>
 *
 *  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.
 */
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
#include "kis_update_info.h"

/**
 * The connection in KisCanvas2 uses queued signals
 * with an argument of KisNodeSP type, so we should
 * register it beforehand
 */
struct KisUpdateInfoSPStaticRegistrar {
    KisUpdateInfoSPStaticRegistrar() {
        qRegisterMetaType<KisUpdateInfoSP>("KisUpdateInfoSP");
    }
};
static KisUpdateInfoSPStaticRegistrar __registrar;

KisUpdateInfo::KisUpdateInfo()
{
}

KisUpdateInfo::~KisUpdateInfo()
{
}

QRect KisUpdateInfo::dirtyViewportRect()
{
    return QRect();
}

45 46 47 48 49
bool KisUpdateInfo::canBeCompressed() const
{
    return true;
}

50 51 52
QRect KisPPUpdateInfo::dirtyViewportRect() {
    return viewportRect.toAlignedRect();
}
53

54 55 56
QRect KisPPUpdateInfo::dirtyImageRect() const {
    return dirtyImageRectVar;
}
57

58 59 60 61 62
int KisPPUpdateInfo::levelOfDetail() const
{
    return 0;
}

63 64
KisOpenGLUpdateInfo::KisOpenGLUpdateInfo()
    : m_levelOfDetail(0)
65 66 67
{
}

68 69
QRect KisOpenGLUpdateInfo::dirtyViewportRect() {
    qFatal("Not implemented yet!");
70
    return QRect();
71 72
}

73 74 75 76 77
void KisOpenGLUpdateInfo::assignDirtyImageRect(const QRect &rect)
{
    m_dirtyImageRect = rect;
}

78 79 80 81 82
void KisOpenGLUpdateInfo::assignLevelOfDetail(int lod)
{
    m_levelOfDetail = lod;
}

83 84 85 86 87
QRect KisOpenGLUpdateInfo::dirtyImageRect() const
{
    return m_dirtyImageRect;
}

88 89 90 91
int KisOpenGLUpdateInfo::levelOfDetail() const
{
    return m_levelOfDetail;
}
92 93 94 95 96 97 98 99 100 101 102 103

bool KisOpenGLUpdateInfo::tryMergeWith(const KisOpenGLUpdateInfo &rhs)
{
    if (m_levelOfDetail != rhs.m_levelOfDetail) return false;

    // TODO: that makes the algorithm of updates compressor incorrect!
    m_dirtyImageRect |= rhs.m_dirtyImageRect;

    tileList.append(rhs.tileList);

    return true;
}
104

105
KisMarkerUpdateInfo::KisMarkerUpdateInfo(KisMarkerUpdateInfo::Type type, const QRect &dirtyImageRect)
106 107 108 109 110
    : m_type(type),
      m_dirtyImageRect(dirtyImageRect)
{
}

111
KisMarkerUpdateInfo::Type KisMarkerUpdateInfo::type() const
112 113 114 115
{
    return m_type;
}

116
QRect KisMarkerUpdateInfo::dirtyImageRect() const
117 118 119 120
{
    return m_dirtyImageRect;
}

121
int KisMarkerUpdateInfo::levelOfDetail() const
122 123 124
{
    // return invalid level of detail to avoid merging the update info
    // with other updates
125
    return -1 - (int)m_type;
126
}
127 128 129 130 131

bool KisMarkerUpdateInfo::canBeCompressed() const
{
    return false;
}