forked from enlightenment/efl
put initialisation of glew in the engine, update the engine so that it uses the cache system
SVN revision: 34912
This commit is contained in:
parent
6b048a4eb5
commit
cf5d5718e2
|
@ -1,6 +1,7 @@
|
||||||
#ifndef __EVAS_ENGINE_GL_GLEW_H__
|
#ifndef __EVAS_ENGINE_GL_GLEW_H__
|
||||||
#define __EVAS_ENGINE_GL_GLEW_H__
|
#define __EVAS_ENGINE_GL_GLEW_H__
|
||||||
|
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +15,6 @@ struct _Evas_Engine_Info_GL_Glew
|
||||||
|
|
||||||
/* engine specific data & parameters it needs to set up */
|
/* engine specific data & parameters it needs to set up */
|
||||||
struct {
|
struct {
|
||||||
HDC dc;
|
|
||||||
HWND window;
|
HWND window;
|
||||||
int depth;
|
int depth;
|
||||||
} info;
|
} info;
|
||||||
|
|
|
@ -9,6 +9,9 @@ typedef struct _Render_Engine Render_Engine;
|
||||||
|
|
||||||
struct _Render_Engine
|
struct _Render_Engine
|
||||||
{
|
{
|
||||||
|
HWND win;
|
||||||
|
HDC dc;
|
||||||
|
HGLRC context;
|
||||||
Evas_GL_Glew_Window *window;
|
Evas_GL_Glew_Window *window;
|
||||||
int end;
|
int end;
|
||||||
};
|
};
|
||||||
|
@ -48,9 +51,18 @@ eng_setup(Evas *e, void *in)
|
||||||
re = calloc(1, sizeof(Render_Engine));
|
re = calloc(1, sizeof(Render_Engine));
|
||||||
if (!re) return;
|
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;
|
e->engine.data.output = re;
|
||||||
re->window = eng_window_new(info->info.dc,
|
re->window = eng_window_new(info->info.window,
|
||||||
info->info.window,
|
re->dc,
|
||||||
|
re->context,
|
||||||
info->info.depth,
|
info->info.depth,
|
||||||
e->output.w,
|
e->output.w,
|
||||||
e->output.h);
|
e->output.h);
|
||||||
|
@ -77,10 +89,20 @@ eng_setup(Evas *e, void *in)
|
||||||
}
|
}
|
||||||
else
|
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;
|
re = e->engine.data.output;
|
||||||
eng_window_free(re->window);
|
eng_window_free(re->window);
|
||||||
re->window = eng_window_new(info->info.dc,
|
re->window = eng_window_new(info->info.window,
|
||||||
info->info.window,
|
re->dc,
|
||||||
|
re->context,
|
||||||
info->info.depth,
|
info->info.depth,
|
||||||
e->output.w,
|
e->output.w,
|
||||||
e->output.h);
|
e->output.h);
|
||||||
|
@ -99,6 +121,7 @@ eng_output_free(void *data)
|
||||||
|
|
||||||
re = (Render_Engine *)data;
|
re = (Render_Engine *)data;
|
||||||
eng_window_free(re->window);
|
eng_window_free(re->window);
|
||||||
|
evas_glew_shutdown(re->win, re->dc, re->context);
|
||||||
free(re);
|
free(re);
|
||||||
|
|
||||||
evas_common_font_shutdown();
|
evas_common_font_shutdown();
|
||||||
|
@ -241,7 +264,7 @@ eng_output_flush(void *data)
|
||||||
eng_window_use(re->window);
|
eng_window_use(re->window);
|
||||||
|
|
||||||
#ifdef SLOW_GL_COPY_RECT
|
#ifdef SLOW_GL_COPY_RECT
|
||||||
SwapBuffers(re->window->dc);
|
SwapBuffers(re->dc);
|
||||||
#else
|
#else
|
||||||
/* SLOW AS ALL HELL */
|
/* SLOW AS ALL HELL */
|
||||||
evas_gl_common_swap_rect(re->window->gl_context,
|
evas_gl_common_swap_rect(re->window->gl_context,
|
||||||
|
@ -499,13 +522,13 @@ eng_image_alpha_set(void *data, void *image, int has_alpha)
|
||||||
im = image;
|
im = image;
|
||||||
/* FIXME: can move to gl_common */
|
/* FIXME: can move to gl_common */
|
||||||
if (im->cs.space != EVAS_COLORSPACE_ARGB8888) return im;
|
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;
|
else if ((!has_alpha) && (!im->im->cache_entry.flags.alpha)) return image;
|
||||||
if (im->references > 1)
|
if (im->references > 1)
|
||||||
{
|
{
|
||||||
Evas_GL_Image *im_new;
|
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_alpha_get(data, image),
|
||||||
eng_image_colorspace_get(data, image));
|
eng_image_colorspace_get(data, image));
|
||||||
if (!im_new) return im;
|
if (!im_new) return im;
|
||||||
|
@ -569,7 +592,7 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
|
||||||
im = image;
|
im = image;
|
||||||
/* FIXME: can move to gl_common */
|
/* FIXME: can move to gl_common */
|
||||||
if (im->cs.space == cspace) return;
|
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)
|
switch (cspace)
|
||||||
{
|
{
|
||||||
case EVAS_COLORSPACE_ARGB8888:
|
case EVAS_COLORSPACE_ARGB8888:
|
||||||
|
@ -588,7 +611,7 @@ eng_image_colorspace_set(void *data, void *image, int cspace)
|
||||||
{
|
{
|
||||||
if (!im->cs.no_free) free(im->cs.data);
|
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;
|
im->cs.no_free = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -615,8 +638,6 @@ eng_image_load(void *data, const char *file, const char *key, int *error, Evas_I
|
||||||
Render_Engine *re;
|
Render_Engine *re;
|
||||||
|
|
||||||
re = (Render_Engine *)data;
|
re = (Render_Engine *)data;
|
||||||
if (!re)
|
|
||||||
printf ("MERDE2\n");
|
|
||||||
*error = 0;
|
*error = 0;
|
||||||
eng_window_use(re->window);
|
eng_window_use(re->window);
|
||||||
return evas_gl_common_image_load(re->window->gl_context, file, key, lo);
|
return evas_gl_common_image_load(re->window->gl_context, file, key, lo);
|
||||||
|
@ -665,8 +686,9 @@ eng_image_size_get(void *data, void *image, int *w, int *h)
|
||||||
*h = 0;
|
*h = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (w) *w = ((Evas_GL_Image *)image)->im->image->w;
|
if (w) *w = ((Evas_GL_Image *)image)->im->cache_entry.w;
|
||||||
if (h) *h = ((Evas_GL_Image *)image)->im->image->h;
|
if (h) *h = ((Evas_GL_Image *)image)->im->cache_entry.h;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
|
@ -682,7 +704,8 @@ eng_image_size_set(void *data, void *image, int w, int h)
|
||||||
if ((eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P601_PL) ||
|
if ((eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P601_PL) ||
|
||||||
(eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P709_PL))
|
(eng_image_colorspace_get(data, image) == EVAS_COLORSPACE_YCBCR422P709_PL))
|
||||||
w &= ~0x1;
|
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;
|
return image;
|
||||||
if (im_old)
|
if (im_old)
|
||||||
{
|
{
|
||||||
|
@ -729,7 +752,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
|
||||||
}
|
}
|
||||||
im = image;
|
im = image;
|
||||||
eng_window_use(re->window);
|
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)
|
switch (im->cs.space)
|
||||||
{
|
{
|
||||||
case EVAS_COLORSPACE_ARGB8888:
|
case EVAS_COLORSPACE_ARGB8888:
|
||||||
|
@ -739,7 +762,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
|
||||||
{
|
{
|
||||||
Evas_GL_Image *im_new;
|
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_alpha_get(data, image),
|
||||||
eng_image_colorspace_get(data, image));
|
eng_image_colorspace_get(data, image));
|
||||||
if (!im_new)
|
if (!im_new)
|
||||||
|
@ -753,7 +776,7 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data)
|
||||||
else
|
else
|
||||||
evas_gl_common_image_dirty(im);
|
evas_gl_common_image_dirty(im);
|
||||||
}
|
}
|
||||||
*image_data = im->im->image->data;
|
*image_data = im->im->image.data;
|
||||||
break;
|
break;
|
||||||
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
||||||
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
||||||
|
@ -779,12 +802,12 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
|
||||||
switch (im->cs.space)
|
switch (im->cs.space)
|
||||||
{
|
{
|
||||||
case EVAS_COLORSPACE_ARGB8888:
|
case EVAS_COLORSPACE_ARGB8888:
|
||||||
if (image_data != im->im->image->data)
|
if (image_data != im->im->image.data)
|
||||||
{
|
{
|
||||||
int w, h;
|
int w, h;
|
||||||
|
|
||||||
w = im->im->image->w;
|
w = im->im->cache_entry.w;
|
||||||
h = im->im->image->h;
|
h = im->im->cache_entry.h;
|
||||||
im2 = eng_image_new_from_data(data, w, h, image_data,
|
im2 = eng_image_new_from_data(data, w, h, image_data,
|
||||||
eng_image_alpha_get(data, image),
|
eng_image_alpha_get(data, image),
|
||||||
eng_image_colorspace_get(data, image));
|
eng_image_colorspace_get(data, image));
|
||||||
|
|
|
@ -10,22 +10,32 @@ typedef struct _Evas_GL_Glew_Window Evas_GL_Glew_Window;
|
||||||
|
|
||||||
struct _Evas_GL_Glew_Window
|
struct _Evas_GL_Glew_Window
|
||||||
{
|
{
|
||||||
HDC dc;
|
|
||||||
HWND window;
|
HWND window;
|
||||||
|
HDC dc;
|
||||||
|
HGLRC context;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
int depth;
|
int depth;
|
||||||
HGLRC context;
|
|
||||||
Evas_GL_Context *gl_context;
|
Evas_GL_Context *gl_context;
|
||||||
struct {
|
struct {
|
||||||
|
int x1;
|
||||||
|
int y1;
|
||||||
|
int x2;
|
||||||
|
int y2;
|
||||||
int redraw : 1;
|
int redraw : 1;
|
||||||
int drew : 1;
|
int drew : 1;
|
||||||
int x1, y1, x2, y2;
|
|
||||||
} draw;
|
} draw;
|
||||||
};
|
};
|
||||||
|
|
||||||
Evas_GL_Glew_Window *eng_window_new(HDC dc,
|
int evas_glew_init(HWND window, HDC *dc, HGLRC *context);
|
||||||
HWND window,
|
|
||||||
|
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 depth,
|
||||||
int width,
|
int width,
|
||||||
int height);
|
int height);
|
||||||
|
|
|
@ -5,12 +5,74 @@
|
||||||
|
|
||||||
static Evas_GL_Glew_Window *_evas_gl_glew_window = NULL;
|
static Evas_GL_Glew_Window *_evas_gl_glew_window = NULL;
|
||||||
|
|
||||||
static HGLRC context = NULL;
|
int
|
||||||
static int glew_is_init = 0;
|
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 *
|
Evas_GL_Glew_Window *
|
||||||
eng_window_new(HDC dc,
|
eng_window_new(HWND window,
|
||||||
HWND window,
|
HDC dc,
|
||||||
|
HGLRC context,
|
||||||
int depth,
|
int depth,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
|
@ -20,32 +82,14 @@ eng_window_new(HDC dc,
|
||||||
gw = calloc(1, sizeof(Evas_GL_Glew_Window));
|
gw = calloc(1, sizeof(Evas_GL_Glew_Window));
|
||||||
if (!gw) return NULL;
|
if (!gw) return NULL;
|
||||||
|
|
||||||
gw->dc = dc;
|
|
||||||
gw->window = window;
|
gw->window = window;
|
||||||
|
gw->dc = dc;
|
||||||
|
gw->context = context;
|
||||||
gw->depth = depth;
|
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();
|
gw->gl_context = evas_gl_common_context_new();
|
||||||
if (!gw->gl_context)
|
if (!gw->gl_context)
|
||||||
{
|
{
|
||||||
wglMakeCurrent(NULL, NULL);
|
|
||||||
wglDeleteContext(context);
|
|
||||||
free(gw);
|
free(gw);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -59,7 +103,6 @@ eng_window_free(Evas_GL_Glew_Window *gw)
|
||||||
{
|
{
|
||||||
if (gw == _evas_gl_glew_window) _evas_gl_glew_window = NULL;
|
if (gw == _evas_gl_glew_window) _evas_gl_glew_window = NULL;
|
||||||
evas_gl_common_context_free(gw->gl_context);
|
evas_gl_common_context_free(gw->gl_context);
|
||||||
/* wglDeleteContext(gw->context); */
|
|
||||||
free(gw);
|
free(gw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue