Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Image support

  • Loading branch information...
commit 4d2416da747d9a4ff380583563c5ec97ccb8d695 1 parent 9aa2377
Sébastien Bourdeauducq authored November 23, 2011
16  src/renderer/compiler.c
@@ -161,7 +161,16 @@ static const char pfv_names[COMP_PFV_COUNT][FPVM_MAXSYMLEN] = {
161 161
 	"midi7",
162 162
 	"midi8",
163 163
 
164  
-	"video_a"
  164
+	"video_a",
  165
+	
  166
+	"image1_a",
  167
+	"image1_x",
  168
+	"image1_y",
  169
+	"image1_zoom",
  170
+	"image2_a",
  171
+	"image2_x",
  172
+	"image2_y",
  173
+	"image2_zoom"
165 174
 };
166 175
 
167 176
 static int pfv_from_name(struct compiler_sc *sc, const char *name)
@@ -216,6 +225,11 @@ static void load_defaults(struct compiler_sc *sc)
216 225
 	sc->p->pfv_initial[pfv_mv_l] = 1.0;
217 226
 
218 227
 	sc->p->pfv_initial[pfv_warp_scale] = 1.0;
  228
+	
  229
+	sc->p->pfv_initial[pfv_video_echo_zoom] = 1.0;
  230
+	
  231
+	sc->p->pfv_initial[pfv_image1_zoom] = 1.0;
  232
+	sc->p->pfv_initial[pfv_image2_zoom] = 1.0;
219 233
 }
220 234
 
221 235
 static void set_initial(struct compiler_sc *sc, int pfv, float x)
9  src/renderer/compiler.h
@@ -128,6 +128,15 @@ enum {
128 128
 	pfv_midi8,
129 129
 
130 130
 	pfv_video_a,
  131
+	
  132
+	pfv_image1_a,
  133
+	pfv_image1_x,
  134
+	pfv_image1_y,
  135
+	pfv_image1_zoom,
  136
+	pfv_image2_a,
  137
+	pfv_image2_x,
  138
+	pfv_image2_y,
  139
+	pfv_image2_zoom,
131 140
 
132 141
 	COMP_PFV_COUNT /* must be last */
133 142
 };
19  src/renderer/eval.c
@@ -27,6 +27,7 @@
27 27
 #include <bsp/milkymist_pfpu.h>
28 28
 #include <bsp/milkymist_tmu.h>
29 29
 
  30
+#include "../pixbuf/pixbuf.h"
30 31
 #include "compiler.h"
31 32
 #include "framedescriptor.h"
32 33
 #include "renderer.h"
@@ -221,6 +222,15 @@ static void set_frd_from_pfv(struct patch *p, struct frame_descriptor *frd)
221 222
 	frd->dmx[7] = read_pfv(p, pfv_dmx8);
222 223
 
223 224
 	frd->video_a = read_pfv(p, pfv_video_a);
  225
+	
  226
+	frd->image_a[0] = read_pfv(p, pfv_image1_a);
  227
+	frd->image_x[0] = read_pfv(p, pfv_image1_x);
  228
+	frd->image_y[0] = read_pfv(p, pfv_image1_y);
  229
+	frd->image_zoom[0] = read_pfv(p, pfv_image1_zoom);
  230
+	frd->image_a[1] = read_pfv(p, pfv_image2_a);
  231
+	frd->image_x[1] = read_pfv(p, pfv_image2_x);
  232
+	frd->image_y[1] = read_pfv(p, pfv_image2_y);
  233
+	frd->image_zoom[1] = read_pfv(p, pfv_image2_zoom);
224 234
 }
225 235
 
226 236
 static unsigned int pfpudummy[2] __attribute__((aligned(sizeof(struct tmu_vertex))));
@@ -278,6 +288,7 @@ static rtems_task eval_task(rtems_task_argument argument)
278 288
 
279 289
 	while(1) {
280 290
 		struct patch *p;
  291
+		int i;
281 292
 
282 293
 		rtems_message_queue_receive(
283 294
 			eval_q,
@@ -294,7 +305,13 @@ static rtems_task eval_task(rtems_task_argument argument)
294 305
 		renderer_lock_patch();
295 306
 
296 307
 		p = renderer_get_patch(1);
297  
-
  308
+		
  309
+		/* NB: we do not increment reference count and assume pixbufs
  310
+		 * will be valid until the renderer has fully stopped.
  311
+		 */
  312
+		for(i=0;i<IMAGE_COUNT;i++)
  313
+			frd->images[i] = p->images[i];
  314
+		
298 315
 		reinit_all_pfv(p);
299 316
 		set_pfv_from_frd(p, frd);
300 317
 		eval_pfv(p, pfpu_fd);
95  src/renderer/raster.c
@@ -365,7 +365,7 @@ static void compute_wave_vertices(struct frame_descriptor *frd, struct wave_para
365 365
 	}
366 366
 }
367 367
 
368  
-static void draw(unsigned short *fb, struct frame_descriptor *frd, struct wave_params *params, struct wave_vertex *vertices, int nvertices)
  368
+static void software_draw(unsigned short *fb, struct frame_descriptor *frd, struct wave_params *params, struct wave_vertex *vertices, int nvertices)
369 369
 {
370 370
 	draw_motion_vectors(fb, frd);
371 371
 	draw_borders(fb, frd);
@@ -488,6 +488,83 @@ static void video(unsigned short *tex_backbuffer, struct frame_descriptor *frd,
488 488
 	ioctl(video_fd, VIDEO_BUFFER_UNLOCK, videoframe);
489 489
 }
490 490
 
  491
+static void images(unsigned short *tex_backbuffer, struct frame_descriptor *frd, int tmu_fd, struct tmu_vertex *scale_vertices)
  492
+{
  493
+	int i;
  494
+	struct tmu_td td;
  495
+	int alpha;
  496
+	float ftexsize;
  497
+	int dx, dy;
  498
+	int sx, sy;
  499
+	
  500
+	for(i=0;i<IMAGE_COUNT;i++) {
  501
+		if((frd->images[i] != NULL) && (frd->image_a[i] != 0.0)) {
  502
+			alpha = 64.0*frd->image_a[i];
  503
+			alpha--;
  504
+			if(alpha > TMU_ALPHA_MAX)
  505
+				alpha = TMU_ALPHA_MAX;
  506
+			if(alpha <= 0)
  507
+				continue;
  508
+			
  509
+			ftexsize = (float)renderer_texsize;
  510
+			dx = ftexsize*frd->image_x[i];
  511
+			dx = ftexsize*frd->image_y[i];
  512
+			sx = ((float)frd->images[i]->width)*frd->image_zoom[i];
  513
+			sy = ((float)frd->images[i]->height)*frd->image_zoom[i];
  514
+			
  515
+			scale_vertices[0].x = 0;
  516
+			scale_vertices[0].y = 0;
  517
+			scale_vertices[1].x = frd->images[i]->width << TMU_FIXEDPOINT_SHIFT;
  518
+			scale_vertices[1].y = 0;
  519
+			scale_vertices[TMU_MESH_MAXSIZE].x = 0;
  520
+			scale_vertices[TMU_MESH_MAXSIZE].y = frd->images[i]->height << TMU_FIXEDPOINT_SHIFT;
  521
+			scale_vertices[TMU_MESH_MAXSIZE+1].x = frd->images[i]->width << TMU_FIXEDPOINT_SHIFT;
  522
+			scale_vertices[TMU_MESH_MAXSIZE+1].y = frd->images[i]->height << TMU_FIXEDPOINT_SHIFT;
  523
+			
  524
+			td.flags = 0;
  525
+			td.hmeshlast = 1;
  526
+			td.vmeshlast = 1;
  527
+			td.brightness = TMU_BRIGHTNESS_MAX;
  528
+			td.chromakey = 0;
  529
+			td.vertices = scale_vertices;
  530
+			td.texfbuf = frd->images[i]->pixels;
  531
+			td.texhres = frd->images[i]->width;
  532
+			td.texvres = frd->images[i]->height;
  533
+			td.texhmask = TMU_MASK_FULL;
  534
+			td.texvmask = TMU_MASK_FULL;
  535
+			td.dstfbuf = tex_backbuffer;
  536
+			td.dsthres = renderer_texsize;
  537
+			td.dstvres = renderer_texsize;
  538
+			td.dsthoffset = dx - (sx >> 1);
  539
+			td.dstvoffset = dy - (sy >> 1);
  540
+			td.dstsquarew = sx;
  541
+			td.dstsquareh = sy;
  542
+			td.alpha = alpha;
  543
+			td.invalidate_before = false;
  544
+			td.invalidate_after = false;
  545
+
  546
+			ioctl(tmu_fd, TMU_EXECUTE, &td);
  547
+		}
  548
+	}
  549
+}
  550
+
  551
+static void update_dmx_outputs(int dmx_fd, struct frame_descriptor *frd, int *dmx_map)
  552
+{
  553
+	int i;
  554
+	unsigned char dmx_val;
  555
+	
  556
+	for(i=0;i<DMX_COUNT;i++) {
  557
+		lseek(dmx_fd, dmx_map[i], SEEK_SET);
  558
+		if(frd->dmx[i] > 1.0)
  559
+			dmx_val = 255;
  560
+		else if(frd->dmx[i] < 0.0)
  561
+			dmx_val = 0;
  562
+		else
  563
+			dmx_val = frd->dmx[i]*255.0;
  564
+		write(dmx_fd, &dmx_val, 1);
  565
+	}
  566
+}
  567
+
491 568
 struct raster_task_param {
492 569
 	int framebuffer_fd;
493 570
 	int dmx_map[DMX_COUNT];
@@ -518,8 +595,6 @@ static rtems_task raster_task(rtems_task_argument argument)
518 595
 	struct wave_vertex vertices[256];
519 596
 	int nvertices;
520 597
 	int vecho_alpha;
521  
-	int i;
522  
-	unsigned char dmx_val;
523 598
 
524 599
 	status = posix_memalign((void **)&tex_frontbuffer, 32,
525 600
 		2*renderer_texsize*renderer_texsize);
@@ -576,8 +651,9 @@ static rtems_task raster_task(rtems_task_argument argument)
576 651
 		warp(tmu_fd, tex_frontbuffer, tex_backbuffer, frd->vertices, frd->tex_wrap, ibrightness);
577 652
 		compute_wave_vertices(frd, &params, vertices, &nvertices);
578 653
 		ioctl(tmu_fd, TMU_EXECUTE_WAIT);
579  
-		draw(tex_backbuffer, frd, &params, vertices, nvertices);
  654
+		software_draw(tex_backbuffer, frd, &params, vertices, nvertices);
580 655
 		video(tex_backbuffer, frd, tmu_fd, video_fd, scale_vertices);
  656
+		images(tex_backbuffer, frd, tmu_fd, scale_vertices);
581 657
 
582 658
 		/* Scale and send to screen */
583 659
 		screen_backbuffer = get_screen_backbuffer(param->framebuffer_fd);
@@ -595,16 +671,7 @@ static rtems_task raster_task(rtems_task_argument argument)
595 671
 		ioctl(param->framebuffer_fd, FBIOSWAPBUFFERS);
596 672
 
597 673
 		/* Update DMX outputs */
598  
-		for(i=0;i<DMX_COUNT;i++) {
599  
-			lseek(dmx_fd, param->dmx_map[i], SEEK_SET);
600  
-			if(frd->dmx[i] > 1.0)
601  
-				dmx_val = 255;
602  
-			else if(frd->dmx[i] < 0.0)
603  
-				dmx_val = 0;
604  
-			else
605  
-				dmx_val = frd->dmx[i]*255.0;
606  
-			write(dmx_fd, &dmx_val, 1);
607  
-		}
  674
+		update_dmx_outputs(dmx_fd, frd, param->dmx_map);
608 675
 
609 676
 		/* Swap texture buffers */
610 677
 		p = tex_frontbuffer;

0 notes on commit 4d2416d

Please sign in to comment.
Something went wrong with that request. Please try again.