Changeset View
Changeset View
Standalone View
Standalone View
libs/ui/canvas/kis_canvas2.cpp
Context not available. | |||||
532 | KisConfig cfg(true); | 532 | KisConfig cfg(true); | ||
---|---|---|---|---|---|
533 | QDesktopWidget dw; | 533 | QDesktopWidget dw; | ||
534 | const KoColorProfile *profile = cfg.displayProfile(dw.screenNumber(imageView())); | 534 | const KoColorProfile *profile = cfg.displayProfile(dw.screenNumber(imageView())); | ||
535 | m_d->displayColorConverter.notifyOpenGLCanvasIsActive(useOpenGL && KisOpenGL::hasOpenGL()); | ||||
535 | m_d->displayColorConverter.setMonitorProfile(profile); | 536 | m_d->displayColorConverter.setMonitorProfile(profile); | ||
536 | 537 | | |||
538 | if (useOpenGL && !KisOpenGL::hasOpenGL()) { | ||||
539 | warnKrita << "Tried to create OpenGL widget when system doesn't have OpenGL\n"; | ||||
540 | useOpenGL = false; | ||||
541 | } | ||||
542 | | ||||
543 | m_d->displayColorConverter.notifyOpenGLCanvasIsActive(useOpenGL); | ||||
544 | | ||||
537 | if (useOpenGL) { | 545 | if (useOpenGL) { | ||
538 | if (KisOpenGL::hasOpenGL()) { | 546 | createOpenGLCanvas(); | ||
539 | createOpenGLCanvas(); | 547 | if (cfg.canvasState() == "OPENGL_FAILED") { | ||
540 | if (cfg.canvasState() == "OPENGL_FAILED") { | 548 | // Creating the opengl canvas failed, fall back | ||
541 | // Creating the opengl canvas failed, fall back | 549 | warnKrita << "OpenGL Canvas initialization returned OPENGL_FAILED. Falling back to QPainter."; | ||
542 | warnKrita << "OpenGL Canvas initialization returned OPENGL_FAILED. Falling back to QPainter."; | 550 | m_d->displayColorConverter.notifyOpenGLCanvasIsActive(false); | ||
543 | createQPainterCanvas(); | | |||
544 | } | | |||
545 | } else { | | |||
546 | warnKrita << "Tried to create OpenGL widget when system doesn't have OpenGL\n"; | | |||
547 | createQPainterCanvas(); | 551 | createQPainterCanvas(); | ||
548 | } | 552 | } | ||
549 | } | 553 | } else { | ||
550 | else { | | |||
551 | createQPainterCanvas(); | 554 | createQPainterCanvas(); | ||
552 | } | 555 | } | ||
553 | 556 | | |||
Context not available. | |||||
561 | { | 564 | { | ||
562 | KisImageSP image = m_d->view->image(); | 565 | KisImageSP image = m_d->view->image(); | ||
563 | 566 | | |||
567 | m_d->displayColorConverter.setImageColorSpace(image->colorSpace()); | ||||
564 | m_d->coordinatesConverter->setImage(image); | 568 | m_d->coordinatesConverter->setImage(image); | ||
565 | m_d->toolProxy.initializeImage(image); | 569 | m_d->toolProxy.initializeImage(image); | ||
566 | 570 | | |||
Context not available. | |||||
573 | connect(image, SIGNAL(sigSizeChanged(QPointF,QPointF)), SLOT(startResizingImage()), Qt::DirectConnection); | 577 | connect(image, SIGNAL(sigSizeChanged(QPointF,QPointF)), SLOT(startResizingImage()), Qt::DirectConnection); | ||
574 | connect(image->undoAdapter(), SIGNAL(selectionChanged()), SLOT(slotTrySwitchShapeManager())); | 578 | connect(image->undoAdapter(), SIGNAL(selectionChanged()), SLOT(slotTrySwitchShapeManager())); | ||
575 | 579 | | |||
580 | connect(image, SIGNAL(sigColorSpaceChanged(const KoColorSpace*)), SLOT(slotImageColorSpaceChanged())); | ||||
581 | connect(image, SIGNAL(sigProfileChanged(const KoColorProfile*)), SLOT(slotImageColorSpaceChanged())); | ||||
582 | | ||||
576 | connectCurrentCanvas(); | 583 | connectCurrentCanvas(); | ||
577 | } | 584 | } | ||
578 | 585 | | |||
Context not available. | |||||
613 | 620 | | |||
614 | void KisCanvas2::startUpdateInPatches(const QRect &imageRect) | 621 | void KisCanvas2::startUpdateInPatches(const QRect &imageRect) | ||
615 | { | 622 | { | ||
623 | /** | ||||
624 | * We don't do patched loading for openGL canvas, becasue it loads | ||||
625 | * the tiles, which are bascially "patches". Therefore, big chunks | ||||
626 | * of memory are never allocated. | ||||
627 | */ | ||||
616 | if (m_d->currentCanvasIsOpenGL) { | 628 | if (m_d->currentCanvasIsOpenGL) { | ||
617 | startUpdateCanvasProjection(imageRect); | 629 | startUpdateCanvasProjection(imageRect); | ||
618 | } else { | 630 | } else { | ||
Context not available. | |||||
646 | return m_d->displayColorConverter.displayFilter(); | 658 | return m_d->displayColorConverter.displayFilter(); | ||
647 | } | 659 | } | ||
648 | 660 | | |||
661 | void KisCanvas2::slotImageColorSpaceChanged() | ||||
662 | { | ||||
663 | KisImageSP image = this->image(); | ||||
664 | | ||||
665 | m_d->view->viewManager()->blockUntilOperationsFinishedForced(image); | ||||
666 | | ||||
667 | m_d->displayColorConverter.setImageColorSpace(image->colorSpace()); | ||||
668 | | ||||
669 | image->barrierLock(); | ||||
670 | m_d->canvasWidget->notifyImageColorSpaceChanged(image->colorSpace()); | ||||
671 | image->unlock(); | ||||
672 | } | ||||
673 | | ||||
649 | KisDisplayColorConverter* KisCanvas2::displayColorConverter() const | 674 | KisDisplayColorConverter* KisCanvas2::displayColorConverter() const | ||
650 | { | 675 | { | ||
651 | return &m_d->displayColorConverter; | 676 | return &m_d->displayColorConverter; | ||
Context not available. | |||||
1048 | m_d->vastScrolling = cfg.vastScrolling(); | 1073 | m_d->vastScrolling = cfg.vastScrolling(); | ||
1049 | 1074 | | |||
1050 | resetCanvas(cfg.useOpenGL()); | 1075 | resetCanvas(cfg.useOpenGL()); | ||
1051 | slotSetDisplayProfile(cfg.displayProfile(QApplication::desktop()->screenNumber(this->canvasWidget()))); | 1076 | setDisplayProfile(cfg.displayProfile(QApplication::desktop()->screenNumber(this->canvasWidget()))); | ||
1052 | 1077 | | |||
1053 | initializeFpsDecoration(); | 1078 | initializeFpsDecoration(); | ||
1054 | } | 1079 | } | ||
Context not available. | |||||
1060 | startUpdateInPatches(image->bounds()); | 1085 | startUpdateInPatches(image->bounds()); | ||
1061 | } | 1086 | } | ||
1062 | 1087 | | |||
1063 | void KisCanvas2::slotSetDisplayProfile(const KoColorProfile *monitorProfile) | 1088 | void KisCanvas2::setDisplayProfile(const KoColorProfile *monitorProfile) | ||
1064 | { | 1089 | { | ||
1065 | if (m_d->displayColorConverter.monitorProfile() == monitorProfile) return; | 1090 | if (m_d->displayColorConverter.monitorProfile() == monitorProfile) return; | ||
1066 | 1091 | | |||
Context not available. | |||||
1069 | { | 1094 | { | ||
1070 | KisImageSP image = this->image(); | 1095 | KisImageSP image = this->image(); | ||
1071 | KisImageBarrierLocker l(image); | 1096 | KisImageBarrierLocker l(image); | ||
1072 | m_d->canvasWidget->setDisplayProfile(&m_d->displayColorConverter); | 1097 | m_d->canvasWidget->setDisplayColorConverter(&m_d->displayColorConverter); | ||
1073 | } | 1098 | } | ||
1074 | 1099 | | |||
1075 | refetchDataFromImage(); | 1100 | refetchDataFromImage(); | ||
Context not available. |