Krita Source Code Documentation
Loading...
Searching...
No Matches
KisCanvas2 Class Reference

#include <kis_canvas2.h>

+ Inheritance diagram for KisCanvas2:

Classes

struct  CanvasInputActionGroupsMaskInterface
 

Public Slots

void channelSelectionChanged ()
 
void finishResizingImage (qint32 w, qint32 h)
 
qreal rotationAngle () const
 canvas rotation in degrees
 
void slotChangeGlobalProofingConfig ()
 
void slotChangeProofingConfig ()
 
void slotConfigChanged ()
 
void slotGamutCheck ()
 
void slotPopupPaletteRequestedZoomChange (int zoom)
 
void slotScreenChanged (QScreen *screen)
 
void slotSoftProofing ()
 
void slotTrySwitchShapeManager ()
 
void startResizingImage ()
 
void startUpdateInPatches (const QRect &imageRect)
 
void updateCanvas ()
 Update the entire canvas area.
 
void updateCanvasDecorations ()
 
void updateCanvasDecorations (const QRectF &docRect)
 
void updateCanvasProjection (const QRectF &docRect)
 
void updateCanvasScene ()
 
void updateCanvasToolOutlineDoc (const QRectF &docRect)
 
void updateCanvasToolOutlineWdg (const QRect &widgetRect)
 
bool xAxisMirrored () const
 Bools indicating canvasmirroring.
 
bool yAxisMirrored () const
 

Signals

void sigCanvasCacheUpdated ()
 
void sigCanvasEngineChanged ()
 
void sigCanvasStateChanged ()
 
void sigContinueResizeImage (qint32 w, qint32 h)
 
void sigRegionOfInterestChanged (const QRect &roi)
 
void updateCanvasRequested (const QRect &rc)
 

Public Member Functions

void addCommand (KUndo2Command *command) override
 
void addDecoration (KisCanvasDecorationSP deco)
 
KisCanvasAnimationStateanimationState () const
 
void assignChangedMultiSurfaceState (const KisMultiSurfaceStateManager::State &newState)
 
void assignChangedMultiSurfaceStateSkipCanvasSurface (const KisMultiSurfaceStateManager::State &newState)
 
bool canvasIsOpenGL () const override
 
const QWidget * canvasWidget () const override
 
QWidget * canvasWidget () override
 
QString colorManagementReport () const
 
const KisCoordinatesConvertercoordinatesConverter () const
 
KisImageWSP currentImage () const
 
int currentScreenId () const
 
KisCanvasDecorationSP decoration (const QString &id) const
 
void disconnectCanvasObserver (QObject *object) override
 
void disconnectImage ()
 
KisDisplayColorConverterdisplayColorConverter () const
 
QSharedPointer< KisDisplayFilterdisplayFilter () const
 
QPoint documentOffset () const
 
QPoint documentOrigin () const override
 
QRect docUpdateRectToWidget (const QRectF &docRect)
 
bool effectiveLodAllowedInImage () const
 
KisExposureGammaCorrectionInterfaceexposureGammaCorrectionInterface () const
 
void fetchProofingOptions ()
 fetchProofingOptions Get the options for softproofing, and apply the view-specific state without affecting the proofing options as stored inside the image.
 
KisAnimationFrameCacheSP frameCache () const
 
KisInputManagerglobalInputManager () const
 
KoShapeManagerglobalShapeManager () const
 
void gridSize (QPointF *offset, QSizeF *spacing) const override
 
KisImageWSP image () const
 
QPointer< KisViewimageView () const
 
void initializeImage ()
 
KisInputActionGroupsMaskInterface::SharedInterface inputActionGroupsMaskInterface ()
 
 KisCanvas2 (KisCoordinatesConverter *coordConverter, KoCanvasResourceProvider *resourceManager, KisMainWindow *mainWindow, KisView *view, KoShapeControllerBase *sc)
 
 KisCanvas2Private (KisCanvas2 *parent, KisCoordinatesConverter *coordConverter, QPointer< KisView > view, KoCanvasResourceProvider *resourceManager)
 
KoShapeManagerlocalShapeManager () const
 
bool lodIsSupported () const
 
bool lodPreferredInCanvas () const
 
KisOpenGL::FilterMode openGLFilterMode () const
 
KisPaintingAssistantsDecorationSP paintingAssistantsDecoration () const
 
KisPopupPalettepopupPalette ()
 
bool proofingConfigUpdated ()
 proofingConfigUpdated ask the canvas whether or not it updated the proofing config.
 
KisProofingConfigurationSP proofingConfiguration () const
 
KisReferenceImagesDecorationSP referenceImagesDecoration () const
 
void refetchDataFromImage ()
 
QRect regionOfInterest () const
 
QRect renderingLimit () const
 
KoSelectedShapesProxyselectedShapesProxy () const override
 
void setActiveShapeManager (KoShapeManager *shapeManager)
 
void setCursor (const QCursor &cursor) override
 
void setDisplayFilter (QSharedPointer< KisDisplayFilter > displayFilter)
 
void setFavoriteResourceManager (KisFavoriteResourceManager *favoriteResourceManager)
 
void setLodPreferredInCanvas (bool value)
 
void setProofingConfigUpdated (bool updated)
 setProofingConfigUpdated This function is to set whether the proofing config is updated, this is needed for determining whether or not to generate a new proofing transform.
 
void setRenderingLimit (const QRect &rc)
 
void setWrapAroundViewingMode (bool value)
 
void setWrapAroundViewingModeAxis (WrapAroundAxis value)
 
KoShapeManagershapeManager () const override
 
bool snapToGrid () const override
 
KoToolProxytoolProxy () const override
 
KoUnit unit () const override
 
void updateCanvas (const QRectF &rc) override
 
void updateProofingState ()
 
const KoViewConverterviewConverter () const override
 
KoViewConverterviewConverter () override
 
KisViewManagerviewManager () const
 
bool wrapAroundViewingMode () const
 
WrapAroundAxis wrapAroundViewingModeAxis () const
 
 ~KisCanvas2 () override
 
 ~KisCanvas2Private ()
 
- Public Member Functions inherited from KoCanvasBase
KoCanvasControllercanvasController () const
 
virtual void clipToDocument (const KoShape *shape, QPointF &move) const
 
 KoCanvasBase (KoShapeControllerBase *shapeController, KoCanvasResourceProvider *sharedResourceManager=0)
 
 Private ()
 
KoCanvasResourceProviderresourceManager () const
 
void setCanvasController (KoCanvasController *controller)
 called by KoCanvasController to set the controller that handles this canvas.
 
KoShapeControllershapeController () const
 
KoSnapGuidesnapGuide () const
 
virtual QPointF viewToDocument (const QPointF &viewPoint) const
 
 ~KoCanvasBase () override
 
 ~Private ()
 

Public Attributes

QScopedPointer< KisCanvasAnimationStateanimationPlayer
 
bool bootstrapLodBlocked = false
 
KisSignalCompressor canvasUpdateCompressor
 
KisAbstractCanvasWidgetcanvasWidget = 0
 
QBitArray channelFlags
 
KisCoordinatesConvertercoordinatesConverter = 0
 
bool currentCanvasIsOpenGL = true
 
QPointer< KoShapeManagercurrentlyActiveShapeManager
 
KisDisplayColorConverter displayColorConverter
 
KisAnimationFrameCacheSP frameCache
 
KisSignalCompressor frameRenderStartCompressor
 
KisInputActionGroupsMask inputActionGroupsMask = AllActionGroup
 
QSharedPointer< CanvasInputActionGroupsMaskInterfaceinputActionGroupsMaskInterface
 
int isBatchUpdateActive = 0
 
bool lodPreferredInImage = false
 
KisMultiSurfaceStateManager multiSurfaceSetupManager
 
std::optional< KisMultiSurfaceStateManager::StatemultiSurfaceState
 
int openGLFilterMode = 0
 
KisPopupPalettepopupPalette = 0
 
KisPrescaledProjectionSP prescaledProjection
 
KisCanvasUpdatesCompressor projectionUpdatesCompressor
 
KisProofingConfigurationSP proofingConfig
 
bool proofingConfigUpdated = false
 
KisCanvas2q = 0
 
KisSignalCompressor referencesBoundsUpdateCompressor
 
QRect regionOfInterest
 
qreal regionOfInterestMargin = 0.25
 
KisSignalCompressor regionOfInterestUpdateCompressor
 
QRect renderingLimit
 
QRect savedCanvasProjectionUpdateRect
 
QRect savedOverlayUpdateRect
 
KisSelectedShapesProxy selectedShapesProxy
 
KoShapeManager shapeManager
 
KisToolProxy toolProxy
 
bool updateSceneRequested = false
 
QPointer< KisViewview
 
- Public Attributes inherited from KoCanvasBase
KoCanvasControllercontroller
 
bool isResourceManagerShared
 
QPointer< KoCanvasResourceProviderresourceManager
 
QPointer< KoShapeControllershapeController
 
KoSnapGuidesnapGuide
 

Private Slots

void bootstrapFinished ()
 
void slotBeginUpdatesBatch ()
 
void slotCanvasStateChanged ()
 
void slotDoCanvasUpdate ()
 
void slotEffectiveZoomChanged (qreal newZoom)
 
void slotEndUpdatesBatch ()
 
void slotImageColorSpaceChanged ()
 
void slotSelectionChanged ()
 
void slotSetLodUpdatesBlocked (bool value)
 
void slotUpdateReferencesBounds ()
 
void slotUpdateRegionOfInterest ()
 
void startUpdateCanvasProjection (const QRect &rc)
 
void updateCanvasProjection ()
 

Private Member Functions

void connectCurrentCanvas ()
 
void createCanvas (bool useOpenGL)
 
void createOpenGLCanvas ()
 
void createQPainterCanvas ()
 
void initializeFpsDecoration ()
 
void notifyLevelOfDetailChange ()
 
void requestCanvasUpdateMaybeCompressed ()
 
void resetCanvas (bool useOpenGL)
 
void setCanvasWidget (KisAbstractCanvasWidget *widget)
 
void setup ()
 
void slotSurfaceFormatChanged (const KisDisplayConfig &config)
 
void updateCanvasWidgetImpl (const QRect &rc=QRect())
 

Private Attributes

KisCanvas2Private *const m_d
 

Friends

class KisView
 

Detailed Description

KisCanvas2 is not an actual widget class, but rather an adapter for the widget it contains, which may be either a QPainter based canvas, or an OpenGL based canvas: that are the real widgets.

Definition at line 113 of file kis_canvas2.cpp.

Constructor & Destructor Documentation

◆ ~KisCanvas2Private()

KisCanvas2::~KisCanvas2Private ( )
inline

Definition at line 173 of file kis_canvas2.cpp.

174 {
175 inputActionGroupsMaskInterface->m_canvasPrivateRef = nullptr;
176
177 // We need to make sure that the QScopedPointer gets freed within the scope
178 // of KisCanvas2Private's lifespan. For some reason, this isn't guaranteed
179 // and was causing a crash when closing a file when playback is happening
180 // and there are multiple images. See Bug: 499658
181 animationPlayer.reset();
182 }
QScopedPointer< KisCanvasAnimationState > animationPlayer
QSharedPointer< CanvasInputActionGroupsMaskInterface > inputActionGroupsMaskInterface

◆ KisCanvas2()

KisCanvas2::KisCanvas2 ( KisCoordinatesConverter * coordConverter,
KoCanvasResourceProvider * resourceManager,
KisMainWindow * mainWindow,
KisView * view,
KoShapeControllerBase * sc )

Create a new canvas. The canvas manages a widget that will do the actual painting: the canvas itself is not a widget.

Parameters
viewConverterthe viewconverter for converting between window and document coordinates.

While loading LoD should be blocked. Only when GUI has finished loading and zoom level settled down, LoD is given a green light.

Definition at line 294 of file kis_canvas2.cpp.

296 , m_d(new KisCanvas2Private(this, coordConverter, view, resourceManager))
297{
303 m_d->bootstrapLodBlocked = true;
304 connect(mainWindow, SIGNAL(guiLoadingFinished()), SLOT(bootstrapFinished()));
305
306 KisImageConfig config(false);
307
308#if !KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
309 m_d->canvasUpdateCompressor.setDelay(1000 / config.fpsLimit());
310 m_d->canvasUpdateCompressor.setMode(KisSignalCompressor::FIRST_ACTIVE);
311#endif
312
313 m_d->frameRenderStartCompressor.setDelay(1000 / config.fpsLimit());
314 m_d->frameRenderStartCompressor.setMode(KisSignalCompressor::FIRST_ACTIVE);
316}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisCanvas2Private *const m_d
QPointer< KisView > view
void bootstrapFinished()
KisCanvas2Private(KisCanvas2 *parent, KisCoordinatesConverter *coordConverter, QPointer< KisView > view, KoCanvasResourceProvider *resourceManager)
KoSnapGuide * snapGuide
QPointer< KoCanvasResourceProvider > resourceManager
void overrideSnapStrategy(Strategy type, KoSnapStrategy *strategy)

References bootstrapFinished(), connect(), KisSignalCompressor::FIRST_ACTIVE, KisImageConfig::fpsLimit(), m_d, KoSnapGuide::overrideSnapStrategy(), KoSnapGuide::PixelSnapping, and KoCanvasBase::snapGuide.

◆ ~KisCanvas2()

KisCanvas2::~KisCanvas2 ( )
override

Definition at line 398 of file kis_canvas2.cpp.

399{
400 delete m_d;
401}

References m_d.

Member Function Documentation

◆ addCommand()

void KisCanvas2::addCommand ( KUndo2Command * command)
overridevirtual

Adds a command to the history. Call this for each command you create. This will also execute the command. This means, most of the application's code will look like MyCommand * cmd = new MyCommand( parameters ); canvas.addCommand( cmd );

Note that the command history takes ownership of the command, it will delete it when the undo limit is reached, or when deleting the command history itself.

Parameters
commandthe command to add

Implements KoCanvasBase.

Definition at line 541 of file kis_canvas2.cpp.

542{
543 // This method exists to support flake-related operations
544 m_d->view->image()->undoAdapter()->addCommand(command);
545}

References m_d.

◆ addDecoration()

void KisCanvas2::addDecoration ( KisCanvasDecorationSP deco)
Returns
true if the canvas image should be displayed in vertically mirrored mode

Definition at line 1472 of file kis_canvas2.cpp.

1473{
1474 m_d->canvasWidget->addDecoration(deco);
1475}

References m_d.

◆ animationState()

KisCanvasAnimationState * KisCanvas2::animationState ( ) const

Definition at line 1522 of file kis_canvas2.cpp.

1523{
1524 return m_d->animationPlayer.data();
1525}

References m_d.

◆ assignChangedMultiSurfaceState()

void KisCanvas2::assignChangedMultiSurfaceState ( const KisMultiSurfaceStateManager::State & newState)

◆ assignChangedMultiSurfaceStateSkipCanvasSurface()

void KisCanvas2::assignChangedMultiSurfaceStateSkipCanvasSurface ( const KisMultiSurfaceStateManager::State & newState)

◆ bootstrapFinished

void KisCanvas2::bootstrapFinished ( )
privateslot

Definition at line 1567 of file kis_canvas2.cpp.

1568{
1569 if (!m_d->bootstrapLodBlocked) return;
1570
1571 m_d->bootstrapLodBlocked = false;
1572 setLodPreferredInCanvas(m_d->lodPreferredInImage);
1573
1574 // Initialization of audio tracks is deferred until after canvas has been completely constructed.
1575 m_d->animationPlayer->setupAudioTracks();
1576}
void setLodPreferredInCanvas(bool value)

References m_d, and setLodPreferredInCanvas().

◆ canvasIsOpenGL()

bool KisCanvas2::canvasIsOpenGL ( ) const
overridevirtual
Returns
true if opengl can be used directly on the canvas

Reimplemented from KoCanvasBase.

Definition at line 484 of file kis_canvas2.cpp.

485{
486 return m_d->currentCanvasIsOpenGL;
487}

References m_d.

◆ canvasWidget() [1/2]

const QWidget * KisCanvas2::canvasWidget ( ) const
overridevirtual

Return the widget that will be added to the scrollArea.

Implements KoCanvasBase.

◆ canvasWidget() [2/2]

QWidget * KisCanvas2::canvasWidget ( )
overridevirtual

Return the widget that will be added to the scrollArea.

Implements KoCanvasBase.

◆ channelSelectionChanged

void KisCanvas2::channelSelectionChanged ( )
slot

Definition at line 528 of file kis_canvas2.cpp.

529{
530 KisImageSP image = this->image();
531 m_d->channelFlags = image->rootLayer()->channelFlags();
532
533 m_d->view->viewManager()->blockUntilOperationsFinishedForced(image);
534
536 m_d->canvasWidget->channelSelectionChanged(m_d->channelFlags);
538 image->unlock();
539}
void startUpdateInPatches(const QRect &imageRect)
KisImageWSP image() const
KisGroupLayerSP rootLayer() const
void unlock()
Definition kis_image.cc:805
void barrierLock(bool readOnly=false)
Wait until all the queued background jobs are completed and lock the image.
Definition kis_image.cc:756
QRect bounds() const override
QBitArray channelFlags
Definition kis_layer.cc:167

References KisImage::barrierLock(), KisImage::bounds(), KisLayer::channelFlags, image(), m_d, KisImage::rootLayer(), startUpdateInPatches(), and KisImage::unlock().

◆ colorManagementReport()

QString KisCanvas2::colorManagementReport ( ) const

Return user-facing information about color management status of the main window surface. The information is intentionally left untranslated, since it is supposed to be used for bugreports.

Definition at line 1615 of file kis_canvas2.cpp.

1616{
1617#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
1618 QString report;
1619 QDebug str(&report);
1620
1621 if (m_d->canvasWidget) {
1622 str << "(canvas bit depth report)" << Qt::endl;
1623 str << Qt::endl;
1624 str.noquote().nospace() << m_d->canvasWidget->currentBitDepthUserReport();
1625 }
1626
1627 str << Qt::endl;
1628
1629 if (m_d->surfaceColorManager) {
1630 str.noquote().nospace() << QString("(canvas surface color manager)\n");
1631 str.noquote().nospace() << QString("\n");
1632 str.noquote().nospace() << m_d->surfaceColorManager->colorManagementReport();
1633 } else {
1634 str.noquote().nospace() << QString("Surface color management is not supported on this platform\n");
1635 }
1636
1637 return report;
1638#else
1639 return "Surface color management is disabled\n";
1640#endif
1641}

References m_d.

◆ connectCurrentCanvas()

void KisCanvas2::connectCurrentCanvas ( )
private

Definition at line 760 of file kis_canvas2.cpp.

761{
762 KisImageWSP image = m_d->view->image();
763
764 if (!m_d->currentCanvasIsOpenGL) {
765 Q_ASSERT(m_d->prescaledProjection);
766 m_d->prescaledProjection->setImage(image);
767 }
768
770 setLodPreferredInCanvas(m_d->lodPreferredInImage);
771
772 Q_EMIT sigCanvasEngineChanged();
773}
void startResizingImage()
void sigCanvasEngineChanged()

References image(), m_d, setLodPreferredInCanvas(), sigCanvasEngineChanged(), and startResizingImage().

◆ coordinatesConverter()

const KisCoordinatesConverter * KisCanvas2::coordinatesConverter ( ) const

◆ createCanvas()

void KisCanvas2::createCanvas ( bool useOpenGL)
private

Definition at line 687 of file kis_canvas2.cpp.

688{
689 // deinitialize previous canvas structures
690 m_d->prescaledProjection = 0;
691 m_d->frameCache = 0;
692
693 KisConfig cfg(true);
694
695 if (useOpenGL && !KisOpenGL::hasOpenGL()) {
696 warnKrita << "Tried to create OpenGL widget when system doesn't have OpenGL\n";
697 useOpenGL = false;
698 }
699
700 if (useOpenGL) {
702 if (cfg.canvasState() == "OPENGL_FAILED") {
703 // Creating the opengl canvas failed, fall back
704 warnKrita << "OpenGL Canvas initialization returned OPENGL_FAILED. Falling back to QPainter.";
706 }
707 } else {
709 }
710
711 KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->multiSurfaceState);
712 m_d->displayColorConverter.setMultiSurfaceDisplayConfig(m_d->multiSurfaceState->multiConfig);
713
714 if (m_d->popupPalette) {
715 m_d->popupPalette->setParent(m_d->canvasWidget->widget());
716 }
717
718}
void createQPainterCanvas()
void createOpenGLCanvas()
static bool hasOpenGL()
Check for OpenGL.
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
Definition kis_assert.h:128
#define warnKrita
Definition kis_debug.h:87

References KisConfig::canvasState(), createOpenGLCanvas(), createQPainterCanvas(), KisOpenGL::hasOpenGL(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, and warnKrita.

◆ createOpenGLCanvas()

void KisCanvas2::createOpenGLCanvas ( )
private

Definition at line 660 of file kis_canvas2.cpp.

661{
662 KisConfig cfg(true);
663 m_d->openGLFilterMode = cfg.openGLFilteringMode();
664 m_d->currentCanvasIsOpenGL = true;
665
666 m_d->multiSurfaceState =
667 m_d->multiSurfaceSetupManager.createInitializingConfig(true, m_d->currentScreenId(), m_d->proofingConfig);
668
669 auto bitDepthMode =
670 cfg.effectiveCanvasSurfaceBitDepthMode(QSurfaceFormat::defaultFormat())
674
676 m_d->coordinatesConverter,
677 0,
678 m_d->view->image(),
679 m_d->multiSurfaceState->multiConfig.canvasDisplayConfig(),
680 m_d->displayColorConverter.displayFilter(),
681 bitDepthMode);
682 m_d->frameCache = KisAnimationFrameCache::getFrameCache(canvasWidget->openGLImageTextures());
683
685}
static KisAnimationFrameCacheSP getFrameCache(KisOpenGLImageTexturesSP textures)
KisAbstractCanvasWidget * canvasWidget
void setCanvasWidget(KisAbstractCanvasWidget *widget)

References canvasWidget, KisAbstractCanvasWidget::Depth10Bit, KisConfig::Depth10Bit, KisAbstractCanvasWidget::Depth8Bit, KisConfig::effectiveCanvasSurfaceBitDepthMode(), KisAnimationFrameCache::getFrameCache(), m_d, KisConfig::openGLFilteringMode(), and setCanvasWidget().

◆ createQPainterCanvas()

void KisCanvas2::createQPainterCanvas ( )
private

Definition at line 644 of file kis_canvas2.cpp.

645{
646 m_d->currentCanvasIsOpenGL = false;
647
648 m_d->multiSurfaceState =
649 m_d->multiSurfaceSetupManager.createInitializingConfig(false, m_d->currentScreenId(), m_d->proofingConfig);
650
651 KisQPainterCanvas * canvasWidget = new KisQPainterCanvas(this, m_d->coordinatesConverter, m_d->view);
652 m_d->prescaledProjection = new KisPrescaledProjection();
653 m_d->prescaledProjection->setCoordinatesConverter(m_d->coordinatesConverter);
654 m_d->prescaledProjection->setDisplayConfig(m_d->displayColorConverter.displayConfig());
655 m_d->prescaledProjection->setDisplayFilter(m_d->displayColorConverter.displayFilter());
656 canvasWidget->setPrescaledProjection(m_d->prescaledProjection);
658}

References canvasWidget, m_d, and setCanvasWidget().

◆ currentImage()

KisImageWSP KisCanvas2::currentImage ( ) const

Definition at line 1343 of file kis_canvas2.cpp.

1344{
1345 return m_d->view->image();
1346}

References m_d.

◆ currentScreenId()

int KisCanvas2::currentScreenId ( ) const
inline

Definition at line 253 of file kis_canvas2.cpp.

253 {
254 int canvasScreenNumber = qApp->screens().indexOf(view->currentScreen());
255
256 if (canvasScreenNumber < 0) {
257 warnKrita << "Couldn't detect screen that Krita belongs to..." << ppVar(view->currentScreen());
258 canvasScreenNumber = 0;
259 }
260 return canvasScreenNumber;
261 }
#define ppVar(var)
Definition kis_debug.h:155

References ppVar, and warnKrita.

◆ decoration()

KisCanvasDecorationSP KisCanvas2::decoration ( const QString & id) const

Definition at line 1477 of file kis_canvas2.cpp.

1478{
1479 return m_d->canvasWidget->decoration(id);
1480}

References m_d.

◆ disconnectCanvasObserver()

void KisCanvas2::disconnectCanvasObserver ( QObject * object)
overridevirtual

disconnect the given QObject completely and utterly from any and all connections it has to any QObject owned by the canvas. Do this in the setCanvas of every KoCanvasObserver.

Reimplemented from KoCanvasBase.

Definition at line 1231 of file kis_canvas2.cpp.

1232{
1234 m_d->view->disconnect(object);
1235}
virtual void disconnectCanvasObserver(QObject *object)

References KoCanvasBase::disconnectCanvasObserver(), and m_d.

◆ disconnectImage()

void KisCanvas2::disconnectImage ( )

We explicitly don't use barrierLock() here, because we don't care about all the updates completed (we don't use image's content). We only need to guarantee that the image will not try to access us in a multithreaded way, while we are being destroyed.

Definition at line 744 of file kis_canvas2.cpp.

745{
746 KisImageSP image = m_d->view->image();
747
756 disconnect(image.data(), 0, this, 0);
757 image->unlock();
758}
void immediateLockForReadOnly()
Definition kis_image.cc:793

References KisWeakSharedPtr< T >::data(), image(), KisImage::immediateLockForReadOnly(), m_d, and KisImage::unlock().

◆ displayColorConverter()

KisDisplayColorConverter * KisCanvas2::displayColorConverter ( ) const

◆ displayFilter()

QSharedPointer< KisDisplayFilter > KisCanvas2::displayFilter ( ) const

Definition at line 838 of file kis_canvas2.cpp.

839{
840 return m_d->displayColorConverter.displayFilter();
841}

References m_d.

◆ documentOffset()

QPoint KisCanvas2::documentOffset ( ) const

Definition at line 1494 of file kis_canvas2.cpp.

1495{
1496 return m_d->coordinatesConverter->documentOffset();
1497}

References m_d.

◆ documentOrigin()

QPoint KisCanvas2::documentOrigin ( ) const
overridevirtual

Return the position of the document origin inside the canvas widget, in pixels. By default the origin of the canvas widget and the position of the document origin are coincident, thus an empty point is returned.

In Krita we don't use document origin anymore. All the centering when needed (vastScrolling < 0.5) is done automatically by the KisCoordinatesConverter.

Reimplemented from KoCanvasBase.

Definition at line 1483 of file kis_canvas2.cpp.

1484{
1491 return QPoint();
1492}

◆ docUpdateRectToWidget()

QRect KisCanvas2::docUpdateRectToWidget ( const QRectF & docRect)

◆ effectiveLodAllowedInImage()

bool KisCanvas2::effectiveLodAllowedInImage ( ) const
inline

Definition at line 238 of file kis_canvas2.cpp.

238 {
240 }
bool bootstrapLodBlocked
bool lodPreferredInImage

◆ exposureGammaCorrectionInterface()

KisExposureGammaCorrectionInterface * KisCanvas2::exposureGammaCorrectionInterface ( ) const

Definition at line 868 of file kis_canvas2.cpp.

869{
870 QSharedPointer<KisDisplayFilter> displayFilter = m_d->displayColorConverter.displayFilter();
871
872 return displayFilter ?
873 displayFilter->correctionInterface() :
875}
QSharedPointer< KisDisplayFilter > displayFilter() const
static KisDumbExposureGammaCorrectionInterface * instance()

References displayFilter(), KisDumbExposureGammaCorrectionInterface::instance(), and m_d.

◆ fetchProofingOptions()

void KisCanvas2::fetchProofingOptions ( )

fetchProofingOptions Get the options for softproofing, and apply the view-specific state without affecting the proofing options as stored inside the image.

Definition at line 877 of file kis_canvas2.cpp.

878{
880 if (!baseConfig) {
881 baseConfig = KisImageConfig(true).defaultProofingconfiguration();
882 }
883 *m_d->proofingConfig = *baseConfig;
884
886}
void updateProofingState()
KisProofingConfigurationSP defaultProofingconfiguration(bool requestDefault=false)
KisProofingConfigurationSP proofingConfiguration() const
proofingConfiguration

References KisImageConfig::defaultProofingconfiguration(), image(), m_d, KisImage::proofingConfiguration(), and updateProofingState().

◆ finishResizingImage

void KisCanvas2::finishResizingImage ( qint32 w,
qint32 h )
slot

Definition at line 963 of file kis_canvas2.cpp.

964{
965 m_d->canvasWidget->finishResizingImage(w, h);
966}

References m_d.

◆ frameCache()

KisAnimationFrameCacheSP KisCanvas2::frameCache ( ) const

◆ globalInputManager()

KisInputManager * KisCanvas2::globalInputManager ( ) const

Filters events and sends them to canvas actions. Shared among all the views/canvases

NOTE: May be null while initialization!

Definition at line 604 of file kis_canvas2.cpp.

605{
606 return m_d->view->globalInputManager();
607}

References m_d.

◆ globalShapeManager()

KoShapeManager * KisCanvas2::globalShapeManager ( ) const

Return the shape manager associated with this canvas

Definition at line 572 of file kis_canvas2.cpp.

573{
574 return &m_d->shapeManager;
575}

References m_d.

◆ gridSize()

void KisCanvas2::gridSize ( QPointF * offset,
QSizeF * spacing ) const
overridevirtual

retrieve the grid size setting. The grid spacing will be provided in pt.

Parameters
horizontala pointer to a qreal that will be filled with the horizontal grid-spacing
verticala pointer to a qreal that will be filled with the vertical grid-spacing

Implements KoCanvasBase.

Definition at line 494 of file kis_canvas2.cpp.

495{
496 QTransform transform = coordinatesConverter()->imageToDocumentTransform();
497
498 const QPoint intSpacing = m_d->view->document()->gridConfig().spacing();
499 const QPoint intOffset = m_d->view->document()->gridConfig().offset();
500
501 QPointF size = transform.map(QPointF(intSpacing));
502 spacing->rwidth() = size.x();
503 spacing->rheight() = size.y();
504
505 *offset = transform.map(QPointF(intOffset));
506}
KisCoordinatesConverter * coordinatesConverter
int size(const Forest< T > &forest)
Definition KisForest.h:1232

References coordinatesConverter, KisCoordinatesConverter::imageToDocumentTransform(), and m_d.

◆ image()

KisImageWSP KisCanvas2::image ( ) const

Definition at line 1337 of file kis_canvas2.cpp.

1338{
1339 return m_d->view->image();
1340
1341}

References m_d.

◆ imageView()

QPointer< KisView > KisCanvas2::imageView ( ) const

Definition at line 1332 of file kis_canvas2.cpp.

1333{
1334 return m_d->view;
1335}

References m_d.

◆ initializeFpsDecoration()

void KisCanvas2::initializeFpsDecoration ( )
private

Definition at line 378 of file kis_canvas2.cpp.

379{
380 KisConfig cfg(true);
381
382 const bool shouldShowDebugOverlay =
383 (canvasIsOpenGL() && cfg.enableOpenGLFramerateLogging()) ||
384 cfg.enableBrushSpeedLogging();
385
386 if (shouldShowDebugOverlay && !decoration(KisFpsDecoration::idTag)) {
388
389 if (cfg.enableBrushSpeedLogging()) {
390 connect(KisStrokeSpeedMonitor::instance(), SIGNAL(sigStatsUpdated()), this, SLOT(updateCanvas()));
391 }
392 } else if (!shouldShowDebugOverlay && decoration(KisFpsDecoration::idTag)) {
393 m_d->canvasWidget->removeDecoration(KisFpsDecoration::idTag);
394 disconnect(KisStrokeSpeedMonitor::instance(), SIGNAL(sigStatsUpdated()), this, SLOT(updateCanvas()));
395 }
396}
void addDecoration(KisCanvasDecorationSP deco)
bool canvasIsOpenGL() const override
QPointer< KisView > imageView() const
KisCanvasDecorationSP decoration(const QString &id) const
void updateCanvas()
Update the entire canvas area.
static const QString idTag
static KisStrokeSpeedMonitor * instance()

References addDecoration(), canvasIsOpenGL(), connect(), decoration(), KisConfig::enableBrushSpeedLogging(), KisConfig::enableOpenGLFramerateLogging(), KisFpsDecoration::idTag, imageView(), KisStrokeSpeedMonitor::instance(), m_d, and updateCanvas().

◆ initializeImage()

void KisCanvas2::initializeImage ( )

Definition at line 720 of file kis_canvas2.cpp.

721{
722 KisImageSP image = m_d->view->image();
723
724 m_d->displayColorConverter.setImageColorSpace(image->colorSpace());
725 m_d->coordinatesConverter->setImage(image);
726 m_d->toolProxy.initializeImage(image);
727
728 connect(image, SIGNAL(sigImageUpdated(QRect)), SLOT(startUpdateCanvasProjection(QRect)), Qt::DirectConnection);
729 connect(image->signalRouter(), SIGNAL(sigNotifyBatchUpdateStarted()), SLOT(slotBeginUpdatesBatch()), Qt::DirectConnection);
730 connect(image->signalRouter(), SIGNAL(sigNotifyBatchUpdateEnded()), SLOT(slotEndUpdatesBatch()), Qt::DirectConnection);
731 connect(image->signalRouter(), SIGNAL(sigRequestLodPlanesSyncBlocked(bool)), SLOT(slotSetLodUpdatesBlocked(bool)), Qt::DirectConnection);
732
733 connect(image, SIGNAL(sigProofingConfigChanged()), SLOT(slotChangeProofingConfig()));
734 connect(image, SIGNAL(sigSizeChanged(QPointF,QPointF)), SLOT(startResizingImage()), Qt::DirectConnection);
735 connect(image->undoAdapter(), SIGNAL(selectionChanged()), SLOT(slotTrySwitchShapeManager()));
736
737 connect(image, SIGNAL(sigColorSpaceChanged(const KoColorSpace*)), SLOT(slotImageColorSpaceChanged()));
738 connect(image, SIGNAL(sigProfileChanged(const KoColorProfile*)), SLOT(slotImageColorSpaceChanged()));
739
742}
void slotBeginUpdatesBatch()
void fetchProofingOptions()
fetchProofingOptions Get the options for softproofing, and apply the view-specific state without affe...
void slotEndUpdatesBatch()
void slotSetLodUpdatesBlocked(bool value)
void startUpdateCanvasProjection(const QRect &rc)
void slotImageColorSpaceChanged()
void slotChangeProofingConfig()
void connectCurrentCanvas()
void slotTrySwitchShapeManager()
KisUndoAdapter * undoAdapter() const
const KoColorSpace * colorSpace() const
KisImageSignalRouter * signalRouter()

References KisImage::colorSpace(), connect(), connectCurrentCanvas(), fetchProofingOptions(), image(), m_d, KisImage::signalRouter(), slotBeginUpdatesBatch(), slotChangeProofingConfig(), slotEndUpdatesBatch(), slotImageColorSpaceChanged(), slotSetLodUpdatesBlocked(), slotTrySwitchShapeManager(), startResizingImage(), startUpdateCanvasProjection(), and KisImage::undoAdapter().

◆ inputActionGroupsMaskInterface()

KisInputActionGroupsMaskInterface::SharedInterface KisCanvas2::inputActionGroupsMaskInterface ( )
Returns
a reference to alter this canvas' input action groups mask

◆ KisCanvas2Private()

KisCanvas2::KisCanvas2Private ( KisCanvas2 * parent,
KisCoordinatesConverter * coordConverter,
QPointer< KisView > view,
KoCanvasResourceProvider * resourceManager )
inline

Definition at line 140 of file kis_canvas2.cpp.

144 : q(parent)
145 , coordinatesConverter(coordConverter)
146 , view(view)
147 , shapeManager(parent)
149 , toolProxy(parent)
152 , inputActionGroupsMaskInterface(new CanvasInputActionGroupsMaskInterface(this))
155 {
156#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
157 if (KisPlatformPluginInterfaceFactory::instance()->surfaceColorManagedByOS()) {
158 rootSurfaceInfoProxy = new KisRootSurfaceInfoProxy(view, q);
159 multiSurfaceSetupManager.setRootSurfaceInfoProxy(rootSurfaceInfoProxy);
160 connect(rootSurfaceInfoProxy,
162 parent,
163 [this](const KoColorProfile *profile) {
165 return;
168 });
169 }
170#endif
171 }
KisSelectedShapesProxy selectedShapesProxy
KisDisplayColorConverter displayColorConverter
std::optional< KisMultiSurfaceStateManager::State > multiSurfaceState
KisProofingConfigurationSP proofingConfig
KoShapeManager shapeManager
void assignChangedMultiSurfaceState(const KisMultiSurfaceStateManager::State &newState)
KisToolProxy toolProxy
KisSignalCompressor referencesBoundsUpdateCompressor
KisMultiSurfaceStateManager multiSurfaceSetupManager
KisSignalCompressor regionOfInterestUpdateCompressor
KisCanvas2 * q
State onGuiSurfaceFormatChanged(const State &oldState, const KoColorProfile *uiProfile) const
static KisPlatformPluginInterfaceFactory * instance()
The KisProofingConfiguration struct Little struct that stores the proofing configuration for a given ...
void sigRootSurfaceProfileChanged(const KoColorProfile *profile) const

References connect(), KisPlatformPluginInterfaceFactory::instance(), and KisRootSurfaceInfoProxy::sigRootSurfaceProfileChanged().

◆ localShapeManager()

KoShapeManager * KisCanvas2::localShapeManager ( ) const

Return shape manager associated with the currently active node. If current node has no internal shape manager, return null.

Definition at line 577 of file kis_canvas2.cpp.

578{
579 KisNodeSP node = m_d->view->currentNode();
580 KoShapeManager *localShapeManager = fetchShapeManagerFromNode(node);
581
582 if (localShapeManager != m_d->currentlyActiveShapeManager) {
583 m_d->setActiveShapeManager(localShapeManager);
584 }
585
586 return localShapeManager;
587}
KoShapeManager * localShapeManager() const

References localShapeManager(), and m_d.

◆ lodIsSupported()

bool KisCanvas2::lodIsSupported ( ) const
inline

◆ lodPreferredInCanvas()

bool KisCanvas2::lodPreferredInCanvas ( ) const

Definition at line 1593 of file kis_canvas2.cpp.

1594{
1595 return m_d->lodPreferredInImage;
1596}

References m_d.

◆ notifyLevelOfDetailChange()

void KisCanvas2::notifyLevelOfDetailChange ( )
private

Definition at line 1303 of file kis_canvas2.cpp.

1304{
1305 KisImageSP image = this->image();
1306
1307 if (m_d->bootstrapLodBlocked || !m_d->lodIsSupported()) {
1309 } else {
1310 const qreal effectiveZoom = m_d->coordinatesConverter->effectiveZoom();
1311
1312 KisConfig cfg(true);
1313 const int maxLod = cfg.numMipmapLevels();
1314 const int lod = KisLodTransform::scaleToLod(effectiveZoom, maxLod);
1315 KisLodPreferences::PreferenceFlags flags = KisLodPreferences::LodSupported;
1316
1317 if (m_d->lodPreferredInImage) {
1319 }
1321 }
1322}
void setLodPreferences(const KisLodPreferences &value)
static int scaleToLod(qreal scale, int maxLod)

References image(), KisLodPreferences::LodPreferred, KisLodPreferences::LodSupported, m_d, KisLodPreferences::None, KisConfig::numMipmapLevels(), KisLodTransformBase::scaleToLod(), and KisImage::setLodPreferences().

◆ openGLFilterMode()

KisOpenGL::FilterMode KisCanvas2::openGLFilterMode ( ) const

◆ paintingAssistantsDecoration()

KisPaintingAssistantsDecorationSP KisCanvas2::paintingAssistantsDecoration ( ) const

Definition at line 1598 of file kis_canvas2.cpp.

1599{
1600 KisCanvasDecorationSP deco = decoration("paintingAssistantsDecoration");
1601 return qobject_cast<KisPaintingAssistantsDecoration*>(deco.data());
1602}

References KisSharedPtr< T >::data(), and decoration().

◆ popupPalette()

KisPopupPalette * KisCanvas2::popupPalette ( )

◆ proofingConfigUpdated()

bool KisCanvas2::proofingConfigUpdated ( )

proofingConfigUpdated ask the canvas whether or not it updated the proofing config.

Returns
whether or not the proofing config is updated, if so, a new proofing transform needs to be made in KisOpenGL canvas.

◆ proofingConfiguration()

KisProofingConfigurationSP KisCanvas2::proofingConfiguration ( ) const

Definition at line 946 of file kis_canvas2.cpp.

947{
948 return m_d->proofingConfig;
949}

References m_d.

◆ referenceImagesDecoration()

KisReferenceImagesDecorationSP KisCanvas2::referenceImagesDecoration ( ) const

Definition at line 1604 of file kis_canvas2.cpp.

1605{
1606 KisCanvasDecorationSP deco = decoration("referenceImagesDecoration");
1607 return qobject_cast<KisReferenceImagesDecoration*>(deco.data());
1608}

References KisSharedPtr< T >::data(), and decoration().

◆ refetchDataFromImage()

void KisCanvas2::refetchDataFromImage ( )

Definition at line 1400 of file kis_canvas2.cpp.

1401{
1402 KisImageSP image = this->image();
1403 KisImageReadOnlyBarrierLock l(image);
1405}

References KisImage::bounds(), image(), and startUpdateInPatches().

◆ regionOfInterest()

QRect KisCanvas2::regionOfInterest ( ) const
Returns
area of the image (in image coordinates) that is visible on the canvas with a small margin selected by the user

◆ renderingLimit()

QRect KisCanvas2::renderingLimit ( ) const
Returns
artificial limit outside which the image will not be rendered

◆ requestCanvasUpdateMaybeCompressed()

void KisCanvas2::requestCanvasUpdateMaybeCompressed ( )
private

If Qt has our custom patch for global updates compression, then we shouldn't do our own compression here in the canvas. Everything will be done in Qt.

Definition at line 1077 of file kis_canvas2.cpp.

1078{
1083#if !KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
1084 m_d->canvasUpdateCompressor.start();
1085#else
1087#endif
1088}
void slotDoCanvasUpdate()

References m_d, and slotDoCanvasUpdate().

◆ resetCanvas()

void KisCanvas2::resetCanvas ( bool useOpenGL)
private

Definition at line 775 of file kis_canvas2.cpp.

776{
777 // we cannot reset the canvas before it's created, but this method might be called,
778 // for instance when setting the monitor profile.
779 if (!m_d->canvasWidget) {
780 return;
781 }
782
783 KisConfig cfg(true);
784
785 const bool canvasHasNativeSurface = bool(m_d->canvasWidget->widget()->windowHandle());
786 const bool canvasNeedsNativeSurface =
787 cfg.enableCanvasSurfaceColorSpaceManagement() &&
789
790 bool needReset = (m_d->currentCanvasIsOpenGL != useOpenGL) ||
791 (m_d->currentCanvasIsOpenGL &&
792 m_d->openGLFilterMode != cfg.openGLFilteringMode()) ||
793 canvasHasNativeSurface != canvasNeedsNativeSurface;
794
795 if (needReset) {
796 createCanvas(useOpenGL);
798 slotEffectiveZoomChanged(m_d->coordinatesConverter->effectiveZoom());
799 }
801}
void createCanvas(bool useOpenGL)
void updateCanvasWidgetImpl(const QRect &rc=QRect())
void slotEffectiveZoomChanged(qreal newZoom)

References connectCurrentCanvas(), createCanvas(), KisConfig::enableCanvasSurfaceColorSpaceManagement(), KisPlatformPluginInterfaceFactory::instance(), m_d, KisConfig::openGLFilteringMode(), slotEffectiveZoomChanged(), KisPlatformPluginInterfaceFactory::surfaceColorManagedByOS(), and updateCanvasWidgetImpl().

◆ rotationAngle

qreal KisCanvas2::rotationAngle ( ) const
slot

canvas rotation in degrees

Definition at line 513 of file kis_canvas2.cpp.

514{
515 return m_d->coordinatesConverter->rotationAngle();
516}

References m_d.

◆ selectedShapesProxy()

KoSelectedShapesProxy * KisCanvas2::selectedShapesProxy ( ) const
overridevirtual

Since shapeManager() may change, we need a persistent object where we can connect to and thack the selection. See more comments in KoCanvasBase.

Implements KoCanvasBase.

◆ setActiveShapeManager()

void KisCanvas2::setActiveShapeManager ( KoShapeManager * shapeManager)

◆ setCanvasWidget()

void KisCanvas2::setCanvasWidget ( KisAbstractCanvasWidget * widget)
private

We are switching the canvas type. We should reinitialize our connections to decorations and input manager

Definition at line 403 of file kis_canvas2.cpp.

404{
405 if (m_d->popupPalette) {
406 m_d->popupPalette->setParent(widget->widget());
407 }
408
409 if (m_d->canvasWidget) {
415 widget->setDecorations(m_d->canvasWidget->decorations());
416
417 if(viewManager()) {
419 m_d->canvasWidget = widget;
421 } else {
422 m_d->canvasWidget = widget;
423 }
424 } else {
425 m_d->canvasWidget = widget;
426 }
427
428 if (!m_d->canvasWidget->decoration(INFINITY_DECORATION_ID)) {
429 KisInfinityManager *manager = new KisInfinityManager(m_d->view, this);
430 manager->setVisible(true);
431 m_d->canvasWidget->addDecoration(manager);
432 }
433
434 widget->widget()->setAutoFillBackground(false);
435 widget->widget()->setAttribute(Qt::WA_OpaquePaintEvent);
436 widget->widget()->setMouseTracking(true);
437 widget->widget()->setAcceptDrops(true);
438
440 if (controller && controller->canvas() == this) {
441 controller->changeCanvasWidget(widget->widget());
442 }
443
444
445#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
451 m_d->surfaceColorManager.reset();
452
453 QWindow *mainWindowNativeWindow = m_d->view->mainWindow()->windowHandle();
454 QWindow *nativeWindow = widget->widget()->windowHandle();
455
456 if (nativeWindow && nativeWindow != mainWindowNativeWindow) {
457 std::unique_ptr<KisSurfaceColorManagerInterface> iface(
458 KisPlatformPluginInterfaceFactory::instance()->createSurfaceColorManager(nativeWindow));
459
460 // if surfaceColorManagedByOS() is true, then interface is guaranteed to
461 // be present
463
464 if (iface) {
465 m_d->surfaceColorManager.reset(
466 new KisCanvasSurfaceColorSpaceManager(iface.release(),
467 m_d->multiSurfaceState->surfaceMode,
468 m_d->multiSurfaceState->multiConfig.options(),
469 this));
470
471 connect(m_d->surfaceColorManager.data(),
473 this,
475 }
476 } else {
477 qWarning() << "WARNING: created non-native Krita canvas on managed platform,"
478 << "its color space will be limited to sRGB";
479 }
480 }
481#endif
482}
virtual void setDecorations(const QList< KisCanvasDecorationSP > &)=0
virtual QWidget * widget()=0
KisViewManager * viewManager() const
void slotSurfaceFormatChanged(const KisDisplayConfig &config)
virtual void setVisible(bool v)
void removeTrackedCanvas(KisCanvas2 *canvas)
void addTrackedCanvas(KisCanvas2 *canvas)
KisInputManager * inputManager() const
Filters events and sends them to canvas actions.
KoCanvasController * controller
KoCanvasController * canvasController() const
virtual KoCanvasBase * canvas() const
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
Definition kis_assert.h:130
static const QString INFINITY_DECORATION_ID
void sigDisplayConfigChanged(const KisDisplayConfig &config)

References KisInputManager::addTrackedCanvas(), KoCanvasController::canvas(), KoCanvasBase::canvasController(), connect(), KoCanvasBase::controller, INFINITY_DECORATION_ID, KisViewManager::inputManager(), KisPlatformPluginInterfaceFactory::instance(), KIS_SAFE_ASSERT_RECOVER_NOOP, m_d, KisInputManager::removeTrackedCanvas(), KisAbstractCanvasWidget::setDecorations(), KisCanvasDecoration::setVisible(), KisCanvasSurfaceColorSpaceManager::sigDisplayConfigChanged(), slotSurfaceFormatChanged(), KisPlatformPluginInterfaceFactory::surfaceColorManagedByOS(), viewManager(), and KisAbstractCanvasWidget::widget().

◆ setCursor()

void KisCanvas2::setCursor ( const QCursor & cursor)
overridevirtual

set the specified cursor on this canvas

Parameters
cursorthe new cursor
Returns
the old cursor

Implements KoCanvasBase.

Definition at line 1512 of file kis_canvas2.cpp.

1513{
1514 canvasWidget()->setCursor(cursor);
1515}

References canvasWidget.

◆ setDisplayFilter()

void KisCanvas2::setDisplayFilter ( QSharedPointer< KisDisplayFilter > displayFilter)

Definition at line 826 of file kis_canvas2.cpp.

827{
828 m_d->displayColorConverter.setDisplayFilter(displayFilter);
829 KisImageSP image = this->image();
830
831 m_d->view->viewManager()->blockUntilOperationsFinishedForced(image);
832
834 m_d->canvasWidget->setDisplayFilter(displayFilter);
835 image->unlock();
836}

References KisImage::barrierLock(), displayFilter(), image(), m_d, and KisImage::unlock().

◆ setFavoriteResourceManager()

void KisCanvas2::setFavoriteResourceManager ( KisFavoriteResourceManager * favoriteResourceManager)

Definition at line 1499 of file kis_canvas2.cpp.

1500{
1501 m_d->popupPalette = new KisPopupPalette(viewManager(), m_d->coordinatesConverter, favoriteResourceManager, displayColorConverter()->displayRendererInterface(),
1502 m_d->canvasWidget->widget());
1503 connect(m_d->popupPalette, SIGNAL(zoomLevelChanged(int)), this, SLOT(slotPopupPaletteRequestedZoomChange(int)));
1504 connect(m_d->popupPalette, SIGNAL(sigUpdateCanvas()), this, SLOT(updateCanvas()));
1505 connect(m_d->view->mainWindow(), SIGNAL(themeChanged()), m_d->popupPalette, SLOT(slotUpdateIcons()));
1506}
void slotPopupPaletteRequestedZoomChange(int zoom)

References connect(), displayColorConverter, m_d, slotPopupPaletteRequestedZoomChange(), updateCanvas(), and viewManager().

◆ setLodPreferredInCanvas()

void KisCanvas2::setLodPreferredInCanvas ( bool value)

Definition at line 1578 of file kis_canvas2.cpp.

1579{
1580 if (!KisOpenGL::supportsLoD()) {
1581 qWarning() << "WARNING: Level of Detail functionality is available only with openGL + GLSL 1.3 support";
1582 }
1583
1584 m_d->lodPreferredInImage =
1585 value && m_d->lodIsSupported();
1586
1588
1589 KisConfig cfg(false);
1590 cfg.setLevelOfDetailEnabled(m_d->lodPreferredInImage);
1591}
float value(const T *src, size_t ch)
void notifyLevelOfDetailChange()

References m_d, notifyLevelOfDetailChange(), KisConfig::setLevelOfDetailEnabled(), KisOpenGL::supportsLoD(), and value().

◆ setProofingConfigUpdated()

void KisCanvas2::setProofingConfigUpdated ( bool updated)

setProofingConfigUpdated This function is to set whether the proofing config is updated, this is needed for determining whether or not to generate a new proofing transform.

Parameters
updatedwhether it's updated. Just set it to false in normal usage.

Definition at line 936 of file kis_canvas2.cpp.

937{
938 m_d->proofingConfigUpdated = updated;
939}

References m_d.

◆ setRenderingLimit()

void KisCanvas2::setRenderingLimit ( const QRect & rc)

Set artificial limit outside which the image will not be rendered rc is measured in image pixels

Definition at line 1278 of file kis_canvas2.cpp.

1279{
1280 m_d->renderingLimit = rc;
1281}

References m_d.

◆ setup()

void KisCanvas2::setup ( )
private

We switch the shape manager every time vector layer or shape selection is activated. Flake does not expect this and connects all the signals of the global shape manager to the clients in the constructor. To workaround this we forward the signals of local shape managers stored in the vector layers to the signals of global shape manager. So the sequence of signal deliveries is the following:

shapeLayer.m_d.canvas.m_shapeManager.selection() -> shapeLayer -> shapeController -> globalShapeManager.selection()

Definition at line 318 of file kis_canvas2.cpp.

319{
320 // a bit of duplication from slotConfigChanged()
321 KisConfig cfg(true);
322 m_d->lodPreferredInImage = cfg.levelOfDetailEnabled();
323 m_d->regionOfInterestMargin = KisImageConfig(true).animationCacheRegionOfInterestMargin();
324
325 createCanvas(cfg.useOpenGL());
326
327 setLodPreferredInCanvas(m_d->lodPreferredInImage);
328
329 connect(m_d->view->canvasController()->proxyObject, SIGNAL(effectiveZoomChanged(qreal)), SLOT(slotEffectiveZoomChanged(qreal)));
331
332 connect(KisConfigNotifier::instance(), SIGNAL(configChanged()), SLOT(slotConfigChanged()));
335
351 KisShapeController *kritaShapeController = static_cast<KisShapeController*>(shapeController()->documentBase());
352 connect(kritaShapeController, SIGNAL(selectionChanged()),
353 this, SLOT(slotSelectionChanged()));
354 connect(kritaShapeController, SIGNAL(selectionContentChanged()),
355 selectedShapesProxy(), SIGNAL(selectionContentChanged()));
356 connect(kritaShapeController, SIGNAL(currentLayerChanged(const KoShapeLayer*)),
357 selectedShapesProxy(), SIGNAL(currentLayerChanged(const KoShapeLayer*)));
358
359#if !KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
360 connect(&m_d->canvasUpdateCompressor, SIGNAL(timeout()), SLOT(slotDoCanvasUpdate()));
361#endif
362
363 connect(this, SIGNAL(sigCanvasCacheUpdated()), &m_d->frameRenderStartCompressor, SLOT(start()));
364 connect(&m_d->frameRenderStartCompressor, SIGNAL(timeout()), SLOT(updateCanvasProjection()));
365
366 connect(this, SIGNAL(sigContinueResizeImage(qint32,qint32)), SLOT(finishResizingImage(qint32,qint32)));
367
368 connect(&m_d->regionOfInterestUpdateCompressor, SIGNAL(timeout()), SLOT(slotUpdateRegionOfInterest()));
369 connect(&m_d->referencesBoundsUpdateCompressor, SIGNAL(timeout()), SLOT(slotUpdateReferencesBounds()));
370
371 connect(m_d->view->document(), SIGNAL(sigReferenceImagesChanged()), &m_d->referencesBoundsUpdateCompressor, SLOT(start()));
372
374
375 m_d->animationPlayer.reset(new KisCanvasAnimationState(this));
376}
void initializeFpsDecoration()
void slotCanvasStateChanged()
void sigContinueResizeImage(qint32 w, qint32 h)
void slotUpdateReferencesBounds()
void slotSelectionChanged()
void slotConfigChanged()
void updateCanvasProjection()
void slotChangeGlobalProofingConfig()
void finishResizingImage(qint32 w, qint32 h)
void slotUpdateRegionOfInterest()
void sigCanvasCacheUpdated()
The KisCanvasAnimationState class stores all of the canvas-specific animation state.
static KisConfigNotifier * instance()
static KisImageConfigNotifier * instance()
void globalProofingConfigChanged()
qreal animationCacheRegionOfInterestMargin(bool defaultValue=false) const
QPointer< KoShapeController > shapeController

References KisImageConfig::animationCacheRegionOfInterestMargin(), KoCanvasControllerProxyObject::canvasStateChanged(), connect(), createCanvas(), finishResizingImage(), KisImageConfigNotifier::globalProofingConfigChanged(), initializeFpsDecoration(), KisConfigNotifier::instance(), KisImageConfigNotifier::instance(), KisConfig::levelOfDetailEnabled(), m_d, selectedShapesProxy, setLodPreferredInCanvas(), KoCanvasBase::shapeController, sigCanvasCacheUpdated(), sigContinueResizeImage(), slotCanvasStateChanged(), slotChangeGlobalProofingConfig(), slotConfigChanged(), slotDoCanvasUpdate(), slotEffectiveZoomChanged(), slotSelectionChanged(), slotUpdateReferencesBounds(), slotUpdateRegionOfInterest(), updateCanvasProjection(), and KisConfig::useOpenGL().

◆ setWrapAroundViewingMode()

void KisCanvas2::setWrapAroundViewingMode ( bool value)

Definition at line 1539 of file kis_canvas2.cpp.

1540{
1541 KisCanvasDecorationSP infinityDecoration =
1542 m_d->canvasWidget->decoration(INFINITY_DECORATION_ID);
1543
1544 if (infinityDecoration) {
1545 infinityDecoration->setVisible(!value);
1546 }
1547
1548 m_d->canvasWidget->setWrapAroundViewingMode(value);
1549}

References INFINITY_DECORATION_ID, m_d, and value().

◆ setWrapAroundViewingModeAxis()

void KisCanvas2::setWrapAroundViewingModeAxis ( WrapAroundAxis value)

Definition at line 1556 of file kis_canvas2.cpp.

1557{
1558 m_d->canvasWidget->setWrapAroundViewingModeAxis(value);
1559 updateCanvas();
1560}

References m_d, updateCanvas(), and value().

◆ shapeManager()

KoShapeManager * KisCanvas2::shapeManager ( ) const
overridevirtual

Return the right shape manager for the current layer. That is to say, if the current layer is a vector layer, return the shape layer's canvas' shapemanager, else the shapemanager associated with the global krita canvas.

Implements KoCanvasBase.

◆ sigCanvasCacheUpdated

void KisCanvas2::sigCanvasCacheUpdated ( )
signal

◆ sigCanvasEngineChanged

void KisCanvas2::sigCanvasEngineChanged ( )
signal

◆ sigCanvasStateChanged

void KisCanvas2::sigCanvasStateChanged ( )
signal

◆ sigContinueResizeImage

void KisCanvas2::sigContinueResizeImage ( qint32 w,
qint32 h )
signal

◆ sigRegionOfInterestChanged

void KisCanvas2::sigRegionOfInterestChanged ( const QRect & roi)
signal

◆ slotBeginUpdatesBatch

void KisCanvas2::slotBeginUpdatesBatch ( )
privateslot

Definition at line 1048 of file kis_canvas2.cpp.

1049{
1050 KisUpdateInfoSP info =
1052 m_d->coordinatesConverter->imageRectInImagePixels());
1053 m_d->projectionUpdatesCompressor.putUpdateInfo(info);
1054 Q_EMIT sigCanvasCacheUpdated();
1055}

References m_d, sigCanvasCacheUpdated(), and KisMarkerUpdateInfo::StartBatch.

◆ slotCanvasStateChanged

void KisCanvas2::slotCanvasStateChanged ( )
privateslot

Definition at line 1348 of file kis_canvas2.cpp.

1349{
1350 if (!m_d->currentCanvasIsOpenGL) {
1351 Q_ASSERT(m_d->prescaledProjection);
1352 auto state = KisCanvasState::fromConverter(*m_d->coordinatesConverter);
1353 m_d->prescaledProjection->notifyCanvasStateChanged(state);
1354 }
1355
1356 updateCanvas();
1357 m_d->regionOfInterestUpdateCompressor.start();
1358
1359 Q_EMIT sigCanvasStateChanged();
1360}
void sigCanvasStateChanged()
static KisCanvasState fromConverter(const KisCoordinatesConverter &converter)

References KisCanvasState::fromConverter(), m_d, sigCanvasStateChanged(), and updateCanvas().

◆ slotChangeGlobalProofingConfig

void KisCanvas2::slotChangeGlobalProofingConfig ( )
slot

Definition at line 919 of file kis_canvas2.cpp.

920{
921 if (image() && !image()->proofingConfiguration()) {
922 // global config should be updated only when
923 // the image doesn't have its own config
925 }
926}
KisProofingConfigurationSP proofingConfiguration() const

References image(), proofingConfiguration(), and slotChangeProofingConfig().

◆ slotChangeProofingConfig

void KisCanvas2::slotChangeProofingConfig ( )
slot

Definition at line 928 of file kis_canvas2.cpp.

929{
931 if (imageView()->softProofing()) {
933 }
934}
void refetchDataFromImage()

References fetchProofingOptions(), imageView(), and refetchDataFromImage().

◆ slotConfigChanged

void KisCanvas2::slotConfigChanged ( )
slot

Called whenever the configuration settings change.

Definition at line 1362 of file kis_canvas2.cpp.

1363{
1364 KisConfig cfg(true);
1365 m_d->regionOfInterestMargin = KisImageConfig(true).animationCacheRegionOfInterestMargin();
1366
1367 resetCanvas(cfg.useOpenGL());
1368
1369 QWidget *mainWindow = m_d->view->mainWindow();
1371
1372 QWidget *topLevelWidget = mainWindow->topLevelWidget();
1373 KIS_SAFE_ASSERT_RECOVER_RETURN(topLevelWidget);
1374
1375 KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->multiSurfaceState);
1376 auto newState = m_d->multiSurfaceSetupManager.onConfigChanged(*m_d->multiSurfaceState,
1377 m_d->currentScreenId(),
1378 cfg.canvasSurfaceColorSpaceManagementMode(),
1380 m_d->assignChangedMultiSurfaceState(newState);
1381
1383}
void resetCanvas(bool useOpenGL)
static Options optionsFromKisConfig(const KisConfig &cfg)

References KisImageConfig::animationCacheRegionOfInterestMargin(), KisConfig::canvasSurfaceColorSpaceManagementMode(), initializeFpsDecoration(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, KisDisplayConfig::optionsFromKisConfig(), resetCanvas(), and KisConfig::useOpenGL().

◆ slotDoCanvasUpdate

void KisCanvas2::slotDoCanvasUpdate ( )
privateslot

WARNING: in isBusy() we access openGL functions without making the painting context current. We hope that currently active context will be Qt's one, which is shared with our own.

Definition at line 1090 of file kis_canvas2.cpp.

1091{
1092
1093#if !KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
1099 if (m_d->canvasWidget->isBusy()) {
1100 // just restarting the timer
1101 m_d->canvasUpdateCompressor.start();
1102 return;
1103 }
1104#endif
1105
1106 QRect combinedUpdateRect = m_d->savedCanvasProjectionUpdateRect | m_d->savedOverlayUpdateRect;
1107 if (!combinedUpdateRect.isEmpty()) {
1108 // TODO: Remove this signal (only used by the old KisSketchView)
1109 Q_EMIT updateCanvasRequested(combinedUpdateRect);
1110
1111 if (wrapAroundViewingMode() && !m_d->savedCanvasProjectionUpdateRect.isEmpty()) {
1112 const QRect widgetRect = m_d->canvasWidget->widget()->rect();
1113 const QRect imageRect = m_d->coordinatesConverter->imageRectInImagePixels();
1114
1115 const QRect widgetRectInImagePixels =
1116 m_d->coordinatesConverter->widgetToImage(widgetRect).toAlignedRect();
1117
1118 const QRect rc = m_d->coordinatesConverter->widgetToImage(m_d->savedCanvasProjectionUpdateRect).toAlignedRect();
1119
1120 const QVector<QRect> updateRects =
1121 KisWrappedRect::multiplyWrappedRect(rc, imageRect, widgetRectInImagePixels, wrapAroundViewingModeAxis());
1122
1123 Q_FOREACH(const QRect &rc, updateRects) {
1124 const QRect widgetUpdateRect =
1125 m_d->coordinatesConverter->imageToWidget(rc).toAlignedRect() & widgetRect;
1126 m_d->canvasWidget->updateCanvasImage(widgetUpdateRect);
1127 }
1128 m_d->canvasWidget->updateCanvasDecorations(m_d->savedOverlayUpdateRect);
1129 } else {
1130 m_d->canvasWidget->updateCanvasImage(m_d->savedCanvasProjectionUpdateRect);
1131 m_d->canvasWidget->updateCanvasDecorations(m_d->savedOverlayUpdateRect);
1132 }
1133 } else if (m_d->updateSceneRequested) {
1134 m_d->canvasWidget->widget()->update();
1135 }
1136
1137 m_d->savedCanvasProjectionUpdateRect = QRect();
1138 m_d->savedOverlayUpdateRect = QRect();
1139 m_d->updateSceneRequested = false;
1140}
bool wrapAroundViewingMode() const
WrapAroundAxis wrapAroundViewingModeAxis() const
void updateCanvasRequested(const QRect &rc)
static QVector< QRect > multiplyWrappedRect(const QRect &rc, const QRect &wrapRect, const QRect &limitRect, WrapAroundAxis wrapAxis)

References m_d, KisWrappedRect::multiplyWrappedRect(), updateCanvasRequested(), wrapAroundViewingMode(), and wrapAroundViewingModeAxis().

◆ slotEffectiveZoomChanged

void KisCanvas2::slotEffectiveZoomChanged ( qreal newZoom)
privateslot

Definition at line 1237 of file kis_canvas2.cpp.

1238{
1239 Q_UNUSED(newZoom)
1240
1241
1242
1244}

References notifyLevelOfDetailChange().

◆ slotEndUpdatesBatch

void KisCanvas2::slotEndUpdatesBatch ( )
privateslot

Definition at line 1057 of file kis_canvas2.cpp.

1058{
1059 KisUpdateInfoSP info =
1061 m_d->coordinatesConverter->imageRectInImagePixels());
1062 m_d->projectionUpdatesCompressor.putUpdateInfo(info);
1063 Q_EMIT sigCanvasCacheUpdated();
1064}

References KisMarkerUpdateInfo::EndBatch, m_d, and sigCanvasCacheUpdated().

◆ slotGamutCheck

void KisCanvas2::slotGamutCheck ( )
slot

Definition at line 911 of file kis_canvas2.cpp.

912{
914 if (imageView()->softProofing()) {
916 }
917}

References imageView(), refetchDataFromImage(), and updateProofingState().

◆ slotImageColorSpaceChanged

void KisCanvas2::slotImageColorSpaceChanged ( )
privateslot

Definition at line 843 of file kis_canvas2.cpp.

844{
845 KisImageSP image = this->image();
846
847 m_d->view->viewManager()->blockUntilOperationsFinishedForced(image);
848
849 m_d->displayColorConverter.setImageColorSpace(image->colorSpace());
850 m_d->channelFlags = image->rootLayer()->channelFlags();
851 m_d->canvasWidget->channelSelectionChanged(m_d->channelFlags);
852
853 // Not all color spaces are supported by soft-proofing, so update state
854 if (imageView()->softProofing()) {
856 }
857
859 m_d->canvasWidget->notifyImageColorSpaceChanged(image->colorSpace());
860 image->unlock();
861}

References KisImage::barrierLock(), KisLayer::channelFlags, KisImage::colorSpace(), image(), imageView(), m_d, KisImage::rootLayer(), KisImage::unlock(), and updateProofingState().

◆ slotPopupPaletteRequestedZoomChange

void KisCanvas2::slotPopupPaletteRequestedZoomChange ( int zoom)
slot

Definition at line 1508 of file kis_canvas2.cpp.

1508 {
1509 m_d->view->canvasController()->setZoom(KoZoomMode::ZOOM_CONSTANT, (qreal)(zoom/100.0)); // 1.0 is 100% zoom
1510}
@ ZOOM_CONSTANT
zoom x %
Definition KoZoomMode.h:24

References m_d, and KoZoomMode::ZOOM_CONSTANT.

◆ slotScreenChanged

void KisCanvas2::slotScreenChanged ( QScreen * screen)
slot

Definition at line 1385 of file kis_canvas2.cpp.

1386{
1387 const int screenId = qApp->screens().indexOf(screen);
1388
1389 if (screenId < 0) {
1390 warnUI << "Failed to get screenNumber for updating display profile.";
1391 return;
1392 }
1393
1394 KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->multiSurfaceState);
1395 auto newState = m_d->multiSurfaceSetupManager.onScreenChanged(*m_d->multiSurfaceState,
1396 screenId);
1397 m_d->assignChangedMultiSurfaceState(newState);
1398}
#define warnUI
Definition kis_debug.h:94

References KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, and warnUI.

◆ slotSelectionChanged

void KisCanvas2::slotSelectionChanged ( )
privateslot

Definition at line 1527 of file kis_canvas2.cpp.

1528{
1529 KisShapeLayer* shapeLayer = dynamic_cast<KisShapeLayer*>(viewManager()->activeLayer().data());
1530 if (!shapeLayer) {
1531 return;
1532 }
1533 m_d->shapeManager.selection()->deselectAll();
1534 Q_FOREACH (KoShape* shape, shapeLayer->shapeManager()->selection()->selectedShapes()) {
1535 m_d->shapeManager.selection()->select(shape);
1536 }
1537}
KoShapeManager * shapeManager() const
KisLayerSP activeLayer()
Convenience method to get at the active layer.
const QList< KoShape * > selectedShapes() const
KoSelection * selection

References KisViewManager::activeLayer(), KisSharedPtr< T >::data(), m_d, KoSelection::selectedShapes(), KoShapeManager::selection, KisShapeLayer::shapeManager(), and viewManager().

◆ slotSetLodUpdatesBlocked

void KisCanvas2::slotSetLodUpdatesBlocked ( bool value)
privateslot

Definition at line 1066 of file kis_canvas2.cpp.

1067{
1068 KisUpdateInfoSP info =
1071 KisMarkerUpdateInfo::UnblockLodUpdates,
1072 m_d->coordinatesConverter->imageRectInImagePixels());
1073 m_d->projectionUpdatesCompressor.putUpdateInfo(info);
1074 Q_EMIT sigCanvasCacheUpdated();
1075}

References KisMarkerUpdateInfo::BlockLodUpdates, m_d, sigCanvasCacheUpdated(), KisMarkerUpdateInfo::UnblockLodUpdates, and value().

◆ slotSoftProofing

void KisCanvas2::slotSoftProofing ( )
slot

Definition at line 905 of file kis_canvas2.cpp.

906{
909}

References refetchDataFromImage(), and updateProofingState().

◆ slotSurfaceFormatChanged()

void KisCanvas2::slotSurfaceFormatChanged ( const KisDisplayConfig & config)
private

Definition at line 1445 of file kis_canvas2.cpp.

1446{
1447#if KRITA_USE_SURFACE_COLOR_MANAGEMENT_API
1448
1449 KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->multiSurfaceState);
1450 if (m_d->multiSurfaceState->multiConfig.canvasDisplayConfig() == config) return;
1451
1452 if (m_d->multiSurfaceState->isCanvasOpenGL) {
1453 if (config.isHDR &&
1454 m_d->canvasWidget->currentBitDepthMode() < KisOpenGLCanvas2::BitDepthMode::Depth10Bit) {
1455
1456 const QString warningMessage = i18n(
1457 "WARNING: HDR mode was activated on surface working in 8-bit mode!\n"
1458 "Please activate 10-bit mode in Krita's Preferences dialog and restart "
1459 "Krita to avoid color banding!");
1460
1461 m_d->view->showFloatingMessage(warningMessage, koIcon("warning"), 7000, KisFloatingMessage::High);
1462 warnOpenGL.noquote() << QString(warningMessage).replace('\n', ' ');
1463 warnOpenGL << ppVar(QSurfaceFormat::defaultFormat());
1464 }
1465 }
1466
1467 auto newState = m_d->multiSurfaceSetupManager.onCanvasSurfaceFormatChanged(*m_d->multiSurfaceState, config);
1468 m_d->assignChangedMultiSurfaceStateSkipCanvasSurface(newState);
1469#endif
1470}
#define warnOpenGL
Definition kis_debug.h:102
#define koIcon(name)
Use these macros for icons without any issues.
Definition kis_icon.h:25

References KisAbstractCanvasWidget::Depth10Bit, KisFloatingMessage::High, KisDisplayConfig::isHDR, KIS_SAFE_ASSERT_RECOVER_RETURN, koIcon, m_d, ppVar, and warnOpenGL.

◆ slotTrySwitchShapeManager

void KisCanvas2::slotTrySwitchShapeManager ( )
slot

Definition at line 1293 of file kis_canvas2.cpp.

1294{
1295 KisNodeSP node = m_d->view->currentNode();
1296
1297 QPointer<KoShapeManager> newManager;
1298 newManager = fetchShapeManagerFromNode(node);
1299
1300 m_d->setActiveShapeManager(newManager);
1301}

References m_d.

◆ slotUpdateReferencesBounds

void KisCanvas2::slotUpdateReferencesBounds ( )
privateslot

Definition at line 1267 of file kis_canvas2.cpp.

1268{
1269 QRectF referencesRect;
1270 KisReferenceImagesLayerSP layer = m_d->view->document()->referenceImagesLayer();
1271 if (layer) {
1272 referencesRect = layer->boundingImageRect();
1273 }
1274
1275 m_d->view->canvasController()->syncOnReferencesChange(referencesRect);
1276}

References KisReferenceImagesLayer::boundingImageRect(), and m_d.

◆ slotUpdateRegionOfInterest

void KisCanvas2::slotUpdateRegionOfInterest ( )
privateslot

Definition at line 1251 of file kis_canvas2.cpp.

1252{
1253 const QRect oldRegionOfInterest = m_d->regionOfInterest;
1254
1255 const qreal ratio = m_d->regionOfInterestMargin;
1256 const QRect proposedRoi = KisAlgebra2D::blowRect(m_d->coordinatesConverter->widgetRectInImagePixels(), ratio).toAlignedRect();
1257
1258 const QRect imageRect = m_d->coordinatesConverter->imageRectInImagePixels();
1259
1260 m_d->regionOfInterest = proposedRoi & imageRect;
1261
1262 if (m_d->regionOfInterest != oldRegionOfInterest) {
1263 Q_EMIT sigRegionOfInterestChanged(m_d->regionOfInterest);
1264 }
1265}
void sigRegionOfInterestChanged(const QRect &roi)
Rect blowRect(const Rect &rect, qreal coeff)

References KisAlgebra2D::blowRect(), m_d, and sigRegionOfInterestChanged().

◆ snapToGrid()

bool KisCanvas2::snapToGrid ( ) const
overridevirtual

return if snap to grid is enabled.

Returns
if snap to grid is enabled.

Implements KoCanvasBase.

Definition at line 508 of file kis_canvas2.cpp.

509{
510 return m_d->view->document()->gridConfig().snapToGrid();
511}

References m_d.

◆ startResizingImage

void KisCanvas2::startResizingImage ( )
slot

Definition at line 951 of file kis_canvas2.cpp.

952{
953 KisImageWSP image = this->image();
954 qint32 w = image->width();
955 qint32 h = image->height();
956
957 Q_EMIT sigContinueResizeImage(w, h);
958
959 QRect imageBounds(0, 0, w, h);
960 startUpdateInPatches(imageBounds);
961}
qint32 width() const
qint32 height() const

References KisImage::height(), image(), sigContinueResizeImage(), startUpdateInPatches(), and KisImage::width().

◆ startUpdateCanvasProjection

void KisCanvas2::startUpdateCanvasProjection ( const QRect & rc)
privateslot

The image projection has changed, now start an update of the canvas representation.

Definition at line 968 of file kis_canvas2.cpp.

969{
970 KisUpdateInfoSP info = m_d->canvasWidget->startUpdateCanvasProjection(rc);
971 if (m_d->projectionUpdatesCompressor.putUpdateInfo(info)) {
972 Q_EMIT sigCanvasCacheUpdated();
973 }
974}

References m_d, and sigCanvasCacheUpdated().

◆ startUpdateInPatches

void KisCanvas2::startUpdateInPatches ( const QRect & imageRect)
slot

We don't do patched loading for openGL canvas, because it loads the tiles, which are basically "patches". Therefore, big chunks of memory are never allocated.

Definition at line 803 of file kis_canvas2.cpp.

804{
810 if (m_d->currentCanvasIsOpenGL) {
812 } else {
813 KisImageConfig imageConfig(true);
814 int patchWidth = imageConfig.updatePatchWidth();
815 int patchHeight = imageConfig.updatePatchHeight();
816
817 for (int y = 0; y < imageRect.height(); y += patchHeight) {
818 for (int x = 0; x < imageRect.width(); x += patchWidth) {
819 QRect patchRect(x, y, patchWidth, patchHeight);
821 }
822 }
823 }
824}

References m_d, startUpdateCanvasProjection(), KisImageConfig::updatePatchHeight(), and KisImageConfig::updatePatchWidth().

◆ toolProxy()

KoToolProxy * KisCanvas2::toolProxy ( ) const
overridevirtual

Return the proxy to the active tool (determining which tool is really, really active is hard when tablets are involved, so leave that to others.

Implements KoCanvasBase.

◆ unit()

KoUnit KisCanvas2::unit ( ) const
overridevirtual

Return the unit of the current document for initialization of the widgets created by the flake framework.

See also
KoDocument::unit()

Implements KoCanvasBase.

Definition at line 620 of file kis_canvas2.cpp.

621{
623
624 KisImageWSP image = m_d->view->image();
625 if (image) {
626 if (!qFuzzyCompare(image->xRes(), image->yRes())) {
627 warnKrita << "WARNING: resolution of the image is anisotropic"
628 << ppVar(image->xRes())
629 << ppVar(image->yRes());
630 }
631
632 const qreal resolution = image->xRes();
633 unit.setFactor(resolution);
634 }
635
636 return unit;
637}
KoUnit unit() const override
double xRes() const
double yRes() const
@ Pixel
Definition KoUnit.h:82
void setFactor(qreal factor)
Definition KoUnit.h:122
static bool qFuzzyCompare(half p1, half p2)

References image(), m_d, KoUnit::Pixel, ppVar, qFuzzyCompare(), KoUnit::setFactor(), unit(), warnKrita, KisImage::xRes(), and KisImage::yRes().

◆ updateCanvas [1/2]

void KisCanvas2::updateCanvas ( )
slot

Update the entire canvas area.

Definition at line 1158 of file kis_canvas2.cpp.

1159{
1161}

References updateCanvasWidgetImpl().

◆ updateCanvas() [2/2]

void KisCanvas2::updateCanvas ( const QRectF & rc)
overridevirtual

Tell the canvas to repaint the specified rectangle. The coordinates are document coordinates, not view coordinates.

Implements KoCanvasBase.

Definition at line 1170 of file kis_canvas2.cpp.

1171{
1172 // updateCanvas is called from tools, never from the projection
1173 // updates, so no need to prescale!
1174 QRect widgetRect = m_d->docUpdateRectToWidget(documentRect);
1175 if (!widgetRect.isEmpty()) {
1176 updateCanvasWidgetImpl(widgetRect);
1177 }
1178}

References m_d, and updateCanvasWidgetImpl().

◆ updateCanvasDecorations [1/2]

void KisCanvas2::updateCanvasDecorations ( )
slot

Definition at line 1189 of file kis_canvas2.cpp.

1190{
1191 m_d->savedOverlayUpdateRect = m_d->canvasWidget->widget()->rect();
1193}
void requestCanvasUpdateMaybeCompressed()

References m_d, and requestCanvasUpdateMaybeCompressed().

◆ updateCanvasDecorations [2/2]

void KisCanvas2::updateCanvasDecorations ( const QRectF & docRect)
slot

Definition at line 1195 of file kis_canvas2.cpp.

1196{
1197 QRect widgetRect = m_d->docUpdateRectToWidget(docRect);
1198 if (!widgetRect.isEmpty()) {
1199 m_d->savedOverlayUpdateRect |= widgetRect;
1201 }
1202}

References m_d, and requestCanvasUpdateMaybeCompressed().

◆ updateCanvasProjection [1/2]

void KisCanvas2::updateCanvasProjection ( )
privateslot

Definition at line 976 of file kis_canvas2.cpp.

977{
978 auto tryIssueCanvasUpdates = [this](const QRect &vRect) {
979 if (!m_d->isBatchUpdateActive) {
980 // TODO: Implement info->dirtyViewportRect() for KisOpenGLCanvas2 to avoid updating whole canvas
981 if (m_d->currentCanvasIsOpenGL) {
982 m_d->savedCanvasProjectionUpdateRect |= vRect;
983
984 // we already had a compression in frameRenderStartCompressor, so force the update directly
986 } else if (/* !m_d->currentCanvasIsOpenGL && */ !vRect.isEmpty()) {
987 m_d->savedCanvasProjectionUpdateRect |= m_d->coordinatesConverter->viewportToWidget(vRect).toAlignedRect();
988
989 // we already had a compression in frameRenderStartCompressor, so force the update directly
991 }
992 }
993 };
994
995 auto uploadData = [this, tryIssueCanvasUpdates](const QVector<KisUpdateInfoSP> &infoObjects) {
996 QVector<QRect> viewportRects = m_d->canvasWidget->updateCanvasProjection(infoObjects);
997 const QRect vRect = std::accumulate(viewportRects.constBegin(), viewportRects.constEnd(),
998 QRect(), std::bit_or<QRect>());
999
1000 tryIssueCanvasUpdates(vRect);
1001 };
1002
1003 bool shouldExplicitlyIssueUpdates = false;
1004
1005 QVector<KisUpdateInfoSP> infoObjects;
1006 KisUpdateInfoList originalInfoObjects;
1007 m_d->projectionUpdatesCompressor.takeUpdateInfo(originalInfoObjects);
1008
1009 for (auto it = originalInfoObjects.constBegin();
1010 it != originalInfoObjects.constEnd();
1011 ++it) {
1012
1013 KisUpdateInfoSP info = *it;
1014
1015 const KisMarkerUpdateInfo *batchInfo = dynamic_cast<const KisMarkerUpdateInfo*>(info.data());
1016 if (batchInfo) {
1017 if (!infoObjects.isEmpty()) {
1018 uploadData(infoObjects);
1019 infoObjects.clear();
1020 }
1021
1022 if (batchInfo->type() == KisMarkerUpdateInfo::StartBatch) {
1023 m_d->isBatchUpdateActive++;
1024 } else if (batchInfo->type() == KisMarkerUpdateInfo::EndBatch) {
1025 m_d->isBatchUpdateActive--;
1026 KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->isBatchUpdateActive >= 0);
1027 if (m_d->isBatchUpdateActive == 0) {
1028 shouldExplicitlyIssueUpdates = true;
1029 }
1030 } else if (batchInfo->type() == KisMarkerUpdateInfo::BlockLodUpdates) {
1031 m_d->canvasWidget->setLodResetInProgress(true);
1032 } else if (batchInfo->type() == KisMarkerUpdateInfo::UnblockLodUpdates) {
1033 m_d->canvasWidget->setLodResetInProgress(false);
1034 shouldExplicitlyIssueUpdates = true;
1035 }
1036 } else {
1037 infoObjects << info;
1038 }
1039 }
1040
1041 if (!infoObjects.isEmpty()) {
1042 uploadData(infoObjects);
1043 } else if (shouldExplicitlyIssueUpdates) {
1044 tryIssueCanvasUpdates(m_d->coordinatesConverter->imageRectInImagePixels());
1045 }
1046}

References KisMarkerUpdateInfo::BlockLodUpdates, KisSharedPtr< T >::data(), KisMarkerUpdateInfo::EndBatch, KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, slotDoCanvasUpdate(), KisMarkerUpdateInfo::StartBatch, KisMarkerUpdateInfo::type(), and KisMarkerUpdateInfo::UnblockLodUpdates.

◆ updateCanvasProjection [2/2]

void KisCanvas2::updateCanvasProjection ( const QRectF & docRect)
slot

Definition at line 1180 of file kis_canvas2.cpp.

1181{
1182 QRect widgetRect = m_d->docUpdateRectToWidget(docRect);
1183 if (!widgetRect.isEmpty()) {
1184 m_d->savedCanvasProjectionUpdateRect |= widgetRect;
1186 }
1187}

References m_d, and requestCanvasUpdateMaybeCompressed().

◆ updateCanvasRequested

void KisCanvas2::updateCanvasRequested ( const QRect & rc)
signal

◆ updateCanvasScene

void KisCanvas2::updateCanvasScene ( )
slot

Definition at line 1225 of file kis_canvas2.cpp.

1226{
1227 m_d->updateSceneRequested = true;
1229}

References m_d, and requestCanvasUpdateMaybeCompressed().

◆ updateCanvasToolOutlineDoc

void KisCanvas2::updateCanvasToolOutlineDoc ( const QRectF & docRect)
slot

Definition at line 1204 of file kis_canvas2.cpp.

1205{
1206 QRect widgetRect = m_d->docUpdateRectToWidget(docRect);
1207 if (!widgetRect.isEmpty()) {
1208 updateCanvasToolOutlineWdg(widgetRect);
1209 }
1210}
void updateCanvasToolOutlineWdg(const QRect &widgetRect)

References m_d, and updateCanvasToolOutlineWdg().

◆ updateCanvasToolOutlineWdg

void KisCanvas2::updateCanvasToolOutlineWdg ( const QRect & widgetRect)
slot

Definition at line 1212 of file kis_canvas2.cpp.

1213{
1214 QRect rect = widgetRect & m_d->canvasWidget->widget()->rect();
1215 if (!rect.isEmpty()) {
1216 m_d->savedOverlayUpdateRect |= rect;
1217#ifdef HAVE_NO_QT_UPDATE_COMPRESSIO
1218 m_d->canvasUpdateCompressor.start();
1219#else
1221#endif
1222 }
1223}

References m_d, and slotDoCanvasUpdate().

◆ updateCanvasWidgetImpl()

void KisCanvas2::updateCanvasWidgetImpl ( const QRect & rc = QRect())
private

Definition at line 1142 of file kis_canvas2.cpp.

1143{
1144 QRect rect = m_d->canvasWidget->widget()->rect();
1145 if (!rc.isEmpty()) {
1146 rect &= rc;
1147 if (rect.isEmpty()) {
1148 return;
1149 }
1150 }
1151 // We don't know if it's the canvas projection or the overlay that's
1152 // changed, so we update both.
1153 m_d->savedCanvasProjectionUpdateRect |= rect;
1154 m_d->savedOverlayUpdateRect |= rect;
1156}

References m_d, and requestCanvasUpdateMaybeCompressed().

◆ updateProofingState()

void KisCanvas2::updateProofingState ( )

Definition at line 888 of file kis_canvas2.cpp.

889{
890 KoColorConversionTransformation::ConversionFlags displayFlags = m_d->proofingConfig->displayFlags;
891 displayFlags.setFlag(KoColorConversionTransformation::SoftProofing, false);
892
893 if (image()->colorSpace()->colorDepthId().id().contains("U")) {
894 displayFlags.setFlag(KoColorConversionTransformation::SoftProofing, imageView()->softProofing());
895 displayFlags.setFlag(KoColorConversionTransformation::GamutCheck, imageView()->gamutCheck());
896 }
897 m_d->proofingConfig->displayFlags = displayFlags;
898 m_d->proofingConfigUpdated = true;
899
900 KIS_SAFE_ASSERT_RECOVER_RETURN(m_d->multiSurfaceState);
901 auto newState = m_d->multiSurfaceSetupManager.onProofingChanged(*m_d->multiSurfaceState, m_d->proofingConfig);
902 m_d->assignChangedMultiSurfaceState(newState);
903}

References KoColorConversionTransformation::GamutCheck, image(), imageView(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_d, and KoColorConversionTransformation::SoftProofing.

◆ viewConverter() [1/2]

const KoViewConverter * KisCanvas2::viewConverter ( ) const
overridevirtual

Return the viewConverter for this view.

Returns
the viewConverter for this view.

Implements KoCanvasBase.

Definition at line 594 of file kis_canvas2.cpp.

595{
596 return m_d->coordinatesConverter;
597}

References m_d.

◆ viewConverter() [2/2]

KoViewConverter * KisCanvas2::viewConverter ( )
overridevirtual

Implements KoCanvasBase.

Definition at line 599 of file kis_canvas2.cpp.

600{
601 return m_d->coordinatesConverter;
602}

References m_d.

◆ viewManager()

KisViewManager * KisCanvas2::viewManager ( ) const

Definition at line 1324 of file kis_canvas2.cpp.

1325{
1326 if (m_d->view) {
1327 return m_d->view->viewManager();
1328 }
1329 return 0;
1330}

References m_d.

◆ wrapAroundViewingMode()

bool KisCanvas2::wrapAroundViewingMode ( ) const

Definition at line 1551 of file kis_canvas2.cpp.

1552{
1553 return m_d->canvasWidget->wrapAroundViewingMode();
1554}

References m_d.

◆ wrapAroundViewingModeAxis()

WrapAroundAxis KisCanvas2::wrapAroundViewingModeAxis ( ) const

Definition at line 1562 of file kis_canvas2.cpp.

1563{
1564 return m_d->canvasWidget->wrapAroundViewingModeAxis();
1565}

References m_d.

◆ xAxisMirrored

bool KisCanvas2::xAxisMirrored ( ) const
slot

Bools indicating canvasmirroring.

Definition at line 518 of file kis_canvas2.cpp.

519{
520 return m_d->coordinatesConverter->xAxisMirrored();
521}

References m_d.

◆ yAxisMirrored

bool KisCanvas2::yAxisMirrored ( ) const
slot

Definition at line 523 of file kis_canvas2.cpp.

524{
525 return m_d->coordinatesConverter->yAxisMirrored();
526}

References m_d.

Friends And Related Symbol Documentation

◆ KisView

friend class KisView
friend

Definition at line 343 of file kis_canvas2.h.

Member Data Documentation

◆ animationPlayer

QScopedPointer<KisCanvasAnimationState> KisCanvas2::animationPlayer

Definition at line 211 of file kis_canvas2.cpp.

◆ bootstrapLodBlocked

bool KisCanvas2::bootstrapLodBlocked = false

Definition at line 214 of file kis_canvas2.cpp.

◆ canvasUpdateCompressor

KisSignalCompressor KisCanvas2::canvasUpdateCompressor

Definition at line 197 of file kis_canvas2.cpp.

◆ canvasWidget

const QWidget * KisCanvas2::canvasWidget = 0

Definition at line 188 of file kis_canvas2.cpp.

◆ channelFlags

QBitArray KisCanvas2::channelFlags

Definition at line 203 of file kis_canvas2.cpp.

◆ coordinatesConverter

const KisCoordinatesConverter * KisCanvas2::coordinatesConverter = 0

Definition at line 186 of file kis_canvas2.cpp.

◆ currentCanvasIsOpenGL

bool KisCanvas2::currentCanvasIsOpenGL = true

Definition at line 191 of file kis_canvas2.cpp.

◆ currentlyActiveShapeManager

QPointer<KoShapeManager> KisCanvas2::currentlyActiveShapeManager

Definition at line 215 of file kis_canvas2.cpp.

◆ displayColorConverter

KisDisplayColorConverter * KisCanvas2::displayColorConverter

Definition at line 208 of file kis_canvas2.cpp.

◆ frameCache

KisAnimationFrameCacheSP KisCanvas2::frameCache

Definition at line 212 of file kis_canvas2.cpp.

◆ frameRenderStartCompressor

KisSignalCompressor KisCanvas2::frameRenderStartCompressor

Definition at line 220 of file kis_canvas2.cpp.

◆ inputActionGroupsMask

KisInputActionGroupsMask KisCanvas2::inputActionGroupsMask = AllActionGroup

Definition at line 216 of file kis_canvas2.cpp.

◆ inputActionGroupsMaskInterface

KisInputActionGroupsMaskInterface::SharedInterface KisCanvas2::inputActionGroupsMaskInterface

Definition at line 218 of file kis_canvas2.cpp.

◆ isBatchUpdateActive

int KisCanvas2::isBatchUpdateActive = 0

Definition at line 228 of file kis_canvas2.cpp.

◆ lodPreferredInImage

bool KisCanvas2::lodPreferredInImage = false

Definition at line 213 of file kis_canvas2.cpp.

◆ m_d

KisCanvas2Private* const KisCanvas2::m_d
private

Definition at line 345 of file kis_canvas2.h.

◆ multiSurfaceSetupManager

KisMultiSurfaceStateManager KisCanvas2::multiSurfaceSetupManager

Definition at line 235 of file kis_canvas2.cpp.

◆ multiSurfaceState

std::optional<KisMultiSurfaceStateManager::State> KisCanvas2::multiSurfaceState

Definition at line 236 of file kis_canvas2.cpp.

◆ openGLFilterMode

KisOpenGL::FilterMode KisCanvas2::openGLFilterMode = 0

Definition at line 192 of file kis_canvas2.cpp.

◆ popupPalette

KisPopupPalette * KisCanvas2::popupPalette = 0

Definition at line 207 of file kis_canvas2.cpp.

◆ prescaledProjection

KisPrescaledProjectionSP KisCanvas2::prescaledProjection

Definition at line 194 of file kis_canvas2.cpp.

◆ projectionUpdatesCompressor

KisCanvasUpdatesCompressor KisCanvas2::projectionUpdatesCompressor

Definition at line 210 of file kis_canvas2.cpp.

◆ proofingConfig

KisProofingConfigurationSP KisCanvas2::proofingConfig

Definition at line 204 of file kis_canvas2.cpp.

◆ proofingConfigUpdated

bool KisCanvas2::proofingConfigUpdated = false

Definition at line 205 of file kis_canvas2.cpp.

◆ q

KisCanvas2* KisCanvas2::q = 0

Definition at line 185 of file kis_canvas2.cpp.

◆ referencesBoundsUpdateCompressor

KisSignalCompressor KisCanvas2::referencesBoundsUpdateCompressor

Definition at line 223 of file kis_canvas2.cpp.

◆ regionOfInterest

QRect KisCanvas2::regionOfInterest

Definition at line 224 of file kis_canvas2.cpp.

◆ regionOfInterestMargin

qreal KisCanvas2::regionOfInterestMargin = 0.25

Definition at line 225 of file kis_canvas2.cpp.

◆ regionOfInterestUpdateCompressor

KisSignalCompressor KisCanvas2::regionOfInterestUpdateCompressor

Definition at line 222 of file kis_canvas2.cpp.

◆ renderingLimit

QRect KisCanvas2::renderingLimit

Definition at line 227 of file kis_canvas2.cpp.

◆ savedCanvasProjectionUpdateRect

QRect KisCanvas2::savedCanvasProjectionUpdateRect

Definition at line 199 of file kis_canvas2.cpp.

◆ savedOverlayUpdateRect

QRect KisCanvas2::savedOverlayUpdateRect

Definition at line 200 of file kis_canvas2.cpp.

◆ selectedShapesProxy

KoSelectedShapesProxy * KisCanvas2::selectedShapesProxy

Definition at line 190 of file kis_canvas2.cpp.

◆ shapeManager

KoShapeManager * KisCanvas2::shapeManager

Definition at line 189 of file kis_canvas2.cpp.

◆ toolProxy

KoToolProxy * KisCanvas2::toolProxy

Definition at line 193 of file kis_canvas2.cpp.

◆ updateSceneRequested

bool KisCanvas2::updateSceneRequested = false

Definition at line 201 of file kis_canvas2.cpp.

◆ view

QPointer<KisView> KisCanvas2::view

Definition at line 187 of file kis_canvas2.cpp.


The documentation for this class was generated from the following files: