|
Krita Source Code Documentation
|
#include <kis_shape_layer_canvas.h>
Inheritance diagram for KisShapeLayerCanvas:Public Member Functions | |
| void | forceRepaint () override |
| void | forceRepaintWithHiddenAreas () override |
| bool | hasPendingUpdates () const override |
| KisShapeLayerCanvas (const KisShapeLayerCanvas &rhs, KisShapeLayer *parent) | |
| KisShapeLayerCanvas (const KoColorSpace *cs, KisDefaultBoundsBaseSP defaultBounds, KisShapeLayer *parent) | |
| KisPaintDeviceSP | projection () const override |
| void | rerenderAfterBeingInvisible () override |
| void | resetCache (const KoColorSpace *colorSpace=0) override |
| void | setImage (KisImageWSP image) override |
| void | setProjection (KisPaintDeviceSP projection) |
| This canvas won't render onto a widget, but a projection. | |
| void | updateCanvas (const QRectF &rc) override |
| void | updateCanvas (const QVector< QRectF > ®ion) |
| ~KisShapeLayerCanvas () override | |
Public Member Functions inherited from KisShapeLayerCanvasBase | |
| void | addCommand (KUndo2Command *command) override |
| const QWidget * | canvasWidget () const override |
| QWidget * | canvasWidget () override |
| void | gridSize (QPointF *offset, QSizeF *spacing) const override |
| bool | hasChangedWhileBeingInvisible () |
| KisShapeLayerCanvasBase (const KisShapeLayerCanvasBase &rhs, KisShapeLayer *parent) | |
| KisShapeLayerCanvasBase (KisShapeLayer *parent) | |
| void | prepareForDestroying () |
| KoSelectedShapesProxy * | selectedShapesProxy () const override |
| selectedShapesProxy() is a special interface for keeping a persistent connections to selectionChanged() and selectionContentChanged() signals. While shapeManager() can change throughout the life time of the canvas, selectedShapesProxy() is guaranteed to stay the same. | |
| void | setCursor (const QCursor &) override |
| KoShapeManager * | shapeManager () const override |
| bool | snapToGrid () const override |
| KoToolProxy * | toolProxy () const override |
| KoUnit | unit () const override |
| const KoViewConverter * | viewConverter () const override |
| KoViewConverter * | viewConverter () override |
Public Member Functions inherited from KoCanvasBase | |
| KoCanvasController * | canvasController () const |
| virtual bool | canvasIsOpenGL () const |
| virtual void | clipToDocument (const KoShape *shape, QPointF &move) const |
| virtual void | disconnectCanvasObserver (QObject *object) |
| virtual QPoint | documentOrigin () const |
| KoCanvasBase (KoShapeControllerBase *shapeController, KoCanvasResourceProvider *sharedResourceManager=0) | |
| Private () | |
| KoCanvasResourceProvider * | resourceManager () const |
| void | setCanvasController (KoCanvasController *controller) |
| called by KoCanvasController to set the controller that handles this canvas. | |
| KoShapeController * | shapeController () const |
| KoSnapGuide * | snapGuide () const |
| virtual QPointF | viewToDocument (const QPointF &viewPoint) const |
| ~KoCanvasBase () override | |
| ~Private () | |
Private Member Functions | |
| void | repaint () |
| void | slotImageSizeChanged () |
| void | slotStartAsyncRepaint () |
Private Attributes | |
| KisThreadSafeSignalCompressor | m_asyncUpdateSignalCompressor |
| QRect | m_cachedImageRect |
| QRegion | m_dirtyRegion |
| QMutex | m_dirtyRegionMutex |
| bool | m_forceUpdateHiddenAreasOnly = false |
| volatile bool | m_hasUpdateInCompressor = false |
| bool | m_hasUpdateOnSetImage = false |
| KisImageWSP | m_image |
| KisSignalAutoConnectionsStore | m_imageConnections |
| KoShapeManager::PaintJobsOrder | m_paintJobsOrder |
| KisShapeLayer * | m_parentLayer {0} |
| KisPaintDeviceSP | m_projection |
| KisSafeBlockingQueueConnectionProxy< void > | m_safeForcedConnection |
Friends | |
| class | KisRepaintShapeLayerLayerJob |
Additional Inherited Members | |
Public Attributes inherited from KoCanvasBase | |
| KoCanvasController * | controller |
| bool | isResourceManagerShared |
| QPointer< KoCanvasResourceProvider > | resourceManager |
| QPointer< KoShapeController > | shapeController |
| KoSnapGuide * | snapGuide |
Protected Attributes inherited from KisShapeLayerCanvasBase | |
| bool | m_hasChangedWhileBeingInvisible {false} |
| bool | m_isDestroying {false} |
| QScopedPointer< KoSelectedShapesProxy > | m_selectedShapesProxy |
| QScopedPointer< KoShapeManager > | m_shapeManager |
| KisImageViewConverter | m_viewConverter |
KisShapeLayerCanvas is a special canvas implementation that Krita uses for non-krita shapes to request updates on.
Do NOT give this canvas to tools or to the KoCanvasController, it's not made for that.
Definition at line 82 of file kis_shape_layer_canvas.h.
| KisShapeLayerCanvas::KisShapeLayerCanvas | ( | const KoColorSpace * | cs, |
| KisDefaultBoundsBaseSP | defaultBounds, | ||
| KisShapeLayer * | parent ) |
The layer should also add itself to its own shape manager, so that the canvas would track its changes/transformations
Definition at line 136 of file kis_shape_layer_canvas.cpp.
References KoShapeManager::AddWithoutRepaint, connect(), m_asyncUpdateSignalCompressor, KisShapeLayerCanvasBase::m_shapeManager, and slotStartAsyncRepaint().
| KisShapeLayerCanvas::KisShapeLayerCanvas | ( | const KisShapeLayerCanvas & | rhs, |
| KisShapeLayer * | parent ) |
The layer should also add itself to its own shape manager, so that the canvas would track its changes/transformations
Definition at line 153 of file kis_shape_layer_canvas.cpp.
References KoShapeManager::AddWithoutRepaint, connect(), m_asyncUpdateSignalCompressor, m_projection, KisShapeLayerCanvasBase::m_shapeManager, KisPaintDevice::setParentNode(), and slotStartAsyncRepaint().
|
override |
Definition at line 171 of file kis_shape_layer_canvas.cpp.
References m_parentLayer, and KisShapeLayerCanvasBase::m_shapeManager.
|
overridevirtual |
WARNING! Although forceRepaint() may be called from different threads, it is not entirely safe. If the user plays with shapes at the same time (vector tools are not ported to strokes yet), the shapes my be accessed from two different places at the same time, which will cause a crash.
The only real solution to this is to port vector tools to strokes framework.
Implements KisShapeLayerCanvasBase.
Definition at line 498 of file kis_shape_layer_canvas.cpp.
References hasPendingUpdates(), m_asyncUpdateSignalCompressor, m_safeForcedConnection, KisSafeBlockingQueueConnectionProxy< void >::start(), and KisThreadSafeSignalCompressor::stop().
|
overridevirtual |
Reimplemented from KisShapeLayerCanvasBase.
Definition at line 520 of file kis_shape_layer_canvas.cpp.
References KisBaseNode::image, KIS_SAFE_ASSERT_RECOVER_RETURN, m_asyncUpdateSignalCompressor, m_dirtyRegionMutex, m_forceUpdateHiddenAreasOnly, m_image, KisShapeLayerCanvasBase::m_isDestroying, m_parentLayer, m_safeForcedConnection, KisSafeBlockingQueueConnectionProxy< void >::start(), and KisThreadSafeSignalCompressor::stop().
|
overridevirtual |
Implements KisShapeLayerCanvasBase.
Definition at line 515 of file kis_shape_layer_canvas.cpp.
References m_hasUpdateInCompressor.
|
overridevirtual |
Implements KisShapeLayerCanvasBase.
Definition at line 181 of file kis_shape_layer_canvas.cpp.
References m_projection.
|
private |
Sometimes two update jobs might not override and the second one will arrive right after the first one
Definition at line 402 of file kis_shape_layer_canvas.cpp.
References KisShapeLayer::antialiased(), KisPaintDevice::clear(), KisPaintDevice::colorSpace(), KoColorSpace::convertPixelsTo(), KoColorSpaceRegistry::instance(), KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), KoShapeManager::PaintJob::isEmpty(), KoShapeManager::PaintJobsOrder::isEmpty(), KoShapeManager::PaintJobsOrder::jobs, KIS_SAFE_ASSERT_RECOVER, m_dirtyRegionMutex, KisShapeLayerCanvasBase::m_hasChangedWhileBeingInvisible, m_paintJobsOrder, m_parentLayer, m_projection, KisShapeLayerCanvasBase::m_shapeManager, KisPaintDevice::pixelSize(), KisPaintDevice::purgeDefaultPixels(), KoColorSpaceRegistry::rgb8(), KisNode::setDirty(), KoShapeManager::PaintJobsOrder::uncroppedViewUpdateRect, KisShapeLayerCanvasBase::viewConverter(), KoShapeManager::PaintJob::viewUpdateRect, KisShapeLayer::visible(), and KisPaintDevice::writeBytes().
|
overridevirtual |
Implements KisShapeLayerCanvasBase.
Definition at line 546 of file kis_shape_layer_canvas.cpp.
References KIS_SAFE_ASSERT_RECOVER_RETURN, KisShapeLayerCanvasBase::m_hasChangedWhileBeingInvisible, m_parentLayer, resetCache(), and KisShapeLayer::visible().
|
overridevirtual |
Implements KisShapeLayerCanvasBase.
Definition at line 535 of file kis_shape_layer_canvas.cpp.
References KisPaintDevice::clear(), m_projection, KisShapeLayerCanvasBase::m_shapeManager, and KoShape::update().
|
overridevirtual |
Reimplemented from KisShapeLayerCanvasBase.
Definition at line 186 of file kis_shape_layer_canvas.cpp.
References KisSignalAutoConnectionsStore::addUniqueConnection(), KisImage::bounds(), KisSignalAutoConnectionsStore::clear(), KisImage::colorSpace(), KisPaintDevice::convertTo(), m_cachedImageRect, m_hasUpdateOnSetImage, m_image, m_imageConnections, m_projection, KisPaintDevice::setDefaultBounds(), KisShapeLayerCanvasBase::setImage(), slotImageSizeChanged(), and updateCanvas().
| void KisShapeLayerCanvas::setProjection | ( | KisPaintDeviceSP | projection | ) |
This canvas won't render onto a widget, but a projection.
Definition at line 176 of file kis_shape_layer_canvas.cpp.
References m_projection, and projection().
|
private |
Definition at line 384 of file kis_shape_layer_canvas.cpp.
References KisImage::bounds(), m_cachedImageRect, m_image, updateCanvas(), KisShapeLayerCanvasBase::viewConverter(), and KoCanvasBase::viewToDocument().
|
private |
Don't try to start a regeneration stroke while image is locked. It may happen on loading, when all necessary conversions are not yet finished.
Since we are going to override the previous jobs, we should fetch all the area covered by it. Otherwise we'll get dirty leftovers of the layer on the projection
Vector shapes are not thread-safe against concurrent read-writes, so we need to utilize rather complicated policy on accessing them:
1) All shape writes happen in GUI thread (right in the tools) 2) No concurrent reads from the shapes may happen in other threads while the user is modifying them.
That is why our shape rendering code is split into two parts:
1) First we just fetch a shallow copy of the shapes of the layer (it takes about 1ms for complicated vector layers) and pack them into KoShapeManager::PaintJobsList jobs. It happens here, in slotStartAsyncRepaint(), which runs in the GUI thread. It guarantees that no one is accessing the shapes during the copy operation.
2) The rendering itself happens in the worker thread in repaint(). But repaint() doesn't access original shapes anymore. It accesses only they shallow copies, which means that there is no concurrent access to anything (*).
(*) "no concurrent access to anything" is a rather fragile term :) There will still be concurrent access to it, on detaching... But(!), when detaching, the original data is kept unchanged, so "it should be safe enough"(c). Especially if we guarantee that rendering thread may not cause a detach (?), and the detach can happen only from a single GUI thread.
Definition at line 275 of file kis_shape_layer_canvas.cpp.
References KisImage::addSpontaneousJob(), KoShape::boundingRect(), KisImage::bounds(), KoShapeManager::PaintJobsOrder::clear(), KoViewConverter::documentToView(), KoShapeManager::PaintJob::docUpdateRect, KisBaseNode::image, KoShapeManager::PaintJobsOrder::isEmpty(), KoShapeManager::PaintJobsOrder::jobs, KIS_SAFE_ASSERT_RECOVER_NOOP, kisGrowRect(), KisRepaintShapeLayerLayerJob, KisImage::locked(), m_asyncUpdateSignalCompressor, m_dirtyRegion, m_dirtyRegionMutex, m_forceUpdateHiddenAreasOnly, m_hasUpdateInCompressor, m_image, m_paintJobsOrder, m_parentLayer, KisShapeLayerCanvasBase::m_shapeManager, KritaUtils::splitRectIntoPatchesTight(), KisThreadSafeSignalCompressor::start(), KoShapeManager::PaintJobsOrder::uncroppedViewUpdateRect, KisShapeLayerCanvasBase::viewConverter(), and KoCanvasBase::viewToDocument().
|
overridevirtual |
Tell the canvas to repaint the specified rectangle. The coordinates are document coordinates, not view coordinates.
Implements KoCanvasBase.
Definition at line 270 of file kis_shape_layer_canvas.cpp.
References updateCanvas().
Definition at line 246 of file kis_shape_layer_canvas.cpp.
References KisBaseNode::image, kisGrowRect(), m_asyncUpdateSignalCompressor, m_dirtyRegion, m_dirtyRegionMutex, m_hasUpdateInCompressor, m_hasUpdateOnSetImage, m_image, KisShapeLayerCanvasBase::m_isDestroying, m_parentLayer, KisThreadSafeSignalCompressor::start(), and KisShapeLayerCanvasBase::viewConverter().
|
friend |
Definition at line 108 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 117 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 127 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 123 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 124 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 122 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 118 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 119 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 129 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 130 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 125 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 115 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 114 of file kis_shape_layer_canvas.h.
|
private |
Definition at line 120 of file kis_shape_layer_canvas.h.