IR / MPX Ideas
 

eZoom idea:

 

IR Idea:

 

 

Triangles Idea:

 

What happens here is that we subdivide the window up into sections and create a pair of triangles for that section, hence creating a mesh. The relevant code is below:

struct _CompMesh
{
    XTriangle *triangles;
    int       width;
    int       height;
};

     /* The window was repainted, we need to recalculate it's input
     * mesh. The mesh accuracy is taken from core options
     * TODO: Needs to be an option */

    /* The window is divided up into portions, depending on the mesh
     * accuracy - createMesh is wrappable so plugins can use the base
     * mesh and adjust it. Once the mesh is adjusted, it is applied
     * through X.
     */

    /* 2 Triangles per portion of the window */

    /* ------------ *
     * |\         | *
     * | \        | *
     * |  \   t1  | *
     * |   \      | *
     * |    \     | *
     * |     \    | *
     * |      \   | *
     * |   t2  \  | *
     * |        \ | *
     * |         \| *
     * ------------ */

    CompMesh mesh;
    int      i;
    int      width, height;
    int      nTriangle = 0;

    mesh.width = MIN (64, w->serverWidth);
    mesh.height = MIN (64, w->serverHeight);
    mesh.triangles = NULL;
    mesh.triangles = realloc (mesh.triangles, ((mesh.width * mesh.height) * 2) * 2 * sizeof(XTriangle));
    for (height = 0; height < mesh.height; height++)
    {
    for (width = 0; width < mesh.width; width++)
    {
        for (i = 1; i <= 2; i++)
        {
        int x1, x2, y1, y2;
        x1 = (int) (w->serverWidth / mesh.width) * width;
        x2 = (int) (w->serverWidth / mesh.width) * (width + 1);
        y1 = (int) (w->serverHeight / mesh.height) * height;
        y2 = (int) (w->serverHeight / mesh.height) * (height + 1);
        switch (i)
        {
            case 1: /* Triangle is right-side up (first triangle in rectangle) */
            mesh.triangles[nTriangle].p1.x = IntToxFixed (x1);
            mesh.triangles[nTriangle].p1.y = IntToxFixed (y1);
            mesh.triangles[nTriangle].p2.x = IntToxFixed (x1);
            mesh.triangles[nTriangle].p2.y = IntToxFixed (y2);
            mesh.triangles[nTriangle].p3.x = IntToxFixed (x2);
            mesh.triangles[nTriangle].p3.y = IntToxFixed (y2);

            nTriangle++;

            mesh.triangles[nTriangle].p1.x = IntToxFixed (x1);
            mesh.triangles[nTriangle].p1.y = IntToxFixed (y1);
            mesh.triangles[nTriangle].p2.x = IntToxFixed (x1);
            mesh.triangles[nTriangle].p2.y = IntToxFixed (y2);
            mesh.triangles[nTriangle].p3.x = IntToxFixed (x2);
            mesh.triangles[nTriangle].p3.y = IntToxFixed (y2);

            nTriangle++;

            break;
            case 2: /* Triangle is right-side up (first triangle in rectangle) */
            mesh.triangles[nTriangle].p1.x = IntToxFixed (x1);
            mesh.triangles[nTriangle].p1.y = IntToxFixed (y1);
            mesh.triangles[nTriangle].p2.x = IntToxFixed (x2);
            mesh.triangles[nTriangle].p2.y = IntToxFixed (y1);
            mesh.triangles[nTriangle].p3.x = IntToxFixed (x2);
            mesh.triangles[nTriangle].p3.y = IntToxFixed (y2);

            nTriangle++;

            mesh.triangles[nTriangle].p1.x = IntToxFixed (x1);
            mesh.triangles[nTriangle].p1.y = IntToxFixed (y1);
            mesh.triangles[nTriangle].p2.x = IntToxFixed (x2);
            mesh.triangles[nTriangle].p2.y = IntToxFixed (y1);
            mesh.triangles[nTriangle].p3.x = IntToxFixed (x2);
            mesh.triangles[nTriangle].p3.y = IntToxFixed (y2);

            nTriangle++;
            break;
            default:
            break;
        }
        }
    }
    }

    (*w->screen->createMesh) (w, &mesh);

    /*
    XCompositeSetTriangularCoordinateMesh (w->screen->display->display,
                       w->id,
                       mesh.triangles,
                       nTriangle);
    */

    free (mesh.triangles);

 (OpenGL was used to draw the triangles as seen)


Some things worth considering so far

  • The mesh width/height needs to be either relative to the window size, configurable, or both. 64x64 mesh size is a bit too accurate (and I notice that compiz chews up the CPU in that case)
  • The createMesh Function is wrappable - core's version doesn't do anything ... yet
  • createMesh is called at the end of paintWindow
  • The parent and child meshes probably need to be separated out. Right now, both are in the XTriangle array. I don't want plugins messing with the child mesh, so we only need to provide the parent mesh to createMesh (w, &mesh)
  • The mesh is a bit offset, but I think this is because I using the server width and height (as well as position) to draw the mesh. This will be changed when I get time.