Ejemplo n.º 1
0
int
main(int argc, char **argv)
{
   int                 rot = 0;

   if ((argc >= 3) && (!strcmp(argv[1], "-rot")))
      rot = atoi(argv[2]);
   evas_init();
   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("fb"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_FB *einfo;

      einfo = (Evas_Engine_Info_FB *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.virtual_terminal = 0;
      einfo->info.device_number = 0;
      einfo->info.refresh = 0;
      einfo->info.rotation = rot;

      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   orig_start_time = start_time = get_time();
   for (;;)
     {
	loop();
	evas_render(evas);
     }
   evas_shutdown();
   return 0;
}
Ejemplo n.º 2
0
/**
 * @brief Shuts down Etk. It decrements the init-counter. If the counter reaches 0, it frees all the resources used by Etk
 * @return Returns the new value of the init-counter. If 0 is returned, it means that the resources has effectively
 * been freed.
 */
int etk_shutdown(void)
{
   if (_etk_main_init_count <= 0)
      return 0;

   _etk_main_init_count--;
   if (_etk_main_init_count == 0)
   {
      ecore_idle_enterer_del(_etk_main_idle_enterer);
      _etk_main_idle_enterer = NULL;

      /* Shutdown the subsystems of Etk */
      etk_object_shutdown();
      etk_type_shutdown();
      etk_signal_shutdown();

      etk_tooltips_shutdown();
      etk_event_shutdown();
      etk_engine_shutdown();
      etk_config_shutdown();
      etk_theme_shutdown();
      etk_argument_shutdown();

      /* Shutdown the EFL*/
      edje_shutdown();
      ecore_imf_shutdown();
      ecore_shutdown();
      evas_shutdown();
   }

   return _etk_main_init_count;
}
Ejemplo n.º 3
0
/* externally accessible functions */
int
main(int    argc,
     char **argv)
{
   int i;

   for (i = 1; i < argc; i++)
     {
        if ((!strcmp(argv[i], "-h")) ||
            (!strcmp(argv[i], "-help")) ||
            (!strcmp(argv[i], "--help")))
          {
             printf(
               "This is an internal tool for Enlightenment.\n"
               "do not use it.\n"
               );
             exit(0);
          }
        else if (!strncmp(argv[i], "--nice=", 7))
          {
             const char *val;
             int ret = 0;

             val = argv[i] + 7;
             if (*val)
               ret = nice(atoi(val));
          }
     }

   ecore_init();
   ecore_app_args_set(argc, (const char **)argv);
   eet_init();
   evas_init();
   ecore_evas_init();
   edje_init();
   ecore_file_init();
   ecore_ipc_init();

   e_user_dir_concat_static(_thumbdir, "fileman/thumbnails");
   ecore_file_mkpath(_thumbdir);

   if (_e_ipc_init()) ecore_main_loop_begin();

   if (_e_ipc_server)
     {
        ecore_ipc_server_del(_e_ipc_server);
        _e_ipc_server = NULL;
     }

   ecore_ipc_shutdown();
   ecore_file_shutdown();
   ecore_evas_shutdown();
   edje_shutdown();
   evas_shutdown();
   eet_shutdown();
   ecore_shutdown();

   return 0;
}
Ejemplo n.º 4
0
int ewk_init(void)
{
    if (_ewkInitCount)
        return ++_ewkInitCount;

    if (!eina_init())
        goto error_eina;

    _ewk_log_dom = eina_log_domain_register("ewebkit", EINA_COLOR_ORANGE);
    if (_ewk_log_dom < 0) {
        EINA_LOG_CRIT("could not register log domain 'ewebkit'");
        goto error_log_domain;
    }

    if (!evas_init()) {
        CRITICAL("could not init evas.");
        goto error_evas;
    }

    if (!ecore_init()) {
        CRITICAL("could not init ecore.");
        goto error_ecore;
    }

    if (!ecore_evas_init()) {
        CRITICAL("could not init ecore_evas.");
        goto error_ecore_evas;
    }

    if (!edje_init()) {
        CRITICAL("could not init edje.");
        goto error_edje;
    }

    if (!_ewk_init_body()) {
        CRITICAL("could not init body");
        goto error_edje;
    }

    return ++_ewkInitCount;

error_edje:
    ecore_evas_shutdown();
error_ecore_evas:
    ecore_shutdown();
error_ecore:
    evas_shutdown();
error_evas:
    eina_log_domain_unregister(_ewk_log_dom);
    _ewk_log_dom = -1;
error_log_domain:
    eina_shutdown();
error_eina:
    return 0;
}
Ejemplo n.º 5
0
ApplicationMain::~ApplicationMain()
{
    DELETE_NULL(controller)

            elm_shutdown();
    edje_shutdown();
    ecore_evas_shutdown();
    evas_shutdown();
    ecore_con_url_shutdown();
    ecore_con_shutdown();
    ecore_shutdown();
    eina_shutdown();
}
Ejemplo n.º 6
0
int ewk_shutdown(void)
{
    _ewkInitCount--;
    if (_ewkInitCount)
        return _ewkInitCount;

    ecore_evas_shutdown();
    ecore_shutdown();
    evas_shutdown();
    eina_log_domain_unregister(_ewk_log_dom);
    _ewk_log_dom = -1;
    eina_shutdown();

    return 0;
}
Ejemplo n.º 7
0
int ewk_shutdown(void)
{
    if (--_ewkInitCount)
        return _ewkInitCount;

#ifdef HAVE_ECORE_X
    ecore_x_shutdown();
#endif
    ecore_evas_shutdown();
    ecore_shutdown();
    evas_shutdown();
    eina_log_domain_unregister(_ewk_log_dom);
    _ewk_log_dom = -1;
    eina_shutdown();

    return 0;
}
Ejemplo n.º 8
0
int EwkMain::finalize()
{
    if (--m_initCount)
        return m_initCount;

    edje_shutdown();
#ifdef HAVE_ECORE_X
    ecore_x_shutdown();
#endif
    efreet_shutdown();
    ecore_imf_shutdown();
    ecore_evas_shutdown();
    ecore_shutdown();
    evas_shutdown();
    eina_log_domain_unregister(m_logDomainId);
    m_logDomainId = -1;
    eina_shutdown();

    return 0;
}
Ejemplo n.º 9
0
int
main(int argc, char **argv)
{
   Suite *s;
   SRunner *sr;
   int i, failed_count;

   for (i = 1; i < argc; i++)
     if ((strcmp(argv[i], "-h") == 0) ||
	 (strcmp(argv[i], "--help") == 0))
       {
	  fprintf(stderr, "Usage:\n\t%s [test_case1 .. [test_caseN]]\n",
		  argv[0]);
	  _list_tests();
	  return 0;
       }
     else if ((strcmp(argv[i], "-l") == 0) ||
	      (strcmp(argv[i], "--list") == 0))
       {
	  _list_tests();
	  return 0;
       }

   putenv("EFL_RUN_IN_TREE=1");

   evas_init();
   s = evas_suite_build(argc - 1, (const char **)argv + 1);
   sr = srunner_create(s);

   srunner_set_xml(sr, TESTS_BUILD_DIR "/check-results.xml");

   srunner_run_all(sr, CK_ENV);
   failed_count = srunner_ntests_failed(sr);
   srunner_free(sr);

   evas_shutdown();
   return (failed_count == 0) ? 0 : 255;
}
Ejemplo n.º 10
0
void EwkMain::shutdownInitializedEFLModules(EFLModuleInitFailure module)
{
    switch (module) {
    case EFLModuleInitFailure::Edje:
#ifdef HAVE_ECORE_X
        ecore_x_shutdown();
#endif
    case EFLModuleInitFailure::EcoreX:
        efreet_shutdown();
    case EFLModuleInitFailure::Efreet:
        ecore_imf_shutdown();
    case EFLModuleInitFailure::EcoreImf:
        ecore_evas_shutdown();
    case EFLModuleInitFailure::EcoreEvas:
        ecore_shutdown();
    case EFLModuleInitFailure::Ecore:
        evas_shutdown();
    case EFLModuleInitFailure::Evas:
        eina_log_domain_unregister(m_logDomainId);
        m_logDomainId = -1;
    case EFLModuleInitFailure::EinaLog:
        eina_shutdown();
    }
}
Ejemplo n.º 11
0
int
main (int argc, char * argv[])
{
  Edvi_Device   *device;
  Edvi_Property *property;
  Edvi_Document *document;
  Edvi_Page     *page;
  Ecore_Evas    *ee;
  Evas          *evas;
  Evas_Object   *o;
  char          *param_kpathsea_mode  = "cx";
  int            page_number;
  int            width;
  int            height;

  if (argc < 3) {
    printf ("\nUsage: %s file.dvi page_number\n\n", argv[0]);
    return EXIT_FAILURE;
  }

  printf ("[DVI] version : %s\n", edvi_version_get ());

  if (!edvi_init (300, param_kpathsea_mode, 4,
                  1.0, 1.0,
                  0, 255, 255, 255, 0, 0, 0)) {
    return EXIT_FAILURE;
  }

  device = edvi_device_new (edvi_dpi_get (), edvi_dpi_get ());
  if (!device) {
    goto shutdown;
  }

  property = edvi_property_new ();
  if (!property) {
    goto free_device;
  }
  edvi_property_property_set (property, EDVI_PROPERTY_DELAYED_FONT_OPEN);

  document = edvi_document_new (argv[1], device, property);
  if (!document) {
    goto free_property;
  }

  sscanf (argv[2], "%d", &page_number);
  page = edvi_page_new (document);
  if (!page) {
    goto free_document;
  }
  edvi_page_page_set (page, page_number);
  edvi_page_size_get (page, &width, &height);

  if (!ecore_init()) {
    goto free_page;
  }

  if (!ecore_evas_init()) {
    goto shutdown_ecore;
  }

  ee = ecore_evas_software_x11_new (NULL, 0,  0, 0, width, height);
  /* these tests can be improved... */
  if (!ee) {
    printf ("Can not find Software X11 engine. Trying DirectDraw engine...\n");
    ee = ecore_evas_software_ddraw_new (NULL,  0, 0, width, height);
    if (!ee) {
      goto shutdown_ecore_evas;
    }
  }
  ecore_event_handler_add (ECORE_EVENT_SIGNAL_EXIT, app_signal_exit, NULL);
  ecore_evas_callback_delete_request_set (ee, app_delete_request);
  ecore_evas_title_set (ee, "Evas Dvi Test");
  ecore_evas_name_class_set (ee, "evas_dvi_test", "test_evas_dvi");
  ecore_evas_callback_resize_set (ee, app_resize);
  ecore_evas_show (ee);

  evas = ecore_evas_get (ee);

  o = evas_object_image_add (evas);
  evas_object_move (o, 0, 0);
  _evas_object_bg_set (o, 255, 255, 255);
  edvi_page_render (page, device, o);
  evas_object_show (o);

  ecore_main_loop_begin ();

  ecore_evas_shutdown ();
  ecore_shutdown ();
  evas_shutdown ();
  edvi_page_delete (page);
  edvi_document_delete (document);
  edvi_property_delete (property);
  edvi_device_delete (device);
  edvi_shutdown ();

  return EXIT_SUCCESS;

 shutdown_ecore_evas:
  ecore_evas_shutdown ();
 shutdown_ecore:
  ecore_shutdown ();
 free_page:
  edvi_page_delete (page);
 free_document:
  edvi_document_delete (document);
 free_property:
  edvi_property_delete (property);
 free_device:
  edvi_device_delete (device);
 shutdown:
  edvi_shutdown ();

  return EXIT_FAILURE;
}
Ejemplo n.º 12
0
Archivo: test.c Proyecto: ixdu/caravan
int main(void)
{
  id_keeper = id_keeper_init(1000); //хеш хранения всех объектов по id

  struct ui_object wconf;
  wconf.h = 800;
  wconf.w = 1600;
  
  int64_t main_id = ui_frame_create_window(&wconf);
  //printf("id is %d\n", main_id);
  //struct ui_frame *main = (struct ui_frame*) id_keeper->id_array[main_id];

  //  printf("Hello %d\n", main->canvas);
  //Evas_Object *bg, *r1, *r2, *r3;
  //bg = evas_object_rectangle_add(main->canvas);
  //evas_object_color_set(bg, 255, 255, 255,150); // white bg
  //evas_object_move(bg, 100, 100);                    // at origin
  //evas_object_resize(bg, main->ui.w, main->ui.h);         // covers full canvas
  //evas_object_show(bg);

  //  Evas_Object *grid = evas_object_grid_add(main->canvas);
  //evas_object_grid_size_set(grid, 400, 400);
  //evas_object_show(grid);

  struct ui_object frame_ui;
  frame_ui.h = 600;
  frame_ui.w = 1000;
  int64_t main_f = ui_evas_frame_create(main_id, &frame_ui);
  //Evas_Object *main_f = evas_smart_frame_add(main->canvas);
					//evas_object_move(main_f, 20, 20);
					//  evas_object_resize(main_f, 100, 100);
					//evas_object_show(main_f);
  
  //rotate
  Evas_Map *m = evas_map_new(4);
  evas_map_util_points_populate_from_object(m, main_f);
  int cx, cy, cw, ch;
  evas_object_geometry_get(main_f, &cx, &cy, &cw, &ch);
  evas_map_util_rotate(m, 30, cx + cw, cy + ch);
  evas_object_map_enable_set(main_f, EINA_TRUE);
  evas_object_map_set(main_f, m);

  puts("initial scene, with just background:");


  /*
   //   Evas_Object *cube =  evas_object_rectangle_add(canvas_win);
      Evas_Object *cube =  evas_object_image_filled_add(main->canvas);
   evas_object_image_file_set(cube, "./balalaika.svg", NULL);
   evas_object_color_set(cube, 0, 255, 255, 200); // white bg
   evas_object_move(cube, 700, 400);                    // at origin
   
   int csize[2];
   csize[0] = 30;
   csize[1] = 20;
   
   int cpos[2];
   cpos[0] = 700;
   cpos[1] = 400;

   //   evas_object_resize(cube, csize[0], csize[1]);         // covers full canvas
   evas_object_resize(cube, 400, 300);         // covers full canvas
   evas_object_show(cube);
   //   evas_object_anti_alias_set(cube, 1);
   //      evas_object_render_op_set(cube, EVAS_RENDER_BLEND);
   //   evas_object_image_smooth_scale_set(cube, EINA_TRUE);
   
   int deg = 1;
   int cx, cy, cw, ch;
   Evas_Map *m = evas_map_new(4);
   
   //   evas_map_point_image_uv_set(m, 0, 0, 0);
   // evas_map_point_image_uv_set(m, 1, 150, 0);
   //evas_map_point_image_uv_set(m, 2, 150, 200);
   //evas_map_point_image_uv_set(m, 3, 0, 200);

   Ecore_Task_Cb _cube_anim(void *data){
     evas_map_util_points_populate_from_object(m, cube);
     evas_object_geometry_get(cube, &cx, &cy, &cw, &ch);
     evas_map_util_rotate(m, ++deg, cx + cw, cy + ch);
     evas_object_map_enable_set(cube, EINA_TRUE);
     evas_object_map_set(cube, m);
     
     
     evas_object_move(cube, (cpos[0] = cpos[0] - 5) >=0 ? cpos[0] : 0, (cpos[1] = cpos[1] - 5) >=0 ? cpos[1] : 0);
     evas_object_resize(cube, csize[0] = csize[0] + 1, csize[1] = csize[1] + 1);
     //evas_object_image_filled_set(cube, EINA_TRUE);
     //evas_render(canvas_win);
     return ECORE_CALLBACK_DONE;
	  //	  Ecore_Timer *timer1 = ecore_timer_loop_add(0.4, timer_func, NULL);
   }

   ecore_animator_frametime_set(1./30);
   Ecore_Animator *anim = ecore_animator_add(_cube_anim,cube);
   //   ecore_animator_timeline_add(20,_cube_anim, cube);
   
   ecore_animator_thaw(anim);
  */
   ecore_main_loop_begin();

   //ecore_animator_del(anim);
   //evas_map_free(m);
   //*/
   //   destroy_canvas(main->datacanvas);

   evas_shutdown();

   return 0;
}
Ejemplo n.º 13
0
int ewk_init(void)
{
    if (_ewkInitCount)
        return ++_ewkInitCount;

    if (!eina_init())
        goto error_eina;

    _ewk_log_dom = eina_log_domain_register("ewebkit2", EINA_COLOR_ORANGE);
    if (_ewk_log_dom < 0) {
        EINA_LOG_CRIT("could not register log domain 'ewebkit2'");
        goto error_log_domain;
    }

    if (!evas_init()) {
        CRITICAL("could not init evas.");
        goto error_evas;
    }

    if (!ecore_init()) {
        CRITICAL("could not init ecore.");
        goto error_ecore;
    }

    if (!ecore_evas_init()) {
        CRITICAL("could not init ecore_evas.");
        goto error_ecore_evas;
    }

    if (!ecore_imf_init()) {
        CRITICAL("could not init ecore_imf.");
        goto error_ecore_imf;
    }

    if (!efreet_init()) {
        CRITICAL("could not init efreet.");
        goto error_efreet;
    }

#ifdef HAVE_ECORE_X
    if (!ecore_x_init(0)) {
        CRITICAL("could not init ecore_x.");
        goto error_ecore_x;
    }
#endif

    if (!edje_init()) {
        CRITICAL("Could not init edje.");
        goto error_edje;
    }

    if (!ecore_main_loop_glib_integrate()) {
        WARN("Ecore was not compiled with GLib support, some plugins will not "
            "work (ie: Adobe Flash)");
    }

    return ++_ewkInitCount;

error_edje:
#ifdef HAVE_ECORE_X
    ecore_x_shutdown();
error_ecore_x:
#else
    efreet_shutdown();
#endif
error_efreet:
    ecore_imf_shutdown();
error_ecore_imf:
    ecore_evas_shutdown();
error_ecore_evas:
    ecore_shutdown();
error_ecore:
    evas_shutdown();
error_evas:
    eina_log_domain_unregister(_ewk_log_dom);
    _ewk_log_dom = -1;
error_log_domain:
    eina_shutdown();
error_eina:
    return 0;
}
Ejemplo n.º 14
0
int main( int argc, char *argv[] )
{
     IDirectFB              *dfb;
     IDirectFBDisplayLayer  *layer;

     IDirectFBSurface       *bgsurface;
     IDirectFBImageProvider *provider;

     IDirectFBWindow        *window1;
     IDirectFBWindow        *window2;
     IDirectFBSurface       *window_surface1;
     IDirectFBSurface       *window_surface2;

     IDirectFBEventBuffer   *buffer;

     DFBDisplayLayerConfig  layer_config;

#if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23))
     DFBCardCapabilities    caps;
#else
     DFBGraphicsDeviceDescription caps;
#endif
     IDirectFBWindow*       upper;
     DFBWindowID            id1;

     IDirectFBFont          *font;
     int fontheight;
     int err;
     int quit = 0;


     DFBCHECK(DirectFBInit( &argc, &argv ));
     DFBCHECK(DirectFBCreate( &dfb ));

#if ((DIRECTFB_MAJOR_VERSION == 0) && (DIRECTFB_MINOR_VERSION == 9) && (DIRECTFB_MICRO_VERSION < 23))
     dfb->GetCardCapabilities( dfb, &caps );
#else
     dfb->GetDeviceDescription( dfb, &caps );
#endif

     dfb->GetDisplayLayer( dfb, DLID_PRIMARY, &layer );

     if (!((caps.blitting_flags & DSBLIT_BLEND_ALPHACHANNEL) &&
           (caps.blitting_flags & DSBLIT_BLEND_COLORALPHA  )))
     {
          layer_config.flags = DLCONF_BUFFERMODE;
          layer_config.buffermode = DLBM_BACKSYSTEM;

          layer->SetConfiguration( layer, &layer_config );
     }

     layer->GetConfiguration( layer, &layer_config );
     layer->EnableCursor ( layer, 1 );

     {
          DFBFontDescription desc;

          desc.flags = DFDESC_HEIGHT;
          desc.height = layer_config.width/50;

          DFBCHECK(dfb->CreateFont( dfb, PACKAGE_DATA_DIR"/grunge.ttf", &desc, &font ));
          font->GetHeight( font, &fontheight );
     }

     {
          DFBSurfaceDescription desc;

          DFBCHECK(dfb->CreateImageProvider( dfb,
                                             PACKAGE_DATA_DIR"/bg.png",
                                             &provider ));

          desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;
          desc.width = layer_config.width;
          desc.height = layer_config.height;

          DFBCHECK(dfb->CreateSurface( dfb, &desc, &bgsurface ) );


          provider->RenderTo( provider, bgsurface, NULL );
          provider->Release( provider );

	  DFBCHECK(bgsurface->SetFont( bgsurface, font ));

          bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF );
          bgsurface->DrawString( bgsurface,
                                 "Move the mouse over a window to activate it.",
                                 -1, 10, 0, DSTF_LEFT | DSTF_TOP );

          bgsurface->SetColor( bgsurface, 0xFF, 0xCF, 0xFF, 0xFF );
          bgsurface->DrawString( bgsurface,
                    "You can drag them around, too, if you want.",
                                 -1, 10 , 40, DSTF_LEFT | DSTF_TOP );

          bgsurface->SetColor( bgsurface, 0xCF, 0xCF, 0xFF, 0xFF );
	  bgsurface->DrawString( bgsurface,
                    "The one with funky stuff happening and things flying around is an evas.",
                                 -1, 10, 80, DSTF_LEFT | DSTF_TOP );




          layer->SetBackgroundImage( layer, bgsurface );
          layer->SetBackgroundMode( layer, DLBM_IMAGE );
     }
     {
	  DFBWindowDescription desc;
	  desc.flags = ( DWDESC_POSX | DWDESC_POSY |
                         DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS );

	  desc.posx = 20;
          desc.posy = 120;
          desc.width = 200;
          desc.height = 200;
	  desc.caps = DWCAPS_ALPHACHANNEL;

          DFBCHECK( layer->CreateWindow( layer, &desc, &window2 ) );
          window2->GetSurface( window2, &window_surface2 );

          window2->SetOpacity( window2, 0xFF );

          window2->CreateEventBuffer( window2, &buffer );

	  {
	     window_surface2->SetColor( window_surface2,
		   0x00, 0x30, 0x10, 0xc0 );
	     window_surface2->DrawRectangle( window_surface2, 0, 0,
		   desc.width, desc.height );
	     window_surface2->SetColor( window_surface2,
		   0x80, 0xa0, 0x00, 0x90 );
	     window_surface2->FillRectangle( window_surface2, 1, 1,
		   desc.width-2, desc.height-2 );


	     DFBCHECK(window_surface2->SetFont(window_surface2, font ));
	     window_surface2->SetColor( window_surface2, 0xCF, 0xFF, 0xCF, 0xFF );

	     window_surface2->DrawString( window_surface2,
		   "Pants!",
		   -1,10, fontheight + 5, DSTF_LEFT | DSTF_TOP );

	  }

          window_surface2->Flip( window_surface2, NULL, 0 );
     }

     {
          DFBWindowDescription desc;

          desc.flags = ( DWDESC_POSX | DWDESC_POSY |
                         DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_CAPS );
          desc.posx = 200;
          desc.posy = 200;
          desc.width = 240;
          desc.height = 320;
          desc.caps = DWCAPS_ALPHACHANNEL;

          DFBCHECK(layer->CreateWindow( layer, &desc, &window1 ) );
          window1->GetSurface( window1, &window_surface1 );

          window_surface1->SetColor( window_surface1, 0xFF, 0x20, 0x20, 0x90 );
          window_surface1->DrawRectangle( window_surface1, 0, 0,
                                          desc.width, desc.height );

          window_surface1->Flip( window_surface1, NULL, 0 );

          window1->SetOpacity( window1, 0xFF );

          window1->GetID( window1, &id1 );

          window1->AttachEventBuffer( window1, buffer );
     }

     window1->RequestFocus( window1 );
     window1->RaiseToTop( window1 );
     upper = window1;
     {
	evas_init();
	evas = evas_new();
	evas_output_method_set(evas, evas_render_method_lookup("directfb"));
	evas_output_size_set(evas, 240, 320);
	evas_output_viewport_set(evas, 0, 0, 240, 320);
	{
	   Evas_Engine_Info_DirectFB *einfo;

	   einfo = (Evas_Engine_Info_DirectFB *) evas_engine_info_get(evas);

	   einfo->info.dfb = dfb;
	   einfo->info.surface = window_surface1;
	   einfo->info.flags = DSDRAW_BLEND;
	   evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
	}
	setup();
	evas_render(evas);
	start_time = get_time();
     }

     while (!quit) {
          static IDirectFBWindow* active = NULL;
          static int grabbed = 0;
          static int startx = 0;
          static int starty = 0;
          static int endx = 0;
          static int endy = 0;
          DFBWindowEvent evt;

          buffer->WaitForEventWithTimeout( buffer, 0, 10 );

          while (buffer->GetEvent( buffer, DFB_EVENT(&evt) ) == DFB_OK) {
               IDirectFBWindow* window;

               if (evt.window_id == id1)
                    window = window1;
               else
                    window = window2;

               if (active) {
                    switch (evt.type) {

                    case DWET_BUTTONDOWN:
                         if (!grabbed && evt.button == DIBI_LEFT) {
                              grabbed = 1;
                              layer->GetCursorPosition( layer,
                                                        &startx, &starty );
                              window->GrabPointer( window );
                         }
                         break;

                    case DWET_BUTTONUP:
                         switch (evt.button) {
                              case DIBI_LEFT:
                                   if (grabbed) {
                                        window->UngrabPointer( window );
                                        grabbed = 0;
                                   }
                                   break;
                              case DIBI_MIDDLE:
                                   upper->LowerToBottom( upper );
                                   upper = (upper == window1) ? window2 : window1;
                                   break;
                              case DIBI_RIGHT:
                                   quit = DIKS_DOWN;
                                   break;
                              default:
                                   break;
                         }
                         break;

                    case DWET_KEYDOWN:
                         if (grabbed)
                              break;
                         switch (evt.key_id) {
                              case DIKI_RIGHT:
                                   active->Move (active, 1, 0);
                                   break;
                              case DIKI_LEFT:
                                   active->Move (active, -1, 0);
                                   break;
                              case DIKI_UP:
                                   active->Move (active, 0, -1);
                                   break;
                              case DIKI_DOWN:
                                   active->Move (active, 0, 1);
                                   break;
                              default:
                                   break;
                         }
                         break;

                    case DWET_LOSTFOCUS:
                         if (!grabbed)
                              active = NULL;
                         break;

                    default:
                         break;

                    }
               }
               else if (evt.type == DWET_GOTFOCUS)
                    active = window;

               switch (evt.type) {

               case DWET_MOTION:
                    endx = evt.cx;
                    endy = evt.cy;
                    break;

               case DWET_KEYDOWN:
                    switch (evt.key_symbol) {
                    case DIKS_ESCAPE:
                    case DIKS_SMALL_Q:
                    case DIKS_CAPITAL_Q:
                    case DIKS_BACK:
                    case DIKS_STOP:
                         quit = 1;
                         break;
                    default:
                         break;
                    }
                    break;

               default:
                    break;
               }
          }

          if (active) {
               if (grabbed) {
                    active->Move( active, endx - startx, endy - starty);
                    startx = endx;
                    starty = endy;
               }
               active->SetOpacity( active,
                                   (sin( myclock()/300.0 ) * 85) + 170 );
          }
	  loop();
	  {
	     Eina_List *updates;

	     updates = evas_render_updates(evas);
	     /* efficient update.. only flip the rectangle regions that changed! */
	     if (updates)
	       {
		  DFBRegion region;
		  Eina_List *l;

		  for (l = updates; l; l = l->next)
		    {
		       Evas_Rectangle *rect;

		       rect = l->data;
		       region.x1 = rect->x;
		       region.y1 = rect->y;
		       region.x2 = rect->x + rect->w - 1;
		       region.y2 = rect->y + rect->h - 1;
		       window_surface1->Flip(window_surface1, &region,
					     DSFLIP_BLIT);
		    }
		  evas_render_updates_free(updates);
	       }
	  }
     }

     buffer->Release( buffer );
     window_surface2->Release( window_surface2 );
     window_surface1->Release( window_surface1 );
     window2->Release( window2 );
     window1->Release( window1 );
     layer->Release( layer );
     bgsurface->Release( bgsurface );
     dfb->Release( dfb );

   evas_shutdown();
   return 0;
}
Ejemplo n.º 15
0
int main(int argc, char *argv[])
{
    Ecore_Evas *ee;
    Evas_Object *bridge, *img;
    const char *opt, *input, *output, *params;
    int r = 0, w = -1, h = -1, err;
    double scale = -1.0;

    if (argc < 4) {
        fprintf(stderr,
                "Usage:\n"
                "\t%s <percentage%%|WxH|w=W|h=H> <input> <output>"
                " [save-params]\n"
                "where save-params is evas supported parameters, like:\n"
                "\tquality=85\n"
                "\tcompress=9\n",
                argv[0]);
        return 1;
    }

    opt = argv[1];
    input = argv[2];
    output = argv[3];
    params = argv[4];

    if (strncasecmp(opt, "w=", 2) == 0) {
        char *end = NULL;
        w = strtol(opt + 2, &end, 10);
        if (!end || *end != '\0') {
            fprintf(stderr, "ERROR: invalid decimal integer '%s'\n",
                    opt + 2);
            return 1;
        } else if (w < 1) {
            fprintf(stderr, "ERROR: invalid width %d, must be >= 1\n", w);
            return 1;
        }
    } else if (strncasecmp(opt, "h=", 2) == 0) {
        char *end = NULL;
        h = strtol(opt + 2, &end, 10);
        if (!end || *end != '\0') {
            fprintf(stderr, "ERROR: invalid decimal integer '%s'\n",
                    opt + 2);
            return 1;
        } else if (h < 1) {
            fprintf(stderr, "ERROR: invalid height %d, must be >= 1\n", h);
            return 1;
        }
    } else if (strchr(opt, '%')) {
        char *end = NULL;
        scale = strtod(opt, &end);
        if (!end || *end != '%') {
            fprintf(stderr, "ERROR: invalid percentual '%s'\n", opt);
            return 1;
        } else if (scale <= 0.0) {
            fprintf(stderr, "ERROR: invalid percentual %g, must be > 0.0\n",
                    scale);
            return 1;
        }
        scale /= 100.0;
    } else if (strchr(opt, 'x')) {
        if (sscanf(opt, "%dx%d", &w, &h) != 2) {
            fprintf(stderr, "ERROR: invalid size format '%s'\n", opt);
            return 1;
        } else if (w < 1) {
            fprintf(stderr, "ERROR: invalid width %d, must be >= 1\n", w);
            return 1;
        } else {
            fprintf(stderr, "ERROR: invalid height %d, must be >= 1\n", h);
            return 1;
        }
    } else {
        fprintf(stderr,
                "ERROR: first parameter must be in format:\n"
                "\tpercentage%%    - example: 10%%\n"
                "\tWxH            - example: 1024x768\n"
                "\tw=W            - example: w=1024\n"
                "\th=H            - example: h=768\n"
                "But '%s' was used!\n",
                opt);
        return 1;
    }

    ecore_evas_init();
    evas_init();

    ee = ecore_evas_buffer_new(1, 1);
    bridge = ecore_evas_object_image_new(ee);
    img = evas_object_image_add(ecore_evas_object_evas_get(bridge));
    evas_object_image_smooth_scale_set(img, EINA_TRUE);

    if (w > 0 && h > 0)
        evas_object_image_load_size_set(img, w, h);

    evas_object_image_file_set(img, input, NULL);
    err = evas_object_image_load_error_get(img);
    if (err != EVAS_LOAD_ERROR_NONE) {
        const char *msg = evas_load_error_str(err);
        fprintf(stderr, "ERROR: could not load '%s': %s\n", input, msg);
        r = 1;
        goto end;
    }

    if (w < 1 || h < 1) {
        int iw, ih;
        evas_object_image_size_get(img, &iw, &ih);

        if (iw < 0 || ih < 0) {
            fprintf(stderr, "ERROR: invalid source image size %dx%d (%s)\n",
                    iw, ih, input);
            goto end;
        }

        if (scale > 0) {
            w = ceil(iw * scale);
            h = ceil(ih * scale);
        } else if (w < 1)
            w = ceil(iw * (double)h / (double)ih);
        else if (h < 1)
            h = ceil(ih * (double)w / (double)iw);

        if (iw != w && ih != h)
            evas_object_image_load_size_set(img, w, h);
    }

    printf("output: %s, size: %dx%d, alpha: %s, params: %s\n",
           output, w, h,
           evas_object_image_alpha_get(img) ? "yes" : "no",
           params ? params : "<none>");

    evas_object_image_fill_set(img, 0, 0, w, h);
    evas_object_resize(img, w, h);
    evas_object_show(img);

    evas_object_image_alpha_set(bridge, evas_object_image_alpha_get(img));
    evas_object_image_size_set(bridge, w, h);
    ecore_evas_manual_render(ecore_evas_object_ecore_evas_get(bridge));

    evas_object_image_save(bridge, output, NULL, params);

  end:
    evas_object_del(img);
    evas_object_del(bridge);
    ecore_evas_free(ee);

    evas_shutdown();
    ecore_evas_shutdown();

    return r;
}
int
main(int argc, char **argv)
{
   int i;
   
   evas_init();
   if (!evas_cserve_init())
     {
        printf("ERROR: Cannot connect to cserve. abort\n");
        exit(-1);
     }

   for (i = 1; i < argc; i++)
     {
        if ((!strcmp(argv[i], "-h")) ||
            (!strcmp(argv[i], "-help")) ||
            (!strcmp(argv[i], "--help")))
          {
             printf("Options:\n"
                    "\t-h                               This help\n"
                    "\tgetconfig                        Get configuration values\n"
                    "\tsetconfig CSIZE CTIME CTIMECHECK Set the config values\n"
                    "\tgetstats                         Get current cache statistics\n"
                    "\tgetinfo                          Get current cache content info\n"
                    );
             exit(0);
          }
        else if ((!strcmp(argv[i], "getconfig")))
          {
             Op_Getconfig_Reply config;
             
             if (!evas_cserve_raw_config_get(&config))
               {
                  printf("ERROR: cannot fetch config.\n");
                  exit(-1);
               }
             printf("-REPLY-\n");
             printf("csize: %i\n", config.cache_max_usage);
             printf("ctime: %i\n", config.cache_item_timeout);
             printf("ctimecheck: %i\n", config.cache_item_timeout_check);
             printf("-OK-\n");
          }
        else if ((!strcmp(argv[i], "setconfig")) && (i < (argc - 3)))
          {
             Op_Setconfig config;
             
             i++;
             config.cache_max_usage = atoi(argv[i]);
             i++;
             config.cache_item_timeout = atoi(argv[i]);
             i++;
             config.cache_item_timeout_check = atoi(argv[i]);
             if (!evas_cserve_raw_config_set(&config))
               {
                  printf("ERROR: cannot set config.\n");
                  exit(-1);
               }
          }
        else if ((!strcmp(argv[i], "getstats")))
          {
             Op_Getstats_Reply stats;
             
             if (!evas_cserve_raw_stats_get(&stats))
               {
                  printf("ERROR: cannot fetch stats.\n");
                  exit(-1);
               }
             printf("-REPLY-\n");
             printf("saved_memory: %i Kb\n", stats.saved_memory / 1024);
             printf("wasted_memory: %i Kb\n", stats.wasted_memory / 1024);
             printf("saved_memory_peak: %i Kb\n", stats.saved_memory_peak / 1024);
             printf("wasted_memory_peak: %i Kb\n", stats.wasted_memory_peak / 1024);
             printf("saved_time_image_header_load: %1.3f sec\n", stats.saved_time_image_header_load);
             printf("saved_time_image_data_load: %1.3f sec\n", stats.saved_time_image_data_load);
             printf("-OK-\n");
          }
        else if ((!strcmp(argv[i], "getinfo")))
          {
             Op_Getinfo_Reply *info;
             unsigned char *p;
             int i, j;
             
             info = evas_cserve_raw_info_get();
             if (!info)
               {
                  printf("ERROR: cannot fetch info.\n");
                  exit(-1);
               }
             j = info->active.count + info->cached.count;
             printf("-REPLY-\n");
             printf("active_count: %i\n", info->active.count);
             printf("active_memory: %i Kb\n", info->active.mem_total);
             printf("cache_count: %i\n", info->cached.count);
             printf("cache_memory: %i Kb\n", info->cached.mem_total);
             p = (unsigned char *)info;
             p += sizeof(Op_Getinfo_Reply);
             for (i = 0; i < j; i++)
               {
                  Op_Getinfo_Item it;
                  char *file, *key, buf[512];
                  struct tm *ltm;
                  
                  memcpy(&it, p, sizeof(Op_Getinfo_Item));
                  file = (char*) (p + sizeof(Op_Getinfo_Item));
                  key = file + strlen(file) + 1;
                  printf("-IMAGE- [#%i]\n", i);
                  printf("  file       : %s\n", file);
                  printf("  key        : %s\n", key);
                  printf("  size       : %i x %i\n", it.w, it.h);
                  printf("  active     : %i\n", (int)it.active);
                  printf("  memory used: %i bytes (%i Kb)\n", it.memory_footprint, (it.memory_footprint + 1023) / 1024);
                  printf("  has alpha  : %i\n", (int)it.alpha);
                  printf("  data loaded: %i\n", (int)it.data_loaded);
                  printf("  dead       : %i\n", (int)it.dead);
                  printf("  useless    : %i\n", (int)it.useless);
                  printf("  image refs : %i\n", it.refcount);
                  printf("  data  refs : %i\n", it.data_refcount);
                  printf("  header load: %1.5f sec\n", it.head_load_time);
                  printf("  data load  : %1.5f sec\n", it.data_load_time);
                  if (it.cached_time == 0)
                    printf("  cached at  : N/A\n");
                  else
                    {
                       ltm = localtime(&(it.cached_time));
                       if (ltm)
                         {
                            strftime(buf, sizeof(buf), "%Y.%m.%d %T", ltm);
                            printf("  cached at  : %s\n", buf);
                         }
                    }
                  ltm = localtime(&(it.file_mod_time));
                  if (ltm)
                    {
                       strftime(buf, sizeof(buf), "%Y.%m.%d %T", ltm);
                       printf("  file mod at: %s\n", buf);
                    }
                  ltm = localtime(&(it.file_checked_time));
                  if (ltm)
                    {
                       strftime(buf, sizeof(buf), "%Y.%m.%d %T", ltm);
                       printf("  file check : %s\n", buf);
                    }
                  p += sizeof(Op_Getinfo_Item) + it.file_key_size;
               }
             free(info);
             printf("-OK-\n");
          }
     }
   evas_cserve_shutdown();
   evas_shutdown();
   return 0;
}
Ejemplo n.º 17
0
int main(void)
{
   Evas *canvas;
   Evas_Object *bg, *r1, *r2, *r3;

   evas_init();

   // create your canvas
   // NOTE: consider using ecore_evas_buffer_new() instead!
   canvas = create_canvas(WIDTH, HEIGHT);
   if (!canvas)
     return -1;

   bg = evas_object_rectangle_add(canvas);
   evas_object_color_set(bg, 255, 255, 255, 255); // white bg
   evas_object_move(bg, 0, 0);                    // at origin
   evas_object_resize(bg, WIDTH, HEIGHT);         // covers full canvas
   evas_object_show(bg);

   puts("initial scene, with just background:");
   draw_scene(canvas);

   r1 = evas_object_rectangle_add(canvas);
   evas_object_color_set(r1, 255, 0, 0, 255); // 100% opaque red
   evas_object_move(r1, 10, 10);
   evas_object_resize(r1, 100, 100);
   evas_object_show(r1);

   // pay attention to transparency! Evas color values are pre-multiplied by
   // alpha, so 50% opaque green is:
   // non-premul: r=0, g=255, b=0    a=128 (50% alpha)
   // premul:
   //         r_premul = r * a / 255 =      0 * 128 / 255 =      0
   //         g_premul = g * a / 255 =    255 * 128 / 255 =    128
   //         b_premul = b * a / 255 =      0 * 128 / 255 =      0
   //
   // this 50% green is over a red background, so it will show in the
   // final output as yellow (green + red = yellow)
   r2 = evas_object_rectangle_add(canvas);
   evas_object_color_set(r2, 0, 128, 0, 128); // 50% opaque green
   evas_object_move(r2, 10, 10);
   evas_object_resize(r2, 50, 50);
   evas_object_show(r2);

   r3 = evas_object_rectangle_add(canvas);
   evas_object_color_set(r3, 0, 128, 0, 255); // 100% opaque dark green
   evas_object_move(r3, 60, 60);
   evas_object_resize(r3, 50, 50);
   evas_object_show(r3);

   puts("final scene (note updates):");
   draw_scene(canvas);
   save_scene(canvas, "/tmp/evas-buffer-simple-render.ppm");

   // NOTE: use ecore_evas_buffer_new() and here ecore_evas_free()
   destroy_canvas(canvas);

   evas_shutdown();

   return 0;
}
Ejemplo n.º 18
0
EvasTestApp::~EvasTestApp()
{
   evas_shutdown();
}
Ejemplo n.º 19
0
int
main(int argc, char **argv)
{
   WNDCLASS            wc;
   RECT                rect;
   HINSTANCE           hinstance;
   MSG                 msg;
   HWND                window;
   LPDIRECTDRAW        object;
   LPDIRECTDRAWSURFACE surface_primary;
   LPDIRECTDRAWSURFACE surface_back;
   int                 depth;
   int                 running;
   int                 pause_me = 0;

   hinstance = GetModuleHandle(0);

   wc.style = 0;
   wc.lpfnWndProc = MainWndProc;
   wc.cbClsExtra = 0;
   wc.cbWndExtra = 0;
   wc.hInstance = hinstance;
   wc.hIcon = LoadIcon (NULL, IDI_APPLICATION);
   wc.hCursor = LoadCursor (NULL, IDC_ARROW);
   wc.hbrBackground = (HBRUSH)(1 + COLOR_BTNFACE);
   wc.lpszMenuName =  NULL;
   wc.lpszClassName = "Evas_Software_DDraw_Test";

   if(!RegisterClass(&wc)) return EXIT_FAILURE;

   rect.left = 0;
   rect.top = 0;
   rect.right = win_w;
   rect.bottom = win_h;
   AdjustWindowRect (&rect, WS_OVERLAPPEDWINDOW | WS_SIZEBOX, FALSE);

   window = CreateWindowEx(0,
			   "Evas_Software_DDraw_Test",
			   "Evas_Software_DDraw_Test",
			   WS_OVERLAPPEDWINDOW | WS_SIZEBOX,
			   CW_USEDEFAULT, CW_USEDEFAULT,
                           rect.right - rect.left, rect.bottom - rect.top,
			   NULL, NULL, hinstance, NULL);
   if (!window) return EXIT_FAILURE;

   if (!_directdraw_init(window,
			 &object,
			 &surface_primary,
			 &surface_back,
			 &depth, win_w, win_h))
     return EXIT_FAILURE;

   ShowWindow(window, SW_SHOWDEFAULT);
   UpdateWindow(window);

   /* test evas_free....  :) */
   evas_init();
   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *)evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   printf("################ evas free\n");
   setdown();
   evas_free(evas);
   printf("evas freed. DONE\n");

   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   printf("################ evas free\n");
   setdown();
   evas_free(evas);
   printf("evas freed. DONE\n");

   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   printf("################ evas free\n");
   setdown();
   evas_free(evas);
   printf("evas freed. DONE\n");

   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   printf("################ evas free\n");
   setdown();
   evas_free(evas);
   printf("evas freed. DONE\n");

   evas = evas_new();
   evas_output_method_set(evas, evas_render_method_lookup("software_ddraw"));
   evas_output_size_set(evas, win_w, win_h);
   evas_output_viewport_set(evas, 0, 0, win_w, win_h);
   {
      Evas_Engine_Info_Software_DDraw *einfo;

      einfo = (Evas_Engine_Info_Software_DDraw *) evas_engine_info_get(evas);

      /* the following is specific to the engine */
      einfo->info.window = window;
      einfo->info.object = object;
      einfo->info.surface_primary = surface_primary;
      einfo->info.surface_back = surface_back;
      einfo->info.depth = depth;
      einfo->info.rotation = 0;
      evas_engine_info_set(evas, (Evas_Engine_Info *) einfo);
   }
   setup();
   orig_start_time = start_time = get_time();

   running = 1;
   while (running)
     {
        while (PeekMessage (&msg, window, 0, 0, PM_NOREMOVE))
	  {
	     int res;

	     res = GetMessage (&msg, NULL, 0, 0);
	     TranslateMessage (&msg);
	     DispatchMessage (&msg);
	     if (res == 0)
	       running = 0;
	  }
	if (!(pause_me == 1))
	  {
	     loop();
	     evas_render(evas);
	  }
     }

 exit:
   setdown();
   evas_free(evas);
   if (surface_primary)
     IDirectDrawSurface7_Release (surface_primary);
   if (object)
      IDirectDraw7_Release (object);
   evas_shutdown();

   return EXIT_SUCCESS;
}
Ejemplo n.º 20
0
static void shutdownEfl()
{
    ecore_evas_shutdown();
    ecore_shutdown();
    evas_shutdown();
}
Ejemplo n.º 21
0
int ewk_init(void)
{
    if (_ewk_init_count)
        return ++_ewk_init_count;

    if (!eina_init())
        goto error_eina;

    _ewk_log_dom = eina_log_domain_register("ewebkit", EINA_COLOR_ORANGE);
    if (_ewk_log_dom < 0) {
        EINA_LOG_CRIT("could not register log domain 'ewebkit'");
        goto error_log_domain;
    }

    if (!evas_init()) {
        CRITICAL("could not init evas.");
        goto error_evas;
    }

    if (!ecore_init()) {
        CRITICAL("could not init ecore.");
        goto error_ecore;
    }

    if (!ecore_evas_init()) {
        CRITICAL("could not init ecore_evas.");
        goto error_ecore_evas;
    }

    if (!edje_init()) {
        CRITICAL("could not init edje.");
        goto error_edje;
    }

#ifdef ENABLE_GLIB_SUPPORT
    g_type_init();

    if (!g_thread_supported())
        g_thread_init(0);

#ifdef ENABLE_GTK_PLUGINS_SUPPORT
    gdk_threads_init();
    if (!gtk_init_check(0, 0))
        WRN("Could not initialize GTK support.");
#endif

    if (!ecore_main_loop_glib_integrate())
        WRN("Ecore was not compiled with GLib support, some plugins will not "
            "work (ie: Adobe Flash)");
#endif

    JSC::initializeThreading();
    WTF::initializeMainThread();
    WebCore::InitializeLoggingChannelsIfNecessary();

    // Page cache capacity (in pages). Comment from Mac port:
    // (Research indicates that value / page drops substantially after 3 pages.)
    // FIXME: Expose this with an API and/or calculate based on available resources
    WebCore::pageCache()->setCapacity(3);
    WebCore::PageGroup::setShouldTrackVisitedLinks(true);

    // TODO: this should move to WebCore, already reported to webkit-gtk folks:
    if (1) {
        SoupSession* session = WebCore::ResourceHandle::defaultSession();
        soup_session_add_feature_by_type(session, SOUP_TYPE_CONTENT_SNIFFER);
    }

    return ++_ewk_init_count;

error_edje:
    ecore_evas_shutdown();
error_ecore_evas:
    ecore_shutdown();
error_ecore:
    evas_shutdown();
error_evas:
    eina_log_domain_unregister(_ewk_log_dom);
    _ewk_log_dom = -1;
error_log_domain:
    eina_shutdown();
error_eina:
    return 0;
}