[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/krita-testing-kazakov] krita: Implement a method of KisStroke which activates LOD mode
From: Dmitry Kazakov <dimula73 () gmail ! com>
Date: 2014-08-05 16:47:49
Message-ID: E1XEhtt-0000K8-L5 () scm ! kde ! org
[Download RAW message or body]
Git commit 17dbb0c90da2a79c53e6528efe590a8986d6fb27 by Dmitry Kazakov.
Committed on 05/08/2014 at 16:47.
Pushed by dkazakov into branch 'krita-testing-kazakov'.
Implement a method of KisStroke which activates LOD mode
M +9 -1 krita/image/kis_image.cc
M +7 -0 krita/image/kis_image.h
M +5 -0 krita/image/kis_stroke.cpp
M +1 -0 krita/image/kis_stroke.h
M +10 -0 krita/image/kis_stroke_strategy.cpp
M +3 -0 krita/image/kis_stroke_strategy.h
M +10 -1 krita/image/kis_strokes_queue.cpp
M +1 -0 krita/image/kis_strokes_queue.h
M +5 -0 krita/image/kis_update_scheduler.cpp
M +1 -0 krita/image/kis_update_scheduler.h
M +3 -0 krita/ui/kis_zoom_manager.cc
http://commits.kde.org/calligra/17dbb0c90da2a79c53e6528efe590a8986d6fb27
diff --git a/krita/image/kis_image.cc b/krita/image/kis_image.cc
index 60ce466..c14f4e3 100644
--- a/krita/image/kis_image.cc
+++ b/krita/image/kis_image.cc
@@ -112,6 +112,7 @@ public:
QList<KisLayerComposition*> compositions;
KisNodeSP isolatedRootNode;
bool wrapAroundModePermitted;
+ int currentLevelOfDetail;
KisNameServer *nserver;
@@ -152,6 +153,7 @@ KisImage::KisImage(KisUndoStore *undoStore, qint32 width, qint32 \
height, const K m_d->perspectiveGrid = 0;
m_d->scheduler = 0;
m_d->wrapAroundModePermitted = false;
+ m_d->currentLevelOfDetail = 0;
m_d->signalRouter = new KisImageSignalRouter(this);
@@ -1698,9 +1700,15 @@ bool KisImage::wrapAroundModeActive() const
m_d->scheduler->wrapAroundModeSupported();
}
+void KisImage::requestLevelOfDetail(int lod)
+{
+ m_d->currentLevelOfDetail = lod;
+}
+
int KisImage::currentLevelOfDetail() const
{
- return 0;
+ return m_d->scheduler &&
+ m_d->scheduler->levelOfDetailSupported() ? m_d->currentLevelOfDetail : 0;
}
void KisImage::notifyNodeCollpasedChanged()
diff --git a/krita/image/kis_image.h b/krita/image/kis_image.h
index eae0d05..df8383e 100644
--- a/krita/image/kis_image.h
+++ b/krita/image/kis_image.h
@@ -529,6 +529,13 @@ public:
int currentLevelOfDetail() const;
/**
+ * Notify KisImage which level of detail should be used in the
+ * lod-mode. Setting the mode does not guarantee the LOD to be
+ * used. It will be activated only when the stokes supports it.
+ */
+ void requestLevelOfDetail(int lod);
+
+ /**
* Notifies that the node collapsed state has changed
*/
void notifyNodeCollpasedChanged();
diff --git a/krita/image/kis_stroke.cpp b/krita/image/kis_stroke.cpp
index d9248f6..3bb2533 100644
--- a/krita/image/kis_stroke.cpp
+++ b/krita/image/kis_stroke.cpp
@@ -167,6 +167,11 @@ bool KisStroke::supportsWrapAroundMode() const
return m_strokeStrategy->supportsWrapAroundMode();
}
+bool KisStroke::supportsLevelOfDetail() const
+{
+ return m_strokeStrategy->supportsLevelOfDetail();
+}
+
bool KisStroke::prevJobSequential() const
{
return m_prevJobSequential;
diff --git a/krita/image/kis_stroke.h b/krita/image/kis_stroke.h
index 9880f6e..40b58cbf9 100644
--- a/krita/image/kis_stroke.h
+++ b/krita/image/kis_stroke.h
@@ -49,6 +49,7 @@ public:
bool isExclusive() const;
bool supportsWrapAroundMode() const;
+ bool supportsLevelOfDetail() const;
bool prevJobSequential() const;
bool nextJobSequential() const;
diff --git a/krita/image/kis_stroke_strategy.cpp \
b/krita/image/kis_stroke_strategy.cpp index 04becec..4876a80 100644
--- a/krita/image/kis_stroke_strategy.cpp
+++ b/krita/image/kis_stroke_strategy.cpp
@@ -80,6 +80,11 @@ bool KisStrokeStrategy::supportsWrapAroundMode() const
return m_supportsWrapAroundMode;
}
+bool KisStrokeStrategy::supportsLevelOfDetail() const
+{
+ return m_supportsLevelOfDetail;
+}
+
bool KisStrokeStrategy::needsIndirectPainting() const
{
return m_needsIndirectPainting;
@@ -110,6 +115,11 @@ void KisStrokeStrategy::setSupportsWrapAroundMode(bool value)
m_supportsWrapAroundMode = value;
}
+void KisStrokeStrategy::setSupportsLevelOfDetail(bool value)
+{
+ m_supportsLevelOfDetail = value;
+}
+
void KisStrokeStrategy::setNeedsIndirectPainting(bool value)
{
m_needsIndirectPainting = value;
diff --git a/krita/image/kis_stroke_strategy.h b/krita/image/kis_stroke_strategy.h
index b44d782..4adf33c 100644
--- a/krita/image/kis_stroke_strategy.h
+++ b/krita/image/kis_stroke_strategy.h
@@ -44,6 +44,7 @@ public:
bool isExclusive() const;
bool supportsWrapAroundMode() const;
+ bool supportsLevelOfDetail() const;
bool needsIndirectPainting() const;
QString indirectPaintingCompositeOp() const;
@@ -71,12 +72,14 @@ protected:
void setExclusive(bool value);
void setSupportsWrapAroundMode(bool value);
+ void setSupportsLevelOfDetail(bool value);
void setNeedsIndirectPainting(bool value);
void setIndirectPaintingCompositeOp(const QString &id);
private:
bool m_exclusive;
bool m_supportsWrapAroundMode;
+ bool m_supportsLevelOfDetail;
bool m_needsIndirectPainting;
QString m_indirectPaintingCompositeOp;
diff --git a/krita/image/kis_strokes_queue.cpp b/krita/image/kis_strokes_queue.cpp
index 3414809..a7102f4 100644
--- a/krita/image/kis_strokes_queue.cpp
+++ b/krita/image/kis_strokes_queue.cpp
@@ -28,12 +28,14 @@ struct KisStrokesQueue::Private {
Private()
: openedStrokesCounter(0),
needsExclusiveAccess(false),
- wrapAroundModeSupported(false) {}
+ wrapAroundModeSupported(false),
+ levelOfDetailSupported(false) {}
QQueue<KisStrokeSP> strokesQueue;
int openedStrokesCounter;
bool needsExclusiveAccess;
bool wrapAroundModeSupported;
+ bool levelOfDetailSupported;
QMutex mutex;
};
@@ -146,6 +148,11 @@ bool KisStrokesQueue::wrapAroundModeSupported() const
return m_d->wrapAroundModeSupported;
}
+bool KisStrokesQueue::levelOfDetailSupported() const
+{
+ return m_d->levelOfDetailSupported;
+}
+
bool KisStrokesQueue::isEmpty() const
{
QMutexLocker locker(&m_d->mutex);
@@ -217,6 +224,7 @@ bool KisStrokesQueue::checkStrokeState(bool hasStrokeJobsRunning)
if(!stroke->isInitialized() && stroke->hasJobs()) {
m_d->needsExclusiveAccess = stroke->isExclusive();
m_d->wrapAroundModeSupported = stroke->supportsWrapAroundMode();
+ m_d->levelOfDetailSupported = stroke->supportsLevelOfDetail();
result = true;
}
else if(stroke->hasJobs()){
@@ -226,6 +234,7 @@ bool KisStrokesQueue::checkStrokeState(bool hasStrokeJobsRunning)
m_d->strokesQueue.dequeue(); // deleted by shared pointer
m_d->needsExclusiveAccess = false;
m_d->wrapAroundModeSupported = false;
+ m_d->levelOfDetailSupported = false;
if(!m_d->strokesQueue.isEmpty()) {
result = checkStrokeState(false);
diff --git a/krita/image/kis_strokes_queue.h b/krita/image/kis_strokes_queue.h
index 46c53ff..196b98e 100644
--- a/krita/image/kis_strokes_queue.h
+++ b/krita/image/kis_strokes_queue.h
@@ -50,6 +50,7 @@ public:
bool hasOpenedStrokes() const;
bool wrapAroundModeSupported() const;
+ bool levelOfDetailSupported() const;
private:
bool processOneJob(KisUpdaterContext &updaterContext, bool externalJobsPending);
diff --git a/krita/image/kis_update_scheduler.cpp \
b/krita/image/kis_update_scheduler.cpp index 087e478..fdeb49c 100644
--- a/krita/image/kis_update_scheduler.cpp
+++ b/krita/image/kis_update_scheduler.cpp
@@ -214,6 +214,11 @@ bool KisUpdateScheduler::wrapAroundModeSupported() const
return m_d->strokesQueue->wrapAroundModeSupported();
}
+bool KisUpdateScheduler::levelOfDetailSupported() const
+{
+ return m_d->strokesQueue->levelOfDetailSupported();
+}
+
void KisUpdateScheduler::updateSettings()
{
if(m_d->updatesQueue) {
diff --git a/krita/image/kis_update_scheduler.h b/krita/image/kis_update_scheduler.h
index c04b838..811f37a 100644
--- a/krita/image/kis_update_scheduler.h
+++ b/krita/image/kis_update_scheduler.h
@@ -145,6 +145,7 @@ public:
bool tryCancelCurrentStrokeAsync();
bool wrapAroundModeSupported() const;
+ bool levelOfDetailSupported() const;
protected:
// Trivial constructor for testing support
diff --git a/krita/ui/kis_zoom_manager.cc b/krita/ui/kis_zoom_manager.cc
index 6d580ca..a84ec13 100644
--- a/krita/ui/kis_zoom_manager.cc
+++ b/krita/ui/kis_zoom_manager.cc
@@ -239,6 +239,9 @@ void KisZoomManager::slotZoomChanged(KoZoomMode::Mode mode, qreal \
zoom)
m_view->canvasBase()->coordinatesConverter()->imageScale(&scaleX, &scaleY);
KIS_ASSERT_RECOVER_NOOP(scaleX == scaleY && "Zoom is not isotropic!");
m_view->canvasBase()->resourceManager()->setResource(KisCanvasResourceProvider::EffectiveZoom, \
scaleX); +
+ int lod = qFloor(log2(1.0 / scaleX));
+ m_view->image()->requestLevelOfDetail(lod);
}
void KisZoomManager::slotScrollAreaSizeChanged()
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic