summaryrefslogtreecommitdiffstats
path: root/recipes-graphics/wayland/weston/0003-Distorted-line-and-shadow-if-use-2d-com.patch
blob: 0e7ffd06a037f01fd5183dbc2bc39813a90a8d13 (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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
From 1fd17db2ab978322803683a4d2d847a0b31a4c1c Mon Sep 17 00:00:00 2001
From: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
Date: Tue, 24 Jun 2014 15:44:13 -0500
Subject: [PATCH 3/3] ENGR00319247 : Distorted line and shadow if use 2d
 compositor to run wayland apps.

Fixed blending for shadown and maintained separate surface for damage composite.

Upstream Status: N/A

Signed-off-by: Prabhu Sundararaj <prabhu.sundararaj@freescale.com>
---
 src/compositor-fbdev.c |   8 ++--
 src/gal2d-renderer.c   | 102 +++++++++++++++++++++++++++++++++++--------------
 src/gal2d-renderer.h   |   6 +++
 3 files changed, 83 insertions(+), 33 deletions(-)

diff --git a/src/compositor-fbdev.c b/src/compositor-fbdev.c
index a3d32e5..b27d199 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -55,7 +55,7 @@ struct fbdev_compositor {
 	int use_pixman;
 	int use_gal2d;
 	struct wl_listener session_listener;
-	EGLNativeDisplayType display;
+	NativeDisplayType display;
 };
 
 struct fbdev_screeninfo {
@@ -91,8 +91,8 @@ struct fbdev_output {
 	void *shadow_buf;
 	uint8_t depth;
 
-	EGLNativeDisplayType display;
-	EGLNativeWindowType  window;
+	NativeDisplayType display;
+	NativeWindowType  window;
 };
 
 struct fbdev_parameters {
@@ -667,7 +667,7 @@ fbdev_output_create(struct fbdev_compositor *compositor,
 			return 0;
 		}
 		if (gl_renderer->output_create(&output->base,
-						(EGLNativeWindowType)output->window,
+						(NativeWindowType)output->window,
 						gl_renderer->opaque_attribs,
 						NULL) < 0) {
 			weston_log("gl_renderer_output_create failed.\n");
diff --git a/src/gal2d-renderer.c b/src/gal2d-renderer.c
index c651573..fbe39f6 100644
--- a/src/gal2d-renderer.c
+++ b/src/gal2d-renderer.c
@@ -42,7 +42,7 @@ struct gal2d_output_state {
 	
 	int current_buffer;
 	pixman_region32_t buffer_damage[2];
-	EGLNativeDisplayType display;
+	NativeDisplayType display;
     gcoSURF* renderSurf;
 	gctUINT32 nNumBuffers;
 	int activebuffer;
@@ -423,11 +423,9 @@ gal2dBindBuffer(struct weston_surface* es)
 	gcoSURF surface = gs->gco_Surface;	
     struct weston_buffer *buffer = gs->buffer_ref.buffer;
 	gcePOOL pool = gcvPOOL_DEFAULT;
-	gctUINT64 node = 0;
-	gctUINT bytes;
-
-	gcmVERIFY_OK(gcoSURF_QueryVidMemNode(surface, &node,
-						&pool, &bytes));
+    
+	gcmVERIFY_OK(gcoSURF_QueryVidMemNode(surface, gcvNULL,
+						&pool, gcvNULL));
 
 	if(pool != gcvPOOL_USER)
 	{
@@ -801,24 +799,26 @@ draw_view(struct weston_view *ev, struct weston_output *output,
 				  ev->surface->width, ev->surface->height);
 	pixman_region32_subtract(&surface_blend, &surface_blend, &ev->surface->opaque);
 
+    struct gal2d_renderer *gr = get_renderer(ec);
+    
 	if (pixman_region32_not_empty(&ev->surface->opaque)) {
 
 		repaint_region(ev, output, go, &repaint, &ev->surface->opaque);
 	}
 
 	if (pixman_region32_not_empty(&surface_blend)) {
-        struct gal2d_renderer *gr = get_renderer(ec);
-        
+    
         gco2D_EnableAlphaBlend(gr->gcoEngine2d,
-			ev->alpha * 0xFF, ev->alpha * 0xFF,
-			gcvSURF_PIXEL_ALPHA_STRAIGHT, gcvSURF_PIXEL_ALPHA_STRAIGHT,
-			gcvSURF_GLOBAL_ALPHA_OFF, gcvSURF_GLOBAL_ALPHA_OFF,
-			gcvSURF_BLEND_ONE, gcvSURF_BLEND_INVERSED,
-			gcvSURF_COLOR_STRAIGHT, gcvSURF_COLOR_STRAIGHT);
+            ev->alpha * 0xFF, ev->alpha * 0xFF,
+            gcvSURF_PIXEL_ALPHA_STRAIGHT, gcvSURF_PIXEL_ALPHA_STRAIGHT,
+            gcvSURF_GLOBAL_ALPHA_SCALE, gcvSURF_GLOBAL_ALPHA_SCALE,
+            gcvSURF_BLEND_STRAIGHT, gcvSURF_BLEND_INVERSED,
+            gcvSURF_COLOR_STRAIGHT, gcvSURF_COLOR_STRAIGHT);
             
 		repaint_region(ev, output, go, &repaint, &surface_blend);
 	}
 
+    gco2D_DisableAlphaBlend(gr->gcoEngine2d);
 	pixman_region32_fini(&surface_blend);
 
 out:
@@ -866,6 +866,48 @@ gal2d_renderer_repaint_output(struct weston_output *output,
 }
 
 static void
+gal2d_renderer_attach_egl(struct weston_surface *es, struct weston_buffer *buffer)
+{
+    gcsWL_VIV_BUFFER *vivBuffer = wl_resource_get_user_data(buffer->resource);
+    gctUINT width = 0;
+    gctUINT height = 0;
+    gctINT stride = 0;
+    gceSURF_FORMAT format;
+    gcoSURF srcSurf = vivBuffer->surface;
+    gctUINT32 physical;
+    gctPOINTER va =0;
+    gceSTATUS status = gcvSTATUS_OK;
+    struct gal2d_surface_state *gs = get_surface_state(es);
+        
+    if(gs->gco_Surface == gcvNULL)
+    {
+        /** Construct a wrapper. */
+        gcmONERROR(gcoSURF_ConstructWrapper(gcvNULL, &gs->gco_Surface));
+    }
+
+    gcmONERROR(gcoSURF_GetAlignedSize(srcSurf, &width, &height, &stride));
+    gcmONERROR(gcoSURF_GetFormat(srcSurf, gcvNULL, &format));
+    gcmONERROR(gcoSURF_Lock(srcSurf, &physical, (gctPOINTER *)&va));  
+
+    /* Set the buffer. */
+    gcmONERROR(gcoSURF_SetBuffer(gs->gco_Surface,
+                               gcvSURF_BITMAP_NO_VIDMEM,
+                               format,
+                               stride,
+                               (gctPOINTER) va,
+                               (gctUINT32) physical));
+
+    /* Set the window. */
+    gcmONERROR(gcoSURF_SetWindow(gs->gco_Surface, 0, 0, width, height));
+    
+    buffer->width = vivBuffer->width;
+    buffer->height = vivBuffer->height;
+    
+  OnError:
+    galONERROR(status);
+}
+
+static void
 gal2d_renderer_flush_damage(struct weston_surface *surface)
 {
 	struct gal2d_surface_state *gs = get_surface_state(surface);
@@ -900,10 +942,7 @@ gal2d_renderer_flush_damage(struct weston_surface *surface)
 		gal2dBindBuffer(surface);
 	}
 	else
-	{
-		gcsWL_VIV_BUFFER *vivBuffer = (gcsWL_VIV_BUFFER *)buffer;
-		gs->gco_Surface = vivBuffer->surface;
-	}
+        gal2d_renderer_attach_egl(surface, buffer);
 
 done:
 	pixman_region32_fini(&gs->texture_damage);
@@ -937,19 +976,17 @@ gal2d_renderer_attach(struct weston_surface *es, struct weston_buffer *buffer)
 		}
 	}
 	else
-	{
-		gcsWL_VIV_BUFFER *vivBuffer = wl_resource_get_user_data(buffer->resource);
-		gs->gco_Surface = vivBuffer->surface;
-
-		buffer->width = vivBuffer->width;
-		buffer->height = vivBuffer->height;
-	}
+		gal2d_renderer_attach_egl(es, buffer);
 }
 
 static void
 surface_state_destroy(struct gal2d_surface_state *gs, struct gal2d_renderer *gr)
 {
-	wl_list_remove(&gs->surface_destroy_listener.link);
+	if(gs->gco_Surface)
+    {
+        gcoSURF_Destroy(gs->gco_Surface);
+    }
+    wl_list_remove(&gs->surface_destroy_listener.link);
 	wl_list_remove(&gs->renderer_destroy_listener.link);
 	if(gs->surface)
 		gs->surface->renderer_state = NULL;
@@ -1043,8 +1080,12 @@ gal2d_renderer_output_destroy(struct weston_output *output)
 {
     struct gal2d_output_state *go = get_output_state(output);
     gctUINT32 i;
-    
-	if(go->nNumBuffers <= 1 )
+
+    for (i = 0; i < 2; i++)
+    {
+        pixman_region32_fini(&go->buffer_damage[i]);
+    }
+    if(go->nNumBuffers <= 1 )
 	{
 		if(go->offscreenSurface)
 			gcmVERIFY_OK(gcoSURF_Destroy(go->offscreenSurface));
@@ -1107,8 +1148,8 @@ OnError:
 }
 
 static int
-gal2d_renderer_output_create(struct weston_output *output, EGLNativeDisplayType display,
-				    EGLNativeWindowType window)
+gal2d_renderer_output_create(struct weston_output *output, NativeDisplayType display,
+				    NativeWindowType window)
 
  {
     struct gal2d_renderer *gr = get_renderer(output->compositor);
@@ -1174,6 +1215,9 @@ gal2d_renderer_output_create(struct weston_output *output, EGLNativeDisplayType
 		gal2d_clear(output);
 		gal2d_flip_surface(output);
 	}
+
+	for (i = 0; i < 2; i++)
+		pixman_region32_init(&go->buffer_damage[i]);
 OnError:
     galONERROR(status);
     /* Return the status. */
diff --git a/src/gal2d-renderer.h b/src/gal2d-renderer.h
index 3b89f73..1322a7d 100644
--- a/src/gal2d-renderer.h
+++ b/src/gal2d-renderer.h
@@ -24,7 +24,13 @@
 #define __gal_2d_renderer_h_
 
 #include  "compositor.h"
+#ifdef ENABLE_EGL
 #include <EGL/egl.h>
+#else
+#include <HAL/gc_hal_eglplatform.h>
+typedef HALNativeDisplayType NativeDisplayType;
+typedef HALNativeWindowType  NativeWindowType;
+#endif
 
 
 struct gal2d_renderer_interface {
-- 
2.0.0