Skip to content
  • Daniel van Vugt's avatar
    clutter: Introduce geometric picking · 14c706e5
    Daniel van Vugt authored and Jonas Ådahl's avatar Jonas Ådahl committed
    Currently, Clutter does picking by drawing with Cogl and reading
    the pixel that's beneath the given point. Since Cogl has a journal
    that records drawing operations, and has optimizations to read a
    single pixel from a list of rectangle, it would be expected that
    we would hit this fast path and not flush the journal while picking.
    
    However, that's not the case: dithering, clipping with scissors, etc,
    can all flush the journal, issuing commands to the GPU and making
    picking slow. On NVidia-based systems, this glReadPixels() call is
    extremely costly.
    
    Introduce geometric picking, and avoid using the Cogl journal entirely.
    Do this by introducing a stack of actors in ClutterStage. This stack
    is cached, but for now, don't use the cache as much as possible.
    
    The picking routines are still tied to painting.
    
    When projecting the actor vertexes, do it manually and take the modelview
    matrix of the framebuffer into account as well.
    
    CPU usage on an Intel i7-7700, tested with two different GPUs/drivers:
    
      |         |     Intel | Nvidia |
      | ------: | --------: | -----: |
      | Moving the mouse:            |
      | Before  |       10% |    10% |
      | After   |        6% |     6% |
      | Moving a window:             |
      | Before  |       23% |    81% |
      | After   |       19% |    40% |
    
    Closes: #154,
            #691
    
    Helps significantly with: #283,
                              #590,
                              #700
    
    v2: Fix code style issues
        Simplify quadrilateral checks
        Remove the 0.5f hack
        Differentiate axis-aligned rectangles
    
    !189
    14c706e5