Enlightenment CVS committal
Author : doursse
Project : e17
Module : libs/evas
Dir : e17/libs/evas/src/modules/engines/gl_glew
Modified Files:
Evas_Engine_GL_Glew.h evas_engine.c evas_engine.h
evas_glew_main.c
Log Message:
put initialisation of glew in the engine, update the engine so that it uses the
cache system
===================================================================
RCS file:
/cvs/e/e17/libs/evas/src/modules/engines/gl_glew/Evas_Engine_GL_Glew.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- Evas_Engine_GL_Glew.h 5 Aug 2007 07:22:44 -0000 1.1
+++ Evas_Engine_GL_Glew.h 26 Jun 2008 08:29:25 -0000 1.2
@@ -1,6 +1,7 @@
#ifndef __EVAS_ENGINE_GL_GLEW_H__
#define __EVAS_ENGINE_GL_GLEW_H__
+
#include <windows.h>
@@ -14,7 +15,6 @@
/* engine specific data & parameters it needs to set up */
struct {
- HDC dc;
HWND window;
int depth;
} info;
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/modules/engines/gl_glew/evas_engine.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -3 -r1.3 -r1.4
--- evas_engine.c 3 Jun 2008 09:09:37 -0000 1.3
+++ evas_engine.c 26 Jun 2008 08:29:25 -0000 1.4
@@ -9,6 +9,9 @@
struct _Render_Engine
{
+ HWND win;
+ HDC dc;
+ HGLRC context;
Evas_GL_Glew_Window *window;
int end;
};
@@ -48,9 +51,18 @@
re = calloc(1, sizeof(Render_Engine));
if (!re) return;
+ if (!evas_glew_init(info->info.window, &re->dc, &re->context))
+ {
+ free(re);
+ e->engine.data.output = NULL;
+ return;
+ }
+
+ re->win = info->info.window;
e->engine.data.output = re;
- re->window = eng_window_new(info->info.dc,
- info->info.window,
+ re->window = eng_window_new(info->info.window,
+ re->dc,
+ re->context,
info->info.depth,
e->output.w,
e->output.h);
@@ -77,10 +89,20 @@
}
else
{
+
+ if (!evas_glew_init(info->info.window, &re->dc, &re->context))
+ {
+ free(re);
+ e->engine.data.output = NULL;
+ return;
+ }
+
+ re->win = info->info.window;
re = e->engine.data.output;
eng_window_free(re->window);
- re->window = eng_window_new(info->info.dc,
- info->info.window,
+ re->window = eng_window_new(info->info.window,
+ re->dc,
+ re->context,
info->info.depth,
e->output.w,
e->output.h);
@@ -99,6 +121,7 @@
re = (Render_Engine *)data;
eng_window_free(re->window);
+ evas_glew_shutdown(re->win, re->dc, re->context);
free(re);
evas_common_font_shutdown();
@@ -241,7 +264,7 @@
eng_window_use(re->window);
#ifdef SLOW_GL_COPY_RECT
- SwapBuffers(re->window->dc);
+ SwapBuffers(re->dc);
#else
/* SLOW AS ALL HELL */
evas_gl_common_swap_rect(re->window->gl_context,
@@ -499,13 +522,13 @@
im = image;
/* FIXME: can move to gl_common */
if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return im;
- if ((has_alpha) && im->im->cache_entry.flags.alpha) return image;
+ if ((has_alpha) && (im->im->cache_entry.flags.alpha)) return image;
else if ((!has_alpha) && (!im->im->cache_entry.flags.alpha)) return image;
if (im->references > 1)
{
Evas_GL_Image *im_new;
- im_new = evas_gl_common_image_new_from_copied_data(im->gc,
im->im->image->w, im->im->image->h, im->im->image->data,
+ im_new = evas_gl_common_image_new_from_copied_data(im->gc,
im->im->cache_entry.w, im->im->cache_entry.h, im->im->image.data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
if (!im_new) return im;
@@ -569,7 +592,7 @@
im = image;
/* FIXME: can move to gl_common */
if (im->cs.space == cspace) return;
- evas_cache_image_colorspace(&im->im.cache_entry, cspace);
+ evas_cache_image_colorspace(&im->im->cache_entry, cspace);
switch (cspace)
{
case EVAS_COLORSPACE_ARGB8888:
@@ -588,7 +611,7 @@
{
if (!im->cs.no_free) free(im->cs.data);
}
- im->cs.data = calloc(1, im->im->image->h * sizeof(unsigned char *) * 2);
+ im->cs.data = calloc(1, im->im->cache_entry.h * sizeof(unsigned char *)
* 2);
im->cs.no_free = 0;
break;
default:
@@ -615,8 +638,6 @@
Render_Engine *re;
re = (Render_Engine *)data;
- if (!re)
- printf ("MERDE2\n");
*error = 0;
eng_window_use(re->window);
return evas_gl_common_image_load(re->window->gl_context, file, key, lo);
@@ -665,8 +686,9 @@
*h = 0;
return;
}
- if (w) *w = ((Evas_GL_Image *)image)->im->image->w;
- if (h) *h = ((Evas_GL_Image *)image)->im->image->h;
+ if (w) *w = ((Evas_GL_Image *)image)->im->cache_entry.w;
+ if (h) *h = ((Evas_GL_Image *)image)->im->cache_entry.h;
+
}
static void *
@@ -682,7 +704,8 @@
if ((eng_image_colorspace_get(data, image) ==
EVAS_COLORSPACE_YCBCR422P601_PL) ||
(eng_image_colorspace_get(data, image) ==
EVAS_COLORSPACE_YCBCR422P709_PL))
w &= ~0x1;
- if ((im_old) && (im_old->im->image->w == w) && (im_old->im->image->h == h))
+ if ((im_old) && (im_old->im->cache_entry.w == w) &&
(im_old->im->cache_entry.h == h))
+
return image;
if (im_old)
{
@@ -729,7 +752,7 @@
}
im = image;
eng_window_use(re->window);
- evas_common_load_image_data_from_file(im->im);
+ evas_cache_image_load_data(&im->im->cache_entry);
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
@@ -739,7 +762,7 @@
{
Evas_GL_Image *im_new;
- im_new = evas_gl_common_image_new_from_copied_data(im->gc,
im->im->image->w, im->im->image->h, im->im->image->data,
+ im_new = evas_gl_common_image_new_from_copied_data(im->gc,
im->im->cache_entry.w, im->im->cache_entry.h, im->im->image.data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
if (!im_new)
@@ -753,7 +776,7 @@
else
evas_gl_common_image_dirty(im);
}
- *image_data = im->im->image->data;
+ *image_data = im->im->image.data;
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
case EVAS_COLORSPACE_YCBCR422P709_PL:
@@ -779,12 +802,12 @@
switch (im->cs.space)
{
case EVAS_COLORSPACE_ARGB8888:
- if (image_data != im->im->image->data)
+ if (image_data != im->im->image.data)
{
int w, h;
- w = im->im->image->w;
- h = im->im->image->h;
+ w = im->im->cache_entry.w;
+ h = im->im->cache_entry.h;
im2 = eng_image_new_from_data(data, w, h, image_data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data,
image));
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/modules/engines/gl_glew/evas_engine.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -3 -r1.2 -r1.3
--- evas_engine.h 7 Aug 2007 05:38:24 -0000 1.2
+++ evas_engine.h 26 Jun 2008 08:29:25 -0000 1.3
@@ -10,22 +10,32 @@
struct _Evas_GL_Glew_Window
{
- HDC dc;
HWND window;
+ HDC dc;
+ HGLRC context;
int width;
int height;
int depth;
- HGLRC context;
Evas_GL_Context *gl_context;
struct {
- int redraw : 1;
- int drew : 1;
- int x1, y1, x2, y2;
+ int x1;
+ int y1;
+ int x2;
+ int y2;
+ int redraw : 1;
+ int drew : 1;
} draw;
};
-Evas_GL_Glew_Window *eng_window_new(HDC dc,
- HWND window,
+int evas_glew_init(HWND window, HDC *dc, HGLRC *context);
+
+void evas_glew_shutdown(HWND window,
+ HDC dc,
+ HGLRC context);
+
+Evas_GL_Glew_Window *eng_window_new(HWND window,
+ HDC dc,
+ HGLRC context,
int depth,
int width,
int height);
===================================================================
RCS file: /cvs/e/e17/libs/evas/src/modules/engines/gl_glew/evas_glew_main.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- evas_glew_main.c 5 Aug 2007 07:22:44 -0000 1.1
+++ evas_glew_main.c 26 Jun 2008 08:29:25 -0000 1.2
@@ -5,47 +5,91 @@
static Evas_GL_Glew_Window *_evas_gl_glew_window = NULL;
-static HGLRC context = NULL;
-static int glew_is_init = 0;
+int
+evas_glew_init(HWND window, HDC *dc, HGLRC *context)
+{
+ PIXELFORMATDESCRIPTOR pfd;
+ int format;
+
+ *dc = GetDC(window);
+ if (!*dc)
+ goto no_dc;
+
+ ZeroMemory(&pfd, sizeof (pfd));
+ pfd.nSize = sizeof (pfd);
+ pfd.nVersion = 1;
+ pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER;
+ pfd.iPixelType = PFD_TYPE_RGBA;
+ pfd.cColorBits = 24;
+ pfd.cDepthBits = 32;
+ pfd.iLayerType = PFD_MAIN_PLANE;
+
+ format = ChoosePixelFormat(*dc, &pfd);
+ if (!format)
+ goto no_format;
+
+ SetPixelFormat(*dc, format, &pfd);
+
+ if (pfd.iPixelType != PFD_TYPE_RGBA)
+ goto no_format;
+
+ *context = wglCreateContext(*dc);
+ if (!*context)
+ goto no_format;
+
+ wglMakeCurrent(*dc, *context);
+
+ if (glewInit() != GLEW_OK)
+ goto glew_init_failed;
+
+ if (GLEW_VERSION_2_0)
+ {
+ printf ("2.0\n");
+ }
+
+ return 1;
+
+ glew_init_failed:
+ wglMakeCurrent(NULL, NULL);
+ wglDeleteContext(*context);
+ no_format:
+ ReleaseDC(window, *dc);
+ no_dc:
+
+ return 0;
+}
+
+void
+evas_glew_shutdown(HWND window,
+ HDC dc,
+ HGLRC context)
+{
+ wglMakeCurrent(NULL, NULL);
+ wglDeleteContext(context);
+ ReleaseDC(window, dc);
+}
Evas_GL_Glew_Window *
-eng_window_new(HDC dc,
- HWND window,
- int depth,
- int width,
- int height)
+eng_window_new(HWND window,
+ HDC dc,
+ HGLRC context,
+ int depth,
+ int width,
+ int height)
{
Evas_GL_Glew_Window *gw;
gw = calloc(1, sizeof(Evas_GL_Glew_Window));
if (!gw) return NULL;
- gw->dc = dc;
gw->window = window;
+ gw->dc = dc;
+ gw->context = context;
gw->depth = depth;
- if (!context)
- context = wglCreateContext(dc);
- if (!context)
- {
- free(gw);
- return NULL;
- }
- gw->context = context;
- wglMakeCurrent(dc, context);
- if (!glew_is_init)
- if (glewInit() != GLEW_OK)
- {
- wglMakeCurrent(NULL, NULL);
- wglDeleteContext(context);
- free(gw);
- return NULL;
- }
gw->gl_context = evas_gl_common_context_new();
if (!gw->gl_context)
{
- wglMakeCurrent(NULL, NULL);
- wglDeleteContext(context);
free(gw);
return NULL;
}
@@ -59,7 +103,6 @@
{
if (gw == _evas_gl_glew_window) _evas_gl_glew_window = NULL;
evas_gl_common_context_free(gw->gl_context);
- /* wglDeleteContext(gw->context); */
free(gw);
}
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs