Merge remote-tracking branch 'anholt/glamor-reformat'
Conflicts: Makefile.am Conflict caused by adding PSEUDORAMIX and GLAMOR directory defines in separate branches
This commit is contained in:
commit
0fbb3d711e
|
@ -31,6 +31,10 @@ if PSEUDORAMIX
|
|||
PSEUDORAMIX_DIR=pseudoramiX
|
||||
endif
|
||||
|
||||
if GLAMOR
|
||||
GLAMOR_DIR=glamor
|
||||
endif
|
||||
|
||||
SUBDIRS = \
|
||||
doc \
|
||||
man \
|
||||
|
@ -55,6 +59,7 @@ SUBDIRS = \
|
|||
$(PRESENT_DIR) \
|
||||
$(DRI3_DIR) \
|
||||
exa \
|
||||
$(GLAMOR_DIR) \
|
||||
config \
|
||||
hw \
|
||||
test
|
||||
|
@ -106,6 +111,7 @@ DIST_SUBDIRS = \
|
|||
composite \
|
||||
glx \
|
||||
exa \
|
||||
$(GLAMOR_DIR) \
|
||||
config \
|
||||
dri3 \
|
||||
present \
|
||||
|
|
10
configure.ac
10
configure.ac
|
@ -636,6 +636,7 @@ AC_ARG_ENABLE(xnest, AS_HELP_STRING([--enable-xnest], [Build Xnest serv
|
|||
AC_ARG_ENABLE(xquartz, AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
|
||||
AC_ARG_ENABLE(standalone-xpbproxy, AS_HELP_STRING([--enable-standalone-xpbproxy], [Build a standalone xpbproxy (in addition to the one integrated into Xquartz as a separate thread) (default: no)]), [STANDALONE_XPBPROXY=$enableval], [STANDALONE_XPBPROXY=no])
|
||||
AC_ARG_ENABLE(xwin, AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
|
||||
AC_ARG_ENABLE(glamor, AS_HELP_STRING([--enable-glamor], [Build glamor dix module (default: no)]), [GLAMOR=$enableval], [GLAMOR=no])
|
||||
dnl kdrive and its subsystems
|
||||
AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
|
||||
AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto])
|
||||
|
@ -2063,6 +2064,14 @@ AM_CONDITIONAL([SOLARIS_VT], [test "x$solaris_vt" = xyes])
|
|||
AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
|
||||
AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
|
||||
AM_CONDITIONAL([XORG_BUS_PLATFORM], [test "x$CONFIG_UDEV_KMS" = xyes])
|
||||
|
||||
dnl glamor
|
||||
AM_CONDITIONAL([GLAMOR], [test "x$GLAMOR" = xyes])
|
||||
if test "x$GLAMOR" = xyes; then
|
||||
AC_DEFINE(GLAMOR, 1, [Build glamor])
|
||||
PKG_CHECK_MODULES([GLAMOR], [egl gl])
|
||||
fi
|
||||
|
||||
dnl XWin DDX
|
||||
|
||||
AC_MSG_CHECKING([whether to build XWin DDX])
|
||||
|
@ -2434,6 +2443,7 @@ doc/Makefile
|
|||
doc/dtrace/Makefile
|
||||
man/Makefile
|
||||
fb/Makefile
|
||||
glamor/Makefile
|
||||
record/Makefile
|
||||
config/Makefile
|
||||
mi/Makefile
|
||||
|
|
|
@ -1,18 +1,10 @@
|
|||
lib_LTLIBRARIES = libglamor.la
|
||||
noinst_LTLIBRARIES = libglamor.la libglamor_egl_stubs.la
|
||||
|
||||
if GLAMOR_GLES2
|
||||
libglamor_la_LIBADD = $(GLESV2_LIBS)
|
||||
else
|
||||
libglamor_la_LIBADD = $(GL_LIBS)
|
||||
endif
|
||||
libglamor_la_LIBADD = $(GLAMOR_LIBS)
|
||||
|
||||
AM_CFLAGS = $(CWARNFLAGS) $(XORG_CFLAGS) $(LIBDRM_CFLAGS)
|
||||
|
||||
libglamor_la_LDFLAGS = -version-info 0:0:0
|
||||
AM_CFLAGS = $(CWARNFLAGS) $(DIX_CFLAGS) $(GLAMOR_CFLAGS)
|
||||
|
||||
libglamor_la_SOURCES = \
|
||||
compat-api.h \
|
||||
compiler.h \
|
||||
glamor.c \
|
||||
glamor_copyarea.c \
|
||||
glamor_copywindow.c \
|
||||
|
@ -48,24 +40,8 @@ libglamor_la_SOURCES = \
|
|||
glamor_compositerects.c\
|
||||
glamor_xv.c\
|
||||
glamor_utils.h\
|
||||
glamor.h\
|
||||
glapi.h
|
||||
glamor.h
|
||||
|
||||
libglamor_egl_stubs_la_SOURCES = glamor_egl_stubs.c
|
||||
|
||||
sdk_HEADERS = glamor.h
|
||||
|
||||
if EGL
|
||||
LIBGLAMOREGL = libglamoregl.la
|
||||
module_LTLIBRARIES = $(LIBGLAMOREGL)
|
||||
libglamoregl_la_DEPENDENCIES = libglamor.la
|
||||
libglamoregl_la_LDFLAGS = -avoid-version -module
|
||||
libglamoregl_la_LIBADD = $(EGL_LIBS) $(GLX_SYS_LIBS) $(GBM_LIBS) libglamor.la
|
||||
libglamoregl_la_SOURCES = glamor_eglmodule.c glamor_egl.c
|
||||
libglamoregl_la_CFLAGS = \
|
||||
$(AM_CFLAGS) \
|
||||
$(GLX_DEFINES) \
|
||||
$(LIBDRM_CFLAGS) \
|
||||
$(EGL_CFLAGS) \
|
||||
$(GBM_CFLAGS)
|
||||
endif
|
||||
|
||||
|
||||
|
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
* Copyright 2012 Red Hat, Inc.
|
||||
*
|
||||
* 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 (including the next
|
||||
* paragraph) 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 AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* Author: Dave Airlie <airlied@redhat.com>
|
||||
*/
|
||||
|
||||
/* this file provides API compat between server post 1.13 and pre it,
|
||||
it should be reused inside as many drivers as possible */
|
||||
#ifndef COMPAT_API_H
|
||||
#define COMPAT_API_H
|
||||
|
||||
#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
|
||||
#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
|
||||
#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
|
||||
#endif
|
||||
|
||||
#ifndef XF86_HAS_SCRN_CONV
|
||||
#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
|
||||
#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
|
||||
#endif
|
||||
|
||||
#ifndef XF86_SCRN_INTERFACE
|
||||
|
||||
#define SCRN_ARG_TYPE int
|
||||
#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = xf86Screens[(arg1)]
|
||||
|
||||
#define SCREEN_ARG_TYPE int
|
||||
#define SCREEN_PTR(arg1) ScreenPtr screen = screenInfo.screens[(arg1)]
|
||||
|
||||
#define SCREEN_INIT_ARGS_DECL int scrnIndex, ScreenPtr screen, int argc, char **argv
|
||||
|
||||
#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer timeout, pointer read_mask
|
||||
#define BLOCKHANDLER_ARGS arg, blockData, timeout, read_mask
|
||||
|
||||
#define WAKEUPHANDLER_ARGS_DECL int arg, pointer wakeupData, unsigned long result, pointer read_mask
|
||||
#define WAKEUPHANDLER_ARGS arg, wakeupData, result, read_mask
|
||||
|
||||
#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr screen
|
||||
#define CLOSE_SCREEN_ARGS scrnIndex, screen
|
||||
|
||||
#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
|
||||
#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0
|
||||
|
||||
#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
|
||||
#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0
|
||||
|
||||
#define FREE_SCREEN_ARGS_DECL int arg, int flags
|
||||
#define FREE_SCREEN_ARGS arg, flags
|
||||
|
||||
#define VT_FUNC_ARGS_DECL int arg, int flags
|
||||
#define VT_FUNC_ARGS(flags) scrn->scrnIndex, (flags)
|
||||
|
||||
#define XF86_ENABLEDISABLEFB_ARG(x) ((x)->scrnIndex)
|
||||
|
||||
#else
|
||||
#define SCRN_ARG_TYPE ScrnInfoPtr
|
||||
#define SCRN_INFO_PTR(arg1) ScrnInfoPtr scrn = (arg1)
|
||||
|
||||
#define SCREEN_ARG_TYPE ScreenPtr
|
||||
#define SCREEN_PTR(arg1) ScreenPtr screen = (arg1)
|
||||
|
||||
#define SCREEN_INIT_ARGS_DECL ScreenPtr screen, int argc, char **argv
|
||||
|
||||
#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer timeout, pointer read_mask
|
||||
#define BLOCKHANDLER_ARGS arg, timeout, read_mask
|
||||
|
||||
#define WAKEUPHANDLER_ARGS_DECL ScreenPtr arg, unsigned long result, pointer read_mask
|
||||
#define WAKEUPHANDLER_ARGS arg, result, read_mask
|
||||
|
||||
#define CLOSE_SCREEN_ARGS_DECL ScreenPtr screen
|
||||
#define CLOSE_SCREEN_ARGS screen
|
||||
|
||||
#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
|
||||
#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
|
||||
|
||||
#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
|
||||
#define SWITCH_MODE_ARGS(arg, m) arg, m
|
||||
|
||||
#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
|
||||
#define FREE_SCREEN_ARGS arg
|
||||
|
||||
#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
|
||||
#define VT_FUNC_ARGS(flags) scrn
|
||||
|
||||
#define XF86_ENABLEDISABLEFB_ARG(x) (x)
|
||||
|
||||
#endif
|
||||
#endif
|
747
glamor/glamor.c
747
glamor/glamor.c
|
@ -54,197 +54,192 @@ DevPrivateKey glamor_pixmap_private_key = &glamor_pixmap_private_key_index;
|
|||
PixmapPtr
|
||||
glamor_get_drawable_pixmap(DrawablePtr drawable)
|
||||
{
|
||||
if (drawable->type == DRAWABLE_WINDOW)
|
||||
return drawable->
|
||||
pScreen->GetWindowPixmap((WindowPtr) drawable);
|
||||
else
|
||||
return (PixmapPtr) drawable;
|
||||
if (drawable->type == DRAWABLE_WINDOW)
|
||||
return drawable->pScreen->GetWindowPixmap((WindowPtr) drawable);
|
||||
else
|
||||
return (PixmapPtr) drawable;
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
|
||||
pixmap_priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key);
|
||||
if (pixmap_priv == NULL) {
|
||||
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
|
||||
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
||||
pixmap_priv->base.pixmap = pixmap;
|
||||
pixmap_priv->base.glamor_priv = glamor_priv;
|
||||
}
|
||||
pixmap_priv->type = type;
|
||||
pixmap_priv = dixLookupPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key);
|
||||
if (pixmap_priv == NULL) {
|
||||
pixmap_priv = calloc(sizeof(*pixmap_priv), 1);
|
||||
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
||||
pixmap_priv->base.pixmap = pixmap;
|
||||
pixmap_priv->base.glamor_priv = glamor_priv;
|
||||
}
|
||||
pixmap_priv->type = type;
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
glamor_set_pixmap_texture(PixmapPtr pixmap, unsigned int tex)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
GLenum format;
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
GLenum format;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (pixmap_priv->base.fbo) {
|
||||
fbo = glamor_pixmap_detach_fbo(pixmap_priv);
|
||||
glamor_destroy_fbo(fbo);
|
||||
}
|
||||
if (pixmap_priv->base.fbo) {
|
||||
fbo = glamor_pixmap_detach_fbo(pixmap_priv);
|
||||
glamor_destroy_fbo(fbo);
|
||||
}
|
||||
|
||||
gl_iformat_for_depth(pixmap->drawable.depth, &format);
|
||||
fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
format, tex, 0);
|
||||
gl_iformat_for_depth(pixmap->drawable.depth, &format);
|
||||
fbo = glamor_create_fbo_from_tex(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height, format, tex, 0);
|
||||
|
||||
if (fbo == NULL) {
|
||||
ErrorF("XXX fail to create fbo.\n");
|
||||
return;
|
||||
}
|
||||
if (fbo == NULL) {
|
||||
ErrorF("XXX fail to create fbo.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen_pixmap->drawable.pScreen);
|
||||
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
|
||||
glamor_priv->screen_fbo = pixmap_priv->base.fbo->fb;
|
||||
glamor_priv = glamor_get_screen_private(screen_pixmap->drawable.pScreen);
|
||||
pixmap_priv = glamor_get_pixmap_private(screen_pixmap);
|
||||
glamor_priv->screen_fbo = pixmap_priv->base.fbo->fb;
|
||||
|
||||
pixmap_priv->base.fbo->width = screen_pixmap->drawable.width;
|
||||
pixmap_priv->base.fbo->height = screen_pixmap->drawable.height;
|
||||
pixmap_priv->base.fbo->width = screen_pixmap->drawable.width;
|
||||
pixmap_priv->base.fbo->height = screen_pixmap->drawable.height;
|
||||
|
||||
glamor_priv->back_pixmap = back_pixmap;
|
||||
glamor_priv->back_pixmap = back_pixmap;
|
||||
}
|
||||
|
||||
PixmapPtr
|
||||
glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||
unsigned int usage)
|
||||
unsigned int usage)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_type_t type = GLAMOR_TEXTURE_ONLY;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_pixmap_fbo *fbo;
|
||||
int pitch;
|
||||
GLenum format;
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_type_t type = GLAMOR_TEXTURE_ONLY;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_fbo *fbo;
|
||||
int pitch;
|
||||
GLenum format;
|
||||
|
||||
if (w > 32767 || h > 32767)
|
||||
return NullPixmap;
|
||||
if (w > 32767 || h > 32767)
|
||||
return NullPixmap;
|
||||
|
||||
if ((usage == GLAMOR_CREATE_PIXMAP_CPU
|
||||
|| (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE && w <= 64 && h <= 64)
|
||||
|| (w == 0 && h == 0)
|
||||
|| !glamor_check_pixmap_fbo_depth(depth))
|
||||
|| (!GLAMOR_TEXTURED_LARGE_PIXMAP &&
|
||||
!glamor_check_fbo_size(glamor_priv, w, h)))
|
||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||
else
|
||||
pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
|
||||
if ((usage == GLAMOR_CREATE_PIXMAP_CPU
|
||||
|| (usage == CREATE_PIXMAP_USAGE_GLYPH_PICTURE && w <= 64 && h <= 64)
|
||||
|| (w == 0 && h == 0)
|
||||
|| !glamor_check_pixmap_fbo_depth(depth))
|
||||
|| (!GLAMOR_TEXTURED_LARGE_PIXMAP &&
|
||||
!glamor_check_fbo_size(glamor_priv, w, h)))
|
||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||
else
|
||||
pixmap = fbCreatePixmap(screen, 0, 0, depth, usage);
|
||||
|
||||
pixmap_priv = calloc(1, sizeof(*pixmap_priv));
|
||||
pixmap_priv = calloc(1, sizeof(*pixmap_priv));
|
||||
|
||||
if (!pixmap_priv) {
|
||||
fbDestroyPixmap(pixmap);
|
||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||
}
|
||||
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
||||
if (!pixmap_priv) {
|
||||
fbDestroyPixmap(pixmap);
|
||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||
}
|
||||
glamor_set_pixmap_private(pixmap, pixmap_priv);
|
||||
|
||||
if (usage == GLAMOR_CREATE_PIXMAP_MAP)
|
||||
type = GLAMOR_MEMORY_MAP;
|
||||
if (usage == GLAMOR_CREATE_PIXMAP_MAP)
|
||||
type = GLAMOR_MEMORY_MAP;
|
||||
|
||||
pixmap_priv->base.pixmap = pixmap;
|
||||
pixmap_priv->base.glamor_priv = glamor_priv;
|
||||
pixmap_priv->base.pixmap = pixmap;
|
||||
pixmap_priv->base.glamor_priv = glamor_priv;
|
||||
|
||||
gl_iformat_for_depth(depth, &format);
|
||||
gl_iformat_for_depth(depth, &format);
|
||||
|
||||
pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
|
||||
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
|
||||
pitch = (((w * pixmap->drawable.bitsPerPixel + 7) / 8) + 3) & ~3;
|
||||
screen->ModifyPixmapHeader(pixmap, w, h, 0, 0, pitch, NULL);
|
||||
|
||||
if (type == GLAMOR_MEMORY_MAP || glamor_check_fbo_size(glamor_priv, w, h)) {
|
||||
pixmap_priv->type = type;
|
||||
fbo = glamor_create_fbo(glamor_priv, w, h, format, usage);
|
||||
}
|
||||
else {
|
||||
DEBUGF("Create LARGE pixmap %p width %d height %d\n", pixmap, w, h);
|
||||
pixmap_priv->type = GLAMOR_TEXTURE_LARGE;
|
||||
fbo = glamor_create_fbo_array(glamor_priv, w, h, format, usage,
|
||||
glamor_priv->max_fbo_size,
|
||||
glamor_priv->max_fbo_size,
|
||||
pixmap_priv);
|
||||
}
|
||||
if (type == GLAMOR_MEMORY_MAP || glamor_check_fbo_size(glamor_priv, w, h)) {
|
||||
pixmap_priv->type = type;
|
||||
fbo = glamor_create_fbo(glamor_priv, w, h, format, usage);
|
||||
}
|
||||
else {
|
||||
DEBUGF("Create LARGE pixmap %p width %d height %d\n", pixmap, w, h);
|
||||
pixmap_priv->type = GLAMOR_TEXTURE_LARGE;
|
||||
fbo = glamor_create_fbo_array(glamor_priv, w, h, format, usage,
|
||||
glamor_priv->max_fbo_size,
|
||||
glamor_priv->max_fbo_size, pixmap_priv);
|
||||
}
|
||||
|
||||
if (fbo == NULL) {
|
||||
fbDestroyPixmap(pixmap);
|
||||
free(pixmap_priv);
|
||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||
}
|
||||
if (fbo == NULL) {
|
||||
fbDestroyPixmap(pixmap);
|
||||
free(pixmap_priv);
|
||||
return fbCreatePixmap(screen, w, h, depth, usage);
|
||||
}
|
||||
|
||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||
|
||||
return pixmap;
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_destroy_textured_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
if (pixmap->refcnt == 1) {
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
if (pixmap->refcnt == 1) {
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv != NULL)
|
||||
glamor_pixmap_destroy_fbo(pixmap_priv);
|
||||
}
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv != NULL)
|
||||
glamor_pixmap_destroy_fbo(pixmap_priv);
|
||||
}
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_destroy_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_screen_private
|
||||
*glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
if (glamor_priv->dri3_enabled)
|
||||
glamor_egl_destroy_textured_pixmap(pixmap);
|
||||
else
|
||||
glamor_destroy_textured_pixmap(pixmap);
|
||||
return fbDestroyPixmap(pixmap);
|
||||
glamor_screen_private
|
||||
*glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
if (glamor_priv->dri3_enabled)
|
||||
glamor_egl_destroy_textured_pixmap(pixmap);
|
||||
else
|
||||
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_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
glamor_priv->tick++;
|
||||
dispatch->glFlush();
|
||||
glamor_fbo_expire(glamor_priv);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
if (glamor_priv->state == RENDER_STATE
|
||||
&& glamor_priv->render_idle_cnt++ > RENDER_IDEL_MAX) {
|
||||
glamor_priv->state = IDLE_STATE;
|
||||
glamor_priv->render_idle_cnt = 0;
|
||||
}
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
glamor_priv->tick++;
|
||||
dispatch->glFlush();
|
||||
glamor_fbo_expire(glamor_priv);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
if (glamor_priv->state == RENDER_STATE
|
||||
&& glamor_priv->render_idle_cnt++ > RENDER_IDEL_MAX) {
|
||||
glamor_priv->state = IDLE_STATE;
|
||||
glamor_priv->render_idle_cnt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
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_screen_private *glamor_priv = data;
|
||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glFlush();
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_screen_private *glamor_priv = data;
|
||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(glamor_priv);
|
||||
|
||||
dispatch->glFlush();
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -255,374 +250,366 @@ _glamor_wakeup_handler(void *data, int result, void *last_select_mask)
|
|||
static void
|
||||
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)
|
||||
return;
|
||||
*debug_level = 0;
|
||||
char *debug_level_string;
|
||||
|
||||
debug_level_string = getenv("GLAMOR_DEBUG");
|
||||
if (debug_level_string
|
||||
&& sscanf(debug_level_string, "%d", debug_level) == 1)
|
||||
return;
|
||||
*debug_level = 0;
|
||||
}
|
||||
|
||||
int glamor_debug_level;
|
||||
|
||||
|
||||
/** Set up glamor for an already-configured GL context. */
|
||||
Bool
|
||||
glamor_init(ScreenPtr screen, unsigned int flags)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
int gl_version;
|
||||
glamor_screen_private *glamor_priv;
|
||||
int gl_version;
|
||||
|
||||
#ifdef RENDER
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
#endif
|
||||
if (flags & ~GLAMOR_VALID_FLAGS) {
|
||||
ErrorF("glamor_init: Invalid flags %x\n", flags);
|
||||
return FALSE;
|
||||
}
|
||||
glamor_priv = calloc(1, sizeof(*glamor_priv));
|
||||
if (glamor_priv == NULL)
|
||||
return FALSE;
|
||||
if (flags & ~GLAMOR_VALID_FLAGS) {
|
||||
ErrorF("glamor_init: Invalid flags %x\n", flags);
|
||||
return FALSE;
|
||||
}
|
||||
glamor_priv = calloc(1, sizeof(*glamor_priv));
|
||||
if (glamor_priv == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (flags & GLAMOR_INVERTED_Y_AXIS) {
|
||||
glamor_priv->yInverted = 1;
|
||||
} else
|
||||
glamor_priv->yInverted = 0;
|
||||
if (flags & GLAMOR_INVERTED_Y_AXIS) {
|
||||
glamor_priv->yInverted = 1;
|
||||
}
|
||||
else
|
||||
glamor_priv->yInverted = 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;
|
||||
}
|
||||
if (!dixRegisterPrivateKey(glamor_screen_private_key, PRIVATE_SCREEN, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate screen private\n",
|
||||
screen->myNum);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glamor_set_screen_private(screen, glamor_priv);
|
||||
glamor_set_screen_private(screen, glamor_priv);
|
||||
|
||||
if (!dixRegisterPrivateKey
|
||||
(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
screen->myNum);
|
||||
goto fail;;
|
||||
}
|
||||
if (!dixRegisterPrivateKey(glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) {
|
||||
LogMessage(X_WARNING,
|
||||
"glamor%d: Failed to allocate pixmap private\n",
|
||||
screen->myNum);
|
||||
goto fail;;
|
||||
}
|
||||
|
||||
gl_version = glamor_gl_get_version();
|
||||
gl_version = glamor_gl_get_version();
|
||||
|
||||
#ifndef GLAMOR_GLES2
|
||||
if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) {
|
||||
ErrorF("Require OpenGL version 1.3 or latter.\n");
|
||||
goto fail;
|
||||
}
|
||||
if (gl_version < GLAMOR_GL_VERSION_ENCODE(1, 3)) {
|
||||
ErrorF("Require OpenGL version 1.3 or latter.\n");
|
||||
goto fail;
|
||||
}
|
||||
#else
|
||||
if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) {
|
||||
ErrorF("Require Open GLES2.0 or latter.\n");
|
||||
goto fail;
|
||||
}
|
||||
if (gl_version < GLAMOR_GL_VERSION_ENCODE(2, 0)) {
|
||||
ErrorF("Require Open GLES2.0 or latter.\n");
|
||||
goto fail;
|
||||
}
|
||||
#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")) {
|
||||
ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
|
||||
goto fail;
|
||||
}
|
||||
if (!glamor_gl_has_extension("GL_EXT_texture_format_BGRA8888")) {
|
||||
ErrorF("GL_EXT_texture_format_BGRA8888 required\n");
|
||||
goto fail;
|
||||
}
|
||||
#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);
|
||||
#ifdef MAX_FBO_SIZE
|
||||
glamor_priv->max_fbo_size = MAX_FBO_SIZE;
|
||||
glamor_priv->max_fbo_size = MAX_FBO_SIZE;
|
||||
#endif
|
||||
|
||||
glamor_set_debug_level(&glamor_debug_level);
|
||||
glamor_set_debug_level(&glamor_debug_level);
|
||||
|
||||
#ifdef GLAMOR_GLES2
|
||||
glamor_priv->gl_flavor = GLAMOR_GL_ES2;
|
||||
glamor_priv->gl_flavor = GLAMOR_GL_ES2;
|
||||
#else
|
||||
glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
|
||||
glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP;
|
||||
#endif
|
||||
/* If we are using egl screen, call egl screen init to
|
||||
* register correct close screen function. */
|
||||
if (flags & GLAMOR_USE_EGL_SCREEN)
|
||||
glamor_egl_screen_init(screen);
|
||||
/* If we are using egl screen, call egl screen init to
|
||||
* register correct close screen function. */
|
||||
if (flags & GLAMOR_USE_EGL_SCREEN)
|
||||
glamor_egl_screen_init(screen);
|
||||
|
||||
glamor_priv->saved_procs.close_screen = screen->CloseScreen;
|
||||
screen->CloseScreen = glamor_close_screen;
|
||||
glamor_priv->saved_procs.close_screen = screen->CloseScreen;
|
||||
screen->CloseScreen = glamor_close_screen;
|
||||
|
||||
if (flags & GLAMOR_USE_SCREEN) {
|
||||
if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
|
||||
_glamor_wakeup_handler,
|
||||
glamor_priv)) {
|
||||
goto fail;
|
||||
}
|
||||
if (flags & GLAMOR_USE_SCREEN) {
|
||||
if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler,
|
||||
_glamor_wakeup_handler,
|
||||
glamor_priv)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
glamor_priv->saved_procs.create_gc = screen->CreateGC;
|
||||
screen->CreateGC = glamor_create_gc;
|
||||
glamor_priv->saved_procs.create_gc = screen->CreateGC;
|
||||
screen->CreateGC = glamor_create_gc;
|
||||
|
||||
glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap;
|
||||
screen->CreatePixmap = glamor_create_pixmap;
|
||||
glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap;
|
||||
screen->CreatePixmap = glamor_create_pixmap;
|
||||
|
||||
glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap;
|
||||
screen->DestroyPixmap = glamor_destroy_pixmap;
|
||||
glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap;
|
||||
screen->DestroyPixmap = glamor_destroy_pixmap;
|
||||
|
||||
glamor_priv->saved_procs.get_spans = screen->GetSpans;
|
||||
screen->GetSpans = glamor_get_spans;
|
||||
glamor_priv->saved_procs.get_spans = screen->GetSpans;
|
||||
screen->GetSpans = glamor_get_spans;
|
||||
|
||||
glamor_priv->saved_procs.get_image = screen->GetImage;
|
||||
screen->GetImage = glamor_get_image;
|
||||
glamor_priv->saved_procs.get_image = screen->GetImage;
|
||||
screen->GetImage = glamor_get_image;
|
||||
|
||||
glamor_priv->saved_procs.change_window_attributes =
|
||||
screen->ChangeWindowAttributes;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_change_window_attributes;
|
||||
glamor_priv->saved_procs.change_window_attributes =
|
||||
screen->ChangeWindowAttributes;
|
||||
screen->ChangeWindowAttributes = glamor_change_window_attributes;
|
||||
|
||||
glamor_priv->saved_procs.copy_window = screen->CopyWindow;
|
||||
screen->CopyWindow = glamor_copy_window;
|
||||
glamor_priv->saved_procs.copy_window = screen->CopyWindow;
|
||||
screen->CopyWindow = glamor_copy_window;
|
||||
|
||||
glamor_priv->saved_procs.bitmap_to_region =
|
||||
screen->BitmapToRegion;
|
||||
screen->BitmapToRegion = glamor_bitmap_to_region;
|
||||
}
|
||||
glamor_priv->saved_procs.bitmap_to_region = screen->BitmapToRegion;
|
||||
screen->BitmapToRegion = glamor_bitmap_to_region;
|
||||
}
|
||||
#ifdef RENDER
|
||||
if (flags & GLAMOR_USE_PICTURE_SCREEN) {
|
||||
glamor_priv->saved_procs.composite = ps->Composite;
|
||||
ps->Composite = glamor_composite;
|
||||
if (flags & GLAMOR_USE_PICTURE_SCREEN) {
|
||||
glamor_priv->saved_procs.composite = ps->Composite;
|
||||
ps->Composite = glamor_composite;
|
||||
|
||||
glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
|
||||
ps->Trapezoids = glamor_trapezoids;
|
||||
|
||||
glamor_priv->saved_procs.trapezoids = ps->Trapezoids;
|
||||
ps->Trapezoids = glamor_trapezoids;
|
||||
glamor_priv->saved_procs.triangles = ps->Triangles;
|
||||
ps->Triangles = glamor_triangles;
|
||||
|
||||
glamor_priv->saved_procs.addtraps = ps->AddTraps;
|
||||
ps->AddTraps = glamor_add_traps;
|
||||
|
||||
glamor_priv->saved_procs.triangles = ps->Triangles;
|
||||
ps->Triangles = glamor_triangles;
|
||||
}
|
||||
|
||||
glamor_priv->saved_procs.addtraps = ps->AddTraps;
|
||||
ps->AddTraps = glamor_add_traps;
|
||||
glamor_priv->saved_procs.composite_rects = ps->CompositeRects;
|
||||
ps->CompositeRects = glamor_composite_rectangles;
|
||||
|
||||
}
|
||||
glamor_priv->saved_procs.glyphs = ps->Glyphs;
|
||||
ps->Glyphs = glamor_glyphs;
|
||||
|
||||
glamor_priv->saved_procs.composite_rects = ps->CompositeRects;
|
||||
ps->CompositeRects = glamor_composite_rectangles;
|
||||
glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph;
|
||||
ps->UnrealizeGlyph = glamor_glyph_unrealize;
|
||||
|
||||
glamor_priv->saved_procs.glyphs = ps->Glyphs;
|
||||
ps->Glyphs = glamor_glyphs;
|
||||
glamor_priv->saved_procs.create_picture = ps->CreatePicture;
|
||||
ps->CreatePicture = glamor_create_picture;
|
||||
|
||||
glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph;
|
||||
ps->UnrealizeGlyph = glamor_glyph_unrealize;
|
||||
glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
|
||||
screen->SetWindowPixmap = glamor_set_window_pixmap;
|
||||
|
||||
glamor_priv->saved_procs.create_picture = ps->CreatePicture;
|
||||
ps->CreatePicture = glamor_create_picture;
|
||||
|
||||
glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
|
||||
screen->SetWindowPixmap = glamor_set_window_pixmap;
|
||||
|
||||
glamor_priv->saved_procs.destroy_picture = ps->DestroyPicture;
|
||||
ps->DestroyPicture = glamor_destroy_picture;
|
||||
glamor_init_composite_shaders(screen);
|
||||
glamor_priv->saved_procs.destroy_picture = ps->DestroyPicture;
|
||||
ps->DestroyPicture = glamor_destroy_picture;
|
||||
glamor_init_composite_shaders(screen);
|
||||
#endif
|
||||
glamor_init_pixmap_fbo(screen);
|
||||
glamor_init_solid_shader(screen);
|
||||
glamor_init_tile_shader(screen);
|
||||
glamor_init_pixmap_fbo(screen);
|
||||
glamor_init_solid_shader(screen);
|
||||
glamor_init_tile_shader(screen);
|
||||
#ifdef GLAMOR_TRAPEZOID_SHADER
|
||||
glamor_init_trapezoid_shader(screen);
|
||||
glamor_init_trapezoid_shader(screen);
|
||||
#endif
|
||||
glamor_init_putimage_shaders(screen);
|
||||
glamor_init_finish_access_shaders(screen);
|
||||
glamor_init_putimage_shaders(screen);
|
||||
glamor_init_finish_access_shaders(screen);
|
||||
#ifdef GLAMOR_GRADIENT_SHADER
|
||||
glamor_init_gradient_shader(screen);
|
||||
glamor_init_gradient_shader(screen);
|
||||
#endif
|
||||
#ifdef GLAMOR_XV
|
||||
glamor_init_xv_shader(screen);
|
||||
glamor_init_xv_shader(screen);
|
||||
#endif
|
||||
glamor_pixmap_init(screen);
|
||||
glamor_pixmap_init(screen);
|
||||
|
||||
glamor_priv->flags = flags;
|
||||
glamor_priv->screen = screen;
|
||||
glamor_priv->flags = flags;
|
||||
glamor_priv->screen = screen;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
free(glamor_priv);
|
||||
glamor_set_screen_private(screen, NULL);
|
||||
return FALSE;
|
||||
fail:
|
||||
free(glamor_priv);
|
||||
glamor_set_screen_private(screen, NULL);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
glamor_release_screen_priv(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_screen_private *glamor_priv;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
#ifdef GLAMOR_XV
|
||||
glamor_fini_xv_shader(screen);
|
||||
glamor_fini_xv_shader(screen);
|
||||
#endif
|
||||
#ifdef RENDER
|
||||
glamor_fini_composite_shaders(screen);
|
||||
glamor_fini_composite_shaders(screen);
|
||||
#endif
|
||||
glamor_fini_pixmap_fbo(screen);
|
||||
glamor_fini_solid_shader(screen);
|
||||
glamor_fini_tile_shader(screen);
|
||||
glamor_fini_pixmap_fbo(screen);
|
||||
glamor_fini_solid_shader(screen);
|
||||
glamor_fini_tile_shader(screen);
|
||||
#ifdef GLAMOR_TRAPEZOID_SHADER
|
||||
glamor_fini_trapezoid_shader(screen);
|
||||
glamor_fini_trapezoid_shader(screen);
|
||||
#endif
|
||||
glamor_fini_putimage_shaders(screen);
|
||||
glamor_fini_finish_access_shaders(screen);
|
||||
glamor_fini_putimage_shaders(screen);
|
||||
glamor_fini_finish_access_shaders(screen);
|
||||
#ifdef GLAMOR_GRADIENT_SHADER
|
||||
glamor_fini_gradient_shader(screen);
|
||||
glamor_fini_gradient_shader(screen);
|
||||
#endif
|
||||
glamor_pixmap_fini(screen);
|
||||
free(glamor_priv);
|
||||
glamor_pixmap_fini(screen);
|
||||
free(glamor_priv);
|
||||
|
||||
glamor_set_screen_private(screen, NULL);
|
||||
glamor_set_screen_private(screen, NULL);
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
glamor_set_pixmap_private(PixmapPtr pixmap, glamor_pixmap_private *priv)
|
||||
{
|
||||
glamor_pixmap_private *old_priv;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
glamor_pixmap_private *old_priv;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
old_priv = dixGetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
|
||||
old_priv = dixGetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key);
|
||||
|
||||
if (priv) {
|
||||
assert(old_priv == NULL);
|
||||
} else {
|
||||
if (old_priv == NULL)
|
||||
return;
|
||||
fbo = glamor_pixmap_detach_fbo(old_priv);
|
||||
glamor_purge_fbo(fbo);
|
||||
free(old_priv);
|
||||
}
|
||||
if (priv) {
|
||||
assert(old_priv == NULL);
|
||||
}
|
||||
else {
|
||||
if (old_priv == NULL)
|
||||
return;
|
||||
fbo = glamor_pixmap_detach_fbo(old_priv);
|
||||
glamor_purge_fbo(fbo);
|
||||
free(old_priv);
|
||||
}
|
||||
|
||||
dixSetPrivate(&pixmap->devPrivates,
|
||||
glamor_pixmap_private_key,
|
||||
priv);
|
||||
dixSetPrivate(&pixmap->devPrivates, glamor_pixmap_private_key, priv);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_close_screen(CLOSE_SCREEN_ARGS_DECL)
|
||||
glamor_close_screen(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
PixmapPtr screen_pixmap;
|
||||
int flags;
|
||||
glamor_screen_private *glamor_priv;
|
||||
PixmapPtr screen_pixmap;
|
||||
int flags;
|
||||
|
||||
#ifdef RENDER
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
PictureScreenPtr ps = GetPictureScreenIfSet(screen);
|
||||
#endif
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
flags = glamor_priv->flags;
|
||||
glamor_glyphs_fini(screen);
|
||||
screen->CloseScreen = glamor_priv->saved_procs.close_screen;
|
||||
if (flags & GLAMOR_USE_SCREEN) {
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
flags = glamor_priv->flags;
|
||||
glamor_glyphs_fini(screen);
|
||||
screen->CloseScreen = glamor_priv->saved_procs.close_screen;
|
||||
if (flags & GLAMOR_USE_SCREEN) {
|
||||
|
||||
screen->CreateGC = glamor_priv->saved_procs.create_gc;
|
||||
screen->CreatePixmap = glamor_priv->saved_procs.create_pixmap;
|
||||
screen->DestroyPixmap = glamor_priv->saved_procs.destroy_pixmap;
|
||||
screen->GetSpans = glamor_priv->saved_procs.get_spans;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_priv->saved_procs.change_window_attributes;
|
||||
screen->CopyWindow = glamor_priv->saved_procs.copy_window;
|
||||
screen->BitmapToRegion = glamor_priv->saved_procs.bitmap_to_region;
|
||||
}
|
||||
screen->CreateGC = glamor_priv->saved_procs.create_gc;
|
||||
screen->CreatePixmap = glamor_priv->saved_procs.create_pixmap;
|
||||
screen->DestroyPixmap = glamor_priv->saved_procs.destroy_pixmap;
|
||||
screen->GetSpans = glamor_priv->saved_procs.get_spans;
|
||||
screen->ChangeWindowAttributes =
|
||||
glamor_priv->saved_procs.change_window_attributes;
|
||||
screen->CopyWindow = glamor_priv->saved_procs.copy_window;
|
||||
screen->BitmapToRegion = glamor_priv->saved_procs.bitmap_to_region;
|
||||
}
|
||||
#ifdef RENDER
|
||||
if (ps && (flags & GLAMOR_USE_PICTURE_SCREEN)) {
|
||||
if (ps && (flags & GLAMOR_USE_PICTURE_SCREEN)) {
|
||||
|
||||
ps->Composite = glamor_priv->saved_procs.composite;
|
||||
ps->Trapezoids = glamor_priv->saved_procs.trapezoids;
|
||||
ps->Triangles = glamor_priv->saved_procs.triangles;
|
||||
ps->CreatePicture = glamor_priv->saved_procs.create_picture;
|
||||
}
|
||||
ps->CompositeRects = glamor_priv->saved_procs.composite_rects;
|
||||
ps->Glyphs = glamor_priv->saved_procs.glyphs;
|
||||
ps->UnrealizeGlyph = glamor_priv->saved_procs.unrealize_glyph;
|
||||
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
||||
ps->Composite = glamor_priv->saved_procs.composite;
|
||||
ps->Trapezoids = glamor_priv->saved_procs.trapezoids;
|
||||
ps->Triangles = glamor_priv->saved_procs.triangles;
|
||||
ps->CreatePicture = glamor_priv->saved_procs.create_picture;
|
||||
}
|
||||
ps->CompositeRects = glamor_priv->saved_procs.composite_rects;
|
||||
ps->Glyphs = glamor_priv->saved_procs.glyphs;
|
||||
ps->UnrealizeGlyph = glamor_priv->saved_procs.unrealize_glyph;
|
||||
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
||||
#endif
|
||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
glamor_set_pixmap_private(screen_pixmap, NULL);
|
||||
if (glamor_priv->back_pixmap && *glamor_priv->back_pixmap)
|
||||
glamor_set_pixmap_private(*glamor_priv->back_pixmap, NULL);
|
||||
screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
glamor_set_pixmap_private(screen_pixmap, NULL);
|
||||
if (glamor_priv->back_pixmap && *glamor_priv->back_pixmap)
|
||||
glamor_set_pixmap_private(*glamor_priv->back_pixmap, NULL);
|
||||
|
||||
glamor_release_screen_priv(screen);
|
||||
glamor_release_screen_priv(screen);
|
||||
|
||||
return screen->CloseScreen(CLOSE_SCREEN_ARGS);
|
||||
return screen->CloseScreen(screen);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fini(ScreenPtr screen)
|
||||
{
|
||||
/* Do nothing currently. */
|
||||
/* Do nothing currently. */
|
||||
}
|
||||
|
||||
void glamor_enable_dri3(ScreenPtr screen)
|
||||
void
|
||||
glamor_enable_dri3(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_priv->dri3_enabled = TRUE;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
||||
glamor_priv->dri3_enabled = TRUE;
|
||||
}
|
||||
|
||||
Bool glamor_is_dri3_support_enabled(ScreenPtr screen)
|
||||
Bool
|
||||
glamor_is_dri3_support_enabled(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
return glamor_priv->dri3_enabled;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
|
||||
return glamor_priv->dri3_enabled;
|
||||
}
|
||||
|
||||
int
|
||||
glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
CARD16 *stride,
|
||||
CARD32 *size)
|
||||
glamor_dri3_fd_from_pixmap(ScreenPtr screen,
|
||||
PixmapPtr pixmap, CARD16 *stride, CARD32 *size)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||
return -1;
|
||||
switch (pixmap_priv->type)
|
||||
{
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||
return glamor_egl_dri3_fd_name_from_tex(screen,
|
||||
pixmap,
|
||||
pixmap_priv->base.fbo->tex,
|
||||
FALSE,
|
||||
stride,
|
||||
size);
|
||||
default: break;
|
||||
}
|
||||
return -1;
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||
return -1;
|
||||
switch (pixmap_priv->type) {
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||
return glamor_egl_dri3_fd_name_from_tex(screen,
|
||||
pixmap,
|
||||
pixmap_priv->base.fbo->tex,
|
||||
FALSE, stride, size);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
glamor_dri3_name_from_pixmap (PixmapPtr pixmap)
|
||||
glamor_dri3_name_from_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||
return -1;
|
||||
switch (pixmap_priv->type)
|
||||
{
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||
return glamor_egl_dri3_fd_name_from_tex(pixmap->drawable.pScreen,
|
||||
pixmap,
|
||||
pixmap_priv->base.fbo->tex,
|
||||
TRUE,
|
||||
NULL,
|
||||
NULL);
|
||||
default: break;
|
||||
}
|
||||
return -1;
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv == NULL || !glamor_priv->dri3_enabled)
|
||||
return -1;
|
||||
switch (pixmap_priv->type) {
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
glamor_pixmap_ensure_fbo(pixmap, GL_RGBA, 0);
|
||||
return glamor_egl_dri3_fd_name_from_tex(pixmap->drawable.pScreen,
|
||||
pixmap,
|
||||
pixmap_priv->base.fbo->tex,
|
||||
TRUE, NULL, NULL);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
|
255
glamor/glamor.h
255
glamor/glamor.h
|
@ -30,14 +30,12 @@
|
|||
#define GLAMOR_H
|
||||
|
||||
#include <scrnintstr.h>
|
||||
#include <xf86.h>
|
||||
#include <xf86str.h>
|
||||
#include <pixmapstr.h>
|
||||
#include <gcstruct.h>
|
||||
#include <picturestr.h>
|
||||
#include <fb.h>
|
||||
#include <fbpict.h>
|
||||
#include <xf86xv.h>
|
||||
|
||||
/*
|
||||
* glamor_pixmap_type : glamor pixmap's type.
|
||||
* @MEMORY: pixmap is in memory.
|
||||
|
@ -48,15 +46,15 @@
|
|||
* @DRM_ONLY: pixmap is in a external DRM buffer.
|
||||
* @TEXTURE_ONLY: pixmap is in an internal texture.
|
||||
*/
|
||||
typedef enum glamor_pixmap_type {
|
||||
GLAMOR_MEMORY,
|
||||
GLAMOR_MEMORY_MAP,
|
||||
GLAMOR_TEXTURE_DRM,
|
||||
GLAMOR_SEPARATE_TEXTURE,
|
||||
GLAMOR_DRM_ONLY,
|
||||
GLAMOR_TEXTURE_ONLY,
|
||||
GLAMOR_TEXTURE_LARGE,
|
||||
GLAMOR_TEXTURE_PACK
|
||||
typedef enum glamor_pixmap_type {
|
||||
GLAMOR_MEMORY,
|
||||
GLAMOR_MEMORY_MAP,
|
||||
GLAMOR_TEXTURE_DRM,
|
||||
GLAMOR_SEPARATE_TEXTURE,
|
||||
GLAMOR_DRM_ONLY,
|
||||
GLAMOR_TEXTURE_ONLY,
|
||||
GLAMOR_TEXTURE_LARGE,
|
||||
GLAMOR_TEXTURE_PACK
|
||||
} glamor_pixmap_type_t;
|
||||
|
||||
#define GLAMOR_EGL_EXTERNAL_BUFFER 3
|
||||
|
@ -116,17 +114,13 @@ extern _X_EXPORT void glamor_fini(ScreenPtr screen);
|
|||
* screen pixmap which must be a glamor pixmap and requires
|
||||
* the internal data structure still exist at that time.
|
||||
* Otherwise, the glamor internal structure will not be freed.*/
|
||||
#ifndef XF86_SCRN_INTERFACE
|
||||
extern _X_EXPORT Bool glamor_close_screen(int scrnIndex, ScreenPtr screen);
|
||||
#else
|
||||
extern _X_EXPORT Bool glamor_close_screen(ScreenPtr screen);
|
||||
#endif
|
||||
|
||||
|
||||
/* Let glamor to know the screen's fbo. The low level
|
||||
* driver should already assign a tex
|
||||
* to this pixmap through the set_pixmap_texture. */
|
||||
extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPtr *back_pixmap);
|
||||
extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap,
|
||||
PixmapPtr *back_pixmap);
|
||||
|
||||
/* @glamor_glyphs_init: Initialize glyphs internal data structures.
|
||||
*
|
||||
|
@ -139,13 +133,14 @@ extern _X_EXPORT void glamor_set_screen_pixmap(PixmapPtr screen_pixmap, PixmapPt
|
|||
extern _X_EXPORT Bool glamor_glyphs_init(ScreenPtr pScreen);
|
||||
|
||||
extern _X_EXPORT void glamor_set_pixmap_texture(PixmapPtr pixmap,
|
||||
unsigned int tex);
|
||||
unsigned int tex);
|
||||
|
||||
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap, glamor_pixmap_type_t type);
|
||||
extern _X_EXPORT void glamor_set_pixmap_type(PixmapPtr pixmap,
|
||||
glamor_pixmap_type_t type);
|
||||
extern _X_EXPORT void glamor_destroy_textured_pixmap(PixmapPtr pixmap);
|
||||
extern _X_EXPORT void glamor_block_handler(ScreenPtr screen);
|
||||
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h, int depth,
|
||||
unsigned int usage);
|
||||
extern _X_EXPORT PixmapPtr glamor_create_pixmap(ScreenPtr screen, int w, int h,
|
||||
int depth, unsigned int usage);
|
||||
|
||||
extern _X_EXPORT void glamor_egl_screen_init(ScreenPtr screen);
|
||||
|
||||
|
@ -160,14 +155,21 @@ extern _X_EXPORT void glamor_egl_restore_context(ScreenPtr screen);
|
|||
* Used by the DRI2 page flip. This function will exchange the KHR images and
|
||||
* fbos of the two pixmaps.
|
||||
* */
|
||||
extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front, PixmapPtr back);
|
||||
extern _X_EXPORT void glamor_egl_exchange_buffers(PixmapPtr front,
|
||||
PixmapPtr back);
|
||||
|
||||
extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back);
|
||||
extern _X_EXPORT void glamor_pixmap_exchange_fbos(PixmapPtr front,
|
||||
PixmapPtr back);
|
||||
|
||||
/* The DDX is not supposed to call these three functions */
|
||||
extern _X_EXPORT void glamor_enable_dri3(ScreenPtr screen);
|
||||
extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h);
|
||||
extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr, unsigned int, Bool, CARD16*, CARD32*);
|
||||
extern _X_EXPORT unsigned int glamor_egl_create_argb8888_based_texture(ScreenPtr
|
||||
screen,
|
||||
int w,
|
||||
int h);
|
||||
extern _X_EXPORT int glamor_egl_dri3_fd_name_from_tex(ScreenPtr, PixmapPtr,
|
||||
unsigned int, Bool,
|
||||
CARD16 *, CARD32 *);
|
||||
|
||||
/* @glamor_is_dri3_support_enabled: Returns if DRI3 support is enabled.
|
||||
*
|
||||
|
@ -194,10 +196,9 @@ extern _X_EXPORT Bool glamor_is_dri3_support_enabled(ScreenPtr screen);
|
|||
* content.
|
||||
* Returns the fd on success, -1 on error.
|
||||
* */
|
||||
extern _X_EXPORT int glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
CARD16 *stride,
|
||||
CARD32 *size);
|
||||
extern _X_EXPORT int glamor_dri3_fd_from_pixmap(ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
CARD16 *stride, CARD32 *size);
|
||||
|
||||
/* @glamor_dri3_name_from_pixmap: helper to get an gem name from a pixmap.
|
||||
*
|
||||
|
@ -208,7 +209,7 @@ extern _X_EXPORT int glamor_dri3_fd_from_pixmap (ScreenPtr screen,
|
|||
* glamor DRI3 support to be activated.
|
||||
* Returns the name on success, -1 on error.
|
||||
* */
|
||||
extern _X_EXPORT int glamor_dri3_name_from_pixmap (PixmapPtr pixmap);
|
||||
extern _X_EXPORT int glamor_dri3_name_from_pixmap(PixmapPtr pixmap);
|
||||
|
||||
/* @glamor_egl_dri3_pixmap_from_fd: DRI3 helper to get a pixmap from a dma-buf fd.
|
||||
*
|
||||
|
@ -222,13 +223,13 @@ extern _X_EXPORT int glamor_dri3_name_from_pixmap (PixmapPtr pixmap);
|
|||
*
|
||||
* Returns a valid pixmap if the import succeeded, else NULL.
|
||||
* */
|
||||
extern _X_EXPORT PixmapPtr glamor_egl_dri3_pixmap_from_fd (ScreenPtr screen,
|
||||
int fd,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
CARD16 stride,
|
||||
CARD8 depth,
|
||||
CARD8 bpp);
|
||||
extern _X_EXPORT PixmapPtr glamor_egl_dri3_pixmap_from_fd(ScreenPtr screen,
|
||||
int fd,
|
||||
CARD16 width,
|
||||
CARD16 height,
|
||||
CARD16 stride,
|
||||
CARD8 depth,
|
||||
CARD8 bpp);
|
||||
|
||||
#ifdef GLAMOR_FOR_XORG
|
||||
|
||||
|
@ -265,8 +266,7 @@ extern _X_EXPORT Bool glamor_egl_init_textured_pixmap(ScreenPtr screen);
|
|||
* screen pixmap is a special, we handle it separately in this function.
|
||||
*/
|
||||
extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
|
||||
int handle,
|
||||
int stride);
|
||||
int handle, int stride);
|
||||
|
||||
/* @glamor_egl_create_textured_screen_ext:
|
||||
*
|
||||
|
@ -275,9 +275,10 @@ extern _X_EXPORT Bool glamor_egl_create_textured_screen(ScreenPtr screen,
|
|||
* the DDX's close screen, we have to free all the glamor related resources.
|
||||
*/
|
||||
extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
||||
int handle,
|
||||
int stride,
|
||||
PixmapPtr *back_pixmap);
|
||||
int handle,
|
||||
int stride,
|
||||
PixmapPtr
|
||||
*back_pixmap);
|
||||
|
||||
/*
|
||||
* @glamor_egl_create_textured_pixmap: Try to create a textured pixmap from
|
||||
|
@ -292,8 +293,7 @@ extern _X_EXPORT Bool glamor_egl_create_textured_screen_ext(ScreenPtr screen,
|
|||
* as well. Return true if successful, otherwise return FALSE.
|
||||
*/
|
||||
extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
|
||||
int handle,
|
||||
int stride);
|
||||
int handle, int stride);
|
||||
|
||||
/*
|
||||
* @glamor_egl_create_textured_pixmap_from_bo: Try to create a textured pixmap
|
||||
|
@ -305,8 +305,7 @@ extern _X_EXPORT Bool glamor_egl_create_textured_pixmap(PixmapPtr pixmap,
|
|||
* This function is similar to glamor_egl_create_textured_pixmap.
|
||||
*/
|
||||
extern _X_EXPORT Bool
|
||||
glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap,
|
||||
void *bo);
|
||||
glamor_egl_create_textured_pixmap_from_gbm_bo(PixmapPtr pixmap, void *bo);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -314,119 +313,131 @@ extern _X_EXPORT void glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap);
|
|||
|
||||
extern _X_EXPORT int glamor_create_gc(GCPtr gc);
|
||||
|
||||
extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable);
|
||||
extern _X_EXPORT void glamor_validate_gc(GCPtr gc, unsigned long changes,
|
||||
DrawablePtr drawable);
|
||||
/* Glamor rendering/drawing functions with XXX_nf.
|
||||
* nf means no fallback within glamor internal if possible. If glamor
|
||||
* fail to accelerate the operation, glamor will return a false, and the
|
||||
* caller need to implement fallback method. Return a true means the
|
||||
* rendering request get done successfully. */
|
||||
extern _X_EXPORT Bool glamor_fill_spans_nf(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points,
|
||||
int *widths, int sorted);
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points,
|
||||
int *widths, int sorted);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_fill_rect_nf(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int nrect,
|
||||
xRectangle * prect);
|
||||
GCPtr gc,
|
||||
int nrect, xRectangle *prect);
|
||||
|
||||
extern _X_EXPORT Bool glamor_put_image_nf(DrawablePtr drawable,
|
||||
GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int left_pad,
|
||||
int image_format, char *bits);
|
||||
GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int left_pad,
|
||||
int image_format, char *bits);
|
||||
|
||||
extern _X_EXPORT Bool glamor_copy_n_to_n_nf(DrawablePtr src,
|
||||
DrawablePtr dst,
|
||||
GCPtr gc,
|
||||
BoxPtr box,
|
||||
int nbox,
|
||||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane,
|
||||
void *closure);
|
||||
DrawablePtr dst,
|
||||
GCPtr gc,
|
||||
BoxPtr box,
|
||||
int nbox,
|
||||
int dx,
|
||||
int dy,
|
||||
Bool reverse,
|
||||
Bool upsidedown, Pixel bitplane,
|
||||
void *closure);
|
||||
|
||||
extern _X_EXPORT Bool glamor_composite_nf(CARD8 op,
|
||||
PicturePtr source,
|
||||
PicturePtr mask,
|
||||
PicturePtr dest,
|
||||
INT16 x_source,
|
||||
INT16 y_source,
|
||||
INT16 x_mask,
|
||||
INT16 y_mask,
|
||||
INT16 x_dest, INT16 y_dest,
|
||||
CARD16 width, CARD16 height);
|
||||
PicturePtr source,
|
||||
PicturePtr mask,
|
||||
PicturePtr dest,
|
||||
INT16 x_source,
|
||||
INT16 y_source,
|
||||
INT16 x_mask,
|
||||
INT16 y_mask,
|
||||
INT16 x_dest, INT16 y_dest,
|
||||
CARD16 width, CARD16 height);
|
||||
|
||||
extern _X_EXPORT Bool glamor_trapezoids_nf(CARD8 op,
|
||||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format,
|
||||
INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid * traps);
|
||||
PicturePtr src, PicturePtr dst,
|
||||
PictFormatPtr mask_format,
|
||||
INT16 x_src, INT16 y_src,
|
||||
int ntrap, xTrapezoid *traps);
|
||||
|
||||
extern _X_EXPORT Bool glamor_glyphs_nf(CARD8 op,
|
||||
PicturePtr src,
|
||||
PicturePtr dst,
|
||||
PictFormatPtr mask_format,
|
||||
INT16 x_src,
|
||||
INT16 y_src, int nlist,
|
||||
GlyphListPtr list, GlyphPtr * glyphs);
|
||||
PicturePtr src,
|
||||
PicturePtr dst,
|
||||
PictFormatPtr mask_format,
|
||||
INT16 x_src,
|
||||
INT16 y_src, int nlist,
|
||||
GlyphListPtr list, GlyphPtr *glyphs);
|
||||
|
||||
extern _X_EXPORT Bool glamor_triangles_nf(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc,
|
||||
int ntris, xTriangle * tris);
|
||||
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc,
|
||||
int ntris, xTriangle *tris);
|
||||
|
||||
extern _X_EXPORT void glamor_glyph_unrealize(ScreenPtr screen, GlyphPtr glyph);
|
||||
|
||||
extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int n, int sorted);
|
||||
extern _X_EXPORT Bool glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc,
|
||||
char *src, DDXPointPtr points,
|
||||
int *widths, int n, int sorted);
|
||||
|
||||
extern _X_EXPORT Bool glamor_get_spans_nf(DrawablePtr drawable, int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst);
|
||||
DDXPointPtr points, int *widths,
|
||||
int count, char *dst);
|
||||
|
||||
extern _X_EXPORT Bool glamor_composite_rects_nf (CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect,
|
||||
xRectangle *rects);
|
||||
extern _X_EXPORT Bool glamor_composite_rects_nf(CARD8 op,
|
||||
PicturePtr pDst,
|
||||
xRenderColor *color,
|
||||
int nRect, xRectangle *rects);
|
||||
|
||||
extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d);
|
||||
extern _X_EXPORT Bool glamor_get_image_nf(DrawablePtr pDrawable, int x, int y,
|
||||
int w, int h, unsigned int format,
|
||||
unsigned long planeMask, char *d);
|
||||
|
||||
extern _X_EXPORT Bool glamor_add_traps_nf(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps);
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap,
|
||||
xTrap *traps);
|
||||
|
||||
extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane, RegionPtr *pRegion);
|
||||
extern _X_EXPORT Bool glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst,
|
||||
GCPtr pGC, int srcx, int srcy, int w,
|
||||
int h, int dstx, int dsty,
|
||||
unsigned long bitPlane,
|
||||
RegionPtr *pRegion);
|
||||
|
||||
extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
extern _X_EXPORT Bool glamor_image_glyph_blt_nf(DrawablePtr pDrawable,
|
||||
GCPtr pGC, int x, int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppci,
|
||||
void *pglyphBase);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase);
|
||||
int x, int y,
|
||||
unsigned int nglyph,
|
||||
CharInfoPtr *ppci,
|
||||
void *pglyphBase);
|
||||
|
||||
extern _X_EXPORT Bool glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y);
|
||||
DrawablePtr pDrawable, int w, int h,
|
||||
int x, int y);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
extern _X_EXPORT Bool glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int mode, int npt, DDXPointPtr ppt);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg);
|
||||
extern _X_EXPORT Bool glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int nseg, xSegment *pSeg);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt);
|
||||
extern _X_EXPORT Bool glamor_poly_line_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int mode, int npt, DDXPointPtr ppt);
|
||||
|
||||
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
DDXPointPtr points);
|
||||
extern _X_EXPORT Bool glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc,
|
||||
int mode, int n, DDXPointPtr points);
|
||||
|
||||
extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen, int num_texture_ports);
|
||||
#if 0
|
||||
extern _X_EXPORT XF86VideoAdaptorPtr glamor_xv_init(ScreenPtr pScreen,
|
||||
int num_texture_ports);
|
||||
#endif
|
||||
|
||||
#endif /* GLAMOR_H */
|
||||
#endif /* GLAMOR_H */
|
||||
|
|
|
@ -30,36 +30,32 @@
|
|||
|
||||
static Bool
|
||||
_glamor_add_traps(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps,
|
||||
Bool fallback)
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap *traps, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& ( !pPicture->pDrawable
|
||||
|| glamor_ddx_fallback_check_pixmap(pPicture->pDrawable)))
|
||||
return FALSE;
|
||||
if (!fallback
|
||||
&& (!pPicture->pDrawable
|
||||
|| glamor_ddx_fallback_check_pixmap(pPicture->pDrawable)))
|
||||
return FALSE;
|
||||
|
||||
if (glamor_prepare_access_picture(pPicture, GLAMOR_ACCESS_RW)) {
|
||||
fbAddTraps(pPicture, x_off, y_off, ntrap, traps);
|
||||
glamor_finish_access_picture(pPicture, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
if (glamor_prepare_access_picture(pPicture, GLAMOR_ACCESS_RW)) {
|
||||
fbAddTraps(pPicture, x_off, y_off, ntrap, traps);
|
||||
glamor_finish_access_picture(pPicture, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_add_traps(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps)
|
||||
INT16 x_off, INT16 y_off, int ntrap, xTrap *traps)
|
||||
{
|
||||
_glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, TRUE);
|
||||
_glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_add_traps_nf(PicturePtr pPicture,
|
||||
INT16 x_off,
|
||||
INT16 y_off, int ntrap, xTrap * traps)
|
||||
INT16 x_off, INT16 y_off, int ntrap, xTrap *traps)
|
||||
{
|
||||
return _glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, FALSE);
|
||||
return _glamor_add_traps(pPicture, x_off, y_off, ntrap, traps, FALSE);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,243 +36,241 @@
|
|||
* compositeRects acceleration implementation
|
||||
*/
|
||||
|
||||
static int16_t bound(int16_t a, uint16_t b)
|
||||
static int16_t
|
||||
bound(int16_t a, uint16_t b)
|
||||
{
|
||||
int v = (int)a + (int)b;
|
||||
if (v > MAXSHORT)
|
||||
return MAXSHORT;
|
||||
return v;
|
||||
int v = (int) a + (int) b;
|
||||
|
||||
if (v > MAXSHORT)
|
||||
return MAXSHORT;
|
||||
return v;
|
||||
}
|
||||
|
||||
static Bool
|
||||
_pixman_region_init_clipped_rectangles(pixman_region16_t *region,
|
||||
unsigned int num_rects,
|
||||
xRectangle *rects,
|
||||
int tx, int ty,
|
||||
BoxPtr extents)
|
||||
_pixman_region_init_clipped_rectangles(pixman_region16_t * region,
|
||||
unsigned int num_rects,
|
||||
xRectangle *rects,
|
||||
int tx, int ty, BoxPtr extents)
|
||||
{
|
||||
pixman_box16_t stack_boxes[64], *boxes = stack_boxes;
|
||||
pixman_bool_t ret;
|
||||
unsigned int i, j;
|
||||
pixman_box16_t stack_boxes[64], *boxes = stack_boxes;
|
||||
pixman_bool_t ret;
|
||||
unsigned int i, j;
|
||||
|
||||
if (num_rects > ARRAY_SIZE(stack_boxes)) {
|
||||
boxes = malloc(sizeof(pixman_box16_t) * num_rects);
|
||||
if (boxes == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
if (num_rects > ARRAY_SIZE(stack_boxes)) {
|
||||
boxes = malloc(sizeof(pixman_box16_t) * num_rects);
|
||||
if (boxes == NULL)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (i = j = 0; i < num_rects; i++) {
|
||||
boxes[j].x1 = rects[i].x + tx;
|
||||
if (boxes[j].x1 < extents->x1)
|
||||
boxes[j].x1 = extents->x1;
|
||||
for (i = j = 0; i < num_rects; i++) {
|
||||
boxes[j].x1 = rects[i].x + tx;
|
||||
if (boxes[j].x1 < extents->x1)
|
||||
boxes[j].x1 = extents->x1;
|
||||
|
||||
boxes[j].y1 = rects[i].y + ty;
|
||||
if (boxes[j].y1 < extents->y1)
|
||||
boxes[j].y1 = extents->y1;
|
||||
boxes[j].y1 = rects[i].y + ty;
|
||||
if (boxes[j].y1 < extents->y1)
|
||||
boxes[j].y1 = extents->y1;
|
||||
|
||||
boxes[j].x2 = bound(rects[i].x + tx, rects[i].width);
|
||||
if (boxes[j].x2 > extents->x2)
|
||||
boxes[j].x2 = extents->x2;
|
||||
boxes[j].x2 = bound(rects[i].x + tx, rects[i].width);
|
||||
if (boxes[j].x2 > extents->x2)
|
||||
boxes[j].x2 = extents->x2;
|
||||
|
||||
boxes[j].y2 = bound(rects[i].y + ty, rects[i].height);
|
||||
if (boxes[j].y2 > extents->y2)
|
||||
boxes[j].y2 = extents->y2;
|
||||
boxes[j].y2 = bound(rects[i].y + ty, rects[i].height);
|
||||
if (boxes[j].y2 > extents->y2)
|
||||
boxes[j].y2 = extents->y2;
|
||||
|
||||
if (boxes[j].x2 > boxes[j].x1 && boxes[j].y2 > boxes[j].y1)
|
||||
j++;
|
||||
}
|
||||
if (boxes[j].x2 > boxes[j].x1 && boxes[j].y2 > boxes[j].y1)
|
||||
j++;
|
||||
}
|
||||
|
||||
ret = FALSE;
|
||||
if (j)
|
||||
ret = pixman_region_init_rects(region, boxes, j);
|
||||
ret = FALSE;
|
||||
if (j)
|
||||
ret = pixman_region_init_rects(region, boxes, j);
|
||||
|
||||
if (boxes != stack_boxes)
|
||||
free(boxes);
|
||||
if (boxes != stack_boxes)
|
||||
free(boxes);
|
||||
|
||||
DEBUGF("%s: nrects=%d, region=(%d, %d), (%d, %d) x %d\n",
|
||||
__FUNCTION__, num_rects,
|
||||
region->extents.x1, region->extents.y1,
|
||||
region->extents.x2, region->extents.y2,
|
||||
j);
|
||||
return ret;
|
||||
DEBUGF("%s: nrects=%d, region=(%d, %d), (%d, %d) x %d\n",
|
||||
__FUNCTION__, num_rects,
|
||||
region->extents.x1, region->extents.y1,
|
||||
region->extents.x2, region->extents.y2, j);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_composite_rectangles(CARD8 op,
|
||||
PicturePtr dst,
|
||||
xRenderColor *color,
|
||||
int num_rects,
|
||||
xRectangle *rects)
|
||||
glamor_composite_rectangles(CARD8 op,
|
||||
PicturePtr dst,
|
||||
xRenderColor * color,
|
||||
int num_rects, xRectangle *rects)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
struct glamor_pixmap_private *priv;
|
||||
pixman_region16_t region;
|
||||
pixman_box16_t *boxes;
|
||||
int dst_x, dst_y;
|
||||
int num_boxes;
|
||||
PicturePtr source = NULL;
|
||||
Bool need_free_region = FALSE;
|
||||
PixmapPtr pixmap;
|
||||
struct glamor_pixmap_private *priv;
|
||||
pixman_region16_t region;
|
||||
pixman_box16_t *boxes;
|
||||
int dst_x, dst_y;
|
||||
int num_boxes;
|
||||
PicturePtr source = NULL;
|
||||
Bool need_free_region = FALSE;
|
||||
|
||||
DEBUGF("%s(op=%d, %08x x %d [(%d, %d)x(%d, %d) ...])\n",
|
||||
__FUNCTION__, op,
|
||||
(color->alpha >> 8 << 24) |
|
||||
(color->red >> 8 << 16) |
|
||||
(color->green >> 8 << 8) |
|
||||
(color->blue >> 8 << 0),
|
||||
num_rects,
|
||||
rects[0].x, rects[0].y, rects[0].width, rects[0].height);
|
||||
DEBUGF("%s(op=%d, %08x x %d [(%d, %d)x(%d, %d) ...])\n",
|
||||
__FUNCTION__, op,
|
||||
(color->alpha >> 8 << 24) |
|
||||
(color->red >> 8 << 16) |
|
||||
(color->green >> 8 << 8) |
|
||||
(color->blue >> 8 << 0),
|
||||
num_rects, rects[0].x, rects[0].y, rects[0].width, rects[0].height);
|
||||
|
||||
if (!num_rects)
|
||||
return;
|
||||
if (!num_rects)
|
||||
return;
|
||||
|
||||
if (region_is_empty(dst->pCompositeClip)) {
|
||||
DEBUGF("%s: empty clip, skipping\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
if (RegionNil(dst->pCompositeClip)) {
|
||||
DEBUGF("%s: empty clip, skipping\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((color->red|color->green|color->blue|color->alpha) <= 0x00ff) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
case PictOpOutReverse:
|
||||
case PictOpAdd:
|
||||
return;
|
||||
case PictOpInReverse:
|
||||
case PictOpSrc:
|
||||
op = PictOpClear;
|
||||
break;
|
||||
case PictOpAtopReverse:
|
||||
op = PictOpOut;
|
||||
break;
|
||||
case PictOpXor:
|
||||
op = PictOpOverReverse;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (color->alpha <= 0x00ff) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
case PictOpOutReverse:
|
||||
return;
|
||||
case PictOpInReverse:
|
||||
op = PictOpClear;
|
||||
break;
|
||||
case PictOpAtopReverse:
|
||||
op = PictOpOut;
|
||||
break;
|
||||
case PictOpXor:
|
||||
op = PictOpOverReverse;
|
||||
break;
|
||||
}
|
||||
} else if (color->alpha >= 0xff00) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
op = PictOpSrc;
|
||||
break;
|
||||
case PictOpInReverse:
|
||||
return;
|
||||
case PictOpOutReverse:
|
||||
op = PictOpClear;
|
||||
break;
|
||||
case PictOpAtopReverse:
|
||||
op = PictOpOverReverse;
|
||||
break;
|
||||
case PictOpXor:
|
||||
op = PictOpOut;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEBUGF("%s: converted to op %d\n", __FUNCTION__, op);
|
||||
if ((color->red | color->green | color->blue | color->alpha) <= 0x00ff) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
case PictOpOutReverse:
|
||||
case PictOpAdd:
|
||||
return;
|
||||
case PictOpInReverse:
|
||||
case PictOpSrc:
|
||||
op = PictOpClear;
|
||||
break;
|
||||
case PictOpAtopReverse:
|
||||
op = PictOpOut;
|
||||
break;
|
||||
case PictOpXor:
|
||||
op = PictOpOverReverse;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (color->alpha <= 0x00ff) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
case PictOpOutReverse:
|
||||
return;
|
||||
case PictOpInReverse:
|
||||
op = PictOpClear;
|
||||
break;
|
||||
case PictOpAtopReverse:
|
||||
op = PictOpOut;
|
||||
break;
|
||||
case PictOpXor:
|
||||
op = PictOpOverReverse;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (color->alpha >= 0xff00) {
|
||||
switch (op) {
|
||||
case PictOpOver:
|
||||
op = PictOpSrc;
|
||||
break;
|
||||
case PictOpInReverse:
|
||||
return;
|
||||
case PictOpOutReverse:
|
||||
op = PictOpClear;
|
||||
break;
|
||||
case PictOpAtopReverse:
|
||||
op = PictOpOverReverse;
|
||||
break;
|
||||
case PictOpXor:
|
||||
op = PictOpOut;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DEBUGF("%s: converted to op %d\n", __FUNCTION__, op);
|
||||
|
||||
if (!_pixman_region_init_clipped_rectangles(®ion,
|
||||
num_rects, rects,
|
||||
dst->pDrawable->x,
|
||||
dst->pDrawable->y,
|
||||
&dst->pCompositeClip->extents))
|
||||
{
|
||||
DEBUGF("%s: allocation failed for region\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
if (!_pixman_region_init_clipped_rectangles(®ion,
|
||||
num_rects, rects,
|
||||
dst->pDrawable->x,
|
||||
dst->pDrawable->y,
|
||||
&dst->pCompositeClip->extents))
|
||||
{
|
||||
DEBUGF("%s: allocation failed for region\n", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
|
||||
priv = glamor_get_pixmap_private(pixmap);
|
||||
pixmap = glamor_get_drawable_pixmap(dst->pDrawable);
|
||||
priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
|
||||
goto fallback;
|
||||
if (dst->alphaMap) {
|
||||
DEBUGF("%s: fallback, dst has an alpha-map\n", __FUNCTION__);
|
||||
goto fallback;
|
||||
}
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(priv))
|
||||
goto fallback;
|
||||
if (dst->alphaMap) {
|
||||
DEBUGF("%s: fallback, dst has an alpha-map\n", __FUNCTION__);
|
||||
goto fallback;
|
||||
}
|
||||
|
||||
need_free_region = TRUE;
|
||||
need_free_region = TRUE;
|
||||
|
||||
DEBUGF("%s: drawable extents (%d, %d),(%d, %d) x %d\n",
|
||||
__FUNCTION__,
|
||||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2,
|
||||
RegionNumRects(®ion));
|
||||
DEBUGF("%s: drawable extents (%d, %d),(%d, %d) x %d\n",
|
||||
__FUNCTION__,
|
||||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2,
|
||||
RegionNumRects(®ion));
|
||||
|
||||
if (dst->pCompositeClip->data &&
|
||||
(!pixman_region_intersect(®ion, ®ion, dst->pCompositeClip) ||
|
||||
region_is_empty(®ion))) {
|
||||
DEBUGF("%s: zero-intersection between rectangles and clip\n",
|
||||
__FUNCTION__);
|
||||
pixman_region_fini(®ion);
|
||||
return;
|
||||
}
|
||||
if (dst->pCompositeClip->data &&
|
||||
(!pixman_region_intersect(®ion, ®ion, dst->pCompositeClip) ||
|
||||
RegionNil(®ion))) {
|
||||
DEBUGF("%s: zero-intersection between rectangles and clip\n",
|
||||
__FUNCTION__);
|
||||
pixman_region_fini(®ion);
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUGF("%s: clipped extents (%d, %d),(%d, %d) x %d\n",
|
||||
__FUNCTION__,
|
||||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2,
|
||||
RegionNumRects(®ion));
|
||||
DEBUGF("%s: clipped extents (%d, %d),(%d, %d) x %d\n",
|
||||
__FUNCTION__,
|
||||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2,
|
||||
RegionNumRects(®ion));
|
||||
|
||||
glamor_get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y);
|
||||
pixman_region_translate(®ion, dst_x, dst_y);
|
||||
glamor_get_drawable_deltas(dst->pDrawable, pixmap, &dst_x, &dst_y);
|
||||
pixman_region_translate(®ion, dst_x, dst_y);
|
||||
|
||||
DEBUGF("%s: pixmap +(%d, %d) extents (%d, %d),(%d, %d)\n",
|
||||
__FUNCTION__, dst_x, dst_y,
|
||||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2);
|
||||
DEBUGF("%s: pixmap +(%d, %d) extents (%d, %d),(%d, %d)\n",
|
||||
__FUNCTION__, dst_x, dst_y,
|
||||
RegionExtents(®ion)->x1, RegionExtents(®ion)->y1,
|
||||
RegionExtents(®ion)->x2, RegionExtents(®ion)->y2);
|
||||
|
||||
boxes = pixman_region_rectangles(®ion, &num_boxes);
|
||||
if (op == PictOpSrc || op == PictOpClear) {
|
||||
CARD32 pixel;
|
||||
|
||||
boxes = pixman_region_rectangles(®ion, &num_boxes);
|
||||
if (op == PictOpSrc || op == PictOpClear) {
|
||||
CARD32 pixel;
|
||||
if (op == PictOpClear)
|
||||
pixel = 0;
|
||||
else
|
||||
miRenderColorToPixel(dst->pFormat, color, &pixel);
|
||||
glamor_solid_boxes(pixmap, boxes, num_boxes, pixel);
|
||||
if (op == PictOpClear)
|
||||
pixel = 0;
|
||||
else
|
||||
miRenderColorToPixel(dst->pFormat, color, &pixel);
|
||||
glamor_solid_boxes(pixmap, boxes, num_boxes, pixel);
|
||||
|
||||
goto done;
|
||||
} else {
|
||||
if (likely(priv->type != GLAMOR_TEXTURE_LARGE)) {
|
||||
int error;
|
||||
goto done;
|
||||
}
|
||||
else {
|
||||
if (_X_LIKELY(priv->type != GLAMOR_TEXTURE_LARGE)) {
|
||||
int error;
|
||||
|
||||
source = CreateSolidPicture(0, color, &error);
|
||||
if (!source)
|
||||
goto done;
|
||||
if (glamor_composite_clipped_region(op, source,
|
||||
NULL, dst,
|
||||
NULL, NULL, priv,
|
||||
®ion,
|
||||
0,0,0,0,0,0))
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
fallback:
|
||||
miCompositeRects(op, dst, color, num_rects, rects);
|
||||
done:
|
||||
/* XXX xserver-1.8: CompositeRects is not tracked by Damage, so we must
|
||||
* manually append the damaged regions ourselves.
|
||||
*/
|
||||
DamageRegionAppend(&pixmap->drawable, ®ion);
|
||||
DamageRegionProcessPending(&pixmap->drawable);
|
||||
source = CreateSolidPicture(0, color, &error);
|
||||
if (!source)
|
||||
goto done;
|
||||
if (glamor_composite_clipped_region(op, source,
|
||||
NULL, dst,
|
||||
NULL, NULL, priv,
|
||||
®ion, 0, 0, 0, 0, 0, 0))
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
fallback:
|
||||
miCompositeRects(op, dst, color, num_rects, rects);
|
||||
done:
|
||||
/* XXX xserver-1.8: CompositeRects is not tracked by Damage, so we must
|
||||
* manually append the damaged regions ourselves.
|
||||
*/
|
||||
DamageRegionAppend(&pixmap->drawable, ®ion);
|
||||
DamageRegionProcessPending(&pixmap->drawable);
|
||||
|
||||
if (need_free_region)
|
||||
pixman_region_fini(®ion);
|
||||
if (source)
|
||||
FreePicture(source, 0);
|
||||
return;
|
||||
if (need_free_region)
|
||||
pixman_region_fini(®ion);
|
||||
if (source)
|
||||
FreePicture(source, 0);
|
||||
return;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,43 +30,43 @@
|
|||
|
||||
static Bool
|
||||
_glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane, RegionPtr *pRegion, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pSrc)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDst))
|
||||
goto fail;
|
||||
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pSrc)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDst))
|
||||
goto fail;
|
||||
|
||||
glamor_prepare_access(pDst, GLAMOR_ACCESS_RW);
|
||||
glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO);
|
||||
*pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||
dstx, dsty, bitPlane);
|
||||
glamor_finish_access(pSrc, GLAMOR_ACCESS_RO);
|
||||
glamor_finish_access(pDst, GLAMOR_ACCESS_RW);
|
||||
return TRUE;
|
||||
glamor_prepare_access(pDst, GLAMOR_ACCESS_RW);
|
||||
glamor_prepare_access(pSrc, GLAMOR_ACCESS_RO);
|
||||
*pRegion = fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||
dstx, dsty, bitPlane);
|
||||
glamor_finish_access(pSrc, GLAMOR_ACCESS_RO);
|
||||
glamor_finish_access(pDst, GLAMOR_ACCESS_RW);
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
glamor_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane)
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane)
|
||||
{
|
||||
RegionPtr ret;
|
||||
_glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||
dstx, dsty, bitPlane, &ret, TRUE);
|
||||
return ret;
|
||||
RegionPtr ret;
|
||||
|
||||
_glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||
dstx, dsty, bitPlane, &ret, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_copy_plane_nf(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane, RegionPtr *pRegion)
|
||||
int srcx, int srcy, int w, int h, int dstx, int dsty,
|
||||
unsigned long bitPlane, RegionPtr *pRegion)
|
||||
{
|
||||
return _glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||
dstx, dsty, bitPlane, pRegion, FALSE);
|
||||
return _glamor_copy_plane(pSrc, pDst, pGC, srcx, srcy, w, h,
|
||||
dstx, dsty, bitPlane, pRegion, FALSE);
|
||||
}
|
||||
|
|
|
@ -29,30 +29,28 @@
|
|||
*/
|
||||
|
||||
void
|
||||
glamor_copy_window(WindowPtr win, DDXPointRec old_origin,
|
||||
RegionPtr src_region)
|
||||
glamor_copy_window(WindowPtr win, DDXPointRec old_origin, RegionPtr src_region)
|
||||
{
|
||||
RegionRec dst_region;
|
||||
int dx, dy;
|
||||
PixmapPtr pixmap = win->drawable.pScreen->GetWindowPixmap(win);
|
||||
RegionRec dst_region;
|
||||
int dx, dy;
|
||||
PixmapPtr pixmap = win->drawable.pScreen->GetWindowPixmap(win);
|
||||
|
||||
dx = old_origin.x - win->drawable.x;
|
||||
dy = old_origin.y - win->drawable.y;
|
||||
REGION_TRANSLATE(win->drawable.pScreen, src_region, -dx, -dy);
|
||||
dx = old_origin.x - win->drawable.x;
|
||||
dy = old_origin.y - win->drawable.y;
|
||||
REGION_TRANSLATE(win->drawable.pScreen, src_region, -dx, -dy);
|
||||
|
||||
REGION_INIT(win->drawable.pScreen, &dst_region, NullBox, 0);
|
||||
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,
|
||||
-pixmap->screen_x, -pixmap->screen_y);
|
||||
if (pixmap->screen_x || pixmap->screen_y)
|
||||
REGION_TRANSLATE(win->drawable.pScreen, &dst_region,
|
||||
-pixmap->screen_x, -pixmap->screen_y);
|
||||
#endif
|
||||
|
||||
miCopyRegion(&pixmap->drawable, &pixmap->drawable,
|
||||
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0,
|
||||
NULL);
|
||||
miCopyRegion(&pixmap->drawable, &pixmap->drawable,
|
||||
NULL, &dst_region, dx, dy, glamor_copy_n_to_n, 0, NULL);
|
||||
|
||||
REGION_UNINIT(win->drawable.pScreen, &dst_region);
|
||||
REGION_UNINIT(win->drawable.pScreen, &dst_region);
|
||||
}
|
||||
|
|
|
@ -38,76 +38,76 @@
|
|||
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_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(drawable->pScreen);
|
||||
if (pixmap_priv == NULL || pixmap_priv->base.gl_fbo == 0)
|
||||
return 'm';
|
||||
if (pixmap_priv->base.fbo->fb == glamor_priv->screen_fbo)
|
||||
return 's';
|
||||
else
|
||||
return 'f';
|
||||
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);
|
||||
if (pixmap_priv == NULL || pixmap_priv->base.gl_fbo == 0)
|
||||
return 'm';
|
||||
if (pixmap_priv->base.fbo->fb == glamor_priv->screen_fbo)
|
||||
return 's';
|
||||
else
|
||||
return 'f';
|
||||
}
|
||||
|
||||
GLint
|
||||
glamor_compile_glsl_prog(glamor_gl_dispatch * dispatch, GLenum type,
|
||||
const char *source)
|
||||
const char *source)
|
||||
{
|
||||
GLint ok;
|
||||
GLint prog;
|
||||
GLint ok;
|
||||
GLint prog;
|
||||
|
||||
prog = dispatch->glCreateShader(type);
|
||||
dispatch->glShaderSource(prog, 1, (const GLchar **) &source, NULL);
|
||||
dispatch->glCompileShader(prog);
|
||||
dispatch->glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
|
||||
if (!ok) {
|
||||
GLchar *info;
|
||||
GLint size;
|
||||
prog = dispatch->glCreateShader(type);
|
||||
dispatch->glShaderSource(prog, 1, (const GLchar **) &source, NULL);
|
||||
dispatch->glCompileShader(prog);
|
||||
dispatch->glGetShaderiv(prog, GL_COMPILE_STATUS, &ok);
|
||||
if (!ok) {
|
||||
GLchar *info;
|
||||
GLint size;
|
||||
|
||||
dispatch->glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
|
||||
info = malloc(size);
|
||||
if (info) {
|
||||
dispatch->glGetShaderInfoLog(prog, size, NULL, info);
|
||||
ErrorF("Failed to compile %s: %s\n",
|
||||
type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
|
||||
ErrorF("Program source:\n%s", source);
|
||||
free(info);
|
||||
} else
|
||||
ErrorF("Failed to get shader compilation info.\n");
|
||||
FatalError("GLSL compile failure\n");
|
||||
}
|
||||
dispatch->glGetShaderiv(prog, GL_INFO_LOG_LENGTH, &size);
|
||||
info = malloc(size);
|
||||
if (info) {
|
||||
dispatch->glGetShaderInfoLog(prog, size, NULL, info);
|
||||
ErrorF("Failed to compile %s: %s\n",
|
||||
type == GL_FRAGMENT_SHADER ? "FS" : "VS", info);
|
||||
ErrorF("Program source:\n%s", source);
|
||||
free(info);
|
||||
}
|
||||
else
|
||||
ErrorF("Failed to get shader compilation info.\n");
|
||||
FatalError("GLSL compile failure\n");
|
||||
}
|
||||
|
||||
return prog;
|
||||
return prog;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_link_glsl_prog(glamor_gl_dispatch * dispatch, GLint prog)
|
||||
{
|
||||
GLint ok;
|
||||
GLint ok;
|
||||
|
||||
dispatch->glLinkProgram(prog);
|
||||
dispatch->glGetProgramiv(prog, GL_LINK_STATUS, &ok);
|
||||
if (!ok) {
|
||||
GLchar *info;
|
||||
GLint size;
|
||||
dispatch->glLinkProgram(prog);
|
||||
dispatch->glGetProgramiv(prog, GL_LINK_STATUS, &ok);
|
||||
if (!ok) {
|
||||
GLchar *info;
|
||||
GLint size;
|
||||
|
||||
dispatch->glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
|
||||
info = malloc(size);
|
||||
dispatch->glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &size);
|
||||
info = malloc(size);
|
||||
|
||||
dispatch->glGetProgramInfoLog(prog, size, NULL, info);
|
||||
ErrorF("Failed to link: %s\n", info);
|
||||
FatalError("GLSL link failure\n");
|
||||
}
|
||||
dispatch->glGetProgramInfoLog(prog, size, NULL, info);
|
||||
ErrorF("Failed to link: %s\n", info);
|
||||
FatalError("GLSL link failure\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
return glamor_download_pixmap_to_cpu(pixmap, access);
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
|
||||
return glamor_download_pixmap_to_cpu(pixmap, access);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -142,221 +142,205 @@ glamor_prepare_access(DrawablePtr drawable, glamor_access_t access)
|
|||
void
|
||||
glamor_init_finish_access_shaders(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
const char *vs_source =
|
||||
"attribute vec4 v_position;\n"
|
||||
"attribute vec4 v_texcoord0;\n"
|
||||
"varying vec2 source_texture;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" source_texture = v_texcoord0.xy;\n" "}\n";
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
const char *vs_source =
|
||||
"attribute vec4 v_position;\n"
|
||||
"attribute vec4 v_texcoord0;\n"
|
||||
"varying vec2 source_texture;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" source_texture = v_texcoord0.xy;\n"
|
||||
"}\n";
|
||||
|
||||
const char *common_source =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"varying vec2 source_texture;\n"
|
||||
"uniform sampler2D sampler;\n"
|
||||
"uniform int revert;\n"
|
||||
"uniform int swap_rb;\n"
|
||||
const char *common_source =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"varying vec2 source_texture;\n"
|
||||
"uniform sampler2D sampler;\n"
|
||||
"uniform int revert;\n"
|
||||
"uniform int swap_rb;\n"
|
||||
"#define REVERT_NONE 0\n"
|
||||
"#define REVERT_NORMAL 1\n"
|
||||
"#define SWAP_NONE_DOWNLOADING 0\n"
|
||||
"#define SWAP_DOWNLOADING 1\n"
|
||||
"#define SWAP_UPLOADING 2\n"
|
||||
"#define SWAP_NONE_UPLOADING 3\n";
|
||||
|
||||
"#define REVERT_NONE 0\n"
|
||||
"#define REVERT_NORMAL 1\n"
|
||||
"#define SWAP_NONE_DOWNLOADING 0\n"
|
||||
"#define SWAP_DOWNLOADING 1\n"
|
||||
"#define SWAP_UPLOADING 2\n"
|
||||
"#define SWAP_NONE_UPLOADING 3\n";
|
||||
const char *fs_source =
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" if (revert == REVERT_NONE) \n"
|
||||
" { \n"
|
||||
" if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != SWAP_NONE_UPLOADING)) \n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).bgra;\n"
|
||||
" else \n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).rgba;\n"
|
||||
" } \n"
|
||||
" else \n"
|
||||
" { \n"
|
||||
" if (swap_rb == SWAP_DOWNLOADING) \n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).argb;\n"
|
||||
" else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).abgr;\n"
|
||||
" else if (swap_rb == SWAP_UPLOADING)\n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).gbar;\n"
|
||||
" else if (swap_rb == SWAP_NONE_UPLOADING)\n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).abgr;\n"
|
||||
" } \n"
|
||||
"}\n";
|
||||
|
||||
const char *fs_source =
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" if (revert == REVERT_NONE) \n"
|
||||
" { \n"
|
||||
" if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != SWAP_NONE_UPLOADING)) \n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).bgra;\n"
|
||||
" else \n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).rgba;\n"
|
||||
" } \n"
|
||||
" else \n"
|
||||
" { \n"
|
||||
" if (swap_rb == SWAP_DOWNLOADING) \n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).argb;\n"
|
||||
" else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).abgr;\n"
|
||||
" else if (swap_rb == SWAP_UPLOADING)\n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).gbar;\n"
|
||||
" else if (swap_rb == SWAP_NONE_UPLOADING)\n"
|
||||
" gl_FragColor = texture2D(sampler, source_texture).abgr;\n"
|
||||
" } \n" "}\n";
|
||||
const char *set_alpha_source =
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" if (revert == REVERT_NONE) \n"
|
||||
" { \n"
|
||||
" if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != SWAP_NONE_UPLOADING)) \n"
|
||||
" gl_FragColor = vec4(texture2D(sampler, source_texture).bgr, 1);\n"
|
||||
" else \n"
|
||||
" gl_FragColor = vec4(texture2D(sampler, source_texture).rgb, 1);\n"
|
||||
" } \n"
|
||||
" else \n"
|
||||
" { \n"
|
||||
" if (swap_rb == SWAP_DOWNLOADING) \n"
|
||||
" gl_FragColor = vec4(1, texture2D(sampler, source_texture).rgb);\n"
|
||||
" else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
|
||||
" gl_FragColor = vec4(1, texture2D(sampler, source_texture).bgr);\n"
|
||||
" else if (swap_rb == SWAP_UPLOADING)\n"
|
||||
" gl_FragColor = vec4(texture2D(sampler, source_texture).gba, 1);\n"
|
||||
" else if (swap_rb == SWAP_NONE_UPLOADING)\n"
|
||||
" gl_FragColor = vec4(texture2D(sampler, source_texture).abg, 1);\n"
|
||||
" } \n"
|
||||
"}\n";
|
||||
GLint fs_prog, vs_prog, avs_prog, set_alpha_prog;
|
||||
GLint sampler_uniform_location;
|
||||
char *source;
|
||||
|
||||
const char *set_alpha_source =
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" if (revert == REVERT_NONE) \n"
|
||||
" { \n"
|
||||
" if ((swap_rb != SWAP_NONE_DOWNLOADING) && (swap_rb != SWAP_NONE_UPLOADING)) \n"
|
||||
" gl_FragColor = vec4(texture2D(sampler, source_texture).bgr, 1);\n"
|
||||
" else \n"
|
||||
" gl_FragColor = vec4(texture2D(sampler, source_texture).rgb, 1);\n"
|
||||
" } \n"
|
||||
" else \n"
|
||||
" { \n"
|
||||
" if (swap_rb == SWAP_DOWNLOADING) \n"
|
||||
" gl_FragColor = vec4(1, texture2D(sampler, source_texture).rgb);\n"
|
||||
" else if (swap_rb == SWAP_NONE_DOWNLOADING)\n"
|
||||
" gl_FragColor = vec4(1, texture2D(sampler, source_texture).bgr);\n"
|
||||
" else if (swap_rb == SWAP_UPLOADING)\n"
|
||||
" gl_FragColor = vec4(texture2D(sampler, source_texture).gba, 1);\n"
|
||||
" else if (swap_rb == SWAP_NONE_UPLOADING)\n"
|
||||
" gl_FragColor = vec4(texture2D(sampler, source_texture).abg, 1);\n"
|
||||
" } \n"
|
||||
"}\n";
|
||||
GLint fs_prog, vs_prog, avs_prog, set_alpha_prog;
|
||||
GLint sampler_uniform_location;
|
||||
char *source;
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
glamor_priv->finish_access_prog[0] = dispatch->glCreateProgram();
|
||||
glamor_priv->finish_access_prog[1] = dispatch->glCreateProgram();
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
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);
|
||||
|
||||
vs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
|
||||
vs_source);
|
||||
XNFasprintf(&source, "%s%s", common_source, fs_source);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER, source);
|
||||
free(source);
|
||||
|
||||
XNFasprintf(&source, "%s%s", common_source, fs_source);
|
||||
fs_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
source);
|
||||
free(source);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[0], fs_prog);
|
||||
|
||||
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);
|
||||
|
||||
avs_prog = glamor_compile_glsl_prog(dispatch, GL_VERTEX_SHADER,
|
||||
vs_source);
|
||||
XNFasprintf(&source, "%s%s", common_source, set_alpha_source);
|
||||
set_alpha_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
source);
|
||||
free(source);
|
||||
|
||||
XNFasprintf(&source, "%s%s", common_source, set_alpha_source);
|
||||
set_alpha_prog = glamor_compile_glsl_prog(dispatch, GL_FRAGMENT_SHADER,
|
||||
source);
|
||||
free(source);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1], avs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->finish_access_prog[1],
|
||||
set_alpha_prog);
|
||||
|
||||
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_revert[0] =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"revert");
|
||||
|
||||
glamor_priv->finish_access_revert[0] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"revert");
|
||||
glamor_priv->finish_access_swap_rb[0] =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
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_revert[0], 0);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0], 0);
|
||||
dispatch->glUseProgram(0);
|
||||
|
||||
glamor_priv->finish_access_swap_rb[0] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[0],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
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_revert[0], 0);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[0], 0);
|
||||
dispatch->glUseProgram(0);
|
||||
|
||||
glamor_priv->finish_access_revert[1] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"revert");
|
||||
glamor_priv->finish_access_swap_rb[1] =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
dispatch->
|
||||
glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"sampler");
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[1]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[1], 0);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[1], 0);
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_priv->finish_access_revert[1] =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"revert");
|
||||
glamor_priv->finish_access_swap_rb[1] =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"swap_rb");
|
||||
sampler_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->finish_access_prog[1],
|
||||
"sampler");
|
||||
dispatch->glUseProgram(glamor_priv->finish_access_prog[1]);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_revert[1], 0);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
dispatch->glUniform1i(glamor_priv->finish_access_swap_rb[1], 0);
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_fini_finish_access_shaders(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[0]);
|
||||
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[1]);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[0]);
|
||||
dispatch->glDeleteProgram(glamor_priv->finish_access_prog[1]);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv))
|
||||
return;
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO_DOWNLOADED(pixmap_priv))
|
||||
return;
|
||||
|
||||
if (access_mode != GLAMOR_ACCESS_RO) {
|
||||
glamor_restore_pixmap_to_texture(pixmap);
|
||||
}
|
||||
if (access_mode != GLAMOR_ACCESS_RO) {
|
||||
glamor_restore_pixmap_to_texture(pixmap);
|
||||
}
|
||||
|
||||
if (pixmap_priv->base.fbo->pbo != 0 && pixmap_priv->base.fbo->pbo_valid) {
|
||||
glamor_gl_dispatch *dispatch;
|
||||
if (pixmap_priv->base.fbo->pbo != 0 && pixmap_priv->base.fbo->pbo_valid) {
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
|
||||
assert(glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP);
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
dispatch->glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
|
||||
dispatch->glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
dispatch->glDeleteBuffers(1, &pixmap_priv->base.fbo->pbo);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
||||
pixmap_priv->base.fbo->pbo_valid = FALSE;
|
||||
pixmap_priv->base.fbo->pbo = 0;
|
||||
} else {
|
||||
free(pixmap->devPrivate.ptr);
|
||||
}
|
||||
pixmap_priv->base.fbo->pbo_valid = FALSE;
|
||||
pixmap_priv->base.fbo->pbo = 0;
|
||||
}
|
||||
else {
|
||||
free(pixmap->devPrivate.ptr);
|
||||
}
|
||||
|
||||
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM)
|
||||
pixmap->devKind = pixmap_priv->base.drm_stride;
|
||||
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM)
|
||||
pixmap->devKind = pixmap_priv->base.drm_stride;
|
||||
|
||||
if (pixmap_priv->base.gl_fbo == GLAMOR_FBO_DOWNLOADED)
|
||||
pixmap_priv->base.gl_fbo = GLAMOR_FBO_NORMAL;
|
||||
if (pixmap_priv->base.gl_fbo == GLAMOR_FBO_DOWNLOADED)
|
||||
pixmap_priv->base.gl_fbo = GLAMOR_FBO_NORMAL;
|
||||
|
||||
pixmap->devPrivate.ptr = NULL;
|
||||
pixmap->devPrivate.ptr = NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Calls uxa_prepare_access with UXA_PREPARE_SRC for the tile, if that is the
|
||||
* current fill style.
|
||||
|
@ -368,22 +352,19 @@ glamor_finish_access(DrawablePtr drawable, glamor_access_t access_mode)
|
|||
Bool
|
||||
glamor_prepare_access_gc(GCPtr gc)
|
||||
{
|
||||
if (gc->stipple) {
|
||||
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_ACCESS_RO);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
if (gc->stipple) {
|
||||
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_ACCESS_RO);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -392,45 +373,44 @@ glamor_prepare_access_gc(GCPtr gc)
|
|||
void
|
||||
glamor_finish_access_gc(GCPtr gc)
|
||||
{
|
||||
if (gc->fillStyle == FillTiled)
|
||||
glamor_finish_access(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
if (gc->stipple)
|
||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
|
||||
if (gc->fillStyle == FillTiled)
|
||||
glamor_finish_access(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
if (gc->stipple)
|
||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_stipple(PixmapPtr pixmap, PixmapPtr stipple,
|
||||
int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask,
|
||||
unsigned long fg_pixel, unsigned long bg_pixel,
|
||||
int stipple_x, int stipple_y)
|
||||
int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask,
|
||||
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);
|
||||
return FALSE;
|
||||
glamor_fallback("stubbed out stipple depth %d\n", pixmap->drawable.depth);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GCOps glamor_gc_ops = {
|
||||
.FillSpans = glamor_fill_spans,
|
||||
.SetSpans = glamor_set_spans,
|
||||
.PutImage = glamor_put_image,
|
||||
.CopyArea = glamor_copy_area,
|
||||
.CopyPlane = glamor_copy_plane,
|
||||
.PolyPoint = glamor_poly_point,
|
||||
.Polylines = glamor_poly_lines,
|
||||
.PolySegment = glamor_poly_segment,
|
||||
.PolyRectangle = miPolyRectangle,
|
||||
.PolyArc = miPolyArc,
|
||||
.FillPolygon = miFillPolygon,
|
||||
.PolyFillRect = glamor_poly_fill_rect,
|
||||
.PolyFillArc = miPolyFillArc,
|
||||
.PolyText8 = miPolyText8,
|
||||
.PolyText16 = miPolyText16,
|
||||
.ImageText8 = miImageText8,
|
||||
.ImageText16 = miImageText16,
|
||||
.ImageGlyphBlt = glamor_image_glyph_blt, //miImageGlyphBlt,
|
||||
.PolyGlyphBlt = glamor_poly_glyph_blt, //miPolyGlyphBlt,
|
||||
.PushPixels = glamor_push_pixels, //miPushPixels,
|
||||
.FillSpans = glamor_fill_spans,
|
||||
.SetSpans = glamor_set_spans,
|
||||
.PutImage = glamor_put_image,
|
||||
.CopyArea = glamor_copy_area,
|
||||
.CopyPlane = glamor_copy_plane,
|
||||
.PolyPoint = glamor_poly_point,
|
||||
.Polylines = glamor_poly_lines,
|
||||
.PolySegment = glamor_poly_segment,
|
||||
.PolyRectangle = miPolyRectangle,
|
||||
.PolyArc = miPolyArc,
|
||||
.FillPolygon = miFillPolygon,
|
||||
.PolyFillRect = glamor_poly_fill_rect,
|
||||
.PolyFillArc = miPolyFillArc,
|
||||
.PolyText8 = miPolyText8,
|
||||
.PolyText16 = miPolyText16,
|
||||
.ImageText8 = miImageText8,
|
||||
.ImageText16 = miImageText16,
|
||||
.ImageGlyphBlt = glamor_image_glyph_blt, //miImageGlyphBlt,
|
||||
.PolyGlyphBlt = glamor_poly_glyph_blt, //miPolyGlyphBlt,
|
||||
.PushPixels = glamor_push_pixels, //miPushPixels,
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -440,104 +420,94 @@ GCOps glamor_gc_ops = {
|
|||
void
|
||||
glamor_validate_gc(GCPtr gc, unsigned long changes, DrawablePtr drawable)
|
||||
{
|
||||
/* fbValidateGC will do direct access to pixmaps if the tiling has changed.
|
||||
* Preempt fbValidateGC by doing its work and masking the change out, so
|
||||
* that we can do the Prepare/finish_access.
|
||||
*/
|
||||
/* fbValidateGC will do direct access to pixmaps if the tiling has changed.
|
||||
* Preempt fbValidateGC by doing its work and masking the change out, so
|
||||
* that we can do the Prepare/finish_access.
|
||||
*/
|
||||
#ifdef FB_24_32BIT
|
||||
if ((changes & GCTile) && fbGetRotatedPixmap(gc)) {
|
||||
gc->pScreen->DestroyPixmap(fbGetRotatedPixmap(gc));
|
||||
fbGetRotatedPixmap(gc) = 0;
|
||||
}
|
||||
if ((changes & GCTile) && fbGetRotatedPixmap(gc)) {
|
||||
gc->pScreen->DestroyPixmap(fbGetRotatedPixmap(gc));
|
||||
fbGetRotatedPixmap(gc) = 0;
|
||||
}
|
||||
|
||||
if (gc->fillStyle == FillTiled) {
|
||||
PixmapPtr old_tile, new_tile;
|
||||
if (gc->fillStyle == FillTiled) {
|
||||
PixmapPtr old_tile, new_tile;
|
||||
|
||||
old_tile = gc->tile.pixmap;
|
||||
if (old_tile->drawable.bitsPerPixel !=
|
||||
drawable->bitsPerPixel) {
|
||||
new_tile = fbGetRotatedPixmap(gc);
|
||||
if (!new_tile ||
|
||||
new_tile->drawable.bitsPerPixel !=
|
||||
drawable->bitsPerPixel) {
|
||||
if (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);
|
||||
old_tile = gc->tile.pixmap;
|
||||
if (old_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
|
||||
new_tile = fbGetRotatedPixmap(gc);
|
||||
if (!new_tile ||
|
||||
new_tile->drawable.bitsPerPixel != drawable->bitsPerPixel) {
|
||||
if (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);
|
||||
|
||||
if (glamor_prepare_access
|
||||
(&old_tile->drawable,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
new_tile =
|
||||
fb24_32ReformatTile
|
||||
(old_tile,
|
||||
drawable->bitsPerPixel);
|
||||
glamor_finish_access
|
||||
(&old_tile->drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
}
|
||||
if (new_tile) {
|
||||
fbGetRotatedPixmap(gc) = old_tile;
|
||||
gc->tile.pixmap = new_tile;
|
||||
changes |= GCTile;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (glamor_prepare_access
|
||||
(&old_tile->drawable, GLAMOR_ACCESS_RO)) {
|
||||
new_tile =
|
||||
fb24_32ReformatTile(old_tile, drawable->bitsPerPixel);
|
||||
glamor_finish_access(&old_tile->drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
}
|
||||
if (new_tile) {
|
||||
fbGetRotatedPixmap(gc) = old_tile;
|
||||
gc->tile.pixmap = new_tile;
|
||||
changes |= GCTile;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (changes & GCTile) {
|
||||
if (!gc->tileIsPixel) {
|
||||
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,
|
||||
GLAMOR_ACCESS_RW)) {
|
||||
fbPadPixmap(gc->tile.pixmap);
|
||||
glamor_finish_access
|
||||
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mask out the GCTile change notification, now that we've done FB's
|
||||
* job for it.
|
||||
*/
|
||||
changes &= ~GCTile;
|
||||
}
|
||||
if (changes & GCTile) {
|
||||
if (!gc->tileIsPixel) {
|
||||
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, GLAMOR_ACCESS_RW)) {
|
||||
fbPadPixmap(gc->tile.pixmap);
|
||||
glamor_finish_access
|
||||
(&gc->tile.pixmap->drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Mask out the GCTile change notification, now that we've done FB's
|
||||
* job for it.
|
||||
*/
|
||||
changes &= ~GCTile;
|
||||
}
|
||||
|
||||
if (changes & GCStipple && gc->stipple) {
|
||||
/* 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)) {
|
||||
fbValidateGC(gc, changes, drawable);
|
||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
} else {
|
||||
fbValidateGC(gc, changes, drawable);
|
||||
}
|
||||
if (changes & GCStipple && gc->stipple) {
|
||||
/* 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)) {
|
||||
fbValidateGC(gc, changes, drawable);
|
||||
glamor_finish_access(&gc->stipple->drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fbValidateGC(gc, changes, drawable);
|
||||
}
|
||||
|
||||
gc->ops = &glamor_gc_ops;
|
||||
gc->ops = &glamor_gc_ops;
|
||||
}
|
||||
|
||||
static GCFuncs glamor_gc_funcs = {
|
||||
glamor_validate_gc,
|
||||
miChangeGC,
|
||||
miCopyGC,
|
||||
miDestroyGC,
|
||||
miChangeClip,
|
||||
miDestroyClip,
|
||||
miCopyClip
|
||||
glamor_validate_gc,
|
||||
miChangeGC,
|
||||
miCopyGC,
|
||||
miDestroyGC,
|
||||
miChangeClip,
|
||||
miDestroyClip,
|
||||
miCopyClip
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -547,66 +517,69 @@ static GCFuncs glamor_gc_funcs = {
|
|||
int
|
||||
glamor_create_gc(GCPtr gc)
|
||||
{
|
||||
if (!fbCreateGC(gc))
|
||||
return FALSE;
|
||||
if (!fbCreateGC(gc))
|
||||
return FALSE;
|
||||
|
||||
gc->funcs = &glamor_gc_funcs;
|
||||
gc->funcs = &glamor_gc_funcs;
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
RegionPtr
|
||||
glamor_bitmap_to_region(PixmapPtr pixmap)
|
||||
{
|
||||
RegionPtr ret;
|
||||
glamor_fallback("pixmap %p \n", pixmap);
|
||||
if (!glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO))
|
||||
return NULL;
|
||||
ret = fbPixmapToRegion(pixmap);
|
||||
glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
return ret;
|
||||
RegionPtr ret;
|
||||
|
||||
glamor_fallback("pixmap %p \n", pixmap);
|
||||
if (!glamor_prepare_access(&pixmap->drawable, GLAMOR_ACCESS_RO))
|
||||
return NULL;
|
||||
ret = fbPixmapToRegion(pixmap);
|
||||
glamor_finish_access(&pixmap->drawable, GLAMOR_ACCESS_RO);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Borrow from cairo. */
|
||||
Bool
|
||||
glamor_gl_has_extension(const char *extension)
|
||||
{
|
||||
const char *pext;
|
||||
int ext_len;
|
||||
ext_len = strlen(extension);
|
||||
const char *pext;
|
||||
int ext_len;
|
||||
|
||||
pext = (const char*)glGetString(GL_EXTENSIONS);
|
||||
ext_len = strlen(extension);
|
||||
|
||||
if (pext == NULL || extension == NULL)
|
||||
return FALSE;
|
||||
pext = (const char *) glGetString(GL_EXTENSIONS);
|
||||
|
||||
while ((pext = strstr(pext, extension)) != NULL) {
|
||||
if (pext[ext_len] == ' ' || pext[ext_len] == '\0')
|
||||
return TRUE;
|
||||
pext += ext_len;
|
||||
}
|
||||
return FALSE;
|
||||
if (pext == NULL || extension == NULL)
|
||||
return FALSE;
|
||||
|
||||
while ((pext = strstr(pext, extension)) != NULL) {
|
||||
if (pext[ext_len] == ' ' || pext[ext_len] == '\0')
|
||||
return TRUE;
|
||||
pext += ext_len;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int
|
||||
glamor_gl_get_version(void)
|
||||
{
|
||||
int major, minor;
|
||||
const char *version = (const char *) glGetString(GL_VERSION);
|
||||
const char *dot = version == NULL ? NULL : strchr(version, '.');
|
||||
const char *major_start = dot;
|
||||
int major, minor;
|
||||
const char *version = (const char *) glGetString(GL_VERSION);
|
||||
const char *dot = version == NULL ? NULL : strchr(version, '.');
|
||||
const char *major_start = dot;
|
||||
|
||||
/* Sanity check */
|
||||
if (dot == NULL || dot == version || *(dot + 1) == '\0') {
|
||||
major = 0;
|
||||
minor = 0;
|
||||
} else {
|
||||
/* Find the start of the major version in the string */
|
||||
while (major_start > version && *major_start != ' ')
|
||||
--major_start;
|
||||
major = strtol(major_start, NULL, 10);
|
||||
minor = strtol(dot + 1, NULL, 10);
|
||||
}
|
||||
/* Sanity check */
|
||||
if (dot == NULL || dot == version || *(dot + 1) == '\0') {
|
||||
major = 0;
|
||||
minor = 0;
|
||||
}
|
||||
else {
|
||||
/* Find the start of the major version in the string */
|
||||
while (major_start > version && *major_start != ' ')
|
||||
--major_start;
|
||||
major = strtol(major_start, NULL, 10);
|
||||
minor = strtol(dot + 1, NULL, 10);
|
||||
}
|
||||
|
||||
return GLAMOR_GL_VERSION_ENCODE(major, minor);
|
||||
return GLAMOR_GL_VERSION_ENCODE(major, minor);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#ifndef __GLAMOR_DEBUG_H__
|
||||
#define __GLAMOR_DEBUG_H__
|
||||
|
||||
|
||||
#define GLAMOR_DELAYED_STRING_MAX 64
|
||||
|
||||
#define GLAMOR_DEBUG_NONE 0
|
||||
|
@ -51,9 +50,6 @@ AbortServer(void)
|
|||
exit(1); \
|
||||
} while(0)
|
||||
|
||||
|
||||
|
||||
|
||||
#define __debug_output_message(_format_, _prefix_, ...) \
|
||||
LogMessageVerb(X_NONE, 0, \
|
||||
"%32s:\t" _format_ , \
|
||||
|
@ -69,7 +65,6 @@ AbortServer(void)
|
|||
##__VA_ARGS__); \
|
||||
} while(0)
|
||||
|
||||
|
||||
#define glamor_fallback(_format_,...) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) \
|
||||
|
@ -77,8 +72,6 @@ AbortServer(void)
|
|||
"Glamor fallback", \
|
||||
##__VA_ARGS__);} while(0)
|
||||
|
||||
|
||||
|
||||
#define glamor_delayed_fallback(_screen_, _format_,...) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||
|
@ -90,7 +83,6 @@ AbortServer(void)
|
|||
"glamor delayed fallback: \t%s " _format_ , \
|
||||
__FUNCTION__, ##__VA_ARGS__); } } while(0)
|
||||
|
||||
|
||||
#define glamor_clear_delayed_fallbacks(_screen_) \
|
||||
do { \
|
||||
if (glamor_debug_level >= GLAMOR_DEBUG_FALLBACK) { \
|
||||
|
@ -112,5 +104,4 @@ AbortServer(void)
|
|||
#define DEBUGRegionPrint(x) do {} while (0)
|
||||
//#define DEBUGRegionPrint RegionPrint
|
||||
|
||||
|
||||
#endif
|
||||
|
|
1067
glamor/glamor_egl.c
1067
glamor/glamor_egl.c
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2011 Intel Corporation
|
||||
* Copyright © 2013 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
|
@ -16,44 +16,49 @@
|
|||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS 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.
|
||||
*
|
||||
* Authors:
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*
|
||||
* Copied from sna
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef _GLAMOR_COMPILER_H_
|
||||
#define _GLAMOR_COMPILER_H_
|
||||
/** @file glamor_egl_stubs.c
|
||||
*
|
||||
* Stubbed out glamor_egl.c functions for servers other than Xorg.
|
||||
*/
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
|
||||
#define likely(expr) (__builtin_expect (!!(expr), 1))
|
||||
#define unlikely(expr) (__builtin_expect (!!(expr), 0))
|
||||
#define noinline __attribute__((noinline))
|
||||
#define fastcall __attribute__((regparm(3)))
|
||||
#define must_check __attribute__((warn_unused_result))
|
||||
#define constant __attribute__((const))
|
||||
#else
|
||||
#define likely(expr) (expr)
|
||||
#define unlikely(expr) (expr)
|
||||
#define noinline
|
||||
#define fastcall
|
||||
#define must_check
|
||||
#define constant
|
||||
#endif
|
||||
#include "glamor_priv.h"
|
||||
|
||||
#ifdef HAVE_VALGRIND
|
||||
#define VG(x) x
|
||||
#else
|
||||
#define VG(x)
|
||||
#endif
|
||||
void
|
||||
glamor_egl_screen_init(ScreenPtr screen)
|
||||
{
|
||||
}
|
||||
|
||||
#define VG_CLEAR(s) VG(memset(&s, 0, sizeof(s)))
|
||||
void
|
||||
glamor_egl_destroy_textured_pixmap(PixmapPtr pixmap)
|
||||
{
|
||||
}
|
||||
|
||||
#define COMPILE_TIME_ASSERT(E) ((void)sizeof(char[1 - 2*!(E)]))
|
||||
void
|
||||
glamor_egl_make_current(ScreenPtr screen)
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* _SNA_COMPILER_H_ */
|
||||
void
|
||||
glamor_egl_restore_context(ScreenPtr screen)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
glamor_egl_dri3_fd_name_from_tex(ScreenPtr screen,
|
||||
PixmapPtr pixmap,
|
||||
unsigned int tex,
|
||||
Bool want_name, CARD16 *stride, CARD32 *size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
glamor_egl_create_argb8888_based_texture(ScreenPtr screen, int w, int h)
|
||||
{
|
||||
return 0;
|
||||
}
|
|
@ -27,9 +27,7 @@
|
|||
* Zhigang Gong <zhigang.gong@gmail.com>
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
#include "dix-config.h"
|
||||
|
||||
#include <xorg-server.h>
|
||||
#define GLAMOR_FOR_XORG
|
||||
|
@ -37,16 +35,16 @@
|
|||
#include "glamor.h"
|
||||
|
||||
static XF86ModuleVersionInfo VersRec = {
|
||||
GLAMOR_EGL_MODULE_NAME,
|
||||
MODULEVENDORSTRING,
|
||||
MODINFOSTRING1,
|
||||
MODINFOSTRING2,
|
||||
XORG_VERSION_CURRENT,
|
||||
PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,
|
||||
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 */
|
||||
GLAMOR_EGL_MODULE_NAME,
|
||||
MODULEVENDORSTRING,
|
||||
MODINFOSTRING1,
|
||||
MODINFOSTRING2,
|
||||
XORG_VERSION_CURRENT,
|
||||
PACKAGE_VERSION_MAJOR, PACKAGE_VERSION_MINOR, PACKAGE_VERSION_PATCHLEVEL,
|
||||
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 glamoreglModuleData = { &VersRec, NULL, NULL };
|
||||
|
|
|
@ -44,547 +44,552 @@
|
|||
&pos->member != (head); \
|
||||
pos = __container_of(pos->member.prev, pos, member))
|
||||
|
||||
|
||||
#define xorg_list_for_each_entry_safe_reverse(pos, tmp, head, member) \
|
||||
for (pos = __container_of((head)->prev, pos, member), \
|
||||
tmp = __container_of(pos->member.prev, pos, member); \
|
||||
&pos->member != (head); \
|
||||
pos = tmp, tmp = __container_of(pos->member.prev, tmp, member))
|
||||
|
||||
inline static int cache_wbucket(int size)
|
||||
inline static int
|
||||
cache_wbucket(int size)
|
||||
{
|
||||
int order = __fls(size / 32);
|
||||
if (order >= CACHE_BUCKET_WCOUNT)
|
||||
order = CACHE_BUCKET_WCOUNT - 1;
|
||||
return order;
|
||||
int order = __fls(size / 32);
|
||||
|
||||
if (order >= CACHE_BUCKET_WCOUNT)
|
||||
order = CACHE_BUCKET_WCOUNT - 1;
|
||||
return order;
|
||||
}
|
||||
|
||||
inline static int cache_hbucket(int size)
|
||||
inline static int
|
||||
cache_hbucket(int size)
|
||||
{
|
||||
int order = __fls(size / 32);
|
||||
if (order >= CACHE_BUCKET_HCOUNT)
|
||||
order = CACHE_BUCKET_HCOUNT - 1;
|
||||
return order;
|
||||
int order = __fls(size / 32);
|
||||
|
||||
if (order >= CACHE_BUCKET_HCOUNT)
|
||||
order = CACHE_BUCKET_HCOUNT - 1;
|
||||
return order;
|
||||
}
|
||||
|
||||
static glamor_pixmap_fbo *
|
||||
glamor_pixmap_fbo_cache_get(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, int flag)
|
||||
int w, int h, GLenum format, int flag)
|
||||
{
|
||||
struct xorg_list *cache;
|
||||
glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
|
||||
int n_format;
|
||||
struct xorg_list *cache;
|
||||
glamor_pixmap_fbo *fbo_entry, *ret_fbo = NULL;
|
||||
int n_format;
|
||||
|
||||
#ifdef NO_FBO_CACHE
|
||||
return NULL;
|
||||
return NULL;
|
||||
#else
|
||||
n_format = cache_format(format);
|
||||
if (n_format == -1)
|
||||
return NULL;
|
||||
cache = &glamor_priv->fbo_cache[n_format]
|
||||
[cache_wbucket(w)]
|
||||
[cache_hbucket(h)];
|
||||
if (!(flag & GLAMOR_CACHE_EXACT_SIZE)) {
|
||||
xorg_list_for_each_entry(fbo_entry, cache, list) {
|
||||
if (fbo_entry->width >= w && fbo_entry->height >= h) {
|
||||
n_format = cache_format(format);
|
||||
if (n_format == -1)
|
||||
return NULL;
|
||||
cache = &glamor_priv->fbo_cache[n_format]
|
||||
[cache_wbucket(w)]
|
||||
[cache_hbucket(h)];
|
||||
if (!(flag & GLAMOR_CACHE_EXACT_SIZE)) {
|
||||
xorg_list_for_each_entry(fbo_entry, cache, list) {
|
||||
if (fbo_entry->width >= w && fbo_entry->height >= h) {
|
||||
|
||||
DEBUGF("Request w %d h %d format %x \n", w, h, format);
|
||||
DEBUGF("got cache entry %p w %d h %d fbo %d tex %d format %x\n",
|
||||
fbo_entry, fbo_entry->width, fbo_entry->height,
|
||||
fbo_entry->fb, fbo_entry->tex);
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
ret_fbo = fbo_entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
xorg_list_for_each_entry(fbo_entry, cache, list) {
|
||||
if (fbo_entry->width == w && fbo_entry->height == h) {
|
||||
DEBUGF("Request w %d h %d format %x \n", w, h, format);
|
||||
DEBUGF("got cache entry %p w %d h %d fbo %d tex %d format %x\n",
|
||||
fbo_entry, fbo_entry->width, fbo_entry->height,
|
||||
fbo_entry->fb, fbo_entry->tex);
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
ret_fbo = fbo_entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
xorg_list_for_each_entry(fbo_entry, cache, list) {
|
||||
if (fbo_entry->width == w && fbo_entry->height == h) {
|
||||
|
||||
DEBUGF("Request w %d h %d format %x \n", w, h, format);
|
||||
DEBUGF("got cache entry %p w %d h %d fbo %d tex %d format %x\n",
|
||||
fbo_entry, fbo_entry->width, fbo_entry->height,
|
||||
fbo_entry->fb, fbo_entry->tex, fbo_entry->format);
|
||||
assert(format == fbo_entry->format);
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
ret_fbo = fbo_entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DEBUGF("Request w %d h %d format %x \n", w, h, format);
|
||||
DEBUGF("got cache entry %p w %d h %d fbo %d tex %d format %x\n",
|
||||
fbo_entry, fbo_entry->width, fbo_entry->height,
|
||||
fbo_entry->fb, fbo_entry->tex, fbo_entry->format);
|
||||
assert(format == fbo_entry->format);
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
ret_fbo = fbo_entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ret_fbo)
|
||||
glamor_priv->fbo_cache_watermark -= ret_fbo->width * ret_fbo->height;
|
||||
if (ret_fbo)
|
||||
glamor_priv->fbo_cache_watermark -= ret_fbo->width * ret_fbo->height;
|
||||
|
||||
assert(glamor_priv->fbo_cache_watermark >= 0);
|
||||
assert(glamor_priv->fbo_cache_watermark >= 0);
|
||||
|
||||
return ret_fbo;
|
||||
return ret_fbo;
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
glamor_purge_fbo(glamor_pixmap_fbo *fbo)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
||||
if (fbo->fb)
|
||||
dispatch->glDeleteFramebuffers(1, &fbo->fb);
|
||||
if (fbo->tex)
|
||||
dispatch->glDeleteTextures(1, &fbo->tex);
|
||||
if (fbo->pbo)
|
||||
dispatch->glDeleteBuffers(1, &fbo->pbo);
|
||||
glamor_put_dispatch(fbo->glamor_priv);
|
||||
glamor_gl_dispatch *dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
||||
|
||||
free(fbo);
|
||||
if (fbo->fb)
|
||||
dispatch->glDeleteFramebuffers(1, &fbo->fb);
|
||||
if (fbo->tex)
|
||||
dispatch->glDeleteTextures(1, &fbo->tex);
|
||||
if (fbo->pbo)
|
||||
dispatch->glDeleteBuffers(1, &fbo->pbo);
|
||||
glamor_put_dispatch(fbo->glamor_priv);
|
||||
|
||||
free(fbo);
|
||||
}
|
||||
|
||||
static void
|
||||
glamor_pixmap_fbo_cache_put(glamor_pixmap_fbo *fbo)
|
||||
{
|
||||
struct xorg_list *cache;
|
||||
int n_format;
|
||||
struct xorg_list *cache;
|
||||
int n_format;
|
||||
|
||||
#ifdef NO_FBO_CACHE
|
||||
glamor_purge_fbo(fbo);
|
||||
return;
|
||||
glamor_purge_fbo(fbo);
|
||||
return;
|
||||
#else
|
||||
n_format = cache_format(fbo->format);
|
||||
n_format = cache_format(fbo->format);
|
||||
|
||||
if (fbo->fb == 0 || n_format == -1
|
||||
|| fbo->glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) {
|
||||
fbo->glamor_priv->tick += GLAMOR_CACHE_EXPIRE_MAX;
|
||||
glamor_fbo_expire(fbo->glamor_priv);
|
||||
glamor_purge_fbo(fbo);
|
||||
return;
|
||||
}
|
||||
if (fbo->fb == 0 || n_format == -1
|
||||
|| fbo->glamor_priv->fbo_cache_watermark >= FBO_CACHE_THRESHOLD) {
|
||||
fbo->glamor_priv->tick += GLAMOR_CACHE_EXPIRE_MAX;
|
||||
glamor_fbo_expire(fbo->glamor_priv);
|
||||
glamor_purge_fbo(fbo);
|
||||
return;
|
||||
}
|
||||
|
||||
cache = &fbo->glamor_priv->fbo_cache[n_format]
|
||||
[cache_wbucket(fbo->width)]
|
||||
[cache_hbucket(fbo->height)];
|
||||
DEBUGF("Put cache entry %p to cache %p w %d h %d format %x fbo %d tex %d \n", fbo, cache,
|
||||
fbo->width, fbo->height, fbo->format, fbo->fb, fbo->tex);
|
||||
cache = &fbo->glamor_priv->fbo_cache[n_format]
|
||||
[cache_wbucket(fbo->width)]
|
||||
[cache_hbucket(fbo->height)];
|
||||
DEBUGF
|
||||
("Put cache entry %p to cache %p w %d h %d format %x fbo %d tex %d \n",
|
||||
fbo, cache, fbo->width, fbo->height, fbo->format, fbo->fb, fbo->tex);
|
||||
|
||||
fbo->glamor_priv->fbo_cache_watermark += fbo->width * fbo->height;
|
||||
xorg_list_add(&fbo->list, cache);
|
||||
fbo->expire = fbo->glamor_priv->tick + GLAMOR_CACHE_EXPIRE_MAX;
|
||||
fbo->glamor_priv->fbo_cache_watermark += fbo->width * fbo->height;
|
||||
xorg_list_add(&fbo->list, cache);
|
||||
fbo->expire = fbo->glamor_priv->tick + GLAMOR_CACHE_EXPIRE_MAX;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
glamor_pixmap_ensure_fb(glamor_pixmap_fbo *fbo)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int status;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int status;
|
||||
|
||||
dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
||||
dispatch = glamor_get_dispatch(fbo->glamor_priv);
|
||||
|
||||
if (fbo->fb == 0)
|
||||
dispatch->glGenFramebuffers(1, &fbo->fb);
|
||||
assert(fbo->tex != 0);
|
||||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
|
||||
dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D, fbo->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;
|
||||
}
|
||||
if (fbo->fb == 0)
|
||||
dispatch->glGenFramebuffers(1, &fbo->fb);
|
||||
assert(fbo->tex != 0);
|
||||
dispatch->glBindFramebuffer(GL_FRAMEBUFFER, fbo->fb);
|
||||
dispatch->glFramebufferTexture2D(GL_FRAMEBUFFER,
|
||||
GL_COLOR_ATTACHMENT0,
|
||||
GL_TEXTURE_2D, fbo->tex, 0);
|
||||
status = dispatch->glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if (status != GL_FRAMEBUFFER_COMPLETE) {
|
||||
const char *str;
|
||||
|
||||
FatalError("destination is framebuffer incomplete: %s [%x]\n",
|
||||
str, status);
|
||||
}
|
||||
glamor_put_dispatch(fbo->glamor_priv);
|
||||
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;
|
||||
}
|
||||
|
||||
FatalError("destination is framebuffer incomplete: %s [%x]\n",
|
||||
str, status);
|
||||
}
|
||||
glamor_put_dispatch(fbo->glamor_priv);
|
||||
}
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_create_fbo_from_tex(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, GLint tex, int flag)
|
||||
int w, int h, GLenum format, GLint tex, int flag)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
fbo = calloc(1, sizeof(*fbo));
|
||||
if (fbo == NULL)
|
||||
return NULL;
|
||||
fbo = calloc(1, sizeof(*fbo));
|
||||
if (fbo == NULL)
|
||||
return NULL;
|
||||
|
||||
xorg_list_init(&fbo->list);
|
||||
xorg_list_init(&fbo->list);
|
||||
|
||||
fbo->tex = tex;
|
||||
fbo->width = w;
|
||||
fbo->height = h;
|
||||
fbo->format = format;
|
||||
fbo->glamor_priv = glamor_priv;
|
||||
fbo->tex = tex;
|
||||
fbo->width = w;
|
||||
fbo->height = h;
|
||||
fbo->format = format;
|
||||
fbo->glamor_priv = glamor_priv;
|
||||
|
||||
if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
|
||||
glamor_gl_dispatch *dispatch;
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glGenBuffers(1, &fbo->pbo);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
goto done;
|
||||
}
|
||||
if (flag == GLAMOR_CREATE_PIXMAP_MAP) {
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
if (flag != GLAMOR_CREATE_FBO_NO_FBO)
|
||||
glamor_pixmap_ensure_fb(fbo);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glGenBuffers(1, &fbo->pbo);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
return fbo;
|
||||
if (flag != GLAMOR_CREATE_FBO_NO_FBO)
|
||||
glamor_pixmap_ensure_fb(fbo);
|
||||
|
||||
done:
|
||||
return fbo;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fbo_expire(glamor_screen_private *glamor_priv)
|
||||
{
|
||||
struct xorg_list *cache;
|
||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||
int i,j,k;
|
||||
struct xorg_list *cache;
|
||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||
int i, j, k;
|
||||
|
||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
|
||||
if (GLAMOR_TICK_AFTER(fbo_entry->expire, glamor_priv->tick)) {
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache,
|
||||
list) {
|
||||
if (GLAMOR_TICK_AFTER(fbo_entry->expire, glamor_priv->tick)) {
|
||||
break;
|
||||
}
|
||||
|
||||
glamor_priv->fbo_cache_watermark -= fbo_entry->width * fbo_entry->height;
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
DEBUGF("cache %p fbo %p expired %d current %d \n", cache, fbo_entry,
|
||||
fbo_entry->expire, glamor_priv->tick);
|
||||
glamor_purge_fbo(fbo_entry);
|
||||
}
|
||||
}
|
||||
glamor_priv->fbo_cache_watermark -=
|
||||
fbo_entry->width * fbo_entry->height;
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
DEBUGF("cache %p fbo %p expired %d current %d \n", cache,
|
||||
fbo_entry, fbo_entry->expire, glamor_priv->tick);
|
||||
glamor_purge_fbo(fbo_entry);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
glamor_init_pixmap_fbo(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
int i,j,k;
|
||||
glamor_screen_private *glamor_priv;
|
||||
int i, j, k;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
|
||||
{
|
||||
xorg_list_init(&glamor_priv->fbo_cache[i][j][k]);
|
||||
}
|
||||
glamor_priv->fbo_cache_watermark = 0;
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
xorg_list_init(&glamor_priv->fbo_cache[i][j][k]);
|
||||
}
|
||||
glamor_priv->fbo_cache_watermark = 0;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_fini_pixmap_fbo(ScreenPtr screen)
|
||||
{
|
||||
struct xorg_list *cache;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||
int i,j,k;
|
||||
struct xorg_list *cache;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_pixmap_fbo *fbo_entry, *tmp;
|
||||
int i, j, k;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
for(i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for(j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for(k = 0; k < CACHE_BUCKET_HCOUNT; k++)
|
||||
{
|
||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache, list) {
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
glamor_purge_fbo(fbo_entry);
|
||||
}
|
||||
}
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
for (i = 0; i < CACHE_FORMAT_COUNT; i++)
|
||||
for (j = 0; j < CACHE_BUCKET_WCOUNT; j++)
|
||||
for (k = 0; k < CACHE_BUCKET_HCOUNT; k++) {
|
||||
cache = &glamor_priv->fbo_cache[i][j][k];
|
||||
xorg_list_for_each_entry_safe_reverse(fbo_entry, tmp, cache,
|
||||
list) {
|
||||
xorg_list_del(&fbo_entry->list);
|
||||
glamor_purge_fbo(fbo_entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glamor_destroy_fbo(glamor_pixmap_fbo *fbo)
|
||||
{
|
||||
xorg_list_del(&fbo->list);
|
||||
glamor_pixmap_fbo_cache_put(fbo);
|
||||
xorg_list_del(&fbo->list);
|
||||
glamor_pixmap_fbo_cache_put(fbo);
|
||||
|
||||
}
|
||||
|
||||
static int
|
||||
_glamor_create_tex(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format)
|
||||
int w, int h, GLenum format)
|
||||
{
|
||||
glamor_gl_dispatch *dispatch;
|
||||
unsigned int tex = 0;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
unsigned int tex = 0;
|
||||
|
||||
/* With dri3, we want to allocate ARGB8888 pixmaps only.
|
||||
* Depending on the implementation, GL_RGBA might not
|
||||
* give us ARGB8888. We ask glamor_egl to use get
|
||||
* an ARGB8888 based texture for us. */
|
||||
if (glamor_priv->dri3_enabled && format == GL_RGBA)
|
||||
{
|
||||
tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,
|
||||
w, h);
|
||||
}
|
||||
if (!tex)
|
||||
{
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
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);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
return tex;
|
||||
/* With dri3, we want to allocate ARGB8888 pixmaps only.
|
||||
* Depending on the implementation, GL_RGBA might not
|
||||
* give us ARGB8888. We ask glamor_egl to use get
|
||||
* an ARGB8888 based texture for us. */
|
||||
if (glamor_priv->dri3_enabled && format == GL_RGBA) {
|
||||
tex = glamor_egl_create_argb8888_based_texture(glamor_priv->screen,
|
||||
w, h);
|
||||
}
|
||||
if (!tex) {
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
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);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
return tex;
|
||||
}
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_create_fbo(glamor_screen_private *glamor_priv,
|
||||
int w, int h,
|
||||
GLenum format,
|
||||
int flag)
|
||||
int w, int h, GLenum format, int flag)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
GLint tex = 0;
|
||||
int cache_flag;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
GLint tex = 0;
|
||||
int cache_flag;
|
||||
|
||||
if (!glamor_check_fbo_size(glamor_priv, w, h))
|
||||
return NULL;
|
||||
if (!glamor_check_fbo_size(glamor_priv, w, h))
|
||||
return NULL;
|
||||
|
||||
if (flag == GLAMOR_CREATE_FBO_NO_FBO)
|
||||
goto new_fbo;
|
||||
if (flag == GLAMOR_CREATE_FBO_NO_FBO)
|
||||
goto new_fbo;
|
||||
|
||||
if (flag == GLAMOR_CREATE_PIXMAP_MAP)
|
||||
goto no_tex;
|
||||
if (flag == GLAMOR_CREATE_PIXMAP_MAP)
|
||||
goto no_tex;
|
||||
|
||||
if (flag == GLAMOR_CREATE_PIXMAP_FIXUP)
|
||||
cache_flag = GLAMOR_CACHE_EXACT_SIZE;
|
||||
else
|
||||
cache_flag = 0;
|
||||
if (flag == GLAMOR_CREATE_PIXMAP_FIXUP)
|
||||
cache_flag = GLAMOR_CACHE_EXACT_SIZE;
|
||||
else
|
||||
cache_flag = 0;
|
||||
|
||||
fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h,
|
||||
format, cache_flag);
|
||||
if (fbo)
|
||||
return fbo;
|
||||
new_fbo:
|
||||
tex = _glamor_create_tex(glamor_priv, w, h, format);
|
||||
no_tex:
|
||||
fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, format, tex, flag);
|
||||
fbo = glamor_pixmap_fbo_cache_get(glamor_priv, w, h, format, cache_flag);
|
||||
if (fbo)
|
||||
return fbo;
|
||||
new_fbo:
|
||||
tex = _glamor_create_tex(glamor_priv, w, h, format);
|
||||
no_tex:
|
||||
fbo = glamor_create_fbo_from_tex(glamor_priv, w, h, format, tex, flag);
|
||||
|
||||
return fbo;
|
||||
return fbo;
|
||||
}
|
||||
|
||||
static glamor_pixmap_fbo *
|
||||
_glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, int flag,
|
||||
int block_w, int block_h,
|
||||
glamor_pixmap_private *pixmap_priv,
|
||||
int has_fbo)
|
||||
int w, int h, GLenum format, int flag,
|
||||
int block_w, int block_h,
|
||||
glamor_pixmap_private *pixmap_priv, int has_fbo)
|
||||
{
|
||||
int block_wcnt;
|
||||
int block_hcnt;
|
||||
glamor_pixmap_fbo **fbo_array;
|
||||
BoxPtr box_array;
|
||||
int i,j;
|
||||
glamor_pixmap_private_large_t *priv;
|
||||
int block_wcnt;
|
||||
int block_hcnt;
|
||||
glamor_pixmap_fbo **fbo_array;
|
||||
BoxPtr box_array;
|
||||
int i, j;
|
||||
glamor_pixmap_private_large_t *priv;
|
||||
|
||||
priv = &pixmap_priv->large;
|
||||
priv = &pixmap_priv->large;
|
||||
|
||||
block_wcnt = (w + block_w - 1) / block_w;
|
||||
block_hcnt = (h + block_h - 1) / block_h;
|
||||
block_wcnt = (w + block_w - 1) / block_w;
|
||||
block_hcnt = (h + block_h - 1) / block_h;
|
||||
|
||||
box_array = calloc(block_wcnt * block_hcnt, sizeof(box_array[0]));
|
||||
if (box_array == NULL)
|
||||
return NULL;
|
||||
box_array = calloc(block_wcnt * block_hcnt, sizeof(box_array[0]));
|
||||
if (box_array == NULL)
|
||||
return NULL;
|
||||
|
||||
fbo_array = calloc(block_wcnt * block_hcnt, sizeof(glamor_pixmap_fbo*));
|
||||
if (fbo_array == NULL) {
|
||||
free(box_array);
|
||||
return FALSE;
|
||||
}
|
||||
for(i = 0; i < block_hcnt; i++)
|
||||
{
|
||||
int block_y1, block_y2;
|
||||
int fbo_w, fbo_h;
|
||||
fbo_array = calloc(block_wcnt * block_hcnt, sizeof(glamor_pixmap_fbo *));
|
||||
if (fbo_array == NULL) {
|
||||
free(box_array);
|
||||
return FALSE;
|
||||
}
|
||||
for (i = 0; i < block_hcnt; i++) {
|
||||
int block_y1, block_y2;
|
||||
int fbo_w, fbo_h;
|
||||
|
||||
block_y1 = i * block_h;
|
||||
block_y2 = (block_y1 + block_h) > h ? h : (block_y1 + block_h);
|
||||
fbo_h = block_y2 - block_y1;
|
||||
block_y1 = i * block_h;
|
||||
block_y2 = (block_y1 + block_h) > h ? h : (block_y1 + block_h);
|
||||
fbo_h = block_y2 - block_y1;
|
||||
|
||||
for (j = 0; j < block_wcnt; j++)
|
||||
{
|
||||
box_array[i * block_wcnt + j].x1 = j * block_w;
|
||||
box_array[i * block_wcnt + j].y1 = block_y1;
|
||||
box_array[i * block_wcnt + j].x2 = (j + 1) * block_w > w ? w : (j + 1) * block_w;
|
||||
box_array[i * block_wcnt + j].y2 = block_y2;
|
||||
fbo_w = box_array[i * block_wcnt + j].x2 - box_array[i * block_wcnt + j].x1;
|
||||
if (!has_fbo)
|
||||
fbo_array[i * block_wcnt + j] = glamor_create_fbo(glamor_priv,
|
||||
fbo_w, fbo_h, format,
|
||||
GLAMOR_CREATE_PIXMAP_FIXUP);
|
||||
else
|
||||
fbo_array[i * block_wcnt + j] = priv->base.fbo;
|
||||
if (fbo_array[i * block_wcnt + j] == NULL)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
for (j = 0; j < block_wcnt; j++) {
|
||||
box_array[i * block_wcnt + j].x1 = j * block_w;
|
||||
box_array[i * block_wcnt + j].y1 = block_y1;
|
||||
box_array[i * block_wcnt + j].x2 =
|
||||
(j + 1) * block_w > w ? w : (j + 1) * block_w;
|
||||
box_array[i * block_wcnt + j].y2 = block_y2;
|
||||
fbo_w =
|
||||
box_array[i * block_wcnt + j].x2 - box_array[i * block_wcnt +
|
||||
j].x1;
|
||||
if (!has_fbo)
|
||||
fbo_array[i * block_wcnt + j] = glamor_create_fbo(glamor_priv,
|
||||
fbo_w, fbo_h,
|
||||
format,
|
||||
GLAMOR_CREATE_PIXMAP_FIXUP);
|
||||
else
|
||||
fbo_array[i * block_wcnt + j] = priv->base.fbo;
|
||||
if (fbo_array[i * block_wcnt + j] == NULL)
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
priv->box = box_array[0];
|
||||
priv->box_array = box_array;
|
||||
priv->fbo_array = fbo_array;
|
||||
priv->block_wcnt = block_wcnt;
|
||||
priv->block_hcnt = block_hcnt;
|
||||
return fbo_array[0];
|
||||
priv->box = box_array[0];
|
||||
priv->box_array = box_array;
|
||||
priv->fbo_array = fbo_array;
|
||||
priv->block_wcnt = block_wcnt;
|
||||
priv->block_hcnt = block_hcnt;
|
||||
return fbo_array[0];
|
||||
|
||||
cleanup:
|
||||
for(i = 0; i < block_wcnt * block_hcnt; i++)
|
||||
if ((fbo_array)[i])
|
||||
glamor_destroy_fbo((fbo_array)[i]);
|
||||
free(box_array);
|
||||
free(fbo_array);
|
||||
return NULL;
|
||||
cleanup:
|
||||
for (i = 0; i < block_wcnt * block_hcnt; i++)
|
||||
if ((fbo_array)[i])
|
||||
glamor_destroy_fbo((fbo_array)[i]);
|
||||
free(box_array);
|
||||
free(fbo_array);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Create a fbo array to cover the w*h region, by using block_w*block_h
|
||||
* block.*/
|
||||
glamor_pixmap_fbo *
|
||||
glamor_create_fbo_array(glamor_screen_private *glamor_priv,
|
||||
int w, int h, GLenum format, int flag,
|
||||
int block_w, int block_h,
|
||||
glamor_pixmap_private *pixmap_priv)
|
||||
int w, int h, GLenum format, int flag,
|
||||
int block_w, int block_h,
|
||||
glamor_pixmap_private *pixmap_priv)
|
||||
{
|
||||
pixmap_priv->large.block_w = block_w;
|
||||
pixmap_priv->large.block_h = block_h;
|
||||
return _glamor_create_fbo_array(glamor_priv, w, h, format, flag,
|
||||
block_w, block_h, pixmap_priv, 0);
|
||||
pixmap_priv->large.block_w = block_w;
|
||||
pixmap_priv->large.block_h = block_h;
|
||||
return _glamor_create_fbo_array(glamor_priv, w, h, format, flag,
|
||||
block_w, block_h, pixmap_priv, 0);
|
||||
}
|
||||
|
||||
glamor_pixmap_fbo *
|
||||
glamor_pixmap_detach_fbo(glamor_pixmap_private *pixmap_priv)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
if (pixmap_priv == NULL)
|
||||
return NULL;
|
||||
if (pixmap_priv == NULL)
|
||||
return NULL;
|
||||
|
||||
fbo = pixmap_priv->base.fbo;
|
||||
if (fbo == NULL)
|
||||
return NULL;
|
||||
fbo = pixmap_priv->base.fbo;
|
||||
if (fbo == NULL)
|
||||
return NULL;
|
||||
|
||||
pixmap_priv->base.fbo = NULL;
|
||||
return fbo;
|
||||
pixmap_priv->base.fbo = NULL;
|
||||
return fbo;
|
||||
}
|
||||
|
||||
/* The pixmap must not be attached to another fbo. */
|
||||
void
|
||||
glamor_pixmap_attach_fbo(PixmapPtr pixmap, glamor_pixmap_fbo *fbo)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (pixmap_priv->base.fbo)
|
||||
return;
|
||||
if (pixmap_priv->base.fbo)
|
||||
return;
|
||||
|
||||
pixmap_priv->base.fbo = fbo;
|
||||
pixmap_priv->base.fbo = fbo;
|
||||
|
||||
switch (pixmap_priv->type) {
|
||||
case GLAMOR_TEXTURE_LARGE:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
pixmap_priv->base.gl_fbo = 1;
|
||||
if (fbo->tex != 0)
|
||||
pixmap_priv->base.gl_tex = 1;
|
||||
else {
|
||||
/* XXX For the Xephyr only, may be broken now.*/
|
||||
pixmap_priv->base.gl_tex = 0;
|
||||
}
|
||||
case GLAMOR_MEMORY_MAP:
|
||||
pixmap->devPrivate.ptr = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (pixmap_priv->type) {
|
||||
case GLAMOR_TEXTURE_LARGE:
|
||||
case GLAMOR_TEXTURE_ONLY:
|
||||
case GLAMOR_TEXTURE_DRM:
|
||||
pixmap_priv->base.gl_fbo = 1;
|
||||
if (fbo->tex != 0)
|
||||
pixmap_priv->base.gl_tex = 1;
|
||||
else {
|
||||
/* XXX For the Xephyr only, may be broken now. */
|
||||
pixmap_priv->base.gl_tex = 0;
|
||||
}
|
||||
case GLAMOR_MEMORY_MAP:
|
||||
pixmap->devPrivate.ptr = NULL;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
glamor_pixmap_destroy_fbo(glamor_pixmap_private *priv)
|
||||
{
|
||||
glamor_pixmap_fbo *fbo;
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
int i;
|
||||
glamor_pixmap_private_large_t *large = &priv->large;
|
||||
for(i = 0; i < large->block_wcnt * large->block_hcnt; i++)
|
||||
glamor_destroy_fbo(large->fbo_array[i]);
|
||||
free(large->fbo_array);
|
||||
} else {
|
||||
fbo = glamor_pixmap_detach_fbo(priv);
|
||||
if (fbo)
|
||||
glamor_destroy_fbo(fbo);
|
||||
}
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
free(priv);
|
||||
if (priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
int i;
|
||||
glamor_pixmap_private_large_t *large = &priv->large;
|
||||
|
||||
for (i = 0; i < large->block_wcnt * large->block_hcnt; i++)
|
||||
glamor_destroy_fbo(large->fbo_array[i]);
|
||||
free(large->fbo_array);
|
||||
}
|
||||
else {
|
||||
fbo = glamor_pixmap_detach_fbo(priv);
|
||||
if (fbo)
|
||||
glamor_destroy_fbo(fbo);
|
||||
}
|
||||
|
||||
free(priv);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_pixmap_ensure_fbo(PixmapPtr pixmap, GLenum format, int flag)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_pixmap_fbo *fbo;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv->base.fbo == NULL) {
|
||||
glamor_priv = glamor_get_screen_private(pixmap->drawable.pScreen);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (pixmap_priv->base.fbo == NULL) {
|
||||
|
||||
fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height,
|
||||
format,
|
||||
flag);
|
||||
if (fbo == NULL)
|
||||
return FALSE;
|
||||
fbo = glamor_create_fbo(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height, format, flag);
|
||||
if (fbo == NULL)
|
||||
return FALSE;
|
||||
|
||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||
} else {
|
||||
/* We do have a fbo, but it may lack of fb or tex. */
|
||||
if (!pixmap_priv->base.fbo->tex)
|
||||
pixmap_priv->base.fbo->tex = _glamor_create_tex(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height, format);
|
||||
glamor_pixmap_attach_fbo(pixmap, fbo);
|
||||
}
|
||||
else {
|
||||
/* We do have a fbo, but it may lack of fb or tex. */
|
||||
if (!pixmap_priv->base.fbo->tex)
|
||||
pixmap_priv->base.fbo->tex =
|
||||
_glamor_create_tex(glamor_priv, pixmap->drawable.width,
|
||||
pixmap->drawable.height, format);
|
||||
|
||||
if (flag != GLAMOR_CREATE_FBO_NO_FBO && pixmap_priv->base.fbo->fb == 0)
|
||||
glamor_pixmap_ensure_fb(pixmap_priv->base.fbo);
|
||||
}
|
||||
if (flag != GLAMOR_CREATE_FBO_NO_FBO && pixmap_priv->base.fbo->fb == 0)
|
||||
glamor_pixmap_ensure_fb(pixmap_priv->base.fbo);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
_X_EXPORT void
|
||||
glamor_pixmap_exchange_fbos(PixmapPtr front, PixmapPtr back)
|
||||
{
|
||||
glamor_pixmap_private *front_priv, *back_priv;
|
||||
glamor_pixmap_fbo *temp_fbo;
|
||||
glamor_pixmap_private *front_priv, *back_priv;
|
||||
glamor_pixmap_fbo *temp_fbo;
|
||||
|
||||
front_priv = glamor_get_pixmap_private(front);
|
||||
back_priv = glamor_get_pixmap_private(back);
|
||||
temp_fbo = front_priv->base.fbo;
|
||||
front_priv->base.fbo = back_priv->base.fbo;
|
||||
back_priv->base.fbo = temp_fbo;
|
||||
front_priv = glamor_get_pixmap_private(front);
|
||||
back_priv = glamor_get_pixmap_private(back);
|
||||
temp_fbo = front_priv->base.fbo;
|
||||
front_priv->base.fbo = back_priv->base.fbo;
|
||||
back_priv->base.fbo = temp_fbo;
|
||||
}
|
||||
|
|
|
@ -33,332 +33,325 @@
|
|||
*/
|
||||
Bool
|
||||
glamor_fill(DrawablePtr drawable,
|
||||
GCPtr gc, int x, int y, int width, int height, Bool fallback)
|
||||
GCPtr gc, int x, int y, int width, int height, Bool fallback)
|
||||
{
|
||||
PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
int off_x, off_y;
|
||||
PixmapPtr sub_pixmap = NULL;
|
||||
glamor_access_t sub_pixmap_access;
|
||||
DrawablePtr saved_drawable = NULL;
|
||||
int saved_x = x, saved_y = y;
|
||||
PixmapPtr dst_pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
int off_x, off_y;
|
||||
PixmapPtr sub_pixmap = NULL;
|
||||
glamor_access_t sub_pixmap_access;
|
||||
DrawablePtr saved_drawable = NULL;
|
||||
int saved_x = x, saved_y = y;
|
||||
|
||||
glamor_get_drawable_deltas(drawable, dst_pixmap, &off_x, &off_y);
|
||||
glamor_get_drawable_deltas(drawable, dst_pixmap, &off_x, &off_y);
|
||||
|
||||
switch (gc->fillStyle) {
|
||||
case FillSolid:
|
||||
if (!glamor_solid(dst_pixmap,
|
||||
x + off_x,
|
||||
y + off_y,
|
||||
width, height, gc->alu, gc->planemask,
|
||||
gc->fgPixel))
|
||||
goto fail;
|
||||
break;
|
||||
case FillStippled:
|
||||
case FillOpaqueStippled:
|
||||
if (!glamor_stipple(dst_pixmap,
|
||||
gc->stipple,
|
||||
x + off_x,
|
||||
y + off_y,
|
||||
width,
|
||||
height,
|
||||
gc->alu,
|
||||
gc->planemask,
|
||||
gc->fgPixel,
|
||||
gc->bgPixel, gc->patOrg.x,
|
||||
gc->patOrg.y))
|
||||
goto fail;
|
||||
break;
|
||||
case FillTiled:
|
||||
if (!glamor_tile(dst_pixmap,
|
||||
gc->tile.pixmap,
|
||||
x + off_x,
|
||||
y + off_y,
|
||||
width,
|
||||
height,
|
||||
gc->alu,
|
||||
gc->planemask,
|
||||
x - drawable->x - gc->patOrg.x,
|
||||
y - drawable->y - gc->patOrg.y))
|
||||
goto fail;
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
switch (gc->fillStyle) {
|
||||
case FillSolid:
|
||||
if (!glamor_solid(dst_pixmap,
|
||||
x + off_x,
|
||||
y + off_y,
|
||||
width, height, gc->alu, gc->planemask, gc->fgPixel))
|
||||
goto fail;
|
||||
break;
|
||||
case FillStippled:
|
||||
case FillOpaqueStippled:
|
||||
if (!glamor_stipple(dst_pixmap,
|
||||
gc->stipple,
|
||||
x + off_x,
|
||||
y + off_y,
|
||||
width,
|
||||
height,
|
||||
gc->alu,
|
||||
gc->planemask,
|
||||
gc->fgPixel,
|
||||
gc->bgPixel, gc->patOrg.x, gc->patOrg.y))
|
||||
goto fail;
|
||||
break;
|
||||
case FillTiled:
|
||||
if (!glamor_tile(dst_pixmap,
|
||||
gc->tile.pixmap,
|
||||
x + off_x,
|
||||
y + off_y,
|
||||
width,
|
||||
height,
|
||||
gc->alu,
|
||||
gc->planemask,
|
||||
x - drawable->x - gc->patOrg.x,
|
||||
y - drawable->y - gc->patOrg.y))
|
||||
goto fail;
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
if (!fallback) {
|
||||
if (glamor_ddx_fallback_check_pixmap(&dst_pixmap->drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
return FALSE;
|
||||
}
|
||||
/* Is it possible to set the access as WO? */
|
||||
fail:
|
||||
if (!fallback) {
|
||||
if (glamor_ddx_fallback_check_pixmap(&dst_pixmap->drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
return FALSE;
|
||||
}
|
||||
/* Is it possible to set the access as WO? */
|
||||
|
||||
sub_pixmap_access = GLAMOR_ACCESS_RW;
|
||||
sub_pixmap_access = GLAMOR_ACCESS_RW;
|
||||
|
||||
sub_pixmap = glamor_get_sub_pixmap(dst_pixmap, x + off_x,
|
||||
y + off_y, width, height,
|
||||
sub_pixmap_access);
|
||||
sub_pixmap = glamor_get_sub_pixmap(dst_pixmap, x + off_x,
|
||||
y + off_y, width, height,
|
||||
sub_pixmap_access);
|
||||
|
||||
if (sub_pixmap != NULL) {
|
||||
if (gc->fillStyle != FillSolid) {
|
||||
gc->patOrg.x += (drawable->x - x);
|
||||
gc->patOrg.y += (drawable->y - y);
|
||||
}
|
||||
saved_drawable = drawable;
|
||||
drawable = &sub_pixmap->drawable;
|
||||
saved_x = x;
|
||||
saved_y = y;
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbFill(drawable, gc, x, y, width, height);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
if (sub_pixmap != NULL) {
|
||||
if (gc->fillStyle != FillSolid) {
|
||||
gc->patOrg.x += (drawable->x - x);
|
||||
gc->patOrg.y += (drawable->y - y);
|
||||
}
|
||||
saved_drawable = drawable;
|
||||
drawable = &sub_pixmap->drawable;
|
||||
saved_x = x;
|
||||
saved_y = y;
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbFill(drawable, gc, x, y, width, height);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
|
||||
if (sub_pixmap != NULL) {
|
||||
if (gc->fillStyle != FillSolid) {
|
||||
gc->patOrg.x -= (saved_drawable->x - saved_x);
|
||||
gc->patOrg.y -= (saved_drawable->y - saved_y);
|
||||
}
|
||||
if (sub_pixmap != NULL) {
|
||||
if (gc->fillStyle != FillSolid) {
|
||||
gc->patOrg.x -= (saved_drawable->x - saved_x);
|
||||
gc->patOrg.y -= (saved_drawable->y - saved_y);
|
||||
}
|
||||
|
||||
x = saved_x;
|
||||
y = saved_y;
|
||||
x = saved_x;
|
||||
y = saved_y;
|
||||
|
||||
glamor_put_sub_pixmap(sub_pixmap, dst_pixmap,
|
||||
x + off_x, y + off_y,
|
||||
width, height, sub_pixmap_access);
|
||||
}
|
||||
glamor_put_sub_pixmap(sub_pixmap, dst_pixmap,
|
||||
x + off_x, y + off_y,
|
||||
width, height, sub_pixmap_access);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_init_solid_shader(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
const char *solid_vs =
|
||||
"attribute vec4 v_position;"
|
||||
"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";
|
||||
GLint fs_prog, vs_prog;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
const char *solid_vs =
|
||||
"attribute vec4 v_position;"
|
||||
"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";
|
||||
GLint fs_prog, vs_prog;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
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);
|
||||
dispatch->glAttachShader(glamor_priv->solid_prog, vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->solid_prog, fs_prog);
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
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);
|
||||
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");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->solid_prog);
|
||||
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");
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_priv->solid_color_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->solid_prog, "color");
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_fini_solid_shader(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glDeleteProgram(glamor_priv->solid_prog);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glDeleteProgram(glamor_priv->solid_prog);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
static void
|
||||
_glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
||||
{
|
||||
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_gl_dispatch *dispatch;
|
||||
GLfloat xscale, yscale;
|
||||
float vertices[32];
|
||||
float *pvertices = vertices;
|
||||
int valid_nbox = ARRAY_SIZE(vertices);
|
||||
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_gl_dispatch *dispatch;
|
||||
GLfloat xscale, yscale;
|
||||
float vertices[32];
|
||||
float *pvertices = vertices;
|
||||
int valid_nbox = ARRAY_SIZE(vertices);
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
glamor_set_destination_pixmap_priv_nc(pixmap_priv);
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->solid_prog);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
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);
|
||||
|
||||
pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
|
||||
pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale);
|
||||
|
||||
if (unlikely(nbox*4*2 > ARRAY_SIZE(vertices))) {
|
||||
int allocated_box;
|
||||
if (_X_UNLIKELY(nbox * 4 * 2 > ARRAY_SIZE(vertices))) {
|
||||
int allocated_box;
|
||||
|
||||
if (nbox * 6 > GLAMOR_COMPOSITE_VBO_VERT_CNT) {
|
||||
allocated_box = GLAMOR_COMPOSITE_VBO_VERT_CNT / 6;
|
||||
} else
|
||||
allocated_box = nbox;
|
||||
pvertices = malloc(allocated_box * 4 * 2 * sizeof(float));
|
||||
if (pvertices)
|
||||
valid_nbox = allocated_box;
|
||||
else {
|
||||
pvertices = vertices;
|
||||
valid_nbox = ARRAY_SIZE(vertices) / (4*2);
|
||||
}
|
||||
}
|
||||
if (nbox * 6 > GLAMOR_COMPOSITE_VBO_VERT_CNT) {
|
||||
allocated_box = GLAMOR_COMPOSITE_VBO_VERT_CNT / 6;
|
||||
}
|
||||
else
|
||||
allocated_box = nbox;
|
||||
pvertices = malloc(allocated_box * 4 * 2 * sizeof(float));
|
||||
if (pvertices)
|
||||
valid_nbox = allocated_box;
|
||||
else {
|
||||
pvertices = vertices;
|
||||
valid_nbox = ARRAY_SIZE(vertices) / (4 * 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely(nbox > 1))
|
||||
dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
|
||||
if (_X_UNLIKELY(nbox > 1))
|
||||
dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float),
|
||||
pvertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT,
|
||||
GL_FALSE, 2 * sizeof(float), pvertices);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
|
||||
while(nbox) {
|
||||
int box_cnt, i;
|
||||
float *valid_vertices;
|
||||
valid_vertices = pvertices;
|
||||
box_cnt = nbox > valid_nbox ? valid_nbox : nbox;
|
||||
for (i = 0; i < box_cnt; i++) {
|
||||
glamor_set_normalize_vcoords(pixmap_priv, xscale, yscale,
|
||||
box[i].x1, box[i].y1,
|
||||
box[i].x2, box[i].y2,
|
||||
glamor_priv->yInverted,
|
||||
valid_vertices);
|
||||
valid_vertices += 4*2;
|
||||
}
|
||||
if (box_cnt == 1)
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
|
||||
else
|
||||
while (nbox) {
|
||||
int box_cnt, i;
|
||||
float *valid_vertices;
|
||||
|
||||
valid_vertices = pvertices;
|
||||
box_cnt = nbox > valid_nbox ? valid_nbox : nbox;
|
||||
for (i = 0; i < box_cnt; i++) {
|
||||
glamor_set_normalize_vcoords(pixmap_priv, xscale, yscale,
|
||||
box[i].x1, box[i].y1,
|
||||
box[i].x2, box[i].y2,
|
||||
glamor_priv->yInverted,
|
||||
valid_vertices);
|
||||
valid_vertices += 4 * 2;
|
||||
}
|
||||
if (box_cnt == 1)
|
||||
dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, box_cnt * 4);
|
||||
else
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glDrawRangeElements(GL_TRIANGLES,
|
||||
0,
|
||||
box_cnt * 4,
|
||||
box_cnt * 6,
|
||||
GL_UNSIGNED_SHORT,
|
||||
NULL);
|
||||
dispatch->glDrawRangeElements(GL_TRIANGLES,
|
||||
0,
|
||||
box_cnt * 4,
|
||||
box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
|
||||
#else
|
||||
dispatch->glDrawElements(GL_TRIANGLES,
|
||||
box_cnt * 6,
|
||||
GL_UNSIGNED_SHORT,
|
||||
NULL);
|
||||
dispatch->glDrawElements(GL_TRIANGLES,
|
||||
box_cnt * 6, GL_UNSIGNED_SHORT, NULL);
|
||||
#endif
|
||||
nbox -= box_cnt;
|
||||
box += box_cnt;
|
||||
}
|
||||
nbox -= box_cnt;
|
||||
box += box_cnt;
|
||||
}
|
||||
|
||||
if (pvertices != vertices)
|
||||
free(pvertices);
|
||||
if (pvertices != vertices)
|
||||
free(pvertices);
|
||||
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_priv->state = RENDER_STATE;
|
||||
glamor_priv->render_idle_cnt = 0;
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_priv->state = RENDER_STATE;
|
||||
glamor_priv->render_idle_cnt = 0;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_solid_boxes(PixmapPtr pixmap,
|
||||
BoxPtr box, int nbox,
|
||||
unsigned long fg_pixel)
|
||||
BoxPtr box, int nbox, unsigned long fg_pixel)
|
||||
{
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
GLfloat color[4];
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
GLfloat color[4];
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return FALSE;
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return FALSE;
|
||||
|
||||
glamor_get_rgba_from_pixel(fg_pixel,
|
||||
&color[0],
|
||||
&color[1],
|
||||
&color[2],
|
||||
&color[3], format_for_pixmap(pixmap));
|
||||
glamor_get_rgba_from_pixel(fg_pixel,
|
||||
&color[0],
|
||||
&color[1],
|
||||
&color[2], &color[3], format_for_pixmap(pixmap));
|
||||
|
||||
if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionRec region;
|
||||
int n_region;
|
||||
glamor_pixmap_clipped_regions *clipped_regions;
|
||||
int i;
|
||||
if (pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionRec region;
|
||||
int n_region;
|
||||
glamor_pixmap_clipped_regions *clipped_regions;
|
||||
int i;
|
||||
|
||||
RegionInitBoxes(®ion, box, nbox);
|
||||
clipped_regions = glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0, 0, 0);
|
||||
for(i = 0; i < n_region; i++)
|
||||
{
|
||||
BoxPtr inner_box;
|
||||
int inner_nbox;
|
||||
SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
|
||||
RegionInitBoxes(®ion, box, nbox);
|
||||
clipped_regions =
|
||||
glamor_compute_clipped_regions(pixmap_priv, ®ion, &n_region, 0,
|
||||
0, 0);
|
||||
for (i = 0; i < n_region; i++) {
|
||||
BoxPtr inner_box;
|
||||
int inner_nbox;
|
||||
|
||||
inner_box = RegionRects(clipped_regions[i].region);
|
||||
inner_nbox = RegionNumRects(clipped_regions[i].region);
|
||||
_glamor_solid_boxes(pixmap, inner_box, inner_nbox, color);
|
||||
RegionDestroy(clipped_regions[i].region);
|
||||
}
|
||||
free(clipped_regions);
|
||||
RegionUninit(®ion);
|
||||
} else
|
||||
_glamor_solid_boxes(pixmap, box, nbox, color);
|
||||
SET_PIXMAP_FBO_CURRENT(pixmap_priv, clipped_regions[i].block_idx);
|
||||
|
||||
return TRUE;
|
||||
inner_box = RegionRects(clipped_regions[i].region);
|
||||
inner_nbox = RegionNumRects(clipped_regions[i].region);
|
||||
_glamor_solid_boxes(pixmap, inner_box, inner_nbox, color);
|
||||
RegionDestroy(clipped_regions[i].region);
|
||||
}
|
||||
free(clipped_regions);
|
||||
RegionUninit(®ion);
|
||||
}
|
||||
else
|
||||
_glamor_solid_boxes(pixmap, box, nbox, color);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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_gl_dispatch *dispatch;
|
||||
BoxRec box;
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
BoxRec box;
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return FALSE;
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
return FALSE;
|
||||
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
glamor_fallback
|
||||
("Failedto set planemask in glamor_solid.\n");
|
||||
return FALSE;
|
||||
}
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
if (!glamor_set_alu(dispatch, alu)) {
|
||||
if (alu == GXclear)
|
||||
fg_pixel = 0;
|
||||
else {
|
||||
glamor_fallback("unsupported alu %x\n", alu);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
box.x1 = x;
|
||||
box.y1 = y;
|
||||
box.x2 = x + width;
|
||||
box.y2 = y + height;
|
||||
glamor_solid_boxes(pixmap, &box, 1, fg_pixel);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
if (!glamor_set_alu(dispatch, alu)) {
|
||||
if (alu == GXclear)
|
||||
fg_pixel = 0;
|
||||
else {
|
||||
glamor_fallback("unsupported alu %x\n", alu);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
box.x1 = x;
|
||||
box.y1 = y;
|
||||
box.x2 = x + width;
|
||||
box.y2 = y + height;
|
||||
glamor_solid_boxes(pixmap, &box, 1, fg_pixel);
|
||||
|
||||
glamor_set_alu(dispatch, GXcopy);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_set_alu(dispatch, GXcopy);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,86 +28,81 @@
|
|||
|
||||
static Bool
|
||||
_glamor_fill_spans(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points, int *widths, int sorted, Bool fallback)
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points, int *widths, int sorted,
|
||||
Bool fallback)
|
||||
{
|
||||
DDXPointPtr ppt;
|
||||
int nbox;
|
||||
BoxPtr pbox;
|
||||
int x1, x2, y;
|
||||
RegionPtr pClip = fbGetCompositeClip(gc);
|
||||
Bool ret = FALSE;
|
||||
DDXPointPtr ppt;
|
||||
int nbox;
|
||||
BoxPtr pbox;
|
||||
int x1, x2, y;
|
||||
RegionPtr pClip = fbGetCompositeClip(gc);
|
||||
Bool ret = FALSE;
|
||||
|
||||
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
|
||||
goto fail;
|
||||
if (gc->fillStyle != FillSolid && gc->fillStyle != FillTiled)
|
||||
goto fail;
|
||||
|
||||
ppt = points;
|
||||
while (n--) {
|
||||
x1 = ppt->x;
|
||||
y = ppt->y;
|
||||
x2 = x1 + (int) *widths;
|
||||
ppt++;
|
||||
widths++;
|
||||
ppt = points;
|
||||
while (n--) {
|
||||
x1 = ppt->x;
|
||||
y = ppt->y;
|
||||
x2 = x1 + (int) *widths;
|
||||
ppt++;
|
||||
widths++;
|
||||
|
||||
nbox = REGION_NUM_RECTS(pClip);
|
||||
pbox = REGION_RECTS(pClip);
|
||||
while (nbox--) {
|
||||
int real_x1 = x1, real_x2 = x2;
|
||||
nbox = REGION_NUM_RECTS(pClip);
|
||||
pbox = REGION_RECTS(pClip);
|
||||
while (nbox--) {
|
||||
int real_x1 = x1, real_x2 = x2;
|
||||
|
||||
if (real_x1 < pbox->x1)
|
||||
real_x1 = pbox->x1;
|
||||
if (real_x1 < pbox->x1)
|
||||
real_x1 = pbox->x1;
|
||||
|
||||
if (real_x2 > pbox->x2)
|
||||
real_x2 = pbox->x2;
|
||||
if (real_x2 > pbox->x2)
|
||||
real_x2 = pbox->x2;
|
||||
|
||||
if (real_x2 > real_x1 && pbox->y1 <= y && pbox->y2 > y) {
|
||||
if (!glamor_fill(drawable, gc, real_x1, y,
|
||||
real_x2 - real_x1, 1, fallback))
|
||||
goto fail;
|
||||
}
|
||||
pbox++;
|
||||
}
|
||||
}
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
if (real_x2 > real_x1 && pbox->y1 <= y && pbox->y2 > y) {
|
||||
if (!glamor_fill(drawable, gc, real_x1, y,
|
||||
real_x2 - real_x1, 1, fallback))
|
||||
goto fail;
|
||||
}
|
||||
pbox++;
|
||||
}
|
||||
}
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc)) {
|
||||
goto done;
|
||||
}
|
||||
glamor_fallback("to %p (%c)\n", drawable,
|
||||
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);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
ret = TRUE;
|
||||
fail:
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc)) {
|
||||
goto done;
|
||||
}
|
||||
glamor_fallback("to %p (%c)\n", drawable,
|
||||
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);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
return ret;
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_fill_spans(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points, int *widths, int sorted)
|
||||
GCPtr gc, int n, DDXPointPtr points, int *widths, int sorted)
|
||||
{
|
||||
_glamor_fill_spans(drawable, gc, n, points, widths, sorted, TRUE);
|
||||
_glamor_fill_spans(drawable, gc, n, points, widths, sorted, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_fill_spans_nf(DrawablePtr drawable,
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points, int *widths, int sorted)
|
||||
GCPtr gc,
|
||||
int n, DDXPointPtr points, int *widths, int sorted)
|
||||
{
|
||||
return _glamor_fill_spans(drawable, gc, n, points, widths, sorted, FALSE);
|
||||
return _glamor_fill_spans(drawable, gc, n, points, widths, sorted, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,74 +28,71 @@
|
|||
|
||||
#include "glamor_priv.h"
|
||||
|
||||
|
||||
static Bool
|
||||
_glamor_get_image(DrawablePtr drawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d,
|
||||
Bool fallback)
|
||||
unsigned int format, unsigned long planeMask, char *d,
|
||||
Bool fallback)
|
||||
{
|
||||
PixmapPtr pixmap, sub_pixmap;
|
||||
struct glamor_pixmap_private *pixmap_priv;
|
||||
int x_off, y_off;
|
||||
int stride;
|
||||
void *data;
|
||||
PixmapPtr pixmap, sub_pixmap;
|
||||
struct glamor_pixmap_private *pixmap_priv;
|
||||
int x_off, y_off;
|
||||
int stride;
|
||||
void *data;
|
||||
|
||||
pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
|
||||
if (format != ZPixmap)
|
||||
goto fall_back;
|
||||
pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
if (format != ZPixmap)
|
||||
goto fall_back;
|
||||
pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
|
||||
if (!glamor_set_planemask(pixmap, planeMask)) {
|
||||
glamor_fallback
|
||||
("Failedto set planemask in glamor_solid.\n");
|
||||
goto fall_back;
|
||||
}
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (!glamor_set_planemask(pixmap, planeMask)) {
|
||||
glamor_fallback("Failedto set planemask in glamor_solid.\n");
|
||||
goto fall_back;
|
||||
}
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
goto fall_back;
|
||||
stride = PixmapBytePad(w, drawable->depth);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
goto fall_back;
|
||||
stride = PixmapBytePad(w, drawable->depth);
|
||||
x += drawable->x + x_off;
|
||||
y += drawable->y + y_off;
|
||||
|
||||
x += drawable->x + x_off;
|
||||
y += drawable->y + y_off;
|
||||
data = glamor_download_sub_pixmap_to_cpu(pixmap, x, y, w, h, stride,
|
||||
d, 0, GLAMOR_ACCESS_RO);
|
||||
if (data != NULL) {
|
||||
assert(data == d);
|
||||
return TRUE;
|
||||
}
|
||||
fall_back:
|
||||
sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
|
||||
y + y_off + drawable->y, w, h,
|
||||
GLAMOR_ACCESS_RO);
|
||||
if (sub_pixmap) {
|
||||
fbGetImage(&sub_pixmap->drawable, 0, 0, w, h, format, planeMask, d);
|
||||
glamor_put_sub_pixmap(sub_pixmap, pixmap,
|
||||
x + x_off + drawable->x,
|
||||
y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
else
|
||||
miGetImage(drawable, x, y, w, h, format, planeMask, d);
|
||||
|
||||
data = glamor_download_sub_pixmap_to_cpu(pixmap, x, y, w, h, stride,
|
||||
d, 0, GLAMOR_ACCESS_RO);
|
||||
if (data != NULL) {
|
||||
assert(data == d);
|
||||
return TRUE;
|
||||
}
|
||||
fall_back:
|
||||
sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
|
||||
y + y_off + drawable->y, w, h,
|
||||
GLAMOR_ACCESS_RO);
|
||||
if (sub_pixmap) {
|
||||
fbGetImage(&sub_pixmap->drawable, 0, 0, w, h, format, planeMask, d);
|
||||
glamor_put_sub_pixmap(sub_pixmap, pixmap,
|
||||
x + x_off + drawable->x,
|
||||
y + y_off + drawable->y,
|
||||
w, h, GLAMOR_ACCESS_RO);
|
||||
} else
|
||||
miGetImage(drawable, x, y, w, h, format, planeMask, d);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_get_image(DrawablePtr pDrawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d)
|
||||
unsigned int format, unsigned long planeMask, char *d)
|
||||
{
|
||||
_glamor_get_image(pDrawable, x, y, w, h, format, planeMask, d, TRUE);
|
||||
_glamor_get_image(pDrawable, x, y, w, h, format, planeMask, d, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_get_image_nf(DrawablePtr pDrawable, int x, int y, int w, int h,
|
||||
unsigned int format, unsigned long planeMask, char *d)
|
||||
unsigned int format, unsigned long planeMask, char *d)
|
||||
{
|
||||
return _glamor_get_image(pDrawable, x, y, w,
|
||||
h, format, planeMask, d, FALSE);
|
||||
return _glamor_get_image(pDrawable, x, y, w,
|
||||
h, format, planeMask, d, FALSE);
|
||||
}
|
||||
|
|
|
@ -28,68 +28,65 @@
|
|||
|
||||
#include "glamor_priv.h"
|
||||
|
||||
static Bool
|
||||
static Bool
|
||||
_glamor_get_spans(DrawablePtr drawable,
|
||||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst,
|
||||
Bool fallback)
|
||||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst,
|
||||
Bool fallback)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
int i;
|
||||
uint8_t *readpixels_dst = (uint8_t *) dst;
|
||||
void *data;
|
||||
int x_off, y_off;
|
||||
Bool ret = FALSE;
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
int i;
|
||||
uint8_t *readpixels_dst = (uint8_t *) dst;
|
||||
void *data;
|
||||
int x_off, y_off;
|
||||
Bool ret = FALSE;
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
goto fail;
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv))
|
||||
goto fail;
|
||||
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
for (i = 0; i < count; i++) {
|
||||
data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
|
||||
points[i].y + y_off, widths[i], 1,
|
||||
PixmapBytePad(widths[i], drawable->depth),
|
||||
readpixels_dst, 0, GLAMOR_ACCESS_RO);
|
||||
assert(data == readpixels_dst);
|
||||
readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
for (i = 0; i < count; i++) {
|
||||
data = glamor_download_sub_pixmap_to_cpu(pixmap, points[i].x + x_off,
|
||||
points[i].y + y_off, widths[i],
|
||||
1, PixmapBytePad(widths[i],
|
||||
drawable->
|
||||
depth),
|
||||
readpixels_dst, 0,
|
||||
GLAMOR_ACCESS_RO);
|
||||
(void)data;
|
||||
assert(data == readpixels_dst);
|
||||
readpixels_dst += PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
fail:
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
fail:
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
|
||||
ret = TRUE;
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
|
||||
fbGetSpans(drawable, wmax, points, widths, count, dst);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
done:
|
||||
return ret;
|
||||
ret = TRUE;
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RO)) {
|
||||
fbGetSpans(drawable, wmax, points, widths, count, dst);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_get_spans(DrawablePtr drawable,
|
||||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst)
|
||||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst)
|
||||
{
|
||||
_glamor_get_spans(drawable, wmax, points,
|
||||
widths, count, dst, TRUE);
|
||||
_glamor_get_spans(drawable, wmax, points, widths, count, dst, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_get_spans_nf(DrawablePtr drawable,
|
||||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst)
|
||||
int wmax,
|
||||
DDXPointPtr points, int *widths, int count, char *dst)
|
||||
{
|
||||
return _glamor_get_spans(drawable, wmax, points,
|
||||
widths, count, dst, FALSE);
|
||||
return _glamor_get_spans(drawable, wmax, points, widths, count, dst, FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -41,78 +41,78 @@
|
|||
|
||||
_X_EXPORT Bool
|
||||
glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version,
|
||||
void *(*get_proc_address) (const char *))
|
||||
int gl_version,
|
||||
void *(*get_proc_address) (const char *))
|
||||
{
|
||||
#ifndef GLAMOR_GLES2
|
||||
INIT_FUNC(dispatch, glMatrixMode, get_proc_address);
|
||||
INIT_FUNC(dispatch, glLoadIdentity, get_proc_address);
|
||||
INIT_FUNC(dispatch, glRasterPos2i, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDrawPixels, get_proc_address);
|
||||
INIT_FUNC(dispatch, glLogicOp, get_proc_address);
|
||||
INIT_FUNC(dispatch, glMapBuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glMapBufferRange, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUnmapBuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBlitFramebuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDrawRangeElements, get_proc_address);
|
||||
INIT_FUNC(dispatch, glMatrixMode, get_proc_address);
|
||||
INIT_FUNC(dispatch, glLoadIdentity, get_proc_address);
|
||||
INIT_FUNC(dispatch, glRasterPos2i, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDrawPixels, get_proc_address);
|
||||
INIT_FUNC(dispatch, glLogicOp, get_proc_address);
|
||||
INIT_FUNC(dispatch, glMapBuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glMapBufferRange, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUnmapBuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBlitFramebuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDrawRangeElements, get_proc_address);
|
||||
#endif
|
||||
INIT_FUNC(dispatch, glViewport, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDrawArrays, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDrawElements, get_proc_address);
|
||||
INIT_FUNC(dispatch, glReadPixels, get_proc_address);
|
||||
INIT_FUNC(dispatch, glPixelStorei, get_proc_address);
|
||||
INIT_FUNC(dispatch, glTexParameteri, get_proc_address);
|
||||
INIT_FUNC(dispatch, glTexImage2D, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGenTextures, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteTextures, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBindTexture, get_proc_address);
|
||||
INIT_FUNC(dispatch, glTexSubImage2D, get_proc_address);
|
||||
INIT_FUNC(dispatch, glFlush, get_proc_address);
|
||||
INIT_FUNC(dispatch, glFinish, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetIntegerv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetString, get_proc_address);
|
||||
INIT_FUNC(dispatch, glScissor, get_proc_address);
|
||||
INIT_FUNC(dispatch, glEnable, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDisable, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBlendFunc, get_proc_address);
|
||||
INIT_FUNC(dispatch, glActiveTexture, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGenBuffers, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBufferData, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBindBuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteBuffers, get_proc_address);
|
||||
INIT_FUNC(dispatch, glFramebufferTexture2D, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBindFramebuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteFramebuffers, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGenFramebuffers, get_proc_address);
|
||||
INIT_FUNC(dispatch, glCheckFramebufferStatus, get_proc_address);
|
||||
INIT_FUNC(dispatch, glVertexAttribPointer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDisableVertexAttribArray, get_proc_address);
|
||||
INIT_FUNC(dispatch, glEnableVertexAttribArray, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBindAttribLocation, get_proc_address);
|
||||
INIT_FUNC(dispatch, glLinkProgram, get_proc_address);
|
||||
INIT_FUNC(dispatch, glShaderSource, get_proc_address);
|
||||
INIT_FUNC(dispatch, glViewport, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDrawArrays, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDrawElements, get_proc_address);
|
||||
INIT_FUNC(dispatch, glReadPixels, get_proc_address);
|
||||
INIT_FUNC(dispatch, glPixelStorei, get_proc_address);
|
||||
INIT_FUNC(dispatch, glTexParameteri, get_proc_address);
|
||||
INIT_FUNC(dispatch, glTexImage2D, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGenTextures, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteTextures, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBindTexture, get_proc_address);
|
||||
INIT_FUNC(dispatch, glTexSubImage2D, get_proc_address);
|
||||
INIT_FUNC(dispatch, glFlush, get_proc_address);
|
||||
INIT_FUNC(dispatch, glFinish, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetIntegerv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetString, get_proc_address);
|
||||
INIT_FUNC(dispatch, glScissor, get_proc_address);
|
||||
INIT_FUNC(dispatch, glEnable, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDisable, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBlendFunc, get_proc_address);
|
||||
INIT_FUNC(dispatch, glActiveTexture, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGenBuffers, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBufferData, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBindBuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteBuffers, get_proc_address);
|
||||
INIT_FUNC(dispatch, glFramebufferTexture2D, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBindFramebuffer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteFramebuffers, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGenFramebuffers, get_proc_address);
|
||||
INIT_FUNC(dispatch, glCheckFramebufferStatus, get_proc_address);
|
||||
INIT_FUNC(dispatch, glVertexAttribPointer, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDisableVertexAttribArray, get_proc_address);
|
||||
INIT_FUNC(dispatch, glEnableVertexAttribArray, get_proc_address);
|
||||
INIT_FUNC(dispatch, glBindAttribLocation, get_proc_address);
|
||||
INIT_FUNC(dispatch, glLinkProgram, get_proc_address);
|
||||
INIT_FUNC(dispatch, glShaderSource, get_proc_address);
|
||||
|
||||
INIT_FUNC(dispatch, glUseProgram, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform1i, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform1f, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform4f, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform4fv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform1fv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform2fv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniformMatrix3fv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glCreateProgram, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteProgram, get_proc_address);
|
||||
INIT_FUNC(dispatch, glCreateShader, get_proc_address);
|
||||
INIT_FUNC(dispatch, glCompileShader, get_proc_address);
|
||||
INIT_FUNC(dispatch, glAttachShader, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteShader, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetShaderiv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetShaderInfoLog, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetProgramiv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetProgramInfoLog, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetUniformLocation, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUseProgram, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform1i, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform1f, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform4f, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform4fv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform1fv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniform2fv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glUniformMatrix3fv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glCreateProgram, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteProgram, get_proc_address);
|
||||
INIT_FUNC(dispatch, glCreateShader, get_proc_address);
|
||||
INIT_FUNC(dispatch, glCompileShader, get_proc_address);
|
||||
INIT_FUNC(dispatch, glAttachShader, get_proc_address);
|
||||
INIT_FUNC(dispatch, glDeleteShader, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetShaderiv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetShaderInfoLog, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetProgramiv, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetProgramInfoLog, get_proc_address);
|
||||
INIT_FUNC(dispatch, glGetUniformLocation, get_proc_address);
|
||||
|
||||
return TRUE;
|
||||
fail:
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
fail:
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -1,138 +1,128 @@
|
|||
typedef struct glamor_gl_dispatch {
|
||||
/* Transformation functions */
|
||||
void (*glMatrixMode) (GLenum mode);
|
||||
void (*glLoadIdentity) (void);
|
||||
void (*glViewport) (GLint x, GLint y, GLsizei width,
|
||||
GLsizei height);
|
||||
/* Drawing functions */
|
||||
void (*glRasterPos2i) (GLint x, GLint y);
|
||||
/* Transformation functions */
|
||||
void (*glMatrixMode) (GLenum mode);
|
||||
void (*glLoadIdentity) (void);
|
||||
void (*glViewport) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
/* Drawing functions */
|
||||
void (*glRasterPos2i) (GLint x, GLint y);
|
||||
|
||||
/* Vertex Array */
|
||||
void (*glDrawArrays) (GLenum mode, GLint first, GLsizei count);
|
||||
/* Vertex Array */
|
||||
void (*glDrawArrays) (GLenum mode, GLint first, GLsizei count);
|
||||
|
||||
/* Elements Array*/
|
||||
void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type, const GLvoid * indices);
|
||||
void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid * indices);
|
||||
/* Elements Array */
|
||||
void (*glDrawElements) (GLenum mode, GLsizei count, GLenum type,
|
||||
const GLvoid * indices);
|
||||
void (*glDrawRangeElements) (GLenum mode, GLuint start, GLuint end,
|
||||
GLsizei count, GLenum type,
|
||||
const GLvoid * indices);
|
||||
|
||||
/* Raster functions */
|
||||
void (*glReadPixels) (GLint x, GLint y,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, GLvoid * pixels);
|
||||
/* Raster functions */
|
||||
void (*glReadPixels) (GLint x, GLint y,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, GLvoid * pixels);
|
||||
|
||||
void (*glDrawPixels) (GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid * pixels);
|
||||
void (*glPixelStorei) (GLenum pname, GLint param);
|
||||
/* Texture Mapping */
|
||||
void (*glDrawPixels) (GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, const GLvoid * pixels);
|
||||
void (*glPixelStorei) (GLenum pname, GLint param);
|
||||
/* Texture Mapping */
|
||||
|
||||
void (*glTexParameteri) (GLenum target, GLenum pname, GLint param);
|
||||
void (*glTexImage2D) (GLenum target, GLint level,
|
||||
GLint internalFormat,
|
||||
GLsizei width, GLsizei height,
|
||||
GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels);
|
||||
/* 1.1 */
|
||||
void (*glGenTextures) (GLsizei n, GLuint * textures);
|
||||
void (*glDeleteTextures) (GLsizei n, const GLuint * textures);
|
||||
void (*glBindTexture) (GLenum target, GLuint texture);
|
||||
void (*glTexSubImage2D) (GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type,
|
||||
const GLvoid * pixels);
|
||||
/* MISC */
|
||||
void (*glFlush) (void);
|
||||
void (*glFinish) (void);
|
||||
void (*glGetIntegerv) (GLenum pname, GLint * params);
|
||||
const GLubyte *(*glGetString) (GLenum name);
|
||||
void (*glScissor) (GLint x, GLint y, GLsizei width,
|
||||
GLsizei height);
|
||||
void (*glEnable) (GLenum cap);
|
||||
void (*glDisable) (GLenum cap);
|
||||
void (*glBlendFunc) (GLenum sfactor, GLenum dfactor);
|
||||
void (*glLogicOp) (GLenum opcode);
|
||||
void (*glTexParameteri) (GLenum target, GLenum pname, GLint param);
|
||||
void (*glTexImage2D) (GLenum target, GLint level,
|
||||
GLint internalFormat,
|
||||
GLsizei width, GLsizei height,
|
||||
GLint border, GLenum format, GLenum type,
|
||||
const GLvoid * pixels);
|
||||
/* 1.1 */
|
||||
void (*glGenTextures) (GLsizei n, GLuint * textures);
|
||||
void (*glDeleteTextures) (GLsizei n, const GLuint * textures);
|
||||
void (*glBindTexture) (GLenum target, GLuint texture);
|
||||
void (*glTexSubImage2D) (GLenum target, GLint level,
|
||||
GLint xoffset, GLint yoffset,
|
||||
GLsizei width, GLsizei height,
|
||||
GLenum format, GLenum type, const GLvoid * pixels);
|
||||
/* MISC */
|
||||
void (*glFlush) (void);
|
||||
void (*glFinish) (void);
|
||||
void (*glGetIntegerv) (GLenum pname, GLint * params);
|
||||
const GLubyte *(*glGetString) (GLenum name);
|
||||
void (*glScissor) (GLint x, GLint y, GLsizei width, GLsizei height);
|
||||
void (*glEnable) (GLenum cap);
|
||||
void (*glDisable) (GLenum cap);
|
||||
void (*glBlendFunc) (GLenum sfactor, GLenum dfactor);
|
||||
void (*glLogicOp) (GLenum opcode);
|
||||
|
||||
/* 1.3 */
|
||||
void (*glActiveTexture) (GLenum texture);
|
||||
/* 1.3 */
|
||||
void (*glActiveTexture) (GLenum texture);
|
||||
|
||||
/* GL Extentions */
|
||||
void (*glGenBuffers) (GLsizei n, GLuint * buffers);
|
||||
void (*glBufferData) (GLenum target, GLsizeiptr size,
|
||||
const GLvoid * data, GLenum usage);
|
||||
GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
|
||||
GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
|
||||
GLboolean (*glUnmapBuffer) (GLenum target);
|
||||
void (*glBindBuffer) (GLenum target, GLuint buffer);
|
||||
void (*glDeleteBuffers) (GLsizei n, const GLuint * buffers);
|
||||
/* GL Extentions */
|
||||
void (*glGenBuffers) (GLsizei n, GLuint * buffers);
|
||||
void (*glBufferData) (GLenum target, GLsizeiptr size,
|
||||
const GLvoid * data, GLenum usage);
|
||||
GLvoid *(*glMapBuffer) (GLenum target, GLenum access);
|
||||
GLvoid *(*glMapBufferRange) (GLenum target, GLintptr offset,
|
||||
GLsizeiptr length, GLbitfield 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 (*glBindFramebuffer) (GLenum target, GLuint framebuffer);
|
||||
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 (*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 (*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 (*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 (*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 (*glLinkProgram) (GLuint program);
|
||||
void (*glShaderSource) (GLuint shader, GLsizei count,
|
||||
const GLchar * *string,
|
||||
const GLint * length);
|
||||
void (*glUseProgram) (GLuint program);
|
||||
void (*glUniform1i) (GLint location, GLint v0);
|
||||
void (*glUniform1f) (GLint location, GLfloat v0);
|
||||
void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
|
||||
GLfloat v2, GLfloat v3);
|
||||
void (*glUniform1fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
void (*glUniform2fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
void (*glUniform4fv) (GLint location, GLsizei count,
|
||||
const GLfloat * value);
|
||||
void (*glUniformMatrix3fv) (GLint location, GLsizei count,
|
||||
GLboolean transpose, const GLfloat* value);
|
||||
GLuint (*glCreateProgram) (void);
|
||||
GLuint (*glDeleteProgram) (GLuint);
|
||||
GLuint (*glCreateShader) (GLenum type);
|
||||
void (*glCompileShader) (GLuint shader);
|
||||
void (*glAttachShader) (GLuint program, GLuint shader);
|
||||
void (*glDeleteShader) (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 (*glLinkProgram) (GLuint program);
|
||||
void (*glShaderSource) (GLuint shader, GLsizei count,
|
||||
const GLchar * *string, const GLint * length);
|
||||
void (*glUseProgram) (GLuint program);
|
||||
void (*glUniform1i) (GLint location, GLint v0);
|
||||
void (*glUniform1f) (GLint location, GLfloat v0);
|
||||
void (*glUniform4f) (GLint location, GLfloat v0, GLfloat v1,
|
||||
GLfloat v2, GLfloat v3);
|
||||
void (*glUniform1fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||
void (*glUniform2fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||
void (*glUniform4fv) (GLint location, GLsizei count, const GLfloat * value);
|
||||
void (*glUniformMatrix3fv) (GLint location, GLsizei count,
|
||||
GLboolean transpose, const GLfloat * value);
|
||||
GLuint(*glCreateProgram) (void);
|
||||
GLuint(*glDeleteProgram) (GLuint);
|
||||
GLuint(*glCreateShader) (GLenum type);
|
||||
void (*glCompileShader) (GLuint shader);
|
||||
void (*glAttachShader) (GLuint program, GLuint shader);
|
||||
void (*glDeleteShader) (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);
|
||||
|
||||
} glamor_gl_dispatch;
|
||||
|
||||
|
||||
typedef void *(*get_proc_address_t) (const char *);
|
||||
|
||||
_X_EXPORT Bool
|
||||
glamor_gl_dispatch_init_impl(struct glamor_gl_dispatch *dispatch,
|
||||
int gl_version,
|
||||
get_proc_address_t get_proc_address);
|
||||
|
||||
glamor_gl_dispatch_init_impl(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);
|
||||
struct glamor_gl_dispatch *dispatch, int gl_version);
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
#ifdef GLAMOR_GLES2
|
||||
|
||||
#define GL_BGRA GL_BGRA_EXT
|
||||
|
|
|
@ -30,89 +30,90 @@
|
|||
|
||||
static Bool
|
||||
_glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
|
||||
miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||
return TRUE;
|
||||
miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase)
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr *ppci, void *pglyphBase)
|
||||
{
|
||||
_glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, TRUE);
|
||||
_glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_image_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase)
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr *ppci, void *pglyphBase)
|
||||
{
|
||||
return _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, FALSE);
|
||||
return _glamor_image_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci,
|
||||
pglyphBase, FALSE);
|
||||
}
|
||||
|
||||
static Bool
|
||||
_glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase, Bool fallback)
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr *ppci, void *pglyphBase, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
|
||||
miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||
return TRUE;
|
||||
miPolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase)
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr *ppci, void *pglyphBase)
|
||||
{
|
||||
_glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, TRUE);
|
||||
_glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,
|
||||
TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_poly_glyph_blt_nf(DrawablePtr pDrawable, GCPtr pGC,
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr * ppci, pointer pglyphBase)
|
||||
int x, int y, unsigned int nglyph,
|
||||
CharInfoPtr *ppci, void *pglyphBase)
|
||||
{
|
||||
return _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase, FALSE);
|
||||
return _glamor_poly_glyph_blt(pDrawable, pGC, x, y, nglyph, ppci,
|
||||
pglyphBase, FALSE);
|
||||
}
|
||||
|
||||
static Bool
|
||||
_glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y, Bool fallback)
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y,
|
||||
Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_pixmap(&pBitmap->drawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDrawable)
|
||||
&& glamor_ddx_fallback_check_pixmap(&pBitmap->drawable)
|
||||
&& glamor_ddx_fallback_check_gc(pGC))
|
||||
return FALSE;
|
||||
|
||||
miPushPixels(pGC, pBitmap, pDrawable, w, h, x, y);
|
||||
return TRUE;
|
||||
miPushPixels(pGC, pBitmap, pDrawable, w, h, x, y);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y)
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y)
|
||||
{
|
||||
_glamor_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y, TRUE);
|
||||
_glamor_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_push_pixels_nf(GCPtr pGC, PixmapPtr pBitmap,
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y)
|
||||
DrawablePtr pDrawable, int w, int h, int x, int y)
|
||||
{
|
||||
return _glamor_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y, FALSE);
|
||||
return _glamor_push_pixels(pGC, pBitmap, pDrawable, w, h, x, y, FALSE);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -37,30 +37,30 @@
|
|||
enum glamor_pixmap_status
|
||||
glamor_upload_picture_to_texture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
assert(picture->pDrawable);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
PixmapPtr pixmap;
|
||||
|
||||
return glamor_upload_pixmap_to_texture(pixmap);
|
||||
assert(picture->pDrawable);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
|
||||
return glamor_upload_pixmap_to_texture(pixmap);
|
||||
}
|
||||
|
||||
|
||||
Bool
|
||||
glamor_prepare_access_picture(PicturePtr picture, glamor_access_t access)
|
||||
{
|
||||
if (!picture || !picture->pDrawable)
|
||||
return TRUE;
|
||||
if (!picture || !picture->pDrawable)
|
||||
return TRUE;
|
||||
|
||||
return glamor_prepare_access(picture->pDrawable, access);
|
||||
return glamor_prepare_access(picture->pDrawable, access);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_finish_access_picture(PicturePtr picture, glamor_access_t access)
|
||||
{
|
||||
if (!picture || !picture->pDrawable)
|
||||
return;
|
||||
if (!picture || !picture->pDrawable)
|
||||
return;
|
||||
|
||||
glamor_finish_access(picture->pDrawable, access);
|
||||
glamor_finish_access(picture->pDrawable, access);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -71,61 +71,62 @@ glamor_finish_access_picture(PicturePtr picture, glamor_access_t access)
|
|||
int
|
||||
glamor_create_picture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
if (!picture || !picture->pDrawable)
|
||||
return 0;
|
||||
if (!picture || !picture->pDrawable)
|
||||
return 0;
|
||||
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (!pixmap_priv) {
|
||||
/* We must create a pixmap priv to track the picture format even
|
||||
* if the pixmap is a pure in memory pixmap. The reason is that
|
||||
* we may need to upload this pixmap to a texture on the fly. During
|
||||
* the uploading, we need to know the picture format. */
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
} else {
|
||||
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||
/* If the picture format is not compatible with glamor fbo format,
|
||||
* we have to mark this pixmap as a separated texture, and don't
|
||||
* fallback to DDX layer. */
|
||||
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM
|
||||
&& !glamor_pict_format_is_compatible(picture->format,
|
||||
pixmap->drawable.depth))
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
|
||||
}
|
||||
}
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
if (!pixmap_priv) {
|
||||
/* We must create a pixmap priv to track the picture format even
|
||||
* if the pixmap is a pure in memory pixmap. The reason is that
|
||||
* we may need to upload this pixmap to a texture on the fly. During
|
||||
* the uploading, we need to know the picture format. */
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
}
|
||||
else {
|
||||
if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||
/* If the picture format is not compatible with glamor fbo format,
|
||||
* we have to mark this pixmap as a separated texture, and don't
|
||||
* fallback to DDX layer. */
|
||||
if (pixmap_priv->type == GLAMOR_TEXTURE_DRM
|
||||
&& !glamor_pict_format_is_compatible(picture->format,
|
||||
pixmap->drawable.depth))
|
||||
glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
|
||||
}
|
||||
}
|
||||
|
||||
pixmap_priv->base.is_picture = 1;
|
||||
pixmap_priv->base.picture = picture;
|
||||
pixmap_priv->base.is_picture = 1;
|
||||
pixmap_priv->base.picture = picture;
|
||||
|
||||
return miCreatePicture(picture);
|
||||
return miCreatePicture(picture);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_destroy_picture(PicturePtr picture)
|
||||
{
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PixmapPtr pixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
if (!picture || !picture->pDrawable)
|
||||
return;
|
||||
if (!picture || !picture->pDrawable)
|
||||
return;
|
||||
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
pixmap = glamor_get_drawable_pixmap(picture->pDrawable);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
if (pixmap_priv) {
|
||||
pixmap_priv->base.is_picture = 0;
|
||||
pixmap_priv->base.picture = NULL;
|
||||
}
|
||||
miDestroyPicture(picture);
|
||||
if (pixmap_priv) {
|
||||
pixmap_priv->base.is_picture = 0;
|
||||
pixmap_priv->base.picture = NULL;
|
||||
}
|
||||
miDestroyPicture(picture);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_picture_format_fixup(PicturePtr picture,
|
||||
glamor_pixmap_private * pixmap_priv)
|
||||
glamor_pixmap_private *pixmap_priv)
|
||||
{
|
||||
pixmap_priv->base.picture = picture;
|
||||
pixmap_priv->base.picture = picture;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -35,93 +35,90 @@
|
|||
|
||||
static Bool
|
||||
_glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect, Bool fallback)
|
||||
GCPtr gc, int nrect, xRectangle *prect, Bool fallback)
|
||||
{
|
||||
int fullX1, fullX2, fullY1, fullY2;
|
||||
int xorg, yorg;
|
||||
int n;
|
||||
register BoxPtr pbox;
|
||||
RegionPtr pClip = fbGetCompositeClip(gc);
|
||||
Bool ret = FALSE;
|
||||
int fullX1, fullX2, fullY1, fullY2;
|
||||
int xorg, yorg;
|
||||
int n;
|
||||
register BoxPtr pbox;
|
||||
RegionPtr pClip = fbGetCompositeClip(gc);
|
||||
Bool ret = FALSE;
|
||||
|
||||
xorg = drawable->x;
|
||||
yorg = drawable->y;
|
||||
xorg = drawable->x;
|
||||
yorg = drawable->y;
|
||||
|
||||
while (nrect--) {
|
||||
fullX1 = prect->x + xorg;
|
||||
fullY1 = prect->y + yorg;
|
||||
fullX2 = fullX1 + (int) prect->width;
|
||||
fullY2 = fullY1 + (int) prect->height;
|
||||
while (nrect--) {
|
||||
fullX1 = prect->x + xorg;
|
||||
fullY1 = prect->y + yorg;
|
||||
fullX2 = fullX1 + (int) prect->width;
|
||||
fullY2 = fullY1 + (int) prect->height;
|
||||
|
||||
n = REGION_NUM_RECTS(pClip);
|
||||
pbox = REGION_RECTS(pClip);
|
||||
/*
|
||||
* clip the rectangle to each box in the clip region
|
||||
* this is logically equivalent to calling Intersect(),
|
||||
* but rectangles may overlap each other here.
|
||||
*/
|
||||
while (n--) {
|
||||
int x1 = fullX1;
|
||||
int x2 = fullX2;
|
||||
int y1 = fullY1;
|
||||
int y2 = fullY2;
|
||||
n = REGION_NUM_RECTS(pClip);
|
||||
pbox = REGION_RECTS(pClip);
|
||||
/*
|
||||
* clip the rectangle to each box in the clip region
|
||||
* this is logically equivalent to calling Intersect(),
|
||||
* but rectangles may overlap each other here.
|
||||
*/
|
||||
while (n--) {
|
||||
int x1 = fullX1;
|
||||
int x2 = fullX2;
|
||||
int y1 = fullY1;
|
||||
int y2 = fullY2;
|
||||
|
||||
if (pbox->x1 > x1)
|
||||
x1 = pbox->x1;
|
||||
if (pbox->x2 < x2)
|
||||
x2 = pbox->x2;
|
||||
if (pbox->y1 > y1)
|
||||
y1 = pbox->y1;
|
||||
if (pbox->y2 < y2)
|
||||
y2 = pbox->y2;
|
||||
if (pbox->x1 > x1)
|
||||
x1 = pbox->x1;
|
||||
if (pbox->x2 < x2)
|
||||
x2 = pbox->x2;
|
||||
if (pbox->y1 > y1)
|
||||
y1 = pbox->y1;
|
||||
if (pbox->y2 < y2)
|
||||
y2 = pbox->y2;
|
||||
|
||||
pbox++;
|
||||
if (x1 >= x2 || y1 >= y2)
|
||||
continue;
|
||||
if (!glamor_fill(drawable, gc, x1, y1, x2 - x1,
|
||||
y2 - y1, fallback)) {
|
||||
nrect++;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
prect++;
|
||||
}
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
pbox++;
|
||||
if (x1 >= x2 || y1 >= y2)
|
||||
continue;
|
||||
if (!glamor_fill(drawable, gc, x1, y1, x2 - x1, y2 - y1, fallback)) {
|
||||
nrect++;
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
prect++;
|
||||
}
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
fail:
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
goto done;
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
goto done;
|
||||
|
||||
glamor_fallback(" to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbPolyFillRect(drawable, gc, nrect, prect);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
ret = TRUE;
|
||||
glamor_fallback(" to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbPolyFillRect(drawable, gc, nrect, prect);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
return ret;
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
glamor_poly_fill_rect(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect)
|
||||
GCPtr gc, int nrect, xRectangle *prect)
|
||||
{
|
||||
_glamor_poly_fill_rect(drawable, gc, nrect, prect, TRUE);
|
||||
_glamor_poly_fill_rect(drawable, gc, nrect, prect, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_poly_fill_rect_nf(DrawablePtr drawable,
|
||||
GCPtr gc, int nrect, xRectangle * prect)
|
||||
GCPtr gc, int nrect, xRectangle *prect)
|
||||
{
|
||||
return _glamor_poly_fill_rect(drawable, gc, nrect, prect, FALSE);
|
||||
return _glamor_poly_fill_rect(drawable, gc, nrect, prect, FALSE);
|
||||
}
|
||||
|
|
|
@ -40,96 +40,97 @@
|
|||
*/
|
||||
static Bool
|
||||
_glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
DDXPointPtr points, Bool fallback)
|
||||
DDXPointPtr points, Bool fallback)
|
||||
{
|
||||
xRectangle *rects;
|
||||
int x1, x2, y1, y2;
|
||||
int i;
|
||||
xRectangle *rects;
|
||||
int x1, x2, y1, y2;
|
||||
int i;
|
||||
|
||||
/* Don't try to do wide lines or non-solid fill style. */
|
||||
if (gc->lineWidth != 0) {
|
||||
/* This ends up in miSetSpans, which is accelerated as well as we
|
||||
* can hope X wide lines will be.
|
||||
*/
|
||||
goto wide_line;
|
||||
}
|
||||
if (gc->lineStyle != LineSolid) {
|
||||
glamor_fallback
|
||||
("non-solid fill line style %d\n",
|
||||
gc->lineStyle);
|
||||
goto fail;
|
||||
}
|
||||
rects = malloc(sizeof(xRectangle) * (n - 1));
|
||||
x1 = points[0].x;
|
||||
y1 = points[0].y;
|
||||
/* If we have any non-horizontal/vertical, fall back. */
|
||||
for (i = 0; i < n - 1; i++) {
|
||||
if (mode == CoordModePrevious) {
|
||||
x2 = x1 + points[i + 1].x;
|
||||
y2 = y1 + points[i + 1].y;
|
||||
} else {
|
||||
x2 = points[i + 1].x;
|
||||
y2 = points[i + 1].y;
|
||||
}
|
||||
if (x1 != x2 && y1 != y2) {
|
||||
free(rects);
|
||||
glamor_fallback("stub diagonal poly_line\n");
|
||||
goto fail;
|
||||
}
|
||||
if (x1 < x2) {
|
||||
rects[i].x = x1;
|
||||
rects[i].width = x2 - x1 + 1;
|
||||
} else {
|
||||
rects[i].x = x2;
|
||||
rects[i].width = x1 - x2 + 1;
|
||||
}
|
||||
if (y1 < y2) {
|
||||
rects[i].y = y1;
|
||||
rects[i].height = y2 - y1 + 1;
|
||||
} else {
|
||||
rects[i].y = y2;
|
||||
rects[i].height = y1 - y2 + 1;
|
||||
}
|
||||
/* Don't try to do wide lines or non-solid fill style. */
|
||||
if (gc->lineWidth != 0) {
|
||||
/* This ends up in miSetSpans, which is accelerated as well as we
|
||||
* can hope X wide lines will be.
|
||||
*/
|
||||
goto wide_line;
|
||||
}
|
||||
if (gc->lineStyle != LineSolid) {
|
||||
glamor_fallback("non-solid fill line style %d\n", gc->lineStyle);
|
||||
goto fail;
|
||||
}
|
||||
rects = malloc(sizeof(xRectangle) * (n - 1));
|
||||
x1 = points[0].x;
|
||||
y1 = points[0].y;
|
||||
/* If we have any non-horizontal/vertical, fall back. */
|
||||
for (i = 0; i < n - 1; i++) {
|
||||
if (mode == CoordModePrevious) {
|
||||
x2 = x1 + points[i + 1].x;
|
||||
y2 = y1 + points[i + 1].y;
|
||||
}
|
||||
else {
|
||||
x2 = points[i + 1].x;
|
||||
y2 = points[i + 1].y;
|
||||
}
|
||||
if (x1 != x2 && y1 != y2) {
|
||||
free(rects);
|
||||
glamor_fallback("stub diagonal poly_line\n");
|
||||
goto fail;
|
||||
}
|
||||
if (x1 < x2) {
|
||||
rects[i].x = x1;
|
||||
rects[i].width = x2 - x1 + 1;
|
||||
}
|
||||
else {
|
||||
rects[i].x = x2;
|
||||
rects[i].width = x1 - x2 + 1;
|
||||
}
|
||||
if (y1 < y2) {
|
||||
rects[i].y = y1;
|
||||
rects[i].height = y2 - y1 + 1;
|
||||
}
|
||||
else {
|
||||
rects[i].y = y2;
|
||||
rects[i].height = y1 - y2 + 1;
|
||||
}
|
||||
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
gc->ops->PolyFillRect(drawable, gc, n - 1, rects);
|
||||
free(rects);
|
||||
return TRUE;
|
||||
x1 = x2;
|
||||
y1 = y2;
|
||||
}
|
||||
gc->ops->PolyFillRect(drawable, gc, n - 1, rects);
|
||||
free(rects);
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
return FALSE;
|
||||
fail:
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable)
|
||||
&& glamor_ddx_fallback_check_gc(gc))
|
||||
return FALSE;
|
||||
|
||||
if (gc->lineWidth == 0) {
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbPolyLine(drawable, gc, mode, n, points);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
} else {
|
||||
wide_line:
|
||||
/* fb calls mi functions in the lineWidth != 0 case. */
|
||||
fbPolyLine(drawable, gc, mode, n, points);
|
||||
}
|
||||
return TRUE;
|
||||
if (gc->lineWidth == 0) {
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_gc(gc)) {
|
||||
fbPolyLine(drawable, gc, mode, n, points);
|
||||
glamor_finish_access_gc(gc);
|
||||
}
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
}
|
||||
else {
|
||||
wide_line:
|
||||
/* fb calls mi functions in the lineWidth != 0 case. */
|
||||
fbPolyLine(drawable, gc, mode, n, points);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_poly_lines(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
DDXPointPtr points)
|
||||
DDXPointPtr points)
|
||||
{
|
||||
_glamor_poly_lines(drawable, gc, mode, n, points, TRUE);
|
||||
_glamor_poly_lines(drawable, gc, mode, n, points, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_poly_lines_nf(DrawablePtr drawable, GCPtr gc, int mode, int n,
|
||||
DDXPointPtr points)
|
||||
DDXPointPtr points)
|
||||
{
|
||||
return _glamor_poly_lines(drawable, gc, mode, n, points, FALSE);
|
||||
return _glamor_poly_lines(drawable, gc, mode, n, points, FALSE);
|
||||
}
|
||||
|
|
|
@ -30,56 +30,53 @@
|
|||
|
||||
static Bool
|
||||
_glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt, Bool fallback)
|
||||
DDXPointPtr ppt, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||
return FALSE;
|
||||
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||
return FALSE;
|
||||
|
||||
miPolyPoint(pDrawable, pGC, mode, npt, ppt);
|
||||
miPolyPoint(pDrawable, pGC, mode, npt, ppt);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt)
|
||||
DDXPointPtr ppt)
|
||||
{
|
||||
_glamor_poly_point(pDrawable, pGC, mode, npt, ppt, TRUE);
|
||||
_glamor_poly_point(pDrawable, pGC, mode, npt, ppt, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_poly_point_nf(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
|
||||
DDXPointPtr ppt)
|
||||
DDXPointPtr ppt)
|
||||
{
|
||||
return _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, FALSE);
|
||||
return _glamor_poly_point(pDrawable, pGC, mode, npt, ppt, FALSE);
|
||||
}
|
||||
|
||||
static Bool
|
||||
_glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg, Bool fallback)
|
||||
xSegment *pSeg, Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||
return FALSE;
|
||||
if (!fallback && glamor_ddx_fallback_check_gc(pGC)
|
||||
&& glamor_ddx_fallback_check_pixmap(pDrawable))
|
||||
return FALSE;
|
||||
|
||||
miPolySegment(pDrawable, pGC, nseg, pSeg);
|
||||
miPolySegment(pDrawable, pGC, nseg, pSeg);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg)
|
||||
glamor_poly_segment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg)
|
||||
{
|
||||
_glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE);
|
||||
_glamor_poly_segment(pDrawable, pGC, nseg, pSeg, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_poly_segment_nf(DrawablePtr pDrawable, GCPtr pGC, int nseg,
|
||||
xSegment *pSeg)
|
||||
xSegment *pSeg)
|
||||
{
|
||||
return _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, FALSE);
|
||||
return _glamor_poly_segment(pDrawable, pGC, nseg, pSeg, FALSE);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -26,7 +26,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
/** @file glamor_putaimge.c
|
||||
*
|
||||
* XPutImage implementation
|
||||
|
@ -37,54 +36,61 @@ void
|
|||
glamor_init_putimage_shaders(ScreenPtr screen)
|
||||
{
|
||||
#if 0
|
||||
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"
|
||||
" 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";
|
||||
const char *xybitmap_fs =
|
||||
"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";
|
||||
GLint fs_prog, vs_prog, prog;
|
||||
GLint sampler_uniform_location;
|
||||
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"
|
||||
" 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";
|
||||
const char *xybitmap_fs =
|
||||
"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";
|
||||
GLint fs_prog, vs_prog, prog;
|
||||
GLint sampler_uniform_location;
|
||||
|
||||
if (!GLEW_ARB_fragment_shader)
|
||||
return;
|
||||
if (!GLEW_ARB_fragment_shader)
|
||||
return;
|
||||
|
||||
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);
|
||||
dispatch->glAttachShader(prog, vs_prog);
|
||||
dispatch->glAttachShader(prog, fs_prog);
|
||||
glamor_link_glsl_prog(prog);
|
||||
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);
|
||||
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");
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
dispatch->glUseProgram(prog);
|
||||
sampler_uniform_location =
|
||||
dispatch->glGetUniformLocation(prog, "bitmap_sampler");
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
|
||||
glamor_priv->put_image_xybitmap_fg_uniform_location =
|
||||
dispatch->glGetUniformLocation(prog, "fg");
|
||||
glamor_priv->put_image_xybitmap_bg_uniform_location =
|
||||
dispatch->glGetUniformLocation(prog, "bg");
|
||||
glamor_get_transform_uniform_locations(prog,
|
||||
&glamor_priv->put_image_xybitmap_transform);
|
||||
glamor_priv->put_image_xybitmap_prog = prog;
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_priv->put_image_xybitmap_fg_uniform_location =
|
||||
dispatch->glGetUniformLocation(prog, "fg");
|
||||
glamor_priv->put_image_xybitmap_bg_uniform_location =
|
||||
dispatch->glGetUniformLocation(prog, "bg");
|
||||
glamor_get_transform_uniform_locations(prog,
|
||||
&glamor_priv->
|
||||
put_image_xybitmap_transform);
|
||||
glamor_priv->put_image_xybitmap_prog = prog;
|
||||
dispatch->glUseProgram(0);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Do an XYBitmap putimage. The bits are byte-aligned rows of bitmap
|
||||
* data (where each row starts at a bit index of left_pad), and the
|
||||
* destination gets filled with the gc's fg color where the bitmap is set
|
||||
|
@ -101,141 +107,136 @@ glamor_init_putimage_shaders(ScreenPtr screen)
|
|||
static int
|
||||
y_flip(PixmapPtr pixmap, int y)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
PixmapPtr screen_pixmap = screen->GetScreenPixmap(screen);
|
||||
|
||||
if (pixmap == screen_pixmap)
|
||||
return (pixmap->drawable.height - 1) - y;
|
||||
else
|
||||
return y;
|
||||
if (pixmap == screen_pixmap)
|
||||
return (pixmap->drawable.height - 1) - y;
|
||||
else
|
||||
return y;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
glamor_put_image_xybitmap(DrawablePtr drawable, GCPtr gc,
|
||||
int x, int y, int w, int h, int left_pad,
|
||||
int image_format, char *bits)
|
||||
int x, int y, int w, int h, int left_pad,
|
||||
int image_format, char *bits)
|
||||
{
|
||||
ScreenPtr screen = drawable->pScreen;
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
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);
|
||||
RegionPtr clip;
|
||||
BoxPtr box;
|
||||
int nbox;
|
||||
float dest_coords[8];
|
||||
const float bitmap_coords[8] = {
|
||||
0.0, 0.0,
|
||||
1.0, 0.0,
|
||||
1.0, 1.0,
|
||||
0.0, 1.0,
|
||||
};
|
||||
GLfloat xscale, yscale;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
ScreenPtr screen = drawable->pScreen;
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
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);
|
||||
RegionPtr clip;
|
||||
BoxPtr box;
|
||||
int nbox;
|
||||
float dest_coords[8];
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
const float bitmap_coords[8] = {
|
||||
0.0, 0.0,
|
||||
1.0, 0.0,
|
||||
1.0, 1.0,
|
||||
0.0, 1.0,
|
||||
};
|
||||
GLfloat xscale, yscale;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
|
||||
pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
glamor_set_normalize_vcoords(xscale, yscale,
|
||||
x, y,
|
||||
x + w, y + h,
|
||||
glamor_priv->yInverted, dest_coords);
|
||||
pixmap_priv_get_scale(pixmap_priv, &xscale, &yscale);
|
||||
|
||||
glamor_fallback("glamor_put_image_xybitmap: disabled\n");
|
||||
goto fail;
|
||||
glamor_set_normalize_vcoords(xscale, yscale,
|
||||
x, y,
|
||||
x + w, y + h,
|
||||
glamor_priv->yInverted, dest_coords);
|
||||
|
||||
if (glamor_priv->put_image_xybitmap_prog == 0) {
|
||||
ErrorF("no program for xybitmap putimage\n");
|
||||
goto fail;
|
||||
}
|
||||
glamor_fallback("glamor_put_image_xybitmap: disabled\n");
|
||||
goto fail;
|
||||
|
||||
glamor_set_alu(gc->alu);
|
||||
if (!glamor_set_planemask(pixmap, gc->planemask))
|
||||
goto fail;
|
||||
if (glamor_priv->put_image_xybitmap_prog == 0) {
|
||||
ErrorF("no program for xybitmap putimage\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dispatch->glUseProgram(glamor_priv->put_image_xybitmap_prog);
|
||||
glamor_set_alu(gc->alu);
|
||||
if (!glamor_set_planemask(pixmap, gc->planemask))
|
||||
goto fail;
|
||||
|
||||
glamor_get_color_4f_from_pixel(pixmap, gc->fgPixel, 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->glUseProgram(glamor_priv->put_image_xybitmap_prog);
|
||||
|
||||
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->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);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
glamor_get_color_4f_from_pixel(pixmap, gc->fgPixel, 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);
|
||||
|
||||
/* Now that we've set up our bitmap texture and the shader, shove
|
||||
* the destination rectangle through the cliprects and run the
|
||||
* shader on the resulting fragments.
|
||||
*/
|
||||
dispatch->glVertexPointer(2, GL_FLOAT, 0, dest_coords);
|
||||
dispatch->glEnableClientState(GL_VERTEX_ARRAY);
|
||||
dispatch->glClientActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glTexCoordPointer(2, GL_FLOAT, 0, bitmap_coords);
|
||||
dispatch->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
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->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);
|
||||
dispatch->glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
dispatch->glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
|
||||
|
||||
dispatch->glEnable(GL_SCISSOR_TEST);
|
||||
clip = fbGetCompositeClip(gc);
|
||||
for (nbox = REGION_NUM_RECTS(clip),
|
||||
box = REGION_RECTS(clip); nbox--; box++) {
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int x2 = x + w;
|
||||
int y2 = y + h;
|
||||
/* Now that we've set up our bitmap texture and the shader, shove
|
||||
* the destination rectangle through the cliprects and run the
|
||||
* shader on the resulting fragments.
|
||||
*/
|
||||
dispatch->glVertexPointer(2, GL_FLOAT, 0, dest_coords);
|
||||
dispatch->glEnableClientState(GL_VERTEX_ARRAY);
|
||||
dispatch->glClientActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glTexCoordPointer(2, GL_FLOAT, 0, bitmap_coords);
|
||||
dispatch->glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
if (x1 < box->x1)
|
||||
x1 = box->x1;
|
||||
if (y1 < box->y1)
|
||||
y1 = box->y1;
|
||||
if (x2 > box->x2)
|
||||
x2 = box->x2;
|
||||
if (y2 > box->y2)
|
||||
y2 = box->y2;
|
||||
if (x1 >= x2 || y1 >= y2)
|
||||
continue;
|
||||
dispatch->glEnable(GL_SCISSOR_TEST);
|
||||
clip = fbGetCompositeClip(gc);
|
||||
for (nbox = REGION_NUM_RECTS(clip), box = REGION_RECTS(clip); nbox--; box++) {
|
||||
int x1 = x;
|
||||
int y1 = y;
|
||||
int x2 = x + w;
|
||||
int y2 = y + h;
|
||||
|
||||
dispatch->glScissor(box->x1,
|
||||
y_flip(pixmap, box->y1),
|
||||
box->x2 - box->x1, box->y2 - box->y1);
|
||||
dispatch->glDrawArrays(GL_QUADS, 0, 4);
|
||||
}
|
||||
if (x1 < box->x1)
|
||||
x1 = box->x1;
|
||||
if (y1 < box->y1)
|
||||
y1 = box->y1;
|
||||
if (x2 > box->x2)
|
||||
x2 = box->x2;
|
||||
if (y2 > box->y2)
|
||||
y2 = box->y2;
|
||||
if (x1 >= x2 || y1 >= y2)
|
||||
continue;
|
||||
|
||||
dispatch->glDisable(GL_SCISSOR_TEST);
|
||||
glamor_set_alu(GXcopy);
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
dispatch->glDeleteTextures(1, &tex);
|
||||
dispatch->glDisable(GL_TEXTURE_2D);
|
||||
dispatch->glDisableClientState(GL_VERTEX_ARRAY);
|
||||
dispatch->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
return;
|
||||
glamor_set_alu(GXcopy);
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
glamor_fallback(": to %p (%c)\n",
|
||||
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);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
dispatch->glScissor(box->x1,
|
||||
y_flip(pixmap, box->y1),
|
||||
box->x2 - box->x1, box->y2 - box->y1);
|
||||
dispatch->glDrawArrays(GL_QUADS, 0, 4);
|
||||
}
|
||||
|
||||
dispatch->glDisable(GL_SCISSOR_TEST);
|
||||
glamor_set_alu(GXcopy);
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
dispatch->glDeleteTextures(1, &tex);
|
||||
dispatch->glDisable(GL_TEXTURE_2D);
|
||||
dispatch->glDisableClientState(GL_VERTEX_ARRAY);
|
||||
dispatch->glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
return;
|
||||
glamor_set_alu(GXcopy);
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
glamor_fallback(": to %p (%c)\n",
|
||||
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);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -244,120 +245,120 @@ glamor_fini_putimage_shaders(ScreenPtr screen)
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
static Bool
|
||||
static Bool
|
||||
_glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int left_pad, int image_format, char *bits, Bool fallback)
|
||||
int w, int h, int left_pad, int image_format, char *bits,
|
||||
Bool fallback)
|
||||
{
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv =
|
||||
glamor_get_pixmap_private(pixmap);
|
||||
RegionPtr clip;
|
||||
int x_off, y_off;
|
||||
Bool ret = FALSE;
|
||||
PixmapPtr temp_pixmap, sub_pixmap;
|
||||
glamor_pixmap_private *temp_pixmap_priv;
|
||||
BoxRec box;
|
||||
PixmapPtr pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
RegionPtr clip;
|
||||
int x_off, y_off;
|
||||
Bool ret = FALSE;
|
||||
PixmapPtr temp_pixmap, sub_pixmap;
|
||||
glamor_pixmap_private *temp_pixmap_priv;
|
||||
BoxRec box;
|
||||
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
clip = fbGetCompositeClip(gc);
|
||||
if (image_format == XYBitmap) {
|
||||
assert(depth == 1);
|
||||
goto fail;
|
||||
}
|
||||
glamor_get_drawable_deltas(drawable, pixmap, &x_off, &y_off);
|
||||
clip = fbGetCompositeClip(gc);
|
||||
if (image_format == XYBitmap) {
|
||||
assert(depth == 1);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||
glamor_fallback("has no fbo.\n");
|
||||
goto fail;
|
||||
}
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
|
||||
glamor_fallback("has no fbo.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (image_format != ZPixmap) {
|
||||
glamor_fallback("non-ZPixmap\n");
|
||||
goto fail;
|
||||
}
|
||||
if (image_format != ZPixmap) {
|
||||
glamor_fallback("non-ZPixmap\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!glamor_set_planemask(pixmap, gc->planemask)) {
|
||||
goto fail;
|
||||
}
|
||||
/* create a temporary pixmap and upload the bits to that
|
||||
* pixmap, then apply clip copy it to the destination pixmap.*/
|
||||
box.x1 = x + drawable->x;
|
||||
box.y1 = y + drawable->y;
|
||||
box.x2 = x + w + drawable->x;
|
||||
box.y2 = y + h + drawable->y;
|
||||
if (!glamor_set_planemask(pixmap, gc->planemask)) {
|
||||
goto fail;
|
||||
}
|
||||
/* create a temporary pixmap and upload the bits to that
|
||||
* pixmap, then apply clip copy it to the destination pixmap.*/
|
||||
box.x1 = x + drawable->x;
|
||||
box.y1 = y + drawable->y;
|
||||
box.x2 = x + w + drawable->x;
|
||||
box.y2 = y + h + drawable->y;
|
||||
|
||||
if ((clip != NULL && RegionContainsRect(clip, &box) != rgnIN)
|
||||
|| gc->alu != GXcopy) {
|
||||
temp_pixmap = glamor_create_pixmap(drawable->pScreen, w, h, depth, 0);
|
||||
if (temp_pixmap == NULL)
|
||||
goto fail;
|
||||
if ((clip != NULL && RegionContainsRect(clip, &box) != rgnIN)
|
||||
|| gc->alu != GXcopy) {
|
||||
temp_pixmap = glamor_create_pixmap(drawable->pScreen, w, h, depth, 0);
|
||||
if (temp_pixmap == NULL)
|
||||
goto fail;
|
||||
|
||||
temp_pixmap_priv = glamor_get_pixmap_private(temp_pixmap);
|
||||
temp_pixmap_priv = glamor_get_pixmap_private(temp_pixmap);
|
||||
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv)) {
|
||||
temp_pixmap_priv->base.picture = pixmap_priv->base.picture;
|
||||
temp_pixmap_priv->base.is_picture = pixmap_priv->base.is_picture;
|
||||
}
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv)) {
|
||||
temp_pixmap_priv->base.picture = pixmap_priv->base.picture;
|
||||
temp_pixmap_priv->base.is_picture = pixmap_priv->base.is_picture;
|
||||
}
|
||||
|
||||
glamor_upload_sub_pixmap_to_texture(temp_pixmap, 0, 0, w, h,
|
||||
pixmap->devKind, bits, 0);
|
||||
glamor_upload_sub_pixmap_to_texture(temp_pixmap, 0, 0, w, h,
|
||||
pixmap->devKind, bits, 0);
|
||||
|
||||
glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x, y);
|
||||
glamor_destroy_pixmap(temp_pixmap);
|
||||
} else
|
||||
glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off, y + drawable->y + y_off,
|
||||
w, h, PixmapBytePad(w, depth), bits, 0);
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
glamor_copy_area(&temp_pixmap->drawable, drawable, gc, 0, 0, w, h, x,
|
||||
y);
|
||||
glamor_destroy_pixmap(temp_pixmap);
|
||||
}
|
||||
else
|
||||
glamor_upload_sub_pixmap_to_texture(pixmap, x + drawable->x + x_off,
|
||||
y + drawable->y + y_off, w, h,
|
||||
PixmapBytePad(w, depth), bits, 0);
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
fail:
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
fail:
|
||||
glamor_set_planemask(pixmap, ~0);
|
||||
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
|
||||
goto done;
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(&pixmap->drawable))
|
||||
goto done;
|
||||
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
|
||||
sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
|
||||
y + y_off + drawable->y, w, h,
|
||||
GLAMOR_ACCESS_RW);
|
||||
if (sub_pixmap) {
|
||||
if (clip != NULL)
|
||||
pixman_region_translate (clip, -x - drawable->x, -y - drawable->y);
|
||||
sub_pixmap = glamor_get_sub_pixmap(pixmap, x + x_off + drawable->x,
|
||||
y + y_off + drawable->y, w, h,
|
||||
GLAMOR_ACCESS_RW);
|
||||
if (sub_pixmap) {
|
||||
if (clip != NULL)
|
||||
pixman_region_translate(clip, -x - drawable->x, -y - drawable->y);
|
||||
|
||||
fbPutImage(&sub_pixmap->drawable, gc, depth, 0, 0, w, h,
|
||||
left_pad, image_format, bits);
|
||||
fbPutImage(&sub_pixmap->drawable, gc, depth, 0, 0, w, h,
|
||||
left_pad, image_format, bits);
|
||||
|
||||
glamor_put_sub_pixmap(sub_pixmap, pixmap,
|
||||
x + x_off + drawable->x,
|
||||
y + y_off + drawable->y,
|
||||
w, h, GLAMOR_ACCESS_RW);
|
||||
if (clip != NULL)
|
||||
pixman_region_translate (clip, x + drawable->x, y + drawable->y);
|
||||
} else
|
||||
fbPutImage(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits);
|
||||
ret = TRUE;
|
||||
glamor_put_sub_pixmap(sub_pixmap, pixmap,
|
||||
x + x_off + drawable->x,
|
||||
y + y_off + drawable->y, w, h, GLAMOR_ACCESS_RW);
|
||||
if (clip != NULL)
|
||||
pixman_region_translate(clip, x + drawable->x, y + drawable->y);
|
||||
}
|
||||
else
|
||||
fbPutImage(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits);
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
return ret;
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_put_image(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int left_pad, int image_format, char *bits)
|
||||
int w, int h, int left_pad, int image_format, char *bits)
|
||||
{
|
||||
_glamor_put_image(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits, TRUE);
|
||||
_glamor_put_image(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_put_image_nf(DrawablePtr drawable, GCPtr gc, int depth, int x, int y,
|
||||
int w, int h, int left_pad, int image_format, char *bits)
|
||||
int w, int h, int left_pad, int image_format, char *bits)
|
||||
{
|
||||
return _glamor_put_image(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits, FALSE);
|
||||
return _glamor_put_image(drawable, gc, depth, x, y, w, h,
|
||||
left_pad, image_format, bits, FALSE);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,82 +30,83 @@
|
|||
|
||||
static Bool
|
||||
_glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int numPoints, int sorted,
|
||||
Bool fallback)
|
||||
DDXPointPtr points, int *widths, int numPoints, int sorted,
|
||||
Bool fallback)
|
||||
{
|
||||
PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *dest_pixmap_priv;
|
||||
int i;
|
||||
uint8_t *drawpixels_src = (uint8_t *) src;
|
||||
RegionPtr clip = fbGetCompositeClip(gc);
|
||||
BoxRec *pbox;
|
||||
int x_off, y_off;
|
||||
Bool ret = FALSE;
|
||||
PixmapPtr dest_pixmap = glamor_get_drawable_pixmap(drawable);
|
||||
glamor_pixmap_private *dest_pixmap_priv;
|
||||
int i;
|
||||
uint8_t *drawpixels_src = (uint8_t *) src;
|
||||
RegionPtr clip = fbGetCompositeClip(gc);
|
||||
BoxRec *pbox;
|
||||
int x_off, y_off;
|
||||
Bool ret = FALSE;
|
||||
|
||||
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
|
||||
glamor_fallback("pixmap has no fbo.\n");
|
||||
goto fail;
|
||||
}
|
||||
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dest_pixmap_priv)) {
|
||||
glamor_fallback("pixmap has no fbo.\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* XXX Shall we set alu here? */
|
||||
if (!glamor_set_planemask(dest_pixmap, gc->planemask))
|
||||
goto fail;
|
||||
/* XXX Shall we set alu here? */
|
||||
if (!glamor_set_planemask(dest_pixmap, gc->planemask))
|
||||
goto fail;
|
||||
|
||||
glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
|
||||
for (i = 0; i < numPoints; i++) {
|
||||
glamor_get_drawable_deltas(drawable, dest_pixmap, &x_off, &y_off);
|
||||
for (i = 0; i < numPoints; i++) {
|
||||
|
||||
int n = REGION_NUM_RECTS(clip);
|
||||
pbox = REGION_RECTS(clip);
|
||||
while (n--) {
|
||||
int x1 = points[i].x;
|
||||
int x2 = x1 + widths[i];
|
||||
int y1 = points[i].y;
|
||||
int n = REGION_NUM_RECTS(clip);
|
||||
|
||||
if (pbox->y1 > points[i].y || pbox->y2 < points[i].y)
|
||||
break;
|
||||
x1 = x1 > pbox->x1 ? x1 : pbox->x1;
|
||||
x2 = x2 < pbox->x2 ? x2 : pbox->x2;
|
||||
if (x1 >= x2)
|
||||
continue;
|
||||
glamor_upload_sub_pixmap_to_texture(dest_pixmap, x1 + x_off, y1 + y_off, x2 - x1, 1,
|
||||
PixmapBytePad(widths[i], drawable->depth),
|
||||
drawpixels_src, 0);
|
||||
}
|
||||
drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
pbox = REGION_RECTS(clip);
|
||||
while (n--) {
|
||||
int x1 = points[i].x;
|
||||
int x2 = x1 + widths[i];
|
||||
int y1 = points[i].y;
|
||||
|
||||
fail:
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
if (pbox->y1 > points[i].y || pbox->y2 < points[i].y)
|
||||
break;
|
||||
x1 = x1 > pbox->x1 ? x1 : pbox->x1;
|
||||
x2 = x2 < pbox->x2 ? x2 : pbox->x2;
|
||||
if (x1 >= x2)
|
||||
continue;
|
||||
glamor_upload_sub_pixmap_to_texture(dest_pixmap, x1 + x_off,
|
||||
y1 + y_off, x2 - x1, 1,
|
||||
PixmapBytePad(widths[i],
|
||||
drawable->depth),
|
||||
drawpixels_src, 0);
|
||||
}
|
||||
drawpixels_src += PixmapBytePad(widths[i], drawable->depth);
|
||||
}
|
||||
ret = TRUE;
|
||||
goto done;
|
||||
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
ret = TRUE;
|
||||
fail:
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(drawable))
|
||||
goto done;
|
||||
|
||||
done:
|
||||
return ret;
|
||||
glamor_fallback("to %p (%c)\n",
|
||||
drawable, glamor_get_drawable_location(drawable));
|
||||
if (glamor_prepare_access(drawable, GLAMOR_ACCESS_RW)) {
|
||||
fbSetSpans(drawable, gc, src, points, widths, numPoints, sorted);
|
||||
glamor_finish_access(drawable, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
ret = TRUE;
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int n, int sorted)
|
||||
DDXPointPtr points, int *widths, int n, int sorted)
|
||||
{
|
||||
_glamor_set_spans(drawable, gc, src, points,
|
||||
widths, n, sorted, TRUE);
|
||||
_glamor_set_spans(drawable, gc, src, points, widths, n, sorted, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_set_spans_nf(DrawablePtr drawable, GCPtr gc, char *src,
|
||||
DDXPointPtr points, int *widths, int n, int sorted)
|
||||
DDXPointPtr points, int *widths, int n, int sorted)
|
||||
{
|
||||
return _glamor_set_spans(drawable, gc, src, points,
|
||||
widths, n, sorted, FALSE);
|
||||
return _glamor_set_spans(drawable, gc, src, points,
|
||||
widths, n, sorted, FALSE);
|
||||
}
|
||||
|
|
|
@ -36,290 +36,276 @@
|
|||
void
|
||||
glamor_init_tile_shader(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
const char *tile_vs =
|
||||
"attribute vec4 v_position;\n"
|
||||
"attribute vec4 v_texcoord0;\n"
|
||||
"varying vec2 tile_texture;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" tile_texture = v_texcoord0.xy;\n" "}\n";
|
||||
const char *tile_fs =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"varying vec2 tile_texture;\n"
|
||||
"uniform sampler2D sampler;\n"
|
||||
"uniform vec2 wh;"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 rel_tex;"
|
||||
" rel_tex = tile_texture * wh; \n"
|
||||
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh); \n"
|
||||
" gl_FragColor = texture2D(sampler, rel_tex);\n"
|
||||
"}\n";
|
||||
GLint fs_prog, vs_prog;
|
||||
GLint sampler_uniform_location;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
const char *tile_vs =
|
||||
"attribute vec4 v_position;\n"
|
||||
"attribute vec4 v_texcoord0;\n"
|
||||
"varying vec2 tile_texture;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" gl_Position = v_position;\n"
|
||||
" tile_texture = v_texcoord0.xy;\n"
|
||||
"}\n";
|
||||
const char *tile_fs =
|
||||
GLAMOR_DEFAULT_PRECISION
|
||||
"varying vec2 tile_texture;\n"
|
||||
"uniform sampler2D sampler;\n"
|
||||
"uniform vec2 wh;"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec2 rel_tex;"
|
||||
" rel_tex = tile_texture * wh; \n"
|
||||
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh); \n"
|
||||
" gl_FragColor = texture2D(sampler, rel_tex);\n"
|
||||
"}\n";
|
||||
GLint fs_prog, vs_prog;
|
||||
GLint sampler_uniform_location;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
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);
|
||||
dispatch->glAttachShader(glamor_priv->tile_prog, vs_prog);
|
||||
dispatch->glAttachShader(glamor_priv->tile_prog, fs_prog);
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
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);
|
||||
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");
|
||||
glamor_link_glsl_prog(dispatch, glamor_priv->tile_prog);
|
||||
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->glUseProgram(glamor_priv->tile_prog);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
sampler_uniform_location =
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog, "sampler");
|
||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||
dispatch->glUniform1i(sampler_uniform_location, 0);
|
||||
|
||||
glamor_priv->tile_wh =
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog,
|
||||
"wh");
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_priv->tile_wh =
|
||||
dispatch->glGetUniformLocation(glamor_priv->tile_prog, "wh");
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
void
|
||||
glamor_fini_tile_shader(ScreenPtr screen)
|
||||
{
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
glamor_screen_private *glamor_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glDeleteProgram(glamor_priv->tile_prog);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
glamor_priv = glamor_get_screen_private(screen);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glDeleteProgram(glamor_priv->tile_prog);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
}
|
||||
|
||||
static void
|
||||
_glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||
int x, int y, int width, int height,
|
||||
int tile_x, int tile_y)
|
||||
int x, int y, int width, int height, int tile_x, int tile_y)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int x1 = x;
|
||||
int x2 = x + width;
|
||||
int y1 = y;
|
||||
int y2 = y + height;
|
||||
int tile_x1 = tile_x;
|
||||
int tile_x2 = tile_x + width;
|
||||
int tile_y1 = tile_y;
|
||||
int tile_y2 = tile_y + height;
|
||||
float vertices[8];
|
||||
float source_texcoords[8];
|
||||
GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
|
||||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_pixmap_private *dst_pixmap_priv;
|
||||
float wh[4];
|
||||
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
||||
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_gl_dispatch *dispatch;
|
||||
int x1 = x;
|
||||
int x2 = x + width;
|
||||
int y1 = y;
|
||||
int y2 = y + height;
|
||||
int tile_x1 = tile_x;
|
||||
int tile_x2 = tile_x + width;
|
||||
int tile_y1 = tile_y;
|
||||
int tile_y2 = tile_y + height;
|
||||
float vertices[8];
|
||||
float source_texcoords[8];
|
||||
GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
|
||||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_pixmap_private *dst_pixmap_priv;
|
||||
float wh[4];
|
||||
|
||||
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
|
||||
pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale,
|
||||
&src_yscale);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
||||
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
|
||||
glamor_pixmap_fbo_fix_wh_ratio(wh, src_pixmap_priv);
|
||||
dispatch->glUniform2fv(glamor_priv->tile_wh, 1, wh);
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D,
|
||||
src_pixmap_priv->base.fbo->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);
|
||||
glamor_set_destination_pixmap_priv_nc(dst_pixmap_priv);
|
||||
pixmap_priv_get_dest_scale(dst_pixmap_priv, &dst_xscale, &dst_yscale);
|
||||
pixmap_priv_get_scale(src_pixmap_priv, &src_xscale, &src_yscale);
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
dispatch->glUseProgram(glamor_priv->tile_prog);
|
||||
|
||||
glamor_pixmap_fbo_fix_wh_ratio(wh, src_pixmap_priv);
|
||||
dispatch->glUniform2fv(glamor_priv->tile_wh, 1, wh);
|
||||
dispatch->glActiveTexture(GL_TEXTURE0);
|
||||
dispatch->glBindTexture(GL_TEXTURE_2D, src_pixmap_priv->base.fbo->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);
|
||||
dispatch->glEnable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
glamor_set_repeat_normalize_tcoords
|
||||
(src_pixmap_priv, RepeatNormal,
|
||||
src_xscale, src_yscale,
|
||||
tile_x1, tile_y1,
|
||||
tile_x2, tile_y2,
|
||||
glamor_priv->yInverted,
|
||||
source_texcoords);
|
||||
glamor_set_repeat_normalize_tcoords
|
||||
(src_pixmap_priv, RepeatNormal,
|
||||
src_xscale, src_yscale,
|
||||
tile_x1, tile_y1,
|
||||
tile_x2, tile_y2, glamor_priv->yInverted, source_texcoords);
|
||||
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float),
|
||||
source_texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
dispatch->glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
|
||||
GL_FLOAT, GL_FALSE,
|
||||
2 * sizeof(float), source_texcoords);
|
||||
dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
|
||||
glamor_set_normalize_vcoords(dst_pixmap_priv, dst_xscale, dst_yscale,
|
||||
x1, y1,
|
||||
x2, y2,
|
||||
glamor_priv->yInverted, vertices);
|
||||
glamor_set_normalize_vcoords(dst_pixmap_priv, dst_xscale, dst_yscale,
|
||||
x1, y1,
|
||||
x2, y2, glamor_priv->yInverted, vertices);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_SOURCE);
|
||||
#ifndef GLAMOR_GLES2
|
||||
dispatch->glDisable(GL_TEXTURE_2D);
|
||||
dispatch->glDisable(GL_TEXTURE_2D);
|
||||
#endif
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||
dispatch->glUseProgram(0);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
|
||||
glamor_priv->state = RENDER_STATE;
|
||||
glamor_priv->render_idle_cnt = 0;
|
||||
glamor_priv->state = RENDER_STATE;
|
||||
glamor_priv->render_idle_cnt = 0;
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||
int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask,
|
||||
int tile_x, int tile_y)
|
||||
int x, int y, int width, int height,
|
||||
unsigned char alu, unsigned long planemask, int tile_x, int tile_y)
|
||||
{
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *dst_pixmap_priv;
|
||||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
ScreenPtr screen = pixmap->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
glamor_pixmap_private *dst_pixmap_priv;
|
||||
glamor_pixmap_private *src_pixmap_priv;
|
||||
glamor_gl_dispatch *dispatch;
|
||||
|
||||
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
||||
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);
|
||||
src_pixmap_priv = glamor_get_pixmap_private(tile);
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
|
||||
return FALSE;
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(dst_pixmap_priv))
|
||||
return FALSE;
|
||||
|
||||
if (glamor_priv->tile_prog == 0) {
|
||||
glamor_fallback("Tiling unsupported\n");
|
||||
goto fail;
|
||||
}
|
||||
if (glamor_priv->tile_prog == 0) {
|
||||
glamor_fallback("Tiling unsupported\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
|
||||
/* XXX dynamic uploading candidate. */
|
||||
glamor_fallback("Non-texture tile pixmap\n");
|
||||
goto fail;
|
||||
}
|
||||
if (!GLAMOR_PIXMAP_PRIV_HAS_FBO(src_pixmap_priv)) {
|
||||
/* XXX dynamic uploading candidate. */
|
||||
glamor_fallback("Non-texture tile pixmap\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
glamor_fallback("unsupported planemask %lx\n", planemask);
|
||||
goto fail;
|
||||
}
|
||||
if (!glamor_set_planemask(pixmap, planemask)) {
|
||||
glamor_fallback("unsupported planemask %lx\n", planemask);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
if (!glamor_set_alu(dispatch, alu)) {
|
||||
glamor_fallback("unsupported alu %x\n", alu);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
goto fail;
|
||||
}
|
||||
dispatch = glamor_get_dispatch(glamor_priv);
|
||||
if (!glamor_set_alu(dispatch, alu)) {
|
||||
glamor_fallback("unsupported alu %x\n", alu);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (dst_pixmap_priv->type == GLAMOR_TEXTURE_LARGE
|
||||
|| src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
glamor_pixmap_clipped_regions *clipped_dst_regions;
|
||||
int n_dst_region, i, j, k;
|
||||
BoxRec box;
|
||||
RegionRec region;
|
||||
if (dst_pixmap_priv->type == GLAMOR_TEXTURE_LARGE
|
||||
|| src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
glamor_pixmap_clipped_regions *clipped_dst_regions;
|
||||
int n_dst_region, i, j, k;
|
||||
BoxRec box;
|
||||
RegionRec region;
|
||||
|
||||
box.x1 = x;
|
||||
box.y1 = y;
|
||||
box.x2 = x + width;
|
||||
box.y2 = y + height;
|
||||
RegionInitBoxes(®ion, &box, 1);
|
||||
clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
|
||||
®ion, &n_dst_region, 0, 0, 0);
|
||||
for(i = 0; i < n_dst_region; i++)
|
||||
{
|
||||
int n_src_region;
|
||||
glamor_pixmap_clipped_regions *clipped_src_regions;
|
||||
BoxPtr current_boxes;
|
||||
int n_current_boxes;
|
||||
box.x1 = x;
|
||||
box.y1 = y;
|
||||
box.x2 = x + width;
|
||||
box.y2 = y + height;
|
||||
RegionInitBoxes(®ion, &box, 1);
|
||||
clipped_dst_regions = glamor_compute_clipped_regions(dst_pixmap_priv,
|
||||
®ion,
|
||||
&n_dst_region, 0,
|
||||
0, 0);
|
||||
for (i = 0; i < n_dst_region; i++) {
|
||||
int n_src_region;
|
||||
glamor_pixmap_clipped_regions *clipped_src_regions;
|
||||
BoxPtr current_boxes;
|
||||
int n_current_boxes;
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv, clipped_dst_regions[i].block_idx);
|
||||
SET_PIXMAP_FBO_CURRENT(dst_pixmap_priv,
|
||||
clipped_dst_regions[i].block_idx);
|
||||
|
||||
if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionTranslate(clipped_dst_regions[i].region,
|
||||
tile_x - x, tile_y - y);
|
||||
DEBUGF("tiled a large src pixmap. %dx%d \n", tile->drawable.width, tile->drawable.height);
|
||||
clipped_src_regions = glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].region,
|
||||
&n_src_region, 1, 0, 0);
|
||||
DEBUGF("got %d src regions %d \n", n_src_region);
|
||||
for (j = 0; j < n_src_region; j++)
|
||||
{
|
||||
if (src_pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
|
||||
RegionTranslate(clipped_dst_regions[i].region,
|
||||
tile_x - x, tile_y - y);
|
||||
DEBUGF("tiled a large src pixmap. %dx%d \n",
|
||||
tile->drawable.width, tile->drawable.height);
|
||||
clipped_src_regions =
|
||||
glamor_compute_clipped_regions(src_pixmap_priv,
|
||||
clipped_dst_regions[i].
|
||||
region, &n_src_region, 1, 0,
|
||||
0);
|
||||
DEBUGF("got %d src regions %d \n", n_src_region);
|
||||
for (j = 0; j < n_src_region; j++) {
|
||||
|
||||
SET_PIXMAP_FBO_CURRENT(src_pixmap_priv, clipped_src_regions[j].block_idx);
|
||||
SET_PIXMAP_FBO_CURRENT(src_pixmap_priv,
|
||||
clipped_src_regions[j].block_idx);
|
||||
|
||||
RegionTranslate(clipped_src_regions[j].region,
|
||||
x - tile_x,
|
||||
y - tile_y);
|
||||
current_boxes = RegionRects(clipped_src_regions[j].region);
|
||||
n_current_boxes = RegionNumRects(clipped_src_regions[j].region);
|
||||
for(k = 0; k < n_current_boxes; k++)
|
||||
{
|
||||
DEBUGF("Tile on %d %d %d %d dst block id %d tile block id %d tilex %d tiley %d\n",
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
current_boxes[k].y2 - current_boxes[k].y1,
|
||||
clipped_dst_regions[i].block_idx,
|
||||
clipped_src_regions[j].block_idx,
|
||||
(tile_x + (current_boxes[k].x1 - x)),
|
||||
tile_y + (current_boxes[k].y1 - y));
|
||||
RegionTranslate(clipped_src_regions[j].region,
|
||||
x - tile_x, y - tile_y);
|
||||
current_boxes = RegionRects(clipped_src_regions[j].region);
|
||||
n_current_boxes =
|
||||
RegionNumRects(clipped_src_regions[j].region);
|
||||
for (k = 0; k < n_current_boxes; k++) {
|
||||
DEBUGF
|
||||
("Tile on %d %d %d %d dst block id %d tile block id %d tilex %d tiley %d\n",
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
current_boxes[k].y2 - current_boxes[k].y1,
|
||||
clipped_dst_regions[i].block_idx,
|
||||
clipped_src_regions[j].block_idx,
|
||||
(tile_x + (current_boxes[k].x1 - x)),
|
||||
tile_y + (current_boxes[k].y1 - y));
|
||||
|
||||
_glamor_tile(pixmap, tile,
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
current_boxes[k].y2 - current_boxes[k].y1,
|
||||
(tile_x + (current_boxes[k].x1 - x)),
|
||||
(tile_y + (current_boxes[k].y1 - y)));
|
||||
}
|
||||
_glamor_tile(pixmap, tile,
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
current_boxes[k].y2 - current_boxes[k].y1,
|
||||
(tile_x + (current_boxes[k].x1 - x)),
|
||||
(tile_y + (current_boxes[k].y1 - y)));
|
||||
}
|
||||
|
||||
RegionDestroy(clipped_src_regions[j].region);
|
||||
}
|
||||
free(clipped_src_regions);
|
||||
} else {
|
||||
current_boxes = RegionRects(clipped_dst_regions[i].region);
|
||||
n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
|
||||
for(k = 0; k < n_current_boxes; k++)
|
||||
{
|
||||
_glamor_tile(pixmap, tile,
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
current_boxes[k].y2 - current_boxes[k].y1,
|
||||
(tile_x + (current_boxes[k].x1 - x)),
|
||||
(tile_y + (current_boxes[k].y1 - y)));
|
||||
}
|
||||
}
|
||||
RegionDestroy(clipped_dst_regions[i].region);
|
||||
}
|
||||
free(clipped_dst_regions);
|
||||
RegionUninit(®ion);
|
||||
}
|
||||
else
|
||||
_glamor_tile(pixmap, tile, x, y, width, height, tile_x, tile_y);
|
||||
RegionDestroy(clipped_src_regions[j].region);
|
||||
}
|
||||
free(clipped_src_regions);
|
||||
}
|
||||
else {
|
||||
current_boxes = RegionRects(clipped_dst_regions[i].region);
|
||||
n_current_boxes = RegionNumRects(clipped_dst_regions[i].region);
|
||||
for (k = 0; k < n_current_boxes; k++) {
|
||||
_glamor_tile(pixmap, tile,
|
||||
current_boxes[k].x1, current_boxes[k].y1,
|
||||
current_boxes[k].x2 - current_boxes[k].x1,
|
||||
current_boxes[k].y2 - current_boxes[k].y1,
|
||||
(tile_x + (current_boxes[k].x1 - x)),
|
||||
(tile_y + (current_boxes[k].y1 - y)));
|
||||
}
|
||||
}
|
||||
RegionDestroy(clipped_dst_regions[i].region);
|
||||
}
|
||||
free(clipped_dst_regions);
|
||||
RegionUninit(®ion);
|
||||
}
|
||||
else
|
||||
_glamor_tile(pixmap, tile, x, y, width, height, tile_x, tile_y);
|
||||
|
||||
glamor_set_alu(dispatch, GXcopy);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
return TRUE;
|
||||
fail:
|
||||
return FALSE;
|
||||
glamor_set_alu(dispatch, GXcopy);
|
||||
glamor_put_dispatch(glamor_priv);
|
||||
return TRUE;
|
||||
fail:
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -30,51 +30,48 @@
|
|||
|
||||
static Bool
|
||||
_glamor_triangles(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris, Bool fallback)
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris,
|
||||
Bool fallback)
|
||||
{
|
||||
if (!fallback
|
||||
&& glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
|
||||
&& (!pSrc->pDrawable
|
||||
|| glamor_ddx_fallback_check_pixmap(pSrc->pDrawable)))
|
||||
return FALSE;
|
||||
if (!fallback && glamor_ddx_fallback_check_pixmap(pDst->pDrawable)
|
||||
&& (!pSrc->pDrawable
|
||||
|| glamor_ddx_fallback_check_pixmap(pSrc->pDrawable)))
|
||||
return FALSE;
|
||||
|
||||
if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_picture(pSrc,
|
||||
GLAMOR_ACCESS_RO)) {
|
||||
if (glamor_prepare_access_picture(pDst, GLAMOR_ACCESS_RW)) {
|
||||
if (glamor_prepare_access_picture(pSrc, GLAMOR_ACCESS_RO)) {
|
||||
|
||||
fbTriangles(op, pSrc, pDst, maskFormat, xSrc,
|
||||
ySrc, ntris, tris);
|
||||
fbTriangles(op, pSrc, pDst, maskFormat, xSrc, ySrc, ntris, tris);
|
||||
|
||||
glamor_finish_access_picture(pSrc, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
glamor_finish_access_picture(pSrc, GLAMOR_ACCESS_RO);
|
||||
}
|
||||
|
||||
glamor_finish_access_picture(pDst, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
return TRUE;
|
||||
glamor_finish_access_picture(pDst, GLAMOR_ACCESS_RW);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_triangles(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
|
||||
{
|
||||
_glamor_triangles(op, pSrc, pDst, maskFormat,
|
||||
xSrc, ySrc, ntris, tris, TRUE);
|
||||
_glamor_triangles(op, pSrc, pDst, maskFormat,
|
||||
xSrc, ySrc, ntris, tris, TRUE);
|
||||
}
|
||||
|
||||
Bool
|
||||
glamor_triangles_nf(CARD8 op,
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
|
||||
PicturePtr pSrc,
|
||||
PicturePtr pDst,
|
||||
PictFormatPtr maskFormat,
|
||||
INT16 xSrc, INT16 ySrc, int ntris, xTriangle * tris)
|
||||
{
|
||||
return _glamor_triangles(op, pSrc, pDst, maskFormat,
|
||||
xSrc, ySrc, ntris, tris, FALSE);
|
||||
return _glamor_triangles(op, pSrc, pDst, maskFormat,
|
||||
xSrc, ySrc, ntris, tris, FALSE);
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -28,76 +28,72 @@
|
|||
* Screen Change Window Attribute implementation.
|
||||
*/
|
||||
|
||||
|
||||
static void
|
||||
glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr * ppPixmap)
|
||||
glamor_fixup_window_pixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
|
||||
{
|
||||
PixmapPtr pPixmap = *ppPixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PixmapPtr pPixmap = *ppPixmap;
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
|
||||
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");
|
||||
}
|
||||
return;
|
||||
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");
|
||||
}
|
||||
return;
|
||||
|
||||
fail:
|
||||
GLAMOR_PANIC
|
||||
(" We can't fall back to fbFixupWindowPixmap, as the fb24_32ReformatTile"
|
||||
" is broken for glamor. \n");
|
||||
fail:
|
||||
GLAMOR_PANIC
|
||||
(" We can't fall back to fbFixupWindowPixmap, as the fb24_32ReformatTile"
|
||||
" is broken for glamor. \n");
|
||||
}
|
||||
|
||||
Bool
|
||||
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);
|
||||
}
|
||||
if (mask & CWBackPixmap) {
|
||||
if (pWin->backgroundState == BackgroundPixmap)
|
||||
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);
|
||||
}
|
||||
return TRUE;
|
||||
if (mask & CWBorderPixmap) {
|
||||
if (pWin->borderIsPixel == FALSE)
|
||||
glamor_fixup_window_pixmap(&pWin->drawable, &pWin->border.pixmap);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
glamor_set_window_pixmap(WindowPtr win, PixmapPtr pPixmap)
|
||||
{
|
||||
ScreenPtr screen = win->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv =
|
||||
glamor_get_screen_private(screen);
|
||||
PixmapPtr old = screen->GetWindowPixmap(win);
|
||||
ScreenPtr screen = win->drawable.pScreen;
|
||||
glamor_screen_private *glamor_priv = glamor_get_screen_private(screen);
|
||||
PixmapPtr old = screen->GetWindowPixmap(win);
|
||||
|
||||
if (pPixmap != old) {
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PicturePtr pic = NULL;
|
||||
if (pPixmap != old) {
|
||||
glamor_pixmap_private *pixmap_priv;
|
||||
PicturePtr pic = NULL;
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(old);
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) && pixmap_priv->base.picture->pDrawable == (DrawablePtr)win) {
|
||||
pic = pixmap_priv->base.picture;
|
||||
pixmap_priv->base.is_picture = 0;
|
||||
pixmap_priv->base.picture = NULL;
|
||||
}
|
||||
pixmap_priv = glamor_get_pixmap_private(old);
|
||||
if (GLAMOR_PIXMAP_PRIV_IS_PICTURE(pixmap_priv) &&
|
||||
pixmap_priv->base.picture->pDrawable == (DrawablePtr) win) {
|
||||
pic = pixmap_priv->base.picture;
|
||||
pixmap_priv->base.is_picture = 0;
|
||||
pixmap_priv->base.picture = NULL;
|
||||
}
|
||||
|
||||
pixmap_priv = glamor_get_pixmap_private(pPixmap);
|
||||
if (pixmap_priv) {
|
||||
pixmap_priv->base.is_picture = !!pic;
|
||||
pixmap_priv->base.picture = pic;
|
||||
}
|
||||
}
|
||||
pixmap_priv = glamor_get_pixmap_private(pPixmap);
|
||||
if (pixmap_priv) {
|
||||
pixmap_priv->base.is_picture = ! !pic;
|
||||
pixmap_priv->base.picture = pic;
|
||||
}
|
||||
}
|
||||
|
||||
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
||||
(screen->SetWindowPixmap)(win, pPixmap);
|
||||
glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
|
||||
screen->SetWindowPixmap = glamor_set_window_pixmap;
|
||||
screen->SetWindowPixmap = glamor_priv->saved_procs.set_window_pixmap;
|
||||
(screen->SetWindowPixmap) (win, pPixmap);
|
||||
glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap;
|
||||
screen->SetWindowPixmap = glamor_set_window_pixmap;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
121
glamor/glapi.h
121
glamor/glapi.h
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 7.1
|
||||
*
|
||||
* Copyright (C) 1999-2008 Brian Paul 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
|
||||
* BRIAN PAUL 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.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* \mainpage Mesa GL API Module
|
||||
*
|
||||
* \section GLAPIIntroduction Introduction
|
||||
*
|
||||
* The Mesa GL API module is responsible for dispatching all the
|
||||
* gl*() functions. All GL functions are dispatched by jumping through
|
||||
* the current dispatch table (basically a struct full of function
|
||||
* pointers.)
|
||||
*
|
||||
* A per-thread current dispatch table and per-thread current context
|
||||
* pointer are managed by this module too.
|
||||
*
|
||||
* This module is intended to be non-Mesa-specific so it can be used
|
||||
* with the X/DRI libGL also.
|
||||
*/
|
||||
|
||||
#ifndef _GLAPI_H
|
||||
#define _GLAPI_H
|
||||
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
|
||||
#if GLAMOR_GLES2
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#else
|
||||
#include <GL/gl.h>
|
||||
#include "GL/glext.h"
|
||||
#endif
|
||||
|
||||
/* Is this needed? It is incomplete anyway. */
|
||||
#ifdef USE_MGL_NAMESPACE
|
||||
#define _glapi_set_dispatch _mglapi_set_dispatch
|
||||
#define _glapi_get_dispatch _mglapi_get_dispatch
|
||||
#define _glapi_set_context _mglapi_set_context
|
||||
#define _glapi_get_context _mglapi_get_context
|
||||
#define _glapi_Dispatch _mglapi_Dispatch
|
||||
#define _glapi_Context _mglapi_Context
|
||||
#endif
|
||||
|
||||
typedef void (*_glapi_proc)(void);
|
||||
struct _glapi_table;
|
||||
|
||||
|
||||
#if defined (GLX_USE_TLS)
|
||||
|
||||
extern __thread struct _glapi_table * _glapi_tls_Dispatch
|
||||
__attribute__((tls_model("initial-exec")));
|
||||
|
||||
extern __thread void * _glapi_tls_Context
|
||||
__attribute__((tls_model("initial-exec")));
|
||||
|
||||
extern const struct _glapi_table *_glapi_Dispatch;
|
||||
extern const void *_glapi_Context;
|
||||
|
||||
# define GET_DISPATCH() _glapi_tls_Dispatch
|
||||
# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_tls_Context
|
||||
# define SET_CURRENT_CONTEXT(C) _glapi_tls_Context = (void*)C
|
||||
|
||||
#else
|
||||
|
||||
extern struct _glapi_table *_glapi_Dispatch;
|
||||
extern void *_glapi_Context;
|
||||
|
||||
# ifdef THREADS
|
||||
|
||||
# define GET_DISPATCH() \
|
||||
(likely(_glapi_Dispatch) ? _glapi_Dispatch : _glapi_get_dispatch())
|
||||
|
||||
# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) \
|
||||
(likely(_glapi_Context) ? _glapi_Context : _glapi_get_context())
|
||||
|
||||
|
||||
# define SET_CURRENT_CONTEXT(C) do { if (likely(_glapi_Context)) \
|
||||
_glapi_Context = (void*)C; \
|
||||
else \
|
||||
_glapi_set_context(C); } while(0)
|
||||
|
||||
# else
|
||||
|
||||
# define GET_DISPATCH() _glapi_Dispatch
|
||||
# define GET_CURRENT_CONTEXT(C) C = (typeof(C)) _glapi_Context
|
||||
# define SET_CURRENT_CONTEXT(C) _glapi_Context = (void*)C
|
||||
|
||||
# endif
|
||||
|
||||
#endif /* defined (GLX_USE_TLS) */
|
||||
|
||||
|
||||
extern void
|
||||
_glapi_set_context(void *context);
|
||||
|
||||
extern void *
|
||||
_glapi_get_context(void);
|
||||
|
||||
#endif
|
|
@ -478,4 +478,7 @@
|
|||
/* Ask fontsproto to make font path element names const */
|
||||
#define FONT_PATH_ELEMENT_NAME_CONST 1
|
||||
|
||||
/* Build GLAMOR */
|
||||
#undef GLAMOR
|
||||
|
||||
#endif /* _DIX_CONFIG_H_ */
|
||||
|
|
Loading…
Reference in New Issue