VIGS: bind multitouch points to window coordinates
authorMunkyu Im <munkyu.im@samsung.com>
Mon, 29 Jun 2015 08:45:46 +0000 (17:45 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 1 Jul 2015 05:35:33 +0000 (14:35 +0900)
It seems a better solution than using guest coordinates
since we no more need to take any special care about
preserving mt points size (i.e. scaling/rotation stuff).

Change-Id: I35243954dc9ac1e189c7eed9beec29e80d67dd0c
Signed-off-by: Munkyu Im <munkyu.im@samsung.com>
Signed-off-by: Vasiliy Ulyanov <v.ulyanov@samsung.com>
hw/vigs/vigs_gl_backend.c
hw/vigs/vigs_gl_backend.h
tizen/src/ui/input/multitouchtracker.cpp

index c2e67b7..efe89c2 100644 (file)
@@ -2450,12 +2450,10 @@ static bool vigs_gl_backend_display(struct vigs_backend *backend,
         vigs_vector_resize(&gl_backend->dpy_v2, 0);
 
         for (i = 0; i < mt_count; i++) {
-            GLfloat w = (GLfloat)gl_backend->mt_tex_width *
-                        ((GLfloat)gl_backend->dpy_tex_width / (GLfloat)qt5_window_width);
-            GLfloat h = (GLfloat)gl_backend->mt_tex_height *
-                        ((GLfloat)gl_backend->dpy_tex_height / (GLfloat)qt5_window_height);
+            GLfloat w = (GLfloat)gl_backend->mt_tex_width;
+            GLfloat h = (GLfloat)gl_backend->mt_tex_height;
             GLfloat x = qt5_mt_points[2 * i + 0] - w / 2;
-            GLfloat y = gl_backend->dpy_tex_height - qt5_mt_points[2 * i + 1] - h / 2;
+            GLfloat y = qt5_window_height - qt5_mt_points[2 * i + 1] - h / 2;
 
             vert_coords = vigs_vector_append(&gl_backend->dpy_v1,
                                              (12 * sizeof(GLfloat)));
@@ -2482,14 +2480,20 @@ static bool vigs_gl_backend_display(struct vigs_backend *backend,
         }
 
         if (mt_count) {
+            vigs_gl_create_ortho(0.0f, qt5_window_width,
+                                 0.0f, qt5_window_height,
+                                 -1.0f, 1.0f,
+                                 gl_backend->mt_tex_ortho);
+
             gl_backend->Enable(GL_BLEND);
             gl_backend->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
 
-            if (scale) {
-                vigs_gl_draw_dpy_scale_prog(gl_backend, mt_count * 6);
-            } else {
-                vigs_gl_draw_dpy_tex_prog(gl_backend, mt_count * 6);
-            }
+            gl_backend->UseProgram(gl_backend->dpy_tex_prog_id);
+            gl_backend->UniformMatrix4fv(gl_backend->dpy_tex_prog_proj_loc, 1, GL_FALSE,
+                                         gl_backend->mt_tex_ortho);
+            gl_backend->Uniform1f(gl_backend->dpy_tex_prog_brightness_loc, 1.0f);
+
+            vigs_gl_draw_dpy_tex_prog(gl_backend, mt_count * 6);
 
             gl_backend->Disable(GL_BLEND);
         }
index 638cf5e..dca456b 100644 (file)
@@ -253,6 +253,7 @@ struct vigs_gl_backend
     uint32_t dpy_tex_height;
 
     GLuint mt_tex;
+    GLfloat mt_tex_ortho[16];
     uint32_t mt_tex_width;
     uint32_t mt_tex_height;
 
index 7b4dd18..9d8774e 100644 (file)
@@ -79,8 +79,8 @@ void TouchPoint::updatePos(QPoint hostPos, QPoint guestPos)
     this->hostPos = hostPos;
     this->guestPos = guestPos;
 
-    qt5_mt_points[2 * (this->id - 1) + 0] = guestPos.x();
-    qt5_mt_points[2 * (this->id - 1) + 1] = guestPos.y();
+    qt5_mt_points[2 * (this->id - 1) + 0] = hostPos.x();
+    qt5_mt_points[2 * (this->id - 1) + 1] = hostPos.y();
     qt5_graphic_hw_invalidate();
 }
 
@@ -105,7 +105,7 @@ MultiTouchTracker::MultiTouchTracker(
     painter.setPen(QColor(255, 255, 255, 255));
     painter.setBrush(QBrush(QColor(128, 128, 128, 128)));
     painter.setRenderHint(QPainter::Antialiasing, true);
-    painter.drawEllipse(0, 0, 31, 31);
+    painter.drawEllipse(1, 1, 30, 30);
 
     qt5_mt_points = new float[2 * maxTouchPoint]();
     qt5_mt_count = 0;
@@ -146,8 +146,8 @@ int MultiTouchTracker::addTouchPoint(QPoint hostPos, QPoint guestPos)
     touchPointList.append(point);
     qDebug() << "ID" << point->getID() << "point touching" << hostPos << guestPos;
 
-    qt5_mt_points[2 * qt5_mt_count + 0] = guestPos.x();
-    qt5_mt_points[2 * qt5_mt_count + 1] = guestPos.y();
+    qt5_mt_points[2 * qt5_mt_count + 0] = hostPos.x();
+    qt5_mt_points[2 * qt5_mt_count + 1] = hostPos.y();
     qt5_mt_count++;
     qt5_graphic_hw_invalidate();