summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-02-23 16:11:52 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-02-23 16:11:52 +0000
commit98b733080e7265f0375a6f0b3c2eb1016c2d483d (patch)
treec52933820ae8f7e612112afb449565f5fca7f32c
parent32c11e818ced148c3d04135556ef57a0f8061e6b (diff)
expedite: remove software_sdl backend and use buffer instead.
This result in an overall drop of 17% in performance. I think it may be due to some stuff related to HWSURFACE, the fact it use double buffer or that maybe SDL_FillRect was faster for cleaning up memory. If someone is really interested by this performance drop, better fix them with buffer engine. SVN revision: 68351
-rw-r--r--src/bin/engine_software_sdl.c114
1 files changed, 99 insertions, 15 deletions
diff --git a/src/bin/engine_software_sdl.c b/src/bin/engine_software_sdl.c
index bf7dd1f..4a75a48 100644
--- a/src/bin/engine_software_sdl.c
+++ b/src/bin/engine_software_sdl.c
@@ -3,33 +3,84 @@
3 3
4#include <SDL/SDL.h> 4#include <SDL/SDL.h>
5#include <Evas_Engine_SDL.h> 5#include <Evas_Engine_SDL.h>
6#include <Evas_Engine_Buffer.h>
7
8static void *
9_expedite_sdl_switch_buffer(void *data, void *dest __UNUSED__)
10{
11 SDL_Flip(data);
12 return ((SDL_Surface*)data)->pixels;
13}
6 14
7Eina_Bool 15Eina_Bool
8engine_software_sdl_args(const char *engine, int width, int height) 16engine_software_sdl_args(const char *engine, int width, int height)
9{ 17{
10 Evas_Engine_Info_SDL *einfo; 18 int ok = 0;
11 int i;
12 int ok = 0;
13 19
14 if (!strcmp(engine, "sdl")) ok = 1; 20 if (!strcmp(engine, "sdl")) ok = 1;
15 if (!strcmp(engine, "sdl-16")) ok = 2; 21 if (!strcmp(engine, "sdl-16")) ok = 2;
16 if (!ok) return EINA_FALSE; 22 if (!ok) return EINA_FALSE;
17 23
18 if (ok == 1) 24 if (ok == 1)
19 evas_output_method_set(evas, evas_render_method_lookup("software_sdl")); 25 {
20 else 26 Evas_Engine_Info_Buffer *einfo;
21 evas_output_method_set(evas, evas_render_method_lookup("software_16_sdl"));
22 27
23 einfo = (Evas_Engine_Info_SDL *) evas_engine_info_get(evas); 28 evas_output_method_set(evas, evas_render_method_lookup("buffer"));
24 29
25 /* the following is specific to the engine */ 30 einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(evas);
26 einfo->info.fullscreen = fullscreen; 31 if (einfo)
27 einfo->info.noframe = 0; 32 {
33 SDL_Init(SDL_INIT_NOPARACHUTE);
28 34
29 if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo)) 35 if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
36 {
37 printf("SDL_Init failed with %s", SDL_GetError());
38 SDL_Quit();
39 return EINA_FALSE;
40 }
41
42 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
43 einfo->info.switch_data = SDL_SetVideoMode(width, height, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
44 if (!einfo->info.switch_data)
45 {
46 printf("SDL_SetVideoMode failed !");
47 return EINA_FALSE;
48 }
49
50 SDL_SetAlpha(einfo->info.switch_data, SDL_SRCALPHA, 0);
51 SDL_FillRect(einfo->info.switch_data, NULL, 0);
52
53 einfo->info.dest_buffer = ((SDL_Surface*)einfo->info.switch_data)->pixels;
54 einfo->info.dest_buffer_row_bytes = width * sizeof (int);
55 einfo->info.use_color_key = 0;
56 einfo->info.alpha_threshold = 0;
57 einfo->info.func.new_update_region = NULL;
58 einfo->info.func.free_update_region = NULL;
59 einfo->info.func.switch_buffer = _expedite_sdl_switch_buffer;
60 if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo))
61 {
62 printf("evas_engine_info_set() for engine 'sdl' with 'buffer' backend failed.");
63 return EINA_FALSE;
64 }
65 }
66 }
67 else
30 { 68 {
31 printf("Evas can not setup the informations of the Software SDL Engine\n"); 69 Evas_Engine_Info_SDL *einfo;
32 return EINA_FALSE; 70
71 evas_output_method_set(evas, evas_render_method_lookup("software_16_sdl"));
72
73 einfo = (Evas_Engine_Info_SDL *) evas_engine_info_get(evas);
74
75 /* the following is specific to the engine */
76 einfo->info.fullscreen = fullscreen;
77 einfo->info.noframe = 0;
78
79 if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo))
80 {
81 printf("Evas can not setup the informations of the Software SDL Engine\n");
82 return EINA_FALSE;
83 }
33 } 84 }
34 85
35 return EINA_TRUE; 86 return EINA_TRUE;
@@ -39,6 +90,7 @@ void
39engine_software_sdl_loop(void) 90engine_software_sdl_loop(void)
40{ 91{
41 SDL_Event event; 92 SDL_Event event;
93 int rmethod;
42 94
43 while(SDL_PollEvent(&event)) 95 while(SDL_PollEvent(&event))
44 { 96 {
@@ -56,9 +108,41 @@ engine_software_sdl_loop(void)
56 evas_event_feed_mouse_up(evas, event.button.button, EVAS_BUTTON_NONE, 0, NULL); 108 evas_event_feed_mouse_up(evas, event.button.button, EVAS_BUTTON_NONE, 0, NULL);
57 break; 109 break;
58 case SDL_VIDEORESIZE: 110 case SDL_VIDEORESIZE:
111 rmethod = evas_output_method_get(evas);
112 if (rmethod == evas_render_method_lookup("buffer"))
113 {
114 Evas_Engine_Info_Buffer *einfo;
115
116 einfo = (Evas_Engine_Info_Buffer *) evas_engine_info_get(evas);
117 if (einfo)
118 {
119 einfo->info.depth_type = EVAS_ENGINE_BUFFER_DEPTH_RGB32;
120 einfo->info.switch_data = SDL_SetVideoMode(event.resize.w, event.resize.h, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
121 if (!einfo->info.switch_data)
122 {
123 return ;
124 }
125
126 SDL_SetAlpha(einfo->info.switch_data, SDL_SRCALPHA, 0);
127 SDL_FillRect(einfo->info.switch_data, NULL, 0);
128
129 einfo->info.dest_buffer = ((SDL_Surface*)einfo->info.switch_data)->pixels;
130 einfo->info.dest_buffer_row_bytes = event.resize.w * sizeof (int);
131 einfo->info.use_color_key = 0;
132 einfo->info.alpha_threshold = 0;
133 einfo->info.func.new_update_region = NULL;
134 einfo->info.func.free_update_region = NULL;
135 einfo->info.func.switch_buffer = _expedite_sdl_switch_buffer;
136 if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo))
137 {
138 return ;
139 }
140 }
141 }
142
59 evas_output_viewport_set(evas, 0, 0, 143 evas_output_viewport_set(evas, 0, 0,
60 event.resize.w, event.resize.w); 144 event.resize.h, event.resize.w);
61 evas_output_size_set(evas, event.resize.w, event.resize.w); 145 evas_output_size_set(evas, event.resize.h, event.resize.w);
62 evas_output_size_get(evas, &win_w, &win_h); 146 evas_output_size_get(evas, &win_w, &win_h);
63 break; 147 break;
64 case SDL_VIDEOEXPOSE: 148 case SDL_VIDEOEXPOSE: