aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-graphics/wayland/weston/0007-MGS-391-Weston-Performance-Optimisation-for-single-b.patch
blob: 295d4e8dea254d1513853bc10aa00a146b66bf2c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
From 399460e202d2b23ffda661499845bcc4d86dc86c Mon Sep 17 00:00:00 2001
From: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
Date: Wed, 31 Dec 2014 16:59:16 -0600
Subject: [PATCH] MGS-391: Weston: Performance Optimisation for single buffer
 mode
Organization: O.S. Systems Software LTDA.

Blit direct to the onscreen whenever compositing is needed which
will help to improve bandwidth utilization

Upstream-Status: Pending

Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
---
 src/gal2d-renderer.c | 114 ++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 81 insertions(+), 33 deletions(-)

diff --git a/src/gal2d-renderer.c b/src/gal2d-renderer.c
index 4cccaf1..e07a2f9 100644
--- a/src/gal2d-renderer.c
+++ b/src/gal2d-renderer.c
@@ -55,6 +55,9 @@ struct gal2d_output_state {
     gctSIGNAL signal;
     gctSIGNAL busySignal;
     gcsHAL_INTERFACE iface;
+    int directBlit;
+    gctINT width;
+    gctINT height;
 };
 
 struct gal2d_surface_state {
@@ -515,34 +518,37 @@ update_surface(struct weston_output *output)
 	struct gal2d_output_state *go = get_output_state(output);
     gceSTATUS status = gcvSTATUS_OK;
 
-    if(go->offscreenSurface && go->nNumBuffers == 1)
+    if(go->nNumBuffers == 1)
 	{
-		make_current(gr, go->renderSurf[go->activebuffer]);
-
-		gctUINT srcWidth = 0;
-		gctUINT srcHeight = 0;
-		gctINT srcStride = 0;
-		gceSURF_FORMAT srcFormat;;
-		gcsRECT dstRect = {0};
-		gcoSURF srcSurface = go->offscreenSurface;
-		gctUINT32 physical;
-		gctPOINTER va =0;
-
-		gcmONERROR(gcoSURF_GetAlignedSize(srcSurface, &srcWidth, &srcHeight, &srcStride));
-		gcmONERROR(gcoSURF_GetFormat(srcSurface, gcvNULL, &srcFormat));
-		gcmONERROR(gcoSURF_Lock(srcSurface, &physical, (gctPOINTER *)&va));
-		gcmONERROR(gco2D_SetColorSource(gr->gcoEngine2d, physical, srcStride, srcFormat,
-							gcvFALSE, srcWidth, gcvFALSE, gcvSURF_OPAQUE, 0));
-
-		dstRect.left 	= 0;
-		dstRect.top		= 0;
-		dstRect.right 	= srcWidth;
-		dstRect.bottom 	= srcHeight;
-
-		gcmONERROR(gco2D_SetSource(gr->gcoEngine2d, &dstRect));
-		gcmONERROR(gco2D_SetClipping(gr->gcoEngine2d, &dstRect));
-		gcmONERROR(gco2D_Blit(gr->gcoEngine2d, 1, &dstRect, 0xCC, 0xCC, go->format));
-		gcmONERROR(gcoSURF_Unlock(srcSurface, (gctPOINTER *)&va));
+        if(!go->directBlit && go->offscreenSurface)
+        {        
+            make_current(gr, go->renderSurf[go->activebuffer]);
+
+            gctUINT srcWidth = 0;
+            gctUINT srcHeight = 0;
+            gctINT srcStride = 0;
+            gceSURF_FORMAT srcFormat;;
+            gcsRECT dstRect = {0};
+            gcoSURF srcSurface = go->offscreenSurface;
+            gctUINT32 physical;
+            gctPOINTER va =0;
+
+            gcmONERROR(gcoSURF_GetAlignedSize(srcSurface, &srcWidth, &srcHeight, &srcStride));
+            gcmONERROR(gcoSURF_GetFormat(srcSurface, gcvNULL, &srcFormat));
+            gcmONERROR(gcoSURF_Lock(srcSurface, &physical, (gctPOINTER *)&va));
+            gcmONERROR(gco2D_SetColorSource(gr->gcoEngine2d, physical, srcStride, srcFormat,
+                                gcvFALSE, srcWidth, gcvFALSE, gcvSURF_OPAQUE, 0));
+
+            dstRect.left 	= 0;
+            dstRect.top		= 0;
+            dstRect.right 	= srcWidth;
+            dstRect.bottom 	= srcHeight;
+
+            gcmONERROR(gco2D_SetSource(gr->gcoEngine2d, &dstRect));
+            gcmONERROR(gco2D_SetClipping(gr->gcoEngine2d, &dstRect));
+            gcmONERROR(gco2D_Blit(gr->gcoEngine2d, 1, &dstRect, 0xCC, 0xCC, go->format));
+            gcmONERROR(gcoSURF_Unlock(srcSurface, (gctPOINTER *)&va));
+        }
 		gcmONERROR(gcoHAL_Commit(gr->gcoHal, gcvFALSE));		
 	}
     else if(go->nNumBuffers > 1)
@@ -554,18 +560,61 @@ OnError:
 	galONERROR(status);
 	return status;
  }
+
+static int
+is_view_visible(struct weston_view *view)
+{
+	/* Return false, if surface is guaranteed to be totally obscured. */
+	int ret;
+	pixman_region32_t unocc;
+
+	pixman_region32_init(&unocc);
+	pixman_region32_subtract(&unocc, &view->transform.boundingbox,
+				 &view->clip);
+	ret = pixman_region32_not_empty(&unocc);
+	pixman_region32_fini(&unocc);
+
+	return ret;
+}
  
 static int
 use_output(struct weston_output *output)
 {
+    struct weston_compositor *compositor = output->compositor;
+	struct weston_view *view;
     struct gal2d_output_state *go = get_output_state(output);	
 	struct gal2d_renderer *gr = get_renderer(output->compositor);    
     gceSTATUS status = gcvSTATUS_OK;
 
     gcoSURF surface;
-	surface = go->nNumBuffers > 1 ?
-						go->renderSurf[go->activebuffer] :
-						go->offscreenSurface;  /*go->renderSurf[0];*/
+    int visibleViews=0;
+    int fullscreenViews=0;
+    
+    surface = go->renderSurf[go->activebuffer];
+    if(go->nNumBuffers == 1)
+    {
+        wl_list_for_each_reverse(view, &compositor->view_list, link)
+    		if (view->plane == &compositor->primary_plane && is_view_visible(view))
+            {   
+                visibleViews++;
+                if(view->surface->width == go->width && view->surface->height == go->height)
+                {
+                    pixman_box32_t *bb_rects;
+                    int nbb=0;
+                    bb_rects = pixman_region32_rectangles(&view->transform.boundingbox, &nbb);
+                    if(nbb == 1)
+                        if(bb_rects[0].x1 == 0 && bb_rects[0].y1 ==0)
+                            fullscreenViews++;
+                }
+            }
+    
+        go->directBlit = ((visibleViews == 1) || (fullscreenViews > 1));
+
+        if(!go->directBlit)
+        {
+             surface = go->offscreenSurface;
+        }
+    }
     make_current(gr, surface); 
     return status;
 }
@@ -1190,8 +1239,7 @@ gal2d_renderer_output_create(struct weston_output *output, NativeDisplayType dis
     struct gal2d_renderer *gr = get_renderer(output->compositor);
 	struct gal2d_output_state *go = calloc(1, sizeof *go);
     halDISPLAY_INFO info;
-    gctUINT32 backOffset = 0;
-    gctINT width, height;
+    gctUINT32 backOffset = 0;    
     gceSTATUS status = gcvSTATUS_OK;
 	gctUINT32 i;
 
@@ -1216,7 +1264,7 @@ gal2d_renderer_output_create(struct weston_output *output, NativeDisplayType dis
 	go->activebuffer = 0;
 
 	go->renderSurf = malloc(sizeof(gcoSURF) * go->nNumBuffers);
-	gcoOS_GetDisplayVirtual(go->display, &width, &height);
+	gcoOS_GetDisplayVirtual(go->display, &go->width, &go->height);
     gcoOS_SetSwapInterval(go->display, 1);
    
     /*Needed only for multi Buffer  */
-- 
2.1.4