static gboolean
insanity_gst_pipeline_test_start (InsanityTest * test)
{
  InsanityGstPipelineTest *ptest = INSANITY_GST_PIPELINE_TEST (test);
  InsanityGstPipelineTestPrivateData *priv = ptest->priv;

  g_assert (priv->loop == NULL);
  priv->loop = g_main_loop_new (NULL, FALSE);

  if (priv->create_pipeline_in_start) {
    if (!create_pipeline (ptest))
      return FALSE;
  }

  if (!INSANITY_TEST_CLASS (insanity_gst_pipeline_test_parent_class)->start
      (test))
    return FALSE;

  priv->reached_initial_state = FALSE;
  priv->error_count = 0;
  priv->tag_count = 0;
  priv->element_count = 0;
  priv->wait_timeout_id = 0;
  priv->is_live = FALSE;
  priv->buffering = FALSE;
  priv->enable_buffering = TRUE;
  priv->done = FALSE;

  add_element_used (ptest, GST_ELEMENT (ptest->priv->pipeline));

  return TRUE;
}
void Smoke::attach_shell(Shell &sh)
{
    Game::attach_shell(sh);

    const Shell::Context &ctx = sh.context();
    physical_dev_ = ctx.physical_dev;
    dev_ = ctx.dev;
    queue_ = ctx.game_queue;
    queue_family_ = ctx.game_queue_family;
    format_ = ctx.format.format;

    vk::GetPhysicalDeviceProperties(physical_dev_, &physical_dev_props_);

    if (use_push_constants_ &&
        sizeof(ShaderParamBlock) > physical_dev_props_.limits.maxPushConstantsSize) {
        shell_->log(Shell::LOG_WARN, "cannot enable push constants");
        use_push_constants_ = false;
    }

    VkPhysicalDeviceMemoryProperties mem_props;
    vk::GetPhysicalDeviceMemoryProperties(physical_dev_, &mem_props);
    mem_flags_.reserve(mem_props.memoryTypeCount);
    for (uint32_t i = 0; i < mem_props.memoryTypeCount; i++)
        mem_flags_.push_back(mem_props.memoryTypes[i].propertyFlags);

    meshes_ = new Meshes(dev_, mem_flags_);

    create_render_pass();
    create_shader_modules();
    create_descriptor_set_layout();
    create_pipeline_layout();
    create_pipeline();

    create_frame_data(2);

    render_pass_begin_info_.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
    render_pass_begin_info_.renderPass = render_pass_;
    render_pass_begin_info_.clearValueCount = 1;
    render_pass_begin_info_.pClearValues = &render_pass_clear_value_;

    primary_cmd_begin_info_.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
    primary_cmd_begin_info_.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;

    // we will render to the swapchain images
    primary_cmd_submit_wait_stages_ = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT;

    primary_cmd_submit_info_.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
    primary_cmd_submit_info_.waitSemaphoreCount = 1;
    primary_cmd_submit_info_.pWaitDstStageMask = &primary_cmd_submit_wait_stages_;
    primary_cmd_submit_info_.commandBufferCount = 1;
    primary_cmd_submit_info_.signalSemaphoreCount = 1;

    if (multithread_) {
        for (auto &worker : workers_)
            worker->start();
    }
}
void
test_primitive_and_journal (void)
{
  CoglPrimitive *primitives[2];
  CoglPipeline *pipeline;

  setup_orthographic_modelview ();
  create_primitives (primitives);
  pipeline = create_pipeline ();

  /* Set a clip to clip all three rectangles to just the bottom half.
   * The journal flushes its own clip state so this verifies that the
   * clip state is correctly restored for the second primitive. */
  cogl_framebuffer_push_rectangle_clip (test_fb,
                                        0, 50, 300, 100);

  cogl_primitive_draw (primitives[0], test_fb, pipeline);

  /* Draw a rectangle using the journal in-between the two primitives.
   * This should test that the journal gets flushed correctly and that
   * the modelview matrix is restored. Half of the rectangle should be
   * overriden by the second primitive */
  cogl_framebuffer_draw_rectangle (test_fb,
                                   pipeline,
                                   100, 0, /* x1/y1 */
                                   300, 100 /* x2/y2 */);

  cogl_primitive_draw (primitives[1], test_fb, pipeline);

  /* Check the three rectangles */
  test_utils_check_region (test_fb,
                           1, 51,
                           98, 48,
                           0xff0000ff);
  test_utils_check_region (test_fb,
                           101, 51,
                           98, 48,
                           0x00ff00ff);
  test_utils_check_region (test_fb,
                           201, 51,
                           98, 48,
                           0x0000ffff);

  /* Check that the top half of all of the rectangles was clipped */
  test_utils_check_region (test_fb,
                           1, 1,
                           298, 48,
                           0x000000ff);

  cogl_framebuffer_pop_clip (test_fb);

  if (cogl_test_verbose ())
    g_print ("OK\n");
}
	optional<vk::vk_pipeline<>> recreate_pipeline() override final {
		// Slice old pipeline, if any, storing the old vk::vk_pipeline object.
		optional<vk::vk_pipeline<>> old_pipeline;
		if (graphics_pipeline) {
			vk::vk_pipeline<> &old_pipeline_object = graphics_pipeline.get();
			old_pipeline = std::move(old_pipeline_object);
		}

		create_pipeline();

		return old_pipeline;
	}
static void
run_gui (const gchar * filename)
{
  GtkWidget *vbox, *hbox;
  AppInfo *info;

  info = g_new0 (AppInfo, 1);

  /* create pipeline */
  if (!create_pipeline (info, filename))
    goto done;

  /* create window */
  info->win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect (info->win, "delete-event", G_CALLBACK (gtk_main_quit),
      NULL);

  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
  gtk_container_add (GTK_CONTAINER (info->win), vbox);

  info->img = gtk_image_new ();
  gtk_box_pack_start (GTK_BOX (vbox), info->img, FALSE, FALSE, 6);

  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 6);

  info->accurate_cb = gtk_check_button_new_with_label ("accurate seek "
      "(might not work reliably with all demuxers)");
  gtk_box_pack_start (GTK_BOX (hbox), info->accurate_cb, FALSE, FALSE, 6);
  g_signal_connect (info->accurate_cb, "toggled",
      G_CALLBACK (accurate_toggled_cb), info);

  info->slider = gtk_scale_new_with_range (GTK_ORIENTATION_HORIZONTAL,
      0.0, 1.0, 0.001);
  gtk_box_pack_start (GTK_BOX (vbox), info->slider, FALSE, FALSE, 6);
  g_signal_connect (info->slider, "value-changed",
      G_CALLBACK (slider_cb), info);
  g_signal_connect (info->slider, "format-value",
      G_CALLBACK (slider_format_value_cb), info);

  /* and go! */
  gst_element_set_state (info->pipe, GST_STATE_PAUSED);

  gtk_widget_show_all (info->win);
  gtk_widget_hide (info->slider);       /* hide until we're prerolled */
  gtk_main ();

done:

  g_free (info);
}
Esempio n. 6
0
int main(int argc, char** argv)
{
    pid_t pid;
    int pipeline[2];
    char pipeReadBuffer[GCC_OUTPUT_BUFFER_SIZE] = {0};   
    
    
    // Traitement des taches du parent
    execute_folder_operations(get_folder_path(argc, argv));
    cFilesList = get_c_files(cFilesList);
    check_folder_has_cFiles(cFilesList);
    create_pipeline(pipeline);
    pid = create_child();
    
    
    if (pid > 0) { // PARENT - Ajustements propre a ce processus
        free_array_of_array(cFilesList);        // Free, cFilesList maintenant inutile pour ce processus
        signal(SIGINT, set_run_status);         // Gestion de la fin du prog par le processus parent
        
        while (RUN) {                           // Lance la lecture sur pipe avec enfant
            read(pipeline[0], pipeReadBuffer, sizeof(pipeReadBuffer));
            
            if (strlen(pipeReadBuffer) != 0)
                //printf("DEBUG-> Parent received:\n%s", pipeReadBuffer);
                printf("%s", pipeReadBuffer);
                
            strcpy(pipeReadBuffer, "");         // Vide buffer
        }
        
        kill(pid, SIGUSR1);                     // Kill Child Process
        wait(NULL);
        
    } else {       // ENFANT - Lance les operations de traitements
        sigignore(SIGINT);                      // Le parent s'occupe de tuer l'enfant        
        signal(SIGUSR1, child_clean_atexit);    // Ecoute directive de terminaison envoyee par le parent
        initMutex();                            // Initialisation du ou des mutex(es)
        
        while (1) {
            JobsList = update_JobsList(JobsList, cFilesList); // Ajout d'une "job" pour tous les nouveaux fichiers

            if (JobsList != NULL)
                update_threads(JobsList, pipeline); // Creation d'un thread pour les nouvelles "Jobs" dans le tableau
            
            sleep(FOLDER_POLLING_DELAY);            // Inutile de verifier le dossier trop rapidement...
            
            cFilesList = free_array_of_array(cFilesList); // Nettoyage
            cFilesList = get_c_files(cFilesList);   // Update la liste et boucle...
        }
    }
    
    return (EXIT_SUCCESS);
}
Esempio n. 7
0
gint
main (gint argc, gchar * argv[])
{
  gst_init (&argc, &argv);

  g_print ("\n"
      "This test will test the various formats ALSA and GStreamer support.\n"
      "You will hear a short sine tone on your default ALSA soundcard for every\n"
      "format tested. They should all sound the same (incl. volume).\n" "\n");
  create_pipeline ();

  while (pipeline) {
    gst_bin_iterate (GST_BIN (pipeline));
    if ((counter / 200) > last) {
      last = counter / 200;
      gst_object_unref (pipeline);
      create_pipeline ();
    }
  }

  return 0;
}
	void update() override final {
		// Make sure we have framebuffer attached
		if (attached_framebuffer == nullptr) {
			throw device_pipeline_no_attached_framebuffer_exception("Attempting to bind graphics pipeline without attaching a framebuffer first");
		}
		// Update framebuffer
		attached_framebuffer->update();

		// Recreate invalidated pipeline object before binding, as needed
		if (!graphics_pipeline) {
			create_pipeline();
		}
	}
Esempio n. 9
0
int main (int argc, char *argv[])
{
    /* Initialisation */
    gst_init (&argc, &argv);

    /* Initialize GTK */
    gtk_init (&argc, &argv);

    /* initialize out gstreamer pipeline */
    create_pipeline();

    /* create our window that shall display everything */
    w = create_ui();
    
    /* do not display the video in own frame but integrate it into our window */
    gst_x_overlay_set_window_handle(GST_X_OVERLAY(p.sink), GDK_WINDOW_XID(w->video_window->window));

    /* Set the pipeline to "playing" state */
    g_print ("Now playing stream from: %s\n", CAMERA);

    /*
       IMPORTANT after state changed to playing the capabilities are fixed.
     */
    gst_element_set_state (p.pipeline, GST_STATE_PLAYING);

    g_print ("Running...");

    /* finished construction and now run the main loop while waiting for user interaction */
    g_main_loop_run (p.loop);

    
    /* ===== clean up ===== */

    /* Out of the main loop, clean up nicely */
    g_print ("Returned, stopping playback\n");
    gst_element_set_state (p.pipeline, GST_STATE_PAUSED);
    gst_element_set_state (p.pipeline, GST_STATE_NULL);

    g_print("Deleting pipeline\n");
    gst_object_unref (GST_OBJECT (p.pipeline));
    g_source_remove (p.bus_watch_id);
    g_main_loop_unref (p.loop);

    free(w);
    w = NULL;

    return 0;
}
static gboolean
insanity_gst_pipeline_test_setup (InsanityTest * test)
{
  InsanityGstPipelineTest *ptest = INSANITY_GST_PIPELINE_TEST (test);
  InsanityGstPipelineTestPrivateData *priv = ptest->priv;

  if (!INSANITY_TEST_CLASS (insanity_gst_pipeline_test_parent_class)->setup
      (test))
    return FALSE;

  priv->elements_used =
      g_hash_table_new_full (&g_str_hash, &g_str_equal, &g_free, &g_free);

  if (!priv->create_pipeline_in_start)
    return create_pipeline (ptest);

  return TRUE;
}
Esempio n. 11
0
static void *
init (CoglContext *context,
      CoglGstVideoSink *sink)
{
  Data *data = g_new0 (Data, 1);
  CoglContext *ctx;

  data->context = ctx = cogl_object_ref (context);
  data->sink = g_object_ref (sink);

  data->borders = borders_new (context);

  create_pipeline (data);

  cogl_gst_video_sink_set_default_sample (data->sink, FALSE);

  return data;
}
Esempio n. 12
0
G_GNUC_INTERNAL
VideoDecoder* create_gstreamer_decoder(int codec_type, display_stream *stream)
{
    SpiceGstDecoder *decoder = NULL;

    if (gstvideo_init()) {
        decoder = spice_new0(SpiceGstDecoder, 1);
        decoder->base.destroy = spice_gst_decoder_destroy;
        decoder->base.reschedule = spice_gst_decoder_reschedule;
        decoder->base.queue_frame = spice_gst_decoder_queue_frame;
        decoder->base.codec_type = codec_type;
        decoder->base.stream = stream;
        g_mutex_init(&decoder->queues_mutex);
        decoder->decoding_queue = g_queue_new();
        decoder->display_queue = g_queue_new();

        if (!create_pipeline(decoder)) {
            decoder->base.destroy((VideoDecoder*)decoder);
            decoder = NULL;
        }
    }

    return (VideoDecoder*)decoder;
}
Esempio n. 13
0
int
main (int argc, gchar ** argv)
{
  GError *err = NULL;
  gchar *outputuri = NULL;
  gchar *container = (gchar *) "application/ogg";
  gchar *audio = (gchar *) "audio/x-vorbis";
  gchar *video = (gchar *) "video/x-theora";
  gchar *video_restriction = (gchar *) "ANY";
  gchar *audio_preset = NULL;
  gchar *video_preset = NULL;
  gchar *exclude_args = NULL;
  static gboolean render = FALSE;
  static gboolean smartrender = FALSE;
  static gboolean list_transitions = FALSE;
  static gboolean list_patterns = FALSE;
  static gdouble thumbinterval = 0;
  static gboolean verbose = FALSE;
  gchar *save_path = NULL;
  gchar *load_path = NULL;
  gchar *project_path = NULL;
  GOptionEntry options[] = {
    {"thumbnail", 'm', 0.0, G_OPTION_ARG_DOUBLE, &thumbinterval,
        "Take thumbnails every n seconds (saved in current directory)", "N"},
    {"render", 'r', 0, G_OPTION_ARG_NONE, &render,
        "Render to outputuri", NULL},
    {"smartrender", 's', 0, G_OPTION_ARG_NONE, &smartrender,
        "Render to outputuri, and avoid decoding/reencoding", NULL},
    {"outputuri", 'o', 0, G_OPTION_ARG_STRING, &outputuri,
        "URI to encode to", "URI (<protocol>://<location>)"},
    {"format", 'f', 0, G_OPTION_ARG_STRING, &container,
        "Container format", "<GstCaps>"},
    {"vformat", 'v', 0, G_OPTION_ARG_STRING, &video,
        "Video format", "<GstCaps>"},
    {"aformat", 'a', 0, G_OPTION_ARG_STRING, &audio,
        "Audio format", "<GstCaps>"},
    {"vrestriction", 'x', 0, G_OPTION_ARG_STRING, &video_restriction,
        "Video restriction", "<GstCaps>"},
    {"apreset", 0, 0, G_OPTION_ARG_STRING, &audio_preset,
        "Encoding audio profile preset", "<GstPresetName>"},
    {"vpreset", 0, 0, G_OPTION_ARG_STRING, &video_preset,
        "Encoding video profile preset", "<GstPresetName>"},
    {"repeat", 'l', 0, G_OPTION_ARG_INT, &repeat,
        "Number of time to repeat timeline", NULL},
    {"list-transitions", 't', 0, G_OPTION_ARG_NONE, &list_transitions,
        "List valid transition types and exit", NULL},
    {"list-patterns", 'p', 0, G_OPTION_ARG_NONE, &list_patterns,
        "List patterns and exit", NULL},
    {"save", 'z', 0, G_OPTION_ARG_STRING, &save_path,
        "Save project to file before rendering", "<path>"},
    {"load", 'q', 0, G_OPTION_ARG_STRING, &load_path,
        "Load project from file before rendering", "<path>"},
    {"verbose", 0, 0, G_OPTION_ARG_NONE, &verbose,
        "Output status information and property notifications", NULL},
    {"exclude", 'X', 0, G_OPTION_ARG_NONE, &exclude_args,
        "Do not output status information of TYPE", "TYPE1,TYPE2,..."},
    {"load-xptv", 'y', 0, G_OPTION_ARG_STRING, &project_path,
        "Load xptv project from file for previewing", "<path>"},
    {NULL}
  };
  GOptionContext *ctx;
  GMainLoop *mainloop;
  GstBus *bus;

  ctx = g_option_context_new ("- plays or renders a timeline.");
  g_option_context_set_summary (ctx,
      "ges-launch renders a timeline, which can be specified on the commandline,\n"
      "or loaded from a file using the -q option.\n\n"
      "A timeline is a list of files, patterns, and transitions to be rendered\n"
      "one after the other. Files and Patterns provide video and audio as the\n"
      "primary input, and transitions animate between the end of one file/pattern\n"
      "and the beginning of a new one. Hence, transitions can only be listed\n"
      "in between patterns or files.\n\n"
      "A file is a triplet of filename, inpoint (in seconds) and\n"
      "duration (in seconds). If the duration is 0, the full file length is used.\n\n"
      "Patterns and transitions are triplets that begin with either \"+pattern\"\n"
      "or \"+transition\", followed by a <type> and duration (in seconds, must be\n"
      "greater than 0)\n\n"
      "Durations in all cases can be fractions of a second.\n\n"
      "Example:\n"
      "ges-launch file1.avi 0 45 +transition crossfade 3.5 file2.avi 0 0");
  g_option_context_add_main_entries (ctx, options, NULL);
  g_option_context_add_group (ctx, gst_init_get_option_group ());

  if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
    g_printerr ("Error initializing: %s\n", err->message);
    g_option_context_free (ctx);
    exit (1);
  }

  /* Initialize the GStreamer Editing Services */
  if (!ges_init ()) {
    g_printerr ("Error initializing GES\n");
    exit (1);
  }

  if (list_transitions) {
    print_transition_list ();
    exit (0);
  }

  if (list_patterns) {
    print_pattern_list ();
    exit (0);
  }

  if (project_path) {
    load_project (project_path);
    exit (0);
  }
  if (((!load_path && (argc < 4))) || (outputuri && (!render && !smartrender))) {
    g_printf ("%s", g_option_context_get_help (ctx, TRUE, NULL));
    g_option_context_free (ctx);
    exit (1);
  }

  g_option_context_free (ctx);

  /* normalize */
  if (strcmp (audio, "none") == 0)
    audio = NULL;
  if (strcmp (video, "none") == 0)
    video = NULL;

  /* Create the pipeline */
  pipeline = create_pipeline (load_path, save_path, argc - 1, argv + 1,
      audio, video);
  if (!pipeline)
    exit (1);

  /* Setup profile/encoding if needed */
  if (render || smartrender) {
    GstEncodingProfile *prof;

    prof = make_encoding_profile (audio, video, video_restriction, audio_preset,
        video_preset, container);

    if (!prof ||
        !ges_timeline_pipeline_set_render_settings (pipeline, outputuri, prof)
        || !ges_timeline_pipeline_set_mode (pipeline,
            smartrender ? TIMELINE_MODE_SMART_RENDER : TIMELINE_MODE_RENDER))
      exit (1);

    g_free (outputuri);
    gst_encoding_profile_unref (prof);
  } else {
    ges_timeline_pipeline_set_mode (pipeline, TIMELINE_MODE_PREVIEW);
  }

  if (verbose) {
    gchar **exclude_list =
        exclude_args ? g_strsplit (exclude_args, ",", 0) : NULL;
    g_signal_connect (pipeline, "deep-notify",
        G_CALLBACK (gst_object_default_deep_notify), exclude_list);
  }

  /* Play the pipeline */
  mainloop = g_main_loop_new (NULL, FALSE);

  if (thumbinterval != 0.0) {
    g_printf ("thumbnailing every %f seconds\n", thumbinterval);
    g_timeout_add (1000 * thumbinterval, thumbnail_cb, pipeline);
  }

  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_signal_watch (bus);
  g_signal_connect (bus, "message", G_CALLBACK (bus_message_cb), mainloop);

  if (gst_element_set_state (GST_ELEMENT (pipeline),
          GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
    g_error ("Failed to start the encoding\n");
    return 1;
  }
  g_main_loop_run (mainloop);

  gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);

  gst_object_unref (pipeline);

  return (int) seenerrors;
}
Esempio n. 14
0
static GtkWidget *
get_voice_test_frame(PurplePlugin *plugin)
{
	GtkWidget *vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER);
	GtkWidget *level = gtk_progress_bar_new();
	GtkWidget *volume = gtk_hscale_new_with_range(0, 100, 1);
	GtkWidget *threshold = gtk_hscale_new_with_range(0, 100, 1);
	GtkWidget *label;
	GtkTable *table = GTK_TABLE(gtk_table_new(2, 2, FALSE));

	GstElement *pipeline;
	GstBus *bus;
	BusCbCtx *ctx;

	g_object_set(vbox, "width-request", 500, NULL);

	gtk_table_set_row_spacings(table, PIDGIN_HIG_BOX_SPACE);
	gtk_table_set_col_spacings(table, PIDGIN_HIG_BOX_SPACE);

	label = gtk_label_new(_("Volume:"));
	g_object_set(label, "xalign", 0.0, NULL);
	gtk_table_attach(table, label, 0, 1, 0, 1, GTK_FILL, 0, 0, 0);
	gtk_table_attach_defaults(table, volume, 1, 2, 0, 1);
	label = gtk_label_new(_("Silence threshold:"));
	g_object_set(label, "xalign", 0.0, "yalign", 1.0, NULL);
	gtk_table_attach(table, label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 0, 0);
	gtk_table_attach_defaults(table, threshold, 1, 2, 1, 2);

	gtk_container_add(GTK_CONTAINER(vbox), level);
	gtk_container_add(GTK_CONTAINER(vbox), GTK_WIDGET(table));
	gtk_widget_show_all(vbox);

	pipeline = create_pipeline();
	bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
	gst_bus_add_signal_watch(bus);
	ctx = g_new(BusCbCtx, 1);
	ctx->level = GTK_PROGRESS_BAR(level);
	ctx->threshold = GTK_RANGE(threshold);
	g_signal_connect_data(bus, "message", G_CALLBACK(gst_bus_cb),
			ctx, (GClosureNotify)g_free, 0);
	gst_object_unref(bus);

	g_signal_connect(volume, "value-changed",
			(GCallback)on_volume_change_cb, pipeline);

	gtk_range_set_value(GTK_RANGE(volume),
			purple_prefs_get_int("/purple/media/audio/volume/input"));
	gtk_widget_set(volume, "draw-value", FALSE, NULL);

	gtk_range_set_value(GTK_RANGE(threshold),
			purple_prefs_get_int("/purple/media/audio/silence_threshold"));

	g_signal_connect(vbox, "destroy",
			G_CALLBACK(voice_test_frame_destroy_cb), pipeline);
	g_signal_connect(volume, "destroy",
			G_CALLBACK(volume_scale_destroy_cb), NULL);
	g_signal_connect(threshold, "format-value",
			G_CALLBACK(threshold_value_format_cb), NULL);
	g_signal_connect(threshold, "destroy",
			G_CALLBACK(threshold_scale_destroy_cb), NULL);

	return vbox;
}
int main(int argc, char **argv)
{
	static const struct option options[] = {
		{ "depth", 1, NULL, 'd' },
		{ "help", 0, NULL, 'h' },
		{ "regenerate", 0, NULL, 'r' },
		{ "subdivisions", 1, NULL, 's' },
		{ "transform", 0, NULL, 't' },
		{ "version", 0, NULL, 'V' },
		{ NULL, 0, NULL, 0 },
	};
	struct framebuffer *display;
	struct framebuffer *source;
	struct pipeline *pipeline;
	unsigned long depth = 24;
	bool regenerate = false;
	float duration, texels;
	unsigned int frames;
	uint64_t start, end;
	struct timespec ts;
	struct gles *gles;
	int opt;

	while ((opt = getopt_long(argc, argv, "d:hrs:tV", options, NULL)) != -1) {
		switch (opt) {
		case 'd':
			depth = strtoul(optarg, NULL, 10);
			if (!depth) {
				fprintf(stderr, "invalid depth: %s\n", optarg);
				return 1;
			}
			break;

		case 'h':
			usage(stdout, argv[0]);
			return 0;

		case 'r':
			regenerate = true;
			break;

		case 's':
			subdivisions = strtoul(optarg, NULL, 10);
			break;

		case 't':
			transform = true;
			break;

		case 'V':
			printf("%s %s\n", argv[0], PACKAGE_VERSION);
			return 0;

		default:
			fprintf(stderr, "invalid option: '%c'\n", opt);
			return 1;
		}
	}

	if (optind >= argc) {
		usage(stderr, argv[0]);
		return 1;
	}

	gles = gles_new(depth, regenerate);
	if (!gles) {
		fprintf(stderr, "gles_new() failed\n");
		return 1;
	}

	display = display_framebuffer_new(gles->width, gles->height);
	if (!display) {
		fprintf(stderr, "display_framebuffer_new() failed\n");
		return 1;
	}

	source = framebuffer_new(gles->width, gles->height);
	if (!source) {
		fprintf(stderr, "failed to create framebuffer\n");
		return 1;
	}

	pipeline = create_pipeline(gles, argc - optind, &argv[optind],
				   regenerate, source);
	if (!pipeline) {
		fprintf(stderr, "failed to create pipeline\n");
		return 1;
	}

	texels = gles->width * gles->height * FRAME_COUNT;

	clock_gettime(CLOCK_MONOTONIC, &ts);
	start = timespec_to_usec(&ts);

	for (frames = 0; frames < FRAME_COUNT; frames++)
		pipeline_render(pipeline);

	clock_gettime(CLOCK_MONOTONIC, &ts);
	end = timespec_to_usec(&ts);

	pipeline_free(pipeline);
	framebuffer_free(source);
	display_framebuffer_free(display);
	gles_free(gles);

	duration = (end - start) / 1000000.0f;
	printf("Rendered %d frames in %fs\n", FRAME_COUNT, duration);
	printf("Average fps was %.02f\n", FRAME_COUNT / duration);
	printf("MTexels/s: %fs\n", (texels / 1000000.0f) / duration);

	return 0;
}
Esempio n. 16
0
void
test_alpha_textures (void)
{
  CoglTexture *tex1, *tex2;
  CoglPipeline *pipeline1, *pipeline2;
  int fb_width = cogl_framebuffer_get_width (test_fb);
  int fb_height = cogl_framebuffer_get_height (test_fb);
  uint8_t replacement_data[1] = { 0xff };

  create_pipeline (&tex1, &pipeline1);

  cogl_framebuffer_draw_rectangle (test_fb,
                                   pipeline1,
                                   -1.0f, 1.0f, /* x1/y1 */
                                   1.0f, 0.0f /* x2/y2 */);

  create_pipeline (&tex2, &pipeline2);

  cogl_texture_set_region (tex2,
                           1, 1, /* width / height */
                           COGL_PIXEL_FORMAT_A_8,
                           1, /* rowstride */
                           replacement_data,
                           1, 1, /* dst_x/y */
                           0, /* level */
                           NULL); /* abort on error */

  cogl_framebuffer_draw_rectangle (test_fb,
                                   pipeline2,
                                   -1.0f, 0.0f, /* x1/y1 */
                                   1.0f, -1.0f /* x2/y2 */);

  cogl_object_unref (tex1);
  cogl_object_unref (tex2);
  cogl_object_unref (pipeline1);
  cogl_object_unref (pipeline2);

  /* Unmodified texture */
  test_utils_check_pixel (test_fb,
                          fb_width / 4,
                          fb_height / 8,
                          0x000000ff);
  test_utils_check_pixel (test_fb,
                          fb_width * 3 / 4,
                          fb_height / 8,
                          0x444444ff);
  test_utils_check_pixel (test_fb,
                          fb_width / 4,
                          fb_height * 3 / 8,
                          0x888888ff);
  test_utils_check_pixel (test_fb,
                          fb_width * 3 / 4,
                          fb_height * 3 / 8,
                          0xccccccff);

  /* Modified texture */
  test_utils_check_pixel (test_fb,
                          fb_width / 4,
                          fb_height * 5 / 8,
                          0x000000ff);
  test_utils_check_pixel (test_fb,
                          fb_width * 3 / 4,
                          fb_height * 5 / 8,
                          0x444444ff);
  test_utils_check_pixel (test_fb,
                          fb_width / 4,
                          fb_height * 7 / 8,
                          0x888888ff);
  test_utils_check_pixel (test_fb,
                          fb_width * 3 / 4,
                          fb_height * 7 / 8,
                          0xffffffff);

  if (cogl_test_verbose ())
    g_print ("OK\n");
}