#include "config.h"
#include <stdio.h>
-#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
struct _Evas_GL_Shared
{
Eina_List *images;
-
+
int images_size;
-
+
struct {
GLint max_texture_units;
GLint max_texture_size;
// tuning params - per gpu/cpu combo?
#define MAX_CUTOUT 512
#define DEF_CUTOUT 512
-
-// FIXME bug with pipes > 1 right now, should default to 32
+
+// FIXME bug with pipes > 1 right now, should default to 32
#define MAX_PIPES 128
#define DEF_PIPES 32
#define DEF_PIPES_SGX_540 32
#define DEF_PIPES_TEGRA_2 1
-
+
#define MIN_ATLAS_ALLOC 16
#define MAX_ATLAS_ALLOC 1024
#define DEF_ATLAS_ALLOC 1024
-
+
#define MIN_ATLAS_ALLOC_ALPHA 16
#define MAX_ATLAS_ALLOC_ALPHA 4096
#define DEF_ATLAS_ALLOC_ALPHA 4096
-
+
#define MAX_ATLAS_W 512
#define DEF_ATLAS_W 512
-
+
#define MAX_ATLAS_H 512
#define DEF_ATLAS_H 512
-
+
#define MIN_ATLAS_SLOT 16
#define MAX_ATLAS_SLOT 512
#define DEF_ATLAS_SLOT 16
-
+
struct {
struct {
int max;
} atlas;
} tune;
} info;
-
+
struct {
Eina_List *whole;
Eina_List *atlas[33][3];
} tex;
-
+
Eina_Hash *native_pm_hash;
Eina_Hash *native_tex_hash;
-
+
struct {
Evas_GL_Program rect;
Evas_GL_Program font;
-
+
Evas_GL_Program img, img_nomul;
Evas_GL_Program img_bgra, img_bgra_nomul;
Evas_GL_Program img_mask;
#define RTYPE_IMAGE 2
#define RTYPE_FONT 3
#define RTYPE_YUV 4
-#define RTYPE_MAP 5 /* need to merge with image */
+#define RTYPE_MAP 5 /* need to merge with image */
#define RTYPE_IMASK 6
int rot;
int foc, z0, px, py;
RGBA_Draw_Context *dc;
-
+
Evas_GL_Shared *shared;
int flushnum;
int clip;
} current;
} state;
-
+
struct {
struct {
int x, y, w, h;
Evas_GL_Image *im;
} array;
} pipe[MAX_PIPES];
-
+
struct {
Eina_Bool size : 1;
} change;
-
+
Eina_Bool havestuff : 1;
-
+
Evas_GL_Image *def_surface;
/* If this is set: Force drawing with a particular filter */
GLuint filter_prog;
-
+
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-// FIXME: hack. expose egl display to gl core for egl image sec extn.
+// FIXME: hack. expose egl display to gl core for egl image sec extn.
void *egldisp;
-#endif
+#endif
};
struct _Evas_GL_Texture_Pool
int x, y, w, h;
double sx1, sy1, sx2, sy2;
int references;
-
+
Eina_Bool alpha : 1;
};
void *data;
unsigned char no_free : 1;
} cs;
-
+
struct {
void *data;
struct {
int scale_hint, content_hint;
int csize;
-
+
Eina_List *filtered;
unsigned char dirty : 1;
#endif
void glerr(int err, const char *file, const char *func, int line, const char *op);
-
+
Evas_Engine_GL_Context *evas_gl_common_context_new(void);
void evas_gl_common_context_free(Evas_Engine_GL_Context *gc);
void evas_gl_common_context_use(Evas_Engine_GL_Context *gc);
RGBA_Map_Point *p,
int clip, int cx, int cy, int cw, int ch,
int r, int g, int b, int a,
- Eina_Bool smooth,
+ Eina_Bool smooth,
Eina_Bool tex_only,
Eina_Bool yuv);
void evas_gl_common_context_flush(Evas_Engine_GL_Context *gc);
int evas_gl_common_shader_program_init(Evas_GL_Shared *shared);
void evas_gl_common_shader_program_init_done(void);
void evas_gl_common_shader_program_shutdown(Evas_GL_Program *p);
-
+
void evas_gl_common_rect_draw(Evas_Engine_GL_Context *gc, int x, int y, int w, int h);
void evas_gl_texture_pool_empty(Evas_GL_Texture_Pool *pt);
# define FINDSYM(dst, sym, typ) if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
#endif
#define FALLBAK(dst, typ) if (!dst) dst = (typ)sym_missing;
-
+
FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffers", glsym_func_void);
FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffersEXT", glsym_func_void);
FINDSYM(glsym_glGenFramebuffers, "glGenFramebuffersARB", glsym_func_void);
FALLBAK(glsym_glGenFramebuffers, glsym_func_void);
-
+
FINDSYM(glsym_glBindFramebuffer, "glBindFramebuffer", glsym_func_void);
FINDSYM(glsym_glBindFramebuffer, "glBindFramebufferEXT", glsym_func_void);
FINDSYM(glsym_glBindFramebuffer, "glBindFramebufferARB", glsym_func_void);
FALLBAK(glsym_glBindFramebuffer, glsym_func_void);
-
+
FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2D", glsym_func_void);
FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2DEXT", glsym_func_void);
FINDSYM(glsym_glFramebufferTexture2D, "glFramebufferTexture2DARB", glsym_func_void);
FINDSYM(glsym_glProgramBinary, "glProgramBinary", glsym_func_void);
FINDSYM(glsym_glProgramBinary, "glProgramBinaryEXT", glsym_func_void);
FINDSYM(glsym_glProgramBinary, "glProgramBinaryARB", glsym_func_void);
-
+
FINDSYM(glsym_glProgramParameteri, "glProgramParameteri", glsym_func_void);
FINDSYM(glsym_glProgramParameteri, "glProgramParameteriEXT", glsym_func_void);
FINDSYM(glsym_glProgramParameteri, "glProgramParameteriARB", glsym_func_void);
-
+
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
#undef FINDSYM
#define FINDSYM(dst, sym, typ) \
FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddressEXT", secsym_func_eng_fn);
FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddressARB", secsym_func_eng_fn);
FINDSYM(secsym_eglGetProcAddress, "eglGetProcAddressKHR", secsym_func_eng_fn);
-
+
FINDSYM(secsym_eglCreateImage, "eglCreateImage", secsym_func_void_ptr);
FINDSYM(secsym_eglCreateImage, "eglCreateImageEXT", secsym_func_void_ptr);
FINDSYM(secsym_eglCreateImage, "eglCreateImageARB", secsym_func_void_ptr);
FINDSYM(secsym_eglCreateImage, "eglCreateImageKHR", secsym_func_void_ptr);
-
+
FINDSYM(secsym_eglDestroyImage, "eglDestroyImage", secsym_func_uint);
FINDSYM(secsym_eglDestroyImage, "eglDestroyImageEXT", secsym_func_uint);
FINDSYM(secsym_eglDestroyImage, "eglDestroyImageARB", secsym_func_uint);
FINDSYM(secsym_eglDestroyImage, "eglDestroyImageKHR", secsym_func_uint);
-
+
FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinary", glsym_func_void);
FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinaryEXT", glsym_func_void);
FINDSYM(glsym_glGetProgramBinary, "glGetProgramBinaryARB", glsym_func_void);
FINDSYM(glsym_glProgramBinary, "glProgramBinaryARB", glsym_func_void);
FINDSYM(glsym_glProgramBinary, "glProgramBinaryOES", glsym_func_void);
FINDSYM(glsym_glProgramBinary, "glProgramBinaryKHR", glsym_func_void);
-
+
FINDSYM(glsym_glProgramParameteri, "glProgramParameteri", glsym_func_void);
FINDSYM(glsym_glProgramParameteri, "glProgramParameteriEXT", glsym_func_void);
FINDSYM(glsym_glProgramParameteri, "glProgramParameteriARB", glsym_func_void);
FINDSYM(glsym_glProgramParameteri, "glProgramParameteriOES", glsym_func_void);
FINDSYM(glsym_glProgramParameteri, "glProgramParameteriKHR", glsym_func_void);
-
+
FINDSYM(secsym_glEGLImageTargetTexture2DOES, "glEGLImageTargetTexture2DOES", glsym_func_void);
-
+
FINDSYM(secsym_eglMapImageSEC, "eglMapImageSEC", secsym_func_void_ptr);
-
+
FINDSYM(secsym_eglUnmapImageSEC, "eglUnmapImageSEC", secsym_func_uint);
-
+
FINDSYM(secsym_eglGetImageAttribSEC, "eglGetImageAttribSEC", secsym_func_uint);
-#endif
+#endif
}
static void shader_array_flush(Evas_Engine_GL_Context *gc);
GLfloat rotf;
GLfloat cosv, sinv;
GLfloat tx, ty;
-
+
rotf = (((rot / 90) & 0x3) * M_PI) / 2.0;
-
+
tx = -0.5 * (1.0 - orth);
ty = -0.5 * (1.0 - orth);
-
+
if (rot == 90)
{
tx += -(vw * 1.0);
tx += -(vw * 0.0);
ty += -(vh * 1.0);
}
-
+
cosv = cos(rotf);
sinv = sin(rotf);
-
+
m[0] = (2.0 / (r - l)) * ( cosv);
m[1] = (2.0 / (r - l)) * ( sinv);
m[2] = 0.0;
m[3] = 0.0;
-
+
m[4] = (2.0 / (t - b)) * (-sinv);
m[5] = (2.0 / (t - b)) * ( cosv);
m[6] = 0.0;
m[7] = 0.0;
-
+
m[8] = 0.0;
m[9] = 0.0;
m[10] = -(2.0 / (far - near));
m[11] = 1.0 / (GLfloat)foc;
-
+
m[12] = (m[0] * tx) + (m[4] * ty) - ((r + l) / (r - l));
m[13] = (m[1] * tx) + (m[5] * ty) - ((t + b) / (t - b));
m[14] = (m[2] * tx) + (m[6] * ty) - ((near + far) / (far - near));
rot = 0;
m = -1;
}
-
- if ((!gc->change.size) ||
+
+ if ((!gc->change.size) ||
((gc->shared->w == w) && (gc->shared->h == h) &&
(gc->shared->rot == rot) && (gc->shared->foc == gc->foc) &&
(gc->shared->mflip == m)))
return;
-
+
gc->shared->w = w;
gc->shared->h = h;
gc->shared->rot = rot;
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
// std matrix
if (m == 1)
- matrix_ortho(proj,
- 0, w, 0, h,
+ matrix_ortho(proj,
+ 0, w, 0, h,
-1000000.0, 1000000.0,
rot, w, h,
1, 1.0);
// v flipped matrix for render-to-texture
else
- matrix_ortho(proj,
- 0, w, h, 0,
+ matrix_ortho(proj,
+ 0, w, h, 0,
-1000000.0, 1000000.0,
rot, w, h,
1, 1.0);
else
{
int px, py, vx, vy, vw = 0, vh = 0, ax = 0, ay = 0, ppx = 0, ppy = 0;
-
+
px = gc->shared->px;
py = gc->shared->py;
-
+
if ((rot == 0 ) || (rot == 90 )) ppx = px;
else if ((rot == 180) || (rot == 270)) ppx = w - px;
if ((rot == 0 ) || (rot == 270)) ppy = py;
else if ((rot == 90 ) || (rot == 180)) ppy = h - py;
-
+
vx = ((w / 2) - ppx);
if (vx >= 0)
{
else if ((rot == 180) || (rot == 270)) ax = ppx - px;
vx = 0;
}
-
+
vy = ((h / 2) - ppy);
if (vy < 0)
{
else if ((rot == 90 ) || (rot == 180)) ay = 0;
vy = 0;
}
-
+
if (m == -1) ay = vy * 2;
-
+
if ((rot == 0) || (rot == 180))
glViewport(-2 * vx, -2 * vy, vw, vh);
else
gc->shared->ax = ax;
gc->shared->ay = ay;
}
-
+
glUseProgram(gc->shared->shader.rect.prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.rect.prog, "mvp"), 1,
glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.font.prog, "mvp"), 1,
GL_FALSE, proj);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glUseProgram(gc->shared->shader.yuv.prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.yuv.prog, "mvp"), 1,
glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.yuv_nomul.prog, "mvp"), 1,
GL_FALSE, proj);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glUseProgram(gc->shared->shader.tex.prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.tex.prog, "mvp"), 1,
glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.tex_nomul.prog, "mvp"), 1,
GL_FALSE, proj);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glUseProgram(gc->shared->shader.img.prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glUniformMatrix4fv(glGetUniformLocation(gc->shared->shader.img.prog, "mvp"), 1,
if (!gc) return NULL;
gl_symbols();
-
+
gc->references = 1;
-
+
_evas_gl_common_context = gc;
-
+
for (i = 0; i < MAX_PIPES; i++)
gc->pipe[i].shader.render_op = EVAS_RENDER_BLEND;
-
+
if (!shared)
{
const GLubyte *ext;
shared->info.bin_program = 1;
#ifdef GL_TEXTURE_MAX_ANISOTROPY_EXT
if ((strstr((char *)ext, "GL_EXT_texture_filter_anisotropic")))
- glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,
+ glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT,
&(shared->info.anisotropic));
#endif
#ifdef GL_BGRA
(secsym_eglGetImageAttribSEC))
shared->info.sec_image_map = 1;
}
-#endif
+#endif
}
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS,
&(shared->info.max_texture_units));
if (s) shared->info.max_vertex_elements = atoi(s);
if (shared->info.max_vertex_elements < 6)
shared->info.max_vertex_elements = 6;
-
+
// magic numbers that are a result of imperical testing and getting
// "best case" performance across a range of systems
shared->info.tune.cutout.max = DEF_CUTOUT;
shared->info.tune.atlas.max_w = DEF_ATLAS_W;
shared->info.tune.atlas.max_h = DEF_ATLAS_H;
shared->info.tune.atlas.slot_size = DEF_ATLAS_SLOT;
-
+
// per gpu hacks. based on impirical measurement of some known gpu's
s = (const char *)glGetString(GL_RENDERER);
if (s)
else if (strstr(s, "NVIDIA Tegra"))
shared->info.tune.pipes.max = DEF_PIPES_TEGRA_2;
}
-
+
#define GETENVOPT(name, tune_param, min, max) \
do { \
const char *__v = getenv(name); \
"EVAS_GL_ATLAS_ALLOC_ALPHA_SIZE: %i\n"
"EVAS_GL_ATLAS_MAX_W x EVAS_GL_ATLAS_MAX_H: %i x %i\n"
"EVAS_GL_ATLAS_SLOT_SIZE: %i\n"
- ,
+ ,
(int)shared->info.max_texture_size, (int)shared->info.max_texture_size,
(int)shared->info.max_texture_units,
(int)shared->info.tex_npo2,
(double)shared->info.anisotropic,
(int)shared->info.sec_image_map,
(int)shared->info.max_vertex_elements,
-
+
(int)shared->info.bin_program,
(int)shared->info.tune.cutout.max,
(int)shared->info.tune.pipes.max,
(int)shared->info.tune.atlas.max_w, (int)shared->info.tune.atlas.max_h,
(int)shared->info.tune.atlas.slot_size
);
-
+
glDisable(GL_DEPTH_TEST);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glEnable(GL_DITHER);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE); // ???
glDepthMask(GL_FALSE);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
#endif
-
+
glEnableVertexAttribArray(SHAD_VERTEX);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glEnableVertexAttribArray(SHAD_COLOR);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
if (!evas_gl_common_shader_program_init(shared)) goto error;
-
+
glUseProgram(shared->shader.yuv.prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "tex"), 0);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glUniform1i(glGetUniformLocation(shared->shader.yuv.prog, "texv"), 2);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glUseProgram(shared->shader.yuv_nomul.prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glUniform1i(glGetUniformLocation(shared->shader.yuv_nomul.prog, "tex"), 0);
glUseProgram(gc->pipe[0].shader.cur_prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
evas_gl_common_shader_program_init_done();
// in shader:
// uniform sampler2D tex[8];
- //
+ //
// in code:
// GLuint texes[8];
// GLint loc = glGetUniformLocation(prog, "tex");
gc->shared = shared;
gc->shared->references++;
_evas_gl_common_viewport_set(gc);
-
+
gc->def_surface = evas_gl_common_image_surface_new(gc, 1, 1, 1);
-
+
return gc;
error:
evas_gl_common_context_free(gc);
{
int i, j;
Eina_List *l;
-
+
gc->references--;
if (gc->references > 0) return;
if (gc->shared) gc->shared->references--;
-
+
if (gc->def_surface) evas_gl_common_image_free(gc->def_surface);
if (gc->shared)
if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3);
}
}
-
+
if ((gc->shared) && (gc->shared->references == 0))
{
Evas_GL_Texture_Pool *pt;
-
+
evas_gl_common_shader_program_shutdown(&(gc->shared->shader.rect));
evas_gl_common_shader_program_shutdown(&(gc->shared->shader.font));
evas_gl_common_shader_program_shutdown(&(gc->shared->shader.img));
{
evas_gl_common_image_free(gc->shared->images->data);
}
-
+
EINA_LIST_FOREACH(gc->shared->tex.whole, l, pt)
evas_gl_texture_pool_empty(pt);
for (i = 0; i < 33; i++)
if (getenv("EVAS_GL_DBG")) dbgflushnum = 1;
}
if (dbgflushnum) printf("----prev-flushnum: %i -----------------------------------\n", gc->flushnum);
-
+
gc->flushnum = 0;
gc->state.current.cur_prog = 0;
gc->state.current.cur_tex = 0;
gc->state.current.cy = 0;
gc->state.current.cw = 0;
gc->state.current.ch = 0;
-
+
for (i = 0; i < gc->shared->info.tune.pipes.max; i++)
{
gc->pipe[i].region.x = 0;
gc->pipe[i].shader.ch = 0;
}
gc->change.size = 1;
-
+
glDisable(GL_SCISSOR_TEST);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glScissor(0, 0, 0, 0);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glDisable(GL_DEPTH_TEST);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glEnable(GL_DITHER);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE); // ???
glDepthMask(GL_FALSE);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
#endif
-
+
glEnableVertexAttribArray(SHAD_VERTEX);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glEnableVertexAttribArray(SHAD_COLOR);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glUseProgram(gc->pipe[0].shader.cur_prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glActiveTexture(GL_TEXTURE0);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
Evas_GL_Image *surface)
{
if (surface == gc->pipe[0].shader.surface) return;
-
+
evas_gl_common_context_flush(gc);
-
+
gc->state.current.cur_prog = -1;
gc->state.current.cur_tex = -1;
gc->state.current.cur_texu = -1;
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
# ifndef GL_FRAMEBUFFER
# define GL_FRAMEBUFFER GL_FRAMEBUFFER_OES
-# endif
+# endif
#else
# ifndef GL_FRAMEBUFFER
# define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT
-# endif
-#endif
+# endif
+#endif
if (gc->pipe[0].shader.surface == gc->def_surface)
{
glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0);
int x, int y, int w, int h)
{
int i, rx, ry, rw, rh, ii;
-
+
rx = gc->pipe[n].region.x;
ry = gc->pipe[n].region.y;
rw = gc->pipe[n].region.w;
rh = gc->pipe[n].region.h;
if (!RECTS_INTERSECT(x, y, w, h, rx, ry, rw, rh))
return 0;
-
+
// a hack for now. map pipes use their whole bounding box for intersects
// which at worst case reduces to old pipeline flushes, but cheaper than
// full quad region or triangle intersects right now
if (gc->pipe[n].region.type == RTYPE_MAP) return 1;
-
- for (i = 0,
- ii = 0;
-
- i < gc->pipe[n].array.num;
-
- i += (3 * 2),
+
+ for (i = 0,
+ ii = 0;
+
+ i < gc->pipe[n].array.num;
+
+ i += (3 * 2),
ii += (3 * 3 * 2))
{ // tri 1...
// 0, 1, 2 < top left
int x, int y, int w, int h)
{
int x1, y1, x2, y2;
-
+
if (gc->pipe[n].region.w <= 0)
{
gc->pipe[n].region.x = x;
}
void
-evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
+evas_gl_common_context_line_push(Evas_Engine_GL_Context *gc,
int x1, int y1, int x2, int y2,
int clip, int cx, int cy, int cw, int ch,
int r, int g, int b, int a)
Eina_Bool blend = 0;
GLuint prog = gc->shared->shader.rect.prog;
int pn = 0;
-
+
if (a < 255) blend = 1;
if (gc->dc->render_op == EVAS_RENDER_COPY) blend = 0;
-
+
shader_array_flush(gc);
vertex_array_size_check(gc, gc->state.top_pipe, 2);
pn = gc->state.top_pipe;
gc->pipe[pn].shader.cy = cy;
gc->pipe[pn].shader.cw = cw;
gc->pipe[pn].shader.ch = ch;
-
+
gc->pipe[pn].array.line = 1;
gc->pipe[pn].array.use_vertex = 1;
gc->pipe[pn].array.use_color = 1;
gc->pipe[pn].array.use_texuv = 0;
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
-
+
pnum = gc->pipe[pn].array.num;
nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; nt = pnum * 4;
gc->pipe[pn].array.num += 2;
array_alloc(gc, pn);
-
+
PUSH_VERTEX(pn, x1, y1, 0);
PUSH_VERTEX(pn, x2, y2, 0);
-
+
for (i = 0; i < 2; i++)
{
PUSH_COLOR(pn, r, g, b, a);
}
-
+
shader_array_flush(gc);
gc->pipe[pn].array.line = 0;
gc->pipe[pn].array.use_vertex = 0;
}
void
-evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
+evas_gl_common_context_rectangle_push(Evas_Engine_GL_Context *gc,
int x, int y, int w, int h,
int r, int g, int b, int a)
{
if (a < 255) blend = 1;
if (gc->dc->render_op == EVAS_RENDER_COPY) blend = 0;
-
+
again:
vertex_array_size_check(gc, gc->state.top_pipe, 6);
pn = gc->state.top_pipe;
else
{
int found = 0;
-
+
for (i = pn; i >= 0; i--)
{
if ((gc->pipe[i].region.type == RTYPE_RECT)
gc->pipe[pn].array.use_texuv3 = 0;
}
}
-#else
+#else
if ((gc->pipe[pn].shader.cur_tex != 0)
|| (gc->pipe[pn].shader.cur_prog != prog)
|| (gc->pipe[pn].shader.blend != blend)
gc->pipe[pn].shader.cw = 0;
gc->pipe[pn].shader.ch = 0;
}
-
+
gc->pipe[pn].region.type = RTYPE_RECT;
gc->pipe[pn].array.line = 0;
gc->pipe[pn].array.use_vertex = 1;
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
#endif
-
+
pipe_region_expand(gc, pn, x, y, w, h);
-
+
pnum = gc->pipe[pn].array.num;
nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; nt = pnum * 4;
gc->pipe[pn].array.num += 6;
array_alloc(gc, pn);
-
+
PUSH_VERTEX(pn, x , y , 0);
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x + w, y + h, 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
for (i = 0; i < 6; i++)
{
PUSH_COLOR(pn, r, g, b, a);
else
{
int found = 0;
-
+
for (i = pn; i >= 0; i--)
{
if ((gc->pipe[i].region.type == RTYPE_IMAGE)
gc->pipe[pn].array.use_texuv = 1;
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
-
+
}
}
if ((tex->im) && (tex->im->native.data))
goto again;
}
}
-#else
+#else
if ((gc->pipe[pn].shader.cur_tex != tex->pt->texture)
|| (gc->pipe[pn].shader.cur_prog != prog)
|| (gc->pipe[pn].shader.smooth != smooth)
gc->pipe[pn].shader.cy = 0;
gc->pipe[pn].shader.cw = 0;
gc->pipe[pn].shader.ch = 0;
- }
+ }
if ((tex->im) && (tex->im->native.data))
{
if (gc->pipe[pn].array.im != tex->im)
#endif
pipe_region_expand(gc, pn, x, y, w, h);
-
+
pnum = gc->pipe[pn].array.num;
nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; nu2 = pnum * 2;
nt = pnum * 4;
PUSH_VERTEX(pn, x , y , 0);
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
PUSH_TEXUV(pn, tx1, ty1);
PUSH_TEXUV(pn, tx2, ty1);
PUSH_TEXUV(pn, tx1, ty2);
-
+
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x + w, y + h, 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
PUSH_TEXUV(pn, tx2, ty1);
PUSH_TEXUV(pn, tx2, ty2);
PUSH_TEXUV(pn, tx1, ty2);
else
{
int found = 0;
-
+
for (i = pn; i >= 0; i--)
{
if ((gc->pipe[i].region.type == RTYPE_IMASK)
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
gc->pipe[pn].array.use_texm = 1;
-
+
}
}
if ((tex->im) && (tex->im->native.data))
goto again;
}
}
-#else
+#else
if ((gc->pipe[pn].shader.cur_tex != tex->pt->texture)
|| (gc->pipe[pn].shader.cur_prog != prog)
|| (gc->pipe[pn].shader.smooth != smooth)
gc->pipe[pn].shader.cy = 0;
gc->pipe[pn].shader.cw = 0;
gc->pipe[pn].shader.ch = 0;
- }
+ }
if ((tex->im) && (tex->im->native.data))
{
if (gc->pipe[pn].array.im != tex->im)
#endif
pipe_region_expand(gc, pn, x, y, w, h);
-
+
pnum = gc->pipe[pn].array.num;
nv = pnum * 3; nc = pnum * 4; nm = pnum * 2; nu = pnum * 2;
nt = pnum * 4;
PUSH_VERTEX(pn, x , y , 0);
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
PUSH_TEXUV(pn, tx1, ty1);
PUSH_TEXUV(pn, tx2, ty1);
PUSH_TEXUV(pn, tx1, ty2);
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x + w, y + h, 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
PUSH_TEXUV(pn, tx2, ty1);
PUSH_TEXUV(pn, tx2, ty2);
PUSH_TEXUV(pn, tx1, ty2);
else
{
int found = 0;
-
+
for (i = pn; i >= 0; i--)
{
if ((gc->pipe[i].region.type == RTYPE_FONT)
gc->pipe[pn].array.use_texuv3 = 0;
}
}
-#else
+#else
if ((gc->pipe[pn].shader.cur_tex != tex->pt->texture)
|| (gc->pipe[pn].shader.cur_prog != gc->shared->shader.font.prog)
|| (gc->pipe[pn].shader.smooth != 0)
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
#endif
-
+
pipe_region_expand(gc, pn, x, y, w, h);
-
+
pnum = gc->pipe[pn].array.num;
nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; nt = pnum * 4;
gc->pipe[pn].array.num += 6;
tx2 = ((double)(tex->x) + sx + sw) / (double)tex->pt->w;
ty2 = ((double)(tex->y) + sy + sh) / (double)tex->pt->h;
}
-
+
PUSH_VERTEX(pn, x , y , 0);
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
PUSH_TEXUV(pn, tx1, ty1);
PUSH_TEXUV(pn, tx2, ty1);
PUSH_TEXUV(pn, tx1, ty2);
-
+
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x + w, y + h, 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
PUSH_TEXUV(pn, tx2, ty1);
PUSH_TEXUV(pn, tx2, ty2);
PUSH_TEXUV(pn, tx1, ty2);
void
evas_gl_common_context_yuv_push(Evas_Engine_GL_Context *gc,
- Evas_GL_Texture *tex,
+ Evas_GL_Texture *tex,
double sx, double sy, double sw, double sh,
int x, int y, int w, int h,
int r, int g, int b, int a,
int pn = 0;
if (a < 255) blend = 1;
-
+
if ((a == 255) && (r == 255) && (g == 255) && (b == 255))
prog = gc->shared->shader.yuv_nomul.prog;
else
prog = gc->shared->shader.yuv.prog;
-
+
again:
vertex_array_size_check(gc, gc->state.top_pipe, 6);
pn = gc->state.top_pipe;
else
{
int found = 0;
-
+
for (i = pn; i >= 0; i--)
{
if ((gc->pipe[i].region.type == RTYPE_YUV)
gc->pipe[pn].array.use_texuv3 = 1;
}
}
-#else
+#else
if ((gc->pipe[pn].shader.cur_tex != tex->pt->texture)
|| (gc->pipe[pn].shader.cur_prog != prog)
|| (gc->pipe[pn].shader.smooth != smooth)
gc->pipe[pn].shader.cw = 0;
gc->pipe[pn].shader.ch = 0;
}
-
+
gc->pipe[pn].region.type = RTYPE_YUV;
gc->pipe[pn].array.line = 0;
gc->pipe[pn].array.use_vertex = 1;
gc->pipe[pn].array.use_texuv2 = 1;
gc->pipe[pn].array.use_texuv3 = 1;
#endif
-
+
pipe_region_expand(gc, pn, x, y, w, h);
-
+
pnum = gc->pipe[pn].array.num;
- nv = pnum * 3; nc = pnum * 4; nu = pnum * 2;
+ nv = pnum * 3; nc = pnum * 4; nu = pnum * 2;
nu2 = pnum * 2; nu3 = pnum * 2; nt = pnum * 4;
gc->pipe[pn].array.num += 6;
array_alloc(gc, pn);
ty1 = (sy) / (double)tex->pt->h;
tx2 = (sx + sw) / (double)tex->pt->w;
ty2 = (sy + sh) / (double)tex->pt->h;
-
+
t2x1 = ((sx) / 2) / (double)tex->ptu->w;
t2y1 = ((sy) / 2) / (double)tex->ptu->h;
t2x2 = ((sx + sw) / 2) / (double)tex->ptu->w;
t2y2 = ((sy + sh) / 2) / (double)tex->ptu->h;
-
+
PUSH_VERTEX(pn, x , y , 0);
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
PUSH_TEXUV(pn, tx1, ty1);
PUSH_TEXUV(pn, tx2, ty1);
PUSH_TEXUV(pn, tx1, ty2);
-
+
PUSH_TEXUV2(pn, t2x1, t2y1);
PUSH_TEXUV2(pn, t2x2, t2y1);
PUSH_TEXUV2(pn, t2x1, t2y2);
-
+
PUSH_TEXUV3(pn, t2x1, t2y1);
PUSH_TEXUV3(pn, t2x2, t2y1);
PUSH_TEXUV3(pn, t2x1, t2y2);
-
+
PUSH_VERTEX(pn, x + w, y , 0);
PUSH_VERTEX(pn, x + w, y + h, 0);
PUSH_VERTEX(pn, x , y + h, 0);
-
+
PUSH_TEXUV(pn, tx2, ty1);
PUSH_TEXUV(pn, tx2, ty2);
PUSH_TEXUV(pn, tx1, ty2);
if ((A_VAL(&(p[0].col)) < 0xff) || (A_VAL(&(p[1].col)) < 0xff) ||
(A_VAL(&(p[2].col)) < 0xff) || (A_VAL(&(p[3].col)) < 0xff))
blend = 1;
-
+
if ((p[0].z == p[1].z) && (p[1].z == p[2].z) && (p[2].z == p[3].z))
flat = 1;
if (!clip) cx = cy = cw = ch = 0;
-
+
if (!flat)
{
if (p[0].foc <= 0) flat = 1;
}
}
}
-
+
x = w = (p[points[0]].x >> FP);
y = h = (p[points[0]].y >> FP);
for (i = 0; i < 4; i++)
{
tx[i] = ((double)(tex->x) + (((double)p[i].u) / FP1)) /
(double)tex->pt->w;
- ty[i] = ((double)(tex->y) + (((double)p[i].v) / FP1)) /
+ ty[i] = ((double)(tex->y) + (((double)p[i].v) / FP1)) /
(double)tex->pt->h;
px = (p[points[i]].x >> FP);
if (px < x) x = px;
}
w = w - x;
h = h - y;
-
+
if (clip)
{
int nx = x, ny = y, nw = w, nh = h;
-
+
RECTS_CLIP_TO_RECT(nx, ny, nw, nh, cx, cy, cw, ch);
if ((nx == x) && (ny == y) && (nw == w) && (nh == h))
{
}
x = nx; y = nw; w = nw; h = nh;
}
-
+
if (!flat)
{
shader_array_flush(gc);
else
{
int found = 0;
-
+
for (i = pn; i >= 0; i--)
{
if ((gc->pipe[i].region.type == RTYPE_MAP)
goto again;
}
}
-#else
+#else
if ((gc->pipe[pn].shader.cur_tex != tex->pt->texture)
|| (gc->pipe[pn].shader.cur_prog != prog)
|| (gc->pipe[pn].shader.smooth != smooth)
gc->pipe[pn].array.use_texuv2 = 0;
gc->pipe[pn].array.use_texuv3 = 0;
}
-#endif
-
+#endif
+
pipe_region_expand(gc, pn, x, y, w, h);
-
+
pnum = gc->pipe[pn].array.num;
nv = pnum * 3; nc = pnum * 4; nu = pnum * 2; nu2 = pnum * 2;
nu2 = pnum * 2; nu3 = pnum * 2; nt = pnum * 4;
t2y[i] = 1.0 - t2y[i];
}
}
-
+
cmul = ARGB_JOIN(a, r, g, b);
for (i = 0; i < 6; i++)
{
if (flat)
{
PUSH_VERTEX(pn,
- (p[points[i]].x >> FP),
+ (p[points[i]].x >> FP),
(p[points[i]].y >> FP),
0);
}
else
{
PUSH_VERTEX(pn,
- (p[points[i]].fx) + gc->shared->ax,
+ (p[points[i]].fx) + gc->shared->ax,
(p[points[i]].fy) + gc->shared->ay,
- (p[points[i]].fz)
+ (p[points[i]].fz)
+ (gc->shared->foc - gc->shared->z0));
}
PUSH_TEXUV(pn,
t2x[points[i]],
t2y[points[i]]);
}
-
+
PUSH_COLOR(pn,
R_VAL(&cl),
G_VAL(&cl),
glUseProgram(gc->pipe[i].shader.cur_prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
-
+
if (gc->pipe[i].shader.cur_tex != gc->state.current.cur_tex)
{
#if 0
(GL_TEXTURE_2D, gc->pipe[i].array.im->tex->pt->dyn.img);
}
else
-#endif
+#endif
{
if (!gc->pipe[i].array.im->native.loose)
{
if (gc->pipe[i].array.im->native.func.bind)
- gc->pipe[i].array.im->native.func.bind(gc->pipe[i].array.im->native.func.data,
+ gc->pipe[i].array.im->native.func.bind(gc->pipe[i].array.im->native.func.data,
gc->pipe[i].array.im);
}
}
}
if (gc->pipe[i].shader.clip != gc->state.current.clip)
{
-
+
if (gc->pipe[i].shader.clip)
{
cy = gh - gc->pipe[i].shader.cy - gc->pipe[i].shader.ch;
if (fbo) cy = gc->pipe[i].shader.cy;
glEnable(GL_SCISSOR_TEST);
if (!fbo)
- scissor_rot(gc, gc->rot, gw, gh,
+ scissor_rot(gc, gc->rot, gw, gh,
gc->pipe[i].shader.cx,
cy,
gc->pipe[i].shader.cw,
cy = gh - gc->pipe[i].shader.cy - gc->pipe[i].shader.ch;
if (fbo) cy = gc->pipe[i].shader.cy;
if (!fbo)
- scissor_rot(gc, gc->rot, gw, gh,
+ scissor_rot(gc, gc->rot, gw, gh,
gc->pipe[i].shader.cx,
cy,
gc->pipe[i].shader.cw,
glDisableVertexAttribArray(SHAD_TEXUV);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
-
+
if (gc->pipe[i].array.line)
{
glDisableVertexAttribArray(SHAD_TEXUV);
}
if (dbgflushnum)
{
- const char *types[6] =
+ const char *types[6] =
{"----", "RECT", "IMAG", "FONT", "YUV-", "MAP"};
printf(" DRAW#%3i %4i -> %p[%4ix%4i] @ %4ix%4i -{ tex %4i type %s }-\n",
i,
- gc->pipe[i].array.num / 6,
+ gc->pipe[i].array.num / 6,
gc->pipe[0].shader.surface,
gc->pipe[0].shader.surface->w,
gc->pipe[0].shader.surface->h,
if (!gc->pipe[i].array.im->native.loose)
{
if (gc->pipe[i].array.im->native.func.unbind)
- gc->pipe[i].array.im->native.func.unbind(gc->pipe[i].array.im->native.func.data,
+ gc->pipe[i].array.im->native.func.unbind(gc->pipe[i].array.im->native.func.data,
gc->pipe[i].array.im);
}
gc->pipe[i].array.im = NULL;
}
-
+
gc->state.current.cur_prog = gc->pipe[i].shader.cur_prog;
gc->state.current.cur_tex = gc->pipe[i].shader.cur_tex;
gc->state.current.blend = gc->pipe[i].shader.blend;
gc->state.current.cy = gc->pipe[i].shader.cy;
gc->state.current.cw = gc->pipe[i].shader.cw;
gc->state.current.ch = gc->pipe[i].shader.ch;
-
+
if (gc->pipe[i].array.vertex) free(gc->pipe[i].array.vertex);
if (gc->pipe[i].array.color) free(gc->pipe[i].array.color);
if (gc->pipe[i].array.texuv) free(gc->pipe[i].array.texuv);
if (gc->pipe[i].array.texm) free(gc->pipe[i].array.texm);
if (gc->pipe[i].array.texuv2) free(gc->pipe[i].array.texuv2);
if (gc->pipe[i].array.texuv3) free(gc->pipe[i].array.texuv3);
-
+
gc->pipe[i].array.vertex = NULL;
gc->pipe[i].array.color = NULL;
gc->pipe[i].array.texuv = NULL;
gc->pipe[i].array.num = 0;
gc->pipe[i].array.alloc = 0;
-
+
gc->pipe[i].region.x = 0;
gc->pipe[i].region.y = 0;
gc->pipe[i].region.w = 0;
int fh;
if (fg->ext_dat) return fg->ext_dat; // FIXME: one engine at a time can do this :(
-
+
w = fg->glyph_out->bitmap.width;
h = fg->glyph_out->bitmap.rows;
if ((w == 0) || (h == 0)) return NULL;
DATA8 *tmpbuf = NULL, *dp, *tp, bits;
int bi, bj, end;
const DATA8 bitrepl[2] = {0x0, 0xff};
-
+
tmpbuf = alloca(w);
if (tmpbuf)
{
int x, y;
DATA8 *p1, *p2;
-
+
for (y = 0; y < h; y++)
{
p1 = tmpbuf;
int c, cx, cy, cw, ch;
int i;
int sx, sy, sw, sh;
-
+
if (dc != gc->dc) return;
tex = fg->ext_dat;
if (!tex) return;
g = (dc->col.col >> 8 ) & 0xff;
b = (dc->col.col ) & 0xff;
sx = 0; sy = 0; sw = tex->w, sh = tex->h;
- if ((!gc->dc->cutout.rects)
+ if ((!gc->dc->cutout.rects)
// || (gc->dc->cutout.active > 32)
)
{
if (gc->dc->clip.use)
{
int nx, ny, nw, nh;
-
+
nx = x; ny = y; nw = tex->w; nh = tex->h;
RECTS_CLIP_TO_RECT(nx, ny, nw, nh,
gc->dc->clip.x, gc->dc->clip.y,
ssy = (double)sy + ((double)(sh * (ny - y)) / (double)(tex->h));
ssw = ((double)sw * (double)(nw)) / (double)(tex->w);
ssh = ((double)sh * (double)(nh)) / (double)(tex->h);
- evas_gl_common_context_font_push(gc, tex,
+ evas_gl_common_context_font_push(gc, tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
r, g, b, a);
}
else
{
- evas_gl_common_context_font_push(gc, tex,
+ evas_gl_common_context_font_push(gc, tex,
0.0, 0.0, 0.0, 0.0,
// sx, sy, sw, sh,
x, y, tex->w, tex->h,
for (i = 0; i < rects->active; ++i)
{
int nx, ny, nw, nh;
-
+
rct = rects->rects + i;
nx = x; ny = y; nw = tex->w; nh = tex->h;
RECTS_CLIP_TO_RECT(nx, ny, nw, nh, rct->x, rct->y, rct->w, rct->h);
ssy = (double)sy + ((double)(sh * (ny - y)) / (double)(tex->h));
ssw = ((double)sw * (double)(nw)) / (double)(tex->w);
ssh = ((double)sh * (double)(nh)) / (double)(tex->h);
- evas_gl_common_context_font_push(gc, tex,
+ evas_gl_common_context_font_push(gc, tex,
ssx, ssy, ssw, ssh,
nx, ny, nw, nh,
r, g, b, a);
{
Eina_List *l;
Evas_GL_Image *im;
-
+
EINA_LIST_FOREACH(gc->shared->images, l, im)
{
if (im->im) evas_cache_image_unload_data(&im->im->cache_entry);
if (im2->references == 0)
{
im2->cached = 0;
- im2->gc->shared->images =
+ im2->gc->shared->images =
eina_list_remove_list(im2->gc->shared->images, l);
im2->gc->shared->images_size -= (im2->csize);
evas_gl_common_image_free(im2);
}
if ((gc->shared->images_size > size) && (l))
{
- printf("EEK %i > %i, no 0 ref imgs\n",
+ printf("EEK %i > %i, no 0 ref imgs\n",
gc->shared->images_size, size);
break;
}
if (!gc->shared->images)
{
- printf("EEK %i > %i, no imgs\n",
+ printf("EEK %i > %i, no imgs\n",
gc->shared->images_size, size);
break;
}
evas_gl_common_texture_free(im->tex);
im->tex = NULL;
}
-
+
im->cs.space = EVAS_COLORSPACE_ARGB8888;
im->tex = evas_gl_common_texture_native_new(im->gc, im->w, im->h, im->alpha, im);
im->tex_only = 1;
im->tex = NULL;
}
im->tex_only = 0;
-
+
im->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
im->im->cache_entry.flags.alpha = im->alpha;
im->cs.space = EVAS_COLORSPACE_ARGB8888;
im->tex = NULL;
}
im->tex_only = 0;
-
+
im->im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
im->im->cache_entry.flags.alpha = im->alpha;
im->cs.space = EVAS_COLORSPACE_ARGB8888;
#if 0 // filtering disabled
Filtered_Image *fi;
#endif
-
+
evas_gl_common_context_flush(im->gc);
im->references--;
if (im->references > 0) return;
-
+
if (im->native.func.free)
im->native.func.free(im->native.func.data, im);
-
+
if (im->cs.data)
{
if (!im->cs.no_free) free(im->cs.data);
evas_gl_common_image_update(Evas_Engine_GL_Context *gc, Evas_GL_Image *im)
{
if (!im->im) return;
-/*
+/*
if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
(im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
{
free(im->im->image.data);
im->im->image.data = malloc(im->im->cache_entry.w * im->im->cache_entry.h * sizeof(DATA32));
if (im->im->image.data)
- evas_common_convert_yuv_420p_601_rgba(im->cs.data,
+ evas_common_convert_yuv_420p_601_rgba(im->cs.data,
(void *)im->im->image.data,
im->im->cache_entry.w, im->im->cache_entry.h);
}
if ((im->tex) && (im->dirty))
{
evas_gl_common_texture_yuv_update(im->tex, im->cs.data,
- im->im->cache_entry.w,
+ im->im->cache_entry.w,
im->im->cache_entry.h);
im->dirty = 0;
}
if ((!im->tex) && (im->cs.data) && (*((unsigned char **)im->cs.data)))
{
im->tex = evas_gl_common_texture_yuv_new(gc, im->cs.data,
- im->im->cache_entry.w,
+ im->im->cache_entry.w,
im->im->cache_entry.h);
im->dirty = 0;
}
}
void
-evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
+evas_gl_common_image_map_draw(Evas_Engine_GL_Context *gc, Evas_GL_Image *im,
int npoints, RGBA_Map_Point *p, int smooth, int level __UNUSED__)
{
RGBA_Draw_Context *dc;
int r, g, b, a;
int c, cx, cy, cw, ch;
Eina_Bool yuv = 0;
-
+
dc = gc->dc;
if (dc->mul.use)
{
{
r = g = b = a = 255;
}
-
+
evas_gl_common_image_update(gc, im);
- c = gc->dc->clip.use;
- cx = gc->dc->clip.x; cy = gc->dc->clip.y;
+ c = gc->dc->clip.use;
+ cx = gc->dc->clip.x; cy = gc->dc->clip.y;
cw = gc->dc->clip.w; ch = gc->dc->clip.h;
im->tex->im = im;
if ((im->cs.space == EVAS_COLORSPACE_YCBCR422P601_PL) ||
(im->cs.space == EVAS_COLORSPACE_YCBCR422P709_PL))
yuv = 1;
evas_gl_common_context_image_map_push(gc, im->tex, npoints, p,
- c, cx, cy, cw, ch,
+ c, cx, cy, cw, ch,
r, g, b, a, smooth, im->tex_only,
yuv);
}
int c, cx, cy, cw, ch;
int i;
int yuv = 0;
-
+
if (sw < 1) sw = 1;
if (sh < 1) sh = 1;
dc = gc->dc;
{
r = g = b = a = 255;
}
-
+
evas_gl_common_image_update(gc, im);
if (!im->tex)
{
}
return;
}
-
+
/* save out clip info */
c = gc->dc->clip.use; cx = gc->dc->clip.x; cy = gc->dc->clip.y; cw = gc->dc->clip.w; ch = gc->dc->clip.h;
evas_common_draw_context_clip_clip(gc->dc, 0, 0, gc->w, gc->h);
RGBA_Draw_Context *dc;
int r, g, b, a;
int c, cx, cy, cw, ch;
-
+
dc = gc->dc;
if (dc->mul.use)
{
}
glFlush();
-
+
c = gc->dc->clip.use;
cx = gc->dc->clip.x; cy = gc->dc->clip.y;
cw = gc->dc->clip.w; ch = gc->dc->clip.h;
-
- evas_gl_common_context_line_push(gc, x1, y1, x2, y2,
- c, cx, cy, cw, ch,
+
+ evas_gl_common_context_line_push(gc, x1, y1, x2, y2,
+ c, cx, cy, cw, ch,
r, g, b, a);
}
polygon_point_sorter(const void *a, const void *b)
{
RGBA_Vertex *p, *q;
-
+
p = (RGBA_Vertex *)a;
q = (RGBA_Vertex *)b;
if (p->y <= q->y) return -1;
polygon_edge_sorter(const void *a, const void *b)
{
RGBA_Edge *p, *q;
-
+
p = (RGBA_Edge *)a;
q = (RGBA_Edge *)b;
if (p->x <= q->x) return -1;
RGBA_Vertex *point;
Evas_GL_Polygon_Point *pt;
Eina_Inlist *spans;
-
+
/* save out clip info */
c = gc->dc->clip.use; cx = gc->dc->clip.x; cy = gc->dc->clip.y; cw = gc->dc->clip.w; ch = gc->dc->clip.h;
cr = (gc->dc->col.col >> 16) & 0xff;
cg = (gc->dc->col.col >> 8 ) & 0xff;
cb = (gc->dc->col.col ) & 0xff;
-
+
n = eina_list_count(poly->points);
if (n < 3) return;
edges = malloc(sizeof(RGBA_Edge) * n);
free(point);
return;
}
-
+
k = 0;
EINA_LIST_FOREACH(poly->points, l, pt)
{
point[k].i = k;
k++;
}
-
+
y0 = MAX(cy, ceil(point[sorted_index[0]].y - 0.5));
y1 = MIN(cy + ch - 1, floor(point[sorted_index[n - 1]].y - 0.5));
-
+
k = 0;
num_active_edges = 0;
spans = NULL;
-
+
for (y = y0; y <= y1; y++)
{
for (; (k < n) && (point[sorted_index[k]].y <= ((double)y + 0.5)); k++)
{
i = sorted_index[k];
-
+
if (i > 0) j = i - 1;
else j = n - 1;
if (point[j].y <= ((double)y - 0.5))
POLY_EDGE_ADD(i, y)
}
}
-
+
qsort(edges, num_active_edges, sizeof(RGBA_Edge), polygon_edge_sorter);
-
+
for (j = 0; j < num_active_edges; j += 2)
{
int x0, x1;
-
+
x0 = ceil(edges[j].x - 0.5);
if (j < (num_active_edges - 1))
x1 = floor(edges[j + 1].x - 0.5);
if ((x1 >= cx) && (x0 < (cx + cw)) && (x0 <= x1))
{
RGBA_Span *span;
-
+
if (x0 < cx) x0 = cx;
if (x1 >= (cx + cw)) x1 = cx + cw - 1;
span = malloc(sizeof(RGBA_Span));
edges[j + 1].x += edges[j + 1].dx;
}
}
-
+
free(edges);
free(point);
free(sorted_index);
-
+
evas_common_draw_context_clip_clip(gc->dc, 0, 0, gc->w, gc->h);
-
+
if (spans)
{
RGBA_Span *span;
span = (RGBA_Span *)spans;
spans = eina_inlist_remove(spans, spans);
free(span);
- }
- }
-
+ }
+ }
+
/* restore clip info */
gc->dc->clip.use = c; gc->dc->clip.x = cx; gc->dc->clip.y = cy; gc->dc->clip.w = cw; gc->dc->clip.h = ch;
Cutout_Rects *rects;
Cutout_Rect *r;
int c, cx, cy, cw, ch, cr, cg, cb, ca, i;
-
+
if ((w <= 0) || (h <= 0)) return;
if (!(RECTS_INTERSECT(x, y, w, h, 0, 0, gc->w, gc->h))) return;
/* save out clip info */
c = gc->dc->clip.use; cx = gc->dc->clip.x; cy = gc->dc->clip.y; cw = gc->dc->clip.w; ch = gc->dc->clip.h;
-
+
ca = (gc->dc->col.col >> 24) & 0xff;
if ((gc->dc->render_op != EVAS_RENDER_COPY) && (ca <= 0)) return;
cr = (gc->dc->col.col >> 16) & 0xff;
gc->dc->clip.x, gc->dc->clip.y,
gc->dc->clip.w, gc->dc->clip.h);
}
-
+
if (!gc->dc->cutout.rects)
{
evas_gl_common_context_rectangle_push(gc, x, y, w, h, cr, cg, cb, ca);
rect_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
rect_frag_bin, sizeof(rect_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
rect_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
rect_vert_bin, sizeof(rect_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
/////////////////////////////////////////////
font_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
font_frag_bin, sizeof(font_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
font_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
font_vert_bin, sizeof(font_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
/////////////////////////////////////////////
yuv_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
yuv_frag_bin, sizeof(yuv_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
yuv_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
yuv_vert_bin, sizeof(yuv_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
/////////////////////////////////////////////
yuv_nomul_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
yuv_nomul_frag_bin, sizeof(yuv_nomul_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
yuv_nomul_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
yuv_nomul_vert_bin, sizeof(yuv_nomul_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
/////////////////////////////////////////////
tex_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
tex_frag_bin, sizeof(tex_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
tex_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
tex_vert_bin, sizeof(tex_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
/////////////////////////////////////////////
tex_nomul_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
tex_nomul_frag_bin, sizeof(tex_nomul_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
tex_nomul_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
tex_nomul_vert_bin, sizeof(tex_nomul_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
/////////////////////////////////////////////
img_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
img_frag_bin, sizeof(img_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
img_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
img_vert_bin, sizeof(img_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
/////////////////////////////////////////////
img_nomul_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
img_nomul_frag_bin, sizeof(img_nomul_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
img_nomul_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
img_nomul_vert_bin, sizeof(img_nomul_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
/////////////////////////////////////////////
img_bgra_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
img_bgra_frag_bin, sizeof(img_bgra_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
img_bgra_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
img_bgra_vert_bin, sizeof(img_bgra_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
img_bgra_nomul_frag_glsl,
#if defined (GLES_VARIETY_S3C6410)
img_bgra_nomul_frag_bin, sizeof(img_bgra_nomul_frag_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
#if defined (GLES_VARIETY_S3C6410)
img_bgra_nomul_vert_glsl,
#if defined (GLES_VARIETY_S3C6410)
img_bgra_nomul_vert_bin, sizeof(img_bgra_nomul_vert_bin)
-#else
+#else
NULL, 0
-#endif
+#endif
};
/////////////////////////////////////////////
free(logtxt);
}
}
-
+
/* Program info log */
glGetProgramiv(target, GL_INFO_LOG_LENGTH, &loglen);
if (loglen > 0)
home = getenv("HOME");
if ((!home) || (!home[0])) return 0;
-
+
snprintf(bin_shader_dir, num, "%s/%s", home, subdir);
return _evas_gl_shader_file_exists(bin_shader_dir);
}
p->prog = glCreateProgram();
#if 0
- // TODO: invalid rendering error occurs when attempting to use a
- // glProgramBinary. in order to render correctly we should create a dummy
+ // TODO: invalid rendering error occurs when attempting to use a
+ // glProgramBinary. in order to render correctly we should create a dummy
// vertex shader.
p->vert = glCreateShader(GL_VERTEX_SHADER);
glAttachShader(p->prog, p->vert);
const char *name)
{
GLint ok;
-
+
p->vert = glCreateShader(GL_VERTEX_SHADER);
p->frag = glCreateShader(GL_FRAGMENT_SHADER);
#if defined (GLES_VARIETY_S3C6410)
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glShaderBinary(1, &(p->frag), 0, frag->bin, frag->bin_size);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-#else
+#else
glShaderSource(p->vert, 1,
(const char **)&(vert->src), NULL);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
#if defined(GLES_VARIETY_S3C6410) || defined(GLES_VARIETY_SGX)
#else
if ((glsym_glGetProgramBinary) && (glsym_glProgramParameteri))
- glsym_glProgramParameteri(p->prog, GL_PROGRAM_BINARY_RETRIEVABLE_HINT,
+ glsym_glProgramParameteri(p->prog, GL_PROGRAM_BINARY_RETRIEVABLE_HINT,
GL_TRUE);
-#endif
+#endif
glAttachShader(p->prog, p->vert);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glAttachShader(p->prog, p->frag);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glBindAttribLocation(p->prog, SHAD_VERTEX, "vertex");
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindAttribLocation(p->prog, SHAD_COLOR, "color");
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindAttribLocation(p->prog, SHAD_TEXM, "tex_coordm");
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glLinkProgram(p->prog);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
ok = 0;
&(shader_yuv_nomul_vert_src),
&(shader_yuv_nomul_frag_src),
"yuv_nomul")) return 0;
-
+
/* Most of the filters use the image fragment shader */
if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_invert),
&(shader_img_vert_src),
&(shader_img_vert_src),
&(shader_filter_invert_bgra_nomul_frag_src),
"filter_invert_bgra_nomul")) return 0;
-
+
if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_sepia),
&(shader_img_vert_src),
&(shader_filter_sepia_frag_src),
&(shader_img_vert_src),
&(shader_filter_sepia_bgra_nomul_frag_src),
"filter_sepia_bgra_nomul")) return 0;
-
+
if (!_evas_gl_common_shader_program_source_init(&(shared->shader.filter_greyscale),
&(shader_img_vert_src),
&(shader_filter_greyscale_frag_src),
&(shader_filter_blur_bgra_nomul_frag_src),
"filter_blur_bgra_nomul")) return 0;
#endif
-
+
return 1;
}
if (!_evas_gl_shader_dir_check(bin_dir_path, sizeof(bin_dir_path)))
return 0;
-
+
if (!_evas_gl_shader_file_check(bin_dir_path, bin_file_path,
- sizeof(bin_dir_path)))
+ sizeof(bin_dir_path)))
return 0;
-
+
/* use eet */
if (!eet_init()) return 0;
et = eet_open(bin_file_path, EET_FILE_MODE_READ);
if (!_evas_gl_shader_dir_check(bin_dir_path, sizeof(bin_dir_path)))
res = _evas_gl_shader_file_mkpath(bin_dir_path);
if (!res) return 0; /* we can't make directory */
-
- _evas_gl_shader_file_check(bin_dir_path, bin_file_path,
+
+ _evas_gl_shader_file_check(bin_dir_path, bin_file_path,
sizeof(bin_dir_path));
-
+
/* use mkstemp for writing */
snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", bin_file_path);
tmpfd = mkstemp(tmp_file);
evas_gl_common_shader_program_init(Evas_GL_Shared *shared)
{
// gl support binary shader and get env of binary shader path
- if (shared->info.bin_program &&
+ if (shared->info.bin_program &&
_evas_gl_common_shader_binary_init(shared)) return 1;
/* compile all shader.*/
if (!_evas_gl_common_shader_source_init(shared)) return 0;
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
glReleaseShaderCompiler();
-#endif
+#endif
}
void
case GL_RGBA:
#ifdef GL_BGRA
case GL_BGRA:
-#endif
+#endif
return 0;
case GL_RGB:
return 1;
_pool_tex_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, GLenum format)
{
Evas_GL_Texture_Pool *pt;
-
+
pt = calloc(1, sizeof(Evas_GL_Texture_Pool));
if (!pt) return NULL;
h = _tex_round_slot(gc, h) * gc->shared->info.tune.atlas.slot_size;
pt->format = format;
pt->dataformat = GL_UNSIGNED_BYTE;
pt->references = 0;
-
+
if (format == alpha_fmt)
{
texinfo.a.num++;
}
_print_tex_count();
-
+
glGenTextures(1, &(pt->texture));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindTexture(GL_TEXTURE_2D, pt->texture);
}
static Evas_GL_Texture_Pool *
-_pool_tex_find(Evas_Engine_GL_Context *gc, int w, int h,
- int intformat, int format, int *u, int *v,
+_pool_tex_find(Evas_Engine_GL_Context *gc, int w, int h,
+ int intformat, int format, int *u, int *v,
Eina_List **l_after, int atlas_w)
{
Evas_GL_Texture_Pool *pt = NULL;
if (atlas_w > gc->shared->info.max_texture_size)
atlas_w = gc->shared->info.max_texture_size;
- if ((w > gc->shared->info.tune.atlas.max_w) ||
+ if ((w > gc->shared->info.tune.atlas.max_w) ||
(h > gc->shared->info.tune.atlas.max_h))
{
pt = _pool_tex_new(gc, w, h, intformat, format);
*l_after = NULL;
return pt;
}
-
+
th = _tex_round_slot(gc, h);
th2 = _tex_format_index(intformat);
EINA_LIST_FOREACH(gc->shared->tex.atlas[th][th2], l, pt)
{
if (_pool_tex_alloc(pt, w, h, u, v, l_after))
{
- gc->shared->tex.atlas[th][th2] =
+ gc->shared->tex.atlas[th][th2] =
eina_list_remove_list(gc->shared->tex.atlas[th][th2], l);
- gc->shared->tex.atlas[th][th2] =
+ gc->shared->tex.atlas[th][th2] =
eina_list_prepend(gc->shared->tex.atlas[th][th2], pt);
return pt;
}
}
pt = _pool_tex_new(gc, atlas_w, h, intformat, format);
- gc->shared->tex.atlas[th][th2] =
+ gc->shared->tex.atlas[th][th2] =
eina_list_prepend(gc->shared->tex.atlas[th][th2], pt);
pt->slot = th;
pt->fslot = th2;
tex = calloc(1, sizeof(Evas_GL_Texture));
if (!tex) return NULL;
-
+
tex->gc = gc;
tex->references = 1;
{
if (gc->shared->info.bgra)
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2,
- im->cache_entry.h + 1, bgra_ifmt, bgra_fmt,
+ im->cache_entry.h + 1, bgra_ifmt, bgra_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_size);
else
tex->pt = _pool_tex_find(gc, im->cache_entry.w + 2,
- im->cache_entry.h + 1, rgba_ifmt, rgba_fmt,
+ im->cache_entry.h + 1, rgba_ifmt, rgba_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_size);
tex->alpha = 1;
else
{
if (gc->shared->info.bgra)
- tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
+ tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
im->cache_entry.h + 1, bgr_ifmt, bgr_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_size);
else
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
- tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
+ tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
im->cache_entry.h + 1, rgba_ifmt, rgba_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_size);
#else
- tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
+ tex->pt = _pool_tex_find(gc, im->cache_entry.w + 3,
im->cache_entry.h + 1, rgb_ifmt, rgb_fmt,
&u, &v, &l_after,
gc->shared->info.tune.atlas.max_alloc_size);
tex->w = im->cache_entry.w;
tex->h = im->cache_entry.h;
if (l_after)
- tex->pt->allocations =
+ tex->pt->allocations =
eina_list_append_relative_list(tex->pt->allocations, tex, l_after);
else
- tex->pt->allocations =
+ tex->pt->allocations =
eina_list_prepend(tex->pt->allocations, tex);
tex->pt->references++;
evas_gl_common_texture_update(tex, im);
_pool_tex_render_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, int format)
{
Evas_GL_Texture_Pool *pt;
-
+
pt = calloc(1, sizeof(Evas_GL_Texture_Pool));
if (!pt) return NULL;
h = _tex_round_slot(gc, h) * gc->shared->info.tune.atlas.slot_size;
# ifndef GL_COLOR_ATTACHMENT0
# define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT
# endif
-#endif
+#endif
texinfo.r.num++;
texinfo.r.pix += pt->w * pt->h;
-
+
_print_tex_count();
-
+
glGenTextures(1, &(pt->texture));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindTexture(GL_TEXTURE_2D, pt->texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
_tex_2d(pt->intformat, w, h, pt->format, pt->dataformat);
-
+
glsym_glGenFramebuffers(1, &(pt->fb));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glsym_glBindFramebuffer(GL_FRAMEBUFFER, pt->fb);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glsym_glBindFramebuffer(GL_FRAMEBUFFER, 0);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
return pt;
_pool_tex_native_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, int format, Evas_GL_Image *im)
{
Evas_GL_Texture_Pool *pt;
-
+
pt = calloc(1, sizeof(Evas_GL_Texture_Pool));
if (!pt) return NULL;
pt->gc = gc;
-#ifdef GL_TEXTURE_RECTANGLE_ARB
+#ifdef GL_TEXTURE_RECTANGLE_ARB
if (im->native.target == GL_TEXTURE_RECTANGLE_ARB)
{
printf("REEEEEEEEECT\n");
pt->h = h;
}
else
-#endif
+#endif
{
// FIXME: handle po2 only textures
pt->w = w;
pt->native = 1;
texinfo.n.num++;
texinfo.n.pix += pt->w * pt->h;
-
+
_print_tex_count();
-
+
glGenTextures(1, &(pt->texture));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindTexture(im->native.target, pt->texture);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-
+
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
#else
if (im->native.loose)
im->native.func.bind(im->native.func.data, im);
}
#endif
-
+
glTexParameteri(im->native.target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glTexParameteri(im->native.target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
_pool_tex_dynamic_new(Evas_Engine_GL_Context *gc, int w, int h, int intformat, int format)
{
Evas_GL_Texture_Pool *pt = NULL;
-
+
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
int fmt; // EGL_MAP_GL_TEXTURE_RGBA_SEC or EGL_MAP_GL_TEXTURE_RGB_SEC or bust
int pixtype; // EGL_MAP_GL_TEXTURE_UNSIGNED_BYTE_SEC or bust
EGL_NONE
};
void *egldisplay;
-
+
pt = calloc(1, sizeof(Evas_GL_Texture_Pool));
if (!pt) return NULL;
h = _tex_round_slot(gc, h) * gc->shared->info.tune.atlas.slot_size;
pt->references = 0;
texinfo.d.num++;
texinfo.d.pix += pt->w * pt->h;
-
+
_print_tex_count();
-
+
glGenTextures(1, &(pt->texture));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
glBindTexture(GL_TEXTURE_2D, pt->texture);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
egldisplay = pt->gc->egldisp;
-
+
attr[1] = pt->w;
attr[3] = pt->h;
// FIXME: seems a bit slower than i'd like - maybe too many flushes?
// FIXME: YCbCr no support as yet
pt->dyn.img = secsym_eglCreateImage(egldisplay,
- EGL_NO_CONTEXT,
+ EGL_NO_CONTEXT,
EGL_MAP_GL_TEXTURE_2D_SEC,
0, attr);
if (!pt->dyn.img)
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
return pt;
}
-
+
glBindTexture(GL_TEXTURE_2D, gc->pipe[0].shader.cur_tex);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
#else
h = 0;
intformat = 0;
format = 0;
-#endif
+#endif
return pt;
}
evas_gl_texture_pool_empty(Evas_GL_Texture_Pool *pt)
{
if (!pt->gc) return;
-
+
if (pt->format == alpha_fmt)
{
texinfo.a.num--;
texinfo.c.num--;
texinfo.c.pix -= pt->w * pt->h;
}
-
+
_print_tex_count();
-
+
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
if (pt->dyn.img)
{
pt->dyn.h = 0;
pt->dyn.stride = 0;
}
-#endif
-
+#endif
+
glDeleteTextures(1, &(pt->texture));
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
if (pt->fb)
pt->fb = 0;
}
while (pt->allocations)
- pt->allocations =
+ pt->allocations =
eina_list_remove_list(pt->allocations, pt->allocations);
pt->texture = 0;
pt->gc = NULL;
if (!((pt->render) || (pt->native)))
{
if (pt->whole)
- pt->gc->shared->tex.whole =
+ pt->gc->shared->tex.whole =
eina_list_remove(pt->gc->shared->tex.whole, pt);
else
pt->gc->shared->tex.atlas [pt->slot][pt->fslot] =
tex = calloc(1, sizeof(Evas_GL_Texture));
if (!tex) return NULL;
-
+
tex->gc = gc;
tex->references = 1;
tex->alpha = alpha;
tex = calloc(1, sizeof(Evas_GL_Texture));
if (!tex) return NULL;
-
+
tex->gc = gc;
tex->references = 1;
tex->alpha = alpha;
tex->y = 0;
tex->w = w;
tex->h = h;
- tex->pt->references++;
+ tex->pt->references++;
return tex;
}
tex = calloc(1, sizeof(Evas_GL_Texture));
if (!tex) return NULL;
-
+
tex->gc = gc;
tex->references = 1;
tex->alpha = im->alpha;
}
if (!tex->pt) return;
if (!im->image.data) return;
-
+
fmt = tex->pt->format;
glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-#ifdef GL_UNPACK_ROW_LENGTH
+#ifdef GL_UNPACK_ROW_LENGTH
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-#endif
+#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
// printf("tex upload %ix%i\n", im->cache_entry.w, im->cache_entry.h);
// +-+
// +-+
- //
- _tex_sub_2d(tex->x, tex->y,
+ //
+ _tex_sub_2d(tex->x, tex->y,
im->cache_entry.w, im->cache_entry.h,
fmt, tex->pt->dataformat,
im->image.data);
// |xxx
// |xxx
- //
- _tex_sub_2d(tex->x - 1, tex->y,
+ //
+ _tex_sub_2d(tex->x - 1, tex->y,
1, im->cache_entry.h,
fmt, tex->pt->dataformat,
im->image.data);
// xxx|
// xxx|
- //
- _tex_sub_2d(tex->x + im->cache_entry.w, tex->y,
+ //
+ _tex_sub_2d(tex->x + im->cache_entry.w, tex->y,
1, im->cache_entry.h,
fmt, tex->pt->dataformat,
im->image.data + (im->cache_entry.w - 1));
tex = calloc(1, sizeof(Evas_GL_Texture));
if (!tex) return NULL;
-
+
tex->gc = gc;
tex->references = 1;
tex->pt = _pool_tex_find(gc, w + 3, fh, alpha_ifmt, alpha_fmt, &u, &v,
- &l_after,
+ &l_after,
gc->shared->info.tune.atlas.max_alloc_alpha_size);
if (!tex->pt)
{
tex->w = w;
tex->h = h;
if (l_after)
- tex->pt->allocations =
+ tex->pt->allocations =
eina_list_append_relative_list(tex->pt->allocations, tex, l_after);
else
tex->pt->allocations = eina_list_prepend(tex->pt->allocations, tex);
if (!tex->pt) return;
glBindTexture(GL_TEXTURE_2D, tex->pt->texture);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-#ifdef GL_UNPACK_ROW_LENGTH
+#ifdef GL_UNPACK_ROW_LENGTH
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
-#endif
+#endif
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
- _tex_sub_2d(tex->x, tex->y, w, h, tex->pt->format, tex->pt->dataformat,
+ _tex_sub_2d(tex->x, tex->y, w, h, tex->pt->format, tex->pt->dataformat,
pixels);
if (tex->pt->texture != tex->gc->pipe[0].shader.cur_tex)
{
tex = calloc(1, sizeof(Evas_GL_Texture));
if (!tex) return NULL;
-
+
tex->gc = gc;
tex->references = 1;
tex->pt = _pool_tex_new(gc, w + 1, h + 1, lum_ifmt, lum_fmt);
for (y = 0; y < (h / 2); y++)
_tex_sub_2d(0, y, w / 2, 1, tex->ptu->format, tex->ptu->dataformat, rows[h + y]);
}
-
+
glBindTexture(GL_TEXTURE_2D, tex->ptv->texture);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
if ((rows[h + (h / 2) + 1] - rows[h + (h / 2)]) == (int)(w / 2))
for (y = 0; y < (h / 2); y++)
_tex_sub_2d(0, y, w / 2, 1, tex->ptv->format, tex->ptv->dataformat, rows[h + (h / 2) + y]);
}
-#endif
+#endif
if (tex->pt->texture != tex->gc->pipe[0].shader.cur_tex)
{
glBindTexture(GL_TEXTURE_2D, tex->gc->pipe[0].shader.cur_tex);
struct {
void (*pre_swap) (void *data, Evas *e);
void (*post_swap) (void *data, Evas *e);
-
+
void *data; // data for callback calls
} callback;
/* non-blocking or blocking mode */
Evas_Engine_Render_Mode render_mode;
-
+
unsigned char vsync : 1; // does nothing right now
unsigned char indirect : 1; // use indirect rendering
};
#endif
-
-
Evas_Engine_Info_GL_X11 *info;
Evas *evas;
int end;
-
+
XrmDatabase xrdb; // xres - dpi
struct { // xres - dpi
int dpi; // xres - dpi
} xr; // xres - dpi
-
+
int w, h;
int vsync;
};
// Render target texture/buffers
GLuint rt_tex;
GLint rt_internal_fmt;
- GLenum rt_fmt;
+ GLenum rt_fmt;
GLuint rb_depth;
GLenum rb_depth_fmt;
GLuint rb_stencil;
int initialized;
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
EGLContext context;
-#else
+#else
GLXContext context;
#endif
- GLuint fbo;
-
+ GLuint fbo;
+
Render_Engine_GL_Surface *current_sfc;
};
_sym_init(void)
{
static int done = 0;
-
+
if (done) return;
-
+
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
#define FINDSYM(dst, sym, typ) \
if ((!dst) && (glsym_eglGetProcAddress)) dst = (typ)glsym_eglGetProcAddress(sym); \
if (!dst) dst = (typ)dlsym(RTLD_DEFAULT, sym)
-
+
FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddress", glsym_func_eng_fn);
FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressEXT", glsym_func_eng_fn);
FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressARB", glsym_func_eng_fn);
FINDSYM(glsym_eglGetProcAddress, "eglGetProcAddressKHR", glsym_func_eng_fn);
-
+
FINDSYM(glsym_eglBindTexImage, "eglBindTexImage", glsym_func_void);
FINDSYM(glsym_eglBindTexImage, "eglBindTexImageEXT", glsym_func_void);
FINDSYM(glsym_eglBindTexImage, "eglBindTexImageARB", glsym_func_void);
FINDSYM(glsym_eglBindTexImage, "eglBindTexImageKHR", glsym_func_void);
-
+
FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImage", glsym_func_void);
FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageEXT", glsym_func_void);
FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageARB", glsym_func_void);
FINDSYM(glsym_eglReleaseTexImage, "eglReleaseTexImageKHR", glsym_func_void);
-
+
FINDSYM(glsym_eglCreateImage, "eglCreateImage", glsym_func_void_ptr);
FINDSYM(glsym_eglCreateImage, "eglCreateImageEXT", glsym_func_void_ptr);
FINDSYM(glsym_eglCreateImage, "eglCreateImageARB", glsym_func_void_ptr);
FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddress", glsym_func_eng_fn);
FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressEXT", glsym_func_eng_fn);
FINDSYM(glsym_glXGetProcAddress, "glXGetProcAddressARB", glsym_func_eng_fn);
-
+
FINDSYM(glsym_glXBindTexImage, "glXBindTexImage", glsym_func_void);
FINDSYM(glsym_glXBindTexImage, "glXBindTexImageEXT", glsym_func_void);
FINDSYM(glsym_glXBindTexImage, "glXBindTexImageARB", glsym_func_void);
FINDSYM(glsym_glXReleaseTexImage, "glXReleaseTexImageARB", glsym_func_void);
FINDSYM(glsym_glXGetVideoSync, "glXGetVideoSyncSGI", glsym_func_int);
-
+
FINDSYM(glsym_glXWaitVideoSync, "glXWaitVideoSyncSGI", glsym_func_int);
FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmap", glsym_func_xid);
FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmapEXT", glsym_func_xid);
FINDSYM(glsym_glXCreatePixmap, "glXCreatePixmapARB", glsym_func_xid);
-
+
FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmap", glsym_func_void);
FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmapEXT", glsym_func_void);
FINDSYM(glsym_glXDestroyPixmap, "glXDestroyPixmapARB", glsym_func_void);
-
+
FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawable", glsym_func_void);
FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawableEXT", glsym_func_void);
FINDSYM(glsym_glXQueryDrawable, "glXQueryDrawableARB", glsym_func_void);
FINDSYM(glsym_glxSwapIntervalSGI, "glXSwapIntervalMESA", glsym_func_int);
FINDSYM(glsym_glxSwapIntervalSGI, "glXSwapIntervalSGI", glsym_func_int);
-
+
FINDSYM(glsym_glxSwapIntervalEXT, "glXSwapIntervalEXT", glsym_func_void);
#endif
}
eng_info_free(Evas *e __UNUSED__, void *info)
{
Evas_Engine_Info_GL_X11 *in;
-// dont free! why bother? its not worth it
+// dont free! why bother? its not worth it
// eina_log_domain_unregister(_evas_engine_GL_X11_log_dom);
in = (Evas_Engine_Info_GL_X11 *)info;
free(in);
if (!e->engine.data.output)
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
-#else
+#else
int eb, evb;
-
+
if (!glXQueryExtension(info->info.display, &eb, &evb)) return 0;
#endif
re = calloc(1, sizeof(Render_Engine));
return 0;
}
gl_wins++;
-
+
{
int status;
char *type = NULL;
XrmValue val;
-
+
re->xr.dpi = 75000; // dpy * 1000
status = xrdb_user_query("Xft.dpi", "Xft.Dpi", &type, &val);
if (!strcmp(type, "String"))
{
const char *str, *dp;
-
+
str = val.addr;
dp = strchr(str, '.');
if (!dp) dp = strchr(str, ',');
-
+
if (dp)
{
int subdpi, len, i;
char *buf;
-
+
buf = alloca(dp - str + 1);
strncpy(buf, str, dp - str);
buf[dp - str] = 0;
len = strlen(dp + 1);
subdpi = atoi(dp + 1);
-
+
if (len < 3)
{
for (i = len; i < 3; i++) subdpi *= 10;
if (!initted)
{
evas_common_cpu_init();
-
+
evas_common_blend_init();
evas_common_image_init();
evas_common_convert_init();
(re->info->info.rotation != re->win->rot))
{
int inc = 0;
-
+
if (re->win)
{
re->win->gl_context->references++;
free(re);
return 0;
}
-
+
if (!e->engine.data.output)
{
if (re->win)
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
}
-
+
_sym_init();
-
+
return 1;
}
Render_Engine *re;
re = (Render_Engine *)data;
-
+
if (re)
{
// NOTE: XrmGetDatabase() result is shared per connection, do not free it.
// dont need to for egl - eng_window_use() can check for other ctxt's
#else
eng_window_use(NULL);
-#endif
+#endif
eng_window_use(re->win);
if (!_re_wincheck(re)) return NULL;
evas_gl_common_context_flush(re->win->gl_context);
get_time(void)
{
struct timeval timev;
-
+
gettimeofday(&timev, NULL);
return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
}
static double pt = 0.0;
double ta, tb;
#endif
-
+
re = (Render_Engine *)data;
/* put back update surface.. in this case just unflag redraw */
if (!_re_wincheck(re)) return;
double t1 = get_time();
tb = t1 - t0;
printf("... %1.5f -> %1.5f | ", ta, tb);
-#endif
+#endif
// if (eglGetError() != EGL_SUCCESS)
// {
// printf("Error: eglWaitNative(EGL_CORE_NATIVE_ENGINE) fail.\n");
#ifdef FRAMECOUNT
double t1 = get_time();
printf("%1.5f\n", t1 - t0);
-#endif
+#endif
// if (eglGetError() != EGL_SUCCESS)
// {
// printf("Error: eglSwapBuffers() fail.\n");
// }
#else
-#ifdef VSYNC_TO_SCREEN
+#ifdef VSYNC_TO_SCREEN
if ((re->info->vsync)/* || (1)*/)
{
if (glsym_glxSwapIntervalEXT)
if ((glsym_glXGetVideoSync) && (glsym_glXWaitVideoSync))
{
unsigned int rc;
-
+
glsym_glXGetVideoSync(&rc);
glsym_glXWaitVideoSync(1, 0, &rc);
}
{
re->info->callback.pre_swap(re->info->callback.data, re->evas);
}
-/*
+/*
if ((1)
-// (re->win->draw.x1 == 0) &&
+// (re->win->draw.x1 == 0) &&
// (re->win->draw.y1 == 0) &&
// (re->win->draw.x2 == (re->win->w - 1)) &&
// (re->win->draw.y2 == (re->win->h - 1))
glXSwapBuffers(re->win->disp, re->win->win);
if (!safe_native) glXWaitGL();
}
-/*
+/*
else
{
-// FIXME: this doesn't work.. why oh why?
+// FIXME: this doesn't work.. why oh why?
int sx, sy, sw, sh;
-
+
// fimxe - reset when done
// glEnable(GL_SCISSOR_TEST);
glDrawBuffer(GL_FRONT);
-
+
sx = re->win->draw.x1;
sy = re->win->draw.y1;
sw = (re->win->draw.x2 - re->win->draw.x1) + 1;
glRasterPos2i(sx, re->win->h - sy);
glCopyPixels(sx, sy, sw, sh, GL_COLOR);
glRasterPos2i(0, 0);
-
+
// glDisable(GL_SCISSOR_TEST);
glDrawBuffer(GL_BACK);
glFlush();
re->info->callback.post_swap(re->info->callback.data, re->evas);
}
#endif
-
+
if (re->win->alpha)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
if (im->references > 1)
{
Evas_GL_Image *im_new;
-
+
im_new = evas_gl_common_image_new_from_copied_data
- (im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
+ (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->cs.no_free) free(im->cs.data);
}
if (im->im->cache_entry.h > 0)
- im->cs.data =
+ im->cs.data =
calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
else
im->cs.data = NULL;
Evas_Native_Surface ns;
Pixmap pixmap;
Visual *visual;
-
+
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
void *egl_surface;
#else
// FIXME: this is enabled so updates happen - but its SLOOOOOOOOOOOOOOOW
// (i am sure this is the reason) not to mention seemingly superfluous. but
// i need to enable it for it to work on fglrx at least. havent tried nvidia.
-//
+//
// why is this the case? does anyone know? has anyone tried it on other gfx
// drivers?
-//
+//
//#define GLX_TEX_PIXMAP_RECREATE 1
static void
{
Evas_GL_Image *im = image;
Native *n = im->native.data;
-
+
if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
#else
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
Render_Engine *re = data;
-
+
if (glsym_glXBindTexImage)
{
- glsym_glXBindTexImage(re->win->disp, n->glx_pixmap,
+ glsym_glXBindTexImage(re->win->disp, n->glx_pixmap,
GLX_FRONT_LEFT_EXT, NULL);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
}
else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
{
- glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
+ glBindTexture(GL_TEXTURE_2D, n->ns.data.opengl.texture_id);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
return;
{
Evas_GL_Image *im = image;
Native *n = im->native.data;
-
+
if (n->ns.type == EVAS_NATIVE_SURFACE_X11)
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
#else
# ifdef GLX_BIND_TO_TEXTURE_TARGETS_EXT
Render_Engine *re = data;
-
+
if (glsym_glXReleaseTexImage)
{
- glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
+ glsym_glXReleaseTexImage(re->win->disp, n->glx_pixmap,
GLX_FRONT_LEFT_EXT);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
}
else if (n->ns.type == EVAS_NATIVE_SURFACE_OPENGL)
{
- glBindTexture(GL_TEXTURE_2D, 0);
+ glBindTexture(GL_TEXTURE_2D, 0);
GLERR(__FUNCTION__, __FILE__, __LINE__, "");
}
return;
Native *n = NULL;
uint32_t pmid, texid;
unsigned int tex = 0;
- unsigned int fbo = 0;
-
- if (!im)
+ unsigned int fbo = 0;
+
+ if (!im)
{
- if ((!ns) && (ns->type == EVAS_NATIVE_SURFACE_OPENGL))
+ if ((!ns) && (ns->type == EVAS_NATIVE_SURFACE_OPENGL))
{
- im = evas_gl_common_image_new_from_data(re->win->gl_context,
- ns->data.opengl.w,
- ns->data.opengl.h,
- NULL, 1,
+ im = evas_gl_common_image_new_from_data(re->win->gl_context,
+ ns->data.opengl.w,
+ ns->data.opengl.h,
+ NULL, 1,
EVAS_COLORSPACE_ARGB8888);
- }
- else
+ }
+ else
return NULL;
}
-
+
if (ns)
{
if (ns->type == EVAS_NATIVE_SURFACE_X11)
if (im->native.data)
{
Evas_Native_Surface *ens = im->native.data;
- if ((ens->data.x11.visual == vis) &&
+ if ((ens->data.x11.visual == vis) &&
(ens->data.x11.pixmap == pm))
return im;
}
if (im->native.data)
{
Evas_Native_Surface *ens = im->native.data;
- if ((ens->data.opengl.texture_id == tex) &&
+ if ((ens->data.opengl.texture_id == tex) &&
(ens->data.opengl.framebuffer_id == fbo))
return im;
}
}
}
if ((!ns) && (!im->native.data)) return im;
-
+
eng_window_use(re->win);
-
+
if (im->native.data)
{
if (im->native.func.free)
}
if (!ns) return im;
-
+
if (ns->type == EVAS_NATIVE_SURFACE_X11)
{
pmid = pm;
}
}
- im2 = evas_gl_common_image_new_from_data(re->win->gl_context,
+ im2 = evas_gl_common_image_new_from_data(re->win->gl_context,
im->w, im->h, NULL, im->alpha,
EVAS_COLORSPACE_ARGB8888);
evas_gl_common_image_free(im);
if (ns->type == EVAS_NATIVE_SURFACE_X11)
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
- if (native)
+ if (native)
{
n = calloc(1, sizeof(Native));
if (n)
EGLConfig egl_config;
int config_attrs[20];
int num_config, i = 0;
-
+
eina_hash_add(re->win->gl_context->shared->native_pm_hash, &pmid, im);
-
+
config_attrs[i++] = EGL_RED_SIZE;
config_attrs[i++] = 8;
config_attrs[i++] = EGL_GREEN_SIZE;
config_attrs[i++] = EGL_SURFACE_TYPE;
config_attrs[i++] = EGL_PIXMAP_BIT;
config_attrs[i++] = EGL_NONE;
-
- if (!eglChooseConfig(re->win->egl_disp, config_attrs,
+
+ if (!eglChooseConfig(re->win->egl_disp, config_attrs,
&egl_config, 1, &num_config))
ERR("eglChooseConfig() failed for pixmap 0x%x, num_config = %i", (unsigned int)pm, num_config);
memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
int dummy;
unsigned int w, h, depth = 32, border;
Window wdummy;
-
+
// fixme: round trip :(
- XGetGeometry(re->win->disp, pm, &wdummy, &dummy, &dummy,
+ XGetGeometry(re->win->disp, pm, &wdummy, &dummy, &dummy,
&w, &h, &border, &depth);
n = calloc(1, sizeof(Native));
if (n)
int pixmap_att[20];
unsigned int target = 0;
unsigned int i = 0;
-
+
eina_hash_add(re->win->gl_context->shared->native_pm_hash, &pmid, im);
if ((re->win->depth_cfg[depth].tex_target &
- GLX_TEXTURE_2D_BIT_EXT)
+ GLX_TEXTURE_2D_BIT_EXT)
// && (1) // we assume npo2 for now
// size is pow2 || mnpo2 supported
)
GLX_TEXTURE_RECTANGLE_BIT_EXT))
target = GLX_TEXTURE_2D_EXT;
}
-
-
+
+
pixmap_att[i++] = GLX_TEXTURE_FORMAT_EXT;
pixmap_att[i++] = re->win->depth_cfg[depth].tex_format;
pixmap_att[i++] = GLX_MIPMAP_TEXTURE_EXT;
pixmap_att[i++] = re->win->depth_cfg[depth].mipmap;
-
+
if (target)
{
pixmap_att[i++] = GLX_TEXTURE_TARGET_EXT;
pixmap_att[i++] = target;
}
-
+
pixmap_att[i++] = 0;
-
+
memcpy(&(n->ns), ns, sizeof(Evas_Native_Surface));
n->pixmap = pm;
n->visual = vis;
n->fbc = re->win->depth_cfg[depth].fbc;
if (glsym_glXCreatePixmap)
- n->glx_pixmap = glsym_glXCreatePixmap(re->win->disp,
- n->fbc,
- n->pixmap,
+ n->glx_pixmap = glsym_glXCreatePixmap(re->win->disp,
+ n->fbc,
+ n->pixmap,
pixmap_att);
else
ERR("Try glXCreatePixmap on GLX with no support");
ERR("no target :(");
if (glsym_glXQueryDrawable)
glsym_glXQueryDrawable(re->win->disp,
- n->pixmap,
- GLX_TEXTURE_TARGET_EXT,
+ n->pixmap,
+ GLX_TEXTURE_TARGET_EXT,
&target);
}
if (target == GLX_TEXTURE_2D_EXT)
im->native.target = GL_TEXTURE_2D;
im->native.mipmap = re->win->depth_cfg[depth].mipmap;
}
-# ifdef GL_TEXTURE_RECTANGLE_ARB
+# ifdef GL_TEXTURE_RECTANGLE_ARB
else if (target == GLX_TEXTURE_RECTANGLE_EXT)
{
im->native.target = GL_TEXTURE_RECTANGLE_ARB;
im->native.mipmap = 0;
}
-# endif
+# endif
else
{
im->native.target = GL_TEXTURE_2D;
im->native.func.bind = _native_bind_cb;
im->native.func.unbind = _native_unbind_cb;
im->native.func.free = _native_free_cb;
-
+
evas_gl_common_image_native_enable(im);
}
}
-# endif
+# endif
#endif
}
else if (ns->type == EVAS_NATIVE_SURFACE_OPENGL)
im->native.func.bind = _native_bind_cb;
im->native.func.unbind = _native_unbind_cb;
im->native.func.free = _native_free_cb;
- im->native.target = GL_TEXTURE_2D;
+ im->native.target = GL_TEXTURE_2D;
im->native.mipmap = 0;
-
+
// FIXME: need to implement mapping sub texture regions
// x, y, w, h for possible texture atlasing
Render_Engine *re;
Evas_GL_Image *im = image;
Evas_GL_Image *im_old;
-
+
re = (Render_Engine *)data;
if (!im) return NULL;
if (im->native.data)
return image;
if (im_old)
{
- im = evas_gl_common_image_new(re->win->gl_context, w, h,
- eng_image_alpha_get(data, image),
- eng_image_colorspace_get(data, image));
+ im = evas_gl_common_image_new(re->win->gl_context, w, h,
+ eng_image_alpha_get(data, image),
+ eng_image_colorspace_get(data, image));
/*
evas_common_load_image_data_from_file(im_old->im);
if (im_old->im->image->data)
{
Evas_GL_Image *im_new;
- im_new = evas_gl_common_image_new_from_copied_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)
- {
- *image_data = NULL;
+ if (!im_new)
+ {
+ *image_data = NULL;
if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
- return im;
- }
- evas_gl_common_image_free(im);
- im = im_new;
+ return im;
+ }
+ evas_gl_common_image_free(im);
+ im = im_new;
}
- else
- evas_gl_common_image_dirty(im, 0, 0, 0, 0);
+ else
+ evas_gl_common_image_dirty(im, 0, 0, 0, 0);
}
*image_data = im->im->image.data;
break;
im2 = eng_image_new_from_data(data, w, h, image_data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
- if (!im2) return im;
- evas_gl_common_image_free(im);
- im = im2;
+ if (!im2) return im;
+ evas_gl_common_image_free(im);
+ im = im2;
evas_gl_common_image_dirty(im, 0, 0, 0, 0);
return im;
}
im2 = eng_image_new_from_data(data, w, h, image_data,
eng_image_alpha_get(data, image),
eng_image_colorspace_get(data, image));
- if (!im2) return im;
- evas_gl_common_image_free(im);
- im = im2;
+ if (!im2) return im;
+ evas_gl_common_image_free(im);
+ im = im2;
}
break;
case EVAS_COLORSPACE_YCBCR422P601_PL:
{
Evas_GL_Image *gim = image;
Render_Engine *re;
-
+
re = (Render_Engine *)data;
if (!image) return;
eng_window_use(re->win);
(p[3].col == 0xffffffff))
{
int dx, dy, dw, dh;
-
+
dx = p[0].x >> FP;
dy = p[0].y >> FP;
dw = (p[2].x >> FP) - dx;
eng_image_map_surface_new(void *data, int w, int h, int alpha)
{
Render_Engine *re;
-
+
re = (Render_Engine *)data;
return evas_gl_common_image_surface_new(re->win->gl_context, w, h, alpha);
}
{
Render_Engine *re;
int tmp_size;
-
+
re = (Render_Engine *)data;
-
+
tmp_size = evas_common_image_get_cache();
evas_common_image_set_cache(0);
evas_common_rgba_image_scalecache_flush();
eng_image_cache_set(void *data, int bytes)
{
Render_Engine *re;
-
+
re = (Render_Engine *)data;
evas_common_image_set_cache(bytes);
evas_common_rgba_image_scalecache_size_set(bytes);
{
// FIXME: put im into context so we can free it
static RGBA_Image *im = NULL;
-
+
if (!im)
im = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
im->cache_entry.w = re->win->w;
im->cache_entry.h = re->win->h;
evas_common_draw_context_font_ext_set(context,
- re->win->gl_context,
- evas_gl_font_texture_new,
- evas_gl_font_texture_free,
- evas_gl_font_texture_draw);
+ re->win->gl_context,
+ evas_gl_font_texture_new,
+ evas_gl_font_texture_free,
+ evas_gl_font_texture_draw);
evas_common_font_draw(im, context, (RGBA_Font *) font, x, y,
intl_props);
evas_common_draw_context_font_ext_set(context,
{
// Also initialize pixel format here as well...
switch(cfg->color_format)
- {
+ {
case EVAS_GL_RGB_8:
sfc->rt_fmt = GL_RGB;
sfc->rt_internal_fmt = GL_RGB;
sfc->rt_internal_fmt = GL_RGBA;
break;
case EVAS_GL_RGB_32:
- // Only supported on some hw
+ // Only supported on some hw
// Fill it in later...
case EVAS_GL_RGBA_32:
// Only supported on some hw
}
switch(cfg->depth_bits)
- {
+ {
case EVAS_GL_DEPTH_NONE:
break;
case EVAS_GL_DEPTH_BIT_8:
}
switch(cfg->stencil_bits)
- {
+ {
case EVAS_GL_STENCIL_NONE:
break;
case EVAS_GL_STENCIL_BIT_1:
return 0;
}
- // Do Packed Depth24_Stencil8 Later...
+ // Do Packed Depth24_Stencil8 Later...
return 1;
}
static int
-_create_rt_buffers(Render_Engine *data __UNUSED__,
+_create_rt_buffers(Render_Engine *data __UNUSED__,
Render_Engine_GL_Surface *sfc)
{
// Render Target texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sfc->w, sfc->h, 0,
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, sfc->w, sfc->h, 0,
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glBindTexture(GL_TEXTURE_2D, 0);
}
static int
-_attach_fbo_surface(Render_Engine *data __UNUSED__,
- Render_Engine_GL_Surface *sfc,
+_attach_fbo_surface(Render_Engine *data __UNUSED__,
+ Render_Engine_GL_Surface *sfc,
Render_Engine_GL_Context *ctx)
{
int fb_status;
glBindFramebuffer(GL_FRAMEBUFFER, ctx->fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
GL_TEXTURE_2D, sfc->rt_tex, 0);
-
+
// Depth RenderBuffer - Attach it to FBO
if (sfc->depth_bits != EVAS_GL_DEPTH_NONE)
{
// Check FBO for completeness
fb_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
- if (fb_status != GL_FRAMEBUFFER_COMPLETE)
+ if (fb_status != GL_FRAMEBUFFER_COMPLETE)
{
ERR("FBO not complete!");
return 0;
{
Render_Engine *re;
Render_Engine_GL_Surface *sfc;
- Evas_GL_Config *cfg;
+ Evas_GL_Config *cfg;
int ret;
sfc = calloc(1, sizeof(Render_Engine_GL_Surface));
}
// Create Render Target Texture/Buffers if not initialized
- if (!sfc->initialized)
+ if (!sfc->initialized)
{
// I'm using evas's original context to create the render target texture
// This is to prevent awkwardness in using native_surface_get() function
// If the rt texture creation is deferred till the context is created and
// make_current called, the user can't call native_surface_get() right
- // after the surface is created. hence this is done here using evas' context.
+ // after the surface is created. hence this is done here using evas' context.
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
ret = eglMakeCurrent(re->win->egl_disp, re->win->egl_surface[0], re->win->egl_surface[0], re->win->egl_context[0]);
#else
ret = glXMakeCurrent(re->info->info.display, re->win->win, re->win->context);
#endif
- if (!ret)
+ if (!ret)
{
ERR("xxxMakeCurrent() failed!");
free(sfc);
}
// Create Render texture
- if (!_create_rt_buffers(re, sfc))
+ if (!_create_rt_buffers(re, sfc))
{
ERR("_create_rt_buffers() failed.");
free(sfc);
}
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
- ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
+ ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
#else
ret = glXMakeCurrent(re->info->info.display, None, NULL);
#endif
- if (!ret)
+ if (!ret)
{
ERR("xxxMakeCurrent() failed!");
free(sfc);
// I'm using evas's original context to delete the created fbo and texture
// This is because the fbo/texture was created in the user created context
// but the context can be destroyed already...
- // I don't think this is the best way but at least for now this is A WAY.
+ // I don't think this is the best way but at least for now this is A WAY.
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
ret = eglMakeCurrent(re->win->egl_disp, re->win->egl_surface[0], re->win->egl_surface[0], re->win->egl_context[0]);
#else
ret = glXMakeCurrent(re->info->info.display, re->win->win, re->win->context);
#endif
- if (!ret)
+ if (!ret)
{
ERR("xxxMakeCurrent() failed!");
return 0;
#else
ret = glXMakeCurrent(re->info->info.display, None, NULL);
#endif
- if (!ret)
+ if (!ret)
{
ERR("xxxMakeCurrent() failed!");
return 0;
Render_Engine_GL_Context *share_ctx;
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
int context_attrs[3];
-#endif
+#endif
ctx = calloc(1, sizeof(Render_Engine_GL_Context));
share_ctx->context, // Share Context
context_attrs);
}
- else
+ else
{
ctx->context = eglCreateContext(re->win->egl_disp,
re->win->egl_config,
context_attrs);
}
- if (!ctx->context)
+ if (!ctx->context)
{
ERR("eglCreateContext() fail. code=%#x", eglGetError());
return NULL;
share_ctx->context, // Share Context
1);
}
- else
+ else
{
ctx->context = glXCreateContext(re->info->info.display,
re->win->visualinfo,
1);
}
- if (!ctx->context)
+ if (!ctx->context)
{
ERR("glXCreateContext() fail.");
return NULL;
// 1. Do a make current with the given context
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
- ret = eglMakeCurrent(re->win->egl_disp, re->win->egl_surface[0],
+ ret = eglMakeCurrent(re->win->egl_disp, re->win->egl_surface[0],
re->win->egl_surface[0], ctx->context);
#else
- ret = glXMakeCurrent(re->info->info.display, re->win->win,
+ ret = glXMakeCurrent(re->info->info.display, re->win->win,
ctx->context);
#endif
- if (!ret)
+ if (!ret)
{
ERR("xxxMakeCurrent() failed!");
return 0;
ctx->context = EGL_NO_CONTEXT;
- ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
+ ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
#else
glXDestroyContext(re->info->info.display, ctx->context);
ret = glXMakeCurrent(re->info->info.display, None, NULL);
#endif
- if (!ret)
+ if (!ret)
{
ERR("xxxMakeCurrent() failed!");
return 0;
evas_gl_common_context_use(re->win->gl_context);
evas_gl_common_context_flush(re->win->gl_context);
}
-#endif
+#endif
eng_window_use(NULL);
evas_gl_common_context_use(NULL);
}
if ((!sfc) || (!ctx))
{
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
- ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
+ ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
EGL_NO_SURFACE, EGL_NO_CONTEXT);
#else
ret = glXMakeCurrent(re->info->info.display, None, NULL);
#endif
- if (!ret)
+ if (!ret)
{
ERR("xxxMakeCurrent() failed!");
return 0;
ret = 1;
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
if ((eglGetCurrentContext() != ctx->context))
- ret = eglMakeCurrent(re->win->egl_disp, re->win->egl_surface[0],
+ ret = eglMakeCurrent(re->win->egl_disp, re->win->egl_surface[0],
re->win->egl_surface[0], ctx->context);
#else
if (glXGetCurrentContext() != ctx->context)
ret = glXMakeCurrent(re->info->info.display, re->win->win, ctx->context);
#endif
- if (!ret)
+ if (!ret)
{
ERR("xxxMakeCurrent() failed!");
return 0;
}
// Create FBO if not already created
- if (!ctx->initialized)
+ if (!ctx->initialized)
{
glGenFramebuffers(1, &ctx->fbo);
ctx->initialized = 1;
// Attach FBO if it hasn't been attached or if surface changed
if ((!sfc->fbo_attached) || (ctx != sfc->current_ctx))
{
- if (!_attach_fbo_surface(re, sfc, ctx))
+ if (!_attach_fbo_surface(re, sfc, ctx))
{
ERR("_attach_fbo_surface() failed.");
return 0;
sfc->fbo_attached = 1;
}
- // Set the current surface/context
+ // Set the current surface/context
ctx->current_sfc = sfc;
sfc->current_ctx = ctx;
#endif
}
-static int
+static int
eng_gl_native_surface_get(void *data, void *surface, void *native_surface)
{
Render_Engine *re;
re = (Render_Engine *)data;
sfc = (Render_Engine_GL_Surface*)surface;
ns = (Evas_Native_Surface*)native_surface;
-
+
ns->type = EVAS_NATIVE_SURFACE_OPENGL;
ns->version = EVAS_NATIVE_SURFACE_VERSION;
ns->data.opengl.texture_id = sfc->rt_tex;
ns->data.opengl.y = 0;
ns->data.opengl.w = sfc->w;
ns->data.opengl.h = sfc->h;
-
+
return 1;
}
#endif
}
-#endif
+#endif
static void *
eng_gl_api_get(void *data)
// Override functions wrapped by Evas_GL
#define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, evgl_)
- ORD(glBindFramebuffer);
- ORD(glBindRenderbuffer);
-
+ ORD(glBindFramebuffer);
+ ORD(glBindRenderbuffer);
+
// GLES2.0 API compat on top of desktop gl
ORD(glClearDepthf);
ORD(glDepthRangef);
ORD(glShaderBinary);
#undef ORD
-#endif
+#endif
return &gl_funcs;
}
eng_image_load_error_get(void *data __UNUSED__, void *image)
{
Evas_GL_Image *im;
-
+
if (!image) return EVAS_LOAD_ERROR_NONE;
im = image;
return im->im->cache_entry.load_error;
ORD(image_filtered_save);
ORD(image_filtered_free);
#endif
-
+
ORD(font_draw);
-
+
ORD(image_scale_hint_set);
ORD(image_scale_hint_get);
ORD(image_stride_get);
-
+
ORD(image_map_draw);
ORD(image_map_surface_new);
ORD(image_map_surface_free);
-
+
ORD(image_content_hint_set);
ORD(image_content_hint_get);
ORD(gl_native_surface_get);
ORD(gl_api_get);
-
+
ORD(image_load_error_get);
-
+
/* now advertise out own api */
em->functions = (void *)(&func);
return 1;
EGLSurface egl_surface[1];
EGLConfig egl_config;
EGLDisplay egl_disp;
-#else
+#else
GLXContext context;
GLXWindow glxwin;
struct {
int mipmap;
unsigned char yinvert : 1;
} depth_cfg[33]; // config for all 32 possible depths!
-
+
struct {
unsigned int loose_binding : 1;
} detected;
int config_attrs[40];
int major_version, minor_version;
int num_config, n = 0;
-#endif
+#endif
XVisualInfo *vi_use;
const GLubyte *vendor, *renderer, *version;
-
+
if (!_evas_gl_x11_vi) return NULL;
-
+
gw = calloc(1, sizeof(Evas_GL_X11_Window));
if (!gw) return NULL;
-
+
win_count++;
gw->disp = disp;
gw->win = win;
{
vi_use = _evas_gl_x11_rgba_vi;
}
-#endif
-#endif
+#endif
+#endif
}
gw->visualinfo = vi_use;
-
+
// EGL / GLES
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
context_attrs[0] = EGL_CONTEXT_CLIENT_VERSION;
config_attrs[n++] = 1;
config_attrs[n++] = EGL_BLUE_SIZE;
config_attrs[n++] = 1;
-// FIXME: end n900 breakage
+// FIXME: end n900 breakage
#endif
if (gw->alpha)
{
config_attrs[n++] = 0;
config_attrs[n++] = EGL_NONE;
# endif
-
+
gw->egl_disp = eglGetDisplay((EGLNativeDisplayType)(gw->disp));
if (!gw->egl_disp)
{
eng_window_free(gw);
return NULL;
}
-
+
num_config = 0;
if (!eglChooseConfig(gw->egl_disp, config_attrs, &gw->egl_config,
1, &num_config) || (num_config != 1))
return NULL;
}
if (context == EGL_NO_CONTEXT)
- context = eglCreateContext(gw->egl_disp, gw->egl_config, NULL,
+ context = eglCreateContext(gw->egl_disp, gw->egl_config, NULL,
context_attrs);
gw->egl_context[0] = context;
if (gw->egl_context[0] == EGL_NO_CONTEXT)
eng_window_free(gw);
return NULL;
}
- if (eglMakeCurrent(gw->egl_disp,
- gw->egl_surface[0],
+ if (eglMakeCurrent(gw->egl_disp,
+ gw->egl_surface[0],
gw->egl_surface[0],
gw->egl_context[0]) == EGL_FALSE)
{
fprintf(stderr, "renderer: %s\n", renderer);
fprintf(stderr, "version: %s\n", version);
}
-// GLX
+// GLX
#else
if (!context)
{
-#ifdef NEWGL
+#ifdef NEWGL
if (indirect)
- context = glXCreateNewContext(gw->disp, fbconf,
- GLX_RGBA_TYPE, NULL,
+ context = glXCreateNewContext(gw->disp, fbconf,
+ GLX_RGBA_TYPE, NULL,
GL_TRUE);
else
- context = glXCreateNewContext(gw->disp, fbconf,
- GLX_RGBA_TYPE, NULL,
+ context = glXCreateNewContext(gw->disp, fbconf,
+ GLX_RGBA_TYPE, NULL,
GL_FALSE);
#else
if (indirect)
if ((gw->alpha) && (!rgba_context))
{
if (indirect)
- rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
- GLX_RGBA_TYPE, context,
+ rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
+ GLX_RGBA_TYPE, context,
GL_TRUE);
else
- rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
- GLX_RGBA_TYPE, context,
+ rgba_context = glXCreateNewContext(gw->disp, rgba_fbconf,
+ GLX_RGBA_TYPE, context,
GL_FALSE);
}
if (gw->alpha)
eng_window_free(gw);
return NULL;
}
-
+
if (gw->alpha) gw->context = rgba_context;
else gw->context = context;
-#else
+#else
gw->context = context;
#endif
if (gw->glxwin)
{
- if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
+ if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
gw->context))
{
printf("Error: glXMakeContextCurrent(%p, %p, %p, %p)\n", (void *)gw->disp, (void *)gw->win, (void *)gw->win, (void *)gw->context);
return NULL;
}
}
-
+
// FIXME: move this up to context creation
vendor = glGetString(GL_VENDOR);
// version: 2.0 Mesa 7.8.2
// or
// vendor: Tungsten Graphics, Inc
- // renderer: Mesa DRI Mobile IntelĀ® GM45 Express Chipset GEM 20100330 DEVELOPMENT
+ // renderer: Mesa DRI Mobile IntelĀ® GM45 Express Chipset GEM 20100330 DEVELOPMENT
// version: 2.1 Mesa 7.9-devel
// or (bad - software renderer)
// vendor: Mesa Project
// vendor: VMware, Inc.
// renderer: Gallium 0.4 on softpipe
// version: 2.1 Mesa 7.9-devel
-
+
if (strstr((const char *)vendor, "Mesa Project"))
{
if (strstr((const char *)renderer, "Software Rasterizer"))
{
int v1 = 0, v2 = 0, v3 = 0;
- if (sscanf((const char *)version,
+ if (sscanf((const char *)version,
"%*s %*s %i.%i.%i",
&v1, &v2, &v3) != 3)
{
v1 = v2 = v3 = 0;
- if (sscanf((const char *)version,
+ if (sscanf((const char *)version,
"%*s %*s %i.%i",
&v1, &v2) != 2)
v1 = 0;
{
// noothing yet. add more cases and options over time
}
-
+
fbc = glXGetFBConfigs(gw->disp, screen, &num);
if (!fbc)
{
int vd;
int alph, val, dbuf, stencil, tdepth;
int rgba;
-
+
vi = glXGetVisualFromFBConfig(gw->disp, fbc[j]);
if (!vi) continue;
vd = vi->depth;
XFree(vi);
-
+
if (vd != i) continue;
-
+
glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_ALPHA_SIZE, &alph);
glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BUFFER_SIZE, &val);
-
+
if ((val != i) && ((val - alph) != i)) continue;
-
+
val = 0;
rgba = 0;
-
+
if (i == 32)
{
glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_RGBA_EXT, &val);
if (!val) continue;
gw->depth_cfg[i].tex_format = GLX_TEXTURE_FORMAT_RGB_EXT;
}
-
+
dbuf = 0x7fff;
glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DOUBLEBUFFER, &val);
if (val > dbuf) continue;
dbuf = val;
-
+
stencil = 0x7fff;
glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_STENCIL_SIZE, &val);
if (val > stencil) continue;
stencil = val;
-
+
tdepth = 0x7fff;
glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_DEPTH_SIZE, &val);
if (val > tdepth) continue;
tdepth = val;
-
+
glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_MIPMAP_TEXTURE_EXT, &val);
if (val < 0) continue;
gw->depth_cfg[i].mipmap = val;
-
+
glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_Y_INVERTED_EXT, &val);
gw->depth_cfg[i].yinvert = val;
-
+
glXGetFBConfigAttrib(gw->disp, fbc[j], GLX_BIND_TO_TEXTURE_TARGETS_EXT, &val);
gw->depth_cfg[i].tex_target = val;
-
+
gw->depth_cfg[i].fbc = fbc[j];
}
}
}
}
#endif
-
+
gw->gl_context = evas_gl_common_context_new();
if (!gw->gl_context)
{
}
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
gw->gl_context->egldisp = gw->egl_disp;
-#endif
+#endif
eng_window_use(gw);
evas_gl_common_context_resize(gw->gl_context, w, h, rot);
gw->surf = 1;
eng_window_use(Evas_GL_X11_Window *gw)
{
Eina_Bool force_use = EINA_FALSE;
-
+
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
if (_evas_gl_x11_window)
{
- if ((eglGetCurrentContext() !=
+ if ((eglGetCurrentContext() !=
_evas_gl_x11_window->egl_context[0]) ||
- (eglGetCurrentSurface(EGL_READ) !=
+ (eglGetCurrentSurface(EGL_READ) !=
_evas_gl_x11_window->egl_surface[0]) ||
- (eglGetCurrentSurface(EGL_DRAW) !=
+ (eglGetCurrentSurface(EGL_DRAW) !=
_evas_gl_x11_window->egl_surface[0]))
force_use = EINA_TRUE;
}
if (glXGetCurrentContext() != _evas_gl_x11_window->context)
force_use = EINA_TRUE;
}
-#endif
+#endif
if ((_evas_gl_x11_window != gw) || (force_use))
{
if (_evas_gl_x11_window)
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
if (gw->egl_surface[0] != EGL_NO_SURFACE)
{
- if (eglMakeCurrent(gw->egl_disp,
- gw->egl_surface[0],
+ if (eglMakeCurrent(gw->egl_disp,
+ gw->egl_surface[0],
gw->egl_surface[0],
gw->egl_context[0]) == EGL_FALSE)
{
ERR("eglMakeCurrent() failed!");
}
}
-// GLX
+// GLX
#else
if (gw->glxwin)
{
- if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
+ if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
gw->context))
{
ERR("glXMakeContextCurrent(%p, %p, %p, %p)", (void *)gw->disp, (void *)gw->win, (void *)gw->win, (void *)gw->context);
(unsigned int)gw->win, eglGetError());
return;
}
- if (eglMakeCurrent(gw->egl_disp,
- gw->egl_surface[0],
+ if (eglMakeCurrent(gw->egl_disp,
+ gw->egl_surface[0],
gw->egl_surface[0],
gw->egl_context[0]) == EGL_FALSE)
{
gw->glxwin = glXCreateWindow(gw->disp, rgba_fbconf, gw->win, NULL);
else
gw->glxwin = glXCreateWindow(gw->disp, fbconf, gw->win, NULL);
- if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
+ if (!glXMakeContextCurrent(gw->disp, gw->glxwin, gw->glxwin,
gw->context))
{
ERR("glXMakeContextCurrent(%p, %p, %p, %p)", (void *)gw->disp, (void *)gw->win, (void *)gw->win, (void *)gw->context);
}
-#else
+#else
if (!glXMakeCurrent(gw->disp, gw->win, gw->context))
{
ERR("glXMakeCurrent(%p, 0x%x, %p) failed", (void *)gw->disp, (unsigned int)gw->win, (void *)gw->context);
}
-#endif
-#endif
+#endif
+#endif
gw->surf = 1;
}
if (!_evas_gl_x11_vi)
{
int alpha;
-
+
// EGL / GLES
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
for (alpha = 0; alpha < 2; alpha++)
XVisualInfo *xvi, vi_in;
int nvi, i;
XRenderPictFormat *fmt;
-
+
vi_in.screen = einfo->info.screen;
vi_in.depth = 32;
vi_in.class = TrueColor;
if (xvi)
{
for (i = 0; i < nvi; i++)
- {
- fmt = XRenderFindVisualFormat(einfo->info.display,
+ {
+ fmt = XRenderFindVisualFormat(einfo->info.display,
xvi[i].visual);
- if ((fmt->type == PictTypeDirect) &&
+ if ((fmt->type == PictTypeDirect) &&
(fmt->direct.alphaMask))
{
- _evas_gl_x11_rgba_vi =
+ _evas_gl_x11_rgba_vi =
calloc(1, sizeof(XVisualInfo));
if (_evas_gl_x11_rgba_vi)
- memcpy(_evas_gl_x11_rgba_vi,
+ memcpy(_evas_gl_x11_rgba_vi,
&(xvi[i]), sizeof(XVisualInfo));
break;
}
int config_attrs[40];
GLXFBConfig *configs = NULL, config = 0;
int i, num;
-
+
i = 0;
config_attrs[i++] = GLX_DRAWABLE_TYPE;
config_attrs[i++] = GLX_WINDOW_BIT;
config_attrs[i++] = GLX_TRANSPARENT_TYPE;
config_attrs[i++] = GLX_NONE;//GLX_NONE;//GLX_TRANSPARENT_INDEX//GLX_TRANSPARENT_RGB;
config_attrs[i++] = 0;
-
- configs = glXChooseFBConfig(einfo->info.display,
+
+ configs = glXChooseFBConfig(einfo->info.display,
einfo->info.screen,
config_attrs, &num);
if ((!configs) || (num < 1))
{
XVisualInfo *visinfo;
XRenderPictFormat *format = NULL;
-
- visinfo = glXGetVisualFromFBConfig(einfo->info.display,
+
+ visinfo = glXGetVisualFromFBConfig(einfo->info.display,
configs[i]);
if (!visinfo) continue;
if (!alpha)
// EGL / GLES
#if defined (GLES_VARIETY_S3C6410) || defined (GLES_VARIETY_SGX)
if (_evas_gl_x11_rgba_vi) return _evas_gl_x11_rgba_vi->visual;
-#else
+#else
# ifdef NEWGL
if (_evas_gl_x11_rgba_vi) return _evas_gl_x11_rgba_vi->visual;
# endif
-#endif
+#endif
}
return _evas_gl_x11_vi->visual;
}
if (einfo->info.destination_alpha)
{
if (!_evas_gl_x11_rgba_cmap)
- _evas_gl_x11_rgba_cmap =
+ _evas_gl_x11_rgba_cmap =
XCreateColormap(einfo->info.display,
RootWindow(einfo->info.display,
einfo->info.screen),
- _evas_gl_x11_rgba_vi->visual,
+ _evas_gl_x11_rgba_vi->visual,
0);
return _evas_gl_x11_rgba_cmap;
}
if (!_evas_gl_x11_cmap)
- _evas_gl_x11_cmap =
+ _evas_gl_x11_cmap =
XCreateColormap(einfo->info.display,
RootWindow(einfo->info.display,
einfo->info.screen),
- _evas_gl_x11_vi->visual,
+ _evas_gl_x11_vi->visual,
0);
return _evas_gl_x11_cmap;
}
-
+
int
eng_best_depth_get(Evas_Engine_Info_GL_X11 *einfo)
{