Initial version.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
parent
2dbbe25650
commit
b861aad8e2
|
@ -1,29 +1,24 @@
|
|||
noinst_LTLIBRARIES = libglamor.la
|
||||
inst_LTLIBRARIES = libglamor.la
|
||||
|
||||
# Override these since glamor doesn't need them and the needed files aren't
|
||||
# built (in hw/xfree86/os-support/solaris) until after glamor is built
|
||||
SOLARIS_ASM_CFLAGS=""
|
||||
|
||||
if XORG
|
||||
sdk_HEADERS = glamor.h
|
||||
endif
|
||||
|
||||
if GLAMOR_GLES2
|
||||
libglamor_la_LIBADD = $(GLESV2_LIBS)
|
||||
else
|
||||
libglamor_la_LIBADD = $(GL_LIBS)
|
||||
endif
|
||||
|
||||
if XORG
|
||||
sdk_HEADERS = glamor.h
|
||||
endif
|
||||
instdir = $(moduledir)
|
||||
|
||||
INCLUDES = \
|
||||
$(XORG_INCS)
|
||||
|
||||
|
||||
AM_CFLAGS = $(XORG_CFLAGS) $(DIX_CFLAGS) $(LIBDRM_CFLAGS)
|
||||
|
||||
libglamor_la_LDFLAGS = -avoid-version
|
||||
|
||||
libglamor_la_SOURCES = \
|
||||
glamor.c \
|
||||
glamor_copyarea.c \
|
||||
|
@ -45,3 +40,17 @@ libglamor_la_SOURCES = \
|
|||
glamor_window.c\
|
||||
glamor_gl_dispatch.c\
|
||||
glamor.h
|
||||
|
||||
sdk_HEADERS = glamor.h
|
||||
|
||||
if EGL
|
||||
LIBGLAMOR_EGL = libglamor_egl.la
|
||||
module_LTLIBRARIES = $(LIBGLAMOR_EGL)
|
||||
libglamor_egl_la_DEPENDENCIES = libglamor.la
|
||||
libglamor_egl_la_LDFLAGS = -avoid-version -module $(EGL_LIBS) -lglamor
|
||||
#libglamor_egl_la_LIBADD = $(top_builddir)/src/libglamor.la
|
||||
libglamor_egl_la_SOURCES = glamor_eglmodule.c $(top_srcdir)/src/glamor_egl.c
|
||||
libglamor_egl_la_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/src $(LIBDRM_CFLAGS) $(EGL_CFLAGS)
|
||||
endif
|
||||
|
||||
|
||||
|
|
189
glamor/glamor.c
189
glamor/glamor.c
|
@ -54,19 +54,29 @@ PixmapPtr
|
|||
glamor_get_drawable_pixmap(DrawablePtr drawable)
|
||||
{
|
||||
if (drawable->type == DRAWABLE_WINDOW)
|
||||
return drawable->pScreen->GetWindowPixmap((WindowPtr)drawable);
|
||||
return drawable->
|
||||
pScreen->GetWindowPixmap((WindowPtr) drawable);
|
||||
else
|
||||
return (PixmapPtr) drawable;
|
||||
}
|
||||
|
||||
void
|
||||
_X_EXPORT void
|
||||
glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
assert(pixmap_priv);
|
||||
if (pixmap_priv == NULL) {
|
||||
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
|
||||
dixSetPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key, pixmap_priv);
|
||||
pixmap_priv->container = pixmap;
|
||||
pixmap_priv->glamor_priv = glamor_priv;
|
||||
}
|
||||
|
||||
pixmap_priv->tex = tex;
|
||||
|
||||
/* Create a framebuffer object wrapping the texture so that we can render
|
||||
|
@ -76,28 +86,32 @@ glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex)
|
|||
if (tex != 0) {
|
||||
glamor_pixmap_ensure_fb(pixmap);
|
||||
pixmap_priv->gl_tex = 1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
pixmap_priv->fb = 0;
|
||||
pixmap_priv->gl_tex = 0;
|
||||
}
|
||||
|
||||
if (pixmap->devKind == 0)
|
||||
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
|
||||
(((w * pixmap->drawable.bitsPerPixel +
|
||||
7) / 8) + 3) & ~3,
|
||||
NULL);
|
||||
(((w *
|
||||
pixmap->drawable.
|
||||
bitsPerPixel + 7) / 8) +
|
||||
3) & ~3, NULL);
|
||||
}
|
||||
|
||||
/* Set screen pixmap. If tex equal to 0, means it is called from ephyr. */
|
||||
void
|
||||
glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h, unsigned int tex)
|
||||
glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h,
|
||||
unsigned int tex)
|
||||
{
|
||||
PixmapPtr pixmap = screen->GetScreenPixmap(screen);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
|
||||
glamor_set_pixmap_texture(pixmap, w, h, tex);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_priv->screen_fbo = pixmap_priv->fb;
|
||||
pixmap_priv->pending_op.type = GLAMOR_PENDING_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -116,7 +130,8 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
GLuint tex;
|
||||
int type = GLAMOR_PIXMAP_TEXTURE;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
if (w > 32767 || h > 32767)
|
||||
return NullPixmap;
|
||||
|
@ -129,24 +144,22 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
type = GLAMOR_PIXMAP_MEMORY;
|
||||
pixmap = fbCreatePixmap(screen, w, h, depth, usage);
|
||||
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0,
|
||||
(((w * pixmap->drawable.bitsPerPixel +
|
||||
7) / 8) + 3) & ~3,
|
||||
NULL);
|
||||
(((w *
|
||||
pixmap->
|
||||
drawable.bitsPerPixel +
|
||||
7) / 8) + 3) & ~3, NULL);
|
||||
#if 0
|
||||
if (usage != GLAMOR_CREATE_PIXMAP_CPU)
|
||||
glamor_fallback("choose cpu memory for pixmap %p ,"
|
||||
" %d x %d depth %d\n", pixmap, w, h, depth);
|
||||
" %d x %d depth %d\n", pixmap, w,
|
||||
h, depth);
|
||||
#endif
|
||||
} else
|
||||
pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
|
||||
|
||||
if (dixAllocatePrivates(&pixmap->devPrivates, PRIVATE_PIXMAP) != TRUE) {
|
||||
fbDestroyPixmap(pixmap);
|
||||
ErrorF("Fail to allocate privates for PIXMAP.\n");
|
||||
return NullPixmap;
|
||||
}
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
pixmap_priv = calloc(1, sizeof(*pixmap_priv));
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key,
|
||||
pixmap_priv);
|
||||
pixmap_priv->container = pixmap;
|
||||
pixmap_priv->glamor_priv = glamor_priv;
|
||||
|
||||
|
@ -170,43 +183,68 @@ glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
|||
/* Create the texture used to store the pixmap's data. */
|
||||
dispatch->glGenTextures(1, &tex);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
|
||||
format, GL_UNSIGNED_BYTE, NULL);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, format,
|
||||
GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glamor_set_pixmap_texture(pixmap, w, h, tex);
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_destroy_textured_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
if (pixmap->refcnt == 1) {
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv != NULL) {
|
||||
if (pixmap_priv->fb)
|
||||
dispatch->glDeleteFramebuffers(1,
|
||||
&pixmap_priv->fb);
|
||||
if (pixmap_priv->tex)
|
||||
dispatch->glDeleteTextures(1,
|
||||
&pixmap_priv->tex);
|
||||
if (pixmap_priv->pbo)
|
||||
dispatch->glDeleteBuffers(1,
|
||||
&pixmap_priv->pbo);
|
||||
free(pixmap_priv);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static Bool
|
||||
glamor_destroy_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
if (pixmap->refcnt == 1) {
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv->fb)
|
||||
dispatch->glDeleteFramebuffers(1, &pixmap_priv->fb);
|
||||
if (pixmap_priv->tex)
|
||||
dispatch->glDeleteTextures(1, &pixmap_priv->tex);
|
||||
if (pixmap_priv->pbo)
|
||||
dispatch->glDeleteBuffers(1, &pixmap_priv->pbo);
|
||||
dixFreePrivates(pixmap->devPrivates, PRIVATE_PIXMAP);
|
||||
}
|
||||
|
||||
glamor_destroy_textured_pixmap(pixmap);
|
||||
return fbDestroyPixmap(pixmap);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_block_handler(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
|
||||
dispatch->glFlush();
|
||||
}
|
||||
|
||||
static void
|
||||
glamor_block_handler(void *data, OSTimePtr timeout, void *last_select_mask)
|
||||
_glamor_block_handler(void *data, OSTimePtr timeout,
|
||||
void *last_select_mask)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch = data;
|
||||
dispatch->glFlush();
|
||||
}
|
||||
|
||||
static void
|
||||
glamor_wakeup_handler(void *data, int result, void *last_select_mask)
|
||||
_glamor_wakeup_handler(void *data, int result, void *last_select_mask)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -215,7 +253,8 @@ glamor_set_debug_level(int *debug_level)
|
|||
{
|
||||
char *debug_level_string;
|
||||
debug_level_string = getenv("GLAMOR_DEBUG");
|
||||
if (debug_level_string && sscanf(debug_level_string, "%d", debug_level) == 1)
|
||||
if (debug_level_string
|
||||
&& sscanf(debug_level_string, "%d", debug_level) == 1)
|
||||
return;
|
||||
*debug_level = 0;
|
||||
}
|
||||
|
@ -245,18 +284,19 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
} else
|
||||
glamor_priv->yInverted = 0;
|
||||
|
||||
if (!dixRegisterPrivateKey(glamor_screen_private_key,PRIVATE_SCREEN,
|
||||
0)) {
|
||||
if (!dixRegisterPrivateKey
|
||||
(glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate screen private\n",
|
||||
screen->myNum);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, glamor_priv);
|
||||
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key,
|
||||
glamor_priv);
|
||||
|
||||
if (!dixRegisterPrivateKey(glamor_pixmap_private_key,PRIVATE_PIXMAP,
|
||||
sizeof(glamor_pixmap_private))) {
|
||||
if (!dixRegisterPrivateKey
|
||||
(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
screen->myNum);
|
||||
|
@ -277,7 +317,8 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
}
|
||||
#endif
|
||||
|
||||
glamor_gl_dispatch_init(screen, &glamor_priv->dispatch, gl_version);
|
||||
glamor_gl_dispatch_init(screen, &glamor_priv->dispatch,
|
||||
gl_version);
|
||||
|
||||
#ifdef GLAMOR_GLES2
|
||||
if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
|
||||
|
@ -286,17 +327,23 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
}
|
||||
#endif
|
||||
|
||||
glamor_priv->has_pack_invert = glamor_gl_has_extension("GL_MESA_pack_invert");
|
||||
glamor_priv->has_fbo_blit = glamor_gl_has_extension("GL_EXT_framebuffer_blit");
|
||||
glamor_priv->dispatch.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size);
|
||||
glamor_priv->has_pack_invert =
|
||||
glamor_gl_has_extension("GL_MESA_pack_invert");
|
||||
glamor_priv->has_fbo_blit =
|
||||
glamor_gl_has_extension("GL_EXT_framebuffer_blit");
|
||||
glamor_priv->dispatch.glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE,
|
||||
&glamor_priv->max_fbo_size);
|
||||
|
||||
if (!RegisterBlockAndWakeupHandlers(glamor_block_handler,
|
||||
glamor_wakeup_handler,
|
||||
(void*)&glamor_priv->dispatch)) {
|
||||
if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
|
||||
_glamor_wakeup_handler,
|
||||
(void *)
|
||||
&glamor_priv->dispatch)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glamor_set_debug_level(&glamor_debug_level);
|
||||
|
||||
if (flags & GLAMOR_USE_SCREEN) {
|
||||
glamor_priv->saved_close_screen = screen->CloseScreen;
|
||||
screen->CloseScreen = glamor_close_screen;
|
||||
|
||||
|
@ -315,32 +362,43 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
glamor_priv->saved_get_image = screen->GetImage;
|
||||
screen->GetImage = miGetImage;
|
||||
|
||||
glamor_priv->saved_change_window_attributes = screen->ChangeWindowAttributes;
|
||||
screen->ChangeWindowAttributes = glamor_change_window_attributes;
|
||||
glamor_priv->saved_change_window_attributes =
|
||||
screen->ChangeWindowAttributes;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_change_window_attributes;
|
||||
|
||||
glamor_priv->saved_copy_window = screen->CopyWindow;
|
||||
screen->CopyWindow = glamor_copy_window;
|
||||
|
||||
glamor_priv->saved_bitmap_to_region = screen->BitmapToRegion;
|
||||
glamor_priv->saved_bitmap_to_region =
|
||||
screen->BitmapToRegion;
|
||||
screen->BitmapToRegion = glamor_bitmap_to_region;
|
||||
|
||||
}
|
||||
#ifdef RENDER
|
||||
if (flags & GLAMOR_USE_PICTURE_SCREEN) {
|
||||
glamor_priv->saved_composite = ps->Composite;
|
||||
ps->Composite = glamor_composite;
|
||||
|
||||
glamor_priv->saved_trapezoids = ps->Trapezoids;
|
||||
ps->Trapezoids = glamor_trapezoids;
|
||||
|
||||
glamor_priv->saved_glyphs = ps->Glyphs;
|
||||
ps->Glyphs = glamor_glyphs;
|
||||
|
||||
glamor_priv->saved_triangles = ps->Triangles;
|
||||
ps->Triangles = glamor_triangles;
|
||||
glamor_init_composite_shaders(screen);
|
||||
|
||||
glamor_priv->saved_create_picture = ps->CreatePicture;
|
||||
ps->CreatePicture = glamor_create_picture;
|
||||
|
||||
glamor_priv->saved_destroy_picture = ps->DestroyPicture;
|
||||
ps->DestroyPicture = glamor_destroy_picture;
|
||||
|
||||
glamor_priv->saved_unrealize_glyph = ps->UnrealizeGlyph;
|
||||
ps->UnrealizeGlyph = glamor_glyph_unrealize;
|
||||
}
|
||||
|
||||
glamor_init_composite_shaders(screen);
|
||||
#endif
|
||||
glamor_init_solid_shader(screen);
|
||||
glamor_init_tile_shader(screen);
|
||||
|
@ -358,14 +416,16 @@ glamor_init(ScreenPtr screen, unsigned int flags)
|
|||
|
||||
fail:
|
||||
free(glamor_priv);
|
||||
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key, NULL);
|
||||
dixSetPrivate(&screen->devPrivates, glamor_screen_private_key,
|
||||
NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_close_screen(int idx, ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
#ifdef RENDER
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
#endif
|
||||
|
@ -375,7 +435,8 @@ glamor_close_screen(int idx, ScreenPtr screen)
|
|||
screen->CreatePixmap = glamor_priv->saved_create_pixmap;
|
||||
screen->DestroyPixmap = glamor_priv->saved_destroy_pixmap;
|
||||
screen->GetSpans = glamor_priv->saved_get_spans;
|
||||
screen->ChangeWindowAttributes = glamor_priv->saved_change_window_attributes;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_priv->saved_change_window_attributes;
|
||||
screen->CopyWindow = glamor_priv->saved_copy_window;
|
||||
screen->BitmapToRegion = glamor_priv->saved_bitmap_to_region;
|
||||
#ifdef RENDER
|
||||
|
|
|
@ -43,21 +43,39 @@
|
|||
|
||||
|
||||
#define GLAMOR_INVERTED_Y_AXIS 1
|
||||
#define GLAMOR_HOSTX 2
|
||||
#define GLAMOR_VALID_FLAGS (GLAMOR_INVERTED_Y_AXIS | GLAMOR_HOSTX)
|
||||
#define GLAMOR_USE_SCREEN 2
|
||||
#define GLAMOR_USE_PICTURE_SCREEN 4
|
||||
|
||||
#define GLAMOR_VALID_FLAGS (GLAMOR_INVERTED_Y_AXIS \
|
||||
| GLAMOR_USE_SCREEN \
|
||||
| GLAMOR_USE_PICTURE_SCREEN)
|
||||
|
||||
#define GLAMOR_EGL_EXTERNAL_BUFFER 3
|
||||
|
||||
extern _X_EXPORT Bool glamor_init(ScreenPtr screen, unsigned int flags);
|
||||
extern _X_EXPORT void glamor_fini(ScreenPtr screen);
|
||||
extern _X_EXPORT void glamor_set_screen_pixmap_texture(ScreenPtr screen, int w, int h, unsigned int tex);
|
||||
extern _X_EXPORT void glamor_set_screen_pixmap_texture(ScreenPtr screen,
|
||||
int w, int h,
|
||||
unsigned int tex);
|
||||
extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
|
||||
void glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h, unsigned int tex);
|
||||
void glamor_set_pixmap_texture(PixmapPtr pixmap, int w, int h,
|
||||
unsigned int tex);
|
||||
|
||||
extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
|
||||
extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
|
||||
|
||||
#ifdef GLAMOR_FOR_XORG
|
||||
extern _X_EXPORT Bool glamor_egl_init(ScrnInfoPtr scrn, int fd);
|
||||
extern _X_EXPORT Bool glamor_create_egl_screen_image(ScreenPtr screen, int handle, int stride);
|
||||
extern _X_EXPORT Bool glamor_create_egl_pixmap_image(PixmapPtr pixmap, int handle, int stride);
|
||||
extern _X_EXPORT Bool glamor_close_egl_screen(ScreenPtr screen);
|
||||
extern _X_EXPORT void glamor_free_egl_screen(int scrnIndex, int flags);
|
||||
extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
|
||||
int handle,
|
||||
int stride);
|
||||
extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
|
||||
int handle,
|
||||
int stride);
|
||||
|
||||
extern _X_EXPORT Bool glamor_egl_close_screen(ScreenPtr screen);
|
||||
extern _X_EXPORT void glamor_egl_free_screen(int scrnIndex, int flags);
|
||||
|
||||
extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
|
||||
extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
|
||||
#endif
|
||||
|
|
|
@ -35,22 +35,20 @@
|
|||
static Bool
|
||||
glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
||||
DrawablePtr dst,
|
||||
GCPtr gc,
|
||||
BoxPtr box,
|
||||
int nbox,
|
||||
int dx,
|
||||
int dy)
|
||||
GCPtr gc, BoxPtr box, int nbox, int dx, int dy)
|
||||
{
|
||||
ScreenPtr screen = dst->pScreen;
|
||||
PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(dst);
|
||||
PixmapPtr src_pixmap = glamor_get_drawable_pixmap(src);
|
||||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
int dst_x_off, dst_y_off, src_x_off, src_y_off, i;
|
||||
|
||||
if (!glamor_priv->has_fbo_blit) {
|
||||
glamor_delayed_fallback(screen,"no EXT_framebuffer_blit\n");
|
||||
glamor_delayed_fallback(screen,
|
||||
"no EXT_framebuffer_blit\n");
|
||||
return FALSE;
|
||||
}
|
||||
src_pixmap_priv = glamor_get_pixmap_private(src_pixmap);
|
||||
|
@ -64,7 +62,8 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
return FALSE;
|
||||
}
|
||||
if (!glamor_pm_is_solid(dst, gc->planemask)) {
|
||||
glamor_delayed_fallback(screen, "non-solid planemask\n");
|
||||
glamor_delayed_fallback(screen,
|
||||
"non-solid planemask\n");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -79,36 +78,59 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
}
|
||||
glamor_validate_pixmap(dst_pixmap);
|
||||
|
||||
dispatch->glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT, src_pixmap_priv->fb);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
dispatch->glBindFramebuffer(GL_READ_FRAMEBUFFER_EXT,
|
||||
src_pixmap_priv->fb);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
src_y_off += dy;
|
||||
|
||||
for (i = 0; i < nbox; i++) {
|
||||
if (glamor_priv->yInverted) {
|
||||
dispatch->glBlitFramebuffer((box[i].x1 + dx + src_x_off),
|
||||
(box[i].y1 + src_y_off),
|
||||
(box[i].x2 + dx + src_x_off),
|
||||
(box[i].y2 + src_y_off),
|
||||
(box[i].x1 + dst_x_off),
|
||||
(box[i].y1 + dst_y_off),
|
||||
(box[i].x2 + dst_x_off),
|
||||
(box[i].y2 + dst_y_off),
|
||||
dispatch->glBlitFramebuffer((box[i].x1 + dx +
|
||||
src_x_off),
|
||||
(box[i].y1 +
|
||||
src_y_off),
|
||||
(box[i].x2 + dx +
|
||||
src_x_off),
|
||||
(box[i].y2 +
|
||||
src_y_off),
|
||||
(box[i].x1 +
|
||||
dst_x_off),
|
||||
(box[i].y1 +
|
||||
dst_y_off),
|
||||
(box[i].x2 +
|
||||
dst_x_off),
|
||||
(box[i].y2 +
|
||||
dst_y_off),
|
||||
GL_COLOR_BUFFER_BIT,
|
||||
GL_NEAREST);
|
||||
} else {
|
||||
int flip_dst_y1 = dst_pixmap->drawable.height - (box[i].y2 + dst_y_off);
|
||||
int flip_dst_y2 = dst_pixmap->drawable.height - (box[i].y1 + dst_y_off);
|
||||
int flip_src_y1 = src_pixmap->drawable.height - (box[i].y2 + src_y_off);
|
||||
int flip_src_y2 = src_pixmap->drawable.height - (box[i].y1 + src_y_off);
|
||||
int flip_dst_y1 =
|
||||
dst_pixmap->drawable.height - (box[i].y2 +
|
||||
dst_y_off);
|
||||
int flip_dst_y2 =
|
||||
dst_pixmap->drawable.height - (box[i].y1 +
|
||||
dst_y_off);
|
||||
int flip_src_y1 =
|
||||
src_pixmap->drawable.height - (box[i].y2 +
|
||||
src_y_off);
|
||||
int flip_src_y2 =
|
||||
src_pixmap->drawable.height - (box[i].y1 +
|
||||
src_y_off);
|
||||
|
||||
dispatch->glBlitFramebuffer(box[i].x1 + dx + src_x_off,
|
||||
dispatch->glBlitFramebuffer(box[i].x1 + dx +
|
||||
src_x_off,
|
||||
flip_src_y1,
|
||||
box[i].x2 + dx + src_x_off,
|
||||
box[i].x2 + dx +
|
||||
src_x_off,
|
||||
flip_src_y2,
|
||||
box[i].x1 + dst_x_off,
|
||||
box[i].x1 +
|
||||
dst_x_off,
|
||||
flip_dst_y1,
|
||||
box[i].x2 + dst_x_off,
|
||||
box[i].x2 +
|
||||
dst_x_off,
|
||||
flip_dst_y2,
|
||||
GL_COLOR_BUFFER_BIT,
|
||||
GL_NEAREST);
|
||||
|
@ -121,12 +143,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
|||
static Bool
|
||||
glamor_copy_n_to_n_textured(DrawablePtr src,
|
||||
DrawablePtr dst,
|
||||
GCPtr gc,
|
||||
BoxPtr box,
|
||||
int nbox,
|
||||
int dx,
|
||||
int dy
|
||||
)
|
||||
GCPtr gc, BoxPtr box, int nbox, int dx, int dy)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(dst->pScreen);
|
||||
|
@ -159,8 +176,7 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
if (src_status != GLAMOR_UPLOAD_DONE)
|
||||
goto fail;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
} else
|
||||
flush_needed = 1;
|
||||
|
||||
if (gc) {
|
||||
|
@ -168,7 +184,8 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
if (!glamor_set_planemask(dst_pixmap, gc->planemask))
|
||||
goto fail;
|
||||
if (gc->alu != GXcopy) {
|
||||
glamor_set_destination_pixmap_priv_nc(src_pixmap_priv);
|
||||
glamor_set_destination_pixmap_priv_nc
|
||||
(src_pixmap_priv);
|
||||
glamor_validate_pixmap(src_pixmap);
|
||||
}
|
||||
}
|
||||
|
@ -179,40 +196,52 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
pixmap_priv_get_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
|
||||
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
|
||||
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
if (GLAMOR_PIXMAP_PRIV_NO_PENDING(src_pixmap_priv)) {
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
dx += src_x_off;
|
||||
dy += src_y_off;
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale,
|
||||
&src_yscale);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->tex);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D,
|
||||
src_pixmap_priv->tex);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_no_revert[0], 1);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0], 0);
|
||||
dispatch->
|
||||
glUniform1i(glamor_priv->finish_access_no_revert[0],
|
||||
1);
|
||||
dispatch->
|
||||
glUniform1i(glamor_priv->finish_access_swap_rb[0], 0);
|
||||
|
||||
}
|
||||
else {
|
||||
GLAMOR_CHECK_PENDING_FILL(dispatch, glamor_priv, src_pixmap_priv);
|
||||
} else {
|
||||
GLAMOR_CHECK_PENDING_FILL(dispatch, glamor_priv,
|
||||
src_pixmap_priv);
|
||||
}
|
||||
|
||||
for (i = 0; i < nbox; i++) {
|
||||
|
@ -226,9 +255,12 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
|||
vertices);
|
||||
|
||||
if (GLAMOR_PIXMAP_PRIV_NO_PENDING(src_pixmap_priv))
|
||||
glamor_set_normalize_tcoords(src_xscale, src_yscale,
|
||||
box[i].x1 + dx, box[i].y1 + dy,
|
||||
box[i].x2 + dx, box[i].y2 + dy,
|
||||
glamor_set_normalize_tcoords(src_xscale,
|
||||
src_yscale,
|
||||
box[i].x1 + dx,
|
||||
box[i].y1 + dy,
|
||||
box[i].x2 + dx,
|
||||
box[i].y2 + dy,
|
||||
glamor_priv->yInverted,
|
||||
texcoords);
|
||||
|
||||
|
@ -263,9 +295,7 @@ glamor_copy_n_to_n(DrawablePtr src,
|
|||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown,
|
||||
Pixel bitplane,
|
||||
void *closure)
|
||||
Bool upsidedown, Pixel bitplane, void *closure)
|
||||
{
|
||||
glamor_access_t dst_access;
|
||||
PixmapPtr dst_pixmap, src_pixmap, temp_pixmap = NULL;
|
||||
|
@ -286,18 +316,20 @@ glamor_copy_n_to_n(DrawablePtr src,
|
|||
screen = dst_pixmap->drawable.pScreen;
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv)) {
|
||||
glamor_fallback("dest pixmap %p has no fbo. \n", dst_pixmap);
|
||||
glamor_fallback("dest pixmap %p has no fbo. \n",
|
||||
dst_pixmap);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off, &src_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off, &dst_y_off);
|
||||
glamor_get_drawable_deltas(src, src_pixmap, &src_x_off,
|
||||
&src_y_off);
|
||||
glamor_get_drawable_deltas(dst, dst_pixmap, &dst_x_off,
|
||||
&dst_y_off);
|
||||
|
||||
if (src_pixmap_priv->fb == dst_pixmap_priv->fb) {
|
||||
int x_shift = abs(src_x_off - dx - dst_x_off);
|
||||
int y_shift = abs(src_y_off - dy - dst_y_off);
|
||||
for ( i = 0; i < nbox; i++)
|
||||
{
|
||||
for (i = 0; i < nbox; i++) {
|
||||
if (x_shift < abs(box[i].x2 - box[i].x1)
|
||||
&& y_shift < abs(box[i].y2 - box[i].y1)) {
|
||||
overlaped = 1;
|
||||
|
@ -310,7 +342,8 @@ glamor_copy_n_to_n(DrawablePtr src,
|
|||
#ifndef GLAMOR_GLES2
|
||||
if ((overlaped
|
||||
|| !src_pixmap_priv->gl_tex || !dst_pixmap_priv->gl_tex)
|
||||
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) {
|
||||
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx,
|
||||
dy)) {
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
@ -320,37 +353,42 @@ glamor_copy_n_to_n(DrawablePtr src,
|
|||
/* Overlaped indicate the src and dst are the same pixmap. */
|
||||
if (overlaped || (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)
|
||||
&& ((bound.x2 - bound.x1) * (bound.y2 - bound.y1)
|
||||
* 4 > src_pixmap->drawable.width * src_pixmap->drawable.height))) {
|
||||
* 4 >
|
||||
src_pixmap->drawable.width *
|
||||
src_pixmap->drawable.height))) {
|
||||
|
||||
temp_pixmap = (*screen->CreatePixmap) (screen,
|
||||
bound.x2 - bound.x1,
|
||||
bound.y2 - bound.y1,
|
||||
src_pixmap->drawable.depth,
|
||||
overlaped ? 0 : GLAMOR_CREATE_PIXMAP_CPU);
|
||||
src_pixmap->
|
||||
drawable.depth,
|
||||
overlaped ? 0 :
|
||||
GLAMOR_CREATE_PIXMAP_CPU);
|
||||
if (!temp_pixmap)
|
||||
goto fail;
|
||||
glamor_transform_boxes(box, nbox, -bound.x1, -bound.y1);
|
||||
temp_src = &temp_pixmap->drawable;
|
||||
|
||||
if (overlaped)
|
||||
glamor_copy_n_to_n_textured(src, temp_src, gc, box, nbox,
|
||||
temp_dx + bound.x1, temp_dy + bound.y1);
|
||||
glamor_copy_n_to_n_textured(src, temp_src, gc, box,
|
||||
nbox,
|
||||
temp_dx + bound.x1,
|
||||
temp_dy + bound.y1);
|
||||
else
|
||||
fbCopyNtoN(src, temp_src, gc, box, nbox,
|
||||
temp_dx + bound.x1, temp_dy + bound.y1,
|
||||
reverse, upsidedown, bitplane,
|
||||
closure);
|
||||
reverse, upsidedown, bitplane, closure);
|
||||
glamor_transform_boxes(box, nbox, bound.x1, bound.y1);
|
||||
temp_dx = -bound.x1;
|
||||
temp_dy = -bound.y1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
temp_dx = dx;
|
||||
temp_dy = dy;
|
||||
temp_src = src;
|
||||
}
|
||||
|
||||
if (glamor_copy_n_to_n_textured(temp_src, dst, gc, box, nbox, temp_dx, temp_dy)) {
|
||||
if (glamor_copy_n_to_n_textured
|
||||
(temp_src, dst, gc, box, nbox, temp_dx, temp_dy)) {
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -390,7 +428,8 @@ done:
|
|||
|
||||
RegionPtr
|
||||
glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
||||
int srcx, int srcy, int width, int height, int dstx, int dsty)
|
||||
int srcx, int srcy, int width, int height, int dstx,
|
||||
int dsty)
|
||||
{
|
||||
RegionPtr region;
|
||||
region = miDoCopy(src, dst, gc,
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
* Screen CopyWindow implementation.
|
||||
*/
|
||||
|
||||
void glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
||||
void
|
||||
glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
||||
RegionPtr src_region)
|
||||
{
|
||||
RegionRec dst_region;
|
||||
|
@ -45,8 +46,8 @@ void glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
|||
|
||||
REGION_INIT(win->drawable.pScreen, &dst_region, NullBox, 0);
|
||||
|
||||
REGION_INTERSECT(win->drawable.pScreen, &dst_region, &win->borderClip,
|
||||
src_region);
|
||||
REGION_INTERSECT(win->drawable.pScreen, &dst_region,
|
||||
&win->borderClip, src_region);
|
||||
#ifdef COMPOSITE
|
||||
if (pixmap->screen_x || pixmap->screen_y)
|
||||
REGION_TRANSLATE(win->drawable.pScreen, &dst_region,
|
||||
|
@ -54,7 +55,8 @@ void glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
|||
#endif
|
||||
|
||||
miCopyRegion(&pixmap->drawable, &pixmap->drawable,
|
||||
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0, NULL);
|
||||
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0,
|
||||
NULL);
|
||||
|
||||
REGION_UNINIT(win->drawable.pScreen, &dst_region);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,8 @@ const Bool
|
|||
glamor_get_drawable_location(const DrawablePtr drawable)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
if (pixmap_priv == NULL || pixmap_priv->gl_fbo == 0)
|
||||
|
@ -55,7 +56,8 @@ glamor_get_drawable_location(const DrawablePtr drawable)
|
|||
}
|
||||
|
||||
GLint
|
||||
glamor_compile_glsl_prog(glamor_gl_dispatch *dispatch, GLenum type, const char *source)
|
||||
glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
|
||||
const char *source)
|
||||
{
|
||||
GLint ok;
|
||||
GLint prog;
|
||||
|
@ -73,8 +75,7 @@ glamor_compile_glsl_prog(glamor_gl_dispatch *dispatch, GLenum type, const char *
|
|||
|
||||
dispatch->glGetShaderInfoLog(prog, size, NULL, info);
|
||||
ErrorF("Failed to compile %s: %s\n",
|
||||
type == GL_FRAGMENT_SHADER ? "FS" : "VS",
|
||||
info);
|
||||
type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
|
||||
ErrorF("Program source:\n%s", source);
|
||||
FatalError("GLSL compile failure\n");
|
||||
}
|
||||
|
@ -97,8 +98,7 @@ glamor_link_glsl_prog(glamor_gl_dispatch *dispatch, GLint prog)
|
|||
info = malloc(size);
|
||||
|
||||
dispatch->glGetProgramInfoLog(prog, size, NULL, info);
|
||||
ErrorF("Failed to link: %s\n",
|
||||
info);
|
||||
ErrorF("Failed to link: %s\n", info);
|
||||
FatalError("GLSL link failure\n");
|
||||
}
|
||||
}
|
||||
|
@ -114,7 +114,8 @@ glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
|
|||
void
|
||||
glamor_init_finish_access_shaders(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
const char *vs_source =
|
||||
"attribute vec4 v_position;\n"
|
||||
|
@ -123,8 +124,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" source_texture = v_texcoord0.xy;\n"
|
||||
"}\n";
|
||||
" source_texture = v_texcoord0.xy;\n" "}\n";
|
||||
|
||||
const char *fs_source =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
|
@ -147,8 +147,7 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
" gl_FragColor = texture2D(sampler, source_texture).argb;\n"
|
||||
" else \n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).abgr;\n"
|
||||
" } \n"
|
||||
"}\n";
|
||||
" } \n" "}\n";
|
||||
|
||||
const char *set_alpha_source =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
|
@ -171,39 +170,64 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
" gl_FragColor = vec4(1, texture2D(sampler, source_texture).rgb);\n"
|
||||
" else \n"
|
||||
" gl_FragColor = vec4(1, texture2D(sampler, source_texture).bgr);\n"
|
||||
" } \n"
|
||||
"}\n";
|
||||
" } \n" "}\n";
|
||||
GLint fs_prog, vs_prog, avs_prog, set_alpha_prog;
|
||||
GLint sampler_uniform_location;
|
||||
|
||||
glamor_priv->finish_access_prog[0] = dispatch->glCreateProgram();
|
||||
glamor_priv->finish_access_prog[1] = dispatch->glCreateProgram();
|
||||
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, fs_source);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], fs_prog);
|
||||
vs_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
|
||||
vs_source);
|
||||
fs_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
fs_source);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
|
||||
vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0],
|
||||
fs_prog);
|
||||
|
||||
avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, vs_source);
|
||||
set_alpha_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, set_alpha_source);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1], avs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1], set_alpha_prog);
|
||||
avs_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
|
||||
vs_source);
|
||||
set_alpha_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
set_alpha_source);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
||||
avs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
||||
set_alpha_prog);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0], GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0], GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[0]);
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[0],
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch,
|
||||
glamor_priv->finish_access_prog[0]);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1], GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1], GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->finish_access_prog[1]);
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->finish_access_prog[1],
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch,
|
||||
glamor_priv->finish_access_prog[1]);
|
||||
|
||||
glamor_priv->finish_access_no_revert[0] =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0], "no_revert");
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"no_revert");
|
||||
|
||||
glamor_priv->finish_access_swap_rb[0] =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0], "swap_rb");
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0], "sampler");
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"sampler");
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[0]);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_no_revert[0], 1);
|
||||
|
@ -211,11 +235,17 @@ glamor_init_finish_access_shaders(ScreenPtr screen)
|
|||
dispatch->glUseProgram(0);
|
||||
|
||||
glamor_priv->finish_access_no_revert[1] =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1], "no_revert");
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"no_revert");
|
||||
glamor_priv->finish_access_swap_rb[1] =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1], "swap_rb");
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1], "sampler");
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"sampler");
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[1]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_no_revert[1], 1);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
|
@ -228,8 +258,10 @@ void
|
|||
glamor_finish_access(DrawablePtr drawable)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(drawable->pScreen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
|
@ -266,14 +298,16 @@ Bool
|
|||
glamor_prepare_access_gc(GCPtr gc)
|
||||
{
|
||||
if (gc->stipple) {
|
||||
if (!glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
|
||||
if (!glamor_prepare_access
|
||||
(&gc->stipple->drawable, GLAMOR_ACCESS_RO))
|
||||
return FALSE;
|
||||
}
|
||||
if (gc->fillStyle == FillTiled) {
|
||||
if (!glamor_prepare_access(&gc->tile.pixmap->drawable,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
if (gc->stipple)
|
||||
glamor_finish_access(&gc->stipple->drawable);
|
||||
glamor_finish_access(&gc->
|
||||
stipple->drawable);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -299,7 +333,8 @@ glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
|
|||
unsigned long fg_pixel, unsigned long bg_pixel,
|
||||
int stipple_x, int stipple_y)
|
||||
{
|
||||
glamor_fallback("stubbed out stipple depth %d\n", pixmap->drawable.depth);
|
||||
glamor_fallback("stubbed out stipple depth %d\n",
|
||||
pixmap->drawable.depth);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -347,23 +382,31 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
|||
PixmapPtr old_tile, new_tile;
|
||||
|
||||
old_tile = gc->tile.pixmap;
|
||||
if (old_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
|
||||
if (old_tile->drawable.bitsPerPixel !=
|
||||
drawable->bitsPerPixel) {
|
||||
new_tile = fbGetRotatedPixmap(gc);
|
||||
if (!new_tile ||
|
||||
new_tile ->drawable.bitsPerPixel != drawable->bitsPerPixel)
|
||||
{
|
||||
new_tile->drawable.bitsPerPixel !=
|
||||
drawable->bitsPerPixel) {
|
||||
if (new_tile)
|
||||
gc->pScreen->DestroyPixmap(new_tile);
|
||||
gc->pScreen->DestroyPixmap
|
||||
(new_tile);
|
||||
/* fb24_32ReformatTile will do direct access of a newly-
|
||||
* allocated pixmap.
|
||||
*/
|
||||
glamor_fallback("GC %p tile FB_24_32 transformat %p.\n", gc, old_tile);
|
||||
glamor_fallback
|
||||
("GC %p tile FB_24_32 transformat %p.\n",
|
||||
gc, old_tile);
|
||||
|
||||
if (glamor_prepare_access(&old_tile->drawable,
|
||||
if (glamor_prepare_access
|
||||
(&old_tile->drawable,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
new_tile = fb24_32ReformatTile(old_tile,
|
||||
new_tile =
|
||||
fb24_32ReformatTile
|
||||
(old_tile,
|
||||
drawable->bitsPerPixel);
|
||||
glamor_finish_access(&old_tile->drawable);
|
||||
glamor_finish_access
|
||||
(&old_tile->drawable);
|
||||
}
|
||||
}
|
||||
if (new_tile) {
|
||||
|
@ -376,16 +419,20 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
|||
#endif
|
||||
if (changes & GCTile) {
|
||||
if (!gc->tileIsPixel) {
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(gc->tile.pixmap);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(gc->tile.pixmap);
|
||||
if ((!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
&& FbEvenTile(gc->tile.pixmap->drawable.width *
|
||||
drawable->bitsPerPixel))
|
||||
{
|
||||
glamor_fallback("GC %p tile changed %p.\n", gc, gc->tile.pixmap);
|
||||
if (glamor_prepare_access(&gc->tile.pixmap->drawable,
|
||||
drawable->bitsPerPixel)) {
|
||||
glamor_fallback
|
||||
("GC %p tile changed %p.\n", gc,
|
||||
gc->tile.pixmap);
|
||||
if (glamor_prepare_access
|
||||
(&gc->tile.pixmap->drawable,
|
||||
GLAMOR_ACCESS_RW)) {
|
||||
fbPadPixmap(gc->tile.pixmap);
|
||||
glamor_finish_access(&gc->tile.pixmap->drawable);
|
||||
glamor_finish_access
|
||||
(&gc->tile.pixmap->drawable);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -399,7 +446,8 @@ glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
|||
/* We can't inline stipple handling like we do for GCTile because
|
||||
* it sets fbgc privates.
|
||||
*/
|
||||
if (glamor_prepare_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access
|
||||
(&gc->stipple->drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbValidateGC(gc, changes, drawable);
|
||||
glamor_finish_access(&gc->stipple->drawable);
|
||||
}
|
||||
|
@ -492,4 +540,3 @@ glamor_gl_get_version (void)
|
|||
|
||||
return GLAMOR_GL_VERSION_ENCODE(major, minor);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
#define GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD 3
|
||||
|
||||
extern void
|
||||
AbortServer(void) _X_NORETURN;
|
||||
AbortServer(void)
|
||||
_X_NORETURN;
|
||||
|
||||
#define GLAMOR_PANIC(_format_, ...) \
|
||||
do { \
|
||||
|
@ -19,7 +20,7 @@ AbortServer(void) _X_NORETURN;
|
|||
" at %32s line %d: " _format_ "\n", \
|
||||
__FUNCTION__, __LINE__, \
|
||||
##__VA_ARGS__ ); \
|
||||
AbortServer(); \
|
||||
exit(1); \
|
||||
} while(0)
|
||||
|
||||
|
||||
|
|
|
@ -64,10 +64,15 @@
|
|||
|
||||
static const char glamor_name[] = "glamor";
|
||||
|
||||
static DevPrivateKeyRec glamor_egl_pixmap_private_key_index;
|
||||
DevPrivateKey glamor_egl_pixmap_private_key =
|
||||
&glamor_egl_pixmap_private_key_index;
|
||||
|
||||
static void
|
||||
glamor_identify(int flags)
|
||||
{
|
||||
xf86Msg(X_INFO, "%s: OpenGL accelerated X.org driver based.\n", glamor_name);
|
||||
xf86Msg(X_INFO, "%s: OpenGL accelerated X.org driver based.\n",
|
||||
glamor_name);
|
||||
}
|
||||
|
||||
struct glamor_egl_screen_private {
|
||||
|
@ -92,21 +97,27 @@ struct glamor_egl_screen_private {
|
|||
|
||||
int xf86GlamorEGLPrivateIndex = -1;
|
||||
|
||||
static struct glamor_egl_screen_private* glamor_get_egl_screen_private(ScrnInfoPtr scrn)
|
||||
static struct glamor_egl_screen_private
|
||||
*
|
||||
glamor_egl_get_screen_private(ScrnInfoPtr scrn)
|
||||
{
|
||||
return (struct glamor_egl_screen_private *) scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
|
||||
return (struct glamor_egl_screen_private *)
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr;
|
||||
}
|
||||
|
||||
static EGLImageKHR
|
||||
_glamor_create_egl_image(struct glamor_egl_screen_private *glamor_egl, int width, int height, int stride, int name)
|
||||
_glamor_egl_create_image(struct glamor_egl_screen_private *glamor_egl,
|
||||
int width, int height, int stride, int name)
|
||||
{
|
||||
EGLImageKHR image;
|
||||
EGLint attribs[] = {
|
||||
EGL_WIDTH, 0,
|
||||
EGL_HEIGHT, 0,
|
||||
EGL_DRM_BUFFER_STRIDE_MESA, 0,
|
||||
EGL_DRM_BUFFER_FORMAT_MESA, EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
|
||||
EGL_DRM_BUFFER_USE_MESA, EGL_DRM_BUFFER_USE_SHARE_MESA |
|
||||
EGL_DRM_BUFFER_FORMAT_MESA,
|
||||
EGL_DRM_BUFFER_FORMAT_ARGB32_MESA,
|
||||
EGL_DRM_BUFFER_USE_MESA,
|
||||
EGL_DRM_BUFFER_USE_SHARE_MESA |
|
||||
EGL_DRM_BUFFER_USE_SCANOUT_MESA,
|
||||
EGL_NONE
|
||||
};
|
||||
|
@ -118,8 +129,7 @@ _glamor_create_egl_image(struct glamor_egl_screen_private *glamor_egl, int width
|
|||
image = glamor_egl->egl_create_image_khr(glamor_egl->display,
|
||||
glamor_egl->context,
|
||||
EGL_DRM_BUFFER_MESA,
|
||||
(void*)name,
|
||||
attribs);
|
||||
(void *) name, attribs);
|
||||
if (image == EGL_NO_IMAGE_KHR)
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
|
||||
|
@ -139,27 +149,36 @@ glamor_get_flink_name(int fd, int handle, int *name)
|
|||
}
|
||||
|
||||
static Bool
|
||||
glamor_create_texture_from_image(struct glamor_egl_screen_private *glamor_egl, EGLImageKHR image, GLuint *texture)
|
||||
glamor_create_texture_from_image(struct glamor_egl_screen_private
|
||||
*glamor_egl,
|
||||
EGLImageKHR image, GLuint * texture)
|
||||
{
|
||||
glamor_egl->dispatch->glGenTextures(1, texture);
|
||||
glamor_egl->dispatch->glBindTexture(GL_TEXTURE_2D, *texture);
|
||||
glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
glamor_egl->dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
|
||||
(glamor_egl->egl_image_target_texture2d_oes)(GL_TEXTURE_2D, image);
|
||||
(glamor_egl->egl_image_target_texture2d_oes) (GL_TEXTURE_2D,
|
||||
image);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_create_egl_screen_image(ScreenPtr screen, int handle, int stride)
|
||||
glamor_egl_create_textured_screen(ScreenPtr screen, int handle, int stride)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
||||
struct glamor_egl_screen_private *glamor_egl = glamor_get_egl_screen_private(scrn);
|
||||
struct glamor_egl_screen_private *glamor_egl =
|
||||
glamor_egl_get_screen_private(scrn);
|
||||
EGLImageKHR image;
|
||||
GLuint texture;
|
||||
|
||||
if (!glamor_get_flink_name(glamor_egl->fd, handle, &glamor_egl->front_buffer_handle)) {
|
||||
if (!glamor_get_flink_name
|
||||
(glamor_egl->fd, handle, &glamor_egl->front_buffer_handle)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Couldn't flink front buffer handle\n");
|
||||
return FALSE;
|
||||
|
@ -170,7 +189,7 @@ glamor_create_egl_screen_image(ScreenPtr screen, int handle, int stride)
|
|||
glamor_egl->root = EGL_NO_IMAGE_KHR;
|
||||
}
|
||||
|
||||
image = _glamor_create_egl_image( glamor_egl,
|
||||
image = _glamor_egl_create_image(glamor_egl,
|
||||
scrn->virtualX,
|
||||
scrn->virtualY,
|
||||
stride,
|
||||
|
@ -179,23 +198,25 @@ glamor_create_egl_screen_image(ScreenPtr screen, int handle, int stride)
|
|||
return FALSE;
|
||||
|
||||
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
||||
glamor_set_screen_pixmap_texture(screen, scrn->virtualX, scrn->virtualY, texture);
|
||||
glamor_set_screen_pixmap_texture(screen, scrn->virtualX,
|
||||
scrn->virtualY, texture);
|
||||
glamor_egl->root = image;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* This function will be called from the dri buffer allocation.
|
||||
* It is somehow very familiar with the create screen image.
|
||||
* It is somehow very familiar with the create textured screen.
|
||||
* XXX the egl image here is not stored at any data structure.
|
||||
* Does this cause a leak problem?
|
||||
*/
|
||||
Bool
|
||||
glamor_create_egl_pixmap_image(PixmapPtr pixmap, int handle, int stride)
|
||||
glamor_egl_create_textured_pixmap(PixmapPtr pixmap, int handle, int stride)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
||||
struct glamor_egl_screen_private *glamor_egl = glamor_get_egl_screen_private(scrn);
|
||||
struct glamor_egl_screen_private *glamor_egl =
|
||||
glamor_egl_get_screen_private(scrn);
|
||||
EGLImageKHR image;
|
||||
GLuint texture;
|
||||
int name;
|
||||
|
@ -205,45 +226,68 @@ glamor_create_egl_pixmap_image(PixmapPtr pixmap, int handle, int stride)
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
image = _glamor_create_egl_image( glamor_egl,
|
||||
|
||||
image = _glamor_egl_create_image(glamor_egl,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
stride,
|
||||
pixmap->drawable.height, stride,
|
||||
name);
|
||||
if (image == EGL_NO_IMAGE_KHR)
|
||||
if (image == EGL_NO_IMAGE_KHR) {
|
||||
ErrorF("Failed to create khr image for bo handle %d.\n", handle);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
glamor_create_texture_from_image(glamor_egl, image, &texture);
|
||||
glamor_set_pixmap_texture(pixmap, pixmap->drawable.width, pixmap->drawable.height, texture);
|
||||
glamor_set_pixmap_texture(pixmap, pixmap->drawable.width,
|
||||
pixmap->drawable.height, texture);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_egl_pixmap_private_key,
|
||||
image);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
EGLImageKHR image;
|
||||
ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum];
|
||||
struct glamor_egl_screen_private *glamor_egl =
|
||||
glamor_egl_get_screen_private(scrn);
|
||||
|
||||
if (pixmap->refcnt == 1) {
|
||||
image = dixLookupPrivate(&pixmap->devPrivates,
|
||||
glamor_egl_pixmap_private_key);
|
||||
if (image != EGL_NO_IMAGE_KHR)
|
||||
eglDestroyImageKHR(glamor_egl->display, image);
|
||||
}
|
||||
glamor_destroy_textured_pixmap(pixmap);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_close_egl_screen(ScreenPtr screen)
|
||||
glamor_egl_close_screen(ScreenPtr screen)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
||||
struct glamor_egl_screen_private *glamor_egl = glamor_get_egl_screen_private(scrn);
|
||||
struct glamor_egl_screen_private *glamor_egl =
|
||||
glamor_egl_get_screen_private(scrn);
|
||||
glamor_fini(screen);
|
||||
|
||||
eglDestroyImageKHR(glamor_egl->display, glamor_egl->root);
|
||||
|
||||
|
||||
glamor_egl->root = EGL_NO_IMAGE_KHR;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Bool
|
||||
glamor_egl_has_extension(struct glamor_egl_screen_private *glamor_egl, char *extension)
|
||||
glamor_egl_has_extension(struct glamor_egl_screen_private *glamor_egl,
|
||||
char *extension)
|
||||
{
|
||||
const char *egl_extensions;
|
||||
char *pext;
|
||||
int ext_len;
|
||||
ext_len = strlen(extension);
|
||||
|
||||
egl_extensions = (const char*)eglQueryString(glamor_egl->display, EGL_EXTENSIONS);
|
||||
egl_extensions =
|
||||
(const char *) eglQueryString(glamor_egl->display,
|
||||
EGL_EXTENSIONS);
|
||||
pext = (char *) egl_extensions;
|
||||
|
||||
if (pext == NULL || extension == NULL)
|
||||
|
@ -257,7 +301,8 @@ glamor_egl_has_extension(struct glamor_egl_screen_private *glamor_egl, char *ext
|
|||
}
|
||||
|
||||
|
||||
Bool glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
||||
Bool
|
||||
glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
||||
{
|
||||
struct glamor_egl_screen_private *glamor_egl;
|
||||
const char *version;
|
||||
|
@ -271,7 +316,8 @@ Bool glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
glamor_identify(0);
|
||||
glamor_egl = calloc(sizeof(*glamor_egl), 1);
|
||||
if (xf86GlamorEGLPrivateIndex == -1)
|
||||
xf86GlamorEGLPrivateIndex = xf86AllocateScrnInfoPrivateIndex();
|
||||
xf86GlamorEGLPrivateIndex =
|
||||
xf86AllocateScrnInfoPrivateIndex();
|
||||
|
||||
scrn->privates[xf86GlamorEGLPrivateIndex].ptr = glamor_egl;
|
||||
|
||||
|
@ -293,7 +339,9 @@ Bool glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
#else
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
#endif
|
||||
if (!eglInitialize(glamor_egl->display, &glamor_egl->major, &glamor_egl->minor)) {
|
||||
if (!eglInitialize
|
||||
(glamor_egl->display, &glamor_egl->major, &glamor_egl->minor))
|
||||
{
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"eglInitialize() failed\n");
|
||||
return FALSE;
|
||||
|
@ -321,7 +369,8 @@ Bool glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
glamor_egl->egl_create_image_khr = (PFNEGLCREATEIMAGEKHRPROC)
|
||||
eglGetProcAddress("eglCreateImageKHR");
|
||||
|
||||
glamor_egl->egl_image_target_texture2d_oes = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)
|
||||
glamor_egl->egl_image_target_texture2d_oes =
|
||||
(PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)
|
||||
eglGetProcAddress("glEGLImageTargetTexture2DOES");
|
||||
|
||||
if (!glamor_egl->egl_create_image_khr
|
||||
|
@ -333,7 +382,8 @@ Bool glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
}
|
||||
|
||||
glamor_egl->context = eglCreateContext(glamor_egl->display,
|
||||
NULL, EGL_NO_CONTEXT, config_attribs);
|
||||
NULL, EGL_NO_CONTEXT,
|
||||
config_attribs);
|
||||
if (glamor_egl->context == EGL_NO_CONTEXT) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Failed to create EGL context\n");
|
||||
|
@ -341,28 +391,41 @@ Bool glamor_egl_init(ScrnInfoPtr scrn, int fd)
|
|||
}
|
||||
|
||||
if (!eglMakeCurrent(glamor_egl->display,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, glamor_egl->context)) {
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
glamor_egl->context)) {
|
||||
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
|
||||
"Failed to make EGL context current\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_egl_init_textured_pixmap(ScreenPtr screen)
|
||||
{
|
||||
if (!dixRegisterPrivateKey
|
||||
(glamor_egl_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate egl pixmap private\n",
|
||||
screen->myNum);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_free_egl_screen(int scrnIndex, int flags)
|
||||
glamor_egl_free_screen(int scrnIndex, int flags)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86Screens[scrnIndex];
|
||||
struct glamor_egl_screen_private *glamor_egl = glamor_get_egl_screen_private(scrn);
|
||||
struct glamor_egl_screen_private *glamor_egl =
|
||||
glamor_egl_get_screen_private(scrn);
|
||||
|
||||
if (glamor_egl != NULL)
|
||||
{
|
||||
if (glamor_egl != NULL) {
|
||||
if (!(flags & GLAMOR_EGL_EXTERNAL_BUFFER)) {
|
||||
eglMakeCurrent(glamor_egl->display,
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
EGL_NO_SURFACE, EGL_NO_SURFACE,
|
||||
EGL_NO_CONTEXT);
|
||||
|
||||
eglTerminate(glamor_egl->display);
|
||||
}
|
||||
|
@ -370,14 +433,16 @@ glamor_free_egl_screen(int scrnIndex, int flags)
|
|||
}
|
||||
}
|
||||
|
||||
/* egl version. */
|
||||
|
||||
Bool
|
||||
glamor_gl_dispatch_init(ScreenPtr screen, struct glamor_gl_dispatch *dispatch, int gl_version)
|
||||
glamor_gl_dispatch_init(ScreenPtr screen,
|
||||
struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version)
|
||||
{
|
||||
ScrnInfoPtr scrn = xf86Screens[screen->myNum];
|
||||
struct glamor_egl_screen_private *glamor_egl = glamor_get_egl_screen_private(scrn);
|
||||
if (!glamor_gl_dispatch_init_impl(dispatch, gl_version, eglGetProcAddress))
|
||||
struct glamor_egl_screen_private *glamor_egl =
|
||||
glamor_egl_get_screen_private(scrn);
|
||||
if (!glamor_gl_dispatch_init_impl
|
||||
(dispatch, gl_version, (get_proc_address_t)eglGetProcAddress))
|
||||
return FALSE;
|
||||
glamor_egl->dispatch = dispatch;
|
||||
return TRUE;
|
||||
|
|
44
glamor/glamor_eglmodule.c
Normal file
44
glamor/glamor_eglmodule.c
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of the XFree86 Project shall
|
||||
* not be used in advertising or otherwise to promote the sale, use or other
|
||||
* dealings in this Software without prior written authorization from the
|
||||
* XFree86 Project.
|
||||
*/
|
||||
|
||||
#include <xorg-server.h>
|
||||
|
||||
#include "xf86Module.h"
|
||||
|
||||
static XF86ModuleVersionInfo VersRec = {
|
||||
"glamor_egl",
|
||||
MODULEVENDORSTRING,
|
||||
MODINFOSTRING1,
|
||||
MODINFOSTRING2,
|
||||
XORG_VERSION_CURRENT,
|
||||
1, 0, 0,
|
||||
ABI_CLASS_ANSIC, /* Only need the ansic layer */
|
||||
ABI_ANSIC_VERSION,
|
||||
MOD_CLASS_NONE,
|
||||
{0, 0, 0, 0} /* signature, to be patched into the file by a tool */
|
||||
};
|
||||
|
||||
_X_EXPORT XF86ModuleData glamor_eglModuleData = { &VersRec, NULL, NULL };
|
|
@ -32,13 +32,9 @@
|
|||
* GC fill implementation, based loosely on fb_fill.c
|
||||
*/
|
||||
|
||||
void
|
||||
Bool
|
||||
glamor_fill(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
GCPtr gc, int x, int y, int width, int height)
|
||||
{
|
||||
PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
int off_x, off_y;
|
||||
|
@ -50,10 +46,7 @@ glamor_fill(DrawablePtr drawable,
|
|||
if (!glamor_solid(dst_pixmap,
|
||||
x + off_x,
|
||||
y + off_y,
|
||||
width,
|
||||
height,
|
||||
gc->alu,
|
||||
gc->planemask,
|
||||
width, height, gc->alu, gc->planemask,
|
||||
gc->fgPixel))
|
||||
goto fail;
|
||||
break;
|
||||
|
@ -68,11 +61,9 @@ glamor_fill(DrawablePtr drawable,
|
|||
gc->alu,
|
||||
gc->planemask,
|
||||
gc->fgPixel,
|
||||
gc->bgPixel,
|
||||
gc->patOrg.x,
|
||||
gc->bgPixel, gc->patOrg.x,
|
||||
gc->patOrg.y))
|
||||
goto fail;
|
||||
return;
|
||||
break;
|
||||
case FillTiled:
|
||||
if (!glamor_tile(dst_pixmap,
|
||||
|
@ -88,7 +79,7 @@ glamor_fill(DrawablePtr drawable,
|
|||
goto fail;
|
||||
break;
|
||||
}
|
||||
return;
|
||||
return TRUE;
|
||||
fail:
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
|
@ -97,50 +88,53 @@ fail:
|
|||
}
|
||||
glamor_finish_access(drawable);
|
||||
}
|
||||
return;
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
glamor_init_solid_shader(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
const char *solid_vs =
|
||||
"attribute vec4 v_position;"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
"void main()\n" "{\n" " gl_Position = v_position;\n"
|
||||
"}\n";
|
||||
const char *solid_fs =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"uniform vec4 color;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = color;\n"
|
||||
"}\n";
|
||||
GLAMOR_DEFAULT_PRECISION "uniform vec4 color;\n"
|
||||
"void main()\n" "{\n" " gl_FragColor = color;\n" "}\n";
|
||||
GLint fs_prog, vs_prog;
|
||||
|
||||
glamor_priv->solid_prog = dispatch->glCreateProgram();
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, solid_vs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, solid_fs);
|
||||
vs_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, solid_vs);
|
||||
fs_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
solid_fs);
|
||||
dispatch->glAttachShader(glamor_priv->solid_prog, vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->solid_prog, fs_prog);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->solid_prog, GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->solid_prog,
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->solid_prog);
|
||||
|
||||
glamor_priv->solid_color_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->solid_prog, "color");
|
||||
dispatch->glGetUniformLocation(glamor_priv->solid_prog,
|
||||
"color");
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask, unsigned long fg_pixel)
|
||||
unsigned char alu, unsigned long planemask,
|
||||
unsigned long fg_pixel)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
int x1 = x;
|
||||
int x2 = x + width;
|
||||
|
@ -155,7 +149,8 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
|||
}
|
||||
glamor_set_alu(dispatch, alu);
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||
glamor_fallback
|
||||
("Failedto set planemask in glamor_solid.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -163,8 +158,7 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
|||
&color[0],
|
||||
&color[1],
|
||||
&color[2],
|
||||
&color[3],
|
||||
format_for_pixmap(pixmap));
|
||||
&color[3], format_for_pixmap(pixmap));
|
||||
#ifdef GLAMOR_DELAYED_FILLING
|
||||
if (x == 0 && y == 0
|
||||
&& width == pixmap->drawable.width
|
||||
|
@ -182,16 +176,17 @@ glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
|||
|
||||
dispatch->glUseProgram(glamor_priv->solid_prog);
|
||||
|
||||
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location, 1, color);
|
||||
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location,
|
||||
1, color);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float), vertices);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
|
||||
|
||||
glamor_set_normalize_vcoords(xscale, yscale, x1, y1, x2, y2,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
glamor_priv->yInverted, vertices);
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glUseProgram(0);
|
||||
|
@ -201,5 +196,3 @@ fail:
|
|||
glamor_set_planemask(pixmap, ~0);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -33,10 +33,7 @@
|
|||
void
|
||||
glamor_fill_spans(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n,
|
||||
DDXPointPtr points,
|
||||
int *widths,
|
||||
int sorted)
|
||||
int n, DDXPointPtr points, int *widths, int sorted)
|
||||
{
|
||||
DDXPointPtr ppt;
|
||||
int nbox;
|
||||
|
@ -69,9 +66,7 @@ glamor_fill_spans(DrawablePtr drawable,
|
|||
|
||||
if (x2 <= x1)
|
||||
continue;
|
||||
glamor_fill (drawable,gc,
|
||||
x1, y,
|
||||
x2 - x1 , 1);
|
||||
glamor_fill(drawable, gc, x1, y, x2 - x1, 1);
|
||||
pbox++;
|
||||
}
|
||||
}
|
||||
|
@ -81,7 +76,8 @@ fail:
|
|||
glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbFillSpans(drawable, gc, n, points, widths, sorted);
|
||||
fbFillSpans(drawable, gc, n, points, widths,
|
||||
sorted);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable);
|
||||
|
|
|
@ -34,16 +34,15 @@
|
|||
void
|
||||
glamor_get_spans(DrawablePtr drawable,
|
||||
int wmax,
|
||||
DDXPointPtr points,
|
||||
int *widths,
|
||||
int count,
|
||||
char *dst)
|
||||
DDXPointPtr points, int *widths, int count, char *dst)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
GLenum format, type;
|
||||
int no_alpha, no_revert;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(drawable->pScreen);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
PixmapPtr temp_pixmap = NULL;
|
||||
int i;
|
||||
|
@ -57,12 +56,9 @@ glamor_get_spans(DrawablePtr drawable,
|
|||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&no_alpha,
|
||||
&no_revert
|
||||
)) {
|
||||
glamor_fallback("unknown depth. %d \n",
|
||||
drawable->depth);
|
||||
&type, &no_alpha,
|
||||
&no_revert)) {
|
||||
glamor_fallback("unknown depth. %d \n", drawable->depth);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -71,8 +67,10 @@ glamor_get_spans(DrawablePtr drawable,
|
|||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) {
|
||||
/* XXX prepare whole pixmap is not efficient. */
|
||||
temp_pixmap = glamor_es2_pixmap_read_prepare(pixmap, &format,
|
||||
&type, no_alpha, no_revert);
|
||||
temp_pixmap =
|
||||
glamor_es2_pixmap_read_prepare(pixmap, &format,
|
||||
&type, no_alpha,
|
||||
no_revert);
|
||||
pixmap_priv = glamor_get_pixmap_private(temp_pixmap);
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
}
|
||||
|
@ -82,19 +80,17 @@ glamor_get_spans(DrawablePtr drawable,
|
|||
if (glamor_priv->yInverted) {
|
||||
dispatch->glReadPixels(points[i].x + x_off,
|
||||
(points[i].y + y_off),
|
||||
widths[i],
|
||||
1,
|
||||
format, type,
|
||||
readpixels_dst);
|
||||
widths[i], 1, format,
|
||||
type, readpixels_dst);
|
||||
} else {
|
||||
dispatch->glReadPixels(points[i].x + x_off,
|
||||
pixmap->drawable.height - 1 - (points[i].y + y_off),
|
||||
widths[i],
|
||||
1,
|
||||
format, type,
|
||||
readpixels_dst);
|
||||
pixmap->drawable.height -
|
||||
1 - (points[i].y + y_off),
|
||||
widths[i], 1, format,
|
||||
type, readpixels_dst);
|
||||
}
|
||||
readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
|
||||
readpixels_dst +=
|
||||
PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
if (temp_pixmap)
|
||||
pixmap->drawable.pScreen->DestroyPixmap(temp_pixmap);
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
#define INIT_FUNC(dst,func_name,get) \
|
||||
dst->func_name = get(#func_name); \
|
||||
if (dst->func_name == NULL) \
|
||||
{ ErrorF("Failed to get fun %s", #func_name); \
|
||||
{ ErrorF("Failed to get function %s", #func_name); \
|
||||
goto fail; }
|
||||
|
||||
Bool
|
||||
_X_EXPORT Bool
|
||||
glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version,
|
||||
void *(*get_proc_address) (const char *))
|
||||
|
|
|
@ -2,8 +2,8 @@ typedef struct glamor_gl_dispatch {
|
|||
/* Transformation functions */
|
||||
void (*glMatrixMode) (GLenum mode);
|
||||
void (*glLoadIdentity) (void);
|
||||
void (*glViewport)( GLint x, GLint y,
|
||||
GLsizei width, GLsizei height );
|
||||
void (*glViewport) (GLint x, GLint y, GLsizei width,
|
||||
GLsizei height);
|
||||
/* Drawing functions */
|
||||
void (*glRasterPos2i) (GLint x, GLint y);
|
||||
|
||||
|
@ -13,8 +13,7 @@ typedef struct glamor_gl_dispatch {
|
|||
/* Raster functions */
|
||||
void (*glReadPixels) (GLint x, GLint y,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
GLvoid *pixels );
|
||||
GLenum format, GLenum type, GLvoid * pixels);
|
||||
|
||||
void (*glDrawPixels) (GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
|
@ -41,7 +40,8 @@ typedef struct glamor_gl_dispatch {
|
|||
void (*glFlush) (void);
|
||||
void (*glGetIntegerv) (GLenum pname, GLint * params);
|
||||
const GLubyte *(*glGetString) (GLenum name);
|
||||
void (*glScissor)( GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void (*glScissor) (GLint x, GLint y, GLsizei width,
|
||||
GLsizei height);
|
||||
void (*glEnable) (GLenum cap);
|
||||
void (*glDisable) (GLenum cap);
|
||||
void (*glBlendFunc) (GLenum sfactor, GLenum dfactor);
|
||||
|
@ -52,50 +52,72 @@ typedef struct glamor_gl_dispatch {
|
|||
|
||||
/* GL Extentions */
|
||||
void (*glGenBuffers) (GLsizei n, GLuint * buffers);
|
||||
void (*glBufferData) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
|
||||
void (*glBufferData) (GLenum target, GLsizeiptr size,
|
||||
const GLvoid * data, GLenum usage);
|
||||
GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
|
||||
GLboolean(*glUnmapBuffer) (GLenum target);
|
||||
void (*glBindBuffer) (GLenum target, GLuint buffer);
|
||||
void (*glDeleteBuffers) (GLsizei n, const GLuint * buffers);
|
||||
|
||||
void (*glFramebufferTexture2D) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
|
||||
void (*glFramebufferTexture2D) (GLenum target, GLenum attachment,
|
||||
GLenum textarget, GLuint texture,
|
||||
GLint level);
|
||||
void (*glBindFramebuffer) (GLenum target, GLuint framebuffer);
|
||||
void (*glDeleteFramebuffers) (GLsizei n, const GLuint *framebuffers);
|
||||
void (*glDeleteFramebuffers) (GLsizei n,
|
||||
const GLuint * framebuffers);
|
||||
void (*glGenFramebuffers) (GLsizei n, GLuint * framebuffers);
|
||||
GLenum(*glCheckFramebufferStatus) (GLenum target);
|
||||
void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
|
||||
void (*glBlitFramebuffer) (GLint srcX0, GLint srcY0, GLint srcX1,
|
||||
GLint srcY1, GLint dstX0, GLint dstY0,
|
||||
GLint dstX1, GLint dstY1,
|
||||
GLbitfield mask, GLenum filter);
|
||||
|
||||
void (*glVertexAttribPointer) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
|
||||
void (*glVertexAttribPointer) (GLuint index, GLint size,
|
||||
GLenum type, GLboolean normalized,
|
||||
GLsizei stride,
|
||||
const GLvoid * pointer);
|
||||
void (*glDisableVertexAttribArray) (GLuint index);
|
||||
void (*glEnableVertexAttribArray) (GLuint index);
|
||||
void (*glBindAttribLocation) (GLuint program, GLuint index, const GLchar *name);
|
||||
void (*glBindAttribLocation) (GLuint program, GLuint index,
|
||||
const GLchar * name);
|
||||
|
||||
void (*glLinkProgram) (GLuint program);
|
||||
void (*glShaderSource) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
|
||||
void (*glShaderSource) (GLuint shader, GLsizei count,
|
||||
const GLchar * *string,
|
||||
const GLint * length);
|
||||
void (*glUseProgram) (GLuint program);
|
||||
void (*glUniform1i) (GLint location, GLint v0);
|
||||
void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
|
||||
void (*glUniform4fv) (GLint location, GLsizei count, const GLfloat *value);
|
||||
void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
|
||||
GLfloat v2, GLfloat v3);
|
||||
void (*glUniform4fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
GLuint(*glCreateProgram) (void);
|
||||
GLuint(*glCreateShader) (GLenum type);
|
||||
void (*glCompileShader) (GLuint shader);
|
||||
void (*glAttachShader) (GLuint program, GLuint shader);
|
||||
void (*glGetShaderiv) (GLuint shader, GLenum pname, GLint *params);
|
||||
void (*glGetShaderInfoLog) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
void (*glGetProgramiv) (GLuint program, GLenum pname, GLint *params);
|
||||
void (*glGetProgramInfoLog) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
|
||||
GLint (*glGetUniformLocation) (GLuint program, const GLchar *name);
|
||||
void (*glGetShaderiv) (GLuint shader, GLenum pname,
|
||||
GLint * params);
|
||||
void (*glGetShaderInfoLog) (GLuint shader, GLsizei bufSize,
|
||||
GLsizei * length, GLchar * infoLog);
|
||||
void (*glGetProgramiv) (GLuint program, GLenum pname,
|
||||
GLint * params);
|
||||
void (*glGetProgramInfoLog) (GLuint program, GLsizei bufSize,
|
||||
GLsizei * length, GLchar * infoLog);
|
||||
GLint(*glGetUniformLocation) (GLuint program,
|
||||
const GLchar * name);
|
||||
|
||||
} glamor_gl_dispatch;
|
||||
|
||||
Bool
|
||||
|
||||
typedef void *(*get_proc_address_t) (const char *);
|
||||
|
||||
_X_EXPORT Bool
|
||||
glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version,
|
||||
void *(*get_proc_address)(const char*));
|
||||
|
||||
|
||||
Bool
|
||||
glamor_gl_dispatch_init(ScreenPtr screen, struct glamor_gl_dispatch *dispatch, int gl_version);
|
||||
|
||||
get_proc_address_t get_proc_address);
|
||||
|
||||
|
||||
_X_EXPORT Bool
|
||||
glamor_gl_dispatch_init(ScreenPtr screen,
|
||||
struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version);
|
||||
|
|
|
@ -77,8 +77,7 @@ typedef struct {
|
|||
int count;
|
||||
} glamor_glyph_buffer_t;
|
||||
|
||||
struct glamor_glyph
|
||||
{
|
||||
struct glamor_glyph {
|
||||
glamor_glyph_cache_t *cache;
|
||||
uint16_t x, y;
|
||||
uint16_t size, pos;
|
||||
|
@ -117,8 +116,7 @@ glamor_unrealize_glyph_caches (ScreenPtr pScreen)
|
|||
if (!glamor->glyph_cache_initialized)
|
||||
return;
|
||||
|
||||
for (i = 0; i < GLAMOR_NUM_GLYPH_CACHE_FORMATS; i++)
|
||||
{
|
||||
for (i = 0; i < GLAMOR_NUM_GLYPH_CACHE_FORMATS; i++) {
|
||||
glamor_glyph_cache_t *cache = &glamor->glyphCaches[i];
|
||||
|
||||
if (cache->picture)
|
||||
|
@ -161,8 +159,7 @@ glamor_realize_glyph_caches (ScreenPtr pScreen)
|
|||
glamor->glyph_cache_initialized = TRUE;
|
||||
memset(glamor->glyphCaches, 0, sizeof(glamor->glyphCaches));
|
||||
|
||||
for (i = 0; i < sizeof (formats) / sizeof (formats[0]); i++)
|
||||
{
|
||||
for (i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) {
|
||||
glamor_glyph_cache_t *cache = &glamor->glyphCaches[i];
|
||||
PixmapPtr pixmap;
|
||||
PicturePtr picture;
|
||||
|
@ -176,8 +173,9 @@ glamor_realize_glyph_caches (ScreenPtr pScreen)
|
|||
|
||||
/* Now allocate the pixmap and picture */
|
||||
pixmap = pScreen->CreatePixmap(pScreen,
|
||||
CACHE_PICTURE_SIZE, CACHE_PICTURE_SIZE,
|
||||
depth, 0);
|
||||
CACHE_PICTURE_SIZE,
|
||||
CACHE_PICTURE_SIZE, depth,
|
||||
0);
|
||||
if (!pixmap)
|
||||
goto bail;
|
||||
|
||||
|
@ -244,53 +242,54 @@ glamor_glyph_cache_upload_glyph (ScreenPtr screen,
|
|||
#if 0
|
||||
/* Create a temporary bo to stream the updates to the cache */
|
||||
if (pGlyphPixmap->drawable.depth != pCachePixmap->drawable.depth ||
|
||||
!uxa_pixmap_is_offscreen (scratch))
|
||||
{
|
||||
!uxa_pixmap_is_offscreen(scratch)) {
|
||||
scratch = screen->CreatePixmap(screen,
|
||||
glyph->info.width,
|
||||
glyph->info.height,
|
||||
pCachePixmap->drawable.depth, 0);
|
||||
if (scratch)
|
||||
{
|
||||
if (pGlyphPixmap->drawable.depth != pCachePixmap->drawable.depth)
|
||||
{
|
||||
pCachePixmap->
|
||||
drawable.depth, 0);
|
||||
if (scratch) {
|
||||
if (pGlyphPixmap->drawable.depth !=
|
||||
pCachePixmap->drawable.depth) {
|
||||
PicturePtr picture;
|
||||
int error;
|
||||
|
||||
picture = CreatePicture (0, &scratch->drawable,
|
||||
PictureMatchFormat (screen,
|
||||
picture =
|
||||
CreatePicture(0,
|
||||
&scratch->drawable,
|
||||
PictureMatchFormat
|
||||
(screen,
|
||||
pCachePixmap->
|
||||
drawable.depth,
|
||||
cache->picture->
|
||||
format), 0, NULL,
|
||||
serverClient, &error);
|
||||
if (picture)
|
||||
{
|
||||
cache->picture->format),
|
||||
0, NULL, serverClient,
|
||||
&error);
|
||||
if (picture) {
|
||||
ValidatePicture(picture);
|
||||
uxa_composite (PictOpSrc, pGlyphPicture, NULL, picture,
|
||||
0, 0,
|
||||
0, 0,
|
||||
0, 0, glyph->info.width, glyph->info.height);
|
||||
uxa_composite(PictOpSrc,
|
||||
pGlyphPicture,
|
||||
NULL, picture,
|
||||
0, 0, 0, 0, 0,
|
||||
0,
|
||||
glyph->info.width,
|
||||
glyph->info.height);
|
||||
FreePicture(picture, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
glamor_copy_area(&pGlyphPixmap->drawable,
|
||||
&scratch->drawable,
|
||||
gc,
|
||||
0, 0,
|
||||
glyph->info.width, glyph->info.height, 0, 0);
|
||||
gc, 0, 0,
|
||||
glyph->info.width,
|
||||
glyph->info.height, 0, 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
scratch = pGlyphPixmap;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
glamor_copy_area(&scratch->drawable, &pCachePixmap->drawable, gc,
|
||||
0, 0, glyph->info.width, glyph->info.height, x, y);
|
||||
0, 0, glyph->info.width, glyph->info.height, x,
|
||||
y);
|
||||
|
||||
if (scratch != pGlyphPixmap)
|
||||
screen->DestroyPixmap(scratch);
|
||||
|
@ -326,14 +325,12 @@ glamor_glyph_extents (int nlist,
|
|||
x1 = y1 = MAXSHORT;
|
||||
x2 = y2 = MINSHORT;
|
||||
x = y = 0;
|
||||
while (nlist--)
|
||||
{
|
||||
while (nlist--) {
|
||||
x += list->xOff;
|
||||
y += list->yOff;
|
||||
n = list->len;
|
||||
list++;
|
||||
while (n--)
|
||||
{
|
||||
while (n--) {
|
||||
GlyphPtr glyph = *glyphs++;
|
||||
int v;
|
||||
|
||||
|
@ -381,18 +378,16 @@ glamor_glyphs_intersect (int nlist, GlyphListPtr list, GlyphPtr * glyphs)
|
|||
extents.y1 = 0;
|
||||
extents.x2 = 0;
|
||||
extents.y2 = 0;
|
||||
while (nlist--)
|
||||
{
|
||||
while (nlist--) {
|
||||
x += list->xOff;
|
||||
y += list->yOff;
|
||||
n = list->len;
|
||||
list++;
|
||||
while (n--)
|
||||
{
|
||||
while (n--) {
|
||||
GlyphPtr glyph = *glyphs++;
|
||||
|
||||
if (glyph->info.width == 0 || glyph->info.height == 0)
|
||||
{
|
||||
if (glyph->info.width == 0
|
||||
|| glyph->info.height == 0) {
|
||||
x += glyph->info.xOff;
|
||||
y += glyph->info.yOff;
|
||||
continue;
|
||||
|
@ -411,19 +406,16 @@ glamor_glyphs_intersect (int nlist, GlyphListPtr list, GlyphPtr * glyphs)
|
|||
if (y2 > MAXSHORT)
|
||||
y2 = MAXSHORT;
|
||||
|
||||
if (first)
|
||||
{
|
||||
if (first) {
|
||||
extents.x1 = x1;
|
||||
extents.y1 = y1;
|
||||
extents.x2 = x2;
|
||||
extents.y2 = y2;
|
||||
first = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x1 < extents.x2 && x2 > extents.x1 &&
|
||||
y1 < extents.y2 && y2 > extents.y1)
|
||||
{
|
||||
} else {
|
||||
if (x1 < extents.x2 && x2 > extents.x1
|
||||
&& y1 < extents.y2
|
||||
&& y2 > extents.y1) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -461,16 +453,19 @@ glamor_glyph_count_to_mask (int count)
|
|||
static inline unsigned int
|
||||
glamor_glyph_size_to_mask(int size)
|
||||
{
|
||||
return glamor_glyph_count_to_mask (glamor_glyph_size_to_count (size));
|
||||
return
|
||||
glamor_glyph_count_to_mask(glamor_glyph_size_to_count(size));
|
||||
}
|
||||
|
||||
static PicturePtr
|
||||
glamor_glyph_cache (ScreenPtr screen, GlyphPtr glyph, int *out_x, int *out_y)
|
||||
glamor_glyph_cache(ScreenPtr screen, GlyphPtr glyph, int *out_x,
|
||||
int *out_y)
|
||||
{
|
||||
glamor_screen_private *glamor = glamor_get_screen_private(screen);
|
||||
PicturePtr glyph_picture = GlyphPicture(glyph)[screen->myNum];
|
||||
glamor_glyph_cache_t *cache =
|
||||
&glamor->glyphCaches[PICT_FORMAT_RGB (glyph_picture->format) != 0];
|
||||
&glamor->glyphCaches[PICT_FORMAT_RGB(glyph_picture->format) !=
|
||||
0];
|
||||
struct glamor_glyph *priv = NULL;
|
||||
int size, mask, pos, s;
|
||||
|
||||
|
@ -479,51 +474,48 @@ glamor_glyph_cache (ScreenPtr screen, GlyphPtr glyph, int *out_x, int *out_y)
|
|||
return NULL;
|
||||
|
||||
for (size = GLYPH_MIN_SIZE; size <= GLYPH_MAX_SIZE; size *= 2)
|
||||
if (glyph->info.width <= size && glyph->info.height <= size)
|
||||
if (glyph->info.width <= size
|
||||
&& glyph->info.height <= size)
|
||||
break;
|
||||
|
||||
s = glamor_glyph_size_to_count(size);
|
||||
mask = glamor_glyph_count_to_mask(s);
|
||||
pos = (cache->count + s - 1) & mask;
|
||||
if (pos < GLYPH_CACHE_SIZE)
|
||||
{
|
||||
if (pos < GLYPH_CACHE_SIZE) {
|
||||
cache->count = pos + s;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (s = size; s <= GLYPH_MAX_SIZE; s *= 2)
|
||||
{
|
||||
int i = cache->evict & glamor_glyph_size_to_mask (s);
|
||||
} else {
|
||||
for (s = size; s <= GLYPH_MAX_SIZE; s *= 2) {
|
||||
int i =
|
||||
cache->evict & glamor_glyph_size_to_mask(s);
|
||||
GlyphPtr evicted = cache->glyphs[i];
|
||||
if (evicted == NULL)
|
||||
continue;
|
||||
|
||||
priv = glamor_glyph_get_private(evicted);
|
||||
if (priv->size >= s)
|
||||
{
|
||||
if (priv->size >= s) {
|
||||
cache->glyphs[i] = NULL;
|
||||
glamor_glyph_set_private(evicted, NULL);
|
||||
pos = cache->evict & glamor_glyph_size_to_mask (size);
|
||||
}
|
||||
else
|
||||
pos = cache->evict &
|
||||
glamor_glyph_size_to_mask(size);
|
||||
} else
|
||||
priv = NULL;
|
||||
break;
|
||||
}
|
||||
if (priv == NULL)
|
||||
{
|
||||
if (priv == NULL) {
|
||||
int count = glamor_glyph_size_to_count(size);
|
||||
mask = glamor_glyph_count_to_mask(count);
|
||||
pos = cache->evict & mask;
|
||||
for (s = 0; s < count; s++)
|
||||
{
|
||||
for (s = 0; s < count; s++) {
|
||||
GlyphPtr evicted = cache->glyphs[pos + s];
|
||||
if (evicted != NULL)
|
||||
{
|
||||
if (evicted != NULL) {
|
||||
if (priv != NULL)
|
||||
free(priv);
|
||||
|
||||
priv = glamor_glyph_get_private (evicted);
|
||||
glamor_glyph_set_private (evicted, NULL);
|
||||
priv =
|
||||
glamor_glyph_get_private
|
||||
(evicted);
|
||||
glamor_glyph_set_private(evicted,
|
||||
NULL);
|
||||
cache->glyphs[pos + s] = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -532,8 +524,7 @@ glamor_glyph_cache (ScreenPtr screen, GlyphPtr glyph, int *out_x, int *out_y)
|
|||
cache->evict = rand() % GLYPH_CACHE_SIZE;
|
||||
}
|
||||
|
||||
if (priv == NULL)
|
||||
{
|
||||
if (priv == NULL) {
|
||||
priv = malloc(sizeof(struct glamor_glyph));
|
||||
if (priv == NULL)
|
||||
return NULL;
|
||||
|
@ -545,13 +536,13 @@ glamor_glyph_cache (ScreenPtr screen, GlyphPtr glyph, int *out_x, int *out_y)
|
|||
priv->cache = cache;
|
||||
priv->size = size;
|
||||
priv->pos = pos;
|
||||
s =
|
||||
pos / ((GLYPH_MAX_SIZE / GLYPH_MIN_SIZE) *
|
||||
s = pos / ((GLYPH_MAX_SIZE / GLYPH_MIN_SIZE) *
|
||||
(GLYPH_MAX_SIZE / GLYPH_MIN_SIZE));
|
||||
priv->x = s % (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE) * GLYPH_MAX_SIZE;
|
||||
priv->y = (s / (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE)) * GLYPH_MAX_SIZE;
|
||||
for (s = GLYPH_MIN_SIZE; s < GLYPH_MAX_SIZE; s *= 2)
|
||||
{
|
||||
priv->x =
|
||||
s % (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE) * GLYPH_MAX_SIZE;
|
||||
priv->y =
|
||||
(s / (CACHE_PICTURE_SIZE / GLYPH_MAX_SIZE)) * GLYPH_MAX_SIZE;
|
||||
for (s = GLYPH_MIN_SIZE; s < GLYPH_MAX_SIZE; s *= 2) {
|
||||
if (pos & 1)
|
||||
priv->x += s;
|
||||
if (pos & 2)
|
||||
|
@ -559,7 +550,8 @@ glamor_glyph_cache (ScreenPtr screen, GlyphPtr glyph, int *out_x, int *out_y)
|
|||
pos >>= 2;
|
||||
}
|
||||
|
||||
glamor_glyph_cache_upload_glyph (screen, cache, glyph, priv->x, priv->y);
|
||||
glamor_glyph_cache_upload_glyph(screen, cache, glyph, priv->x,
|
||||
priv->y);
|
||||
|
||||
*out_x = priv->x;
|
||||
*out_y = priv->y;
|
||||
|
@ -571,7 +563,8 @@ glamor_buffer_glyph (ScreenPtr screen,
|
|||
glamor_glyph_buffer_t * buffer,
|
||||
GlyphPtr glyph, int x_glyph, int y_glyph)
|
||||
{
|
||||
glamor_screen_private *glamor_screen = glamor_get_screen_private (screen);
|
||||
glamor_screen_private *glamor_screen =
|
||||
glamor_get_screen_private(screen);
|
||||
unsigned int format = (GlyphPicture(glyph)[screen->myNum])->format;
|
||||
glamor_composite_rect_t *rect;
|
||||
PicturePtr source;
|
||||
|
@ -583,7 +576,9 @@ glamor_buffer_glyph (ScreenPtr screen,
|
|||
if (PICT_FORMAT_BPP(format) == 1)
|
||||
format = PICT_a8;
|
||||
|
||||
cache = &glamor_screen->glyphCaches[PICT_FORMAT_RGB (glyph_picture->format) != 0];
|
||||
cache =
|
||||
&glamor_screen->glyphCaches[PICT_FORMAT_RGB
|
||||
(glyph_picture->format) != 0];
|
||||
|
||||
if (buffer->source && buffer->source != cache->picture)
|
||||
return GLAMOR_GLYPH_NEED_FLUSH;
|
||||
|
@ -593,25 +588,21 @@ glamor_buffer_glyph (ScreenPtr screen,
|
|||
|
||||
priv = glamor_glyph_get_private(glyph);
|
||||
|
||||
if (priv)
|
||||
{
|
||||
if (priv) {
|
||||
rect = &buffer->rects[buffer->count++];
|
||||
rect->x_src = priv->x;
|
||||
rect->y_src = priv->y;
|
||||
if (buffer->source == NULL) buffer->source = priv->cache->picture;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buffer->source == NULL)
|
||||
buffer->source = priv->cache->picture;
|
||||
} else {
|
||||
source = glamor_glyph_cache(screen, glyph, &x, &y);
|
||||
if (source != NULL)
|
||||
{
|
||||
if (source != NULL) {
|
||||
rect = &buffer->rects[buffer->count++];
|
||||
rect->x_src = x;
|
||||
rect->y_src = y;
|
||||
if (buffer->source == NULL) buffer->source = source;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (buffer->source == NULL)
|
||||
buffer->source = source;
|
||||
} else {
|
||||
source = GlyphPicture(glyph)[screen->myNum];
|
||||
if (buffer->source && buffer->source != source)
|
||||
return GLAMOR_GLYPH_NEED_FLUSH;
|
||||
|
@ -676,9 +667,9 @@ glamor_glyphs_via_mask (CARD8 op,
|
|||
width = extents.x2 - extents.x1;
|
||||
height = extents.y2 - extents.y1;
|
||||
|
||||
if (mask_format->depth == 1)
|
||||
{
|
||||
PictFormatPtr a8Format = PictureMatchFormat (screen, 8, PICT_a8);
|
||||
if (mask_format->depth == 1) {
|
||||
PictFormatPtr a8Format =
|
||||
PictureMatchFormat(screen, 8, PICT_a8);
|
||||
|
||||
if (a8Format)
|
||||
mask_format = a8Format;
|
||||
|
@ -693,8 +684,7 @@ glamor_glyphs_via_mask (CARD8 op,
|
|||
mask = CreatePicture(0, &mask_pixmap->drawable,
|
||||
mask_format, CPComponentAlpha,
|
||||
&component_alpha, serverClient, &error);
|
||||
if (!mask)
|
||||
{
|
||||
if (!mask) {
|
||||
screen->DestroyPixmap(mask_pixmap);
|
||||
return;
|
||||
}
|
||||
|
@ -707,23 +697,24 @@ glamor_glyphs_via_mask (CARD8 op,
|
|||
|
||||
buffer.count = 0;
|
||||
buffer.source = NULL;
|
||||
while (nlist--)
|
||||
{
|
||||
while (nlist--) {
|
||||
x += list->xOff;
|
||||
y += list->yOff;
|
||||
n = list->len;
|
||||
while (n--)
|
||||
{
|
||||
while (n--) {
|
||||
glyph = *glyphs++;
|
||||
|
||||
if (glyph->info.width > 0 && glyph->info.height > 0 &&
|
||||
glamor_buffer_glyph (screen, &buffer, glyph, x,
|
||||
y) == GLAMOR_GLYPH_NEED_FLUSH)
|
||||
{
|
||||
if (glyph->info.width > 0
|
||||
&& glyph->info.height > 0
|
||||
&& glamor_buffer_glyph(screen, &buffer,
|
||||
glyph, x,
|
||||
y) ==
|
||||
GLAMOR_GLYPH_NEED_FLUSH) {
|
||||
|
||||
glamor_glyphs_flush_mask(mask, &buffer);
|
||||
|
||||
glamor_buffer_glyph (screen, &buffer, glyph, x, y);
|
||||
glamor_buffer_glyph(screen, &buffer,
|
||||
glyph, x, y);
|
||||
}
|
||||
|
||||
x += glyph->info.xOff;
|
||||
|
@ -756,8 +747,7 @@ glamor_glyphs_flush_dst (CARD8 op,
|
|||
{
|
||||
int i;
|
||||
glamor_composite_rect_t *rect = &buffer->rects[0];
|
||||
for (i = 0; i < buffer->count; i++, rect++)
|
||||
{
|
||||
for (i = 0; i < buffer->count; i++, rect++) {
|
||||
rect->x_mask = rect->x_src;
|
||||
rect->y_mask = rect->y_src;
|
||||
rect->x_src = x_src + rect->x_dst - x_dst;
|
||||
|
@ -788,22 +778,25 @@ glamor_glyphs_to_dst (CARD8 op,
|
|||
|
||||
buffer.count = 0;
|
||||
buffer.source = NULL;
|
||||
while (nlist--)
|
||||
{
|
||||
while (nlist--) {
|
||||
x += list->xOff;
|
||||
y += list->yOff;
|
||||
n = list->len;
|
||||
while (n--)
|
||||
{
|
||||
while (n--) {
|
||||
glyph = *glyphs++;
|
||||
|
||||
if (glyph->info.width > 0 && glyph->info.height > 0 &&
|
||||
glamor_buffer_glyph (screen, &buffer, glyph, x,
|
||||
y) == GLAMOR_GLYPH_NEED_FLUSH)
|
||||
{
|
||||
if (glyph->info.width > 0
|
||||
&& glyph->info.height > 0
|
||||
&& glamor_buffer_glyph(screen, &buffer,
|
||||
glyph, x,
|
||||
y) ==
|
||||
GLAMOR_GLYPH_NEED_FLUSH) {
|
||||
glamor_glyphs_flush_dst(op, src, dst,
|
||||
&buffer, x_src, y_src, x_dst, y_dst);
|
||||
glamor_buffer_glyph (screen, &buffer, glyph, x, y);
|
||||
&buffer, x_src,
|
||||
y_src, x_dst,
|
||||
y_dst);
|
||||
glamor_buffer_glyph(screen, &buffer,
|
||||
glyph, x, y);
|
||||
}
|
||||
|
||||
x += glyph->info.xOff;
|
||||
|
@ -829,25 +822,22 @@ glamor_glyphs (CARD8 op,
|
|||
* and don't intersect, use the glyph format as mask format for the full
|
||||
* benefits of the glyph cache.
|
||||
*/
|
||||
if (!mask_format)
|
||||
{
|
||||
if (!mask_format) {
|
||||
Bool same_format = TRUE;
|
||||
int i;
|
||||
|
||||
mask_format = list[0].format;
|
||||
|
||||
for (i = 0; i < nlist; i++)
|
||||
{
|
||||
if (mask_format->format != list[i].format->format)
|
||||
{
|
||||
for (i = 0; i < nlist; i++) {
|
||||
if (mask_format->format != list[i].format->format) {
|
||||
same_format = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!same_format || (mask_format->depth != 1 &&
|
||||
glamor_glyphs_intersect (nlist, list, glyphs)))
|
||||
{
|
||||
glamor_glyphs_intersect(nlist, list,
|
||||
glyphs))) {
|
||||
mask_format = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -856,5 +846,6 @@ glamor_glyphs (CARD8 op,
|
|||
glamor_glyphs_via_mask(op, src, dst, mask_format,
|
||||
x_src, y_src, nlist, list, glyphs);
|
||||
else
|
||||
glamor_glyphs_to_dst (op, src, dst, x_src, y_src, nlist, list, glyphs);
|
||||
glamor_glyphs_to_dst(op, src, dst, x_src, y_src, nlist,
|
||||
list, glyphs);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,8 @@ glamor_create_picture(PicturePtr picture)
|
|||
if (!picture || !picture->pDrawable)
|
||||
return 0;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(picture->pDrawable->pScreen);
|
||||
glamor_priv =
|
||||
glamor_get_screen_private(picture->pDrawable->pScreen);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
assert(pixmap_priv);
|
||||
|
@ -76,7 +77,8 @@ glamor_destroy_picture(PicturePtr picture)
|
|||
if (!picture || !picture->pDrawable)
|
||||
return;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(picture->pDrawable->pScreen);
|
||||
glamor_priv =
|
||||
glamor_get_screen_private(picture->pDrawable->pScreen);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
assert(pixmap_priv);
|
||||
|
@ -86,8 +88,9 @@ glamor_destroy_picture(PicturePtr picture)
|
|||
glamor_priv->saved_destroy_picture(picture);
|
||||
}
|
||||
|
||||
void glamor_picture_format_fixup(PicturePtr picture, glamor_pixmap_private *pixmap_priv)
|
||||
void
|
||||
glamor_picture_format_fixup(PicturePtr picture,
|
||||
glamor_pixmap_private * pixmap_priv)
|
||||
{
|
||||
pixmap_priv->pict_format = picture->format;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,9 @@ _glamor_pixmap_validate_filling(glamor_screen_private *glamor_priv,
|
|||
{
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
GLfloat vertices[8];
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float), vertices);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glUseProgram(glamor_priv->solid_prog);
|
||||
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location,
|
||||
|
@ -62,7 +63,8 @@ glamor_pixmap_validate_function_t pixmap_validate_funcs[] = {
|
|||
void
|
||||
glamor_pixmap_init(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_priv->pixmap_validate_funcs = pixmap_validate_funcs;
|
||||
}
|
||||
|
||||
|
@ -75,7 +77,9 @@ glamor_validate_pixmap(PixmapPtr pixmap)
|
|||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
|
||||
validate_op = glamor_priv->pixmap_validate_funcs[pixmap_priv->pending_op.type];
|
||||
validate_op =
|
||||
glamor_priv->pixmap_validate_funcs[pixmap_priv->
|
||||
pending_op.type];
|
||||
if (validate_op) {
|
||||
(*validate_op) (glamor_priv, pixmap_priv);
|
||||
}
|
||||
|
@ -112,7 +116,8 @@ int
|
|||
glamor_set_destination_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
int err;
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
|
||||
err = glamor_set_destination_pixmap_priv(pixmap_priv);
|
||||
return err;
|
||||
|
@ -204,10 +209,13 @@ glamor_set_alu(struct glamor_gl_dispatch *dispatch, unsigned char alu)
|
|||
**/
|
||||
int in_restore = 0;
|
||||
static void
|
||||
__glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type, GLuint tex)
|
||||
__glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
|
||||
GLenum type, GLuint tex)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
unsigned int stride, row_length;
|
||||
void *texels;
|
||||
|
@ -239,24 +247,23 @@ __glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format, GLenum type,
|
|||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
}
|
||||
|
||||
if (pixmap_priv->pbo && pixmap_priv->pbo_valid) {
|
||||
texels = NULL;
|
||||
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pixmap_priv->pbo);
|
||||
}
|
||||
else
|
||||
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
|
||||
pixmap_priv->pbo);
|
||||
} else
|
||||
texels = pixmap->devPrivate.ptr;
|
||||
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
iformat,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height, 0,
|
||||
format, type, texels);
|
||||
pixmap->drawable.height, 0, format, type,
|
||||
texels);
|
||||
}
|
||||
|
||||
|
||||
|
@ -271,22 +278,26 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
|
|||
int flip)
|
||||
{
|
||||
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
static float vertices[8] = { -1, -1,
|
||||
1, -1,
|
||||
1, 1,
|
||||
-1, 1};
|
||||
-1, 1
|
||||
};
|
||||
static float texcoords[8] = { 0, 1,
|
||||
1, 1,
|
||||
1, 0,
|
||||
0, 0};
|
||||
0, 0
|
||||
};
|
||||
static float texcoords_inv[8] = { 0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
0, 1};
|
||||
0, 1
|
||||
};
|
||||
float *ptexcoords;
|
||||
|
||||
GLuint tex;
|
||||
|
@ -296,7 +307,8 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
|
|||
/* Try fast path firstly, upload the pixmap to the texture attached
|
||||
* to the fbo directly. */
|
||||
if (no_alpha == 0 && no_revert == 1 && !need_flip) {
|
||||
__glamor_upload_pixmap_to_texture(pixmap, format, type, pixmap_priv->tex);
|
||||
__glamor_upload_pixmap_to_texture(pixmap, format, type,
|
||||
pixmap_priv->tex);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -307,12 +319,12 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
|
|||
ptexcoords = texcoords_inv;
|
||||
|
||||
/* Slow path, we need to flip y or wire alpha to 1. */
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
ptexcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
|
@ -323,14 +335,19 @@ _glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
|
|||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_no_revert[no_alpha], no_revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],0);
|
||||
dispatch->glUniform1i(glamor_priv->
|
||||
finish_access_no_revert[no_alpha],
|
||||
no_revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
|
||||
0);
|
||||
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
|
@ -348,7 +365,8 @@ void
|
|||
glamor_pixmap_ensure_fb(PixmapPtr pixmap)
|
||||
{
|
||||
int status;
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_gl_dispatch *dispatch = &pixmap_priv->glamor_priv->dispatch;
|
||||
|
||||
if (pixmap_priv->fb == 0)
|
||||
|
@ -357,20 +375,33 @@ glamor_pixmap_ensure_fb(PixmapPtr pixmap)
|
|||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, pixmap_priv->fb);
|
||||
dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D,
|
||||
pixmap_priv->tex,
|
||||
GL_TEXTURE_2D, pixmap_priv->tex,
|
||||
0);
|
||||
status = dispatch->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
const char *str;
|
||||
switch (status) {
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: str= "incomplete attachment"; break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: str= "incomplete/missing attachment"; break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: str= "incomplete draw buffer"; break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: str= "incomplete read buffer"; break;
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED: str= "unsupported"; break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: str= "incomplete multiple"; break;
|
||||
default: str = "unknown error"; break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
||||
str = "incomplete attachment";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
||||
str = "incomplete/missing attachment";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
|
||||
str = "incomplete draw buffer";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
|
||||
str = "incomplete read buffer";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED:
|
||||
str = "unsupported";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
||||
str = "incomplete multiple";
|
||||
break;
|
||||
default:
|
||||
str = "unknown error";
|
||||
break;
|
||||
}
|
||||
|
||||
LogMessageVerb(X_INFO, 0,
|
||||
|
@ -391,14 +422,19 @@ static int
|
|||
glamor_pixmap_upload_prepare(PixmapPtr pixmap, int no_alpha, int no_revert)
|
||||
{
|
||||
int need_fbo;
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
|
||||
if (!glamor_check_fbo_size(glamor_priv, pixmap->drawable.width , pixmap->drawable.height)
|
||||
if (!glamor_check_fbo_size
|
||||
(glamor_priv, pixmap->drawable.width, pixmap->drawable.height)
|
||||
|| !glamor_check_fbo_depth(pixmap->drawable.depth)) {
|
||||
glamor_fallback("upload failed reason: bad size or depth %d x %d @depth %d \n",
|
||||
pixmap->drawable.width, pixmap->drawable.height, pixmap->drawable.depth);
|
||||
glamor_fallback
|
||||
("upload failed reason: bad size or depth %d x %d @depth %d \n",
|
||||
pixmap->drawable.width, pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -415,11 +451,16 @@ glamor_pixmap_upload_prepare(PixmapPtr pixmap, int no_alpha, int no_revert)
|
|||
|
||||
if (need_fbo) {
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, pixmap_priv->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, pixmap->drawable.width,
|
||||
pixmap->drawable.height, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, NULL);
|
||||
glamor_pixmap_ensure_fb(pixmap);
|
||||
}
|
||||
|
||||
|
@ -434,10 +475,10 @@ glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
|
|||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&no_alpha,
|
||||
&type, &no_alpha,
|
||||
&no_revert)) {
|
||||
glamor_fallback("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
|
||||
glamor_fallback("Unknown pixmap depth %d.\n",
|
||||
pixmap->drawable.depth);
|
||||
return GLAMOR_UPLOAD_FAILED;
|
||||
}
|
||||
if (glamor_pixmap_upload_prepare(pixmap, no_alpha, no_revert))
|
||||
|
@ -448,7 +489,8 @@ glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
|
|||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
_glamor_upload_pixmap_to_texture(pixmap, format, type, no_alpha, no_revert, 1);
|
||||
_glamor_upload_pixmap_to_texture(pixmap, format, type, no_alpha,
|
||||
no_revert, 1);
|
||||
return GLAMOR_UPLOAD_DONE;
|
||||
}
|
||||
|
||||
|
@ -457,7 +499,8 @@ enum glamor_pixmap_status
|
|||
glamor_upload_pixmap_to_texure_from_data(PixmapPtr pixmap, void *data)
|
||||
{
|
||||
enum glamor_pixmap_status upload_status;
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
|
||||
assert(pixmap_priv->pbo_valid == 0);
|
||||
assert(pixmap->devPrivate.ptr == NULL);
|
||||
|
@ -476,15 +519,16 @@ glamor_restore_pixmap_to_texture(PixmapPtr pixmap)
|
|||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&no_alpha,
|
||||
&type, &no_alpha,
|
||||
&no_revert)) {
|
||||
ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
|
||||
ErrorF("Unknown pixmap depth %d.\n",
|
||||
pixmap->drawable.depth);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
in_restore = 1;
|
||||
_glamor_upload_pixmap_to_texture(pixmap, format, type, no_alpha, no_revert, 1);
|
||||
_glamor_upload_pixmap_to_texture(pixmap, format, type, no_alpha,
|
||||
no_revert, 1);
|
||||
in_restore = 0;
|
||||
}
|
||||
|
||||
|
@ -509,11 +553,13 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum *format,
|
|||
static float vertices[8] = { -1, -1,
|
||||
1, -1,
|
||||
1, 1,
|
||||
-1, 1};
|
||||
-1, 1
|
||||
};
|
||||
static float texcoords[8] = { 0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
0, 1};
|
||||
0, 1
|
||||
};
|
||||
|
||||
int swap_rb = 0;
|
||||
|
||||
|
@ -531,23 +577,23 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum *format,
|
|||
temp_pixmap = (*screen->CreatePixmap) (screen,
|
||||
source->drawable.width,
|
||||
source->drawable.height,
|
||||
source->drawable.depth,
|
||||
0);
|
||||
source->drawable.depth, 0);
|
||||
|
||||
temp_pixmap_priv = glamor_get_pixmap_private(temp_pixmap);
|
||||
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, temp_pixmap_priv->tex);
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, *format, source->drawable.width,
|
||||
source->drawable.height, 0,
|
||||
*format, *type, NULL);
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, *format,
|
||||
source->drawable.width,
|
||||
source->drawable.height, 0, *format, *type,
|
||||
NULL);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
|
@ -557,8 +603,11 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum *format,
|
|||
glamor_set_destination_pixmap_priv_nc(temp_pixmap_priv);
|
||||
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_no_revert[no_alpha], no_revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], swap_rb);
|
||||
dispatch->glUniform1i(glamor_priv->
|
||||
finish_access_no_revert[no_alpha],
|
||||
no_revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
|
||||
swap_rb);
|
||||
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
|
@ -582,7 +631,8 @@ glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum *format,
|
|||
Bool
|
||||
glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
unsigned int stride, row_length, y;
|
||||
GLenum format, type, gl_access, gl_usage;
|
||||
int no_alpha, no_revert;
|
||||
|
@ -598,10 +648,10 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
|||
return TRUE;
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&no_alpha,
|
||||
&type, &no_alpha,
|
||||
&no_revert)) {
|
||||
ErrorF("Unknown pixmap depth %d.\n", pixmap->drawable.depth);
|
||||
ErrorF("Unknown pixmap depth %d.\n",
|
||||
pixmap->drawable.depth);
|
||||
assert(0); // Should never happen.
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -622,9 +672,14 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
|||
glamor_validate_pixmap(pixmap);
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
|
||||
&& ((format != GL_RGBA && format != GL_RGB && format != GL_ALPHA) || no_revert != 1)) {
|
||||
&&
|
||||
((format != GL_RGBA && format != GL_RGB && format != GL_ALPHA)
|
||||
|| no_revert != 1)) {
|
||||
|
||||
temp_pixmap = glamor_es2_pixmap_read_prepare(pixmap, &format, &type, no_alpha, no_revert);
|
||||
temp_pixmap =
|
||||
glamor_es2_pixmap_read_prepare(pixmap, &format,
|
||||
&type, no_alpha,
|
||||
no_revert);
|
||||
|
||||
}
|
||||
switch (access) {
|
||||
|
@ -652,34 +707,40 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
|||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
|
||||
dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
dispatch->glPixelStorei(GL_PACK_ROW_LENGTH, row_length);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
// dispatch->glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
}
|
||||
if (glamor_priv->has_pack_invert || glamor_priv->yInverted) {
|
||||
|
||||
if (!glamor_priv->yInverted) {
|
||||
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
|
||||
assert(glamor_priv->gl_flavor ==
|
||||
GLAMOR_GL_DESKTOP);
|
||||
dispatch->glPixelStorei(GL_PACK_INVERT_MESA, 1);
|
||||
}
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
|
||||
if (pixmap_priv->pbo == 0)
|
||||
dispatch->glGenBuffers (1, &pixmap_priv->pbo);
|
||||
dispatch->glBindBuffer (GL_PIXEL_PACK_BUFFER, pixmap_priv->pbo);
|
||||
dispatch->glGenBuffers(1,
|
||||
&pixmap_priv->pbo);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
pixmap_priv->pbo);
|
||||
dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
|
||||
stride * pixmap->drawable.height,
|
||||
stride *
|
||||
pixmap->drawable.height,
|
||||
NULL, gl_usage);
|
||||
dispatch->glReadPixels (0, 0,
|
||||
row_length, pixmap->drawable.height,
|
||||
dispatch->glReadPixels(0, 0, row_length,
|
||||
pixmap->drawable.height,
|
||||
format, type, 0);
|
||||
data = dispatch->glMapBuffer (GL_PIXEL_PACK_BUFFER, gl_access);
|
||||
data = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
gl_access);
|
||||
pixmap_priv->pbo_valid = TRUE;
|
||||
|
||||
if (!glamor_priv->yInverted) {
|
||||
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
|
||||
dispatch->glPixelStorei(GL_PACK_INVERT_MESA, 0);
|
||||
assert(glamor_priv->gl_flavor ==
|
||||
GLAMOR_GL_DESKTOP);
|
||||
dispatch->glPixelStorei
|
||||
(GL_PACK_INVERT_MESA, 0);
|
||||
}
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
|
||||
|
@ -687,7 +748,8 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
|||
if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV)
|
||||
type = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
dispatch->glReadPixels(0, 0,
|
||||
pixmap->drawable.width, pixmap->drawable.height,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
format, type, data);
|
||||
}
|
||||
} else {
|
||||
|
@ -695,18 +757,24 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
|||
assert(data);
|
||||
if (access != GLAMOR_ACCESS_WO) {
|
||||
if (pixmap_priv->pbo == 0)
|
||||
dispatch->glGenBuffers(1, &pixmap_priv->pbo);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, pixmap_priv->pbo);
|
||||
dispatch->glGenBuffers(1,
|
||||
&pixmap_priv->pbo);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
pixmap_priv->pbo);
|
||||
dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
|
||||
stride * pixmap->drawable.height,
|
||||
stride *
|
||||
pixmap->drawable.height,
|
||||
NULL, GL_STREAM_READ);
|
||||
dispatch->glReadPixels (0, 0, row_length, pixmap->drawable.height,
|
||||
dispatch->glReadPixels(0, 0, row_length,
|
||||
pixmap->drawable.height,
|
||||
format, type, 0);
|
||||
read = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY);
|
||||
read = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
GL_READ_ONLY);
|
||||
|
||||
for (y = 0; y < pixmap->drawable.height; y++)
|
||||
memcpy(data + y * stride,
|
||||
read + (pixmap->drawable.height - y - 1) * stride, stride);
|
||||
read + (pixmap->drawable.height -
|
||||
y - 1) * stride, stride);
|
||||
dispatch->glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
pixmap_priv->pbo_valid = FALSE;
|
||||
|
@ -731,7 +799,8 @@ done:
|
|||
static void
|
||||
_glamor_destroy_upload_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_gl_dispatch *dispatch = &pixmap_priv->glamor_priv->dispatch;
|
||||
|
||||
assert(pixmap_priv->gl_fbo == 0);
|
||||
|
@ -745,8 +814,8 @@ _glamor_destroy_upload_pixmap(PixmapPtr pixmap)
|
|||
|
||||
}
|
||||
|
||||
void glamor_destroy_upload_pixmap(PixmapPtr pixmap)
|
||||
void
|
||||
glamor_destroy_upload_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
_glamor_destroy_upload_pixmap(pixmap);
|
||||
}
|
||||
|
||||
|
|
821
glamor/glamor_pixmap.indent.c
Normal file
821
glamor/glamor_pixmap.indent.c
Normal file
|
@ -0,0 +1,821 @@
|
|||
#ifdef HAVE_DIX_CONFIG_H
|
||||
#include <dix-config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "glamor_priv.h"
|
||||
/**
|
||||
* Sets the offsets to add to coordinates to make them address the same bits in
|
||||
* the backing drawable. These coordinates are nonzero only for redirected
|
||||
* windows.
|
||||
*/
|
||||
void
|
||||
glamor_get_drawable_deltas(DrawablePtr drawable, PixmapPtr pixmap,
|
||||
int *x, int *y)
|
||||
{
|
||||
#ifdef COMPOSITE
|
||||
if (drawable->type == DRAWABLE_WINDOW) {
|
||||
*x = -pixmap->screen_x;
|
||||
*y = -pixmap->screen_y;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
*x = 0;
|
||||
*y = 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_glamor_pixmap_validate_filling(glamor_screen_private * glamor_priv,
|
||||
glamor_pixmap_private * pixmap_priv)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
GLfloat vertices[8];
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glUseProgram(glamor_priv->solid_prog);
|
||||
dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location,
|
||||
1, pixmap_priv->pending_op.fill.color4fv);
|
||||
vertices[0] = -1;
|
||||
vertices[1] = -1;
|
||||
vertices[2] = 1;
|
||||
vertices[3] = -1;
|
||||
vertices[4] = 1;
|
||||
vertices[5] = 1;
|
||||
vertices[6] = -1;
|
||||
vertices[7] = 1;
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glUseProgram(0);
|
||||
pixmap_priv->pending_op.type = GLAMOR_PENDING_NONE;
|
||||
}
|
||||
|
||||
|
||||
glamor_pixmap_validate_function_t pixmap_validate_funcs[] = {
|
||||
NULL,
|
||||
_glamor_pixmap_validate_filling
|
||||
};
|
||||
|
||||
void
|
||||
glamor_pixmap_init(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_priv->pixmap_validate_funcs = pixmap_validate_funcs;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_validate_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_validate_function_t validate_op;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
|
||||
validate_op =
|
||||
glamor_priv->pixmap_validate_funcs[pixmap_priv->
|
||||
pending_op.type];
|
||||
if (validate_op) {
|
||||
(*validate_op) (glamor_priv, pixmap_priv);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private * pixmap_priv)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch = &pixmap_priv->glamor_priv->dispatch;
|
||||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, pixmap_priv->fb);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glMatrixMode(GL_PROJECTION);
|
||||
dispatch->glLoadIdentity();
|
||||
dispatch->glMatrixMode(GL_MODELVIEW);
|
||||
dispatch->glLoadIdentity();
|
||||
#endif
|
||||
dispatch->glViewport(0, 0,
|
||||
pixmap_priv->container->drawable.width,
|
||||
pixmap_priv->container->drawable.height);
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
glamor_set_destination_pixmap_priv(glamor_pixmap_private * pixmap_priv)
|
||||
{
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return -1;
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
glamor_set_destination_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
int err;
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
|
||||
err = glamor_set_destination_pixmap_priv(pixmap_priv);
|
||||
return err;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask)
|
||||
{
|
||||
if (glamor_pm_is_solid(&pixmap->drawable, planemask)) {
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
glamor_fallback("unsupported planemask %lx\n", planemask);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
glamor_set_alu(struct glamor_gl_dispatch *dispatch, unsigned char alu)
|
||||
{
|
||||
#ifndef GLAMOR_GLES2
|
||||
if (alu == GXcopy) {
|
||||
dispatch->glDisable(GL_COLOR_LOGIC_OP);
|
||||
return;
|
||||
}
|
||||
dispatch->glEnable(GL_COLOR_LOGIC_OP);
|
||||
switch (alu) {
|
||||
case GXclear:
|
||||
dispatch->glLogicOp(GL_CLEAR);
|
||||
break;
|
||||
case GXand:
|
||||
dispatch->glLogicOp(GL_AND);
|
||||
break;
|
||||
case GXandReverse:
|
||||
dispatch->glLogicOp(GL_AND_REVERSE);
|
||||
break;
|
||||
case GXandInverted:
|
||||
dispatch->glLogicOp(GL_AND_INVERTED);
|
||||
break;
|
||||
case GXnoop:
|
||||
dispatch->glLogicOp(GL_NOOP);
|
||||
break;
|
||||
case GXxor:
|
||||
dispatch->glLogicOp(GL_XOR);
|
||||
break;
|
||||
case GXor:
|
||||
dispatch->glLogicOp(GL_OR);
|
||||
break;
|
||||
case GXnor:
|
||||
dispatch->glLogicOp(GL_NOR);
|
||||
break;
|
||||
case GXequiv:
|
||||
dispatch->glLogicOp(GL_EQUIV);
|
||||
break;
|
||||
case GXinvert:
|
||||
dispatch->glLogicOp(GL_INVERT);
|
||||
break;
|
||||
case GXorReverse:
|
||||
dispatch->glLogicOp(GL_OR_REVERSE);
|
||||
break;
|
||||
case GXcopyInverted:
|
||||
dispatch->glLogicOp(GL_COPY_INVERTED);
|
||||
break;
|
||||
case GXorInverted:
|
||||
dispatch->glLogicOp(GL_OR_INVERTED);
|
||||
break;
|
||||
case GXnand:
|
||||
dispatch->glLogicOp(GL_NAND);
|
||||
break;
|
||||
case GXset:
|
||||
dispatch->glLogicOp(GL_SET);
|
||||
break;
|
||||
default:
|
||||
FatalError("unknown logic op\n");
|
||||
}
|
||||
#else
|
||||
if (alu != GXcopy)
|
||||
ErrorF("unsupported alu %x \n", alu);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Upload pixmap to a specified texture.
|
||||
* This texture may not be the one attached to it.
|
||||
**/
|
||||
int in_restore = 0;
|
||||
static void
|
||||
__glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
|
||||
GLenum type, GLuint tex)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
unsigned int stride, row_length;
|
||||
void *texels;
|
||||
GLenum iformat;
|
||||
|
||||
switch (pixmap->drawable.depth) {
|
||||
#if 0
|
||||
case 8:
|
||||
iformat = GL_ALPHA;
|
||||
break;
|
||||
#endif
|
||||
case 24:
|
||||
iformat = GL_RGB;
|
||||
break;
|
||||
default:
|
||||
iformat = GL_RGBA;
|
||||
break;
|
||||
}
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) {
|
||||
iformat = format;
|
||||
}
|
||||
|
||||
stride = pixmap->devKind;
|
||||
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
|
||||
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, row_length);
|
||||
} else {
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
}
|
||||
|
||||
if (pixmap_priv->pbo && pixmap_priv->pbo_valid) {
|
||||
texels = NULL;
|
||||
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
|
||||
pixmap_priv->pbo);
|
||||
} else
|
||||
texels = pixmap->devPrivate.ptr;
|
||||
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D,
|
||||
0,
|
||||
iformat,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height, 0, format, type,
|
||||
texels);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Load texture from the pixmap's data pointer and then
|
||||
* draw the texture to the fbo, and flip the y axis.
|
||||
* */
|
||||
|
||||
static void
|
||||
_glamor_upload_pixmap_to_texture(PixmapPtr pixmap, GLenum format,
|
||||
GLenum type, int no_alpha, int no_revert,
|
||||
int flip)
|
||||
{
|
||||
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
static float vertices[8] = { -1, -1,
|
||||
1, -1,
|
||||
1, 1,
|
||||
-1, 1
|
||||
};
|
||||
static float texcoords[8] = { 0, 1,
|
||||
1, 1,
|
||||
1, 0,
|
||||
0, 0
|
||||
};
|
||||
static float texcoords_inv[8] = { 0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
0, 1
|
||||
};
|
||||
float *ptexcoords;
|
||||
|
||||
GLuint tex;
|
||||
int need_flip;
|
||||
need_flip = (flip && !glamor_priv->yInverted);
|
||||
|
||||
/* Try fast path firstly, upload the pixmap to the texture attached
|
||||
* to the fbo directly. */
|
||||
if (no_alpha == 0 && no_revert == 1 && !need_flip) {
|
||||
__glamor_upload_pixmap_to_texture(pixmap, format, type,
|
||||
pixmap_priv->tex);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (need_flip)
|
||||
ptexcoords = texcoords;
|
||||
else
|
||||
ptexcoords = texcoords_inv;
|
||||
|
||||
/* Slow path, we need to flip y or wire alpha to 1. */
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
ptexcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
dispatch->glGenTextures(1, &tex);
|
||||
|
||||
__glamor_upload_pixmap_to_texture(pixmap, format, type, tex);
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
|
||||
dispatch->glUniform1i(glamor_priv->
|
||||
finish_access_no_revert[no_alpha],
|
||||
no_revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
|
||||
0);
|
||||
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glDisable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
dispatch->glUseProgram(0);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
dispatch->glDeleteTextures(1, &tex);
|
||||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_pixmap_ensure_fb(PixmapPtr pixmap)
|
||||
{
|
||||
int status;
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_gl_dispatch *dispatch = &pixmap_priv->glamor_priv->dispatch;
|
||||
|
||||
if (pixmap_priv->fb == 0)
|
||||
dispatch->glGenFramebuffers(1, &pixmap_priv->fb);
|
||||
assert(pixmap_priv->tex != 0);
|
||||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, pixmap_priv->fb);
|
||||
dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D, pixmap_priv->tex,
|
||||
0);
|
||||
status = dispatch->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
const char *str;
|
||||
switch (status) {
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT:
|
||||
str = "incomplete attachment";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:
|
||||
str = "incomplete/missing attachment";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER:
|
||||
str = "incomplete draw buffer";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER:
|
||||
str = "incomplete read buffer";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_UNSUPPORTED:
|
||||
str = "unsupported";
|
||||
break;
|
||||
case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE:
|
||||
str = "incomplete multiple";
|
||||
break;
|
||||
default:
|
||||
str = "unknown error";
|
||||
break;
|
||||
}
|
||||
|
||||
LogMessageVerb(X_INFO, 0,
|
||||
"destination is framebuffer incomplete: %s [%#x]\n",
|
||||
str, status);
|
||||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare to upload a pixmap to texture memory.
|
||||
* no_alpha equals 1 means the format needs to wire alpha to 1.
|
||||
* Two condtion need to setup a fbo for a pixmap
|
||||
* 1. !yInverted, we need to do flip if we are not yInverted.
|
||||
* 2. no_alpha != 0, we need to wire the alpha.
|
||||
* */
|
||||
static int
|
||||
glamor_pixmap_upload_prepare(PixmapPtr pixmap, int no_alpha, int no_revert)
|
||||
{
|
||||
int need_fbo;
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
|
||||
if (!glamor_check_fbo_size
|
||||
(glamor_priv, pixmap->drawable.width, pixmap->drawable.height)
|
||||
|| !glamor_check_fbo_depth(pixmap->drawable.depth)) {
|
||||
glamor_fallback
|
||||
("upload failed reason: bad size or depth %d x %d @depth %d \n",
|
||||
pixmap->drawable.width, pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return 0;
|
||||
|
||||
if (no_alpha != 0 || no_revert == 0 || !glamor_priv->yInverted)
|
||||
need_fbo = 1;
|
||||
else
|
||||
need_fbo = 0;
|
||||
|
||||
if (pixmap_priv->tex == 0)
|
||||
dispatch->glGenTextures(1, &pixmap_priv->tex);
|
||||
|
||||
if (need_fbo) {
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, pixmap_priv->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height, 0, GL_RGBA,
|
||||
GL_UNSIGNED_BYTE, NULL);
|
||||
glamor_pixmap_ensure_fb(pixmap);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_pixmap_to_texture(PixmapPtr pixmap)
|
||||
{
|
||||
GLenum format, type;
|
||||
int no_alpha, no_revert;
|
||||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type, &no_alpha,
|
||||
&no_revert)) {
|
||||
glamor_fallback("Unknown pixmap depth %d.\n",
|
||||
pixmap->drawable.depth);
|
||||
return GLAMOR_UPLOAD_FAILED;
|
||||
}
|
||||
if (glamor_pixmap_upload_prepare(pixmap, no_alpha, no_revert))
|
||||
return GLAMOR_UPLOAD_FAILED;
|
||||
glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DYNAMIC_UPLOAD,
|
||||
"Uploading pixmap %p %dx%d depth%d.\n",
|
||||
pixmap,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
_glamor_upload_pixmap_to_texture(pixmap, format, type, no_alpha,
|
||||
no_revert, 1);
|
||||
return GLAMOR_UPLOAD_DONE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_pixmap_to_texure_from_data(PixmapPtr pixmap, void *data)
|
||||
{
|
||||
enum glamor_pixmap_status upload_status;
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
|
||||
assert(pixmap_priv->pbo_valid == 0);
|
||||
assert(pixmap->devPrivate.ptr == NULL);
|
||||
pixmap->devPrivate.ptr = data;
|
||||
upload_status = glamor_upload_pixmap_to_texture(pixmap);
|
||||
pixmap->devPrivate.ptr = NULL;
|
||||
return upload_status;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
glamor_restore_pixmap_to_texture(PixmapPtr pixmap)
|
||||
{
|
||||
GLenum format, type;
|
||||
int no_alpha, no_revert;
|
||||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type, &no_alpha,
|
||||
&no_revert)) {
|
||||
ErrorF("Unknown pixmap depth %d.\n",
|
||||
pixmap->drawable.depth);
|
||||
assert(0);
|
||||
}
|
||||
|
||||
in_restore = 1;
|
||||
_glamor_upload_pixmap_to_texture(pixmap, format, type, no_alpha,
|
||||
no_revert, 1);
|
||||
in_restore = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* as gles2 only support a very small set of color format and
|
||||
* type when do glReadPixel,
|
||||
* Before we use glReadPixels to get back a textured pixmap,
|
||||
* Use shader to convert it to a supported format and thus
|
||||
* get a new temporary pixmap returned.
|
||||
* */
|
||||
|
||||
PixmapPtr
|
||||
glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum * format,
|
||||
GLenum * type, int no_alpha, int no_revert)
|
||||
{
|
||||
glamor_pixmap_private *source_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
ScreenPtr screen;
|
||||
PixmapPtr temp_pixmap;
|
||||
glamor_pixmap_private *temp_pixmap_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
static float vertices[8] = { -1, -1,
|
||||
1, -1,
|
||||
1, 1,
|
||||
-1, 1
|
||||
};
|
||||
static float texcoords[8] = { 0, 0,
|
||||
1, 0,
|
||||
1, 1,
|
||||
0, 1
|
||||
};
|
||||
|
||||
int swap_rb = 0;
|
||||
|
||||
screen = source->drawable.pScreen;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
source_priv = glamor_get_pixmap_private(source);
|
||||
dispatch = &glamor_priv->dispatch;
|
||||
if (*format == GL_BGRA) {
|
||||
*format = GL_RGBA;
|
||||
swap_rb = 1;
|
||||
}
|
||||
|
||||
|
||||
temp_pixmap = (*screen->CreatePixmap) (screen,
|
||||
source->drawable.width,
|
||||
source->drawable.height,
|
||||
source->drawable.depth, 0);
|
||||
|
||||
temp_pixmap_priv = glamor_get_pixmap_private(temp_pixmap);
|
||||
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, temp_pixmap_priv->tex);
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, *format,
|
||||
source->drawable.width,
|
||||
source->drawable.height, 0, *format, *type,
|
||||
NULL);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, source_priv->tex);
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(temp_pixmap_priv);
|
||||
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
|
||||
dispatch->glUniform1i(glamor_priv->
|
||||
finish_access_no_revert[no_alpha],
|
||||
no_revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
|
||||
swap_rb);
|
||||
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
dispatch->glUseProgram(0);
|
||||
return temp_pixmap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Move a pixmap to CPU memory.
|
||||
* The input data is the pixmap's fbo.
|
||||
* The output data is at pixmap->devPrivate.ptr. We always use pbo
|
||||
* to read the fbo and then map it to va. If possible, we will use
|
||||
* it directly as devPrivate.ptr.
|
||||
* If successfully download a fbo to cpu then return TRUE.
|
||||
* Otherwise return FALSE.
|
||||
**/
|
||||
|
||||
Bool
|
||||
glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
unsigned int stride, row_length, y;
|
||||
GLenum format, type, gl_access, gl_usage;
|
||||
int no_alpha, no_revert;
|
||||
uint8_t *data = NULL, *read;
|
||||
PixmapPtr temp_pixmap = NULL;
|
||||
ScreenPtr screen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
|
||||
screen = pixmap->drawable.pScreen;
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return TRUE;
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type, &no_alpha,
|
||||
&no_revert)) {
|
||||
ErrorF("Unknown pixmap depth %d.\n",
|
||||
pixmap->drawable.depth);
|
||||
assert(0); // Should never happen.
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pixmap_priv->access_mode = access;
|
||||
glamor_debug_output(GLAMOR_DEBUG_TEXTURE_DOWNLOAD,
|
||||
"Downloading pixmap %p %dx%d depth%d\n",
|
||||
pixmap,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
pixmap->drawable.depth);
|
||||
|
||||
stride = pixmap->devKind;
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
/* XXX we may don't need to validate it on GPU here,
|
||||
* we can just validate it on CPU. */
|
||||
glamor_validate_pixmap(pixmap);
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
|
||||
&&
|
||||
((format != GL_RGBA && format != GL_RGB && format != GL_ALPHA)
|
||||
|| no_revert != 1)) {
|
||||
|
||||
temp_pixmap =
|
||||
glamor_es2_pixmap_read_prepare(pixmap, &format,
|
||||
&type, no_alpha,
|
||||
no_revert);
|
||||
|
||||
}
|
||||
switch (access) {
|
||||
case GLAMOR_ACCESS_RO:
|
||||
gl_access = GL_READ_ONLY;
|
||||
gl_usage = GL_STREAM_READ;
|
||||
break;
|
||||
case GLAMOR_ACCESS_WO:
|
||||
data = malloc(stride * pixmap->drawable.height);
|
||||
goto done;
|
||||
break;
|
||||
case GLAMOR_ACCESS_RW:
|
||||
gl_access = GL_READ_WRITE;
|
||||
gl_usage = GL_DYNAMIC_DRAW;
|
||||
break;
|
||||
default:
|
||||
ErrorF("Glamor: Invalid access code. %d\n", access);
|
||||
assert(0);
|
||||
}
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) {
|
||||
data = malloc(stride * pixmap->drawable.height);
|
||||
}
|
||||
row_length = (stride * 8) / pixmap->drawable.bitsPerPixel;
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
|
||||
dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 1);
|
||||
dispatch->glPixelStorei(GL_PACK_ROW_LENGTH, row_length);
|
||||
} else {
|
||||
dispatch->glPixelStorei(GL_PACK_ALIGNMENT, 4);
|
||||
// dispatch->glPixelStorei(GL_PACK_ROW_LENGTH, 0);
|
||||
}
|
||||
if (glamor_priv->has_pack_invert || glamor_priv->yInverted) {
|
||||
|
||||
if (!glamor_priv->yInverted) {
|
||||
assert(glamor_priv->gl_flavor ==
|
||||
GLAMOR_GL_DESKTOP);
|
||||
dispatch->glPixelStorei(GL_PACK_INVERT_MESA, 1);
|
||||
}
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
|
||||
if (pixmap_priv->pbo == 0)
|
||||
dispatch->glGenBuffers(1,
|
||||
&pixmap_priv->pbo);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
pixmap_priv->pbo);
|
||||
dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
|
||||
stride *
|
||||
pixmap->drawable.height,
|
||||
NULL, gl_usage);
|
||||
dispatch->glReadPixels(0, 0, row_length,
|
||||
pixmap->drawable.height,
|
||||
format, type, 0);
|
||||
data = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
gl_access);
|
||||
pixmap_priv->pbo_valid = TRUE;
|
||||
|
||||
if (!glamor_priv->yInverted) {
|
||||
assert(glamor_priv->gl_flavor ==
|
||||
GLAMOR_GL_DESKTOP);
|
||||
dispatch->glPixelStorei
|
||||
(GL_PACK_INVERT_MESA, 0);
|
||||
}
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
|
||||
} else {
|
||||
if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV)
|
||||
type = GL_UNSIGNED_SHORT_5_5_5_1;
|
||||
dispatch->glReadPixels(0, 0,
|
||||
pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
format, type, data);
|
||||
}
|
||||
} else {
|
||||
data = malloc(stride * pixmap->drawable.height);
|
||||
assert(data);
|
||||
if (access != GLAMOR_ACCESS_WO) {
|
||||
if (pixmap_priv->pbo == 0)
|
||||
dispatch->glGenBuffers(1,
|
||||
&pixmap_priv->pbo);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
pixmap_priv->pbo);
|
||||
dispatch->glBufferData(GL_PIXEL_PACK_BUFFER,
|
||||
stride *
|
||||
pixmap->drawable.height,
|
||||
NULL, GL_STREAM_READ);
|
||||
dispatch->glReadPixels(0, 0, row_length,
|
||||
pixmap->drawable.height,
|
||||
format, type, 0);
|
||||
read = dispatch->glMapBuffer(GL_PIXEL_PACK_BUFFER,
|
||||
GL_READ_ONLY);
|
||||
|
||||
for (y = 0; y < pixmap->drawable.height; y++)
|
||||
memcpy(data + y * stride,
|
||||
read + (pixmap->drawable.height -
|
||||
y - 1) * stride, stride);
|
||||
dispatch->glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
pixmap_priv->pbo_valid = FALSE;
|
||||
dispatch->glDeleteBuffers(1, &pixmap_priv->pbo);
|
||||
pixmap_priv->pbo = 0;
|
||||
}
|
||||
}
|
||||
|
||||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
done:
|
||||
pixmap->devPrivate.ptr = data;
|
||||
|
||||
if (temp_pixmap) {
|
||||
(*screen->DestroyPixmap) (temp_pixmap);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
_glamor_destroy_upload_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
glamor_gl_dispatch *dispatch = &pixmap_priv->glamor_priv->dispatch;
|
||||
|
||||
assert(pixmap_priv->gl_fbo == 0);
|
||||
if (pixmap_priv->fb)
|
||||
dispatch->glDeleteFramebuffers(1, &pixmap_priv->fb);
|
||||
if (pixmap_priv->tex)
|
||||
dispatch->glDeleteTextures(1, &pixmap_priv->tex);
|
||||
if (pixmap_priv->pbo)
|
||||
dispatch->glDeleteBuffers(1, &pixmap_priv->pbo);
|
||||
pixmap_priv->fb = pixmap_priv->tex = pixmap_priv->pbo = 0;
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
glamor_destroy_upload_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
_glamor_destroy_upload_pixmap(pixmap);
|
||||
}
|
|
@ -39,14 +39,13 @@
|
|||
|
||||
void
|
||||
glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int nrect,
|
||||
xRectangle *prect)
|
||||
GCPtr gc, int nrect, xRectangle * prect)
|
||||
{
|
||||
int fullX1, fullX2, fullY1, fullY2;
|
||||
int xorg, yorg;
|
||||
int n;
|
||||
register BoxPtr pbox;
|
||||
|
||||
RegionPtr pClip = fbGetCompositeClip(gc);
|
||||
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled) {
|
||||
goto fail;
|
||||
|
@ -87,12 +86,9 @@ glamor_poly_fill_rect(DrawablePtr drawable,
|
|||
|
||||
if (x1 >= x2 || y1 >= y2)
|
||||
continue;
|
||||
glamor_fill(drawable,
|
||||
gc,
|
||||
x1,
|
||||
y1,
|
||||
x2 - x1,
|
||||
y2 - y1);
|
||||
if (!glamor_fill(drawable, gc, x1, y1, x2 - x1,
|
||||
y2 - y1))
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -107,4 +103,5 @@ fail:
|
|||
}
|
||||
glamor_finish_access(drawable);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -63,9 +63,9 @@ glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
*/
|
||||
goto fail;
|
||||
}
|
||||
if (gc->lineStyle != LineSolid ||
|
||||
gc->fillStyle != FillSolid) {
|
||||
glamor_fallback("non-solid fill line style %d, fill style %d\n",
|
||||
if (gc->lineStyle != LineSolid || gc->fillStyle != FillSolid) {
|
||||
glamor_fallback
|
||||
("non-solid fill line style %d, fill style %d\n",
|
||||
gc->lineStyle, gc->fillStyle);
|
||||
goto fail;
|
||||
}
|
||||
|
@ -110,8 +110,7 @@ glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
|||
return;
|
||||
|
||||
fail:
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
for (i = 0; i < n; i++) {
|
||||
if (x_min > points[i].x)
|
||||
x_min = points[i].x;
|
||||
if (x_max < points[i].x)
|
||||
|
@ -124,15 +123,15 @@ fail:
|
|||
}
|
||||
|
||||
temp_pixmap = drawable->pScreen->CreatePixmap(drawable->pScreen,
|
||||
x_max - x_min + 1, y_max - y_min + 1,
|
||||
drawable->depth,
|
||||
0);
|
||||
x_max - x_min + 1,
|
||||
y_max - y_min + 1,
|
||||
drawable->depth, 0);
|
||||
if (temp_pixmap) {
|
||||
temp_dest = &temp_pixmap->drawable;
|
||||
temp_gc = GetScratchGC(temp_dest->depth, temp_dest->pScreen);
|
||||
temp_gc =
|
||||
GetScratchGC(temp_dest->depth, temp_dest->pScreen);
|
||||
ValidateGC(temp_dest, temp_gc);
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
for (i = 0; i < n; i++) {
|
||||
points[i].x -= x_min;
|
||||
points[i].y -= y_min;
|
||||
}
|
||||
|
@ -140,11 +139,10 @@ fail:
|
|||
temp_dest,
|
||||
temp_gc,
|
||||
x_min, y_min,
|
||||
x_max - x_min + 1, y_max - y_min + 1,
|
||||
0, 0);
|
||||
x_max - x_min + 1,
|
||||
y_max - y_min + 1, 0, 0);
|
||||
|
||||
}
|
||||
else
|
||||
} else
|
||||
temp_dest = drawable;
|
||||
|
||||
if (gc->lineWidth == 0) {
|
||||
|
@ -155,8 +153,7 @@ fail:
|
|||
}
|
||||
glamor_finish_access(temp_dest);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* fb calls mi functions in the lineWidth != 0 case. */
|
||||
fbPolyLine(drawable, gc, mode, n, points);
|
||||
}
|
||||
|
@ -165,11 +162,10 @@ fail:
|
|||
drawable,
|
||||
temp_gc,
|
||||
0, 0,
|
||||
x_max - x_min + 1, y_max - y_min + 1,
|
||||
x_min, y_min);
|
||||
x_max - x_min + 1,
|
||||
y_max - y_min + 1, x_min, y_min);
|
||||
drawable->pScreen->DestroyPixmap(temp_pixmap);
|
||||
for(i = 0; i < n; i++)
|
||||
{
|
||||
for (i = 0; i < n; i++) {
|
||||
points[i].x += x_min;
|
||||
points[i].y += y_min;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <dix-config.h>
|
||||
#include <xorg-config.h>
|
||||
#endif
|
||||
|
||||
#include <xorg-server.h>
|
||||
|
||||
#include "glamor.h"
|
||||
|
||||
|
@ -107,8 +107,11 @@ enum shader_in {
|
|||
|
||||
struct glamor_screen_private;
|
||||
struct glamor_pixmap_private;
|
||||
typedef void (*glamor_pixmap_validate_function_t)(struct glamor_screen_private*,
|
||||
struct glamor_pixmap_private*);
|
||||
typedef void (*glamor_pixmap_validate_function_t) (struct
|
||||
glamor_screen_private *,
|
||||
struct
|
||||
glamor_pixmap_private
|
||||
*);
|
||||
|
||||
enum glamor_gl_flavor {
|
||||
GLAMOR_GL_DESKTOP, // OPENGL API
|
||||
|
@ -179,8 +182,7 @@ typedef struct glamor_screen_private {
|
|||
|
||||
/* glamor_composite */
|
||||
glamor_composite_shader composite_shader[SHADER_SOURCE_COUNT]
|
||||
[SHADER_MASK_COUNT]
|
||||
[SHADER_IN_COUNT];
|
||||
[SHADER_MASK_COUNT][SHADER_IN_COUNT];
|
||||
Bool has_source_coords, has_mask_coords;
|
||||
int render_nr_verts;
|
||||
glamor_pixmap_validate_function_t *pixmap_validate_funcs;
|
||||
|
@ -267,13 +269,16 @@ extern DevPrivateKey glamor_pixmap_private_key;
|
|||
static inline glamor_screen_private *
|
||||
glamor_get_screen_private(ScreenPtr screen)
|
||||
{
|
||||
return (glamor_screen_private *)dixLookupPrivate(&screen->devPrivates,
|
||||
return (glamor_screen_private *)
|
||||
dixLookupPrivate(&screen->devPrivates,
|
||||
glamor_screen_private_key);
|
||||
}
|
||||
|
||||
static inline glamor_pixmap_private *
|
||||
glamor_get_pixmap_private(PixmapPtr pixmap)
|
||||
{
|
||||
return dixLookupPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
|
||||
return dixLookupPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key);
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,19 +304,11 @@ Bool glamor_close_screen(int idx, ScreenPtr screen);
|
|||
/* glamor_copyarea.c */
|
||||
RegionPtr
|
||||
glamor_copy_area(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
||||
int srcx, int srcy, int width, int height, int dstx, int dsty);
|
||||
void
|
||||
glamor_copy_n_to_n(DrawablePtr src,
|
||||
DrawablePtr dst,
|
||||
GCPtr gc,
|
||||
BoxPtr box,
|
||||
int nbox,
|
||||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown,
|
||||
Pixel bitplane,
|
||||
void *closure);
|
||||
int srcx, int srcy, int width, int height, int dstx,
|
||||
int dsty);
|
||||
void glamor_copy_n_to_n(DrawablePtr src, DrawablePtr dst, GCPtr gc,
|
||||
BoxPtr box, int nbox, int dx, int dy, Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane, void *closure);
|
||||
|
||||
/* glamor_copywindow.c */
|
||||
void glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
||||
|
@ -334,25 +331,30 @@ Bool glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
|
|||
unsigned char alu, unsigned long planemask,
|
||||
unsigned long fg_pixel, unsigned long bg_pixel,
|
||||
int stipple_x, int stipple_y);
|
||||
GLint glamor_compile_glsl_prog(glamor_gl_dispatch *dispatch, GLenum type, const char *source);
|
||||
GLint glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
|
||||
const char *source);
|
||||
void glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog);
|
||||
void glamor_get_color_4f_from_pixel(PixmapPtr pixmap, unsigned long fg_pixel,
|
||||
void glamor_get_color_4f_from_pixel(PixmapPtr pixmap,
|
||||
unsigned long fg_pixel,
|
||||
GLfloat * color);
|
||||
|
||||
int glamor_set_destination_pixmap(PixmapPtr pixmap);
|
||||
int glamor_set_destination_pixmap_priv(glamor_pixmap_private *pixmap_priv);
|
||||
int glamor_set_destination_pixmap_priv(glamor_pixmap_private *
|
||||
pixmap_priv);
|
||||
|
||||
/* nc means no check. caller must ensure this pixmap has valid fbo.
|
||||
* usually use the GLAMOR_PIXMAP_PRIV_HAS_FBO firstly.
|
||||
* */
|
||||
void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *pixmap_priv);
|
||||
void glamor_set_destination_pixmap_priv_nc(glamor_pixmap_private *
|
||||
pixmap_priv);
|
||||
|
||||
|
||||
PixmapPtr
|
||||
glamor_es2_pixmap_read_prepare(PixmapPtr source, GLenum * format,
|
||||
GLenum * type, int no_alpha, int no_revert);
|
||||
|
||||
void glamor_set_alu(struct glamor_gl_dispatch * dispatch, unsigned char alu);
|
||||
void glamor_set_alu(struct glamor_gl_dispatch *dispatch,
|
||||
unsigned char alu);
|
||||
Bool glamor_set_planemask(PixmapPtr pixmap, unsigned long planemask);
|
||||
Bool glamor_change_window_attributes(WindowPtr pWin, unsigned long mask);
|
||||
RegionPtr glamor_bitmap_to_region(PixmapPtr pixmap);
|
||||
|
@ -367,12 +369,8 @@ int glamor_gl_get_version(void);
|
|||
|
||||
|
||||
/* glamor_fill.c */
|
||||
void glamor_fill(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height);
|
||||
Bool glamor_fill(DrawablePtr drawable,
|
||||
GCPtr gc, int x, int y, int width, int height);
|
||||
Bool glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask,
|
||||
unsigned long fg_pixel);
|
||||
|
@ -382,21 +380,17 @@ void glamor_solid_fail_region(PixmapPtr pixmap,
|
|||
/* glamor_fillspans.c */
|
||||
void glamor_fill_spans(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n,
|
||||
DDXPointPtr points,
|
||||
int *widths,
|
||||
int sorted);
|
||||
int n, DDXPointPtr points, int *widths, int sorted);
|
||||
|
||||
void glamor_init_solid_shader(ScreenPtr screen);
|
||||
|
||||
/* glamor_getspans.c */
|
||||
void
|
||||
|
||||
glamor_get_spans(DrawablePtr drawable,
|
||||
int wmax,
|
||||
DDXPointPtr points,
|
||||
int *widths,
|
||||
int nspans,
|
||||
char *dst_start);
|
||||
int *widths, int nspans, char *dst_start);
|
||||
|
||||
/* glamor_glyphs.c */
|
||||
void glamor_glyphs_fini(ScreenPtr screen);
|
||||
|
@ -405,10 +399,10 @@ void glamor_glyphs(CARD8 op,
|
|||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc, int nlist, GlyphListPtr list, GlyphPtr * glyphs);
|
||||
INT16 ySrc, int nlist, GlyphListPtr list,
|
||||
GlyphPtr * glyphs);
|
||||
|
||||
void
|
||||
glamor_glyph_unrealize (ScreenPtr screen, GlyphPtr glyph);
|
||||
void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
|
||||
/* glamor_setspans.c */
|
||||
void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int n, int sorted);
|
||||
|
@ -416,17 +410,17 @@ void glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
/* glamor_polyfillrect.c */
|
||||
void
|
||||
glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int nrect,
|
||||
xRectangle *prect);
|
||||
GCPtr gc, int nrect, xRectangle * prect);
|
||||
|
||||
/* glamor_polylines.c */
|
||||
void
|
||||
|
||||
glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
DDXPointPtr points);
|
||||
|
||||
/* glamor_putimage.c */
|
||||
void
|
||||
|
||||
glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int leftPad, int format, char *bits);
|
||||
void glamor_init_putimage_shaders(ScreenPtr screen);
|
||||
|
@ -440,18 +434,16 @@ void glamor_composite(CARD8 op,
|
|||
INT16 ySrc,
|
||||
INT16 xMask,
|
||||
INT16 yMask,
|
||||
INT16 xDst,
|
||||
INT16 yDst,
|
||||
CARD16 width,
|
||||
CARD16 height);
|
||||
INT16 xDst, INT16 yDst, CARD16 width, CARD16 height);
|
||||
void glamor_trapezoids(CARD8 op,
|
||||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format, INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid * traps);
|
||||
void glamor_init_composite_shaders(ScreenPtr screen);
|
||||
void glamor_composite_rects(CARD8 op,
|
||||
PicturePtr src, PicturePtr mask, PicturePtr dst,
|
||||
int nrect, glamor_composite_rect_t *rects);
|
||||
PicturePtr src, PicturePtr mask,
|
||||
PicturePtr dst, int nrect,
|
||||
glamor_composite_rect_t * rects);
|
||||
|
||||
/* glamor_tile.c */
|
||||
Bool glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||
|
@ -462,19 +454,16 @@ void glamor_init_tile_shader(ScreenPtr screen);
|
|||
|
||||
/* glamor_triangles.c */
|
||||
void
|
||||
|
||||
glamor_triangles(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntris,
|
||||
xTriangle *tris);
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris);
|
||||
|
||||
/* glamor_pixmap.c */
|
||||
|
||||
void
|
||||
glamor_pixmap_init(ScreenPtr screen);
|
||||
void glamor_pixmap_init(ScreenPtr screen);
|
||||
/**
|
||||
* Download a pixmap's texture to cpu memory. If success,
|
||||
* One copy of current pixmap's texture will be put into
|
||||
|
@ -484,8 +473,8 @@ glamor_pixmap_init(ScreenPtr screen);
|
|||
* gl_tex must be 1. Used by glamor_prepare_access.
|
||||
*
|
||||
*/
|
||||
Bool
|
||||
glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access);
|
||||
Bool glamor_download_pixmap_to_cpu(PixmapPtr pixmap,
|
||||
glamor_access_t access);
|
||||
|
||||
/**
|
||||
* Restore a pixmap's data which is downloaded by
|
||||
|
@ -496,8 +485,7 @@ glamor_download_pixmap_to_cpu(PixmapPtr pixmap, glamor_access_t access);
|
|||
* in texture originally. In other word, the gl_fbo
|
||||
* must be 1.
|
||||
**/
|
||||
void
|
||||
glamor_restore_pixmap_to_texture(PixmapPtr pixmap);
|
||||
void glamor_restore_pixmap_to_texture(PixmapPtr pixmap);
|
||||
/**
|
||||
* Ensure to have a fbo attached to the pixmap.
|
||||
* If the pixmap already has one fbo then do nothing.
|
||||
|
@ -506,16 +494,15 @@ glamor_restore_pixmap_to_texture(PixmapPtr pixmap);
|
|||
* The pixmap must has a valid texture before call this
|
||||
* API, othersie, it will trigger a assert.
|
||||
*/
|
||||
void
|
||||
glamor_pixmap_ensure_fb(PixmapPtr pixmap);
|
||||
void glamor_pixmap_ensure_fb(PixmapPtr pixmap);
|
||||
|
||||
/**
|
||||
* Upload a pixmap to gl texture. Used by dynamic pixmap
|
||||
* uploading feature. The pixmap must be a software pixmap.
|
||||
* This function will change current FBO and current shaders.
|
||||
*/
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_pixmap_to_texture(PixmapPtr pixmap);
|
||||
enum glamor_pixmap_status glamor_upload_pixmap_to_texture(PixmapPtr
|
||||
pixmap);
|
||||
|
||||
/**
|
||||
* Upload a picture to gl texture. Similar to the
|
||||
|
@ -528,29 +515,26 @@ glamor_upload_picture_to_texture(PicturePtr picture);
|
|||
* Destroy all the resources allocated on the uploading
|
||||
* phase, includs the tex and fbo.
|
||||
**/
|
||||
void
|
||||
glamor_destroy_upload_pixmap(PixmapPtr pixmap);
|
||||
void glamor_destroy_upload_pixmap(PixmapPtr pixmap);
|
||||
|
||||
void
|
||||
glamor_validate_pixmap(PixmapPtr pixmap);
|
||||
void glamor_validate_pixmap(PixmapPtr pixmap);
|
||||
|
||||
int
|
||||
glamor_create_picture(PicturePtr picture);
|
||||
int glamor_create_picture(PicturePtr picture);
|
||||
|
||||
Bool
|
||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access);
|
||||
|
||||
void
|
||||
glamor_finish_access_picture(PicturePtr picture);
|
||||
void glamor_finish_access_picture(PicturePtr picture);
|
||||
|
||||
void
|
||||
glamor_destroy_picture(PicturePtr picture);
|
||||
void glamor_destroy_picture(PicturePtr picture);
|
||||
|
||||
enum glamor_pixmap_status
|
||||
glamor_upload_picture_to_texture(PicturePtr picture);
|
||||
|
||||
void
|
||||
glamor_picture_format_fixup(PicturePtr picture, glamor_pixmap_private *pixmap_priv);
|
||||
|
||||
glamor_picture_format_fixup(PicturePtr picture,
|
||||
glamor_pixmap_private * pixmap_priv);
|
||||
|
||||
#include"glamor_utils.h"
|
||||
|
||||
|
@ -562,7 +546,7 @@ glamor_picture_format_fixup(PicturePtr picture, glamor_pixmap_private *pixmap_pr
|
|||
* this will increase performance obviously. */
|
||||
|
||||
#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
|
||||
#define GLAMOR_DELAYED_FILLING
|
||||
//#define GLAMOR_DELAYED_FILLING
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -36,31 +36,23 @@ void
|
|||
glamor_init_putimage_shaders(ScreenPtr screen)
|
||||
{
|
||||
#if 0
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
const char *xybitmap_vs =
|
||||
"uniform float x_bias;\n"
|
||||
"uniform float x_scale;\n"
|
||||
"uniform float y_bias;\n"
|
||||
"uniform float y_scale;\n"
|
||||
"varying vec2 bitmap_coords;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"uniform float x_bias;\n" "uniform float x_scale;\n"
|
||||
"uniform float y_bias;\n" "uniform float y_scale;\n"
|
||||
"varying vec2 bitmap_coords;\n" "void main()\n" "{\n"
|
||||
" gl_Position = vec4((gl_Vertex.x + x_bias) * x_scale,\n"
|
||||
" (gl_Vertex.y + y_bias) * y_scale,\n"
|
||||
" 0,\n"
|
||||
" 1);\n"
|
||||
" bitmap_coords = gl_MultiTexCoord0.xy;\n"
|
||||
"}\n";
|
||||
" bitmap_coords = gl_MultiTexCoord0.xy;\n" "}\n";
|
||||
const char *xybitmap_fs =
|
||||
"uniform vec4 fg, bg;\n"
|
||||
"varying vec2 bitmap_coords;\n"
|
||||
"uniform sampler2D bitmap_sampler;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
"uniform vec4 fg, bg;\n" "varying vec2 bitmap_coords;\n"
|
||||
"uniform sampler2D bitmap_sampler;\n" "void main()\n" "{\n"
|
||||
" float bitmap_value = texture2D(bitmap_sampler,\n"
|
||||
" bitmap_coords).x;\n"
|
||||
" gl_FragColor = mix(bg, fg, bitmap_value);\n"
|
||||
"}\n";
|
||||
" gl_FragColor = mix(bg, fg, bitmap_value);\n" "}\n";
|
||||
GLint fs_prog, vs_prog, prog;
|
||||
GLint sampler_uniform_location;
|
||||
|
||||
|
@ -69,13 +61,15 @@ glamor_init_putimage_shaders(ScreenPtr screen)
|
|||
|
||||
prog = dispatch->glCreateProgram();
|
||||
vs_prog = glamor_compile_glsl_prog(GL_VERTEX_SHADER, xybitmap_vs);
|
||||
fs_prog = glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
|
||||
fs_prog =
|
||||
glamor_compile_glsl_prog(GL_FRAGMENT_SHADER, xybitmap_fs);
|
||||
dispatch->glAttachShader(prog, vs_prog);
|
||||
dispatch->glAttachShader(prog, fs_prog);
|
||||
glamor_link_glsl_prog(prog);
|
||||
|
||||
dispatch->glUseProgram(prog);
|
||||
sampler_uniform_location = dispatch->glGetUniformLocation(prog, "bitmap_sampler");
|
||||
sampler_uniform_location =
|
||||
dispatch->glGetUniformLocation(prog, "bitmap_sampler");
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
|
||||
glamor_priv->put_image_xybitmap_fg_uniform_location =
|
||||
|
@ -123,7 +117,8 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
{
|
||||
ScreenPtr screen = drawable->pScreen;
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
float fg[4], bg[4];
|
||||
GLuint tex;
|
||||
unsigned int stride = PixmapBytePad(1, w + left_pad);
|
||||
|
@ -147,8 +142,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
glamor_set_normalize_vcoords(xscale, yscale,
|
||||
x, y,
|
||||
x + w, y + h,
|
||||
glamor_priv->yInverted,
|
||||
dest_coords);
|
||||
glamor_priv->yInverted, dest_coords);
|
||||
|
||||
glamor_fallback("glamor_put_image_xybitmap: disabled\n");
|
||||
goto fail;
|
||||
|
@ -165,24 +159,25 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
dispatch->glUseProgram(glamor_priv->put_image_xybitmap_prog);
|
||||
|
||||
glamor_get_color_4f_from_pixel(pixmap, gc->fgPixel, fg);
|
||||
dispatch->glUniform4fv(glamor_priv->put_image_xybitmap_fg_uniform_location,
|
||||
1, fg);
|
||||
dispatch->glUniform4fv
|
||||
(glamor_priv->put_image_xybitmap_fg_uniform_location, 1, fg);
|
||||
glamor_get_color_4f_from_pixel(pixmap, gc->bgPixel, bg);
|
||||
dispatch->glUniform4fv(glamor_priv->put_image_xybitmap_bg_uniform_location,
|
||||
1, bg);
|
||||
dispatch->glUniform4fv
|
||||
(glamor_priv->put_image_xybitmap_bg_uniform_location, 1, bg);
|
||||
|
||||
dispatch->glGenTextures(1, &tex);
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, stride * 8);
|
||||
dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, left_pad);
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA,
|
||||
w, h, 0,
|
||||
GL_COLOR_INDEX, GL_BITMAP, bits);
|
||||
w, h, 0, GL_COLOR_INDEX, GL_BITMAP, bits);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
|
@ -200,10 +195,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
dispatch->glEnable(GL_SCISSOR_TEST);
|
||||
clip = fbGetCompositeClip(gc);
|
||||
for (nbox = REGION_NUM_RECTS(clip),
|
||||
box = REGION_RECTS(clip);
|
||||
nbox--;
|
||||
box++)
|
||||
{
|
||||
box = REGION_RECTS(clip); nbox--; box++) {
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int x2 = x + w;
|
||||
|
@ -222,8 +214,7 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
|
||||
dispatch->glScissor(box->x1,
|
||||
y_flip(pixmap, box->y1),
|
||||
box->x2 - box->x1,
|
||||
box->y2 - box->y1);
|
||||
box->x2 - box->x1, box->y2 - box->y1);
|
||||
dispatch->glDrawArrays(GL_QUADS, 0, 4);
|
||||
}
|
||||
|
||||
|
@ -241,7 +232,8 @@ glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
|||
drawable, glamor_get_drawable_location(drawable));
|
||||
fail:
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap, bits);
|
||||
fbPutImage(drawable, gc, 1, x, y, w, h, left_pad, XYBitmap,
|
||||
bits);
|
||||
glamor_finish_access(drawable);
|
||||
}
|
||||
}
|
||||
|
@ -256,7 +248,8 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
glamor_get_screen_private(drawable->pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
GLenum type, format, iformat;
|
||||
RegionPtr clip;
|
||||
BoxPtr pbox;
|
||||
|
@ -290,34 +283,31 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
|
||||
if (glamor_get_tex_format_type_from_pixmap(pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&no_alpha,
|
||||
&no_revert
|
||||
)) {
|
||||
glamor_fallback("unknown depth. %d \n",
|
||||
drawable->depth);
|
||||
&type, &no_alpha,
|
||||
&no_revert)) {
|
||||
glamor_fallback("unknown depth. %d \n", drawable->depth);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* XXX consider to reuse a function to do the following work. */
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
glamor_validate_pixmap(pixmap);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) {
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, src_stride * 8 /
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH,
|
||||
src_stride * 8 /
|
||||
pixmap->drawable.bitsPerPixel);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
dispatch->glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
||||
// dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
}
|
||||
|
@ -327,24 +317,27 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
dispatch->glBindTexture(GL_TEXTURE_2D, tex);
|
||||
if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) {
|
||||
iformat = format;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
iformat = GL_RGBA;
|
||||
}
|
||||
|
||||
dispatch->glTexImage2D(GL_TEXTURE_2D, 0, iformat,
|
||||
w, h, 0,
|
||||
format, type, bits);
|
||||
w, h, 0, format, type, bits);
|
||||
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[no_alpha]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_no_revert[no_alpha], no_revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha], 0);
|
||||
dispatch->glUniform1i(glamor_priv->
|
||||
finish_access_no_revert[no_alpha],
|
||||
no_revert);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[no_alpha],
|
||||
0);
|
||||
|
||||
x += drawable->x;
|
||||
y += drawable->y;
|
||||
|
@ -357,10 +350,7 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
|
||||
|
||||
for (nbox = REGION_NUM_RECTS(clip),
|
||||
pbox = REGION_RECTS(clip);
|
||||
nbox--;
|
||||
pbox++)
|
||||
{
|
||||
pbox = REGION_RECTS(clip); nbox--; pbox++) {
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int x2 = x + w;
|
||||
|
@ -379,9 +369,7 @@ glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
|||
|
||||
glamor_set_normalize_tcoords(txscale, tyscale,
|
||||
x1 - x, y1 - y,
|
||||
x2 - x, y2 - y,
|
||||
1,
|
||||
texcoords);
|
||||
x2 - x, y2 - y, 1, texcoords);
|
||||
|
||||
glamor_set_normalize_vcoords(xscale, yscale,
|
||||
x1 + x_off, y1 + y_off,
|
||||
|
@ -410,8 +398,8 @@ fail:
|
|||
glamor_fallback("to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbPutImage(&pixmap->drawable, gc, depth, x, y, w, h, left_pad, image_format,
|
||||
bits);
|
||||
fbPutImage(&pixmap->drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits);
|
||||
glamor_finish_access(&pixmap->drawable);
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -36,7 +36,8 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
DDXPointPtr points, int *widths, int n, int sorted)
|
||||
{
|
||||
PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(drawable->pScreen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
GLenum format, type;
|
||||
int no_alpha, no_revert, i;
|
||||
|
@ -52,12 +53,9 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
|
||||
if (glamor_get_tex_format_type_from_pixmap(dest_pixmap,
|
||||
&format,
|
||||
&type,
|
||||
&no_alpha,
|
||||
&no_revert
|
||||
)) {
|
||||
glamor_fallback("unknown depth. %d \n",
|
||||
drawable->depth);
|
||||
&type, &no_alpha,
|
||||
&no_revert)) {
|
||||
glamor_fallback("unknown depth. %d \n", drawable->depth);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -83,17 +81,15 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
|||
break;
|
||||
dispatch->glScissor(pbox->x1,
|
||||
points[i].y + y_off,
|
||||
pbox->x2 - pbox->x1,
|
||||
1);
|
||||
pbox->x2 - pbox->x1, 1);
|
||||
dispatch->glEnable(GL_SCISSOR_TEST);
|
||||
dispatch->glRasterPos2i(points[i].x + x_off,
|
||||
points[i].y + y_off);
|
||||
dispatch->glDrawPixels(widths[i],
|
||||
1,
|
||||
format, type,
|
||||
drawpixels_src);
|
||||
dispatch->glDrawPixels(widths[i], 1, format,
|
||||
type, drawpixels_src);
|
||||
}
|
||||
drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
|
||||
drawpixels_src +=
|
||||
PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
glamor_set_planemask(dest_pixmap, ~0);
|
||||
glamor_set_alu(dispatch, GXcopy);
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
void
|
||||
glamor_init_tile_shader(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
const char *tile_vs =
|
||||
"attribute vec4 v_position;\n"
|
||||
|
@ -48,31 +49,36 @@ glamor_init_tile_shader(ScreenPtr screen)
|
|||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" tile_texture = v_texcoord0.xy;\n"
|
||||
"}\n";
|
||||
" tile_texture = v_texcoord0.xy;\n" "}\n";
|
||||
const char *tile_fs =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"varying vec2 tile_texture;\n"
|
||||
"uniform sampler2D sampler;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_FragColor = texture2D(sampler, tile_texture);\n"
|
||||
"{\n" " gl_FragColor = texture2D(sampler, tile_texture);\n"
|
||||
"}\n";
|
||||
GLint fs_prog, vs_prog;
|
||||
GLint sampler_uniform_location;
|
||||
|
||||
glamor_priv->tile_prog = dispatch->glCreateProgram();
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, tile_vs);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, tile_fs);
|
||||
vs_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER, tile_vs);
|
||||
fs_prog =
|
||||
glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
tile_fs);
|
||||
dispatch->glAttachShader(glamor_priv->tile_prog, vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->tile_prog, fs_prog);
|
||||
|
||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog, GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog, GLAMOR_VERTEX_SOURCE, "v_texcoord0");
|
||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
||||
GLAMOR_VERTEX_POS, "v_position");
|
||||
dispatch->glBindAttribLocation(glamor_priv->tile_prog,
|
||||
GLAMOR_VERTEX_SOURCE,
|
||||
"v_texcoord0");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->tile_prog);
|
||||
|
||||
sampler_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog, "sampler");
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog,
|
||||
"sampler");
|
||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
dispatch->glUseProgram(0);
|
||||
|
@ -85,7 +91,8 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
int tile_x, int tile_y)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch = &glamor_priv->dispatch;
|
||||
int x1 = x;
|
||||
int x2 = x + width;
|
||||
|
@ -104,8 +111,12 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
||||
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (src_pixmap_priv == NULL || dst_pixmap_priv == NULL)
|
||||
goto fail;
|
||||
|
||||
if (((tile_x != 0) && (tile_x + width > tile->drawable.width))
|
||||
|| ((tile_y != 0) && (tile_y + height > tile->drawable.height))) {
|
||||
|| ((tile_y != 0)
|
||||
&& (tile_y + height > tile->drawable.height))) {
|
||||
ErrorF("tile_x = %d tile_y = %d \n", tile_x, tile_y);
|
||||
goto fail;
|
||||
}
|
||||
|
@ -140,15 +151,23 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
glamor_set_alu(dispatch, alu);
|
||||
|
||||
if (GLAMOR_PIXMAP_PRIV_NO_PENDING(src_pixmap_priv)) {
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale,
|
||||
&src_yscale);
|
||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D,
|
||||
src_pixmap_priv->tex);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MIN_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D,
|
||||
GL_TEXTURE_MAG_FILTER,
|
||||
GL_NEAREST);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
|
||||
GL_REPEAT);
|
||||
dispatch->glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
|
||||
GL_REPEAT);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
|
@ -157,22 +176,22 @@ glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
|||
tile_x2, tile_y2,
|
||||
glamor_priv->yInverted,
|
||||
source_texcoords);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, GL_FLOAT, GL_FALSE,
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
source_texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
}
|
||||
else {
|
||||
GLAMOR_CHECK_PENDING_FILL(dispatch, glamor_priv, src_pixmap_priv);
|
||||
} else {
|
||||
GLAMOR_CHECK_PENDING_FILL(dispatch, glamor_priv,
|
||||
src_pixmap_priv);
|
||||
}
|
||||
|
||||
glamor_set_normalize_vcoords(dst_xscale, dst_yscale,
|
||||
x1, y1, x2, y2,
|
||||
glamor_priv->yInverted,
|
||||
vertices);
|
||||
glamor_priv->yInverted, vertices);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
vertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
|
|
@ -37,19 +37,16 @@ glamor_triangles (CARD8 op,
|
|||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc,
|
||||
INT16 ySrc,
|
||||
int ntris,
|
||||
xTriangle *tris)
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
|
||||
{
|
||||
|
||||
if (glamor_prepare_access(pDst->pDrawable, GLAMOR_ACCESS_RW)) {
|
||||
if (pSrc->pDrawable == NULL ||
|
||||
glamor_prepare_access(pSrc->pDrawable, GLAMOR_ACCESS_RO))
|
||||
{
|
||||
glamor_prepare_access(pSrc->pDrawable,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
|
||||
fbTriangles(op,
|
||||
pSrc, pDst, maskFormat, xSrc, ySrc, ntris, tris);
|
||||
fbTriangles(op, pSrc, pDst, maskFormat, xSrc,
|
||||
ySrc, ntris, tris);
|
||||
}
|
||||
if (pSrc->pDrawable != NULL)
|
||||
glamor_finish_access(pSrc->pDrawable);
|
||||
|
@ -57,5 +54,3 @@ glamor_triangles (CARD8 op,
|
|||
glamor_finish_access(pDst->pDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -129,8 +129,7 @@ glamor_calculate_boxes_bound(BoxPtr bound, BoxPtr boxes, int nbox)
|
|||
int i;
|
||||
x_min = y_min = MAXSHORT;
|
||||
x_max = y_max = MINSHORT;
|
||||
for(i = 0; i < nbox; i++)
|
||||
{
|
||||
for (i = 0; i < nbox; i++) {
|
||||
if (x_min > boxes[i].x1)
|
||||
x_min = boxes[i].x1;
|
||||
if (y_min > boxes[i].y1)
|
||||
|
@ -151,8 +150,7 @@ inline static void
|
|||
glamor_transform_boxes(BoxPtr boxes, int nbox, int dx, int dy)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < nbox; i++)
|
||||
{
|
||||
for (i = 0; i < nbox; i++) {
|
||||
boxes[i].x1 += dx;
|
||||
boxes[i].y1 += dy;
|
||||
boxes[i].x2 += dx;
|
||||
|
@ -204,17 +202,25 @@ static inline CARD32
|
|||
format_for_depth(int depth)
|
||||
{
|
||||
switch (depth) {
|
||||
case 1: return PICT_a1;
|
||||
case 4: return PICT_a4;
|
||||
case 8: return PICT_a8;
|
||||
case 15: return PICT_x1r5g5b5;
|
||||
case 16: return PICT_r5g6b5;
|
||||
case 1:
|
||||
return PICT_a1;
|
||||
case 4:
|
||||
return PICT_a4;
|
||||
case 8:
|
||||
return PICT_a8;
|
||||
case 15:
|
||||
return PICT_x1r5g5b5;
|
||||
case 16:
|
||||
return PICT_r5g6b5;
|
||||
default:
|
||||
case 24: return PICT_x8r8g8b8;
|
||||
case 24:
|
||||
return PICT_x8r8g8b8;
|
||||
#if XORG_VERSION_CURRENT >= 10699900
|
||||
case 30: return PICT_x2r10g10b10;
|
||||
case 30:
|
||||
return PICT_x2r10g10b10;
|
||||
#endif
|
||||
case 32: return PICT_a8r8g8b8;
|
||||
case 32:
|
||||
return PICT_a8r8g8b8;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,8 +250,7 @@ static inline int
|
|||
glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
||||
GLenum * tex_format,
|
||||
GLenum * tex_type,
|
||||
int *no_alpha,
|
||||
int *no_revert)
|
||||
int *no_alpha, int *no_revert)
|
||||
{
|
||||
*no_alpha = 0;
|
||||
*no_revert = 1;
|
||||
|
@ -326,7 +331,9 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
break;
|
||||
|
||||
default:
|
||||
LogMessageVerb(X_INFO, 0, "fail to get matched format for %x \n", format);
|
||||
LogMessageVerb(X_INFO, 0,
|
||||
"fail to get matched format for %x \n",
|
||||
format);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -338,8 +345,7 @@ static inline int
|
|||
glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
||||
GLenum * tex_format,
|
||||
GLenum * tex_type,
|
||||
int *no_alpha,
|
||||
int *no_revert)
|
||||
int *no_alpha, int *no_revert)
|
||||
{
|
||||
*no_alpha = 0;
|
||||
*no_revert = IS_LITTLE_ENDIAN;
|
||||
|
@ -434,7 +440,9 @@ glamor_get_tex_format_type_from_pictformat(PictFormatShort format,
|
|||
break;
|
||||
|
||||
default:
|
||||
LogMessageVerb(X_INFO, 0, "fail to get matched format for %x \n", format);
|
||||
LogMessageVerb(X_INFO, 0,
|
||||
"fail to get matched format for %x \n",
|
||||
format);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -448,8 +456,7 @@ static inline int
|
|||
glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
|
||||
GLenum * format,
|
||||
GLenum * type,
|
||||
int *no_alpha,
|
||||
int *no_revert)
|
||||
int *no_alpha, int *no_revert)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PictFormatShort pict_format;
|
||||
|
@ -462,7 +469,8 @@ glamor_get_tex_format_type_from_pixmap(PixmapPtr pixmap,
|
|||
|
||||
return glamor_get_tex_format_type_from_pictformat(pict_format,
|
||||
format, type,
|
||||
no_alpha, no_revert);
|
||||
no_alpha,
|
||||
no_revert);
|
||||
}
|
||||
|
||||
|
||||
|
@ -471,9 +479,7 @@ static inline Bool
|
|||
glamor_get_rgba_from_pixel(CARD32 pixel,
|
||||
float *red,
|
||||
float *green,
|
||||
float * blue,
|
||||
float * alpha,
|
||||
CARD32 format)
|
||||
float *blue, float *alpha, CARD32 format)
|
||||
{
|
||||
int rbits, bbits, gbits, abits;
|
||||
int rshift, bshift, gshift, ashift;
|
||||
|
@ -500,7 +506,8 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
|
|||
ashift = 0;
|
||||
rshift = abits;
|
||||
if (abits == 0)
|
||||
rshift = PICT_FORMAT_BPP(format) - (rbits+gbits+bbits);
|
||||
rshift = PICT_FORMAT_BPP(format) - (rbits + gbits +
|
||||
bbits);
|
||||
gshift = rshift + rbits;
|
||||
bshift = gshift + gbits;
|
||||
#endif
|
||||
|
|
|
@ -39,19 +39,20 @@ glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
|
|||
PixmapPtr pPixmap = *ppPixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
|
||||
{
|
||||
if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel) {
|
||||
pixmap_priv = glamor_get_pixmap_private(pPixmap);
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||
glamor_fallback("pixmap %p has no fbo\n", pPixmap);
|
||||
goto fail;
|
||||
}
|
||||
glamor_debug_output(GLAMOR_DEBUG_UNIMPL, "To be implemented.\n");
|
||||
glamor_debug_output(GLAMOR_DEBUG_UNIMPL,
|
||||
"To be implemented.\n");
|
||||
}
|
||||
return;
|
||||
|
||||
fail:
|
||||
GLAMOR_PANIC(" We can't fall back to fbFixupWindowPixmap, as the fb24_32ReformatTile"
|
||||
GLAMOR_PANIC
|
||||
(" We can't fall back to fbFixupWindowPixmap, as the fb24_32ReformatTile"
|
||||
" is broken for glamor. \n");
|
||||
}
|
||||
|
||||
|
@ -60,15 +61,15 @@ glamor_change_window_attributes(WindowPtr pWin, unsigned long mask)
|
|||
{
|
||||
if (mask & CWBackPixmap) {
|
||||
if (pWin->backgroundState == BackgroundPixmap)
|
||||
glamor_fixup_window_pixmap(&pWin->drawable, &pWin->background.pixmap);
|
||||
glamor_fixup_window_pixmap(&pWin->drawable,
|
||||
&pWin->
|
||||
background.pixmap);
|
||||
}
|
||||
|
||||
if (mask & CWBorderPixmap) {
|
||||
if (pWin->borderIsPixel == FALSE)
|
||||
glamor_fixup_window_pixmap(&pWin->drawable, &pWin->border.pixmap);
|
||||
glamor_fixup_window_pixmap(&pWin->drawable,
|
||||
&pWin->border.pixmap);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user