File indexing completed on 2024-12-22 04:12:46
0001 /* 0002 * SPDX-FileCopyrightText: 2006 Boudewijn Rempt <boud@valdyas.org> 0003 * SPDX-FileCopyrightText: 2015 Michael Abrahams <miabraha@gmail.com> 0004 * 0005 * SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 0008 #ifndef KIS_OPENGL_CANVAS_2_H 0009 #define KIS_OPENGL_CANVAS_2_H 0010 0011 #include <QOpenGLWidget> 0012 #include "canvas/kis_canvas_widget_base.h" 0013 #include "opengl/kis_opengl_image_textures.h" 0014 0015 #include "kritaui_export.h" 0016 #include "kis_ui_types.h" 0017 0018 class KisCanvas2; 0019 class KisDisplayColorConverter; 0020 class QOpenGLShaderProgram; 0021 class QPainterPath; 0022 class KisOptimizedBrushOutline; 0023 0024 /** 0025 * KisOpenGLCanvas is the widget that shows the actual image using OpenGL 0026 * 0027 * NOTE: if you change something in the event handling here, also change it 0028 * in the qpainter canvas. 0029 * 0030 */ 0031 class KRITAUI_EXPORT KisOpenGLCanvas2 0032 : public QOpenGLWidget 0033 , public KisCanvasWidgetBase 0034 { 0035 Q_OBJECT 0036 0037 public: 0038 0039 KisOpenGLCanvas2(KisCanvas2 *canvas, KisCoordinatesConverter *coordinatesConverter, QWidget *parent, KisImageWSP image, KisDisplayColorConverter *colorConverter); 0040 0041 ~KisOpenGLCanvas2() override; 0042 0043 public: // QOpenGLWidget 0044 0045 void resizeGL(int width, int height) override; 0046 void initializeGL() override; 0047 void paintGL() override; 0048 void paintEvent(QPaintEvent *e) override; 0049 0050 QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; 0051 void inputMethodEvent(QInputMethodEvent *event) override; 0052 0053 void focusInEvent(QFocusEvent *event) override; 0054 void focusOutEvent(QFocusEvent *event) override; 0055 0056 void hideEvent(QHideEvent *event) override; 0057 void showEvent(QShowEvent *event) override; 0058 0059 public: 0060 void paintToolOutline(const KisOptimizedBrushOutline &path, int thickness = 1); 0061 0062 0063 public: // Implement kis_abstract_canvas_widget interface 0064 void setDisplayFilter(QSharedPointer<KisDisplayFilter> displayFilter) override; 0065 void notifyImageColorSpaceChanged(const KoColorSpace *cs) override; 0066 0067 void setWrapAroundViewingMode(bool value) override; 0068 bool wrapAroundViewingMode() const override; 0069 void setWrapAroundViewingModeAxis(WrapAroundAxis value) override; 0070 WrapAroundAxis wrapAroundViewingModeAxis() const override; 0071 0072 void channelSelectionChanged(const QBitArray &channelFlags) override; 0073 void setDisplayColorConverter(KisDisplayColorConverter *colorConverter) override; 0074 void finishResizingImage(qint32 w, qint32 h) override; 0075 KisUpdateInfoSP startUpdateCanvasProjection(const QRect & rc) override; 0076 QRect updateCanvasProjection(KisUpdateInfoSP info) override; 0077 QVector<QRect> updateCanvasProjection(const QVector<KisUpdateInfoSP> &infoObjects) override; 0078 void updateCanvasImage(const QRect &imageUpdateRect) override; 0079 void updateCanvasDecorations(const QRect &decoUpdateRect) override; 0080 0081 0082 QWidget *widget() override { 0083 return this; 0084 } 0085 0086 bool isBusy() const override; 0087 void setLodResetInProgress(bool value) override; 0088 0089 KisOpenGLImageTexturesSP openGLImageTextures() const; 0090 0091 public Q_SLOTS: 0092 void slotConfigChanged(); 0093 void slotPixelGridModeChanged(); 0094 void slotUpdateCursorColor(); 0095 0096 private Q_SLOTS: 0097 void slotShowFloatingMessage(const QString &message, int timeout, bool priority); 0098 0099 protected: // KisCanvasWidgetBase 0100 bool callFocusNextPrevChild(bool next) override; 0101 0102 private: 0103 struct Private; 0104 Private * const d; 0105 0106 class CanvasBridge; 0107 }; 0108 0109 #endif // KIS_OPENGL_CANVAS_2_H