]> git.tdb.fi Git - geometrycompositor.git/commitdiff
Use 4096 rather than 10000 as the fixed point multiplier
authorMikko Rasa <tdb@tdb.fi>
Mon, 14 Dec 2015 20:56:49 +0000 (22:56 +0200)
committerMikko Rasa <tdb@tdb.fi>
Mon, 14 Dec 2015 20:57:17 +0000 (22:57 +0200)
It has the advantage of producing values exactly representable as floats,
making various operations more consistently repeatable.

source/control.c
source/main.c

index b02783893dd81e8934a8356cfe6ef8073b36b735..fc0f8718c4e554e92dd41f8505b1f8598478d2a5 100644 (file)
@@ -154,10 +154,10 @@ GeometryCorrection *get_corrections(Display *display)
                corrections[i].monitor_name = (char *)malloc(namelen+1);
                strcpy(corrections[i].monitor_name, name_ptr);
 
-               corrections[i].keystone_vertical = values[i*4]/10000.0f;
-               corrections[i].cylinder_depth = values[i*4+1]/10000.0f;
-               corrections[i].vertical_center = values[i*4+2]/10000.0f;
-               corrections[i].perspective = values[i*4+3]/10000.0f;
+               corrections[i].keystone_vertical = values[i*4]/4096.0f;
+               corrections[i].cylinder_depth = values[i*4+1]/4096.0f;
+               corrections[i].vertical_center = values[i*4+2]/4096.0f;
+               corrections[i].perspective = values[i*4+3]/4096.0f;
 
                name_ptr += namelen+1;
        }
@@ -198,10 +198,10 @@ void set_corrections(Display *display, GeometryCorrection *corrections)
                strcpy(name_ptr, corrections[i].monitor_name);
                name_ptr += strlen(name_ptr)+1;
 
-               values[i*4] = corrections[i].keystone_vertical*10000;
-               values[i*4+1] = corrections[i].cylinder_depth*10000;
-               values[i*4+2] = corrections[i].vertical_center*10000;
-               values[i*4+3] = corrections[i].perspective*10000;
+               values[i*4] = corrections[i].keystone_vertical*4096;
+               values[i*4+1] = corrections[i].cylinder_depth*4096;
+               values[i*4+2] = corrections[i].vertical_center*4096;
+               values[i*4+3] = corrections[i].perspective*4096;
        }
 
        root = DefaultRootWindow(display);
@@ -338,7 +338,7 @@ void update_view(Display *display, InteractiveView *view, XSelectionEvent *event
 
        vertex_data = (float *)malloc(nvertices*3*sizeof(float));
        for(i=0; i<nvertices*3; ++i)
-               vertex_data[i] = geometry_data[1+i]/10000.0f;
+               vertex_data[i] = geometry_data[1+i]/4096.0f;
 
        view->nelements = tessellation*((tessellation+1)*2+1)-1;
 
index 1a4d5960b257059dccf6d288a0d024be9ed30b36..024e84930d88209f58cc0dcdbe9b643015b959a4 100644 (file)
@@ -647,17 +647,17 @@ void update_monitor_vertices(CompositedScreen *screen, CompositedMonitor *monito
 
        monitor->geometry_data[0] = t;
        for(i=0; i<3; ++i)
-               monitor->geometry_data[1+i] = eye[i]*10000;
+               monitor->geometry_data[1+i] = eye[i]*4096;
        for(y=0; y<2; ++y)
                for(x=0; x<2; ++x)
                {
                        i = 1+(1+y*2+x)*3;
-                       monitor->geometry_data[i] = ((x-0.5f)*distance/monitor->perspective)*10000;
-                       monitor->geometry_data[i+1] = (eye[1]+look[1]*distance-(y-monitor->vertical_center)*look[2]*distance/monitor->perspective/aspect)*10000;
-                       monitor->geometry_data[i+2] = (eye[2]+look[2]*distance+(y-monitor->vertical_center)*look[1]*distance/monitor->perspective/aspect)*10000;
+                       monitor->geometry_data[i] = ((x-0.5f)*distance/monitor->perspective)*4096;
+                       monitor->geometry_data[i+1] = (eye[1]+look[1]*distance-(y-monitor->vertical_center)*look[2]*distance/monitor->perspective/aspect)*4096;
+                       monitor->geometry_data[i+2] = (eye[2]+look[2]*distance+(y-monitor->vertical_center)*look[1]*distance/monitor->perspective/aspect)*4096;
                }
        for(i=0; i<(t+1)*(t+1)*3; ++i)
-               monitor->geometry_data[16+i] = vertex_data[i]*10000;
+               monitor->geometry_data[16+i] = vertex_data[i]*4096;
 
        for(y=t; y<=t; --y)
                for(x=t; x<=t; --x)
@@ -831,10 +831,10 @@ void update_geometry_correction(Compositor *compositor, CompositedScreen *screen
                monitor = find_monitor_by_name(screen, name_ptr);
                if(monitor)
                {
-                       monitor->keystone_vertical = values[i*4]/10000.0f;
-                       monitor->cylinder_depth = values[i*4+1]/10000.0f;
-                       monitor->vertical_center = values[i*4+2]/10000.0f;
-                       monitor->perspective = values[i*4+3]/10000.0f;
+                       monitor->keystone_vertical = values[i*4]/4096.0f;
+                       monitor->cylinder_depth = values[i*4+1]/4096.0f;
+                       monitor->vertical_center = values[i*4+2]/4096.0f;
+                       monitor->perspective = values[i*4+3]/4096.0f;
 
                        if(monitor->enabled)
                                update_monitor_vertices(screen, monitor);