예제 #1
0
static void rc_sync_actor(RendererClutter *rc)
{
	PixbufRenderer *pr = rc->pr;
	gint anchor_x = 0;
	gint anchor_y = 0;
	gint rot_z = 0;
	gint rot_y = 0;

	clutter_actor_set_anchor_point(CLUTTER_ACTOR(rc->texture), 0, 0);

	DEBUG_3("scale %d %d", rc->pr->width, rc->pr->height);
	DEBUG_3("pos   %d %d", rc->pr->x_offset, rc->pr->y_offset);

	clutter_actor_set_scale(CLUTTER_ACTOR(rc->texture),
			        (gfloat)pr->width / pr->image_width,
			        (gfloat)pr->height / pr->image_height);

	switch (pr->orientation)
		{
		case EXIF_ORIENTATION_TOP_LEFT:
			/* 1 - Horizontal (normal)  */
			break;
		case EXIF_ORIENTATION_TOP_RIGHT:
			/* 2 - Mirror horizontal */
			rot_y = 180;
			anchor_x = pr->width;
			break;
		case EXIF_ORIENTATION_BOTTOM_RIGHT:
			/* 3 - Rotate 180 */
			rot_z = 180;
			anchor_x = pr->width;
			anchor_y = pr->height;
			break;
		case EXIF_ORIENTATION_BOTTOM_LEFT:
			/* 4 - Mirror vertical */
			rot_z = 180;
			rot_y = 180;
			anchor_y = pr->height;
			break;
		case EXIF_ORIENTATION_LEFT_TOP:
			/* 5 - Mirror horizontal and rotate 270 CW */
			rot_z = 270;
			rot_y = 180;
			break;
		case EXIF_ORIENTATION_RIGHT_TOP:
			/* 6 - Rotate 90 CW */
			rot_z = 90;
			anchor_x = pr->width;
			break;
		case EXIF_ORIENTATION_RIGHT_BOTTOM:
			/* 7 - Mirror horizontal and rotate 90 CW */
			rot_z = 90;
			rot_y = 180;
			anchor_x = pr->width;
			anchor_y = pr->height;
			break;
		case EXIF_ORIENTATION_LEFT_BOTTOM:
			/* 8 - Rotate 270 CW */
			rot_z = 270;
			anchor_y = pr->height;
			break;
		default:
			/* The other values are out of range */
			break;
		}

	clutter_actor_set_rotation(	CLUTTER_ACTOR(rc->texture),
								CLUTTER_Z_AXIS,
								rot_z, 0, 0, 0);
	clutter_actor_set_rotation(	CLUTTER_ACTOR(rc->texture),
								CLUTTER_Y_AXIS,
								rot_y, 0, 0, 0);

	clutter_actor_set_position(CLUTTER_ACTOR(rc->texture),
				pr->x_offset - pr->x_scroll + anchor_x,
				pr->y_offset - pr->y_scroll + anchor_y);

}
예제 #2
0
static void rc_prepare_post_process_lut(RendererClutter *rc)
{
	PixbufRenderer *pr = rc->pr;
	static guchar clut[CLUT_SIZE * CLUT_SIZE * CLUT_SIZE * 3];
	guint r, g, b;
	GdkPixbuf *tmp_pixbuf;
	CoglHandle material;
	CoglHandle tex3d;

	DEBUG_3("%s clut start", get_exec_time());

	for (r = 0; r < CLUT_SIZE; r++)
		{
		for (g = 0; g < CLUT_SIZE; g++)
			{
			for (b = 0; b < CLUT_SIZE; b++)
				{
				guchar *ptr = clut + ((b * CLUT_SIZE + g) * CLUT_SIZE + r) * 3;
				ptr[0] = floor ((double) r / (CLUT_SIZE - 1) * 255.0 + 0.5);
				ptr[1] = floor ((double) g / (CLUT_SIZE - 1) * 255.0 + 0.5);
				ptr[2] = floor ((double) b / (CLUT_SIZE - 1) * 255.0 + 0.5);
				}
			}
		}
	tmp_pixbuf = gdk_pixbuf_new_from_data(clut, GDK_COLORSPACE_RGB, FALSE, 8,
					      CLUT_SIZE * CLUT_SIZE,
					      CLUT_SIZE,
					      CLUT_SIZE * CLUT_SIZE * 3,
					      NULL, NULL);
	if (pr->func_post_process)
		{
		pr->func_post_process(pr, &tmp_pixbuf, 0, 0, CLUT_SIZE * CLUT_SIZE, CLUT_SIZE, pr->post_process_user_data);
		}
	g_object_unref(tmp_pixbuf);

	DEBUG_3("%s clut upload start", get_exec_time());
#if COGL_VERSION_CHECK(1,18,2)
	{
	CoglContext *ctx = clutter_backend_get_cogl_context(clutter_get_default_backend ());

	tex3d = cogl_texture_3d_new_from_data(ctx,
					      CLUT_SIZE, CLUT_SIZE, CLUT_SIZE,
					      COGL_PIXEL_FORMAT_RGB_888,
					      CLUT_SIZE * 3,
					      CLUT_SIZE * CLUT_SIZE * 3,
					      clut,
					      NULL);
	}
#elif COGL_VERSION_CHECK(1,10,4)
	{
	CoglContext *ctx = clutter_backend_get_cogl_context(clutter_get_default_backend ());

	tex3d = cogl_texture_3d_new_from_data(ctx,
					      CLUT_SIZE, CLUT_SIZE, CLUT_SIZE,
					      COGL_PIXEL_FORMAT_RGB_888,
					      COGL_PIXEL_FORMAT_RGB_888,
					      CLUT_SIZE * 3,
					      CLUT_SIZE * CLUT_SIZE * 3,
					      clut,
					      NULL);
	}
#else
	tex3d = cogl_texture_3d_new_from_data(CLUT_SIZE, CLUT_SIZE, CLUT_SIZE,
					      COGL_TEXTURE_NONE,
					      COGL_PIXEL_FORMAT_RGB_888,
					      COGL_PIXEL_FORMAT_RGB_888,
					      CLUT_SIZE * 3,
					      CLUT_SIZE * CLUT_SIZE * 3,
					      clut,
					      NULL);
#endif
	material = clutter_texture_get_cogl_material(CLUTTER_TEXTURE(rc->texture));
	cogl_material_set_layer(material, 1, tex3d);
	cogl_handle_unref(tex3d);
	DEBUG_3("%s clut end", get_exec_time());
	rc->clut_updated = TRUE;
}
예제 #3
0
EditorFlags editor_command_parse(const EditorDescription *editor, GList *list, gboolean consider_sidecars, gchar **output)
{
    EditorFlags flags = 0;
    const gchar *p;
    GString *result = NULL;
    gboolean escape = FALSE;
    gboolean single_quotes = FALSE;
    gboolean double_quotes = FALSE;

    DEBUG_2("editor_command_parse: %s %d %d", editor->key, consider_sidecars, !!output);

    if (output)
        result = g_string_new("");

    if (editor->exec[0] == '\0')
    {
        flags |= EDITOR_ERROR_EMPTY;
        goto err;
    }

    p = editor->exec;
    /* skip leading whitespaces if any */
    while (g_ascii_isspace(*p)) p++;

    /* command */

    while (*p)
    {
        if (escape)
        {
            escape = FALSE;
            if (output) result = g_string_append_c(result, *p);
        }
        else if (*p == '\\')
        {
            if (!single_quotes) escape = TRUE;
            if (output) result = g_string_append_c(result, *p);
        }
        else if (*p == '\'')
        {
            if (output) result = g_string_append_c(result, *p);
            if (!single_quotes && !double_quotes)
                single_quotes = TRUE;
            else if (single_quotes)
                single_quotes = FALSE;
        }
        else if (*p == '"')
        {
            if (output) result = g_string_append_c(result, *p);
            if (!single_quotes && !double_quotes)
                double_quotes = TRUE;
            else if (double_quotes)
                double_quotes = FALSE;
        }
        else if (*p == '%' && p[1])
        {
            gchar *pathl = NULL;

            p++;

            switch (*p)
            {
            case 'f': /* single file */
            case 'u': /* single url */
                flags |= EDITOR_FOR_EACH;
                if (flags & EDITOR_SINGLE_COMMAND)
                {
                    flags |= EDITOR_ERROR_INCOMPATIBLE;
                    goto err;
                }
                if (list)
                {
                    /* use the first file from the list */
                    if (!list->data)
                    {
                        flags |= EDITOR_ERROR_NO_FILE;
                        goto err;
                    }
                    pathl = editor_command_path_parse((FileData *)list->data,
                                                      consider_sidecars,
                                                      (*p == 'f') ? PATH_FILE : PATH_FILE_URL,
                                                      editor);
                    if (!output)
                    {
                        /* just testing, check also the rest of the list (like with F and U)
                           any matching file is OK */
                        GList *work = list->next;

                        while (!pathl && work)
                        {
                            FileData *fd = work->data;
                            pathl = editor_command_path_parse(fd,
                                                              consider_sidecars,
                                                              (*p == 'f') ? PATH_FILE : PATH_FILE_URL,
                                                              editor);
                            work = work->next;
                        }
                    }

                    if (!pathl)
                    {
                        flags |= EDITOR_ERROR_NO_FILE;
                        goto err;
                    }
                    if (output)
                    {
                        result = append_quoted(result, pathl, single_quotes, double_quotes);
                    }
                    g_free(pathl);
                }
                break;

            case 'F':
            case 'U':
                flags |= EDITOR_SINGLE_COMMAND;
                if (flags & (EDITOR_FOR_EACH | EDITOR_DEST))
                {
                    flags |= EDITOR_ERROR_INCOMPATIBLE;
                    goto err;
                }

                if (list)
                {
                    /* use whole list */
                    GList *work = list;
                    gboolean ok = FALSE;

                    while (work)
                    {
                        FileData *fd = work->data;
                        pathl = editor_command_path_parse(fd, consider_sidecars, (*p == 'F') ? PATH_FILE : PATH_FILE_URL, editor);
                        if (pathl)
                        {
                            ok = TRUE;

                            if (output)
                            {
                                ok = TRUE;
                                if (work != list) g_string_append_c(result, ' ');
                                result = append_quoted(result, pathl, single_quotes, double_quotes);
                            }
                            g_free(pathl);
                        }
                        work = work->next;
                    }
                    if (!ok)
                    {
                        flags |= EDITOR_ERROR_NO_FILE;
                        goto err;
                    }
                }
                break;
            case 'i':
                if (editor->icon && *editor->icon)
                {
                    if (output)
                    {
                        result = g_string_append(result, "--icon ");
                        result = append_quoted(result, editor->icon, single_quotes, double_quotes);
                    }
                }
                break;
            case 'c':
                if (output)
                {
                    result = append_quoted(result, editor->name, single_quotes, double_quotes);
                }
                break;
            case 'k':
                if (output)
                {
                    result = append_quoted(result, editor->file, single_quotes, double_quotes);
                }
                break;
            case '%':
                /* %% = % escaping */
                if (output) result = g_string_append_c(result, *p);
                break;
            case 'd':
            case 'D':
            case 'n':
            case 'N':
            case 'v':
            case 'm':
                /* deprecated according to spec, ignore */
                break;
            default:
                flags |= EDITOR_ERROR_SYNTAX;
                goto err;
            }
        }
        else
        {
            if (output) result = g_string_append_c(result, *p);
        }
        p++;
    }

    if (!(flags & (EDITOR_FOR_EACH | EDITOR_SINGLE_COMMAND))) flags |= EDITOR_NO_PARAM;

    if (output)
    {
        *output = g_string_free(result, FALSE);
        DEBUG_3("Editor cmd: %s", *output);
    }

    return flags;


err:
    if (output)
    {
        g_string_free(result, TRUE);
        *output = NULL;
    }
    return flags;
}
예제 #4
0
static void rc_set_shader(CoglHandle material, const RendererClutterShaderInfo *shaderInfo)
{
	CoglHandle shader;
	CoglHandle program;
	gint uniform_no;

	shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
	cogl_shader_source (shader,
	"vec3 checker(vec2 texc, vec3 color0, vec3 color1)						\n"
	"{																		\n"
	"  if (mod(floor(texc.x) + floor(texc.y), 2.0) == 0.0)					\n"
	"    return color0;														\n"
	"  else																	\n"
	"    return color1;														\n"
	"}																		\n"
	"																		\n"
	"uniform sampler2D tex;													\n"
	"uniform sampler3D clut;												\n"
	"uniform float scale;													\n"
	"uniform float offset;													\n"
	"uniform float checkersize;												\n"
	"uniform vec3 color0;													\n"
	"uniform vec3 color1;													\n"
	"																		\n"
	"void main(void)														\n"
	"{																		\n"
	"    vec3 bg = checker(gl_FragCoord.xy / checkersize, color0, color1);	\n"
	"    vec4 img4 = texture2D(tex, gl_TexCoord[0].xy);						\n"
	"    vec3 img3 = img4.bgr;												\n"
	"    img3 = img3 * scale + offset;										\n"
	"    img3 = texture3D(clut, img3).rgb;									\n"
	"																		\n"
	"    gl_FragColor = vec4(img3 * img4.a + bg * (1.0 - img4.a), 1.0);		\n"
	"}																		\n"
	);
	cogl_shader_compile(shader);
	gchar *err = cogl_shader_get_info_log(shader);
	DEBUG_3("%s\n",err);
	g_free(err);

	program = cogl_create_program ();
	cogl_program_attach_shader (program, shader);
	cogl_handle_unref (shader);
	cogl_program_link (program);

	uniform_no = cogl_program_get_uniform_location (program, "tex");
	cogl_program_set_uniform_1i (program, uniform_no, 0);

	uniform_no = cogl_program_get_uniform_location (program, "clut");
	cogl_program_set_uniform_1i (program, uniform_no, 1);

	uniform_no = cogl_program_get_uniform_location (program, "scale");
	cogl_program_set_uniform_1f (program, uniform_no, (double) (CLUT_SIZE - 1) / CLUT_SIZE);

	uniform_no = cogl_program_get_uniform_location (program, "offset");
	cogl_program_set_uniform_1f (program, uniform_no, 1.0 / (2 * CLUT_SIZE));

	uniform_no = cogl_program_get_uniform_location (program, "checkersize");
	cogl_program_set_uniform_1f (program, uniform_no, shaderInfo->checkersize);

	uniform_no = cogl_program_get_uniform_location (program, "color0");
	cogl_program_set_uniform_float (program, uniform_no, 3, 1, shaderInfo->checkercolor0);

	uniform_no = cogl_program_get_uniform_location (program, "color1");
	cogl_program_set_uniform_float (program, uniform_no, 3, 1, shaderInfo->checkercolor1);

	cogl_material_set_user_program (material, program);
	cogl_handle_unref (program);
}
예제 #5
0
////////////////////////////////////////////////////////////////////////////////
// listenbootp
// PURPOSE: Listens for bootp response, returns status after one packet
//          received.
// PARAMS:  (IN)  u32 xid     - xid from the bootp request we sent.
//          (OUT) u32 *ciaddr - Clients (our) IP address.
//          (OUT) u32 *siaddr - Servers IP address.
// RETURNS: int - 0 for failure, 1 for success.
////////////////////////////////////////////////////////////////////////////////
static int
listenbootp(u32 xid,
            u32 *ciaddr,
            u32 *siaddr,
	    u32 *giaddr,
	    u32 *smask,
	    char *bootfile)
{
   u8 packet[MAX_PACKET_SIZE];
   u16 size = MAX_PACKET_SIZE;
   u8 *bootppacket = packet + UDPIP_HEADER_SIZE;
   u32 rxid;
   u32 iaddr;
   u32 time = get_time_timer() + NET_TIMEOUT;
   u32 client_iaddr;
   u32 server_iaddr;
   //scratch variables for parse_options_dhcp; we don't care about these
   u8 msg_type;
   u32 sid;

   while(1)
   {
      u8 bootp_type;

      if (time < get_time_timer())
      {
         // We timed out receiving reply
         // We can't rely on the udplisten timeout because we could
         // theoretically receive a steady supply of miscellaneous packets
         // so it will never time out.
         return 0;
      }

      if(udplisten(packet, &size, &iaddr, 1))
      {

         bootp_type = *bootppacket;
         bootppacket += 4;

         rxid = (*(bootppacket++) << 24);
         rxid |= (*(bootppacket++) << 16);
         rxid |= (*(bootppacket++) << 8);
         rxid |= *(bootppacket++);
         bootppacket += sizeof(u32) * 2;

         if(rxid == xid && bootp_type == BOOTP_REPLY)
         {
            client_iaddr = *bootppacket++ << 24;
            client_iaddr |= *bootppacket++ << 16;
            client_iaddr |= *bootppacket++ << 8;
            client_iaddr |= *bootppacket++;

            server_iaddr = *bootppacket++ << 24;
            server_iaddr |= *bootppacket++ << 16;
            server_iaddr |= *bootppacket++ << 8;
            server_iaddr |= *bootppacket++;

            break;
         }
      }
   }

   //skip the relay agent ip field
   bootppacket += sizeof(u32);
   //skip the hardware address field
   bootppacket += 16;
   //skip the servername field
   bootppacket += 64;
   //skip the bootfile field
   itc_strcpy(bootfile, (char *)bootppacket);
   DEBUG_3("Bootfile: %s\r\n", bootfile);
   bootppacket += 128;
   //skip the magic cookie
   bootppacket += sizeof(u32);

   parse_options_dhcp(bootppacket, giaddr, smask, &sid, &msg_type);

   *ciaddr = client_iaddr;
   *siaddr = server_iaddr;

   return 1;
}