summaryrefslogtreecommitdiffstats
path: root/chalk/ui/kis_opengl_image_context.h
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-26 00:41:16 +0000
commit698569f8428ca088f764d704034a1330517b98c0 (patch)
treebf45be6946ebbbee9cce5a5bcf838f4c952d87e6 /chalk/ui/kis_opengl_image_context.h
parent2785103a6bd4de55bd26d79e34d0fdd4b329a73a (diff)
downloadkoffice-698569f8428ca088f764d704034a1330517b98c0.tar.gz
koffice-698569f8428ca088f764d704034a1330517b98c0.zip
Finish rebranding of Krita as Chalk
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1238363 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'chalk/ui/kis_opengl_image_context.h')
-rw-r--r--chalk/ui/kis_opengl_image_context.h157
1 files changed, 157 insertions, 0 deletions
diff --git a/chalk/ui/kis_opengl_image_context.h b/chalk/ui/kis_opengl_image_context.h
new file mode 100644
index 00000000..03833cd2
--- /dev/null
+++ b/chalk/ui/kis_opengl_image_context.h
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2005 Adrian Page <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+#ifndef KIS_OPENGL_IMAGE_CONTEXT_H_
+#define KIS_OPENGL_IMAGE_CONTEXT_H_
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_GL
+
+#include <map>
+
+#include <tqgl.h>
+#include <tqobject.h>
+#include <tqvaluevector.h>
+
+#include <koffice_export.h>
+
+#include "kis_types.h"
+
+class TQRegion;
+
+class KisOpenGLImageContext;
+typedef KSharedPtr<KisOpenGLImageContext> KisOpenGLImageContextSP;
+class KisColorSpace;
+
+class KRITACORE_EXPORT KisOpenGLImageContext : public TQObject , public KShared {
+
+ Q_OBJECT
+ TQ_OBJECT
+
+public:
+ static KisOpenGLImageContextSP getImageContext(KisImageSP image, KisProfile *monitorProfile);
+
+ KisOpenGLImageContext();
+ virtual ~KisOpenGLImageContext();
+
+public:
+ // In order to use the image textures, the caller must pass
+ // the sharedContextWidget() as the shareWidget argument to the
+ // TQGLWidget constructor.
+ TQGLWidget *sharedContextWidget() const;
+
+ void setMonitorProfile(KisProfile *profile);
+ void setHDRExposure(float exposure);
+
+ GLuint backgroundTexture() const;
+
+ static const int BACKGROUND_TEXTURE_WIDTH = 32;
+ static const int BACKGROUND_TEXTURE_HEIGHT = 32;
+
+ // Get the image texture tile containing the point (pixelX, pixelY).
+ GLuint imageTextureTile(int pixelX, int pixelY) const;
+
+ int imageTextureTileWidth() const;
+ int imageTextureTileHeight() const;
+
+ /**
+ * Select selection visualisation rendering.
+ *
+ * @param enable Set to true to enable selection visualisation rendering.
+ */
+ void setSelectionDisplayEnabled(bool enable);
+
+ /**
+ * Update the image textures for the given image rectangle.
+ *
+ * @param imageRect The rectangle to update in image coordinates.
+ */
+ void update(const TQRect& imageRect);
+
+signals:
+ /**
+ * Clients using the KisOpenGLImageContext should connect to the
+ * following signals rather than to the KisImage's own equivalent
+ * signals. This ensures that the image textures are always up to date
+ * when used.
+ */
+
+ /**
+ * Emitted whenever an action has caused the image to be recomposited.
+ *
+ * @param rc The rect that has been recomposited.
+ */
+ void sigImageUpdated(TQRect rc);
+
+ /**
+ * Emitted whenever the image size changes.
+ *
+ * @param width New image width
+ * @param height New image height
+ */
+ void sigSizeChanged(TQ_INT32 width, TQ_INT32 height);
+
+protected:
+ KisOpenGLImageContext(KisImageSP image, KisProfile *monitorProfile);
+
+ void generateBackgroundTexture();
+ void createImageTextureTiles();
+ void destroyImageTextureTiles();
+ int imageTextureTileIndex(int x, int y) const;
+ void updateImageTextureTiles(const TQRect& rect);
+
+ static KisColorSpace* textureColorSpaceForImageColorSpace(KisColorSpace *imageColorSpace);
+ static bool imageCanShareImageContext(KisImageSP image);
+
+protected slots:
+ void slotImageUpdated(TQRect r);
+ void slotImageSizeChanged(TQ_INT32 w, TQ_INT32 h);
+
+private:
+ KisImageSP m_image;
+ KisProfile *m_monitorProfile;
+ float m_exposure;
+ bool m_displaySelection;
+
+ GLuint m_backgroundTexture;
+
+ static const int PREFERRED_IMAGE_TEXTURE_WIDTH = 256;
+ static const int PREFERRED_IMAGE_TEXTURE_HEIGHT = 256;
+
+ TQValueVector<GLuint> m_imageTextureTiles;
+ int m_imageTextureTileWidth;
+ int m_imageTextureTileHeight;
+ int m_numImageTextureTileColumns;
+
+ // We create a single OpenGL context and share it between all views
+ // in the process. Aptqparently with some OpenGL implementations, only
+ // one context will be hardware accelerated.
+ static TQGLWidget *SharedContextWidget;
+ static int SharedContextWidgetRefCount;
+
+ typedef std::map<KisImageSP, KisOpenGLImageContext*> ImageContextMap;
+
+ static ImageContextMap imageContextMap;
+};
+
+#endif // HAVE_GL
+
+#endif // KIS_OPENGL_IMAGE_CONTEXT_H_
+