8#define GL_GLEXT_PROTOTYPES
30#include "config-qt-patches-present.h"
52 return m_canvas->devicePixelRatioF();
73#if KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
74 bool shouldSkipRenderingPass =
false;
89 : QOpenGLWidget(parent)
93 setProperty(
"krita_skip_srgb_surface_manager_assignment",
true);
102 SIGNAL(sigShowFloatingMessage(QString,
int,
bool)),
105 setAcceptDrops(
true);
106 setAutoFillBackground(
false);
108 setFocusPolicy(Qt::StrongFocus);
109 setAttribute(Qt::WA_NoSystemBackground,
true);
111 setAttribute(Qt::WA_AcceptTouchEvents,
false);
113 setAttribute(Qt::WA_AcceptTouchEvents,
true);
115 setAttribute(Qt::WA_InputMethodEnabled,
true);
116 setAttribute(Qt::WA_DontCreateNativeAncestors,
true);
120 if (useNativeSurfaceForCanvas) {
121 setAttribute(Qt::WA_NativeWindow,
true);
124 setUpdateBehavior(PartialUpdate);
129 setTextureFormat(GL_RGBA16F);
132 if (QSurfaceFormat::defaultFormat().redBufferSize() < 10) {
134 "WARNING: KisOpenGLCanvas2 was created with a 10-bit surface, "
135 "while the global surface format is still set to 8-bit. Expect "
136 "color banding to appear";
138 setTextureFormat(GL_RGB10_A2);
150 setTextureFormat(GL_RGB8);
163 cfg.
writeEntry(
"canvasState",
"OPENGL_SUCCESS");
188 KisOpenGLContextSwitchLockSkipOnQt5 contextLock(
this);
194 KisOpenGLContextSwitchLockSkipOnQt5 contextLock(
this);
234#if KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
235 if (
d->shouldSkipRenderingPass) {
244 cfg.
writeEntry(
"canvasState",
"OPENGL_PAINT_STARTED");
253 if (!updateRect.isEmpty()) {
254 gc.setClipRect(updateRect);
259 if (!updateRect.isEmpty()) {
260 decorationsBoundingRect &= updateRect;
277 cfg.
writeEntry(
"canvasState",
"OPENGL_SUCCESS");
286 if (
qFuzzyCompare(devicePixelRatioF(), qRound(devicePixelRatioF()))) {
299#if KRITA_QT_HAS_UPDATE_COMPRESSION_PATCH
307 d->shouldSkipRenderingPass =
true;
308 QOpenGLWidget::paintEvent(e);
309 d->shouldSkipRenderingPass =
false;
310 QTimer::singleShot(0,
this,
312 if (updateRect.isEmpty()) {
315 this->update(updateRect);
321 QOpenGLWidget::paintEvent(e);
324 d->updateRect = boost::none;
400 QOpenGLWidget::hideEvent(e);
406 QOpenGLWidget::showEvent(e);
412 KisOpenGLContextSwitchLockSkipOnQt5 contextLock(
this);
424 KisOpenGLContextSwitchLockSkipOnQt5 contextLock(
this);
441 KisOpenGLContextSwitchLockSkipOnQt5 contextLock(
this);
448 update(imageUpdateRect);
453 update(decoUpdateRect);
457 return focusNextPrevChild(next);
468 textureFormat() == GL_RGB10_A2 &&
469 format().redBufferSize() == 10 &&
470 format().greenBufferSize() == 10 &&
471 format().blueBufferSize() == 10 ?
480 str <<
"Texture Format: " << Qt::hex << Qt::showbase << textureFormat() << Qt::reset;
482 switch (textureFormat()) {
484 str <<
" (" <<
"GL_RGB10_A2" <<
")";
489 str <<
" (" <<
"GL_RGB10" <<
")";
495 str <<
" (" <<
"GL_RGB12" <<
")";
501 str <<
" (" <<
"GL_RGBA16" <<
")";
507 str <<
" (" <<
"GL_RGB16" <<
")";
511 str <<
" (" <<
"GL_RGBA16F" <<
")";
514 str <<
" (" <<
"GL_RGB8" <<
")";
517 str <<
" (" <<
"GL_RGBA8" <<
")";
520 str <<
" (" <<
"<unknown>" <<
")";
525 str <<
"FBO Buffer Size: "
526 <<
"R: " << format().redBufferSize() <<
" "
527 <<
"G: " << format().greenBufferSize() <<
" "
528 <<
"B: " << format().blueBufferSize() <<
" "
529 <<
"A: " << format().alphaBufferSize() << Qt::endl;
531 QWindow *win = windowHandle();
533 str <<
"Window Buffer Size: "
534 <<
"R: " << win->format().redBufferSize() <<
" "
535 <<
"G: " << win->format().greenBufferSize() <<
" "
536 <<
"B: " << win->format().blueBufferSize() <<
" "
537 <<
"A: " << win->format().alphaBufferSize() << Qt::endl;
541 str <<
"Global Buffer Size: "
542 <<
"R: " << QSurfaceFormat::defaultFormat().redBufferSize() <<
" "
543 <<
"G: " << QSurfaceFormat::defaultFormat().greenBufferSize() <<
" "
544 <<
"B: " << QSurfaceFormat::defaultFormat().blueBufferSize() <<
" "
545 <<
"A: " << QSurfaceFormat::defaultFormat().alphaBufferSize() << Qt::endl;
float value(const T *src, size_t ch)
KisViewManager * viewManager() const
QPointer< KisView > imageView() const
static KisConfigNotifier * instance()
void setCanvasState(const QString &state) const
void writeEntry(const QString &name, const T &value)
bool effectiveShouldUseNativeSurfaceForCanvas(bool osManagedSurfacePresent) const
QRectF imageRectInWidgetPixels() const
KisDisplayConfig This class keeps track of the color management configuration for image to display....
static constexpr char ENABLED_PROPERTY[]
QColor borderColor() const override
CanvasBridge(KisOpenGLCanvas2 *canvas)
KisCanvas2 * canvas() const override
qreal devicePixelRatioF() const override
GLenum internalTextureFormat() const override
QOpenGLContext * openglContext() const override
KisCoordinatesConverter * coordinatesConverter() const override
~CanvasBridge() override=default
KisOpenGLCanvas2 * m_canvas
void showEvent(QShowEvent *event) override
void initializeGL() override
QString currentBitDepthUserReport() const override
BitDepthMode currentBitDepthMode() const override
void setDisplayConfig(const KisDisplayConfig &config) override
void setDisplayFilter(QSharedPointer< KisDisplayFilter > displayFilter) override
set the specified display filter on the canvas
void updateCanvasDecorations(const QRect &decoUpdateRect) override
void slotShowFloatingMessage(const QString &message, int timeout, bool priority)
void notifyImageColorSpaceChanged(const KoColorSpace *cs) override
set/update the color space of the attached image
bool wrapAroundViewingMode() const override
void inputMethodEvent(QInputMethodEvent *event) override
QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
void slotPixelGridModeChanged()
KisUpdateInfoSP startUpdateCanvasProjection(const QRect &rc) override
void setLodResetInProgress(bool value) override
void updateCanvasImage(const QRect &imageUpdateRect) override
bool isBusy() const override
KisOpenGLImageTexturesSP openGLImageTextures() const
void channelSelectionChanged(const QBitArray &channelFlags) override
void slotUpdateCursorColor()
void hideEvent(QHideEvent *event) override
KisOpenGLCanvas2(KisCanvas2 *canvas, KisCoordinatesConverter *coordinatesConverter, QWidget *parent, KisImageWSP image, const KisDisplayConfig &displayConfig, QSharedPointer< KisDisplayFilter > displayFilter, BitDepthMode bitDepthRequest)
void paintToolOutline(const KisOptimizedBrushOutline &path, int thickness=1)
QRect updateCanvasProjection(KisUpdateInfoSP info) override
void setWrapAroundViewingMode(bool value) override
void focusOutEvent(QFocusEvent *event) override
void resizeGL(int width, int height) override
void focusInEvent(QFocusEvent *event) override
WrapAroundAxis wrapAroundViewingModeAxis() const override
void setWrapAroundViewingModeAxis(WrapAroundAxis value) override
void paintEvent(QPaintEvent *e) override
bool callFocusNextPrevChild(bool next) override
To be implemented by the derived canvas.
void finishResizingImage(qint32 w, qint32 h) override
~KisOpenGLCanvas2() override
QRect updateCanvasProjection(KisUpdateInfoSP info)
void setDisplayFilter(QSharedPointer< KisDisplayFilter > displayFilter)
void resizeGL(int width, int height)
KisOpenGLImageTexturesSP openGLImageTextures() const
void channelSelectionChanged(const QBitArray &channelFlags)
KisUpdateInfoSP startUpdateCanvasProjection(const QRect &rc)
void paintCanvasOnly(const QRect &canvasImageDirtyRect, const QRect &viewportUpdateRect=QRect())
void setLodResetInProgress(bool value)
void setDisplayConfig(const KisDisplayConfig &config)
WrapAroundAxis wrapAroundViewingModeAxis() const
void setWrapAroundViewingModeAxis(WrapAroundAxis value)
bool wrapAroundViewingMode() const
void updatePixelGridMode()
void finishResizingImage(qint32 w, qint32 h)
void paintToolOutline(const KisOptimizedBrushOutline &path, const QRect &viewportUpdateRect, const int thickness=1)
void setWrapAroundViewingMode(bool value)
void notifyImageColorSpaceChanged(const KoColorSpace *cs)
static KisOpenGLModeProber * instance()
static void init(QOpenGLContext *ctx)
static bool hasOpenGLES()
void notifyPaintRequested()
static KisOpenglCanvasDebugger * instance()
void notifySyncStatus(bool value)
void paint(QPaintDevice *paintDevice, const QRect &widgetRect)
KisCanvasResourceProvider * canvasResourceProvider()
static bool qFuzzyCompare(half p1, half p2)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
static bool OPENGL_SUCCESS
boost::optional< QRect > updateRect
KisRepaintDebugger repaintDbg
QScopedPointer< KisOpenGLSync > glSyncObject
QRect canvasImageDirtyRect
KisOpenGLCanvasRenderer * renderer