static void
gst_hermes_colorspace_init (GstHermesColorspace * space)
{
  space->sinkpad =
      gst_pad_new_from_static_template
      (&gst_hermes_colorspace_sink_pad_template, "sink");
  gst_pad_set_link_function (space->sinkpad, gst_hermes_colorspace_link);
  gst_pad_set_getcaps_function (space->sinkpad, gst_hermes_colorspace_getcaps);
  gst_pad_set_chain_function (space->sinkpad, gst_hermes_colorspace_chain);
  gst_element_add_pad (GST_ELEMENT (space), space->sinkpad);

  space->srcpad =
      gst_pad_new_from_static_template (&gst_hermes_colorspace_src_pad_template,
      "src");
  gst_element_add_pad (GST_ELEMENT (space), space->srcpad);
  gst_pad_set_link_function (space->srcpad, gst_hermes_colorspace_link);

  space->h_handle = Hermes_ConverterInstance (0);
  space->passthru = FALSE;
}
Ejemplo n.º 2
0
int ctor_plotter_vdi( GEM_PLOTTER self , GRECT * loc_size )
{
	int retval = 0;
	int i;
	struct rect clip;

	self->dtor = dtor;
	self->resize= resize;
	self->move = move;
	self->lock = lock;
	self->unlock = unlock;
	self->put_pixel = put_pixel;
	self->copy_rect = copy_rect;
	self->set_clip = set_clip;
	self->get_clip = get_clip;
	self->arc = arc;
	self->disc = disc;
	self->line = line;
	self->rectangle = rectangle;
	self->polygon = polygon;
	self->path = path;
	self->bitmap = bitmap;
	self->bitmap_resize = bitmap_resize;
	/* override virtual bpp - must be in sync with screen for this driver: 	*/
	self->bpp_virt = app.nplanes;
#ifdef WITH_8BPP_SUPPORT
	self->bitmap_convert =(app.nplanes > 8) ? bitmap_convert : bitmap_convert_8;
#else
	self->bitmap_convert = bitmap_convert;
#endif
	self->plot_mfdb = plot_mfdb;
	self->text = text;
	LOG(("Screen: x: %d, y: %d\n", vdi_sysinfo.scr_w, vdi_sysinfo.scr_h));

	self->priv_data = malloc( sizeof(struct s_vdi_priv_data) );
	if( self->priv_data == NULL )
		return( 0-ERR_NO_MEM );
	memset( self->priv_data, 0, sizeof(struct s_vdi_priv_data) );
	memset( &VIEW(self), 0, sizeof( struct s_view) );
	VIEW( self ).x = loc_size->g_x;
	VIEW( self ).y = loc_size->g_y;
	VIEW( self ).w = loc_size->g_w;
	VIEW( self ).h = loc_size->g_h;
	DUMMY_PRIV(self)->bufops = 0;
	DUMMY_PRIV(self)->size_buf_packed = 0;
	DUMMY_PRIV(self)->size_buf_planar = 0;
	DUMMY_PRIV(self)->buf_packed = NULL;
	DUMMY_PRIV(self)->buf_planar = NULL;
	if( vdi_sysinfo.vdiformat == VDI_FORMAT_PACK  ) {
		self->bpp_virt = vdi_sysinfo.scr_bpp;
	} else {
		DUMMY_PRIV(self)->bufops = C2P;
		self->bpp_virt = 8;
	}

	VIEW(self).mem = NULL;
	update_visible_rect( self );

	clip.x0 = 0;
	clip.y0 = 0;
	clip.x1 = VIEW(self).w;
	clip.y1 = VIEW(self).h;
	self->set_clip( self, &clip );

	assert( Hermes_Init() );
	/* store system palette & setup the new (web) palette: */
#ifdef WITH_8BPP_SUPPORT
	i = 0;

	unsigned char * col;
	unsigned char rgbcol[4];
	unsigned char graytone=0;
	if( app.nplanes <= 8 ){
		for( i=0; i<=255; i++ ) {

			// get the current color and save it for restore:
			vq_color(self->vdi_handle, i, 1, (unsigned short*)&sys_pal[i][0] );
			if( i<OFFSET_WEB_PAL ) {
				pal[i][0] = sys_pal[i][0];
		 		pal[i][1] = sys_pal[i][1];
				pal[i][2] = sys_pal[i][2];
			} else if( app.nplanes >= 8 ) {
				if ( i < OFFSET_CUST_PAL ){
					pal[i][0] = vdi_web_pal[i-OFFSET_WEB_PAL][0];
					pal[i][1] = vdi_web_pal[i-OFFSET_WEB_PAL][1];
					pal[i][2] = vdi_web_pal[i-OFFSET_WEB_PAL][2];
					//set the new palette color to websafe value:
					vs_color( self->vdi_handle, i, &pal[i][0] );
				}
				if( i >= OFFSET_CUST_PAL && i<OFFSET_CUST_PAL+16 ) {
					/* here we define 20 additional gray colors... */
					rgbcol[1] = rgbcol[2] = rgbcol[3] = ((graytone&0x0F) << 4);
					rgb_to_vdi1000( &rgbcol[0], &pal[i][0] );
					vs_color( self->vdi_handle, i, &pal[i][0] );
					graytone++;
				}

			}
			vdi1000_to_rgb( &pal[i][0],  &rgb_lookup[i][0] );
		}

	} else {
		/* no need to change the palette - its application specific */
	}


#endif

	unsigned long flags = ( self->flags & PLOT_FLAG_DITHER ) ? HERMES_CONVERT_DITHER : 0;
	hermes_cnv_h = Hermes_ConverterInstance( flags );
	assert( hermes_cnv_h );
	hermes_res_h = Hermes_ConverterInstance( flags );
	assert( hermes_res_h );

	/* set up the src & dst format: */
	/* netsurf uses RGBA ... */
	DUMMY_PRIV(self)->nsfmt.a = 0xFFUL;
	DUMMY_PRIV(self)->nsfmt.b = 0x0FF00UL;
	DUMMY_PRIV(self)->nsfmt.g = 0x0FF0000UL;
	DUMMY_PRIV(self)->nsfmt.r = 0x0FF000000UL;
	DUMMY_PRIV(self)->nsfmt.bits = 32;
	DUMMY_PRIV(self)->nsfmt.indexed = false;
	DUMMY_PRIV(self)->nsfmt.has_colorkey = false;

	DUMMY_PRIV(self)->vfmt.r = vdi_sysinfo.mask_r;
	DUMMY_PRIV(self)->vfmt.g = vdi_sysinfo.mask_g;
	DUMMY_PRIV(self)->vfmt.b = vdi_sysinfo.mask_b;
	DUMMY_PRIV(self)->vfmt.a = vdi_sysinfo.mask_a;
	DUMMY_PRIV(self)->vfmt.bits = self->bpp_virt;
	DUMMY_PRIV(self)->vfmt.indexed = ( app.nplanes <= 8 ) ? 1 : 0;
	DUMMY_PRIV(self)->vfmt.has_colorkey = 0;

	return( 1 );
}