File indexing completed on 2025-02-23 04:09:02
0001 /* 0002 * SPDX-FileCopyrightText: 2010 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #include "kis_update_info.h" 0007 #include <KisStaticInitializer.h> 0008 0009 /** 0010 * The connection in KisCanvas2 uses queued signals 0011 * with an argument of KisNodeSP type, so we should 0012 * register it beforehand 0013 */ 0014 KIS_DECLARE_STATIC_INITIALIZER { 0015 qRegisterMetaType<KisUpdateInfoSP>("KisUpdateInfoSP"); 0016 } 0017 0018 KisUpdateInfo::KisUpdateInfo() 0019 { 0020 } 0021 0022 KisUpdateInfo::~KisUpdateInfo() 0023 { 0024 } 0025 0026 QRect KisUpdateInfo::dirtyViewportRect() 0027 { 0028 return QRect(); 0029 } 0030 0031 bool KisUpdateInfo::canBeCompressed() const 0032 { 0033 return true; 0034 } 0035 0036 QRect KisPPUpdateInfo::dirtyViewportRect() { 0037 return viewportRect.toAlignedRect(); 0038 } 0039 0040 QRect KisPPUpdateInfo::dirtyImageRect() const { 0041 return dirtyImageRectVar; 0042 } 0043 0044 int KisPPUpdateInfo::levelOfDetail() const 0045 { 0046 return 0; 0047 } 0048 0049 KisOpenGLUpdateInfo::KisOpenGLUpdateInfo() 0050 : m_levelOfDetail(0) 0051 { 0052 } 0053 0054 QRect KisOpenGLUpdateInfo::dirtyViewportRect() { 0055 qFatal("Not implemented yet!"); 0056 return QRect(); 0057 } 0058 0059 void KisOpenGLUpdateInfo::assignDirtyImageRect(const QRect &rect) 0060 { 0061 m_dirtyImageRect = rect; 0062 } 0063 0064 void KisOpenGLUpdateInfo::assignLevelOfDetail(int lod) 0065 { 0066 m_levelOfDetail = lod; 0067 } 0068 0069 QRect KisOpenGLUpdateInfo::dirtyImageRect() const 0070 { 0071 return m_dirtyImageRect; 0072 } 0073 0074 int KisOpenGLUpdateInfo::levelOfDetail() const 0075 { 0076 return m_levelOfDetail; 0077 } 0078 0079 bool KisOpenGLUpdateInfo::tryMergeWith(const KisOpenGLUpdateInfo &rhs) 0080 { 0081 if (m_levelOfDetail != rhs.m_levelOfDetail) return false; 0082 0083 // TODO: that makes the algorithm of updates compressor incorrect! 0084 m_dirtyImageRect |= rhs.m_dirtyImageRect; 0085 0086 tileList.append(rhs.tileList); 0087 0088 return true; 0089 } 0090 0091 KisMarkerUpdateInfo::KisMarkerUpdateInfo(KisMarkerUpdateInfo::Type type, const QRect &dirtyImageRect) 0092 : m_type(type), 0093 m_dirtyImageRect(dirtyImageRect) 0094 { 0095 } 0096 0097 KisMarkerUpdateInfo::Type KisMarkerUpdateInfo::type() const 0098 { 0099 return m_type; 0100 } 0101 0102 QRect KisMarkerUpdateInfo::dirtyImageRect() const 0103 { 0104 return m_dirtyImageRect; 0105 } 0106 0107 int KisMarkerUpdateInfo::levelOfDetail() const 0108 { 0109 // return invalid level of detail to avoid merging the update info 0110 // with other updates 0111 return -1 - (int)m_type; 0112 } 0113 0114 bool KisMarkerUpdateInfo::canBeCompressed() const 0115 { 0116 return false; 0117 }