]> code.ossystems Code Review - meta-freescale.git/blob
295d4e8dea254d1513853bc10aa00a146b66bf2c
[meta-freescale.git] /
1 From 399460e202d2b23ffda661499845bcc4d86dc86c Mon Sep 17 00:00:00 2001
2 From: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
3 Date: Wed, 31 Dec 2014 16:59:16 -0600
4 Subject: [PATCH] MGS-391: Weston: Performance Optimisation for single buffer
5  mode
6 Organization: O.S. Systems Software LTDA.
7
8 Blit direct to the onscreen whenever compositing is needed which
9 will help to improve bandwidth utilization
10
11 Upstream-Status: Pending
12
13 Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
14 ---
15  src/gal2d-renderer.c | 114 ++++++++++++++++++++++++++++++++++++---------------
16  1 file changed, 81 insertions(+), 33 deletions(-)
17
18 diff --git a/src/gal2d-renderer.c b/src/gal2d-renderer.c
19 index 4cccaf1..e07a2f9 100644
20 --- a/src/gal2d-renderer.c
21 +++ b/src/gal2d-renderer.c
22 @@ -55,6 +55,9 @@ struct gal2d_output_state {
23      gctSIGNAL signal;
24      gctSIGNAL busySignal;
25      gcsHAL_INTERFACE iface;
26 +    int directBlit;
27 +    gctINT width;
28 +    gctINT height;
29  };
30  
31  struct gal2d_surface_state {
32 @@ -515,34 +518,37 @@ update_surface(struct weston_output *output)
33         struct gal2d_output_state *go = get_output_state(output);
34      gceSTATUS status = gcvSTATUS_OK;
35  
36 -    if(go->offscreenSurface && go->nNumBuffers == 1)
37 +    if(go->nNumBuffers == 1)
38         {
39 -               make_current(gr, go->renderSurf[go->activebuffer]);
40 -
41 -               gctUINT srcWidth = 0;
42 -               gctUINT srcHeight = 0;
43 -               gctINT srcStride = 0;
44 -               gceSURF_FORMAT srcFormat;;
45 -               gcsRECT dstRect = {0};
46 -               gcoSURF srcSurface = go->offscreenSurface;
47 -               gctUINT32 physical;
48 -               gctPOINTER va =0;
49 -
50 -               gcmONERROR(gcoSURF_GetAlignedSize(srcSurface, &srcWidth, &srcHeight, &srcStride));
51 -               gcmONERROR(gcoSURF_GetFormat(srcSurface, gcvNULL, &srcFormat));
52 -               gcmONERROR(gcoSURF_Lock(srcSurface, &physical, (gctPOINTER *)&va));
53 -               gcmONERROR(gco2D_SetColorSource(gr->gcoEngine2d, physical, srcStride, srcFormat,
54 -                                                       gcvFALSE, srcWidth, gcvFALSE, gcvSURF_OPAQUE, 0));
55 -
56 -               dstRect.left    = 0;
57 -               dstRect.top             = 0;
58 -               dstRect.right   = srcWidth;
59 -               dstRect.bottom  = srcHeight;
60 -
61 -               gcmONERROR(gco2D_SetSource(gr->gcoEngine2d, &dstRect));
62 -               gcmONERROR(gco2D_SetClipping(gr->gcoEngine2d, &dstRect));
63 -               gcmONERROR(gco2D_Blit(gr->gcoEngine2d, 1, &dstRect, 0xCC, 0xCC, go->format));
64 -               gcmONERROR(gcoSURF_Unlock(srcSurface, (gctPOINTER *)&va));
65 +        if(!go->directBlit && go->offscreenSurface)
66 +        {        
67 +            make_current(gr, go->renderSurf[go->activebuffer]);
68 +
69 +            gctUINT srcWidth = 0;
70 +            gctUINT srcHeight = 0;
71 +            gctINT srcStride = 0;
72 +            gceSURF_FORMAT srcFormat;;
73 +            gcsRECT dstRect = {0};
74 +            gcoSURF srcSurface = go->offscreenSurface;
75 +            gctUINT32 physical;
76 +            gctPOINTER va =0;
77 +
78 +            gcmONERROR(gcoSURF_GetAlignedSize(srcSurface, &srcWidth, &srcHeight, &srcStride));
79 +            gcmONERROR(gcoSURF_GetFormat(srcSurface, gcvNULL, &srcFormat));
80 +            gcmONERROR(gcoSURF_Lock(srcSurface, &physical, (gctPOINTER *)&va));
81 +            gcmONERROR(gco2D_SetColorSource(gr->gcoEngine2d, physical, srcStride, srcFormat,
82 +                                gcvFALSE, srcWidth, gcvFALSE, gcvSURF_OPAQUE, 0));
83 +
84 +            dstRect.left       = 0;
85 +            dstRect.top                = 0;
86 +            dstRect.right      = srcWidth;
87 +            dstRect.bottom     = srcHeight;
88 +
89 +            gcmONERROR(gco2D_SetSource(gr->gcoEngine2d, &dstRect));
90 +            gcmONERROR(gco2D_SetClipping(gr->gcoEngine2d, &dstRect));
91 +            gcmONERROR(gco2D_Blit(gr->gcoEngine2d, 1, &dstRect, 0xCC, 0xCC, go->format));
92 +            gcmONERROR(gcoSURF_Unlock(srcSurface, (gctPOINTER *)&va));
93 +        }
94                 gcmONERROR(gcoHAL_Commit(gr->gcoHal, gcvFALSE));                
95         }
96      else if(go->nNumBuffers > 1)
97 @@ -554,18 +560,61 @@ OnError:
98         galONERROR(status);
99         return status;
100   }
101 +
102 +static int
103 +is_view_visible(struct weston_view *view)
104 +{
105 +       /* Return false, if surface is guaranteed to be totally obscured. */
106 +       int ret;
107 +       pixman_region32_t unocc;
108 +
109 +       pixman_region32_init(&unocc);
110 +       pixman_region32_subtract(&unocc, &view->transform.boundingbox,
111 +                                &view->clip);
112 +       ret = pixman_region32_not_empty(&unocc);
113 +       pixman_region32_fini(&unocc);
114 +
115 +       return ret;
116 +}
117   
118  static int
119  use_output(struct weston_output *output)
120  {
121 +    struct weston_compositor *compositor = output->compositor;
122 +       struct weston_view *view;
123      struct gal2d_output_state *go = get_output_state(output);  
124         struct gal2d_renderer *gr = get_renderer(output->compositor);    
125      gceSTATUS status = gcvSTATUS_OK;
126  
127      gcoSURF surface;
128 -       surface = go->nNumBuffers > 1 ?
129 -                                               go->renderSurf[go->activebuffer] :
130 -                                               go->offscreenSurface;  /*go->renderSurf[0];*/
131 +    int visibleViews=0;
132 +    int fullscreenViews=0;
133 +    
134 +    surface = go->renderSurf[go->activebuffer];
135 +    if(go->nNumBuffers == 1)
136 +    {
137 +        wl_list_for_each_reverse(view, &compositor->view_list, link)
138 +               if (view->plane == &compositor->primary_plane && is_view_visible(view))
139 +            {   
140 +                visibleViews++;
141 +                if(view->surface->width == go->width && view->surface->height == go->height)
142 +                {
143 +                    pixman_box32_t *bb_rects;
144 +                    int nbb=0;
145 +                    bb_rects = pixman_region32_rectangles(&view->transform.boundingbox, &nbb);
146 +                    if(nbb == 1)
147 +                        if(bb_rects[0].x1 == 0 && bb_rects[0].y1 ==0)
148 +                            fullscreenViews++;
149 +                }
150 +            }
151 +    
152 +        go->directBlit = ((visibleViews == 1) || (fullscreenViews > 1));
153 +
154 +        if(!go->directBlit)
155 +        {
156 +             surface = go->offscreenSurface;
157 +        }
158 +    }
159      make_current(gr, surface); 
160      return status;
161  }
162 @@ -1190,8 +1239,7 @@ gal2d_renderer_output_create(struct weston_output *output, NativeDisplayType dis
163      struct gal2d_renderer *gr = get_renderer(output->compositor);
164         struct gal2d_output_state *go = calloc(1, sizeof *go);
165      halDISPLAY_INFO info;
166 -    gctUINT32 backOffset = 0;
167 -    gctINT width, height;
168 +    gctUINT32 backOffset = 0;    
169      gceSTATUS status = gcvSTATUS_OK;
170         gctUINT32 i;
171  
172 @@ -1216,7 +1264,7 @@ gal2d_renderer_output_create(struct weston_output *output, NativeDisplayType dis
173         go->activebuffer = 0;
174  
175         go->renderSurf = malloc(sizeof(gcoSURF) * go->nNumBuffers);
176 -       gcoOS_GetDisplayVirtual(go->display, &width, &height);
177 +       gcoOS_GetDisplayVirtual(go->display, &go->width, &go->height);
178      gcoOS_SetSwapInterval(go->display, 1);
179     
180      /*Needed only for multi Buffer  */
181 -- 
182 2.1.4
183