summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElvis Lee <kwangwoong.lee@lge.com>2012-07-31 18:46:14 +0900
committerLaszlo Agocs <laszlo.p.agocs@nokia.com>2012-07-31 11:51:55 +0200
commit5b2ffd10e85af5860248ee761255721cb3675b40 (patch)
tree6aedbee6644775fc65f061fef0cb6a27a09ca33a
parent70f5d1d20f0568d5a67f7fa9f14be582c17a039d (diff)
downloadqtwayland-5b2ffd10e85af5860248ee761255721cb3675b40.tar.gz
qtwayland-5b2ffd10e85af5860248ee761255721cb3675b40.tar.bz2
qtwayland-5b2ffd10e85af5860248ee761255721cb3675b40.zip
Correct background's coordinates
Background has been rendered from (0, 0), so it didn't reprensent boundary of qwindowcompositor correctly when using -nofullscreen. And make background'size equal to window size on constructing. Change-Id: I2bcdc350c1e8ebccdb19c69211afecf5d59000ea Reviewed-by: Laszlo Agocs <laszlo.p.agocs@nokia.com>
-rw-r--r--examples/qwindow-compositor/qwindowcompositor.cpp33
-rw-r--r--examples/qwindow-compositor/qwindowcompositor.h1
2 files changed, 25 insertions, 9 deletions
diff --git a/examples/qwindow-compositor/qwindowcompositor.cpp b/examples/qwindow-compositor/qwindowcompositor.cpp
index c30aba3..b30c86d 100644
--- a/examples/qwindow-compositor/qwindowcompositor.cpp
+++ b/examples/qwindow-compositor/qwindowcompositor.cpp
@@ -49,6 +49,7 @@
#include <QPixmap>
#include <QLinkedList>
#include <QScreen>
+#include <QPainter>
#include <QtCompositor/waylandinput.h>
@@ -66,7 +67,7 @@ QWindowCompositor::QWindowCompositor(QOpenGLWindow *window)
m_textureCache = new QOpenGLTextureCache(m_window->context());
m_textureBlitter = new TextureBlitter();
- m_backgroundImage = QImage(QLatin1String(":/background.jpg"));
+ m_backgroundImage = makeBackgroundImage(QLatin1String(":/background.jpg"));
m_renderScheduler.setSingleShot(true);
connect(&m_renderScheduler,SIGNAL(timeout()),this,SLOT(render()));
@@ -87,6 +88,27 @@ QWindowCompositor::~QWindowCompositor()
delete m_textureCache;
}
+
+QImage QWindowCompositor::makeBackgroundImage(const QString &fileName)
+{
+ Q_ASSERT(m_window);
+
+ int width = m_window->width();
+ int height = m_window->height();
+ QImage baseImage(fileName);
+ QImage patternedBackground(width, height, baseImage.format());
+ QPainter painter(&patternedBackground);
+
+ QSize imageSize = baseImage.size();
+ for (int y = 0; y < height; y += imageSize.height()) {
+ for (int x = 0; x < width; x += imageSize.width()) {
+ painter.drawImage(x, y, baseImage);
+ }
+ }
+
+ return patternedBackground;
+}
+
void QWindowCompositor::ensureKeyboardFocusSurface(WaylandSurface *oldSurface)
{
WaylandSurface *kbdFocus = defaultInputDevice()->keyboardFocus();
@@ -246,14 +268,7 @@ void QWindowCompositor::render()
m_textureBlitter->bind();
//Draw the background Image texture
- int w = m_window->width();
- int h = m_window->height();
- QSize imageSize = m_backgroundImage.size();
- for (int y = 0; y < h; y += imageSize.height()) {
- for (int x = 0; x < w; x += imageSize.width()) {
- m_textureBlitter->drawTexture(m_backgroundTexture,QRect(QPoint(x, y),imageSize),window()->size(), 0,true,true);
- }
- }
+ m_textureBlitter->drawTexture(m_backgroundTexture, window()->geometry(), window()->size(), 0, true, true);
foreach (WaylandSurface *surface, m_surfaces) {
GLuint texture = composeSurface(surface);
diff --git a/examples/qwindow-compositor/qwindowcompositor.h b/examples/qwindow-compositor/qwindowcompositor.h
index 2efc095..ad1aae0 100644
--- a/examples/qwindow-compositor/qwindowcompositor.h
+++ b/examples/qwindow-compositor/qwindowcompositor.h
@@ -80,6 +80,7 @@ protected:
void changeCursor(const QImage &image, int hotspotX, int hotspotY);
void ensureKeyboardFocusSurface(WaylandSurface *oldSurface);
+ QImage makeBackgroundImage(const QString &fileName);
private slots:
void sendExpose();