1 #include "evas_engine.h"
5 evas_direct3d_outbuf_init(void)
10 evas_direct3d_outbuf_free(Outbuf *buf)
16 evas_direct3d_outbuf_setup_d3d(int width,
22 LPDIRECT3DDEVICE9 device,
24 LPDIRECT3DTEXTURE9 texture,
29 buf = (Outbuf *)calloc(1, sizeof(Outbuf));
38 buf->priv.d3d.window = window;
39 buf->priv.d3d.object = object;
40 buf->priv.d3d.device = device;
41 buf->priv.d3d.sprite = sprite;
42 buf->priv.d3d.texture = texture;
43 buf->priv.d3d.depth = w_depth;
46 Gfx_Func_Convert conv_func;
47 Direct3D_Output_Buffer *d3dob;
49 d3dob = evas_direct3d_output_buffer_new(buf->priv.d3d.depth, 1, 1, NULL);
54 if (evas_direct3d_masks_get(buf))
56 if ((rotation == 0) || (rotation == 180))
57 conv_func = evas_common_convert_func_get(0,
60 evas_direct3d_output_buffer_depth (d3dob),
66 else if ((rotation == 90) || (rotation == 270))
67 conv_func = evas_common_convert_func_get(0,
70 evas_direct3d_output_buffer_depth (d3dob),
77 evas_direct3d_output_buffer_free(d3dob);
80 printf(".[ Evas Error ].\n"
83 " RGB format mask: %08x, %08x, %08x\n"
84 " Not supported by and compiled in converters!\n"
98 evas_direct3d_outbuf_new_region_for_update(Outbuf *buf,
109 Direct3D_Output_Buffer *d3dob = NULL;
117 if ((buf->rot == 0) &&
118 (buf->priv.mask.r == 0xff0000) &&
119 (buf->priv.mask.g == 0x00ff00) &&
120 (buf->priv.mask.b == 0x0000ff))
122 im = evas_cache_image_empty(evas_common_image_cache_get());
123 im->image->w = width;
124 im->image->h = height;
125 im->image->data = NULL;
126 im->image->no_free = 1;
127 d3dob = evas_direct3d_output_buffer_new(buf->priv.d3d.depth,
131 im->extended_info = d3dob;
132 im->image->data = (DATA32 *)evas_direct3d_output_buffer_data(d3dob, &bpl);
136 im = (RGBA_Image*) evas_cache_image_empty(evas_common_image_cache_get());
137 evas_cache_image_surface_alloc(&im->cache_entry, width, height);
138 im->extended_info = d3dob;
139 if ((buf->rot == 0) || (buf->rot == 180))
140 d3dob = evas_direct3d_output_buffer_new(buf->priv.d3d.depth,
144 else if ((buf->rot == 90) || (buf->rot == 270))
145 d3dob = evas_direct3d_output_buffer_new(buf->priv.d3d.depth,
149 im->extended_info = d3dob;
152 buf->priv.pending_writes = evas_list_append(buf->priv.pending_writes, im);
158 evas_direct3d_outbuf_free_region_for_update(Outbuf *buf,
161 /* no need to do anything - they are cleaned up on flush */
165 evas_direct3d_outbuf_flush(Outbuf *buf)
173 /* lock the texture */
174 if (!(d3d_data = evas_direct3d_lock(buf,
175 &d3d_width, &d3d_height, &d3d_pitch)))
178 /* copy safely the images that need to be drawn onto the back surface */
179 for (l = buf->priv.pending_writes; l; l = l->next)
182 Direct3D_Output_Buffer *d3dob;
185 d3dob = im->extended_info;
187 evas_direct3d_output_buffer_paste(d3dob,
196 /* unlock the texture */
197 evas_direct3d_unlock(buf);
200 while (buf->priv.pending_writes)
203 Direct3D_Output_Buffer *d3dob;
205 im = buf->priv.pending_writes->data;
206 buf->priv.pending_writes = evas_list_remove_list(buf->priv.pending_writes,
207 buf->priv.pending_writes);
208 d3dob = im->extended_info;
209 evas_cache_image_drop(im);
210 if (d3dob) evas_direct3d_output_buffer_free(d3dob);
212 evas_common_cpu_end_opt();
216 evas_direct3d_outbuf_push_updated_region(Outbuf *buf,
223 Gfx_Func_Convert conv_func;
224 Direct3D_Output_Buffer *d3dob;
230 d3dob = update->extended_info;
232 if ((buf->rot == 0) || (buf->rot == 180))
233 conv_func = evas_common_convert_func_get(NULL,
236 evas_direct3d_output_buffer_depth(d3dob),
242 else if ((buf->rot == 90) || (buf->rot == 270))
243 conv_func = evas_common_convert_func_get(NULL,
246 evas_direct3d_output_buffer_depth(d3dob),
253 if (!conv_func) return;
255 data = evas_direct3d_output_buffer_data(d3dob, &bpl);
256 src_data = update->image->data;
262 else if (buf->rot == 90)
265 d3dob->y = buf->width - x - width;
267 else if (buf->rot == 180)
269 d3dob->x = buf->width - x - width;
270 d3dob->y = buf->height - y - height;
272 else if (buf->rot == 270)
274 d3dob->x = buf->height - y - height;
277 if ((buf->rot == 0) || (buf->rot == 180))
279 d3dob->width = width;
280 d3dob->height = height;
282 else if ((buf->rot == 90) || (buf->rot == 270))
284 d3dob->width = height;
285 d3dob->height = width;
288 if (data != src_data)
289 conv_func(src_data, data,
292 ((evas_direct3d_output_buffer_depth(d3dob))) - d3dob->width,
293 d3dob->width, d3dob->height, x, y, NULL);
297 evas_direct3d_outbuf_reconfigure(Outbuf *buf,
303 if ((width == buf->width) && (height == buf->height) &&
304 (rotation == buf->rot) && (depth == buf->depth))
307 buf->height = height;
312 evas_direct3d_outbuf_width_get(Outbuf *buf)
318 evas_direct3d_outbuf_height_get(Outbuf *buf)
324 evas_direct3d_outbuf_depth_get(Outbuf *buf)
330 evas_direct3d_outbuf_rot_get(Outbuf *buf)