• yjliu's avatar
    Surface Aggregator Prewalk Optimization (Hackweek Project) · bf097d43
    yjliu authored
    Summary:
    This is a Hackthon week project and I reworked the PrewalkTree function to be more streamlined.
    
    Please see the design doc at the following link for purpose of the project and other details.
    https://docs.google.com/document/d/1D1MTNTaJnZjbmMZGMz0u150N3u5evEFSmJU-ou2vcFw/edit#heading=h.c0uts5ftkk58
    
    
    In short, the original PrewalkTree() is as follows:
    ---------------------
    // Returns the damage rect of the surface
    gfx::Rect PrewalkTree(Surface* surface) {
    	......
    
    	// Gather all the embedded child surfaces into a flat_map
    	FindChildSurfaces(&child_surfaces, ...)
    
    	// Iterate through the child surfaces to accumulate damage
    	gfx::Rect damage_rect;
    	for (child_surface : child_surfaces) {
    	    damage_rect += PrewalkTree(child_surface); // apply quad transform here
    	}
    
    	// ...do some other stuff
    
    	return damage_rect;
    }
    -----------------
    
    I modified it to:
    -----------------
    // Returns the damage of a surface
    gfx::Rect PrewalkTree(Surface* surface) {
    	......
    	RenderPass* root_pass = surface->GetActiveFrame()->render_pass_list.back();
      	return PrewalkRenderPass(root_pass);
    }
    
    
    // Returns the accumulated damage of a render pass
    gfx::Rect PrewalkRenderPass(RenderPass* render_pass) {
    	gfx::Rect damage_rect;
    	for (DrawQuad* quad : render_pass->quad_list.reverse())  { // in reverse order
    	    if (quad is SurfaceDrawQuad)
    		  damage_rect += PrewalkTree(quad_surface); // apply quad transform here
    	    else if (quad is RenderPassDrawQuad)
    		  damage_rect += PrewalkRenderPass(quad_render_pass); // apply quad transform here
       	}
       	return damage_rect;
    }
    ----------------
    
    
    Bug: N/A
    Change-Id: I662e93b3f61cd7102c54ca4ba1c2183d6233ac0f
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2175315
    Commit-Queue: Jun Liu <yjliu@chromium.org>
    Auto-Submit: Jun Liu <yjliu@chromium.org>
    Reviewed-by: default avatarkylechar <kylechar@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#770994}
    bf097d43
surface_aggregator.h 18.1 KB